bison-patches
[Top][All Lists]
Advanced

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

[PATCH 3/9] style: use %code for local function declarations in our pars


From: Akim Demaille
Subject: [PATCH 3/9] style: use %code for local function declarations in our parser
Date: Thu, 18 Apr 2013 17:28:02 +0200

* src/parse-gram.y (version_check, gram_error, char_name, lloc_default):
Move their prototypes from %{...%} to %code.
(YYLLOC_DEFAULT, YY_LOCATION_PRINT): Move from %{...%} to %code.
(current_lhs): Move its implementation to the epilogue.
---
 src/parse-gram.y | 57 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/src/parse-gram.y b/src/parse-gram.y
index 355e148..62cee18 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -34,19 +34,6 @@
 #include "scan-gram.h"
 #include "scan-code.h"
 #include "xmemdup0.h"
-
-#define YYLLOC_DEFAULT(Current, Rhs, N)  (Current) = lloc_default (Rhs, N)
-static YYLTYPE lloc_default (YYLTYPE const *, int);
-
-#define YY_LOCATION_PRINT(File, Loc) \
-          location_print (Loc, File)
-
-static void version_check (location const *loc, char const *version);
-
-static void gram_error (location const *, char const *);
-
-/* A string that describes a char (e.g., 'a' -> "'a'").  */
-static char const *char_name (char);
 %}
 
 %code
@@ -61,20 +48,21 @@ static char const *char_name (char);
   /** Set the new current left-hand side symbol, possibly common
    * to several right-hand side parts of rule.
    */
-  static
-  void
-  current_lhs (symbol *sym, location loc, named_ref *ref)
-  {
-    current_lhs_symbol = sym;
-    current_lhs_location = loc;
-    /* In order to simplify memory management, named references for lhs
-       are always assigned by deep copy into the current symbol_list
-       node.  This is because a single named-ref in the grammar may
-       result in several uses when the user factors lhs between several
-       rules using "|".  Therefore free the parser's original copy.  */
-    free (current_lhs_named_ref);
-    current_lhs_named_ref = ref;
-  }
+  static void current_lhs (symbol *sym, location loc, named_ref *ref);
+
+  #define YYLLOC_DEFAULT(Current, Rhs, N)         \
+    (Current) = lloc_default (Rhs, N)
+  static YYLTYPE lloc_default (YYLTYPE const *, int);
+
+  #define YY_LOCATION_PRINT(File, Loc)            \
+    location_print (Loc, File)
+
+  static void version_check (location const *loc, char const *version);
+
+  static void gram_error (location const *, char const *);
+
+  /* A string that describes a char (e.g., 'a' -> "'a'").  */
+  static char const *char_name (char);
 
   #define YYTYPE_INT16 int_fast16_t
   #define YYTYPE_INT8 int_fast8_t
@@ -854,3 +842,18 @@ char_name (char c)
       return quotearg_style (escape_quoting_style, buf);
     }
 }
+
+static
+void
+current_lhs (symbol *sym, location loc, named_ref *ref)
+{
+  current_lhs_symbol = sym;
+  current_lhs_location = loc;
+  /* In order to simplify memory management, named references for lhs
+     are always assigned by deep copy into the current symbol_list
+     node.  This is because a single named-ref in the grammar may
+     result in several uses when the user factors lhs between several
+     rules using "|".  Therefore free the parser's original copy.  */
+  free (current_lhs_named_ref);
+  current_lhs_named_ref = ref;
+}
-- 
1.8.2.1




reply via email to

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