summaryrefslogtreecommitdiff
path: root/livetree.c
diff options
context:
space:
mode:
authorJon Loeliger <jdl@freescale.com>2007-10-22 16:09:56 -0500
committerJon Loeliger <jdl@freescale.com>2007-10-25 11:13:29 -0500
commit7b3fb789d2cd5fed818f439d0c7aed44b9860fab (patch)
tree34096341311b428a243bb75d074a1cb397cbc922 /livetree.c
parent3bef796b449320cefb8e52838ca90163df698722 (diff)
downloaddtc-7b3fb789d2cd5fed818f439d0c7aed44b9860fab.tar.gz
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.c17
1 files changed, 16 insertions, 1 deletions
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) {