2006-10-16 Paolo Bonzini <bonzini@gnu.org>

* data/bison.m4 (b4_user_requires, b4_user_provides): New.
	(b4_user_start_header): Remove.
	* data/glr.c: Use new macros instead of b4_*start_header
	and b4_*end_header.
	* data/glr.cc: Likewise.
	* data/lalr1.cc: Likewise.
	* data/push.c: Likewise.
	* data/yacc.c: Likewise.

	* doc/bison.texinfo: Remove %before-header, rename
	%{start,end,after}-header to %requires, %provides, %code.

	* src/parse-gram.y: Likewise (also rename token names accordingly).
	* src/scan-gram.l: Likewise.
	* tests/actions.at: Likewise.
This commit is contained in:
Paolo Bonzini
2006-10-15 12:37:07 +00:00
parent 10f429ef19
commit 136a0f766b
13 changed files with 887 additions and 776 deletions

View File

@@ -1,3 +1,21 @@
2006-10-16 Paolo Bonzini <bonzini@gnu.org>
* data/bison.m4 (b4_user_requires, b4_user_provides): New.
(b4_user_start_header): Remove.
* data/glr.c: Use new macros instead of b4_*start_header
and b4_*end_header.
* data/glr.cc: Likewise.
* data/lalr1.cc: Likewise.
* data/push.c: Likewise.
* data/yacc.c: Likewise.
* doc/bison.texinfo: Remove %before-header, rename
%{start,end,after}-header to %requires, %provides, %code.
* src/parse-gram.y: Likewise (also rename token names accordingly).
* src/scan-gram.l: Likewise.
* tests/actions.at: Likewise.
2006-10-14 Paul Eggert <eggert@cs.ucla.edu> 2006-10-14 Paul Eggert <eggert@cs.ucla.edu>
* lib/Makefile.am (AM_CFLAGS): Remove $(WERROR_CFLAGS). * lib/Makefile.am (AM_CFLAGS): Remove $(WERROR_CFLAGS).

View File

