summaryrefslogtreecommitdiff
path: root/dtc-parser.y
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2010-02-24 18:22:17 +1100
committerJon Loeliger <jdl@jdl.com>2010-02-24 08:48:51 -0600
commit05898c67c15d73fe50bd87fc939bd9ee6a4275ce (patch)
treea8ea4e24ccdd0e8a21dc028e2b55a1226d6d3bc2 /dtc-parser.y
parent49c2da308534a4bffb67d53b5a7f8e5f05c305b9 (diff)
downloaddtc-05898c67c15d73fe50bd87fc939bd9ee6a4275ce.tar.gz
dtc: Allow multiple labels on nodes and properties
At present, both the grammar and our internal data structures mean that there can be only one label on a node or property. This is a fairly arbitrary constraint, given that any number of value labels can appear at the same point, and that in C you can have any number of labels on the same statement. This is pretty much a non-issue now, but it may become important with some of the extensions that Grant and I have in mind. It's not that hard to change, so this patch does so, allowing an arbitrary number of labels on any given node or property. As usual a testcase is added too. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'dtc-parser.y')
-rw-r--r--dtc-parser.y43
1 files changed, 23 insertions, 20 deletions
diff --git a/dtc-parser.y b/dtc-parser.y
index bd9e097..8fa1e4f 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -78,7 +78,6 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
%type <node> nodedef
%type <node> subnode
%type <nodelist> subnodes
-%type <labelref> label
%%
@@ -102,9 +101,14 @@ memreserves:
;
memreserve:
- label DT_MEMRESERVE addr addr ';'
+ DT_MEMRESERVE addr addr ';'
{
- $$ = build_reserve_entry($3, $4, $1);
+ $$ = build_reserve_entry($2, $3);
+ }
+ | DT_LABEL memreserve
+ {
+ add_label(&$2->labels, $1);
+ $$ = $2;
}
;
@@ -118,7 +122,7 @@ addr:
devicetree:
'/' nodedef
{
- $$ = name_node($2, "", NULL);
+ $$ = name_node($2, "");
}
;
@@ -141,13 +145,18 @@ proplist:
;
propdef:
- label DT_PROPNODENAME '=' propdata ';'
+ DT_PROPNODENAME '=' propdata ';'
+ {
+ $$ = build_property($1, $3);
+ }
+ | DT_PROPNODENAME ';'
{
- $$ = build_property($2, $4, $1);
+ $$ = build_property($1, empty_data);
}
- | label DT_PROPNODENAME ';'
+ | DT_LABEL propdef
{
- $$ = build_property($2, empty_data, $1);
+ add_label(&$2->labels, $1);
+ $$ = $2;
}
;
@@ -264,7 +273,7 @@ subnodes:
{
$$ = NULL;
}
- | subnode subnodes
+ | subnode subnodes
{
$$ = chain_node($1, $2);
}
@@ -276,20 +285,14 @@ subnodes:
;
subnode:
- label DT_PROPNODENAME nodedef
+ DT_PROPNODENAME nodedef
{
- $$ = name_node($3, $2, $1);
+ $$ = name_node($2, $1);
}
- ;
-
-label:
- /* empty */
+ | DT_LABEL subnode
{
- $$ = NULL;
- }
- | DT_LABEL
- {
- $$ = $1;
+ add_label(&$2->labels, $1);
+ $$ = $2;
}
;