diff --git a/types/ds_types.anubis b/types/ds_types.anubis index fbc5b18..257925e 100644 --- a/types/ds_types.anubis +++ b/types/ds_types.anubis @@ -30,7 +30,7 @@ public type Bool_List: list. public type DS_Comment: - none, + no_comment, comment(String comment). public type DS_Component: @@ -61,7 +61,7 @@ public define DS_Component DS_Anubis_Type anb_type, String name )= - component(list, anb_type, name, none). + component(list, anb_type, name, no_comment). public define DS_Component /* Default constructor helper without Bool_List means 'none' @@ -71,7 +71,7 @@ public define DS_Component DS_Anubis_Type anb_type, String name )= - component(none, anb_type, name, none). + component(none, anb_type, name, no_comment). public type DS_Alternative: @@ -82,7 +82,8 @@ public type DS_Alternative: ), //alternative alternative( - String alt_name, //Name of the alternative + String alt_name, //Name of the alternative + DS_Comment comment, //main comment of the alternative if need List(DS_Component) components //list of components of that alternative ). @@ -93,8 +94,17 @@ public define DS_Alternative ( String alt_name )= - enum(alt_name, none). - + enum(alt_name, no_comment). + +public define DS_Alternative + alternative + ( + String alt_name, //Name of the alternative + List(DS_Component) components //list of components of that alternative + )= + alternative(alt_name, no_comment, components) +. + public type DS_Type: ds_type( String type_name, @@ -139,8 +149,8 @@ define List(Extern_type) [h . t] then if h is { - enum(_ , _) then extract_extern_type(t, so_far) - alternative(_, components) then + enum(_ , _) then extract_extern_type(t, so_far) + alternative(_, _, components) then extract_extern_type(t, extract_extern_type(components, so_far)) } } @@ -186,7 +196,7 @@ public define String )= if comment is { - none then "", + no_comment then "", comment(_str) then "//"+_str } . @@ -239,8 +249,8 @@ define Int [h . t] then with name = if h is { - enum(name, _) then name, - alternative(name, _) then name + enum(name, _) then name, + alternative(name, _, _) then name }, alternative_name_max_length(t, max(current_length, length(name))) } @@ -276,7 +286,7 @@ define Int with current = if h is { enum(name, _) then length(name), - alternative(name, components) then component_type_max_length(components, 0) + alternative(name, _, components) then component_type_max_length(components, 0) }, alternative_type_max_length(t, max(current, so_far_length)) } @@ -311,8 +321,8 @@ define Int [h . t] then with current = if h is { - enum(_, _) then 0, - alternative(_, components) then component_name_max_length(components, 0) + enum(_, _) then 0, + alternative(_, _, components) then component_name_max_length(components, 0) }, alternative_type_name_max_length(t, max(current, so_far_length)) } @@ -336,7 +346,13 @@ public define String enum(name, _comment) then prefix + fill(name+(if is_empty(t) then "" else ","), type_length + name_length+2) + dump(_comment) + dump_DS_Alternative_list(t, type_length, alt_name_length, name_length), - alternative(name, components) then prefix + name+"("+ + alternative(name, comment, components) then + //if comment exists, add it first + (if comment != no_comment then + prefix + dump(comment) +"\n" + else + "")+ + prefix + name+"("+ dump(components, true, type_length, name_length)+(if is_empty(t) then "" else ",")+ dump_DS_Alternative_list(t, type_length, alt_name_length, name_length) } -- libgit2 0.21.4