@@ -178,14 +178,18 @@ m4_define([b4_define_user_code],
# b4_user_actions # b4_user_actions
# b4_user_initial_action # b4_user_initial_action
# b4_user_post_prologue # b4_user_post_prologue
# b4_user_start_header # b4_user_pre_prologue
# b4_user_provides
# b4_user_requires
# b4_user_stype # b4_user_stype
# ---------------------- # ----------------------
# Macros that issue user code, ending with synclines. # Macros that issue user code, ending with synclines.
b4_define_user_code([actions]) b4_define_user_code([actions])
b4_define_user_code([initial_action]) b4_define_user_code([initial_action])
b4_define_user_code([post_prologue]) b4_define_user_code([post_prologue])
b4_define_user_code([start_header]) b4_define_user_code([pre_prologue])
b4_define_user_code([provides])
b4_define_user_code([requires])
b4_define_user_code([stype]) b4_define_user_code([stype])

View File

@@ -162,16 +162,16 @@ m4_if(b4_prefix, [yy], [],
#define yylloc b4_prefix[]lloc])[ #define yylloc b4_prefix[]lloc])[
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
]b4_pre_prologue ]b4_user_pre_prologue
dnl # b4_shared_declarations dnl # b4_shared_declarations
dnl # ---------------------- dnl # ----------------------
dnl # Declaration that might either go into the header (if --defines) dnl # Declaration that might either go into the header (if --defines)
dnl # or open coded in the parser body. dnl # or open coded in the parser body.
m4_define([b4_shared_declarations], m4_define([b4_shared_declarations],
[m4_ifdef([b4_start_header], [m4_ifdef([b4_requires],
[[/* Copy the %start-header blocks. */ [[/* Copy the %requires blocks. */
]b4_start_header])[]dnl ]b4_user_requires])[]dnl
b4_token_enums(b4_tokens) b4_token_enums(b4_tokens)
@@ -202,9 +202,9 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1 # define YYLTYPE_IS_TRIVIAL 1
#endif #endif
]m4_ifdef([b4_end_header], ]m4_ifdef([b4_provides],
[[/* Copy the %end-header blocks. */ [[/* Copy the %provides blocks. */
]b4_end_header])[]dnl ]b4_user_provides])[]dnl
]) ])
b4_defines_if([#include @output_header_name@], b4_defines_if([#include @output_header_name@],

View File

@@ -225,9 +225,9 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
#ifndef PARSER_HEADER_H #ifndef PARSER_HEADER_H
# define PARSER_HEADER_H # define PARSER_HEADER_H
]m4_ifdef([b4_start_header], ]m4_ifdef([b4_requires],
[[/* Copy the %start-header blocks. */ [[/* Copy the %requires blocks. */
]b4_user_start_header])[ ]b4_user_requires])[
#include <string> #include <string>
#include <iostream> #include <iostream>
@@ -373,8 +373,8 @@ m4_ifset([b4_global_tokens_and_yystype],
} }
]m4_ifdef([b4_end_header], ]m4_ifdef([b4_provides],
[[/* Copy the %end-header blocks. */ [[/* Copy the %provides blocks. */
]b4_end_header])[]dnl ]b4_user_provides])[]dnl
[#endif /* ! defined PARSER_HEADER_H */] [#endif /* ! defined PARSER_HEADER_H */]

View File

@@ -43,9 +43,9 @@ dnl FIXME: This is wrong, we want computed header guards.
#ifndef PARSER_HEADER_H #ifndef PARSER_HEADER_H
# define PARSER_HEADER_H # define PARSER_HEADER_H
]m4_ifdef([b4_start_header], ]m4_ifdef([b4_requires],
[[/* Copy the %start-header blocks. */ [[/* Copy the %requires blocks. */
]b4_user_start_header])[ ]b4_user_requires])[
#include <string> #include <string>
#include <iostream> #include <iostream>
@@ -295,9 +295,9 @@ b4_error_verbose_if([, int tok])[);
# define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type # define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type
#endif #endif
]) ])
m4_ifdef([b4_end_header], m4_ifdef([b4_provides],
[[/* Copy the %end-header blocks. */ [[/* Copy the %provides blocks. */
]b4_end_header])[]dnl ]b4_user_provides])[]dnl
[#endif /* ! defined PARSER_HEADER_H */] [#endif /* ! defined PARSER_HEADER_H */]
])dnl ])dnl
@@ -310,7 +310,7 @@ m4_if(b4_prefix, [yy], [],
#define yylex b4_prefix[]lex])[ #define yylex b4_prefix[]lex])[
/* First part of user declarations. */ /* First part of user declarations. */
]b4_pre_prologue ]b4_user_pre_prologue
b4_defines_if([ b4_defines_if([
#include @output_header_name@])[ #include @output_header_name@])[

View File

@@ -168,7 +168,7 @@ b4_push_if([
#define yylloc_set b4_prefix[]lloc_set])])[ #define yylloc_set b4_prefix[]lloc_set])])[
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
]b4_pre_prologue[ ]b4_user_pre_prologue[
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
@@ -188,9 +188,9 @@ b4_push_if([
# define YYTOKEN_TABLE ]b4_token_table[ # define YYTOKEN_TABLE ]b4_token_table[
#endif #endif
]m4_ifdef([b4_start_header], ]m4_ifdef([b4_requires],
[[/* Copy the %start-header blocks. */ [[/* Copy the %requires blocks. */
]b4_start_header])[]dnl ]b4_user_requires])[]dnl
b4_token_enums_defines(b4_tokens)[ b4_token_enums_defines(b4_tokens)[
@@ -220,9 +220,9 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1 # define YYLTYPE_IS_TRIVIAL 1
#endif]) #endif])
m4_ifdef([b4_end_header], m4_ifdef([b4_provides],
[[/* Copy the %end-header blocks. */ [[/* Copy the %provides blocks. */
]b4_end_header])[]dnl ]b4_user_provides])[]dnl
[/* Copy the second part of user declarations. */ [/* Copy the second part of user declarations. */
]b4_user_post_prologue[ ]b4_user_post_prologue[
@@ -1710,9 +1710,9 @@ b4_defines_if(
b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl ' b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl '
[1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006]) [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])
m4_ifdef([b4_start_header], m4_ifdef([b4_requires],
[[/* Copy the %start-header blocks. */ [[/* Copy the %requires blocks. */
]b4_start_header])[]dnl ]b4_user_requires])[]dnl
b4_token_enums_defines(b4_tokens) b4_token_enums_defines(b4_tokens)
@@ -1752,7 +1752,7 @@ enum { YYPUSH_MORE = 4 };])[
[extern YYLTYPE b4_prefix[]lloc;]) [extern YYLTYPE b4_prefix[]lloc;])
)dnl b4_locations_if )dnl b4_locations_if
m4_ifdef([b4_end_header], m4_ifdef([b4_provides],
[[/* Copy the %end-header blocks. */ [[/* Copy the %provides blocks. */
]b4_end_header])[]dnl ]b4_user_provides])[]dnl
])dnl b4_defines_if ])dnl b4_defines_if

View File

