bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 5/8] parser: factor the handling of code_props


From: Akim Demaille
Subject: [PATCH 5/8] parser: factor the handling of code_props
Date: Mon, 23 Jul 2012 14:06:04 +0200

* src/parse-gram.y: Now that %printer and %destructor are treated
equally, let...
(code_props_type): handle them.
---
 src/parse-gram.y | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/parse-gram.y b/src/parse-gram.y
index efaa3d1..d84a7dd 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -30,6 +30,7 @@
 #include "quotearg.h"
 #include "reader.h"
 #include "symlist.h"
+#include "symtab.h"
 #include "scan-gram.h"
 #include "scan-code.h"
 #include "xmemdup0.h"
@@ -386,20 +387,13 @@ grammar_declaration:
     {
       grammar_start_symbol_set ($2, @2);
     }
-| "%destructor" "{...}" generic_symlist
+| code_props_type "{...}" generic_symlist
     {
       symbol_list *list;
       for (list = $3; list; list = list->next)
         symbol_list_code_props_set (list, $1, @2, $2);
       symbol_list_free ($3);
     }
-| "%printer" "{...}" generic_symlist
-    {
-      symbol_list *list;
-      for (list = $3; list; list = list->next)
-        symbol_list_code_props_set (list, printer, @2, $2);
-      symbol_list_free ($3);
-    }
 | "%default-prec"
     {
       default_prec = true;
@@ -422,6 +416,13 @@ grammar_declaration:
     }
 ;
 
+%type <code_type> code_props_type;
+%union {code_props_type code_type;};
+%printer { fprintf (stderr, "%s", code_props_type_string ($$)); } <code_type>;
+code_props_type:
+  "%destructor"  { $$ = destructor; }
+| "%printer"     { $$ = printer; }
+;
 
 /*---------.
 | %union.  |
-- 
1.7.11.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]