diff options
author | Jon Loeliger <jdl@freescale.com> | 2007-10-22 16:09:56 -0500 |
---|---|---|
committer | Jon Loeliger <jdl@freescale.com> | 2007-10-25 11:13:29 -0500 |
commit | 7b3fb789d2cd5fed818f439d0c7aed44b9860fab (patch) | |
tree | 34096341311b428a243bb75d074a1cb397cbc922 /livetree.c | |
parent | 3bef796b449320cefb8e52838ca90163df698722 (diff) | |
download | dtc-7b3fb789d2cd5fed818f439d0c7aed44b9860fab.zip dtc-7b3fb789d2cd5fed818f439d0c7aed44b9860fab.tar.gz dtc-7b3fb789d2cd5fed818f439d0c7aed44b9860fab.tar.bz2 |
DTC: Remove the need for the GLR Parser.
Previously, there were a few shift/reduce and reduce/reduce
errors in the grammar that were being handled by the not-so-popular
GLR Parser technique.
Flip a right-recursive stack-abusing rule into a left-recursive
stack-friendly rule and clear up three messes in one shot: No more
conflicts, no need for the GLR parser, and friendlier stackness.
Compensate by reversing the property list on the node.
Signed-off-by: Jon Loeliger <jdl@freescale.com>
Diffstat (limited to 'livetree.c')
-rw-r--r-- | livetree.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -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) { |