@@ -161,7 +161,7 @@ m4_if(b4_prefix, [yy], [],
b4_locations_if([#define yylloc b4_prefix[]lloc])])[ b4_locations_if([#define yylloc b4_prefix[]lloc])])[
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
]b4_pre_prologue[ ]b4_user_pre_prologue[
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
@@ -181,9 +181,9 @@ b4_locations_if([#define yylloc b4_prefix[]lloc])])[
# define YYTOKEN_TABLE ]b4_token_table[ # define YYTOKEN_TABLE ]b4_token_table[
#endif #endif
]m4_ifdef([b4_start_header], ]m4_ifdef([b4_requires],
[[/* Copy the %start-header blocks. */ [[/* Copy the %requires blocks. */
]b4_start_header])[]dnl ]b4_user_requires])[]dnl
b4_token_enums_defines(b4_tokens)[ b4_token_enums_defines(b4_tokens)[
@@ -213,9 +213,9 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1 # define YYLTYPE_IS_TRIVIAL 1
#endif]) #endif])
m4_ifdef([b4_end_header], m4_ifdef([b4_provides],
[[/* Copy the %end-header blocks. */ [[/* Copy the %provides blocks. */
]b4_end_header])[]dnl ]b4_user_provides])[]dnl
[/* Copy the second part of user declarations. */ [/* Copy the second part of user declarations. */
]b4_user_post_prologue[ ]b4_user_post_prologue[
@@ -1489,9 +1489,9 @@ b4_defines_if(
b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl ' b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl '
[1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006]) [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])
m4_ifdef([b4_start_header], m4_ifdef([b4_requires],
[[/* Copy the %start-header blocks. */ [[/* Copy the %requires blocks. */
]b4_start_header])[]dnl ]b4_user_requires])[]dnl
b4_token_enums_defines(b4_tokens) b4_token_enums_defines(b4_tokens)
@@ -1529,7 +1529,7 @@ typedef struct YYLTYPE
[extern YYLTYPE b4_prefix[]lloc;]) [extern YYLTYPE b4_prefix[]lloc;])
)dnl b4_locations_if )dnl b4_locations_if
m4_ifdef([b4_end_header], m4_ifdef([b4_provides],
[[/* Copy the %end-header blocks. */ [[/* Copy the %provides blocks. */
]b4_end_header])[]dnl ]b4_user_provides])[]dnl
])dnl b4_defines_if ])dnl b4_defines_if

View File

