diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2014-02-16 22:12:56 +1100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2014-03-03 10:51:50 +1100 |
commit | 6793050c308ad121d4c5ae9db0ecf614bccdeda4 (patch) | |
tree | dde98b760e5bd47afe97c797bb16424c18732621 | |
parent | 3d3fc9208207dfa40ce21426d556071fb7017085 (diff) | |
download | device-tree-compiler-6793050c308ad121d4c5ae9db0ecf614bccdeda4.tar.gz |
Implement labels within property values as bytestring expressions
This re-implements labels within property values as a form of bytestring
expression. The grammar gets a little hairy to handle the fact that
labels are allowed both at the beginning and end of property values without
introducing parser conflicts.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r-- | dtc-parser.y | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/dtc-parser.y b/dtc-parser.y index fcc3b4d..bff22d9 100644 --- a/dtc-parser.y +++ b/dtc-parser.y @@ -93,6 +93,7 @@ static struct data expr_bytestring(struct expression *expr); %type <expr> expr_incbin %type <expr> expr_prim +%type <expr> expr_prelabel %type <expr> expr_unary %type <expr> expr_mul %type <expr> expr_add @@ -105,6 +106,7 @@ static struct data expr_bytestring(struct expression *expr); %type <expr> expr_and %type <expr> expr_or %type <expr> expr_conditional +%type <expr> expr_postlabel %type <expr> expr %% @@ -221,10 +223,6 @@ propdata: { $$ = data_add_marker($1, REF_PATH, $2); } - | propdata DT_LABEL - { - $$ = data_add_marker($1, LABEL, $2); - } ; propdataprefix: @@ -236,10 +234,6 @@ propdataprefix: { $$ = $1; } - | propdataprefix DT_LABEL - { - $$ = data_add_marker($1, LABEL, $2); - } ; array: @@ -338,7 +332,19 @@ expr_prim: ; expr: - expr_conditional + expr_postlabel + ; + +expr_postlabel: + expr_conditional + | expr_conditional DT_LABEL + { + struct data d = data_add_marker(empty_data, LABEL, $2); + struct expression *label; + + label = expression_bytestring_constant(&@2, d); + $$ = expression_join(&@$, $1, label); + } ; expr_conditional: @@ -408,12 +414,24 @@ expr_mul: ; expr_unary: - expr_prim + expr_prelabel | '-' expr_unary { $$ = UNOP(@$, negate, $2); } | '~' expr_unary { $$ = UNOP(@$, bit_not, $2); } | '!' expr_unary { $$ = UNOP(@$, logic_not, $2); } ; +expr_prelabel: + expr_prim + | DT_LABEL expr_prelabel + { + struct data d = data_add_marker(empty_data, LABEL, $1); + struct expression *label; + + label = expression_bytestring_constant(&@1, d); + $$ = expression_join(&@$, label, $2); + } + ; + bytestring_literal: /* empty */ { |