diff --git a/Makefile b/Makefile index d7d1af5..84f0efe 100644 --- a/Makefile +++ b/Makefile @@ -207,7 +207,6 @@ clean: libfdt_clean tests_clean %.tab.c %.tab.h %.output: %.y @$(VECHO) BISON $@ - @$(VECHO) ---- Expect 2 s/r and 2 r/r. ---- $(BISON) -d $< FORCE: diff --git a/dtc-parser.y b/dtc-parser.y index 33cf540..61ed250 100644 --- a/dtc-parser.y +++ b/dtc-parser.y @@ -18,7 +18,6 @@ * USA */ -%glr-parser %locations %{ @@ -126,9 +125,9 @@ proplist: { $$ = NULL; } - | propdef proplist + | proplist propdef { - $$ = chain_property($1, $2); + $$ = chain_property($2, $1); } ; diff --git a/dtc.h b/dtc.h index 77494af..1fc6523 100644 --- a/dtc.h +++ b/dtc.h @@ -180,6 +180,7 @@ struct node { struct property *build_property(char *name, struct data val, char *label); struct property *chain_property(struct property *first, struct property *list); +struct property *reverse_properties(struct property *first); struct node *build_node(struct property *proplist, struct node *children); struct node *name_node(struct node *node, char *name, char *label); diff --git a/livetree.c b/livetree.c index aa81d12..c480b36 100644 --- a/livetree.c +++ b/livetree.c @@ -46,6 +46,21 @@ struct property *chain_property(struct property *first, struct property *list) return first; } +struct property *reverse_properties(struct property *first) +{ + struct property *p = first; + struct property *head = NULL; + struct property *next; + + while (p) { + next = p->next; + p->next = head; + head = p; + p = next; + } + return head; +} + struct node *build_node(struct property *proplist, struct node *children) { struct node *new = xmalloc(sizeof(*new)); @@ -53,7 +68,7 @@ struct node *build_node(struct property *proplist, struct node *children) memset(new, 0, sizeof(*new)); - new->proplist = proplist; + new->proplist = reverse_properties(proplist); new->children = children; for_each_child(new, child) {