@@ -2674,22 +2674,17 @@ of feature test macros like @code{_GNU_SOURCE} or
feature test macros can affect the behavior of Bison-generated feature test macros can affect the behavior of Bison-generated
@code{#include} directives. @code{#include} directives.
@findex %before-header @findex %requires
@findex %start-header @findex %code
@findex %after-header
If you've instructed Bison to generate a header file (@pxref{Table of Symbols, If you've instructed Bison to generate a header file (@pxref{Table of Symbols,
,%defines}), you probably want @code{#include "ptypes.h"} to appear ,%defines}), you probably want @code{#include "ptypes.h"} to appear
in that header file as well. in that header file as well.
In that case, use @code{%before-header}, @code{%start-header}, and In that case, use @code{%requires}, @code{%provides}, and
@code{%after-header} instead of @var{Prologue} sections @code{%code} instead of @var{Prologue} sections
(@pxref{Table of Symbols, ,%start-header}): (@pxref{Table of Symbols, ,%requires}):
@smallexample @smallexample
%before-header @{ %requires @{
#include <stdio.h>
@}
%start-header @{
#include "ptypes.h" #include "ptypes.h"
@} @}
%union @{ %union @{
@@ -2697,7 +2692,9 @@ In that case, use @code{%before-header}, @code{%start-header}, and
tree t; /* @r{@code{tree} is defined in @file{ptypes.h}.} */ tree t; /* @r{@code{tree} is defined in @file{ptypes.h}.} */
@} @}
%after-header @{ %code @{
#include <stdio.h>
static void print_token_value (FILE *, int, YYSTYPE); static void print_token_value (FILE *, int, YYSTYPE);
#define YYPRINT(F, N, L) print_token_value (F, N, L) #define YYPRINT(F, N, L) print_token_value (F, N, L)
@} @}
@@ -4327,11 +4324,11 @@ typically needs to be able to refer to the above-mentioned declarations
and to the token type codes. @xref{Token Values, ,Semantic Values of and to the token type codes. @xref{Token Values, ,Semantic Values of
Tokens}. Tokens}.
@findex %start-header @findex %requires
@findex %end-header @findex %provides
If you have declared @code{%start-header} or @code{%end-header}, the output If you have declared @code{%requires} or @code{%provides}, the output
header also contains their code. header also contains their code.
@xref{Table of Symbols, ,%start-header}. @xref{Table of Symbols, ,%requires}.
@end deffn @end deffn
@deffn {Directive} %destructor @deffn {Directive} %destructor
@@ -7560,18 +7557,18 @@ the grammar for.
@end example @end example
@noindent @noindent
@findex %start-header @findex %requires
Then come the declarations/inclusions needed to define the Then come the declarations/inclusions needed to define the
@code{%union}. Because the parser uses the parsing driver and @code{%union}. Because the parser uses the parsing driver and
reciprocally, both cannot include the header of the other. Because the reciprocally, both cannot include the header of the other. Because the
driver's header needs detailed knowledge about the parser class (in driver's header needs detailed knowledge about the parser class (in
particular its inner types), it is the parser's header which will simply particular its inner types), it is the parser's header which will simply
use a forward declaration of the driver. use a forward declaration of the driver.
@xref{Table of Symbols, ,%start-header}. @xref{Table of Symbols, ,%requires}.
@comment file: calc++-parser.yy @comment file: calc++-parser.yy
@example @example
%start-header @{ %requires @{
# include <string> # include <string>
class calcxx_driver; class calcxx_driver;
@} @}
@@ -7630,13 +7627,13 @@ them.
@end example @end example
@noindent @noindent
@findex %after-header @findex %code
The code between @samp{%after-header @{} and @samp{@}} is output in the The code between @samp{%code @{} and @samp{@}} is output in the
@file{*.cc} file; it needs detailed knowledge about the driver. @file{*.cc} file; it needs detailed knowledge about the driver.
@comment file: calc++-parser.yy @comment file: calc++-parser.yy
@example @example
%after-header @{ %code @{
# include "calc++-driver.hh" # include "calc++-driver.hh"
@} @}
@end example @end example
@@ -8308,49 +8305,35 @@ $end}, where @var{start} is the start symbol. @xref{Start Decl, , The
Start-Symbol}. It cannot be used in the grammar. Start-Symbol}. It cannot be used in the grammar.
@end deffn @end deffn
@deffn {Directive} %after-header @{@var{code}@} @deffn {Directive} %code @{@var{code}@}
Specifies code to be inserted into the code file after the contents of the Specifies code to be inserted into the code file after the contents of the
header file. header file.
@xref{Table of Symbols, ,%start-header}. @xref{Table of Symbols, ,%requires}.
@end deffn @end deffn
@deffn {Directive} %before-header @{@var{code}@} @deffn {Directive} %provides @{@var{code}@}
Specifies code to be inserted into the code file before the contents of the
header file.
@xref{Table of Symbols, ,%start-header}.
@end deffn
@deffn {Directive} %end-header @{@var{code}@}
Specifies code to be inserted both into the header file (if generated; Specifies code to be inserted both into the header file (if generated;
@pxref{Table of Symbols, ,%defines}) and into the code file after any @pxref{Table of Symbols, ,%defines}) and into the code file after any
Bison-generated definitions. Bison-generated definitions.
@xref{Table of Symbols, ,%start-header}. @xref{Table of Symbols, ,%requires}.
@end deffn @end deffn
@deffn {Directive} %start-header @{@var{code}@} @deffn {Directive} %requires @{@var{code}@}
Specifies code to be inserted both into the header file (if generated; Specifies code to be inserted both into the header file (if generated;
@pxref{Table of Symbols, ,%defines}) and into the code file before any @pxref{Table of Symbols, ,%defines}) and into the code file before any
Bison-generated definitions. Bison-generated definitions.
@cindex Prologue @cindex Prologue
@findex %before-header
@findex %union @findex %union
@findex %end-header @findex %provides
@findex %after-header @findex %code
For example, the following declaration order in the grammar file reflects the For example, the following declaration order in the grammar file reflects the
order in which Bison will output these code blocks. However, you are free to order in which Bison will output these code blocks. However, you are free to
declare these code blocks in your grammar file in whatever order is most declare these code blocks in your grammar file in whatever order is most
convenient for you: convenient for you:
@smallexample @smallexample
%before-header @{ %requires @{
/* Bison treats this block like a pre-prologue block: it inserts it
* into the code file before the contents of the header file. It
* does *not* insert it into the header file. This is a good place
* to put #include's that you want at the top of your code file. A
* common example is `#include "system.h"'. */
@}
%start-header @{
/* Bison inserts this block into both the header file and the code /* Bison inserts this block into both the header file and the code
* file. In both files, the point of insertion is before any * file. In both files, the point of insertion is before any
* Bison-generated token, semantic type, location type, and class * Bison-generated token, semantic type, location type, and class
@@ -8359,17 +8342,17 @@ convenient for you:
@} @}
%union @{ %union @{
/* Unlike the traditional Yacc prologue blocks, the output order /* Unlike the traditional Yacc prologue blocks, the output order
* for the %*-header blocks is not affected by their declaration * for %requires, %provides or %code blocks is not affected by their
* position relative to any %union in the grammar file. */ * declaration position relative to any %union in the grammar file. */
@} @}
%end-header @{ %provides @{
/* Bison inserts this block into both the header file and the code /* Bison inserts this block into both the header file and the code
* file. In both files, the point of insertion is after the * file. In both files, the point of insertion is after the
* Bison-generated definitions. This is a good place to declare or * Bison-generated definitions. This is a good place to declare or
* define public functions or data structures that depend on the * define public functions or data structures that depend on the
* Bison-generated definitions. */ * Bison-generated definitions. */
@} @}
%after-header @{ %code @{
/* Bison treats this block like a post-prologue block: it inserts /* Bison treats this block like a post-prologue block: it inserts
* it into the code file after the contents of the header file. It * it into the code file after the contents of the header file. It
* does *not* insert it into the header file. This is a good place * does *not* insert it into the header file. This is a good place

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 2.3a. */ /* A Bison parser, made by GNU Bison 2.3a+. */
/* Skeleton interface for Bison's Yacc-like parsers in C /* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc. Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -55,48 +55,47 @@
PERCENT_PREC = 269, PERCENT_PREC = 269,
PERCENT_DPREC = 270, PERCENT_DPREC = 270,
PERCENT_MERGE = 271, PERCENT_MERGE = 271,
PERCENT_AFTER_HEADER = 272, PERCENT_CODE = 272,
PERCENT_BEFORE_HEADER = 273, PERCENT_DEBUG = 273,
PERCENT_DEBUG = 274, PERCENT_DEFAULT_PREC = 274,
PERCENT_DEFAULT_PREC = 275, PERCENT_DEFINE = 275,
PERCENT_DEFINE = 276, PERCENT_DEFINES = 276,
PERCENT_DEFINES = 277, PERCENT_ERROR_VERBOSE = 277,
PERCENT_END_HEADER = 278, PERCENT_EXPECT = 278,
PERCENT_ERROR_VERBOSE = 279, PERCENT_EXPECT_RR = 279,
PERCENT_EXPECT = 280, PERCENT_FILE_PREFIX = 280,
PERCENT_EXPECT_RR = 281, PERCENT_GLR_PARSER = 281,
PERCENT_FILE_PREFIX = 282, PERCENT_INITIAL_ACTION = 282,
PERCENT_GLR_PARSER = 283, PERCENT_LEX_PARAM = 283,
PERCENT_INITIAL_ACTION = 284, PERCENT_LOCATIONS = 284,
PERCENT_LEX_PARAM = 285, PERCENT_NAME_PREFIX = 285,
PERCENT_LOCATIONS = 286, PERCENT_NO_DEFAULT_PREC = 286,
PERCENT_NAME_PREFIX = 287, PERCENT_NO_LINES = 287,
PERCENT_NO_DEFAULT_PREC = 288, PERCENT_NONDETERMINISTIC_PARSER = 288,
PERCENT_NO_LINES = 289, PERCENT_OUTPUT = 289,
PERCENT_NONDETERMINISTIC_PARSER = 290, PERCENT_PARSE_PARAM = 290,
PERCENT_OUTPUT = 291, PERCENT_PROVIDES = 291,
PERCENT_PARSE_PARAM = 292, PERCENT_PURE_PARSER = 292,
PERCENT_PURE_PARSER = 293, PERCENT_PUSH_PARSER = 293,
PERCENT_PUSH_PARSER = 294, PERCENT_REQUIRE = 294,
PERCENT_REQUIRE = 295, PERCENT_REQUIRES = 295,
PERCENT_SKELETON = 296, PERCENT_SKELETON = 296,
PERCENT_START = 297, PERCENT_START = 297,
PERCENT_START_HEADER = 298, PERCENT_TOKEN_TABLE = 298,
PERCENT_TOKEN_TABLE = 299, PERCENT_VERBOSE = 299,
PERCENT_VERBOSE = 300, PERCENT_YACC = 300,
PERCENT_YACC = 301, BRACED_CODE = 301,
BRACED_CODE = 302, CHAR = 302,
CHAR = 303, EPILOGUE = 303,
EPILOGUE = 304, EQUAL = 304,
EQUAL = 305, ID = 305,
ID = 306, ID_COLON = 306,
ID_COLON = 307, PERCENT_PERCENT = 307,
PERCENT_PERCENT = 308, PIPE = 308,
PIPE = 309, PROLOGUE = 309,
PROLOGUE = 310, SEMICOLON = 310,
SEMICOLON = 311, TYPE = 311,
TYPE = 312, PERCENT_UNION = 312
PERCENT_UNION = 313
}; };
#endif #endif
/* Tokens. */ /* Tokens. */
@@ -115,56 +114,56 @@
#define PERCENT_PREC 269 #define PERCENT_PREC 269
#define PERCENT_DPREC 270 #define PERCENT_DPREC 270
#define PERCENT_MERGE 271 #define PERCENT_MERGE 271
#define PERCENT_AFTER_HEADER 272 #define PERCENT_CODE 272
#define PERCENT_BEFORE_HEADER 273 #define PERCENT_DEBUG 273
#define PERCENT_DEBUG 274 #define PERCENT_DEFAULT_PREC 274
#define PERCENT_DEFAULT_PREC 275 #define PERCENT_DEFINE 275
#define PERCENT_DEFINE 276 #define PERCENT_DEFINES 276
#define PERCENT_DEFINES 277 #define PERCENT_ERROR_VERBOSE 277
#define PERCENT_END_HEADER 278 #define PERCENT_EXPECT 278
#define PERCENT_ERROR_VERBOSE 279 #define PERCENT_EXPECT_RR 279
#define PERCENT_EXPECT 280 #define PERCENT_FILE_PREFIX 280
#define PERCENT_EXPECT_RR 281 #define PERCENT_GLR_PARSER 281
#define PERCENT_FILE_PREFIX 282 #define PERCENT_INITIAL_ACTION 282
#define PERCENT_GLR_PARSER 283 #define PERCENT_LEX_PARAM 283
#define PERCENT_INITIAL_ACTION 284 #define PERCENT_LOCATIONS 284
#define PERCENT_LEX_PARAM 285 #define PERCENT_NAME_PREFIX 285
#define PERCENT_LOCATIONS 286 #define PERCENT_NO_DEFAULT_PREC 286
#define PERCENT_NAME_PREFIX 287 #define PERCENT_NO_LINES 287
#define PERCENT_NO_DEFAULT_PREC 288 #define PERCENT_NONDETERMINISTIC_PARSER 288
#define PERCENT_NO_LINES 289 #define PERCENT_OUTPUT 289
#define PERCENT_NONDETERMINISTIC_PARSER 290 #define PERCENT_PARSE_PARAM 290
#define PERCENT_OUTPUT 291 #define PERCENT_PROVIDES 291
#define PERCENT_PARSE_PARAM 292 #define PERCENT_PURE_PARSER 292
#define PERCENT_PURE_PARSER 293 #define PERCENT_PUSH_PARSER 293
#define PERCENT_PUSH_PARSER 294 #define PERCENT_REQUIRE 294
#define PERCENT_REQUIRE 295 #define PERCENT_REQUIRES 295
#define PERCENT_SKELETON 296 #define PERCENT_SKELETON 296
#define PERCENT_START 297 #define PERCENT_START 297
#define PERCENT_START_HEADER 298 #define PERCENT_TOKEN_TABLE 298
#define PERCENT_TOKEN_TABLE 299 #define PERCENT_VERBOSE 299
#define PERCENT_VERBOSE 300 #define PERCENT_YACC 300
#define PERCENT_YACC 301 #define BRACED_CODE 301
#define BRACED_CODE 302 #define CHAR 302
#define CHAR 303 #define EPILOGUE 303
#define EPILOGUE 304 #define EQUAL 304
#define EQUAL 305 #define ID 305
#define ID 306 #define ID_COLON 306
#define ID_COLON 307 #define PERCENT_PERCENT 307
#define PERCENT_PERCENT 308 #define PIPE 308
#define PIPE 309 #define PROLOGUE 309
#define PROLOGUE 310 #define SEMICOLON 310
#define SEMICOLON 311 #define TYPE 311
#define TYPE 312 #define PERCENT_UNION 312
#define PERCENT_UNION 313
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
{/* Line 1535 of yacc.c. */ {
#line 98 "parse-gram.y" /* Line 1535 of yacc.c */
#line 98 "../../src/parse-gram.y"
symbol *symbol; symbol *symbol;
symbol_list *list; symbol_list *list;
@@ -174,8 +173,9 @@ typedef union YYSTYPE
uniqstr uniqstr; uniqstr uniqstr;
unsigned char character; unsigned char character;
} }
/* Line 1535 of yacc.c. */
#line 179 "parse-gram.h" /* Line 1535 of yacc.c */
#line 179 "../../src/parse-gram.h"
YYSTYPE; YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */

View File

@@ -133,13 +133,11 @@ static int current_prec = 0;
`----------------------*/ `----------------------*/
%token %token
PERCENT_AFTER_HEADER "%after-header" PERCENT_CODE "%code"
PERCENT_BEFORE_HEADER "%before-header"
PERCENT_DEBUG "%debug" PERCENT_DEBUG "%debug"
PERCENT_DEFAULT_PREC "%default-prec" PERCENT_DEFAULT_PREC "%default-prec"
PERCENT_DEFINE "%define" PERCENT_DEFINE "%define"
PERCENT_DEFINES "%defines" PERCENT_DEFINES "%defines"
PERCENT_END_HEADER "%end-header"
PERCENT_ERROR_VERBOSE "%error-verbose" PERCENT_ERROR_VERBOSE "%error-verbose"
PERCENT_EXPECT "%expect" PERCENT_EXPECT "%expect"
PERCENT_EXPECT_RR "%expect-rr" PERCENT_EXPECT_RR "%expect-rr"
@@ -155,12 +153,13 @@ static int current_prec = 0;
"%nondeterministic-parser" "%nondeterministic-parser"
PERCENT_OUTPUT "%output" PERCENT_OUTPUT "%output"
PERCENT_PARSE_PARAM "%parse-param" PERCENT_PARSE_PARAM "%parse-param"
PERCENT_PROVIDES "%provides"
PERCENT_PURE_PARSER "%pure-parser" PERCENT_PURE_PARSER "%pure-parser"
PERCENT_PUSH_PARSER "%push-parser" PERCENT_PUSH_PARSER "%push-parser"
PERCENT_REQUIRE "%require" PERCENT_REQUIRE "%require"
PERCENT_REQUIRES "%requires"
PERCENT_SKELETON "%skeleton" PERCENT_SKELETON "%skeleton"
PERCENT_START "%start" PERCENT_START "%start"
PERCENT_START_HEADER "%start-header"
PERCENT_TOKEN_TABLE "%token-table" PERCENT_TOKEN_TABLE "%token-table"
PERCENT_VERBOSE "%verbose" PERCENT_VERBOSE "%verbose"
PERCENT_YACC "%yacc" PERCENT_YACC "%yacc"
@@ -222,12 +221,10 @@ prologue_declarations:
prologue_declaration: prologue_declaration:
grammar_declaration grammar_declaration
| "%{...%}" { prologue_augment (translate_code ($1, @1), @1, union_seen); } | "%{...%}" { prologue_augment (translate_code ($1, @1), @1, union_seen); }
| "%after-header" braceless { prologue_augment ($2, @2, true); } | "%code" braceless { prologue_augment ($2, @2, true); }
| "%before-header" braceless { prologue_augment ($2, @2, false); }
| "%debug" { debug_flag = true; } | "%debug" { debug_flag = true; }
| "%define" STRING content.opt { muscle_insert ($2, $3); } | "%define" STRING content.opt { muscle_insert ($2, $3); }
| "%defines" { defines_flag = true; } | "%defines" { defines_flag = true; }
| "%end-header" braceless { muscle_code_grow ("end_header", $2, @2); }
| "%error-verbose" { error_verbose = true; } | "%error-verbose" { error_verbose = true; }
| "%expect" INT { expected_sr_conflicts = $2; } | "%expect" INT { expected_sr_conflicts = $2; }
| "%expect-rr" INT { expected_rr_conflicts = $2; } | "%expect-rr" INT { expected_rr_conflicts = $2; }
@@ -248,11 +245,12 @@ prologue_declaration:
| "%nondeterministic-parser" { nondeterministic_parser = true; } | "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%output" "=" STRING { spec_outfile = $3; } | "%output" "=" STRING { spec_outfile = $3; }
| "%parse-param" "{...}" { add_param ("parse_param", $2, @2); } | "%parse-param" "{...}" { add_param ("parse_param", $2, @2); }
| "%provides" braceless { muscle_code_grow ("provides", $2, @2); }
| "%pure-parser" { pure_parser = true; } | "%pure-parser" { pure_parser = true; }
| "%push-parser" { push_parser = true; } | "%push-parser" { push_parser = true; }
| "%require" STRING { version_check (&@2, $2); } | "%require" STRING { version_check (&@2, $2); }
| "%requires" braceless { muscle_code_grow ("requires", $2, @2); }
| "%skeleton" STRING { skeleton = $2; } | "%skeleton" STRING { skeleton = $2; }
| "%start-header" braceless { muscle_code_grow ("start_header", $2, @2); }
| "%token-table" { token_table_flag = true; } | "%token-table" { token_table_flag = true; }
| "%verbose" { report_flag = report_states; } | "%verbose" { report_flag = report_states; }
| "%yacc" { yacc_flag = true; } | "%yacc" { yacc_flag = true; }

View File

@@ -156,16 +156,14 @@ splice (\\[ \f\t\v]*\n)*
`----------------------------*/ `----------------------------*/
<INITIAL> <INITIAL>
{ {
"%after-header" return PERCENT_AFTER_HEADER;
"%before-header" return PERCENT_BEFORE_HEADER;
"%binary" return PERCENT_NONASSOC; "%binary" return PERCENT_NONASSOC;
"%code" return PERCENT_CODE;
"%debug" return PERCENT_DEBUG; "%debug" return PERCENT_DEBUG;
"%default"[-_]"prec" return PERCENT_DEFAULT_PREC; "%default"[-_]"prec" return PERCENT_DEFAULT_PREC;
"%define" return PERCENT_DEFINE; "%define" return PERCENT_DEFINE;
"%defines" return PERCENT_DEFINES; "%defines" return PERCENT_DEFINES;
"%destructor" return PERCENT_DESTRUCTOR; "%destructor" return PERCENT_DESTRUCTOR;
"%dprec" return PERCENT_DPREC; "%dprec" return PERCENT_DPREC;
"%end-header" return PERCENT_END_HEADER;
"%error"[-_]"verbose" return PERCENT_ERROR_VERBOSE; "%error"[-_]"verbose" return PERCENT_ERROR_VERBOSE;
"%expect" return PERCENT_EXPECT; "%expect" return PERCENT_EXPECT;
"%expect"[-_]"rr" return PERCENT_EXPECT_RR; "%expect"[-_]"rr" return PERCENT_EXPECT_RR;
@@ -187,13 +185,14 @@ splice (\\[ \f\t\v]*\n)*
"%parse-param" return PERCENT_PARSE_PARAM; "%parse-param" return PERCENT_PARSE_PARAM;
"%prec" return PERCENT_PREC; "%prec" return PERCENT_PREC;
"%printer" return PERCENT_PRINTER; "%printer" return PERCENT_PRINTER;
"%provides" return PERCENT_PROVIDES;
"%pure"[-_]"parser" return PERCENT_PURE_PARSER; "%pure"[-_]"parser" return PERCENT_PURE_PARSER;
"%push"[-_]"parser" return PERCENT_PUSH_PARSER; "%push"[-_]"parser" return PERCENT_PUSH_PARSER;
"%require" return PERCENT_REQUIRE; "%require" return PERCENT_REQUIRE;
"%requires" return PERCENT_REQUIRES;
"%right" return PERCENT_RIGHT; "%right" return PERCENT_RIGHT;
"%skeleton" return PERCENT_SKELETON; "%skeleton" return PERCENT_SKELETON;
"%start" return PERCENT_START; "%start" return PERCENT_START;
"%start-header" return PERCENT_START_HEADER;
"%symbol-default" return PERCENT_SYMBOL_DEFAULT; "%symbol-default" return PERCENT_SYMBOL_DEFAULT;
"%term" return PERCENT_TOKEN; "%term" return PERCENT_TOKEN;
"%token" return PERCENT_TOKEN; "%token" return PERCENT_TOKEN;

View File

@@ -178,7 +178,7 @@ m4_if([$1$2$3], $[1]$[2]$[3], [],
# helping macros. So don't put any directly in the Bison file. # helping macros. So don't put any directly in the Bison file.
AT_BISON_OPTION_PUSHDEFS([$5]) AT_BISON_OPTION_PUSHDEFS([$5])
AT_DATA_GRAMMAR([[input.y]], AT_DATA_GRAMMAR([[input.y]],
[[%start-header { [[%requires {
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -197,7 +197,7 @@ m4_ifval([$6], [%union
int ival; int ival;
}]) }])
AT_LALR1_CC_IF([%define "global_tokens_and_yystype"]) AT_LALR1_CC_IF([%define "global_tokens_and_yystype"])
m4_ifval([$6], [[%end-header {]], [[%after-header {]]) m4_ifval([$6], [[%provides {]], [[%code {]])
AT_LALR1_CC_IF([typedef yy::location YYLTYPE;]) AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])
[static int yylex (]AT_LEX_FORMALS[); [static int yylex (]AT_LEX_FORMALS[);
]AT_LALR1_CC_IF([], [static void yyerror (const char *msg);]) ]AT_LALR1_CC_IF([], [static void yyerror (const char *msg);])