Revision 7f5d0cde
Added by Arnaud Dieumegard over 6 years ago
src/backends/VHDL/vhdl_ast_deriving.ml | ||
---|---|---|
143 | 143 |
selection: vhdl_suffix_selection_t } |
144 | 144 |
| Aggregate of { |
145 | 145 |
elems: vhdl_element_assoc_t list } [@name "AGGREGATE"] |
146 |
| QualifiedExpression of |
|
147 |
{ |
|
148 |
type_mark: vhdl_name_t ; |
|
149 |
aggregate: vhdl_element_assoc_t list ; |
|
150 |
expression: vhdl_expr_t option } [@name "QUALIFIED_EXPRESSION"] |
|
146 | 151 |
| Others [@name "OTHERS"] |
147 | 152 |
and vhdl_name_t = |
148 | 153 |
| Simple of string [@name "SIMPLE_NAME"] |
... | ... | |
438 | 443 |
(* TODO adapt for Op, Time, Sig, suffixMod *) |
439 | 444 |
and pp_vhdl_expr_t : |
440 | 445 |
Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit = |
441 |
let __8 () = pp_vhdl_element_assoc_t |
|
446 |
let __11 () = pp_vhdl_expr_t |
|
447 |
|
|
448 |
and __10 () = pp_vhdl_element_assoc_t |
|
449 |
|
|
450 |
and __9 () = pp_vhdl_name_t |
|
451 |
|
|
452 |
and __8 () = pp_vhdl_element_assoc_t |
|
442 | 453 |
|
443 | 454 |
and __7 () = pp_vhdl_suffix_selection_t |
444 | 455 |
|
... | ... | |
547 | 558 |
((__8 ()) fmt) x; |
548 | 559 |
true) false x))) aelems; |
549 | 560 |
Format.fprintf fmt ")@]");) |
561 |
| QualifiedExpression |
|
562 |
{ type_mark = atype_mark; aggregate = aaggregate; |
|
563 |
expression = aexpression } |
|
564 |
-> |
|
565 |
((__9 ()) fmt) atype_mark; |
|
566 |
Format.fprintf fmt "'"; |
|
567 |
(match aaggregate with |
|
568 |
| [] -> Format.fprintf fmt ""; |
|
569 |
| _ -> |
|
570 |
Format.fprintf fmt "(@[<v>"; |
|
571 |
((fun x -> |
|
572 |
ignore |
|
573 |
(List.fold_left |
|
574 |
(fun sep -> |
|
575 |
fun x -> |
|
576 |
if sep then Format.fprintf fmt ",@ "; |
|
577 |
((__10 ()) fmt) x; |
|
578 |
true) false x))) aaggregate; |
|
579 |
Format.fprintf fmt ")@]"); |
|
580 |
(match aexpression with |
|
581 |
| None -> Format.pp_print_string fmt "" |
|
582 |
| Some x -> |
|
583 |
((__11 ()) fmt) x;); |
|
550 | 584 |
| Others -> Format.pp_print_string fmt "others") |
551 | 585 |
[@ocaml.warning "-A"]) |
552 | 586 |
|
... | ... | |
661 | 695 |
| Some a -> |
662 | 696 |
(((__0 ()) fmt) a; |
663 | 697 |
(match x.formal_arg with |
664 |
| None -> () |
|
665 |
| Some b -> Format.fprintf fmt "("; |
|
666 |
((__1 ()) fmt) b; |
|
667 |
Format.fprintf fmt ")"); |
|
698 |
| None -> Format.pp_print_string fmt "" |
|
699 |
| Some b -> ((__1 ()) fmt) b); |
|
668 | 700 |
Format.fprintf fmt " => ")); |
669 | 701 |
(match x.actual_name with |
670 |
| None -> Format.pp_print_string fmt "" |
|
702 |
| None -> |
|
703 |
((match x.actual_designator with |
|
704 |
| None -> Format.pp_print_string fmt "" |
|
705 |
| Some NoName -> Format.pp_print_string fmt "" |
|
706 |
| Some b -> ((__3 ()) fmt) b); |
|
707 |
(match x.actual_expr with |
|
708 |
| None -> Format.pp_print_string fmt "" |
|
709 |
| Some IsNull -> Format.pp_print_string fmt "" |
|
710 |
| Some c -> ((__4 ()) fmt) c);) |
|
671 | 711 |
| Some a -> |
672 | 712 |
(((__2 ()) fmt) a; |
713 |
(match a with |
|
714 |
| NoName -> () |
|
715 |
| _ -> Format.fprintf fmt "("); |
|
673 | 716 |
(match x.actual_designator with |
674 |
| None -> () |
|
675 |
| Some NoName -> Format.pp_print_string fmt "" |
|
676 |
| Some b -> (Format.fprintf fmt "("; |
|
677 |
((__3 ()) fmt) b; |
|
678 |
Format.fprintf fmt ")")); |
|
717 |
| None -> Format.pp_print_string fmt "" |
|
718 |
| Some b -> ((__3 ()) fmt) b); |
|
679 | 719 |
(match x.actual_expr with |
680 |
| None -> ()
|
|
720 |
| None -> Format.pp_print_string fmt ""
|
|
681 | 721 |
| Some IsNull -> Format.pp_print_string fmt "" |
682 |
| Some c -> (Format.fprintf fmt "("; |
|
683 |
((__4 ()) fmt) c; |
|
684 |
Format.fprintf fmt ")"))));) |
|
722 |
| Some c -> ((__4 ()) fmt) c); |
|
723 |
(match a with |
|
724 |
| NoName -> () |
|
725 |
| _ -> Format.fprintf fmt ")")));) |
|
685 | 726 |
[@ocaml.warning "-A"]) |
686 | 727 |
|
687 | 728 |
and show_vhdl_assoc_element_t : |
... | ... | |
1481 | 1522 |
[`String "Sig"; |
1482 | 1523 |
(let fields = [] in |
1483 | 1524 |
let fields = |
1484 |
("att", |
|
1485 |
((function |
|
1486 |
| None -> `Null |
|
1487 |
| Some x -> |
|
1488 |
((fun x -> vhdl_signal_attributes_t_to_yojson x)) x) |
|
1489 |
arg0.att)) |
|
1490 |
:: fields in |
|
1525 |
if arg0.att = None |
|
1526 |
then fields |
|
1527 |
else |
|
1528 |
("att", |
|
1529 |
(((function |
|
1530 |
| None -> `Null |
|
1531 |
| Some x -> |
|
1532 |
((fun x -> vhdl_signal_attributes_t_to_yojson x)) |
|
1533 |
x)) arg0.att)) |
|
1534 |
:: fields |
|
1535 |
in |
|
1491 | 1536 |
let fields = |
1492 | 1537 |
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) :: |
1493 | 1538 |
fields in |
... | ... | |
1510 | 1555 |
[`String "AGGREGATE"; |
1511 | 1556 |
(let fields = [] in |
1512 | 1557 |
let fields = |
1513 |
("elems", |
|
1514 |
((fun x -> |
|
1515 |
`List |
|
1516 |
(List.map (fun x -> vhdl_element_assoc_t_to_yojson x) |
|
1517 |
x)) arg0.elems)) |
|
1558 |
if arg0.elems = [] |
|
1559 |
then fields |
|
1560 |
else |
|
1561 |
("elems", |
|
1562 |
(((fun x -> |
|
1563 |
`List |
|
1564 |
(List.map |
|
1565 |
(fun x -> vhdl_element_assoc_t_to_yojson x) x))) |
|
1566 |
arg0.elems)) |
|
1567 |
:: fields |
|
1568 |
in |
|
1569 |
`Assoc fields)] |
|
1570 |
| QualifiedExpression arg0 -> |
|
1571 |
`List |
|
1572 |
[`String "QUALIFIED_EXPRESSION"; |
|
1573 |
(let fields = [] in |
|
1574 |
let fields = |
|
1575 |
if arg0.expression = None |
|
1576 |
then fields |
|
1577 |
else |
|
1578 |
("expression", |
|
1579 |
(((function |
|
1580 |
| None -> `Null |
|
1581 |
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x)) |
|
1582 |
arg0.expression)) |
|
1583 |
:: fields |
|
1584 |
in |
|
1585 |
let fields = |
|
1586 |
if arg0.aggregate = [] |
|
1587 |
then fields |
|
1588 |
else |
|
1589 |
("aggregate", |
|
1590 |
(((fun x -> |
|
1591 |
`List |
|
1592 |
(List.map |
|
1593 |
(fun x -> vhdl_element_assoc_t_to_yojson x) x))) |
|
1594 |
arg0.aggregate)) |
|
1595 |
:: fields |
|
1596 |
in |
|
1597 |
let fields = |
|
1598 |
("type_mark", |
|
1599 |
((fun x -> vhdl_name_t_to_yojson x) arg0.type_mark)) |
|
1518 | 1600 |
:: fields in |
1519 | 1601 |
`Assoc fields)] |
1520 | 1602 |
| Others -> `List [`String "OTHERS"]) |
... | ... | |
1642 | 1724 |
| _::xs -> loop xs _state in |
1643 | 1725 |
loop xs |
1644 | 1726 |
((Result.Error "Vhdl_ast.vhdl_expr_t.name"), |
1645 |
(Result.Error "Vhdl_ast.vhdl_expr_t.att"))
|
|
1727 |
(Result.Ok None))
|
|
1646 | 1728 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
1647 | 1729 |
| `List ((`String "SuffixMod")::arg0::[]) -> |
1648 | 1730 |
((function |
... | ... | |
1685 | 1767 |
arg0 >>= |
1686 | 1768 |
((fun arg0 -> Result.Ok (Aggregate { elems = arg0 }))) |
1687 | 1769 |
| _::xs -> loop xs _state in |
1688 |
loop xs (Result.Error "Vhdl_ast.vhdl_expr_t.elems") |
|
1770 |
loop xs (Result.Ok []) |
|
1771 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
|
1772 |
| `List ((`String "QUALIFIED_EXPRESSION")::arg0::[]) -> |
|
1773 |
((function |
|
1774 |
| `Assoc xs -> |
|
1775 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
|
1776 |
match xs with |
|
1777 |
| ("type_mark",x)::xs -> |
|
1778 |
loop xs |
|
1779 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
|
1780 |
| ("aggregate",x)::xs -> |
|
1781 |
loop xs |
|
1782 |
(arg0, |
|
1783 |
((function |
|
1784 |
| `List xs -> |
|
1785 |
map_bind |
|
1786 |
(fun x -> vhdl_element_assoc_t_of_yojson x) |
|
1787 |
[] xs |
|
1788 |
| _ -> |
|
1789 |
Result.Error "Vhdl_ast.vhdl_expr_t.aggregate") |
|
1790 |
x), arg2) |
|
1791 |
| ("expression",x)::xs -> |
|
1792 |
loop xs |
|
1793 |
(arg0, arg1, |
|
1794 |
((function |
|
1795 |
| `Null -> Result.Ok None |
|
1796 |
| x -> |
|
1797 |
((fun x -> vhdl_expr_t_of_yojson x) x) >>= |
|
1798 |
((fun x -> Result.Ok (Some x)))) x)) |
|
1799 |
| [] -> |
|
1800 |
arg2 >>= |
|
1801 |
((fun arg2 -> |
|
1802 |
arg1 >>= |
|
1803 |
(fun arg1 -> |
|
1804 |
arg0 >>= |
|
1805 |
(fun arg0 -> |
|
1806 |
Result.Ok |
|
1807 |
(QualifiedExpression |
|
1808 |
{ |
|
1809 |
type_mark = arg0; |
|
1810 |
aggregate = arg1; |
|
1811 |
expression = arg2 |
|
1812 |
}))))) |
|
1813 |
| _::xs -> loop xs _state in |
|
1814 |
loop xs |
|
1815 |
((Result.Error "Vhdl_ast.vhdl_expr_t.type_mark"), |
|
1816 |
(Result.Ok []), (Result.Ok None)) |
|
1689 | 1817 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
1690 | 1818 |
| `List ((`String "OTHERS")::[]) -> Result.Ok Others |
1691 | 1819 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t") |
... | ... | |
4746 | 4874 |
fun x -> |
4747 | 4875 |
if sep then Format.fprintf fmt "."; |
4748 | 4876 |
((__1 ()) fmt) x; |
4749 |
true) false x))) a0; |
|
4750 |
Format.fprintf fmt ";")) |
|
4877 |
true) false x))) a0)) |
|
4751 | 4878 |
[@ocaml.warning "-A"]) |
4752 | 4879 |
|
4753 | 4880 |
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string = |
Also available in: Unified diff
Qualified expressions, default values for expressions, pp for association_elements