2 * Copyright 2011 Leiden University. All rights reserved.
7 static int extract_isl_int(isl_ctx
*ctx
, yaml_document_t
*document
,
8 yaml_node_t
*node
, isl_int
&v
)
10 if (node
->type
!= YAML_SCALAR_NODE
)
11 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
14 isl_int_read(v
, (char *) node
->data
.scalar
.value
);
19 static __isl_give isl_id
*extract_id(isl_ctx
*ctx
, yaml_document_t
*document
,
22 if (node
->type
!= YAML_SCALAR_NODE
)
23 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
26 return isl_id_alloc(ctx
, (char *) node
->data
.scalar
.value
, NULL
);
29 static __isl_give isl_set
*extract_set(isl_ctx
*ctx
, yaml_document_t
*document
,
32 if (node
->type
!= YAML_SCALAR_NODE
)
33 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
36 return isl_set_read_from_str(ctx
, (char *) node
->data
.scalar
.value
);
39 static __isl_give isl_map
*extract_map(isl_ctx
*ctx
, yaml_document_t
*document
,
42 if (node
->type
!= YAML_SCALAR_NODE
)
43 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
46 return isl_map_read_from_str(ctx
, (char *) node
->data
.scalar
.value
);
49 static __isl_give isl_aff
*extract_aff(isl_ctx
*ctx
,
50 yaml_document_t
*document
, yaml_node_t
*node
)
52 if (node
->type
!= YAML_SCALAR_NODE
)
53 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
56 return isl_aff_read_from_str(ctx
, (char *) node
->data
.scalar
.value
);
59 static __isl_give isl_pw_aff
*extract_pw_aff(isl_ctx
*ctx
,
60 yaml_document_t
*document
, yaml_node_t
*node
)
62 if (node
->type
!= YAML_SCALAR_NODE
)
63 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
66 return isl_pw_aff_read_from_str(ctx
, (char *) node
->data
.scalar
.value
);
69 static __isl_give isl_multi_aff
*extract_multi_aff(isl_ctx
*ctx
,
70 yaml_document_t
*document
, yaml_node_t
*node
)
72 if (node
->type
!= YAML_SCALAR_NODE
)
73 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
76 return isl_multi_aff_read_from_str(ctx
,
77 (char *) node
->data
.scalar
.value
);
80 static __isl_give isl_pw_multi_aff
*extract_pw_multi_aff(isl_ctx
*ctx
,
81 yaml_document_t
*document
, yaml_node_t
*node
)
83 if (node
->type
!= YAML_SCALAR_NODE
)
84 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
87 return isl_pw_multi_aff_read_from_str(ctx
,
88 (char *) node
->data
.scalar
.value
);
91 static int extract_id_list(isl_ctx
*ctx
, yaml_document_t
*document
,
92 yaml_node_t
*node
, std::vector
<isl_id
*> &list
)
94 yaml_node_item_t
*item
;
96 if (node
->type
!= YAML_SEQUENCE_NODE
)
97 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
100 for (item
= node
->data
.sequence
.items
.start
;
101 item
< node
->data
.sequence
.items
.top
; ++item
) {
105 n
= yaml_document_get_node(document
, *item
);
106 id
= extract_id(ctx
, document
, n
);
115 static adg_var
*extract_var(isl_ctx
*ctx
, yaml_document_t
*document
,
119 yaml_node_pair_t
*pair
;
124 if (node
->type
!= YAML_MAPPING_NODE
)
125 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
132 for (pair
= node
->data
.mapping
.pairs
.start
;
133 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
134 yaml_node_t
*key
, *value
;
136 key
= yaml_document_get_node(document
, pair
->key
);
137 value
= yaml_document_get_node(document
, pair
->value
);
139 if (key
->type
!= YAML_SCALAR_NODE
)
140 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
142 if (!strcmp((char *) key
->data
.scalar
.value
, "access"))
143 var
->access
= extract_pw_multi_aff(ctx
, document
, value
);
144 if (!strcmp((char *) key
->data
.scalar
.value
, "type"))
145 var
->type
= extract_id(ctx
, document
, value
);
155 static adg_expr
*extract_expr(isl_ctx
*ctx
, yaml_document_t
*document
,
159 yaml_node_pair_t
*pair
;
164 if (node
->type
!= YAML_MAPPING_NODE
)
165 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
172 for (pair
= node
->data
.mapping
.pairs
.start
;
173 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
174 yaml_node_t
*key
, *value
;
176 key
= yaml_document_get_node(document
, pair
->key
);
177 value
= yaml_document_get_node(document
, pair
->value
);
179 if (key
->type
!= YAML_SCALAR_NODE
)
180 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
182 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
183 expr
->name
= extract_id(ctx
, document
, value
);
184 if (!strcmp((char *) key
->data
.scalar
.value
, "expr"))
185 expr
->expr
= extract_pw_aff(ctx
, document
, value
);
195 static int extract_var_list(isl_ctx
*ctx
, yaml_document_t
*document
,
196 yaml_node_t
*node
, std::vector
<adg_var
*> &list
)
198 yaml_node_item_t
*item
;
200 if (node
->type
!= YAML_SEQUENCE_NODE
)
201 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
204 for (item
= node
->data
.sequence
.items
.start
;
205 item
< node
->data
.sequence
.items
.top
; ++item
) {
209 n
= yaml_document_get_node(document
, *item
);
210 var
= extract_var(ctx
, document
, n
);
219 static enum adg_arg_type
extract_arg_type(isl_ctx
*ctx
,
220 yaml_document_t
*document
, yaml_node_t
*node
)
222 if (node
->type
!= YAML_SCALAR_NODE
)
223 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
224 return adg_arg_unknown
);
226 if (!strcmp((char *) node
->data
.scalar
.value
, "value"))
227 return adg_arg_value
;
228 if (!strcmp((char *) node
->data
.scalar
.value
, "reference"))
229 return adg_arg_reference
;
230 if (!strcmp((char *) node
->data
.scalar
.value
, "return"))
231 return adg_arg_return
;
233 return adg_arg_unknown
;
236 static adg_arg
*extract_arg(isl_ctx
*ctx
, yaml_document_t
*document
,
240 yaml_node_pair_t
*pair
;
245 if (node
->type
!= YAML_MAPPING_NODE
)
246 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
253 for (pair
= node
->data
.mapping
.pairs
.start
;
254 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
255 yaml_node_t
*key
, *value
;
257 key
= yaml_document_get_node(document
, pair
->key
);
258 value
= yaml_document_get_node(document
, pair
->value
);
260 if (key
->type
!= YAML_SCALAR_NODE
)
261 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
263 if (!strcmp((char *) key
->data
.scalar
.value
, "var"))
264 arg
->var
= extract_var(ctx
, document
, value
);
265 if (!strcmp((char *) key
->data
.scalar
.value
, "type"))
266 arg
->type
= extract_arg_type(ctx
, document
, value
);
276 static int extract_arg_list(isl_ctx
*ctx
, yaml_document_t
*document
,
277 yaml_node_t
*node
, std::vector
<adg_arg
*> &list
)
279 yaml_node_item_t
*item
;
281 if (node
->type
!= YAML_SEQUENCE_NODE
)
282 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
285 for (item
= node
->data
.sequence
.items
.start
;
286 item
< node
->data
.sequence
.items
.top
; ++item
) {
290 n
= yaml_document_get_node(document
, *item
);
291 arg
= extract_arg(ctx
, document
, n
);
300 static int extract_expr_list(isl_ctx
*ctx
, yaml_document_t
*document
,
301 yaml_node_t
*node
, std::vector
<adg_expr
*> &list
)
303 yaml_node_item_t
*item
;
305 if (node
->type
!= YAML_SEQUENCE_NODE
)
306 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
309 for (item
= node
->data
.sequence
.items
.start
;
310 item
< node
->data
.sequence
.items
.top
; ++item
) {
314 n
= yaml_document_get_node(document
, *item
);
315 expr
= extract_expr(ctx
, document
, n
);
318 list
.push_back(expr
);
324 static adg_domain
*extract_domain(isl_ctx
*ctx
, yaml_document_t
*document
,
328 yaml_node_pair_t
*pair
;
333 if (node
->type
!= YAML_MAPPING_NODE
)
334 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
337 domain
= new adg_domain
;
341 for (pair
= node
->data
.mapping
.pairs
.start
;
342 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
343 yaml_node_t
*key
, *value
;
345 key
= yaml_document_get_node(document
, pair
->key
);
346 value
= yaml_document_get_node(document
, pair
->value
);
348 if (key
->type
!= YAML_SCALAR_NODE
)
349 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
351 if (!strcmp((char *) key
->data
.scalar
.value
, "bounds"))
352 domain
->bounds
= extract_set(ctx
, document
, value
);
353 if (!strcmp((char *) key
->data
.scalar
.value
, "controls") &&
354 extract_expr_list(ctx
, document
, value
, domain
->controls
) < 0)
356 if (!strcmp((char *) key
->data
.scalar
.value
, "filters") &&
357 extract_var_list(ctx
, document
, value
, domain
->filters
) < 0)
368 static adg_function
*extract_function(isl_ctx
*ctx
, yaml_document_t
*document
,
372 yaml_node_pair_t
*pair
;
377 if (node
->type
!= YAML_MAPPING_NODE
)
378 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
381 fn
= new adg_function
;
385 for (pair
= node
->data
.mapping
.pairs
.start
;
386 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
387 yaml_node_t
*key
, *value
;
389 key
= yaml_document_get_node(document
, pair
->key
);
390 value
= yaml_document_get_node(document
, pair
->value
);
392 if (key
->type
!= YAML_SCALAR_NODE
)
393 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
395 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
396 fn
->name
= extract_id(ctx
, document
, value
);
397 if (!strcmp((char *) key
->data
.scalar
.value
, "in") &&
398 extract_arg_list(ctx
, document
, value
, fn
->in
) < 0)
400 if (!strcmp((char *) key
->data
.scalar
.value
, "out") &&
401 extract_arg_list(ctx
, document
, value
, fn
->out
) < 0)
403 if (!strcmp((char *) key
->data
.scalar
.value
, "ctrl") &&
404 extract_expr_list(ctx
, document
, value
, fn
->ctrl
) < 0)
406 if (!strcmp((char *) key
->data
.scalar
.value
, "domain"))
407 fn
->domain
= extract_domain(ctx
, document
, value
);
417 static adg_port
*extract_port(isl_ctx
*ctx
, yaml_document_t
*document
,
421 yaml_node_pair_t
*pair
;
426 if (node
->type
!= YAML_MAPPING_NODE
)
427 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
434 for (pair
= node
->data
.mapping
.pairs
.start
;
435 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
436 yaml_node_t
*key
, *value
;
438 key
= yaml_document_get_node(document
, pair
->key
);
439 value
= yaml_document_get_node(document
, pair
->value
);
441 if (key
->type
!= YAML_SCALAR_NODE
)
442 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
444 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
445 port
->name
= extract_id(ctx
, document
, value
);
446 if (!strcmp((char *) key
->data
.scalar
.value
, "node"))
447 port
->node_name
= extract_id(ctx
, document
, value
);
448 if (!strcmp((char *) key
->data
.scalar
.value
, "edge"))
449 port
->edge_name
= extract_id(ctx
, document
, value
);
450 if (!strcmp((char *) key
->data
.scalar
.value
, "vars") &&
451 extract_var_list(ctx
, document
, value
, port
->vars
) < 0)
453 if (!strcmp((char *) key
->data
.scalar
.value
, "domain"))
454 port
->domain
= extract_domain(ctx
, document
, value
);
464 static int extract_port_list(isl_ctx
*ctx
, yaml_document_t
*document
,
465 yaml_node_t
*node
, std::vector
<adg_port
*> &list
)
467 yaml_node_item_t
*item
;
469 if (node
->type
!= YAML_SEQUENCE_NODE
)
470 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
473 for (item
= node
->data
.sequence
.items
.start
;
474 item
< node
->data
.sequence
.items
.top
; ++item
) {
478 n
= yaml_document_get_node(document
, *item
);
479 port
= extract_port(ctx
, document
, n
);
482 list
.push_back(port
);
488 static adg_gate
*extract_gate(isl_ctx
*ctx
, yaml_document_t
*document
,
492 yaml_node_pair_t
*pair
;
497 if (node
->type
!= YAML_MAPPING_NODE
)
498 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
505 for (pair
= node
->data
.mapping
.pairs
.start
;
506 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
507 yaml_node_t
*key
, *value
;
509 key
= yaml_document_get_node(document
, pair
->key
);
510 value
= yaml_document_get_node(document
, pair
->value
);
512 if (key
->type
!= YAML_SCALAR_NODE
)
513 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
515 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
516 gate
->name
= extract_id(ctx
, document
, value
);
517 if (!strcmp((char *) key
->data
.scalar
.value
, "node"))
518 gate
->node_name
= extract_id(ctx
, document
, value
);
519 if (!strcmp((char *) key
->data
.scalar
.value
, "in"))
520 gate
->in
= extract_var(ctx
, document
, value
);
521 if (!strcmp((char *) key
->data
.scalar
.value
, "out"))
522 gate
->out
= extract_var(ctx
, document
, value
);
523 if (!strcmp((char *) key
->data
.scalar
.value
, "domain"))
524 gate
->domain
= extract_domain(ctx
, document
, value
);
534 static int extract_gate_list(isl_ctx
*ctx
, yaml_document_t
*document
,
535 yaml_node_t
*node
, std::vector
<adg_gate
*> &list
)
537 yaml_node_item_t
*item
;
539 if (node
->type
!= YAML_SEQUENCE_NODE
)
540 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
543 for (item
= node
->data
.sequence
.items
.start
;
544 item
< node
->data
.sequence
.items
.top
; ++item
) {
548 n
= yaml_document_get_node(document
, *item
);
549 gate
= extract_gate(ctx
, document
, n
);
552 list
.push_back(gate
);
558 static adg_node
*extract_node(isl_ctx
*ctx
, yaml_document_t
*document
,
562 yaml_node_pair_t
*pair
;
567 if (node
->type
!= YAML_MAPPING_NODE
)
568 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
571 anode
= new adg_node
;
575 for (pair
= node
->data
.mapping
.pairs
.start
;
576 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
577 yaml_node_t
*key
, *value
;
579 key
= yaml_document_get_node(document
, pair
->key
);
580 value
= yaml_document_get_node(document
, pair
->value
);
582 if (key
->type
!= YAML_SCALAR_NODE
)
583 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
585 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
586 anode
->name
= extract_id(ctx
, document
, value
);
587 if (!strcmp((char *) key
->data
.scalar
.value
, "function"))
588 anode
->function
= extract_function(ctx
, document
, value
);
589 if (!strcmp((char *) key
->data
.scalar
.value
, "domain"))
590 anode
->domain
= extract_domain(ctx
, document
, value
);
591 if (!strcmp((char *) key
->data
.scalar
.value
, "schedule"))
592 anode
->schedule
= extract_map(ctx
, document
, value
);
593 if (!strcmp((char *) key
->data
.scalar
.value
, "input_ports") &&
594 extract_port_list(ctx
, document
, value
,
595 anode
->input_ports
) < 0)
597 if (!strcmp((char *) key
->data
.scalar
.value
, "output_ports") &&
598 extract_port_list(ctx
, document
, value
,
599 anode
->output_ports
) < 0)
601 if (!strcmp((char *) key
->data
.scalar
.value
, "gates") &&
602 extract_gate_list(ctx
, document
, value
, anode
->gates
) < 0)
604 if (!strcmp((char *) key
->data
.scalar
.value
, "expressions") &&
605 extract_expr_list(ctx
, document
, value
,
606 anode
->expressions
) < 0)
617 static int extract_node_list(isl_ctx
*ctx
, yaml_document_t
*document
,
618 yaml_node_t
*node
, std::vector
<adg_node
*> &list
)
620 yaml_node_item_t
*item
;
622 if (node
->type
!= YAML_SEQUENCE_NODE
)
623 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
626 for (item
= node
->data
.sequence
.items
.start
;
627 item
< node
->data
.sequence
.items
.top
; ++item
) {
631 n
= yaml_document_get_node(document
, *item
);
632 node
= extract_node(ctx
, document
, n
);
635 list
.push_back(node
);
641 static enum adg_edge_type
extract_type(isl_ctx
*ctx
,
642 yaml_document_t
*document
, yaml_node_t
*node
)
644 if (node
->type
!= YAML_SCALAR_NODE
)
645 isl_die(ctx
, isl_error_invalid
, "expecting scalar node",
646 return adg_edge_error
);
648 if (!strcmp((char *) node
->data
.scalar
.value
, "fifo"))
649 return adg_edge_fifo
;
650 if (!strcmp((char *) node
->data
.scalar
.value
, "sticky fifo"))
651 return adg_edge_sticky_fifo
;
652 if (!strcmp((char *) node
->data
.scalar
.value
, "shift register"))
653 return adg_edge_shift_register
;
654 if (!strcmp((char *) node
->data
.scalar
.value
, "broadcast"))
655 return adg_edge_broadcast
;
656 if (!strcmp((char *) node
->data
.scalar
.value
, "generic"))
657 return adg_edge_generic
;
659 return adg_edge_error
;
662 static adg_edge
*extract_edge(isl_ctx
*ctx
, yaml_document_t
*document
,
666 yaml_node_pair_t
*pair
;
671 if (node
->type
!= YAML_MAPPING_NODE
)
672 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
679 for (pair
= node
->data
.mapping
.pairs
.start
;
680 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
681 yaml_node_t
*key
, *value
;
683 key
= yaml_document_get_node(document
, pair
->key
);
684 value
= yaml_document_get_node(document
, pair
->value
);
686 if (key
->type
!= YAML_SCALAR_NODE
)
687 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
689 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
690 edge
->name
= extract_id(ctx
, document
, value
);
691 if (!strcmp((char *) key
->data
.scalar
.value
, "map"))
692 edge
->map
= extract_multi_aff(ctx
, document
, value
);
693 if (!strcmp((char *) key
->data
.scalar
.value
, "from_node"))
694 edge
->from_node_name
= extract_id(ctx
, document
, value
);
695 if (!strcmp((char *) key
->data
.scalar
.value
, "from_port"))
696 edge
->from_port_name
= extract_id(ctx
, document
, value
);
697 if (!strcmp((char *) key
->data
.scalar
.value
, "to_node"))
698 edge
->to_node_name
= extract_id(ctx
, document
, value
);
699 if (!strcmp((char *) key
->data
.scalar
.value
, "to_port"))
700 edge
->to_port_name
= extract_id(ctx
, document
, value
);
701 if (!strcmp((char *) key
->data
.scalar
.value
, "value_size") &&
702 extract_isl_int(ctx
, document
, value
, edge
->value_size
) < 0)
704 if (!strcmp((char *) key
->data
.scalar
.value
, "type"))
705 edge
->type
= extract_type(ctx
, document
, value
);
715 static int extract_edge_list(isl_ctx
*ctx
, yaml_document_t
*document
,
716 yaml_node_t
*node
, std::vector
<adg_edge
*> &list
)
718 yaml_node_item_t
*item
;
720 if (node
->type
!= YAML_SEQUENCE_NODE
)
721 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
724 for (item
= node
->data
.sequence
.items
.start
;
725 item
< node
->data
.sequence
.items
.top
; ++item
) {
729 n
= yaml_document_get_node(document
, *item
);
730 edge
= extract_edge(ctx
, document
, n
);
733 list
.push_back(edge
);
739 static adg_param
*extract_param(isl_ctx
*ctx
, yaml_document_t
*document
,
743 yaml_node_pair_t
*pair
;
748 if (node
->type
!= YAML_MAPPING_NODE
)
749 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
752 param
= new adg_param
;
756 for (pair
= node
->data
.mapping
.pairs
.start
;
757 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
758 yaml_node_t
*key
, *value
;
760 key
= yaml_document_get_node(document
, pair
->key
);
761 value
= yaml_document_get_node(document
, pair
->value
);
763 if (key
->type
!= YAML_SCALAR_NODE
)
764 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
766 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
767 param
->name
= extract_id(ctx
, document
, value
);
768 if (!strcmp((char *) key
->data
.scalar
.value
, "lb"))
769 param
->lb
= extract_aff(ctx
, document
, value
);
770 if (!strcmp((char *) key
->data
.scalar
.value
, "ub"))
771 param
->ub
= extract_aff(ctx
, document
, value
);
772 if (!strcmp((char *) key
->data
.scalar
.value
, "val"))
773 param
->val
= extract_aff(ctx
, document
, value
);
783 static int extract_param_list(isl_ctx
*ctx
, yaml_document_t
*document
,
784 yaml_node_t
*node
, std::vector
<adg_param
*> &list
)
786 yaml_node_item_t
*item
;
788 if (node
->type
!= YAML_SEQUENCE_NODE
)
789 isl_die(ctx
, isl_error_invalid
, "expecting sequence",
792 for (item
= node
->data
.sequence
.items
.start
;
793 item
< node
->data
.sequence
.items
.top
; ++item
) {
797 n
= yaml_document_get_node(document
, *item
);
798 param
= extract_param(ctx
, document
, n
);
801 list
.push_back(param
);
807 static adg
*extract_adg(isl_ctx
*ctx
, yaml_document_t
*document
,
811 yaml_node_pair_t
*pair
;
816 if (node
->type
!= YAML_MAPPING_NODE
)
817 isl_die(ctx
, isl_error_invalid
, "expecting mapping",
824 for (pair
= node
->data
.mapping
.pairs
.start
;
825 pair
< node
->data
.mapping
.pairs
.top
; ++pair
) {
826 yaml_node_t
*key
, *value
;
828 key
= yaml_document_get_node(document
, pair
->key
);
829 value
= yaml_document_get_node(document
, pair
->value
);
831 if (key
->type
!= YAML_SCALAR_NODE
)
832 isl_die(ctx
, isl_error_invalid
, "expecting scalar key",
834 if (!strcmp((char *) key
->data
.scalar
.value
, "name"))
835 adg
->name
= extract_id(ctx
, document
, value
);
836 if (!strcmp((char *) key
->data
.scalar
.value
, "context"))
837 adg
->context
= extract_set(ctx
, document
, value
);
838 if (!strcmp((char *) key
->data
.scalar
.value
, "iterator_map"))
839 adg
->iterator_map
= extract_map(ctx
, document
, value
);
840 if (!strcmp((char *) key
->data
.scalar
.value
, "iterators") &&
841 extract_id_list(ctx
, document
, value
, adg
->iterators
) < 0)
843 if (!strcmp((char *) key
->data
.scalar
.value
, "all_iterators") &&
844 extract_id_list(ctx
, document
, value
, adg
->all_iterators
) < 0)
846 if (!strcmp((char *) key
->data
.scalar
.value
, "nodes") &&
847 extract_node_list(ctx
, document
, value
, adg
->nodes
) < 0)
849 if (!strcmp((char *) key
->data
.scalar
.value
, "edges") &&
850 extract_edge_list(ctx
, document
, value
, adg
->edges
) < 0)
852 if (!strcmp((char *) key
->data
.scalar
.value
, "params") &&
853 extract_param_list(ctx
, document
, value
, adg
->params
) < 0)
864 /* Extract an adg from the YAML description in "in".
866 adg
*adg_parse(isl_ctx
*ctx
, FILE *in
)
869 yaml_parser_t parser
;
871 yaml_document_t document
= { 0 };
873 yaml_parser_initialize(&parser
);
875 yaml_parser_set_input_file(&parser
, in
);
877 if (!yaml_parser_load(&parser
, &document
))
880 root
= yaml_document_get_root_node(&document
);
882 adg
= extract_adg(ctx
, &document
, root
);
884 yaml_document_delete(&document
);
886 yaml_parser_delete(&parser
);
890 yaml_parser_delete(&parser
);