[Crosstoolchain-logs] [device-tree-compiler] 171/357: DTC: Remove the need for the GLR Parser.

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:06:10 UTC 2016


This is an automated email from the git hooks/post-receive script.

zumbi pushed a commit to branch upstream/1.3.x
in repository device-tree-compiler.

commit 7b3fb789d2cd5fed818f439d0c7aed44b9860fab
Author: Jon Loeliger <jdl at freescale.com>
Date:   Mon Oct 22 16:09:56 2007 -0500

    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 at freescale.com>
---
 Makefile     |  1 -
 dtc-parser.y |  5 ++---
 dtc.h        |  1 +
 livetree.c   | 17 ++++++++++++++++-
 4 files changed, 19 insertions(+), 5 deletions(-)

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) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list