bug-bison
[Top][All Lists]
Advanced

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

FYI: glr.c: minor refactoring (was: yacc.c does not prototype yyparse in


From: Akim Demaille
Subject: FYI: glr.c: minor refactoring (was: yacc.c does not prototype yyparse in the header)
Date: Tue, 12 Jun 2012 15:56:38 +0200

Le 11 juin 2012 à 10:54, Akim Demaille a écrit :

> Bruce Korb just pointed out to me that Bison 2.5.1 does
> not prototype yyparse in the generated header, with yacc.c.
> The other skeletons do.  I don't understand why.  I see
> nothing in the documentation of Yacc that prevents this,
> and surely this is troublesome for many uses.

Refactoring is needed beforehand.  First of these, a simple
one, made to have glr.c and yacc.c share a more common
structure.  Already installed in maint.


From e9807a79348dee60a4d83c2b1281e9e3678b8287 Mon Sep 17 00:00:00 2001
From: Akim Demaille <address@hidden>
Date: Tue, 12 Jun 2012 09:27:12 +0200
Subject: [PATCH] glr.c: minor refactoring.

* data/glr.c (b4_shared_declarations): Move from the generated file
section, to the M4 prologue.
---
 data/glr.c |   74 ++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 39 insertions(+), 35 deletions(-)

diff --git a/data/glr.c b/data/glr.c
index 5f7aac8..7588bd1 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -154,43 +154,14 @@ m4_define([b4_rhs_location],
 [(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)])
 
 
-
 ## -------------- ##
-## Output files.  ##
+## Declarations.  ##
 ## -------------- ##
 
-# We do want M4 expansion after # for CPP macros.
-m4_changecom()
-m4_divert_push(0)dnl
address@hidden(b4_parser_file_name@)@
-b4_copyright([Skeleton implementation for Bison GLR parsers in C],
-             [2002-2012])
-[
-/* C GLR parser skeleton written by Paul Hilfinger.  */
-
-]b4_identification
-
-b4_percent_code_get([[top]])[]dnl
-m4_if(b4_prefix, [yy], [],
-[/* Substitute the variable and function names.  */
-#define yyparse b4_prefix[]parse
-#define yylex   b4_prefix[]lex
-#define yyerror b4_prefix[]error
-#define yylval  b4_prefix[]lval
-#define yychar  b4_prefix[]char
-#define yydebug b4_prefix[]debug
-#define yynerrs b4_prefix[]nerrs
-#define yylloc  b4_prefix[]lloc])[
-
-/* Copy the first part of user declarations.  */
-]b4_user_pre_prologue
-
-b4_null_define
-
-dnl # b4_shared_declarations
-dnl # ----------------------
-dnl # Declaration that might either go into the header (if --defines)
-dnl # or open coded in the parser body.
+# b4_shared_declarations
+# ----------------------
+# Declaration that might either go into the header (if --defines)
+# or open coded in the parser body.
 m4_define([b4_shared_declarations],
 [b4_percent_code_get([[requires]])[]dnl
 
@@ -223,7 +194,40 @@ typedef struct YYLTYPE
 ]b4_percent_code_get([[provides]])[]dnl
 ])
 
-b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
+
+## -------------- ##
+## Output files.  ##
+## -------------- ##
+
+# We do want M4 expansion after # for CPP macros.
+m4_changecom()
+m4_divert_push(0)dnl
address@hidden(b4_parser_file_name@)@
+b4_copyright([Skeleton implementation for Bison GLR parsers in C],
+             [2002-2012])
+[
+/* C GLR parser skeleton written by Paul Hilfinger.  */
+
+]b4_identification
+
+b4_percent_code_get([[top]])[]dnl
+m4_if(b4_prefix, [yy], [],
+[/* Substitute the variable and function names.  */
+#define yyparse b4_prefix[]parse
+#define yylex   b4_prefix[]lex
+#define yyerror b4_prefix[]error
+#define yylval  b4_prefix[]lval
+#define yychar  b4_prefix[]char
+#define yydebug b4_prefix[]debug
+#define yynerrs b4_prefix[]nerrs
+#define yylloc  b4_prefix[]lloc])[
+
+/* Copy the first part of user declarations.  */
+]b4_user_pre_prologue[
+
+]b4_null_define[
+
+]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
               [b4_shared_declarations])[
 
 /* Enabling traces.  */
-- 
1.7.10.4





reply via email to

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