Skip to content

Commit

Permalink
fixes the ordering of the fields in structures and unions (#43)
Browse files Browse the repository at this point in the history
we got it reversed at some point of time
  • Loading branch information
ivg authored May 17, 2021
1 parent d53127c commit bc6a60f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
20 changes: 10 additions & 10 deletions ctoxml/test.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -5234,24 +5234,24 @@
<struct id="struct:Scope">
<field name="">
<union>
<field name="num">
<long/>
</field>
<field name="alpha">
<char/>
</field>
<field name="num">
<long/>
</field>
</union>
</field>
</struct>
<struct id="struct:Scope2">
<field name="">
<struct>
<field name="num">
<long/>
</field>
<field name="alpha">
<char/>
</field>
<field name="num">
<long/>
</field>
</struct>
</field>
</struct>
Expand Down Expand Up @@ -5335,21 +5335,21 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<file>
<struct id="struct:point">
<field name="y">
<field name="x">
<long/>
</field>
<field name="x">
<field name="y">
<long/>
</field>
</struct>
<struct id="struct:point3d">
<field name="z">
<field name="x">
<long/>
</field>
<field name="y">
<long/>
</field>
<field name="x">
<field name="z">
<long/>
</field>
</struct>
Expand Down
19 changes: 10 additions & 9 deletions frontc/cparser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -521,16 +521,16 @@ field_list: field* {$1};
field:
| field_type field_defs opt_gcc_attributes SEMICOLON
{
match $3, set_name_group $1 (List.rev $2) with
match $3, set_name_group $1 $2 with
| [],r -> r
| attrs,(t,s,ns) -> GNU_TYPE (attrs,t),s,ns
}
| field_mod_list_opt struct_type field_mod_list_opt field_defs SEMICOLON
{ set_name_group (apply_mods $3 (apply_mods $1 ($2, NO_STORAGE))) (List.rev $4)}
{ set_name_group (apply_mods $3 (apply_mods $1 ($2, NO_STORAGE))) $4}
| field_mod_list_opt struct_type field_mod_list_opt SEMICOLON
{ set_name_group (apply_mods $3 (apply_mods $1 ($2, NO_STORAGE))) [("", NO_TYPE, [], NOTHING)]}
| field_mod_list_opt union_type field_mod_list_opt field_defs SEMICOLON
{ set_name_group (apply_mods $1 (apply_mods $3 ($2, NO_STORAGE))) (List.rev $4) }
{ set_name_group (apply_mods $1 (apply_mods $3 ($2, NO_STORAGE))) $4 }
| field_mod_list_opt union_type field_mod_list_opt SEMICOLON
{ set_name_group (apply_mods $3 (apply_mods $1 ($2, NO_STORAGE))) [("", NO_TYPE, [], NOTHING)]}
;
Expand Down Expand Up @@ -753,17 +753,17 @@ struct_type:
STRUCT type_name
{STRUCT ($2, [])}
| STRUCT LBRACE field_list RBRACE
{STRUCT ("", List.rev $3)}
{STRUCT ("", $3)}
| STRUCT type_name LBRACE field_list RBRACE
{STRUCT ($2, List.rev $4)}
{STRUCT ($2, $4)}
;
union_type:
| UNION type_name
{UNION ($2, [])}
| UNION LBRACE field_list RBRACE
{UNION ("", List.rev $3)}
{UNION ("", $3)}
| UNION type_name LBRACE field_list RBRACE
{UNION ($2, List.rev $4)}
{UNION ($2, $4)}
;
enum_type:
| ENUM type_name
Expand All @@ -779,7 +779,8 @@ type_name:
IDENT {$1}
| NAMED_TYPE {$1}
;
enum_list: enum_name {[$1]}
enum_list:
| enum_name {[$1]}
| enum_list COMMA enum_name {$3::$1}
;
enum_name: IDENT {($1, NOTHING)}
Expand Down Expand Up @@ -1085,7 +1086,7 @@ gnu_arg:
| constant
{ GNU_CST $1 }
| gnu_id LPAREN opt_gnu_args RPAREN
{ GNU_CALL ($1, List.rev $3) }
{ GNU_CALL ($1, $3) }
;

gnu_id:
Expand Down

0 comments on commit bc6a60f

Please sign in to comment.