2 * Copyright 2011 Leiden University. All rights reserved.
7 static __isl_give isl_val
*extract_val(isl_ctx
*ctx
, yaml_document_t
*document
,
10 if (node
->type
!= YAML_SCALAR_NODE
)
11 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
14 return isl_val_read_from_str(ctx
, (char *) node
->data
.scalar
.value
);
17 static __isl_give isl_id
*extract_id(isl_ctx
*ctx
, yaml_document_t
*document
,
20 if (node
->type
!= YAML_SCALAR_NODE
)
21 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
24 return isl_id_alloc(ctx
, (char *) node
->data
.scalar
.value
, NULL
);
27 static __isl_give isl_set
*extract_set(isl_ctx
*ctx
, yaml_document_t
*document
,
30 if (node
->type
!= YAML_SCALAR_NODE
)
31 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
34 return isl_set_read_from_str(ctx
, (char *) node
->data
.scalar
.value
);
37 static __isl_give isl_map
*extract_map(isl_ctx
*ctx
, yaml_document_t
*document
,
40 if (node
->type
!= YAML_SCALAR_NODE
)
41 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
44 return isl_map_read_from_str(ctx
, (char *) node
->data
.scalar
.value
);
47 static __isl_give isl_aff
*extract_aff(isl_ctx
*ctx
,
48 yaml_document_t
*document
, yaml_node_t
*node
)
50 if (node
->type
!= YAML_SCALAR_NODE
)
51 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
54 return isl_aff_read_from_str(ctx
, (char *) node
->data
.scalar
.value
);
57 static __isl_give isl_pw_aff
*extract_pw_aff(isl_ctx
*ctx
,
58 yaml_document_t
*document
, yaml_node_t
*node
)
60 if (node
->type
!= YAML_SCALAR_NODE
)
61 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
64 return isl_pw_aff_read_from_str(ctx
, (char *) node
->data
.scalar
.value
);
67 static __isl_give isl_multi_aff
*extract_multi_aff(isl_ctx
*ctx
,
68 yaml_document_t
*document
, yaml_node_t
*node
)
70 if (node
->type
!= YAML_SCALAR_NODE
)
71 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
74 return isl_multi_aff_read_from_str(ctx
,
75 (char *) node
->data
.scalar
.value
);
78 static __isl_give isl_pw_multi_aff
*extract_pw_multi_aff(isl_ctx
*ctx
,
79 yaml_document_t
*document
, yaml_node_t
*node
)
81 if (node
->type
!= YAML_SCALAR_NODE
)
82 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
85 return isl_pw_multi_aff_read_from_str(ctx
,
86 (char *) node
->data
.scalar
.value
);
89 static int extract_id_list(isl_ctx
*ctx
, yaml_document_t
*document
,
90 yaml_node_t
*node
, std::vector
<isl_id
*> &list
)
92 yaml_node_item_t
*item
;
94 if (node
->type
!= YAML_SEQUENCE_NODE
)
95 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
98 for (item
= node
->data
.sequence
.items
.start
;
99 item
< node
->data
.sequence
.items
.top
; ++item
) {
103 n
= yaml_document_get_node(document
, *item
);
104 id
= extract_id(ctx
, document
, n
);
113 static adg_var
*extract_var(isl_ctx
*ctx
, yaml_document_t
*document
,
117 yaml_node_pair_t
*pair
;
122 if (node
->type
!= YAML_MAPPING_NODE
)
123 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
130 for (pair
= node
->data
.mapping
.pairs
.start
;
131 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
132 yaml_node_t
*key
, *value
;
134 key
= yaml_document_get_node(document
, pair
->key
);
135 value
= yaml_document_get_node(document
, pair
->value
);
137 if (key
->type
!= YAML_SCALAR_NODE
)
138 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
140 if (!strcmp((char *) key
->data
.scalar
.value
, "access"))
141 var
->access
= extract_pw_multi_aff(ctx
, document
, value
);
142 if (!strcmp((char *) key
->data
.scalar
.value
, "type"))
143 var
->type
= extract_id(ctx
, document
, value
);
153 static adg_expr
*extract_expr(isl_ctx
*ctx
, yaml_document_t
*document
,
157 yaml_node_pair_t
*pair
;
162 if (node
->type
!= YAML_MAPPING_NODE
)
163 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
170 for (pair
= node
->data
.mapping
.pairs
.start
;
171 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
172 yaml_node_t
*key
, *value
;
174 key
= yaml_document_get_node(document
, pair
->key
);
175 value
= yaml_document_get_node(document
, pair
->value
);
177 if (key
->type
!= YAML_SCALAR_NODE
)
178 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
180 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
181 expr
->name
= extract_id(ctx
, document
, value
);
182 if (!strcmp((char *) key
->data
.scalar
.value
, "expr"))
183 expr
->expr
= extract_pw_aff(ctx
, document
, value
);
193 static int extract_var_list(isl_ctx
*ctx
, yaml_document_t
*document
,
194 yaml_node_t
*node
, std::vector
<adg_var
*> &list
)
196 yaml_node_item_t
*item
;
198 if (node
->type
!= YAML_SEQUENCE_NODE
)
199 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
202 for (item
= node
->data
.sequence
.items
.start
;
203 item
< node
->data
.sequence
.items
.top
; ++item
) {
207 n
= yaml_document_get_node(document
, *item
);
208 var
= extract_var(ctx
, document
, n
);
217 static enum adg_arg_type
extract_arg_type(isl_ctx
*ctx
,
218 yaml_document_t
*document
, yaml_node_t
*node
)
220 if (node
->type
!= YAML_SCALAR_NODE
)
221 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
222 return adg_arg_unknown
);
224 if (!strcmp((char *) node
->data
.scalar
.value
, "value"))
225 return adg_arg_value
;
226 if (!strcmp((char *) node
->data
.scalar
.value
, "reference"))
227 return adg_arg_reference
;
228 if (!strcmp((char *) node
->data
.scalar
.value
, "return"))
229 return adg_arg_return
;
231 return adg_arg_unknown
;
234 static adg_arg
*extract_arg(isl_ctx
*ctx
, yaml_document_t
*document
,
238 yaml_node_pair_t
*pair
;
243 if (node
->type
!= YAML_MAPPING_NODE
)
244 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
251 for (pair
= node
->data
.mapping
.pairs
.start
;
252 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
253 yaml_node_t
*key
, *value
;
255 key
= yaml_document_get_node(document
, pair
->key
);
256 value
= yaml_document_get_node(document
, pair
->value
);
258 if (key
->type
!= YAML_SCALAR_NODE
)
259 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
261 if (!strcmp((char *) key
->data
.scalar
.value
, "var"))
262 arg
->var
= extract_var(ctx
, document
, value
);
263 if (!strcmp((char *) key
->data
.scalar
.value
, "type"))
264 arg
->type
= extract_arg_type(ctx
, document
, value
);
274 static int extract_arg_list(isl_ctx
*ctx
, yaml_document_t
*document
,
275 yaml_node_t
*node
, std::vector
<adg_arg
*> &list
)
277 yaml_node_item_t
*item
;
279 if (node
->type
!= YAML_SEQUENCE_NODE
)
280 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
283 for (item
= node
->data
.sequence
.items
.start
;
284 item
< node
->data
.sequence
.items
.top
; ++item
) {
288 n
= yaml_document_get_node(document
, *item
);
289 arg
= extract_arg(ctx
, document
, n
);
298 static int extract_expr_list(isl_ctx
*ctx
, yaml_document_t
*document
,
299 yaml_node_t
*node
, std::vector
<adg_expr
*> &list
)
301 yaml_node_item_t
*item
;
303 if (node
->type
!= YAML_SEQUENCE_NODE
)
304 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
307 for (item
= node
->data
.sequence
.items
.start
;
308 item
< node
->data
.sequence
.items
.top
; ++item
) {
312 n
= yaml_document_get_node(document
, *item
);
313 expr
= extract_expr(ctx
, document
, n
);
316 list
.push_back(expr
);
322 static adg_domain
*extract_domain(isl_ctx
*ctx
, yaml_document_t
*document
,
326 yaml_node_pair_t
*pair
;
331 if (node
->type
!= YAML_MAPPING_NODE
)
332 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
335 domain
= new adg_domain
;
339 for (pair
= node
->data
.mapping
.pairs
.start
;
340 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
341 yaml_node_t
*key
, *value
;
343 key
= yaml_document_get_node(document
, pair
->key
);
344 value
= yaml_document_get_node(document
, pair
->value
);
346 if (key
->type
!= YAML_SCALAR_NODE
)
347 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
349 if (!strcmp((char *) key
->data
.scalar
.value
, "bounds"))
350 domain
->bounds
= extract_set(ctx
, document
, value
);
351 if (!strcmp((char *) key
->data
.scalar
.value
, "controls") &&
352 extract_expr_list(ctx
, document
, value
, domain
->controls
) < 0)
354 if (!strcmp((char *) key
->data
.scalar
.value
, "filters") &&
355 extract_var_list(ctx
, document
, value
, domain
->filters
) < 0)
366 static adg_function
*extract_function(isl_ctx
*ctx
, yaml_document_t
*document
,
370 yaml_node_pair_t
*pair
;
375 if (node
->type
!= YAML_MAPPING_NODE
)
376 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
379 fn
= new adg_function
;
383 for (pair
= node
->data
.mapping
.pairs
.start
;
384 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
385 yaml_node_t
*key
, *value
;
387 key
= yaml_document_get_node(document
, pair
->key
);
388 value
= yaml_document_get_node(document
, pair
->value
);
390 if (key
->type
!= YAML_SCALAR_NODE
)
391 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
393 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
394 fn
->name
= extract_id(ctx
, document
, value
);
395 if (!strcmp((char *) key
->data
.scalar
.value
, "in") &&
396 extract_arg_list(ctx
, document
, value
, fn
->in
) < 0)
398 if (!strcmp((char *) key
->data
.scalar
.value
, "out") &&
399 extract_arg_list(ctx
, document
, value
, fn
->out
) < 0)
401 if (!strcmp((char *) key
->data
.scalar
.value
, "ctrl") &&
402 extract_expr_list(ctx
, document
, value
, fn
->ctrl
) < 0)
404 if (!strcmp((char *) key
->data
.scalar
.value
, "domain"))
405 fn
->domain
= extract_domain(ctx
, document
, value
);
415 static adg_port
*extract_port(isl_ctx
*ctx
, yaml_document_t
*document
,
419 yaml_node_pair_t
*pair
;
424 if (node
->type
!= YAML_MAPPING_NODE
)
425 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
432 for (pair
= node
->data
.mapping
.pairs
.start
;
433 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
434 yaml_node_t
*key
, *value
;
436 key
= yaml_document_get_node(document
, pair
->key
);
437 value
= yaml_document_get_node(document
, pair
->value
);
439 if (key
->type
!= YAML_SCALAR_NODE
)
440 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
442 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
443 port
->name
= extract_id(ctx
, document
, value
);
444 if (!strcmp((char *) key
->data
.scalar
.value
, "node"))
445 port
->node_name
= extract_id(ctx
, document
, value
);
446 if (!strcmp((char *) key
->data
.scalar
.value
, "edge"))
447 port
->edge_name
= extract_id(ctx
, document
, value
);
448 if (!strcmp((char *) key
->data
.scalar
.value
, "vars") &&
449 extract_var_list(ctx
, document
, value
, port
->vars
) < 0)
451 if (!strcmp((char *) key
->data
.scalar
.value
, "domain"))
452 port
->domain
= extract_domain(ctx
, document
, value
);
462 static int extract_port_list(isl_ctx
*ctx
, yaml_document_t
*document
,
463 yaml_node_t
*node
, std::vector
<adg_port
*> &list
)
465 yaml_node_item_t
*item
;
467 if (node
->type
!= YAML_SEQUENCE_NODE
)
468 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
471 for (item
= node
->data
.sequence
.items
.start
;
472 item
< node
->data
.sequence
.items
.top
; ++item
) {
476 n
= yaml_document_get_node(document
, *item
);
477 port
= extract_port(ctx
, document
, n
);
480 list
.push_back(port
);
486 static adg_gate
*extract_gate(isl_ctx
*ctx
, yaml_document_t
*document
,
490 yaml_node_pair_t
*pair
;
495 if (node
->type
!= YAML_MAPPING_NODE
)
496 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
503 for (pair
= node
->data
.mapping
.pairs
.start
;
504 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
505 yaml_node_t
*key
, *value
;
507 key
= yaml_document_get_node(document
, pair
->key
);
508 value
= yaml_document_get_node(document
, pair
->value
);
510 if (key
->type
!= YAML_SCALAR_NODE
)
511 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
513 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
514 gate
->name
= extract_id(ctx
, document
, value
);
515 if (!strcmp((char *) key
->data
.scalar
.value
, "node"))
516 gate
->node_name
= extract_id(ctx
, document
, value
);
517 if (!strcmp((char *) key
->data
.scalar
.value
, "in"))
518 gate
->in
= extract_var(ctx
, document
, value
);
519 if (!strcmp((char *) key
->data
.scalar
.value
, "out"))
520 gate
->out
= extract_var(ctx
, document
, value
);
521 if (!strcmp((char *) key
->data
.scalar
.value
, "domain"))
522 gate
->domain
= extract_domain(ctx
, document
, value
);
532 static int extract_gate_list(isl_ctx
*ctx
, yaml_document_t
*document
,
533 yaml_node_t
*node
, std::vector
<adg_gate
*> &list
)
535 yaml_node_item_t
*item
;
537 if (node
->type
!= YAML_SEQUENCE_NODE
)
538 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
541 for (item
= node
->data
.sequence
.items
.start
;
542 item
< node
->data
.sequence
.items
.top
; ++item
) {
546 n
= yaml_document_get_node(document
, *item
);
547 gate
= extract_gate(ctx
, document
, n
);
550 list
.push_back(gate
);
556 static adg_node
*extract_node(isl_ctx
*ctx
, yaml_document_t
*document
,
560 yaml_node_pair_t
*pair
;
565 if (node
->type
!= YAML_MAPPING_NODE
)
566 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
569 anode
= new adg_node
;
573 for (pair
= node
->data
.mapping
.pairs
.start
;
574 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
575 yaml_node_t
*key
, *value
;
577 key
= yaml_document_get_node(document
, pair
->key
);
578 value
= yaml_document_get_node(document
, pair
->value
);
580 if (key
->type
!= YAML_SCALAR_NODE
)
581 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
583 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
584 anode
->name
= extract_id(ctx
, document
, value
);
585 if (!strcmp((char *) key
->data
.scalar
.value
, "function"))
586 anode
->function
= extract_function(ctx
, document
, value
);
587 if (!strcmp((char *) key
->data
.scalar
.value
, "domain"))
588 anode
->domain
= extract_domain(ctx
, document
, value
);
589 if (!strcmp((char *) key
->data
.scalar
.value
, "schedule"))
590 anode
->schedule
= extract_map(ctx
, document
, value
);
591 if (!strcmp((char *) key
->data
.scalar
.value
, "input_ports") &&
592 extract_port_list(ctx
, document
, value
,
593 anode
->input_ports
) < 0)
595 if (!strcmp((char *) key
->data
.scalar
.value
, "output_ports") &&
596 extract_port_list(ctx
, document
, value
,
597 anode
->output_ports
) < 0)
599 if (!strcmp((char *) key
->data
.scalar
.value
, "gates") &&
600 extract_gate_list(ctx
, document
, value
, anode
->gates
) < 0)
602 if (!strcmp((char *) key
->data
.scalar
.value
, "expressions") &&
603 extract_expr_list(ctx
, document
, value
,
604 anode
->expressions
) < 0)
615 static int extract_node_list(isl_ctx
*ctx
, yaml_document_t
*document
,
616 yaml_node_t
*node
, std::vector
<adg_node
*> &list
)
618 yaml_node_item_t
*item
;
620 if (node
->type
!= YAML_SEQUENCE_NODE
)
621 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
624 for (item
= node
->data
.sequence
.items
.start
;
625 item
< node
->data
.sequence
.items
.top
; ++item
) {
629 n
= yaml_document_get_node(document
, *item
);
630 node
= extract_node(ctx
, document
, n
);
633 list
.push_back(node
);
639 static enum adg_edge_type
extract_type(isl_ctx
*ctx
,
640 yaml_document_t
*document
, yaml_node_t
*node
)
642 if (node
->type
!= YAML_SCALAR_NODE
)
643 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
644 return adg_edge_error
);
646 if (!strcmp((char *) node
->data
.scalar
.value
, "fifo"))
647 return adg_edge_fifo
;
648 if (!strcmp((char *) node
->data
.scalar
.value
, "sticky fifo"))
649 return adg_edge_sticky_fifo
;
650 if (!strcmp((char *) node
->data
.scalar
.value
, "shift register"))
651 return adg_edge_shift_register
;
652 if (!strcmp((char *) node
->data
.scalar
.value
, "broadcast"))
653 return adg_edge_broadcast
;
654 if (!strcmp((char *) node
->data
.scalar
.value
, "generic"))
655 return adg_edge_generic
;
657 return adg_edge_error
;
660 static adg_edge
*extract_edge(isl_ctx
*ctx
, yaml_document_t
*document
,
664 yaml_node_pair_t
*pair
;
669 if (node
->type
!= YAML_MAPPING_NODE
)
670 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
677 for (pair
= node
->data
.mapping
.pairs
.start
;
678 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
679 yaml_node_t
*key
, *value
;
681 key
= yaml_document_get_node(document
, pair
->key
);
682 value
= yaml_document_get_node(document
, pair
->value
);
684 if (key
->type
!= YAML_SCALAR_NODE
)
685 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
687 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
688 edge
->name
= extract_id(ctx
, document
, value
);
689 if (!strcmp((char *) key
->data
.scalar
.value
, "map"))
690 edge
->map
= extract_multi_aff(ctx
, document
, value
);
691 if (!strcmp((char *) key
->data
.scalar
.value
, "from_node"))
692 edge
->from_node_name
= extract_id(ctx
, document
, value
);
693 if (!strcmp((char *) key
->data
.scalar
.value
, "from_port"))
694 edge
->from_port_name
= extract_id(ctx
, document
, value
);
695 if (!strcmp((char *) key
->data
.scalar
.value
, "to_node"))
696 edge
->to_node_name
= extract_id(ctx
, document
, value
);
697 if (!strcmp((char *) key
->data
.scalar
.value
, "to_port"))
698 edge
->to_port_name
= extract_id(ctx
, document
, value
);
699 if (!strcmp((char *) key
->data
.scalar
.value
, "value_size"))
700 edge
->value_size
= extract_val(ctx
, document
, value
);
701 if (!strcmp((char *) key
->data
.scalar
.value
, "type"))
702 edge
->type
= extract_type(ctx
, document
, value
);
712 static int extract_edge_list(isl_ctx
*ctx
, yaml_document_t
*document
,
713 yaml_node_t
*node
, std::vector
<adg_edge
*> &list
)
715 yaml_node_item_t
*item
;
717 if (node
->type
!= YAML_SEQUENCE_NODE
)
718 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
721 for (item
= node
->data
.sequence
.items
.start
;
722 item
< node
->data
.sequence
.items
.top
; ++item
) {
726 n
= yaml_document_get_node(document
, *item
);
727 edge
= extract_edge(ctx
, document
, n
);
730 list
.push_back(edge
);
736 static adg_param
*extract_param(isl_ctx
*ctx
, yaml_document_t
*document
,
740 yaml_node_pair_t
*pair
;
745 if (node
->type
!= YAML_MAPPING_NODE
)
746 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
749 param
= new adg_param
;
753 for (pair
= node
->data
.mapping
.pairs
.start
;
754 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
755 yaml_node_t
*key
, *value
;
757 key
= yaml_document_get_node(document
, pair
->key
);
758 value
= yaml_document_get_node(document
, pair
->value
);
760 if (key
->type
!= YAML_SCALAR_NODE
)
761 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
763 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
764 param
->name
= extract_id(ctx
, document
, value
);
765 if (!strcmp((char *) key
->data
.scalar
.value
, "lb"))
766 param
->lb
= extract_aff(ctx
, document
, value
);
767 if (!strcmp((char *) key
->data
.scalar
.value
, "ub"))
768 param
->ub
= extract_aff(ctx
, document
, value
);
769 if (!strcmp((char *) key
->data
.scalar
.value
, "val"))
770 param
->val
= extract_aff(ctx
, document
, value
);
780 static int extract_param_list(isl_ctx
*ctx
, yaml_document_t
*document
,
781 yaml_node_t
*node
, std::vector
<adg_param
*> &list
)
783 yaml_node_item_t
*item
;
785 if (node
->type
!= YAML_SEQUENCE_NODE
)
786 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
789 for (item
= node
->data
.sequence
.items
.start
;
790 item
< node
->data
.sequence
.items
.top
; ++item
) {
794 n
= yaml_document_get_node(document
, *item
);
795 param
= extract_param(ctx
, document
, n
);
798 list
.push_back(param
);
804 static adg
*extract_adg(isl_ctx
*ctx
, yaml_document_t
*document
,
808 yaml_node_pair_t
*pair
;
813 if (node
->type
!= YAML_MAPPING_NODE
)
814 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
821 for (pair
= node
->data
.mapping
.pairs
.start
;
822 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
823 yaml_node_t
*key
, *value
;
825 key
= yaml_document_get_node(document
, pair
->key
);
826 value
= yaml_document_get_node(document
, pair
->value
);
828 if (key
->type
!= YAML_SCALAR_NODE
)
829 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
831 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
832 adg
->name
= extract_id(ctx
, document
, value
);
833 if (!strcmp((char *) key
->data
.scalar
.value
, "context"))
834 adg
->context
= extract_set(ctx
, document
, value
);
835 if (!strcmp((char *) key
->data
.scalar
.value
, "iterator_map"))
836 adg
->iterator_map
= extract_map(ctx
, document
, value
);
837 if (!strcmp((char *) key
->data
.scalar
.value
, "iterators") &&
838 extract_id_list(ctx
, document
, value
, adg
->iterators
) < 0)
840 if (!strcmp((char *) key
->data
.scalar
.value
, "all_iterators") &&
841 extract_id_list(ctx
, document
, value
, adg
->all_iterators
) < 0)
843 if (!strcmp((char *) key
->data
.scalar
.value
, "nodes") &&
844 extract_node_list(ctx
, document
, value
, adg
->nodes
) < 0)
846 if (!strcmp((char *) key
->data
.scalar
.value
, "edges") &&
847 extract_edge_list(ctx
, document
, value
, adg
->edges
) < 0)
849 if (!strcmp((char *) key
->data
.scalar
.value
, "params") &&
850 extract_param_list(ctx
, document
, value
, adg
->params
) < 0)
861 /* Extract an adg from the YAML description in "in".
863 adg
*adg_parse(isl_ctx
*ctx
, FILE *in
)
866 yaml_parser_t parser
;
868 yaml_document_t document
= { 0 };
870 yaml_parser_initialize(&parser
);
872 yaml_parser_set_input_file(&parser
, in
);
874 if (!yaml_parser_load(&parser
, &document
))
877 root
= yaml_document_get_root_node(&document
);
879 adg
= extract_adg(ctx
, &document
, root
);
881 yaml_document_delete(&document
);
883 yaml_parser_delete(&parser
);
887 yaml_parser_delete(&parser
);