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>
* 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_initial_action
# b4_user_post_prologue
# b4_user_start_header
# b4_user_pre_prologue
# b4_user_provides
# b4_user_requires
# b4_user_stype
# ----------------------
# Macros that issue user code, ending with synclines.
b4_define_user_code([actions])
b4_define_user_code([initial_action])
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])

View File

@@ -162,16 +162,16 @@ m4_if(b4_prefix, [yy], [],
#define yylloc b4_prefix[]lloc])[
/* Copy the first part of user declarations. */
]b4_pre_prologue
]b4_user_pre_prologue
dnl # b4_shared_declarations
dnl # ----------------------
dnl # Declaration that might either go into the header (if --defines)
dnl # or open coded in the parser body.
m4_define([b4_shared_declarations],
[m4_ifdef([b4_start_header],
[[/* Copy the %start-header blocks. */
]b4_start_header])[]dnl
[m4_ifdef([b4_requires],
[[/* Copy the %requires blocks. */
]b4_user_requires])[]dnl
b4_token_enums(b4_tokens)
@@ -202,9 +202,9 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1
#endif
]m4_ifdef([b4_end_header],
[[/* Copy the %end-header blocks. */
]b4_end_header])[]dnl
]m4_ifdef([b4_provides],
[[/* Copy the %provides blocks. */
]b4_user_provides])[]dnl
])
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
# define PARSER_HEADER_H
]m4_ifdef([b4_start_header],
[[/* Copy the %start-header blocks. */
]b4_user_start_header])[
]m4_ifdef([b4_requires],
[[/* Copy the %requires blocks. */
]b4_user_requires])[
#include <string>
#include <iostream>
@@ -373,8 +373,8 @@ m4_ifset([b4_global_tokens_and_yystype],
}
]m4_ifdef([b4_end_header],
[[/* Copy the %end-header blocks. */
]b4_end_header])[]dnl
]m4_ifdef([b4_provides],
[[/* Copy the %provides blocks. */
]b4_user_provides])[]dnl
[#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
# define PARSER_HEADER_H
]m4_ifdef([b4_start_header],
[[/* Copy the %start-header blocks. */
]b4_user_start_header])[
]m4_ifdef([b4_requires],
[[/* Copy the %requires blocks. */
]b4_user_requires])[
#include <string>
#include <iostream>
@@ -295,9 +295,9 @@ b4_error_verbose_if([, int tok])[);
# define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type
#endif
])
m4_ifdef([b4_end_header],
[[/* Copy the %end-header blocks. */
]b4_end_header])[]dnl
m4_ifdef([b4_provides],
[[/* Copy the %provides blocks. */
]b4_user_provides])[]dnl
[#endif /* ! defined PARSER_HEADER_H */]
])dnl
@@ -310,7 +310,7 @@ m4_if(b4_prefix, [yy], [],
#define yylex b4_prefix[]lex])[
/* First part of user declarations. */
]b4_pre_prologue
]b4_user_pre_prologue
b4_defines_if([
#include @output_header_name@])[

View File

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

View File

@@ -161,7 +161,7 @@ m4_if(b4_prefix, [yy], [],
b4_locations_if([#define yylloc b4_prefix[]lloc])])[
/* Copy the first part of user declarations. */
]b4_pre_prologue[
]b4_user_pre_prologue[
/* Enabling traces. */
#ifndef YYDEBUG
@@ -181,9 +181,9 @@ b4_locations_if([#define yylloc b4_prefix[]lloc])])[
# define YYTOKEN_TABLE ]b4_token_table[
#endif
]m4_ifdef([b4_start_header],
[[/* Copy the %start-header blocks. */
]b4_start_header])[]dnl
]m4_ifdef([b4_requires],
[[/* Copy the %requires blocks. */
]b4_user_requires])[]dnl
b4_token_enums_defines(b4_tokens)[
@@ -213,9 +213,9 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1
#endif])
m4_ifdef([b4_end_header],
[[/* Copy the %end-header blocks. */
]b4_end_header])[]dnl
m4_ifdef([b4_provides],
[[/* Copy the %provides blocks. */
]b4_user_provides])[]dnl
[/* Copy the second part of user declarations. */
]b4_user_post_prologue[
@@ -1489,9 +1489,9 @@ b4_defines_if(
b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl '
[1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])
m4_ifdef([b4_start_header],
[[/* Copy the %start-header blocks. */
]b4_start_header])[]dnl
m4_ifdef([b4_requires],
[[/* Copy the %requires blocks. */
]b4_user_requires])[]dnl
b4_token_enums_defines(b4_tokens)
@@ -1529,7 +1529,7 @@ typedef struct YYLTYPE
[extern YYLTYPE b4_prefix[]lloc;])
)dnl b4_locations_if
m4_ifdef([b4_end_header],
[[/* Copy the %end-header blocks. */
]b4_end_header])[]dnl
m4_ifdef([b4_provides],
[[/* Copy the %provides blocks. */
]b4_user_provides])[]dnl
])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
@code{#include} directives.
@findex %before-header
@findex %start-header
@findex %after-header
@findex %requires
@findex %code
If you've instructed Bison to generate a header file (@pxref{Table of Symbols,
,%defines}), you probably want @code{#include "ptypes.h"} to appear
in that header file as well.
In that case, use @code{%before-header}, @code{%start-header}, and
@code{%after-header} instead of @var{Prologue} sections
(@pxref{Table of Symbols, ,%start-header}):
In that case, use @code{%requires}, @code{%provides}, and
@code{%code} instead of @var{Prologue} sections
(@pxref{Table of Symbols, ,%requires}):
@smallexample
%before-header @{
#include <stdio.h>
@}
%start-header @{
%requires @{
#include "ptypes.h"
@}
%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}.} */
@}
%after-header @{
%code @{
#include <stdio.h>
static void print_token_value (FILE *, int, YYSTYPE);
#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
Tokens}.
@findex %start-header
@findex %end-header
If you have declared @code{%start-header} or @code{%end-header}, the output
@findex %requires
@findex %provides
If you have declared @code{%requires} or @code{%provides}, the output
header also contains their code.
@xref{Table of Symbols, ,%start-header}.
@xref{Table of Symbols, ,%requires}.
@end deffn
@deffn {Directive} %destructor
@@ -7560,18 +7557,18 @@ the grammar for.
@end example
@noindent
@findex %start-header
@findex %requires
Then come the declarations/inclusions needed to define the
@code{%union}. Because the parser uses the parsing driver and
reciprocally, both cannot include the header of the other. Because the
driver's header needs detailed knowledge about the parser class (in
particular its inner types), it is the parser's header which will simply
use a forward declaration of the driver.
@xref{Table of Symbols, ,%start-header}.
@xref{Table of Symbols, ,%requires}.
@comment file: calc++-parser.yy
@example
%start-header @{
%requires @{
# include <string>
class calcxx_driver;
@}
@@ -7630,13 +7627,13 @@ them.
@end example
@noindent
@findex %after-header
The code between @samp{%after-header @{} and @samp{@}} is output in the
@findex %code
The code between @samp{%code @{} and @samp{@}} is output in the
@file{*.cc} file; it needs detailed knowledge about the driver.
@comment file: calc++-parser.yy
@example
%after-header @{
%code @{
# include "calc++-driver.hh"
@}
@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.
@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
header file.
@xref{Table of Symbols, ,%start-header}.
@xref{Table of Symbols, ,%requires}.
@end deffn
@deffn {Directive} %before-header @{@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}@}
@deffn {Directive} %provides @{@var{code}@}
Specifies code to be inserted both into the header file (if generated;
@pxref{Table of Symbols, ,%defines}) and into the code file after any
Bison-generated definitions.
@xref{Table of Symbols, ,%start-header}.
@xref{Table of Symbols, ,%requires}.
@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;
@pxref{Table of Symbols, ,%defines}) and into the code file before any
Bison-generated definitions.
@cindex Prologue
@findex %before-header
@findex %union
@findex %end-header
@findex %after-header
@findex %provides
@findex %code
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
declare these code blocks in your grammar file in whatever order is most
convenient for you:
@smallexample
%before-header @{
/* 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 @{
%requires @{
/* Bison inserts this block into both the header file and the code
* file. In both files, the point of insertion is before any
* Bison-generated token, semantic type, location type, and class
@@ -8359,17 +8342,17 @@ convenient for you:
@}
%union @{
/* Unlike the traditional Yacc prologue blocks, the output order
* for the %*-header blocks is not affected by their declaration
* position relative to any %union in the grammar file. */
* for %requires, %provides or %code blocks is not affected by their
* 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
* file. In both files, the point of insertion is after the
* Bison-generated definitions. This is a good place to declare or
* define public functions or data structures that depend on the
* Bison-generated definitions. */
@}
%after-header @{
%code @{
/* Bison treats this block like a post-prologue block: it inserts
* 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

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +1,20 @@
/* 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
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.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -29,7 +29,7 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
@@ -55,48 +55,47 @@
PERCENT_PREC = 269,
PERCENT_DPREC = 270,
PERCENT_MERGE = 271,
PERCENT_AFTER_HEADER = 272,
PERCENT_BEFORE_HEADER = 273,
PERCENT_DEBUG = 274,
PERCENT_DEFAULT_PREC = 275,
PERCENT_DEFINE = 276,
PERCENT_DEFINES = 277,
PERCENT_END_HEADER = 278,
PERCENT_ERROR_VERBOSE = 279,
PERCENT_EXPECT = 280,
PERCENT_EXPECT_RR = 281,
PERCENT_FILE_PREFIX = 282,
PERCENT_GLR_PARSER = 283,
PERCENT_INITIAL_ACTION = 284,
PERCENT_LEX_PARAM = 285,
PERCENT_LOCATIONS = 286,
PERCENT_NAME_PREFIX = 287,
PERCENT_NO_DEFAULT_PREC = 288,
PERCENT_NO_LINES = 289,
PERCENT_NONDETERMINISTIC_PARSER = 290,
PERCENT_OUTPUT = 291,
PERCENT_PARSE_PARAM = 292,
PERCENT_PURE_PARSER = 293,
PERCENT_PUSH_PARSER = 294,
PERCENT_REQUIRE = 295,
PERCENT_CODE = 272,
PERCENT_DEBUG = 273,
PERCENT_DEFAULT_PREC = 274,
PERCENT_DEFINE = 275,
PERCENT_DEFINES = 276,
PERCENT_ERROR_VERBOSE = 277,
PERCENT_EXPECT = 278,
PERCENT_EXPECT_RR = 279,
PERCENT_FILE_PREFIX = 280,
PERCENT_GLR_PARSER = 281,
PERCENT_INITIAL_ACTION = 282,
PERCENT_LEX_PARAM = 283,
PERCENT_LOCATIONS = 284,
PERCENT_NAME_PREFIX = 285,
PERCENT_NO_DEFAULT_PREC = 286,
PERCENT_NO_LINES = 287,
PERCENT_NONDETERMINISTIC_PARSER = 288,
PERCENT_OUTPUT = 289,
PERCENT_PARSE_PARAM = 290,
PERCENT_PROVIDES = 291,
PERCENT_PURE_PARSER = 292,
PERCENT_PUSH_PARSER = 293,
PERCENT_REQUIRE = 294,
PERCENT_REQUIRES = 295,
PERCENT_SKELETON = 296,
PERCENT_START = 297,
PERCENT_START_HEADER = 298,
PERCENT_TOKEN_TABLE = 299,
PERCENT_VERBOSE = 300,
PERCENT_YACC = 301,
BRACED_CODE = 302,
CHAR = 303,
EPILOGUE = 304,
EQUAL = 305,
ID = 306,
ID_COLON = 307,
PERCENT_PERCENT = 308,
PIPE = 309,
PROLOGUE = 310,
SEMICOLON = 311,
TYPE = 312,
PERCENT_UNION = 313
PERCENT_TOKEN_TABLE = 298,
PERCENT_VERBOSE = 299,
PERCENT_YACC = 300,
BRACED_CODE = 301,
CHAR = 302,
EPILOGUE = 303,
EQUAL = 304,
ID = 305,
ID_COLON = 306,
PERCENT_PERCENT = 307,
PIPE = 308,
PROLOGUE = 309,
SEMICOLON = 310,
TYPE = 311,
PERCENT_UNION = 312
};
#endif
/* Tokens. */
@@ -115,56 +114,56 @@
#define PERCENT_PREC 269
#define PERCENT_DPREC 270
#define PERCENT_MERGE 271
#define PERCENT_AFTER_HEADER 272
#define PERCENT_BEFORE_HEADER 273
#define PERCENT_DEBUG 274
#define PERCENT_DEFAULT_PREC 275
#define PERCENT_DEFINE 276
#define PERCENT_DEFINES 277
#define PERCENT_END_HEADER 278
#define PERCENT_ERROR_VERBOSE 279
#define PERCENT_EXPECT 280
#define PERCENT_EXPECT_RR 281
#define PERCENT_FILE_PREFIX 282
#define PERCENT_GLR_PARSER 283
#define PERCENT_INITIAL_ACTION 284
#define PERCENT_LEX_PARAM 285
#define PERCENT_LOCATIONS 286
#define PERCENT_NAME_PREFIX 287
#define PERCENT_NO_DEFAULT_PREC 288
#define PERCENT_NO_LINES 289
#define PERCENT_NONDETERMINISTIC_PARSER 290
#define PERCENT_OUTPUT 291
#define PERCENT_PARSE_PARAM 292
#define PERCENT_PURE_PARSER 293
#define PERCENT_PUSH_PARSER 294
#define PERCENT_REQUIRE 295
#define PERCENT_CODE 272
#define PERCENT_DEBUG 273
#define PERCENT_DEFAULT_PREC 274
#define PERCENT_DEFINE 275
#define PERCENT_DEFINES 276
#define PERCENT_ERROR_VERBOSE 277
#define PERCENT_EXPECT 278
#define PERCENT_EXPECT_RR 279
#define PERCENT_FILE_PREFIX 280
#define PERCENT_GLR_PARSER 281
#define PERCENT_INITIAL_ACTION 282
#define PERCENT_LEX_PARAM 283
#define PERCENT_LOCATIONS 284
#define PERCENT_NAME_PREFIX 285
#define PERCENT_NO_DEFAULT_PREC 286
#define PERCENT_NO_LINES 287
#define PERCENT_NONDETERMINISTIC_PARSER 288
#define PERCENT_OUTPUT 289
#define PERCENT_PARSE_PARAM 290
#define PERCENT_PROVIDES 291
#define PERCENT_PURE_PARSER 292
#define PERCENT_PUSH_PARSER 293
#define PERCENT_REQUIRE 294
#define PERCENT_REQUIRES 295
#define PERCENT_SKELETON 296
#define PERCENT_START 297
#define PERCENT_START_HEADER 298
#define PERCENT_TOKEN_TABLE 299
#define PERCENT_VERBOSE 300
#define PERCENT_YACC 301
#define BRACED_CODE 302
#define CHAR 303
#define EPILOGUE 304
#define EQUAL 305
#define ID 306
#define ID_COLON 307
#define PERCENT_PERCENT 308
#define PIPE 309
#define PROLOGUE 310
#define SEMICOLON 311
#define TYPE 312
#define PERCENT_UNION 313
#define PERCENT_TOKEN_TABLE 298
#define PERCENT_VERBOSE 299
#define PERCENT_YACC 300
#define BRACED_CODE 301
#define CHAR 302
#define EPILOGUE 303
#define EQUAL 304
#define ID 305
#define ID_COLON 306
#define PERCENT_PERCENT 307
#define PIPE 308
#define PROLOGUE 309
#define SEMICOLON 310
#define TYPE 311
#define PERCENT_UNION 312
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
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_list *list;
@@ -174,8 +173,9 @@ typedef union YYSTYPE
uniqstr uniqstr;
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;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */

View File

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

View File

@@ -156,16 +156,14 @@ splice (\\[ \f\t\v]*\n)*
`----------------------------*/
<INITIAL>
{
"%after-header" return PERCENT_AFTER_HEADER;
"%before-header" return PERCENT_BEFORE_HEADER;
"%binary" return PERCENT_NONASSOC;
"%code" return PERCENT_CODE;
"%debug" return PERCENT_DEBUG;
"%default"[-_]"prec" return PERCENT_DEFAULT_PREC;
"%define" return PERCENT_DEFINE;
"%defines" return PERCENT_DEFINES;
"%destructor" return PERCENT_DESTRUCTOR;
"%dprec" return PERCENT_DPREC;
"%end-header" return PERCENT_END_HEADER;
"%error"[-_]"verbose" return PERCENT_ERROR_VERBOSE;
"%expect" return PERCENT_EXPECT;
"%expect"[-_]"rr" return PERCENT_EXPECT_RR;
@@ -187,13 +185,14 @@ splice (\\[ \f\t\v]*\n)*
"%parse-param" return PERCENT_PARSE_PARAM;
"%prec" return PERCENT_PREC;
"%printer" return PERCENT_PRINTER;
"%provides" return PERCENT_PROVIDES;
"%pure"[-_]"parser" return PERCENT_PURE_PARSER;
"%push"[-_]"parser" return PERCENT_PUSH_PARSER;
"%require" return PERCENT_REQUIRE;
"%requires" return PERCENT_REQUIRES;
"%right" return PERCENT_RIGHT;
"%skeleton" return PERCENT_SKELETON;
"%start" return PERCENT_START;
"%start-header" return PERCENT_START_HEADER;
"%symbol-default" return PERCENT_SYMBOL_DEFAULT;
"%term" 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.
AT_BISON_OPTION_PUSHDEFS([$5])
AT_DATA_GRAMMAR([[input.y]],
[[%start-header {
[[%requires {
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -197,7 +197,7 @@ m4_ifval([$6], [%union
int ival;
}])
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;])
[static int yylex (]AT_LEX_FORMALS[);
]AT_LALR1_CC_IF([], [static void yyerror (const char *msg);])