mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-13 12:45:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1eeecd384 | ||
|
|
43ca804096 | ||
|
|
dcd5344dcd | ||
|
|
62a58c14bd | ||
|
|
e39eff37e2 | ||
|
|
06f2ac78d7 | ||
|
|
1914a78115 | ||
|
|
d6e2a57964 | ||
|
|
a0c45dd5d2 | ||
|
|
c9d546b2a8 | ||
|
|
d61e59ea0e | ||
|
|
aaf63e45b6 | ||
|
|
dbfcf7a89f | ||
|
|
8c707b10e7 | ||
|
|
9c26b8fc03 | ||
|
|
77b214ef48 | ||
|
|
d35d6dd2cd | ||
|
|
466a2de317 | ||
|
|
4acc22e5cf | ||
|
|
7b18c11231 | ||
|
|
e6cab382c5 | ||
|
|
cd735a8c6c | ||
|
|
d6a44ffd00 | ||
|
|
93e3dbab95 | ||
|
|
1c292035e1 | ||
|
|
263137264f | ||
|
|
e20e6a50d5 | ||
|
|
4d24ffb75e | ||
|
|
a74a3158d4 | ||
|
|
4982f078bf | ||
|
|
65a99eca25 | ||
|
|
9a86ee6058 | ||
|
|
0e164d43d1 | ||
|
|
d511fbd576 | ||
|
|
9c46ba16e3 | ||
|
|
55e075f229 | ||
|
|
0bb672d87c | ||
|
|
8617d87e24 | ||
|
|
0601c3bf0f | ||
|
|
eea7239a23 | ||
|
|
e58782294d | ||
|
|
c1cc91bdcd | ||
|
|
13b712d7d4 | ||
|
|
dba9149595 | ||
|
|
9b8585410a | ||
|
|
f9b8635172 | ||
|
|
733d4546ce | ||
|
|
aaf6103699 | ||
|
|
d0d3313d10 | ||
|
|
a4107f24bc | ||
|
|
1505e8bb78 | ||
|
|
58c7e5ee2c | ||
|
|
ad6b775fc5 | ||
|
|
5d614dfa8c | ||
|
|
858c700fc0 | ||
|
|
c30717cafa | ||
|
|
0e98a81e00 | ||
|
|
d5c20d1a36 | ||
|
|
e6ae99fe75 | ||
|
|
bcbbf65486 | ||
|
|
1aa9fa823b | ||
|
|
321b8117a6 | ||
|
|
e4828e2384 | ||
|
|
a122efad8a | ||
|
|
15ffba51b0 | ||
|
|
ea6a2d96db | ||
|
|
ae63f0e8e2 | ||
|
|
41c11ce484 | ||
|
|
a59a6ddef4 | ||
|
|
aca4ddc75d | ||
|
|
47977a7e74 | ||
|
|
813f7d3482 | ||
|
|
7a9e6d65ea | ||
|
|
916f26b65a | ||
|
|
32ae07efde | ||
|
|
ad60e80f3d | ||
|
|
2a824fae30 | ||
|
|
c242519127 | ||
|
|
e358222ba8 | ||
|
|
9dcb193aeb | ||
|
|
faff3bef5b | ||
|
|
53ab797db7 | ||
|
|
426903aa75 | ||
|
|
9104636b03 | ||
|
|
1168b32295 | ||
|
|
771dc64324 | ||
|
|
a7385a21ce | ||
|
|
b142cfd128 | ||
|
|
5f108727a1 | ||
|
|
242cc08e8d | ||
|
|
4b3847c3c0 | ||
|
|
087dcd7868 | ||
|
|
95361618de | ||
|
|
694af10cb7 | ||
|
|
258cddbc36 | ||
|
|
9bcffa0c13 | ||
|
|
a32a2d57a5 | ||
|
|
8d6c1b5e85 | ||
|
|
77519a7d18 | ||
|
|
0e16927b48 | ||
|
|
91ce0b3a66 | ||
|
|
837b769659 | ||
|
|
5e01579ec0 | ||
|
|
55d1006fce | ||
|
|
230a3db428 | ||
|
|
6d55954743 | ||
|
|
7490994123 | ||
|
|
eb46d61f4d | ||
|
|
05a7b6ec80 | ||
|
|
290a8ff2c0 | ||
|
|
6e2d7b0974 | ||
|
|
2d40532bf5 | ||
|
|
756257ee86 | ||
|
|
18ad57b384 | ||
|
|
da402d1cae | ||
|
|
e29f0771d7 | ||
|
|
71c7e24f2e | ||
|
|
5f7f1e210b | ||
|
|
eb83259dc1 | ||
|
|
55f48c4831 | ||
|
|
34d867d7d2 | ||
|
|
363bf73276 | ||
|
|
c8c220d19a | ||
|
|
56ca3d8fce | ||
|
|
c3e9f08f93 | ||
|
|
6aef2e01a4 | ||
|
|
3d8082ad27 | ||
|
|
9d67a52ad6 | ||
|
|
0f11eec272 | ||
|
|
ae6bdabbf6 | ||
|
|
c0828abf9d | ||
|
|
e9807a7934 | ||
|
|
02287ec650 | ||
|
|
6537c71fcc | ||
|
|
6733d02476 | ||
|
|
cc9fb4f6b6 | ||
|
|
f763e6ef67 | ||
|
|
c4576b484a | ||
|
|
91aadcc7a9 |
+1
-1
@@ -11,6 +11,7 @@
|
|||||||
/INSTALL
|
/INSTALL
|
||||||
/Makefile
|
/Makefile
|
||||||
/Makefile.in
|
/Makefile.in
|
||||||
|
/README-release
|
||||||
/_*
|
/_*
|
||||||
/a.exe
|
/a.exe
|
||||||
/a.out
|
/a.out
|
||||||
@@ -31,4 +32,3 @@
|
|||||||
/patches
|
/patches
|
||||||
/releases
|
/releases
|
||||||
/stamp-h*
|
/stamp-h*
|
||||||
/README-release
|
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
2.5
|
2.6.1
|
||||||
|
|||||||
+11
-9
@@ -66,13 +66,15 @@ update-package-copyright-year:
|
|||||||
gen_start_date = 2012-01-16
|
gen_start_date = 2012-01-16
|
||||||
.PHONY: gen-ChangeLog
|
.PHONY: gen-ChangeLog
|
||||||
gen-ChangeLog:
|
gen-ChangeLog:
|
||||||
$(AM_V_GEN)if test -d $(srcdir)/.git; then \
|
$(AM_V_GEN)if test -d $(srcdir)/.git; then \
|
||||||
$(top_srcdir)/build-aux/gitlog-to-changelog \
|
cl=$(distdir)/ChangeLog && \
|
||||||
--strip-tab \
|
rm -f $$cl.tmp && \
|
||||||
--strip-cherry-picked \
|
$(top_srcdir)/build-aux/gitlog-to-changelog \
|
||||||
--no-cluster \
|
--strip-tab \
|
||||||
--amend=$(srcdir)/build-aux/git-log-fix \
|
--strip-cherry-pick \
|
||||||
--since=$(gen_start_date) > $(distdir)/cl-t; \
|
--no-cluster \
|
||||||
rm -f $(distdir)/ChangeLog; \
|
--amend=$(srcdir)/build-aux/git-log-fix \
|
||||||
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
|
--srcdir=$(srcdir) \
|
||||||
|
--since=$(gen_start_date) > $$cl.tmp && \
|
||||||
|
mv -f $$cl.tmp $$cl; \
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,5 +1,192 @@
|
|||||||
GNU Bison NEWS
|
GNU Bison NEWS
|
||||||
|
|
||||||
|
* Noteworthy changes in release 2.6.2 (2012-08-03) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Buffer overruns, complaints from Flex, and portability issues in the test
|
||||||
|
suite have been fixed.
|
||||||
|
|
||||||
|
** Spaces in %lex- and %parse-param (lalr1.cc, glr.cc)
|
||||||
|
|
||||||
|
Trailing end-of-lines in %parse-param or %lex-param would result in
|
||||||
|
invalid C++. This is fixed.
|
||||||
|
|
||||||
|
** Spurious spaces and end-of-lines
|
||||||
|
|
||||||
|
The generated files no longer end (nor start) with empty lines.
|
||||||
|
|
||||||
|
* Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
|
||||||
|
|
||||||
|
Bison no longer executes user-specified M4 code when processing a grammar.
|
||||||
|
|
||||||
|
** Future Changes
|
||||||
|
|
||||||
|
In addition to the removal of the features announced in Bison 2.6, the
|
||||||
|
next major release will remove the "Temporary hack for adding a semicolon
|
||||||
|
to the user action", as announced in the release 2.5. Instead of:
|
||||||
|
|
||||||
|
exp: exp "+" exp { $$ = $1 + $3 };
|
||||||
|
|
||||||
|
write:
|
||||||
|
|
||||||
|
exp: exp "+" exp { $$ = $1 + $3; };
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
*** Type names are now properly escaped.
|
||||||
|
|
||||||
|
*** glr.cc: set_debug_level and debug_level work as expected.
|
||||||
|
|
||||||
|
*** Stray @ or $ in actions
|
||||||
|
|
||||||
|
While Bison used to warn about stray $ or @ in action rules, it did not
|
||||||
|
for other actions such as printers, destructors, or initial actions. It
|
||||||
|
now does.
|
||||||
|
|
||||||
|
** Type names in actions
|
||||||
|
|
||||||
|
For consistency with rule actions, it is now possible to qualify $$ by a
|
||||||
|
type-name in destructors, printers, and initial actions. For instance:
|
||||||
|
|
||||||
|
%printer { fprintf (yyo, "(%d, %f)", $<ival>$, $<fval>$); } <*> <>;
|
||||||
|
|
||||||
|
will display two values for each typed and untyped symbol (provided
|
||||||
|
that YYSTYPE has both "ival" and "fval" fields).
|
||||||
|
|
||||||
|
* Noteworthy changes in release 2.6 (2012-07-19) [stable]
|
||||||
|
|
||||||
|
** Future Changes
|
||||||
|
|
||||||
|
The next major release of Bison will drop support for the following
|
||||||
|
deprecated features. Please report disagreements to [email protected].
|
||||||
|
|
||||||
|
*** K&R C parsers
|
||||||
|
|
||||||
|
Support for generating parsers in K&R C will be removed. Parsers
|
||||||
|
generated for C support ISO C90, and are tested with ISO C99 and ISO C11
|
||||||
|
compilers.
|
||||||
|
|
||||||
|
*** Features deprecated since Bison 1.875
|
||||||
|
|
||||||
|
The definitions of yystype and yyltype will be removed; use YYSTYPE and
|
||||||
|
YYLTYPE.
|
||||||
|
|
||||||
|
YYPARSE_PARAM and YYLEX_PARAM, deprecated in favor of %parse-param and
|
||||||
|
%lex-param, will no longer be supported.
|
||||||
|
|
||||||
|
Support for the preprocessor symbol YYERROR_VERBOSE will be removed, use
|
||||||
|
%error-verbose.
|
||||||
|
|
||||||
|
*** The generated header will be included (yacc.c)
|
||||||
|
|
||||||
|
Instead of duplicating the content of the generated header (definition of
|
||||||
|
YYSTYPE, yyparse declaration etc.), the generated parser will include it,
|
||||||
|
as is already the case for GLR or C++ parsers. This change is deferred
|
||||||
|
because existing versions of ylwrap (e.g., Automake 1.12.1) do not support
|
||||||
|
it.
|
||||||
|
|
||||||
|
** Generated Parser Headers
|
||||||
|
|
||||||
|
*** Guards (yacc.c, glr.c, glr.cc)
|
||||||
|
|
||||||
|
The generated headers are now guarded, as is already the case for C++
|
||||||
|
parsers (lalr1.cc). For instance, with --defines=foo.h:
|
||||||
|
|
||||||
|
#ifndef YY_FOO_H
|
||||||
|
# define YY_FOO_H
|
||||||
|
...
|
||||||
|
#endif /* !YY_FOO_H */
|
||||||
|
|
||||||
|
*** New declarations (yacc.c, glr.c)
|
||||||
|
|
||||||
|
The generated header now declares yydebug and yyparse. Both honor
|
||||||
|
--name-prefix=bar_, and yield
|
||||||
|
|
||||||
|
int bar_parse (void);
|
||||||
|
|
||||||
|
rather than
|
||||||
|
|
||||||
|
#define yyparse bar_parse
|
||||||
|
int yyparse (void);
|
||||||
|
|
||||||
|
in order to facilitate the inclusion of several parser headers inside a
|
||||||
|
single compilation unit.
|
||||||
|
|
||||||
|
*** Exported symbols in C++
|
||||||
|
|
||||||
|
The symbols YYTOKEN_TABLE and YYERROR_VERBOSE, which were defined in the
|
||||||
|
header, are removed, as they prevent the possibility of including several
|
||||||
|
generated headers from a single compilation unit.
|
||||||
|
|
||||||
|
*** YYLSP_NEEDED
|
||||||
|
|
||||||
|
For the same reasons, the undocumented and unused macro YYLSP_NEEDED is no
|
||||||
|
longer defined.
|
||||||
|
|
||||||
|
** New %define variable: api.prefix
|
||||||
|
|
||||||
|
Now that the generated headers are more complete and properly protected
|
||||||
|
against multiple inclusions, constant names, such as YYSTYPE are a
|
||||||
|
problem. While yyparse and others are properly renamed by %name-prefix,
|
||||||
|
YYSTYPE, YYDEBUG and others have never been affected by it. Because it
|
||||||
|
would introduce backward compatibility issues in projects not expecting
|
||||||
|
YYSTYPE to be renamed, instead of changing the behavior of %name-prefix,
|
||||||
|
it is deprecated in favor of a new %define variable: api.prefix.
|
||||||
|
|
||||||
|
The following examples compares both:
|
||||||
|
|
||||||
|
%name-prefix "bar_" | %define api.prefix "bar_"
|
||||||
|
%token <ival> FOO %token <ival> FOO
|
||||||
|
%union { int ival; } %union { int ival; }
|
||||||
|
%% %%
|
||||||
|
exp: 'a'; exp: 'a';
|
||||||
|
|
||||||
|
bison generates:
|
||||||
|
|
||||||
|
#ifndef BAR_FOO_H #ifndef BAR_FOO_H
|
||||||
|
# define BAR_FOO_H # define BAR_FOO_H
|
||||||
|
|
||||||
|
/* Enabling traces. */ /* Enabling traces. */
|
||||||
|
# ifndef YYDEBUG | # ifndef BAR_DEBUG
|
||||||
|
> # if defined YYDEBUG
|
||||||
|
> # if YYDEBUG
|
||||||
|
> # define BAR_DEBUG 1
|
||||||
|
> # else
|
||||||
|
> # define BAR_DEBUG 0
|
||||||
|
> # endif
|
||||||
|
> # else
|
||||||
|
# define YYDEBUG 0 | # define BAR_DEBUG 0
|
||||||
|
> # endif
|
||||||
|
# endif | # endif
|
||||||
|
|
||||||
|
# if YYDEBUG | # if BAR_DEBUG
|
||||||
|
extern int bar_debug; extern int bar_debug;
|
||||||
|
# endif # endif
|
||||||
|
|
||||||
|
/* Tokens. */ /* Tokens. */
|
||||||
|
# ifndef YYTOKENTYPE | # ifndef BAR_TOKENTYPE
|
||||||
|
# define YYTOKENTYPE | # define BAR_TOKENTYPE
|
||||||
|
enum yytokentype { | enum bar_tokentype {
|
||||||
|
FOO = 258 FOO = 258
|
||||||
|
}; };
|
||||||
|
# endif # endif
|
||||||
|
|
||||||
|
#if ! defined YYSTYPE \ | #if ! defined BAR_STYPE \
|
||||||
|
&& ! defined YYSTYPE_IS_DECLARED | && ! defined BAR_STYPE_IS_DECLARED
|
||||||
|
typedef union YYSTYPE | typedef union BAR_STYPE
|
||||||
|
{ {
|
||||||
|
int ival; int ival;
|
||||||
|
} YYSTYPE; | } BAR_STYPE;
|
||||||
|
# define YYSTYPE_IS_DECLARED 1 | # define BAR_STYPE_IS_DECLARED 1
|
||||||
|
#endif #endif
|
||||||
|
|
||||||
|
extern YYSTYPE bar_lval; | extern BAR_STYPE bar_lval;
|
||||||
|
|
||||||
|
int bar_parse (void); int bar_parse (void);
|
||||||
|
|
||||||
|
#endif /* !BAR_FOO_H */ #endif /* !BAR_FOO_H */
|
||||||
|
|
||||||
* Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
|
* Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
|
||||||
|
|
||||||
** Future changes:
|
** Future changes:
|
||||||
@@ -37,10 +224,10 @@ GNU Bison NEWS
|
|||||||
The header files such as "parser.hh", "location.hh", etc. used a constant
|
The header files such as "parser.hh", "location.hh", etc. used a constant
|
||||||
name for preprocessor guards, for instance:
|
name for preprocessor guards, for instance:
|
||||||
|
|
||||||
#ifndef BISON_LOCATION_HH
|
#ifndef BISON_LOCATION_HH
|
||||||
# define BISON_LOCATION_HH
|
# define BISON_LOCATION_HH
|
||||||
...
|
...
|
||||||
#endif // !BISON_LOCATION_HH
|
#endif // !BISON_LOCATION_HH
|
||||||
|
|
||||||
The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
|
The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
|
||||||
case characters are converted to upper case, and series of
|
case characters are converted to upper case, and series of
|
||||||
@@ -48,10 +235,10 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
With "bison -o lang++/parser.cc", "location.hh" would now include:
|
With "bison -o lang++/parser.cc", "location.hh" would now include:
|
||||||
|
|
||||||
#ifndef YY_LANG_LOCATION_HH
|
#ifndef YY_LANG_LOCATION_HH
|
||||||
# define YY_LANG_LOCATION_HH
|
# define YY_LANG_LOCATION_HH
|
||||||
...
|
...
|
||||||
#endif // !YY_LANG_LOCATION_HH
|
#endif // !YY_LANG_LOCATION_HH
|
||||||
|
|
||||||
*** C++ locations:
|
*** C++ locations:
|
||||||
|
|
||||||
@@ -92,7 +279,7 @@ GNU Bison NEWS
|
|||||||
This includes warnings with some compilers, unexpected behavior of tools
|
This includes warnings with some compilers, unexpected behavior of tools
|
||||||
such as diff, warning messages from the test suite itself, etc.
|
such as diff, warning messages from the test suite itself, etc.
|
||||||
|
|
||||||
*** The install-pdf target work properly:
|
*** The install-pdf target works properly:
|
||||||
|
|
||||||
Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
|
Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
|
||||||
halts in the middle of its course.
|
halts in the middle of its course.
|
||||||
@@ -282,33 +469,33 @@ GNU Bison NEWS
|
|||||||
to use it. If, for instance, your location structure has "first"
|
to use it. If, for instance, your location structure has "first"
|
||||||
and "last" members, instead of
|
and "last" members, instead of
|
||||||
|
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
do \
|
do \
|
||||||
if (N) \
|
if (N) \
|
||||||
{ \
|
{ \
|
||||||
(Current).first = (Rhs)[1].location.first; \
|
(Current).first = (Rhs)[1].location.first; \
|
||||||
(Current).last = (Rhs)[N].location.last; \
|
(Current).last = (Rhs)[N].location.last; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
(Current).first = (Current).last = (Rhs)[0].location.last; \
|
(Current).first = (Current).last = (Rhs)[0].location.last; \
|
||||||
} \
|
} \
|
||||||
while (false)
|
while (false)
|
||||||
|
|
||||||
use:
|
use:
|
||||||
|
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
do \
|
do \
|
||||||
if (N) \
|
if (N) \
|
||||||
{ \
|
{ \
|
||||||
(Current).first = YYRHSLOC (Rhs, 1).first; \
|
(Current).first = YYRHSLOC (Rhs, 1).first; \
|
||||||
(Current).last = YYRHSLOC (Rhs, N).last; \
|
(Current).last = YYRHSLOC (Rhs, N).last; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
(Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
|
(Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
|
||||||
} \
|
} \
|
||||||
while (false)
|
while (false)
|
||||||
|
|
||||||
** YYLLOC_DEFAULT in C++:
|
** YYLLOC_DEFAULT in C++:
|
||||||
|
|
||||||
@@ -927,26 +1114,26 @@ GNU Bison NEWS
|
|||||||
if the symbols have destructors. For instance:
|
if the symbols have destructors. For instance:
|
||||||
|
|
||||||
exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
|
exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
|
||||||
| exp "+" exp
|
| exp "+" exp
|
||||||
;
|
;
|
||||||
|
|
||||||
will trigger a warning about $$ and $5 in the first rule, and $3 in
|
will trigger a warning about $$ and $5 in the first rule, and $3 in
|
||||||
the second ($1 is copied to $$ by the default rule). This example
|
the second ($1 is copied to $$ by the default rule). This example
|
||||||
most likely contains three errors, and could be rewritten as:
|
most likely contains three errors, and could be rewritten as:
|
||||||
|
|
||||||
exp: exp "?" exp ":" exp
|
exp: exp "?" exp ":" exp
|
||||||
{ $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
|
{ $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
|
||||||
| exp "+" exp
|
| exp "+" exp
|
||||||
{ $$ = $1 ? $1 : $3; if ($1) free ($3); }
|
{ $$ = $1 ? $1 : $3; if ($1) free ($3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
However, if the original actions were really intended, memory leaks
|
However, if the original actions were really intended, memory leaks
|
||||||
and all, the warnings can be suppressed by letting Bison believe the
|
and all, the warnings can be suppressed by letting Bison believe the
|
||||||
values are used, e.g.:
|
values are used, e.g.:
|
||||||
|
|
||||||
exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
|
exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
|
||||||
| exp "+" exp { $$ = $1; (void) $3; }
|
| exp "+" exp { $$ = $1; (void) $3; }
|
||||||
;
|
;
|
||||||
|
|
||||||
If there are mid-rule actions, the warning is issued if no action
|
If there are mid-rule actions, the warning is issued if no action
|
||||||
uses it. The following triggers no warning: $1 and $3 are used.
|
uses it. The following triggers no warning: $1 and $3 are used.
|
||||||
@@ -1161,6 +1348,33 @@ GNU Bison NEWS
|
|||||||
- "parsing stack overflow..." -> "parser stack overflow"
|
- "parsing stack overflow..." -> "parser stack overflow"
|
||||||
GLR parsers now report "parser stack overflow" as per the Bison manual.
|
GLR parsers now report "parser stack overflow" as per the Bison manual.
|
||||||
|
|
||||||
|
** %parse-param and %lex-param
|
||||||
|
The macros YYPARSE_PARAM and YYLEX_PARAM provide a means to pass
|
||||||
|
additional context to yyparse and yylex. They suffer from several
|
||||||
|
shortcomings:
|
||||||
|
|
||||||
|
- a single argument only can be added,
|
||||||
|
- their types are weak (void *),
|
||||||
|
- this context is not passed to ancillary functions such as yyerror,
|
||||||
|
- only yacc.c parsers support them.
|
||||||
|
|
||||||
|
The new %parse-param/%lex-param directives provide a more precise control.
|
||||||
|
For instance:
|
||||||
|
|
||||||
|
%parse-param {int *nastiness}
|
||||||
|
%lex-param {int *nastiness}
|
||||||
|
%parse-param {int *randomness}
|
||||||
|
|
||||||
|
results in the following signatures:
|
||||||
|
|
||||||
|
int yylex (int *nastiness);
|
||||||
|
int yyparse (int *nastiness, int *randomness);
|
||||||
|
|
||||||
|
or, if both %pure-parser and %locations are used:
|
||||||
|
|
||||||
|
int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
|
||||||
|
int yyparse (int *nastiness, int *randomness);
|
||||||
|
|
||||||
** Bison now warns if it detects conflicting outputs to the same file,
|
** Bison now warns if it detects conflicting outputs to the same file,
|
||||||
e.g., it generates a warning for "bison -d -o foo.h foo.y" since
|
e.g., it generates a warning for "bison -d -o foo.h foo.y" since
|
||||||
that command outputs both code and header to foo.h.
|
that command outputs both code and header to foo.h.
|
||||||
@@ -1190,16 +1404,16 @@ GNU Bison NEWS
|
|||||||
In agreement with POSIX and with other Yaccs, leaving a default
|
In agreement with POSIX and with other Yaccs, leaving a default
|
||||||
action is valid when $$ is untyped, and $1 typed:
|
action is valid when $$ is untyped, and $1 typed:
|
||||||
|
|
||||||
untyped: ... typed;
|
untyped: ... typed;
|
||||||
|
|
||||||
but the converse remains an error:
|
but the converse remains an error:
|
||||||
|
|
||||||
typed: ... untyped;
|
typed: ... untyped;
|
||||||
|
|
||||||
** Values of mid-rule actions
|
** Values of mid-rule actions
|
||||||
The following code:
|
The following code:
|
||||||
|
|
||||||
foo: { ... } { $$ = $1; } ...
|
foo: { ... } { $$ = $1; } ...
|
||||||
|
|
||||||
was incorrectly rejected: $1 is defined in the second mid-rule
|
was incorrectly rejected: $1 is defined in the second mid-rule
|
||||||
action, and is equal to the $$ of the first mid-rule action.
|
action, and is equal to the $$ of the first mid-rule action.
|
||||||
@@ -1281,9 +1495,9 @@ GNU Bison NEWS
|
|||||||
** Incorrect "Token not used"
|
** Incorrect "Token not used"
|
||||||
On a grammar such as
|
On a grammar such as
|
||||||
|
|
||||||
%token useless useful
|
%token useless useful
|
||||||
%%
|
%%
|
||||||
exp: '0' %prec useful;
|
exp: '0' %prec useful;
|
||||||
|
|
||||||
where a token was used to set the precedence of the last rule,
|
where a token was used to set the precedence of the last rule,
|
||||||
bison reported both "useful" and "useless" as useless tokens.
|
bison reported both "useful" and "useless" as useless tokens.
|
||||||
@@ -1302,9 +1516,9 @@ GNU Bison NEWS
|
|||||||
the user symbol is used in the reports, the graphs, and the verbose
|
the user symbol is used in the reports, the graphs, and the verbose
|
||||||
error messages instead of "$end", which remains being the default.
|
error messages instead of "$end", which remains being the default.
|
||||||
For instance
|
For instance
|
||||||
%token MYEOF 0
|
%token MYEOF 0
|
||||||
or
|
or
|
||||||
%token MYEOF 0 "end of file"
|
%token MYEOF 0 "end of file"
|
||||||
|
|
||||||
** Semantic parser
|
** Semantic parser
|
||||||
This old option, which has been broken for ages, is removed.
|
This old option, which has been broken for ages, is removed.
|
||||||
@@ -1340,9 +1554,9 @@ GNU Bison NEWS
|
|||||||
Previous versions don't complain when there is a type clash on
|
Previous versions don't complain when there is a type clash on
|
||||||
the default action if the rule has a mid-rule action, such as in:
|
the default action if the rule has a mid-rule action, such as in:
|
||||||
|
|
||||||
%type <foo> bar
|
%type <foo> bar
|
||||||
%%
|
%%
|
||||||
bar: '0' {} '0';
|
bar: '0' {} '0';
|
||||||
|
|
||||||
This is fixed.
|
This is fixed.
|
||||||
|
|
||||||
@@ -1639,9 +1853,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
LocalWords: struct yystype DJGPP lex param Haible NUM alloca YYSTACK NUL goto
|
LocalWords: struct yystype DJGPP lex param Haible NUM alloca YYSTACK NUL goto
|
||||||
LocalWords: YYMAXDEPTH Unescaped UCNs YYLTYPE's yyltype typedefs inline Yaccs
|
LocalWords: YYMAXDEPTH Unescaped UCNs YYLTYPE's yyltype typedefs inline Yaccs
|
||||||
LocalWords: Heriyanto Reenable dprec Hilfinger Eggert MYEOF Folle Menezes EOF
|
LocalWords: Heriyanto Reenable dprec Hilfinger Eggert MYEOF Folle Menezes EOF
|
||||||
LocalWords: Lackovic define's itemset Groff Gettext malloc NEWS'ed YYDEBUG
|
LocalWords: Lackovic define's itemset Groff Gettext malloc NEWS'ed YYDEBUG YY
|
||||||
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
|
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
|
||||||
LocalWords: Automake TMPDIR LESSEQ
|
LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
|
||||||
|
LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
|
||||||
|
LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: outline
|
mode: outline
|
||||||
|
|||||||
+47
-32
@@ -1,5 +1,3 @@
|
|||||||
-*- outline -*-
|
|
||||||
|
|
||||||
This file attempts to describe the rules to use when hacking Bison.
|
This file attempts to describe the rules to use when hacking Bison.
|
||||||
Don't put this file into the distribution.
|
Don't put this file into the distribution.
|
||||||
|
|
||||||
@@ -60,8 +58,8 @@ tools we depend upon, including:
|
|||||||
- Rsync <http://samba.anu.edu.au/rsync/>
|
- Rsync <http://samba.anu.edu.au/rsync/>
|
||||||
- Tar <http://www.gnu.org/software/tar/>
|
- Tar <http://www.gnu.org/software/tar/>
|
||||||
|
|
||||||
Valgrind <http://valgrind.org/> is also highly recommended, if
|
Valgrind <http://valgrind.org/> is also highly recommended, if it supports
|
||||||
Valgrind supports your architecture.
|
your architecture.
|
||||||
|
|
||||||
Bison is written using Bison grammars, so there are bootstrapping
|
Bison is written using Bison grammars, so there are bootstrapping
|
||||||
issues. The bootstrap script attempts to discover when the C code
|
issues. The bootstrap script attempts to discover when the C code
|
||||||
@@ -124,7 +122,7 @@ import requests for updated submodules. A simple "git diff" will
|
|||||||
reveal if the current version of the submodule (i.e., the actual
|
reveal if the current version of the submodule (i.e., the actual
|
||||||
contents of the gnulib directory) and the current request from the
|
contents of the gnulib directory) and the current request from the
|
||||||
subscriber (i.e., the reference of the version of gnulib that the
|
subscriber (i.e., the reference of the version of gnulib that the
|
||||||
Bison reporitory requests) differ. To upgrade the submodules (i.e.,
|
Bison repository requests) differ. To upgrade the submodules (i.e.,
|
||||||
to check out the version that is actually requested by the subscriber,
|
to check out the version that is actually requested by the subscriber,
|
||||||
run "git submodule update".
|
run "git submodule update".
|
||||||
|
|
||||||
@@ -155,7 +153,7 @@ formal release, see the ChangeLog in the latest gnulib snapshot at:
|
|||||||
|
|
||||||
http://erislabs.net/ianb/projects/gnulib/
|
http://erislabs.net/ianb/projects/gnulib/
|
||||||
|
|
||||||
The autoconf files we use are currently:
|
The Autoconf files we use are currently:
|
||||||
|
|
||||||
m4/m4.m4
|
m4/m4.m4
|
||||||
lib/m4sugar/m4sugar.m4
|
lib/m4sugar/m4sugar.m4
|
||||||
@@ -170,6 +168,23 @@ decide whether to update.
|
|||||||
** make check
|
** make check
|
||||||
Use liberally.
|
Use liberally.
|
||||||
|
|
||||||
|
** make maintainer-check-valgrind
|
||||||
|
This target uses valgrind both to check bison, and the generated parsers.
|
||||||
|
|
||||||
|
This is not mature on Mac OS X. First, Valgrind does support the way bison
|
||||||
|
calls m4, so Valgrind cannot be used to check bison on Mac OS X.
|
||||||
|
|
||||||
|
Second, there are many errors that come from the platform itself, not from
|
||||||
|
bison. build-aux/darwin11.4.0.valgrind addresses some of them.
|
||||||
|
|
||||||
|
Third, valgrind issues warnings such as:
|
||||||
|
|
||||||
|
--99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
|
||||||
|
|
||||||
|
which cause the test to fail uselessly. It is hard to ignore these errors
|
||||||
|
with a major overhaul of the way instrumentation is performed in the test
|
||||||
|
suite. So currently, do not try to run valgrind on Mac OS X.
|
||||||
|
|
||||||
** Release checks
|
** Release checks
|
||||||
Try to run the test suite with more severe conditions before a
|
Try to run the test suite with more severe conditions before a
|
||||||
release:
|
release:
|
||||||
@@ -248,25 +263,13 @@ copyright statement for each Bison file, check the copyright statements
|
|||||||
that the skeletons insert into generated parsers, and check all
|
that the skeletons insert into generated parsers, and check all
|
||||||
occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac.
|
occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac.
|
||||||
|
|
||||||
** Update NEWS
|
** Update NEWS, commit and tag.
|
||||||
The version number, *and* the date of the release (including for
|
See do-release-commit-and-tag in README-release. For a while, we used
|
||||||
betas).
|
beta names such as "2.6_rc1". Now that we use gnulib in the release
|
||||||
|
procedure, we must use "2.5.90", which has the additional benefit of
|
||||||
|
being properly sorted in "git tag -l".
|
||||||
|
|
||||||
** Mention the release name in a commit message
|
** make alpha, beta, or stable
|
||||||
Should have an entry similar to "Version 2.3b.".
|
|
||||||
|
|
||||||
** Tag the release
|
|
||||||
Before Bison will build with the right version number, you must tag
|
|
||||||
the release in git. Do this after all other changes. The command is
|
|
||||||
similar to:
|
|
||||||
|
|
||||||
git tag -a v2.3b -m "Bison 2.3b."
|
|
||||||
|
|
||||||
** Push
|
|
||||||
Once "make distcheck" passes, push your changes and the tag.
|
|
||||||
"git push" without arguments will not push the tag.
|
|
||||||
|
|
||||||
** make alpha, beta, or release
|
|
||||||
See README-release.
|
See README-release.
|
||||||
|
|
||||||
** Upload
|
** Upload
|
||||||
@@ -287,8 +290,8 @@ where F125BDF3 should be replaced with your key ID.
|
|||||||
*** Using gnupload
|
*** Using gnupload
|
||||||
You need "ncftp".
|
You need "ncftp".
|
||||||
|
|
||||||
At the end "make release" (or alpha/beta) will display the prodecure
|
At the end "make stable" (or alpha/beta) will display the procedure to
|
||||||
to run. Just copy and paste it in your shell.
|
run. Just copy and paste it in your shell.
|
||||||
|
|
||||||
*** By hand
|
*** By hand
|
||||||
|
|
||||||
@@ -359,7 +362,8 @@ function 'index', once for the table of contents); you can ignore this
|
|||||||
issue.
|
issue.
|
||||||
|
|
||||||
** Announce
|
** Announce
|
||||||
To generate a template announcement file:
|
The "make stable" (or alpha/beta) command just created a template,
|
||||||
|
$HOME/announce-bison-X.Y. Otherwise, to generate it, run:
|
||||||
|
|
||||||
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
|
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
|
||||||
|
|
||||||
@@ -379,15 +383,15 @@ newsgroup by sending email to [email protected]. Do not make any Cc as
|
|||||||
the moderator will throw away anything cross-posted or Cc'ed. It really
|
the moderator will throw away anything cross-posted or Cc'ed. It really
|
||||||
needs to be a separate message.
|
needs to be a separate message.
|
||||||
|
|
||||||
** Bump the version number
|
** Prepare NEWS
|
||||||
In configure.ac. Run "make". So that developers don't accidentally add new
|
So that developers don't accidentally add new items to the old NEWS
|
||||||
items to the old NEWS entry, create a new empty NEWS entry something like:
|
entry, create a new empty entry in line 3 (without the two leading
|
||||||
|
spaces):
|
||||||
|
|
||||||
Changes in version ?.? (????-??-??):
|
* Noteworthy changes in release ?.? (????-??-??) [?]
|
||||||
|
|
||||||
Push these changes.
|
Push these changes.
|
||||||
|
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
|
Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
|
||||||
@@ -406,3 +410,14 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
LocalWords: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
|
||||||
|
LocalWords: submodule init cd distcheck checkin ChangeLog valgrind sigreturn
|
||||||
|
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
|
||||||
|
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
|
||||||
|
LocalWords: symlinks vti html lt POSIX Cc'ed
|
||||||
|
|
||||||
|
Local Variables:
|
||||||
|
mode: outline
|
||||||
|
fill-column: 76
|
||||||
|
End:
|
||||||
|
|||||||
@@ -126,12 +126,6 @@ The code bw glr.c and yacc.c is really alike, we can certainly factor
|
|||||||
some parts.
|
some parts.
|
||||||
|
|
||||||
|
|
||||||
* Yacc.c: CPP Macros
|
|
||||||
|
|
||||||
Do some people use YYPURE, YYLSP_NEEDED like we do in the test suite?
|
|
||||||
They should not: it is not documented. But if they need to, let's
|
|
||||||
find something clean (not like YYLSP_NEEDED...).
|
|
||||||
|
|
||||||
* Report
|
* Report
|
||||||
|
|
||||||
** Figures
|
** Figures
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Print a version string.
|
# Print a version string.
|
||||||
scriptversion=2012-05-15.06; # UTC
|
scriptversion=2012-07-19.14; # UTC
|
||||||
|
|
||||||
# Bootstrap this package from checked-out sources.
|
# Bootstrap this package from checked-out sources.
|
||||||
|
|
||||||
@@ -77,6 +77,33 @@ Running without arguments will suffice in most cases.
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# warnf_ FORMAT-STRING ARG1...
|
||||||
|
warnf_ ()
|
||||||
|
{
|
||||||
|
warnf_format_=$1
|
||||||
|
shift
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
case $* in
|
||||||
|
*$nl*) me_=$(printf "$me"|tr "$nl|" '??')
|
||||||
|
printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
|
||||||
|
*) printf "$me: $warnf_format_" "$@" ;;
|
||||||
|
esac >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# warn_ WORD1...
|
||||||
|
warn_ ()
|
||||||
|
{
|
||||||
|
# If IFS does not start with ' ', set it and emit the warning in a subshell.
|
||||||
|
case $IFS in
|
||||||
|
' '*) warnf_ '%s\n' "$*";;
|
||||||
|
*) (IFS=' '; warn_ "$@");;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# die WORD1...
|
||||||
|
die() { warn_ "$@"; exit 1; }
|
||||||
|
|
||||||
# Configuration.
|
# Configuration.
|
||||||
|
|
||||||
# Name of the Makefile.am
|
# Name of the Makefile.am
|
||||||
@@ -130,7 +157,8 @@ extract_package_name='
|
|||||||
p
|
p
|
||||||
}
|
}
|
||||||
'
|
'
|
||||||
package=$(sed -n "$extract_package_name" configure.ac) || exit
|
package=$(sed -n "$extract_package_name" configure.ac) \
|
||||||
|
|| die 'cannot find package name in configure.ac'
|
||||||
gnulib_name=lib$package
|
gnulib_name=lib$package
|
||||||
|
|
||||||
build_aux=build-aux
|
build_aux=build-aux
|
||||||
@@ -186,6 +214,8 @@ use_git=true
|
|||||||
# otherwise find the first of the NAMES that can be run (i.e.,
|
# otherwise find the first of the NAMES that can be run (i.e.,
|
||||||
# supports --version). If found, set ENVVAR to the program name,
|
# supports --version). If found, set ENVVAR to the program name,
|
||||||
# die otherwise.
|
# die otherwise.
|
||||||
|
#
|
||||||
|
# FIXME: code duplication, see also gnu-web-doc-update.
|
||||||
find_tool ()
|
find_tool ()
|
||||||
{
|
{
|
||||||
find_tool_envvar=$1
|
find_tool_envvar=$1
|
||||||
@@ -203,19 +233,15 @@ find_tool ()
|
|||||||
else
|
else
|
||||||
find_tool_error_prefix="\$$find_tool_envvar: "
|
find_tool_error_prefix="\$$find_tool_envvar: "
|
||||||
fi
|
fi
|
||||||
if test x"$find_tool_res" = x; then
|
test x"$find_tool_res" != x \
|
||||||
echo >&2 "$me: one of these is required: $find_tool_names"
|
|| die "one of these is required: $find_tool_names"
|
||||||
exit 1
|
($find_tool_res --version </dev/null) >/dev/null 2>&1 \
|
||||||
fi
|
|| die "${find_tool_error_prefix}cannot run $find_tool_res --version"
|
||||||
($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
|
|
||||||
echo >&2 "$me: ${find_tool_error_prefix}cannot run $find_tool_res --version"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
eval "$find_tool_envvar=\$find_tool_res"
|
eval "$find_tool_envvar=\$find_tool_res"
|
||||||
eval "export $find_tool_envvar"
|
eval "export $find_tool_envvar"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
|
# Find sha1sum, named gsha1sum on MacPorts, and shasum on Mac OS X 10.6.
|
||||||
find_tool SHA1SUM sha1sum gsha1sum shasum
|
find_tool SHA1SUM sha1sum gsha1sum shasum
|
||||||
|
|
||||||
# Override the default configuration, if necessary.
|
# Override the default configuration, if necessary.
|
||||||
@@ -230,7 +256,6 @@ esac
|
|||||||
test -z "${gnulib_extra_files}" && \
|
test -z "${gnulib_extra_files}" && \
|
||||||
gnulib_extra_files="
|
gnulib_extra_files="
|
||||||
$build_aux/install-sh
|
$build_aux/install-sh
|
||||||
$build_aux/missing
|
|
||||||
$build_aux/mdate-sh
|
$build_aux/mdate-sh
|
||||||
$build_aux/texinfo.tex
|
$build_aux/texinfo.tex
|
||||||
$build_aux/depcomp
|
$build_aux/depcomp
|
||||||
@@ -270,21 +295,15 @@ do
|
|||||||
--no-git)
|
--no-git)
|
||||||
use_git=false;;
|
use_git=false;;
|
||||||
*)
|
*)
|
||||||
echo >&2 "$0: $option: unknown option"
|
die "$option: unknown option";;
|
||||||
exit 1;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if $use_git || test -d "$GNULIB_SRCDIR"; then
|
$use_git || test -d "$GNULIB_SRCDIR" \
|
||||||
:
|
|| die "Error: --no-git requires --gnulib-srcdir"
|
||||||
else
|
|
||||||
echo "$0: Error: --no-git requires --gnulib-srcdir" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
|
if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
|
||||||
echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
|
die "Bootstrapping from a non-checked-out distribution is risky."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure that lines starting with ! sort last, per gitignore conventions
|
# Ensure that lines starting with ! sort last, per gitignore conventions
|
||||||
@@ -310,7 +329,7 @@ insert_sorted_if_absent() {
|
|||||||
echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
|
echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
|
||||||
|| { echo "$str" | sort_patterns - $file > $file.bak \
|
|| { echo "$str" | sort_patterns - $file > $file.bak \
|
||||||
&& mv $file.bak $file; } \
|
&& mv $file.bak $file; } \
|
||||||
|| exit 1
|
|| die "insert_sorted_if_absent $file $str: failed"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
|
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
|
||||||
@@ -334,11 +353,8 @@ grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
|
|||||||
>/dev/null && found_aux_dir=yes
|
>/dev/null && found_aux_dir=yes
|
||||||
grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
|
grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
|
||||||
>/dev/null && found_aux_dir=yes
|
>/dev/null && found_aux_dir=yes
|
||||||
if test $found_aux_dir = no; then
|
test $found_aux_dir = yes \
|
||||||
echo "$0: expected line not found in configure.ac. Add the following:" >&2
|
|| die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
|
||||||
echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If $build_aux doesn't exist, create it now, otherwise some bits
|
# If $build_aux doesn't exist, create it now, otherwise some bits
|
||||||
# below will malfunction. If creating it, also mark it as ignored.
|
# below will malfunction. If creating it, also mark it as ignored.
|
||||||
@@ -444,7 +460,7 @@ check_versions() {
|
|||||||
automake-ng|aclocal-ng)
|
automake-ng|aclocal-ng)
|
||||||
app=${app%-ng}
|
app=${app%-ng}
|
||||||
($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
|
($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
|
||||||
echo "$me: Error: '$app' not found or not from Automake-NG" >&2
|
warn_ "Error: '$app' not found or not from Automake-NG"
|
||||||
ret=1
|
ret=1
|
||||||
continue
|
continue
|
||||||
} ;;
|
} ;;
|
||||||
@@ -454,20 +470,21 @@ check_versions() {
|
|||||||
# so we have to rely on $? rather than get_version.
|
# so we have to rely on $? rather than get_version.
|
||||||
$app --version >/dev/null 2>&1
|
$app --version >/dev/null 2>&1
|
||||||
if [ 126 -le $? ]; then
|
if [ 126 -le $? ]; then
|
||||||
echo "$me: Error: '$app' not found" >&2
|
warn_ "Error: '$app' not found"
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Require app to produce a new enough version string.
|
# Require app to produce a new enough version string.
|
||||||
inst_ver=$(get_version $app)
|
inst_ver=$(get_version $app)
|
||||||
if [ ! "$inst_ver" ]; then
|
if [ ! "$inst_ver" ]; then
|
||||||
echo "$me: Error: '$app' not found" >&2
|
warn_ "Error: '$app' not found"
|
||||||
ret=1
|
ret=1
|
||||||
else
|
else
|
||||||
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
|
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
|
||||||
if [ ! "$latest_ver" = "$inst_ver" ]; then
|
if [ ! "$latest_ver" = "$inst_ver" ]; then
|
||||||
echo "$me: Error: '$app' version == $inst_ver is too old" >&2
|
warnf_ '%s\n' \
|
||||||
echo " '$app' version >= $req_ver is required" >&2
|
"Error: '$app' version == $inst_ver is too old" \
|
||||||
|
" '$app' version >= $req_ver is required"
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -524,11 +541,10 @@ fi
|
|||||||
if ! printf "$buildreq" | check_versions; then
|
if ! printf "$buildreq" | check_versions; then
|
||||||
echo >&2
|
echo >&2
|
||||||
if test -f README-prereq; then
|
if test -f README-prereq; then
|
||||||
echo "$0: See README-prereq for how to get the prerequisite programs" >&2
|
die "See README-prereq for how to get the prerequisite programs"
|
||||||
else
|
else
|
||||||
echo "$0: Please install the prerequisite programs" >&2
|
die "Please install the prerequisite programs"
|
||||||
fi
|
fi
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$0: Bootstrapping from checked-out $package sources..."
|
echo "$0: Bootstrapping from checked-out $package sources..."
|
||||||
@@ -739,11 +755,10 @@ symlink_to_dir()
|
|||||||
*)
|
*)
|
||||||
case /$dst/ in
|
case /$dst/ in
|
||||||
*//* | */../* | */./* | /*/*/*/*/*/)
|
*//* | */../* | */./* | /*/*/*/*/*/)
|
||||||
echo >&2 "$me: invalid symlink calculation: $src -> $dst"
|
die "invalid symlink calculation: $src -> $dst";;
|
||||||
exit 1;;
|
/*/*/*/*/) dot_dots=../../../;;
|
||||||
/*/*/*/*/) dot_dots=../../../;;
|
/*/*/*/) dot_dots=../../;;
|
||||||
/*/*/*/) dot_dots=../../;;
|
/*/*/) dot_dots=../;;
|
||||||
/*/*/) dot_dots=../;;
|
|
||||||
esac;;
|
esac;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -765,7 +780,7 @@ version_controlled_file() {
|
|||||||
grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
|
grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
|
||||||
grep '^/[^/]*/[0-9]' > /dev/null
|
grep '^/[^/]*/[0-9]' > /dev/null
|
||||||
else
|
else
|
||||||
echo "$me: no version control for $file?" >&2
|
warn_ "no version control for $file?"
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -855,11 +870,12 @@ echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
|
|||||||
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
|
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
|
||||||
|
|
||||||
for file in $gnulib_files; do
|
for file in $gnulib_files; do
|
||||||
symlink_to_dir "$GNULIB_SRCDIR" $file || exit
|
symlink_to_dir "$GNULIB_SRCDIR" $file \
|
||||||
|
|| die "failed to symlink $file"
|
||||||
done
|
done
|
||||||
|
|
||||||
bootstrap_post_import_hook \
|
bootstrap_post_import_hook \
|
||||||
|| { echo >&2 "$me: bootstrap_post_import_hook failed"; exit 1; }
|
|| die "bootstrap_post_import_hook failed"
|
||||||
|
|
||||||
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
|
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
|
||||||
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
|
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
|
||||||
@@ -887,7 +903,7 @@ echo "running: AUTOPOINT=true LIBTOOLIZE=true " \
|
|||||||
"$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
|
"$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
|
||||||
AUTOPOINT=true LIBTOOLIZE=true \
|
AUTOPOINT=true LIBTOOLIZE=true \
|
||||||
$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
|
$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
|
||||||
|| exit 1
|
|| die "autoreconf failed"
|
||||||
|
|
||||||
# Get some extra files from gnulib, overriding existing files.
|
# Get some extra files from gnulib, overriding existing files.
|
||||||
for file in $gnulib_extra_files; do
|
for file in $gnulib_extra_files; do
|
||||||
@@ -896,7 +912,8 @@ for file in $gnulib_extra_files; do
|
|||||||
build-aux/*) dst=$build_aux/${file#build-aux/};;
|
build-aux/*) dst=$build_aux/${file#build-aux/};;
|
||||||
*) dst=$file;;
|
*) dst=$file;;
|
||||||
esac
|
esac
|
||||||
symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
|
symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
|
||||||
|
|| die "failed to symlink $file"
|
||||||
done
|
done
|
||||||
|
|
||||||
if test $with_gettext = yes; then
|
if test $with_gettext = yes; then
|
||||||
@@ -912,7 +929,8 @@ if test $with_gettext = yes; then
|
|||||||
a\
|
a\
|
||||||
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
|
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
|
||||||
}
|
}
|
||||||
' po/Makevars.template >po/Makevars || exit 1
|
' po/Makevars.template >po/Makevars \
|
||||||
|
|| die 'cannot generate po/Makevars'
|
||||||
|
|
||||||
# If the 'gettext' module is in use, grab the latest Makefile.in.in.
|
# If the 'gettext' module is in use, grab the latest Makefile.in.in.
|
||||||
# If only the 'gettext-h' module is in use, assume autopoint already
|
# If only the 'gettext-h' module is in use, assume autopoint already
|
||||||
@@ -920,7 +938,8 @@ if test $with_gettext = yes; then
|
|||||||
case $gnulib_modules in
|
case $gnulib_modules in
|
||||||
*gettext-h*) ;;
|
*gettext-h*) ;;
|
||||||
*gettext*)
|
*gettext*)
|
||||||
cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in || exit 1
|
cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
|
||||||
|
|| die "cannot create po/Makefile.in.in"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -936,7 +955,8 @@ if test $with_gettext = yes; then
|
|||||||
a\
|
a\
|
||||||
'"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
|
'"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
|
||||||
}
|
}
|
||||||
' po/Makevars.template >runtime-po/Makevars || exit 1
|
' po/Makevars.template >runtime-po/Makevars \
|
||||||
|
|| die 'cannot generate runtime-po/Makevars'
|
||||||
|
|
||||||
# Copy identical files from po to runtime-po.
|
# Copy identical files from po to runtime-po.
|
||||||
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
|
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
|
||||||
|
|||||||
+7
-5
@@ -17,15 +17,17 @@
|
|||||||
|
|
||||||
# gnulib modules used by this package.
|
# gnulib modules used by this package.
|
||||||
gnulib_modules='
|
gnulib_modules='
|
||||||
announce-gen argmatch assert calloc-posix close closeout config-h c-strcase
|
argmatch assert calloc-posix close closeout config-h c-strcase
|
||||||
configmake
|
configmake
|
||||||
dirname
|
dirname
|
||||||
do-release-commit-and-tag
|
error extensions fdl fopen-safer getopt-gnu
|
||||||
error extensions fdl fopen-safer gendocs getopt-gnu
|
|
||||||
gettext git-version-gen gitlog-to-changelog
|
gettext git-version-gen gitlog-to-changelog
|
||||||
gpl-3.0 hash inttypes isnan javacomp-script
|
gpl-3.0 hash inttypes isnan javacomp-script
|
||||||
javaexec-script ldexpl maintainer-makefile malloc-gnu mbschr mbsrchr
|
javaexec-script ldexpl malloc-gnu mbschr mbsrchr
|
||||||
mbswidth obstack perror progname
|
mbswidth
|
||||||
|
obstack
|
||||||
|
obstack-printf
|
||||||
|
perror progname
|
||||||
quote quotearg
|
quote quotearg
|
||||||
readme-release
|
readme-release
|
||||||
realloc-posix
|
realloc-posix
|
||||||
|
|||||||
@@ -8,9 +8,12 @@
|
|||||||
/config.rpath
|
/config.rpath
|
||||||
/config.sub
|
/config.sub
|
||||||
/depcomp
|
/depcomp
|
||||||
|
/do-release-commit-and-tag
|
||||||
/gendocs.sh
|
/gendocs.sh
|
||||||
/git-version-gen
|
/git-version-gen
|
||||||
/gitlog-to-changelog
|
/gitlog-to-changelog
|
||||||
|
/gnu-web-doc-update
|
||||||
|
/gnupload
|
||||||
/install-sh
|
/install-sh
|
||||||
/javacomp.sh.in
|
/javacomp.sh.in
|
||||||
/javaexec.sh.in
|
/javaexec.sh.in
|
||||||
@@ -23,4 +26,3 @@
|
|||||||
/vc-list-files
|
/vc-list-files
|
||||||
/warn-on-use.h
|
/warn-on-use.h
|
||||||
/ylwrap
|
/ylwrap
|
||||||
/do-release-commit-and-tag
|
|
||||||
|
|||||||
+20
-2
@@ -1,2 +1,20 @@
|
|||||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
## Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
|
||||||
EXTRA_DIST = prev-version.txt cross-options.pl update-b4-copyright
|
|
||||||
|
# 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
cross-options.pl \
|
||||||
|
darwin11.4.0.valgrind \
|
||||||
|
prev-version.txt \
|
||||||
|
update-b4-copyright
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Copyright (C) 2012 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Valgrind suppression file for Bison.
|
||||||
|
|
||||||
|
{
|
||||||
|
Mac OS X initialization
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:?alloc*
|
||||||
|
...
|
||||||
|
fun:*ImageLoader*
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mac OS X initialization
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:?alloc*
|
||||||
|
...
|
||||||
|
fun:*dyld*
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mac OS X initialization
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:?alloc*
|
||||||
|
...
|
||||||
|
fun:__CFInitialize
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mac OS X I/O buffer
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:malloc
|
||||||
|
fun:__smakebuf
|
||||||
|
fun:__swsetup
|
||||||
|
fun:__sfvwrite
|
||||||
|
fun:fwrite
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mac OS X I/O buffer
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:malloc
|
||||||
|
fun:__smakebuf
|
||||||
|
fun:__swsetup
|
||||||
|
fun:__swbuf
|
||||||
|
fun:putchar
|
||||||
|
}
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# End:
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/_Noreturn.h
|
||||||
|
/arg-nonnull.h
|
||||||
|
/c++defs.h
|
||||||
|
/warn-on-use.h
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
# Customize maint.mk -*- makefile -*-
|
# Customize maint.mk -*- makefile -*-
|
||||||
|
|
||||||
# Copyright (C) 2008-2012 Free Software Foundation, Inc.
|
# Copyright (C) 2008-2012 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
|
||||||
@@ -15,6 +14,17 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Update version, then recompile so that tests/bison --version be
|
||||||
|
# up-to-date, then compile our parser again with our up-to-date bison.
|
||||||
|
.PHONY: regen
|
||||||
|
regen: _version
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS)
|
||||||
|
touch $(srcdir)/src/parse-gram.y
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS)
|
||||||
|
|
||||||
|
# Used in maint.mk's web-manual rule
|
||||||
|
manual_title = The Yacc-compatible Parser Generator
|
||||||
|
|
||||||
# It's useful to run maintainer-*check* targets during development, but we
|
# It's useful to run maintainer-*check* targets during development, but we
|
||||||
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
|
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
|
||||||
# override the _is-dist-target from GNUmakefile so that maintainer-*check*
|
# override the _is-dist-target from GNUmakefile so that maintainer-*check*
|
||||||
@@ -22,13 +32,6 @@
|
|||||||
_is-dist-target = $(filter-out %clean maintainer-check% maintainer-%-check, \
|
_is-dist-target = $(filter-out %clean maintainer-check% maintainer-%-check, \
|
||||||
$(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
|
$(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
|
||||||
|
|
||||||
# Use alpha.gnu.org for alpha and beta releases.
|
|
||||||
# Use ftp.gnu.org for major releases.
|
|
||||||
gnu_ftp_host-alpha = alpha.gnu.org
|
|
||||||
gnu_ftp_host-beta = alpha.gnu.org
|
|
||||||
gnu_ftp_host-major = ftp.gnu.org
|
|
||||||
gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
|
|
||||||
|
|
||||||
url_dir_list = \
|
url_dir_list = \
|
||||||
ftp://$(gnu_rel_host)/gnu/bison
|
ftp://$(gnu_rel_host)/gnu/bison
|
||||||
|
|
||||||
@@ -57,17 +60,20 @@ update-copyright: update-b4-copyright update-package-copyright-year
|
|||||||
update-copyright-env = \
|
update-copyright-env = \
|
||||||
UPDATE_COPYRIGHT_FORCE=1 UPDATE_COPYRIGHT_USE_INTERVALS=1
|
UPDATE_COPYRIGHT_FORCE=1 UPDATE_COPYRIGHT_USE_INTERVALS=1
|
||||||
|
|
||||||
exclude = $(foreach a,$(1),$(eval exclude_file_name_regexp--sc_$(a)))
|
exclude = \
|
||||||
|
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
||||||
$(call exclude, \
|
$(call exclude, \
|
||||||
bindtextdomain=^lib/main.c$$ \
|
bindtextdomain=^lib/main.c$$ \
|
||||||
program_name=^lib/main.c$$ \
|
program_name=^lib/main.c$$ \
|
||||||
prohibit_always-defined_macros=^data/yacc.c|^djgpp/ \
|
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
|
||||||
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
|
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
|
||||||
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
||||||
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
||||||
prohibit_empty_lines_at_EOF=^src/parse-gram.[ch]$$ \
|
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
|
||||||
|
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
||||||
|
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
||||||
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
|
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
|
||||||
space_tab=^tests/(input|c\+\+)\.at$$ \
|
space_tab=^tests/(input|c\+\+)\.at$$ \
|
||||||
trailing_blank=^src/parse-gram.[ch]$$ \
|
trailing_blank=^src/parse-gram.[ch]$$ \
|
||||||
unmarked_diagnostics=^djgpp/ \
|
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$) \
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -163,6 +163,16 @@ AC_CONFIG_TESTDIR(tests)
|
|||||||
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
|
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
|
||||||
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
|
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
|
||||||
AC_CHECK_PROGS([VALGRIND], [valgrind])
|
AC_CHECK_PROGS([VALGRIND], [valgrind])
|
||||||
|
case $VALGRIND:$host_os in
|
||||||
|
'':*) ;;
|
||||||
|
*:darwin*)
|
||||||
|
# See README-hacking.
|
||||||
|
# VALGRIND+=' --suppressions=$(abs_top_srcdir)/build-aux/darwin11.4.0.valgrind'
|
||||||
|
VALGRIND=;;
|
||||||
|
*:*)
|
||||||
|
AC_SUBST([VALGRIND_PREBISON], ["$VALGRIND -q"]);;
|
||||||
|
esac
|
||||||
|
|
||||||
AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
||||||
# Needed by tests/atlocal.in.
|
# Needed by tests/atlocal.in.
|
||||||
AC_SUBST([GCC])
|
AC_SUBST([GCC])
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
dist_pkgdata_DATA = README bison.m4 \
|
dist_pkgdata_DATA = README bison.m4 \
|
||||||
|
c-like.m4 \
|
||||||
c-skel.m4 c.m4 yacc.c glr.c \
|
c-skel.m4 c.m4 yacc.c glr.c \
|
||||||
c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \
|
c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \
|
||||||
java-skel.m4 java.m4 lalr1.java
|
java-skel.m4 java.m4 lalr1.java
|
||||||
|
|||||||
+37
-29
@@ -183,21 +183,6 @@ m4_define([b4_fatal_at],
|
|||||||
m4_exit(1)])
|
m4_exit(1)])
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
|
||||||
## Default values. ##
|
|
||||||
## ---------------- ##
|
|
||||||
|
|
||||||
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
|
|
||||||
m4_define_default([b4_pre_prologue], [])
|
|
||||||
m4_define_default([b4_post_prologue], [])
|
|
||||||
m4_define_default([b4_epilogue], [])
|
|
||||||
m4_define_default([b4_parse_param], [])
|
|
||||||
|
|
||||||
# The initial column and line.
|
|
||||||
m4_define_default([b4_location_initial_column], [1])
|
|
||||||
m4_define_default([b4_location_initial_line], [1])
|
|
||||||
|
|
||||||
|
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
## Data Types. ##
|
## Data Types. ##
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
@@ -233,9 +218,9 @@ m4_define([b4_define_flag_if],
|
|||||||
|
|
||||||
# _b4_define_flag_if($1, $2, FLAG)
|
# _b4_define_flag_if($1, $2, FLAG)
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
# This macro works around the impossibility to define macros
|
# Work around the impossibility to define macros inside macros,
|
||||||
# inside macros, because issuing `[$1]' is not possible in M4 :(.
|
# because issuing `[$1]' is not possible in M4. GNU M4 should provide
|
||||||
# This sucks hard, GNU M4 should really provide M5 like $$1.
|
# $$1 a la M5/TeX.
|
||||||
m4_define([_b4_define_flag_if],
|
m4_define([_b4_define_flag_if],
|
||||||
[m4_if([$1$2], $[1]$[2], [],
|
[m4_if([$1$2], $[1]$[2], [],
|
||||||
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
||||||
@@ -246,17 +231,17 @@ m4_define([b4_$3_if],
|
|||||||
# b4_FLAG_if(IF-TRUE, IF-FALSE)
|
# b4_FLAG_if(IF-TRUE, IF-FALSE)
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
||||||
b4_define_flag_if([defines]) # Whether headers are requested.
|
b4_define_flag_if([defines]) # Whether headers are requested.
|
||||||
b4_define_flag_if([error_verbose]) # Whether error are verbose.
|
b4_define_flag_if([error_verbose]) # Whether error are verbose.
|
||||||
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
||||||
b4_define_flag_if([locations]) # Whether locations are tracked.
|
b4_define_flag_if([locations]) # Whether locations are tracked.
|
||||||
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
||||||
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
||||||
|
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||||
|
|
||||||
|
# yytoken_table is needed to support verbose errors.
|
||||||
|
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
|
||||||
|
|
||||||
## ------------------------- ##
|
|
||||||
## Assigning token numbers. ##
|
|
||||||
## ------------------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
## ----------- ##
|
## ----------- ##
|
||||||
@@ -274,8 +259,8 @@ m4_define([b4_basename],
|
|||||||
# b4_syncline(LINE, FILE)
|
# b4_syncline(LINE, FILE)
|
||||||
# -----------------------
|
# -----------------------
|
||||||
m4_define([b4_syncline],
|
m4_define([b4_syncline],
|
||||||
[b4_flag_if([synclines], [
|
[b4_flag_if([synclines],
|
||||||
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
[b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
||||||
b4_sync_start([$1], [$2])])])
|
b4_sync_start([$1], [$2])])])
|
||||||
|
|
||||||
m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
|
m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
|
||||||
@@ -576,3 +561,26 @@ m4_wrap_lifo([
|
|||||||
b4_check_user_names_wrap([[define]], [[variable]])
|
b4_check_user_names_wrap([[define]], [[variable]])
|
||||||
b4_check_user_names_wrap([[code]], [[qualifier]])
|
b4_check_user_names_wrap([[code]], [[qualifier]])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Default values. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
|
||||||
|
m4_define_default([b4_pre_prologue], [])
|
||||||
|
m4_define_default([b4_post_prologue], [])
|
||||||
|
m4_define_default([b4_epilogue], [])
|
||||||
|
m4_define_default([b4_parse_param], [])
|
||||||
|
|
||||||
|
# The initial column and line.
|
||||||
|
m4_define_default([b4_location_initial_column], [1])
|
||||||
|
m4_define_default([b4_location_initial_line], [1])
|
||||||
|
|
||||||
|
# Sanity checks.
|
||||||
|
b4_percent_define_ifdef([api.prefix],
|
||||||
|
[m4_ifdef([b4_prefix],
|
||||||
|
[b4_complain_at(b4_percent_define_get_loc([api.prefix]),
|
||||||
|
[['%s' and '%s' cannot be used together]],
|
||||||
|
[%name-prefix],
|
||||||
|
[%define api.prefix])])])
|
||||||
|
|||||||
+29
@@ -174,3 +174,32 @@ m4_define([b4_cc_var_decls],
|
|||||||
], [$@])])
|
], [$@])])
|
||||||
m4_define([b4_cc_var_decl],
|
m4_define([b4_cc_var_decl],
|
||||||
[ $1;])
|
[ $1;])
|
||||||
|
|
||||||
|
|
||||||
|
## ---------##
|
||||||
|
## Values. ##
|
||||||
|
## ---------##
|
||||||
|
|
||||||
|
# b4_yylloc_default_define
|
||||||
|
# ------------------------
|
||||||
|
# Define YYLLOC_DEFAULT.
|
||||||
|
m4_define([b4_yylloc_default_define],
|
||||||
|
[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||||
|
If N is 0, then set CURRENT to the empty location which ends
|
||||||
|
the previous symbol: RHS[0] (always defined). */
|
||||||
|
|
||||||
|
# ifndef YYLLOC_DEFAULT
|
||||||
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
|
do \
|
||||||
|
if (N) \
|
||||||
|
{ \
|
||||||
|
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
||||||
|
(Current).end = YYRHSLOC (Rhs, N).end; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
||||||
|
} \
|
||||||
|
while (/*CONSTCOND*/ false)
|
||||||
|
# endif
|
||||||
|
]])
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
-*- Autoconf -*-
|
||||||
|
|
||||||
|
# Common code for C-like languages (C, C++, Java, etc.)
|
||||||
|
|
||||||
|
# Copyright (C) 2012 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)
|
||||||
|
# ----------------------------------------------
|
||||||
|
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
|
||||||
|
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
|
||||||
|
# pointer.
|
||||||
|
m4_define([b4_dollar_dollar_],
|
||||||
|
[m4_if([$2], [[]],
|
||||||
|
[m4_ifval([$3], [($1.$3)],
|
||||||
|
[$1])],
|
||||||
|
[($1.$2)])])
|
||||||
|
|
||||||
|
# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION)
|
||||||
|
# b4_dollar_popdef
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD,
|
||||||
|
# and b4_at_dollar for LOCATION.
|
||||||
|
m4_define([b4_dollar_pushdef],
|
||||||
|
[m4_pushdef([b4_dollar_dollar],
|
||||||
|
[b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl
|
||||||
|
m4_pushdef([b4_at_dollar], [$3])dnl
|
||||||
|
])
|
||||||
|
m4_define([b4_dollar_popdef],
|
||||||
|
[m4_popdef([b4_at_dollar])dnl
|
||||||
|
m4_popdef([b4_dollar_dollar])dnl
|
||||||
|
])
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
m4_include(b4_pkgdatadir/[c-like.m4])
|
||||||
|
|
||||||
# b4_tocpp(STRING)
|
# b4_tocpp(STRING)
|
||||||
# ----------------
|
# ----------------
|
||||||
@@ -77,9 +78,6 @@ m4_define([b4_identification],
|
|||||||
|
|
||||||
/* Pull parsers. */
|
/* Pull parsers. */
|
||||||
#define YYPULL ]b4_pull_flag])[
|
#define YYPULL ]b4_pull_flag])[
|
||||||
|
|
||||||
/* Using locations. */
|
|
||||||
#define YYLSP_NEEDED ]b4_locations_flag[
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
@@ -87,11 +85,24 @@ m4_define([b4_identification],
|
|||||||
## Default values. ##
|
## Default values. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
# If the %union is not named, its name is YYSTYPE.
|
# b4_api_prefix, b4_api_PREFIX
|
||||||
m4_define_default([b4_union_name], [YYSTYPE])
|
# ----------------------------
|
||||||
|
# Corresponds to %define api.prefix
|
||||||
|
b4_percent_define_default([[api.prefix]], [[yy]])
|
||||||
|
m4_define([b4_api_prefix],
|
||||||
|
[b4_percent_define_get([[api.prefix]])])
|
||||||
|
m4_define([b4_api_PREFIX],
|
||||||
|
[m4_toupper(b4_api_prefix)])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_prefix
|
||||||
|
# ---------
|
||||||
|
# If the %name-prefix is not given, it is api.prefix.
|
||||||
|
m4_define_default([b4_prefix], [b4_api_prefix])
|
||||||
|
|
||||||
|
# If the %union is not named, its name is YYSTYPE.
|
||||||
|
m4_define_default([b4_union_name], [b4_api_PREFIX[]STYPE])
|
||||||
|
|
||||||
# If the %name-prefix is not given, it is yy.
|
|
||||||
m4_define_default([b4_prefix], [yy])
|
|
||||||
|
|
||||||
## ------------------------ ##
|
## ------------------------ ##
|
||||||
## Pure/impure interfaces. ##
|
## Pure/impure interfaces. ##
|
||||||
@@ -235,18 +246,18 @@ m4_define([b4_token_enum],
|
|||||||
# Output the definition of the tokens (if there are) as enums.
|
# Output the definition of the tokens (if there are) as enums.
|
||||||
m4_define([b4_token_enums],
|
m4_define([b4_token_enums],
|
||||||
[m4_if([$#$1], [1], [],
|
[m4_if([$#$1], [1], [],
|
||||||
[/* Tokens. */
|
[[/* Tokens. */
|
||||||
#ifndef YYTOKENTYPE
|
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
||||||
# define YYTOKENTYPE
|
# define ]b4_api_PREFIX[TOKENTYPE
|
||||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
know about them. */
|
know about them. */
|
||||||
enum yytokentype {
|
enum ]b4_api_prefix[tokentype {
|
||||||
m4_map_sep([ b4_token_enum], [,
|
]m4_map_sep([ b4_token_enum], [,
|
||||||
],
|
],
|
||||||
[$@])
|
[$@])[
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
])])
|
]])])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
# b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||||
@@ -411,17 +422,18 @@ $2
|
|||||||
# SYMBOL-TAG, SYMBOL-NUM,
|
# SYMBOL-TAG, SYMBOL-NUM,
|
||||||
# SYMBOL-ACTION, SYMBOL-TYPENAME)
|
# SYMBOL-ACTION, SYMBOL-TYPENAME)
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
|
# Issue the code for a symbol action (e.g., %printer).
|
||||||
|
#
|
||||||
|
# Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are
|
||||||
|
# invoked where $<TYPE-NAME>$ and @$ were specified by the user.
|
||||||
m4_define([b4_symbol_actions],
|
m4_define([b4_symbol_actions],
|
||||||
[m4_pushdef([b4_dollar_dollar],
|
[b4_dollar_pushdef([(*yyvaluep)], [$6], [(*yylocationp)])dnl
|
||||||
[m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
|
|
||||||
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
|
|
||||||
case $4: /* $3 */
|
case $4: /* $3 */
|
||||||
b4_syncline([$2], [$1])
|
b4_syncline([$2], [$1])
|
||||||
$5;
|
$5;
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])
|
||||||
break;
|
break;
|
||||||
m4_popdef([b4_at_dollar])dnl
|
b4_dollar_popdef[]dnl
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -530,3 +542,102 @@ b4_locations_if([, yylocationp])[]b4_user_args[);
|
|||||||
YYFPRINTF (yyoutput, ")");
|
YYFPRINTF (yyoutput, ")");
|
||||||
}]dnl
|
}]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Declarations. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
# b4_declare_yylstype
|
||||||
|
# -------------------
|
||||||
|
# Declarations that might either go into the header (if --defines) or
|
||||||
|
# in the parser body. Declare YYSTYPE/YYLTYPE, and yylval/yylloc.
|
||||||
|
m4_define([b4_declare_yylstype],
|
||||||
|
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
||||||
|
]m4_ifdef([b4_stype],
|
||||||
|
[[typedef union ]b4_union_name[
|
||||||
|
{
|
||||||
|
]b4_user_stype[
|
||||||
|
} ]b4_api_PREFIX[STYPE;
|
||||||
|
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1]],
|
||||||
|
[m4_if(b4_tag_seen_flag, 0,
|
||||||
|
[[typedef int ]b4_api_PREFIX[STYPE;
|
||||||
|
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1]])])[
|
||||||
|
# define ]b4_api_prefix[stype ]b4_api_PREFIX[STYPE /* obsolescent; will be withdrawn */
|
||||||
|
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
||||||
|
#endif]b4_locations_if([[
|
||||||
|
|
||||||
|
#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
|
||||||
|
typedef struct ]b4_api_PREFIX[LTYPE
|
||||||
|
{
|
||||||
|
int first_line;
|
||||||
|
int first_column;
|
||||||
|
int last_line;
|
||||||
|
int last_column;
|
||||||
|
} ]b4_api_PREFIX[LTYPE;
|
||||||
|
# define ]b4_api_prefix[ltype ]b4_api_PREFIX[LTYPE /* obsolescent; will be withdrawn */
|
||||||
|
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
|
||||||
|
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
|
||||||
|
#endif]])
|
||||||
|
|
||||||
|
b4_pure_if([], [[extern ]b4_api_PREFIX[STYPE ]b4_prefix[lval;
|
||||||
|
]b4_locations_if([[extern ]b4_api_PREFIX[LTYPE ]b4_prefix[lloc;]])])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4_YYDEBUG_define
|
||||||
|
# ------------------
|
||||||
|
m4_define([b4_YYDEBUG_define],
|
||||||
|
[[/* Enabling traces. */
|
||||||
|
]m4_if(b4_api_prefix, [yy],
|
||||||
|
[[#ifndef YYDEBUG
|
||||||
|
# define YYDEBUG ]b4_debug_flag[
|
||||||
|
#endif]],
|
||||||
|
[[#ifndef ]b4_api_PREFIX[DEBUG
|
||||||
|
# if defined YYDEBUG
|
||||||
|
# if YYDEBUG
|
||||||
|
# define ]b4_api_PREFIX[DEBUG 1
|
||||||
|
# else
|
||||||
|
# define ]b4_api_PREFIX[DEBUG 0
|
||||||
|
# endif
|
||||||
|
# else /* ! defined YYDEBUG */
|
||||||
|
# define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[
|
||||||
|
# endif /* ! defined ]b4_api_PREFIX[DEBUG */
|
||||||
|
#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4_declare_yydebug
|
||||||
|
# ------------------
|
||||||
|
m4_define([b4_declare_yydebug],
|
||||||
|
[b4_YYDEBUG_define[
|
||||||
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
|
extern int ]b4_prefix[debug;
|
||||||
|
#endif][]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4_yylloc_default_define
|
||||||
|
# ------------------------
|
||||||
|
# Define YYLLOC_DEFAULT.
|
||||||
|
m4_define([b4_yylloc_default_define],
|
||||||
|
[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||||
|
If N is 0, then set CURRENT to the empty location which ends
|
||||||
|
the previous symbol: RHS[0] (always defined). */
|
||||||
|
|
||||||
|
#ifndef YYLLOC_DEFAULT
|
||||||
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
|
do \
|
||||||
|
if (YYID (N)) \
|
||||||
|
{ \
|
||||||
|
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
||||||
|
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
||||||
|
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
||||||
|
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
(Current).first_line = (Current).last_line = \
|
||||||
|
YYRHSLOC (Rhs, 0).last_line; \
|
||||||
|
(Current).first_column = (Current).last_column = \
|
||||||
|
YYRHSLOC (Rhs, 0).last_column; \
|
||||||
|
} \
|
||||||
|
while (YYID (0))
|
||||||
|
#endif
|
||||||
|
]])
|
||||||
|
|||||||
+66
-122
@@ -18,7 +18,10 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c.m4])
|
# If we are loaded by glr.cc, do not override c++.m4 definitions by
|
||||||
|
# those of c.m4.
|
||||||
|
m4_if(b4_skeleton, ["glr.c"],
|
||||||
|
[m4_include(b4_pkgdatadir/[c.m4])])
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Default values. ##
|
## Default values. ##
|
||||||
@@ -154,6 +157,23 @@ m4_define([b4_rhs_location],
|
|||||||
[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)])
|
[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)])
|
||||||
|
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Declarations. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
# 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_declare_yydebug[
|
||||||
|
]b4_percent_code_get([[requires]])[
|
||||||
|
]b4_token_enums(b4_tokens)[
|
||||||
|
]b4_declare_yylstype[
|
||||||
|
]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
|
||||||
|
]b4_percent_code_get([[provides]])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
## Output files. ##
|
## Output files. ##
|
||||||
@@ -170,66 +190,29 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
|||||||
|
|
||||||
]b4_identification
|
]b4_identification
|
||||||
|
|
||||||
b4_percent_code_get([[top]])[]dnl
|
b4_percent_code_get([[top]])[
|
||||||
m4_if(b4_prefix, [yy], [],
|
]m4_if(b4_api_prefix, [yy], [],
|
||||||
[/* Substitute the variable and function names. */
|
[[/* Substitute the type names. */
|
||||||
#define yyparse b4_prefix[]parse
|
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
|
||||||
#define yylex b4_prefix[]lex
|
#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
|
||||||
#define yyerror b4_prefix[]error
|
]m4_if(b4_prefix, [yy], [],
|
||||||
#define yylval b4_prefix[]lval
|
[[/* Substitute the variable and function names. */
|
||||||
#define yychar b4_prefix[]char
|
#define yyparse ]b4_prefix[parse
|
||||||
#define yydebug b4_prefix[]debug
|
#define yylex ]b4_prefix[lex
|
||||||
#define yynerrs b4_prefix[]nerrs
|
#define yyerror ]b4_prefix[error
|
||||||
#define yylloc b4_prefix[]lloc])[
|
#define yylval ]b4_prefix[lval
|
||||||
|
#define yychar ]b4_prefix[char
|
||||||
|
#define yydebug ]b4_prefix[debug
|
||||||
|
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
|
||||||
|
#define yylloc ]b4_prefix[lloc]])])[
|
||||||
|
|
||||||
/* Copy the first part of user declarations. */
|
/* Copy the first part of user declarations. */
|
||||||
]b4_user_pre_prologue
|
]b4_user_pre_prologue[
|
||||||
|
|
||||||
b4_null_define
|
]b4_null_define[
|
||||||
|
|
||||||
dnl # b4_shared_declarations
|
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
|
||||||
dnl # ----------------------
|
[b4_shared_declarations])[
|
||||||
dnl # Declaration that might either go into the header (if --defines)
|
|
||||||
dnl # or open coded in the parser body.
|
|
||||||
m4_define([b4_shared_declarations],
|
|
||||||
[b4_percent_code_get([[requires]])[]dnl
|
|
||||||
|
|
||||||
b4_token_enums(b4_tokens)
|
|
||||||
|
|
||||||
[#ifndef YYSTYPE
|
|
||||||
]m4_ifdef([b4_stype],
|
|
||||||
[[typedef union ]b4_union_name[
|
|
||||||
{
|
|
||||||
]b4_user_stype[
|
|
||||||
} YYSTYPE;
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1]],
|
|
||||||
[m4_if(b4_tag_seen_flag, 0,
|
|
||||||
[[typedef int YYSTYPE;
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1]])])[
|
|
||||||
#endif
|
|
||||||
]b4_locations_if([[
|
|
||||||
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
|
||||||
typedef struct YYLTYPE
|
|
||||||
{
|
|
||||||
int first_line;
|
|
||||||
int first_column;
|
|
||||||
int last_line;
|
|
||||||
int last_column;
|
|
||||||
} YYLTYPE;
|
|
||||||
# define YYLTYPE_IS_DECLARED 1
|
|
||||||
# define YYLTYPE_IS_TRIVIAL 1
|
|
||||||
#endif
|
|
||||||
]])[
|
|
||||||
]b4_percent_code_get([[provides]])[]dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
|
|
||||||
[b4_shared_declarations])[
|
|
||||||
|
|
||||||
/* Enabling traces. */
|
|
||||||
#ifndef YYDEBUG
|
|
||||||
# define YYDEBUG ]b4_debug_flag[
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enabling verbose error messages. */
|
/* Enabling verbose error messages. */
|
||||||
#ifdef YYERROR_VERBOSE
|
#ifdef YYERROR_VERBOSE
|
||||||
@@ -239,11 +222,6 @@ b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
|
|||||||
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
|
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enabling the token table. */
|
|
||||||
#ifndef YYTOKEN_TABLE
|
|
||||||
# define YYTOKEN_TABLE ]b4_token_table[
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Default (constant) value used for initialization for null
|
/* Default (constant) value used for initialization for null
|
||||||
right-hand sides. Unlike the standard yacc.c template,
|
right-hand sides. Unlike the standard yacc.c template,
|
||||||
here we set the default value of $$ to a zeroed-out value.
|
here we set the default value of $$ to a zeroed-out value.
|
||||||
@@ -370,7 +348,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
|||||||
]b4_translate[
|
]b4_translate[
|
||||||
};
|
};
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
||||||
YYRHS. */
|
YYRHS. */
|
||||||
static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
|
static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
|
||||||
@@ -391,7 +369,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
|
||||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||||
static const char *const yytname[] =
|
static const char *const yytname[] =
|
||||||
@@ -492,37 +470,13 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
|
|||||||
]b4_stos[
|
]b4_stos[
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Prevent warning if -Wmissing-prototypes. */
|
|
||||||
]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param)[
|
|
||||||
|
|
||||||
/* Error token number */
|
/* Error token number */
|
||||||
#define YYTERROR 1
|
#define YYTERROR 1
|
||||||
|
|
||||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
|
||||||
If N is 0, then set CURRENT to the empty location which ends
|
|
||||||
the previous symbol: RHS[0] (always defined). */
|
|
||||||
|
|
||||||
]b4_locations_if([[
|
]b4_locations_if([[
|
||||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
|
|
||||||
#ifndef YYLLOC_DEFAULT
|
#ifndef YYLLOC_DEFAULT
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
]b4_yylloc_default_define[
|
||||||
do \
|
# define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
|
||||||
if (YYID (N)) \
|
|
||||||
{ \
|
|
||||||
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
|
||||||
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
|
||||||
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
|
||||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
(Current).first_line = (Current).last_line = \
|
|
||||||
YYRHSLOC (Rhs, 0).last_line; \
|
|
||||||
(Current).first_column = (Current).last_column = \
|
|
||||||
YYRHSLOC (Rhs, 0).last_column; \
|
|
||||||
} \
|
|
||||||
while (YYID (0))
|
|
||||||
|
|
||||||
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
||||||
This macro was not mandated originally: define only if we know
|
This macro was not mandated originally: define only if we know
|
||||||
@@ -543,7 +497,6 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
|
|||||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* YYLEX -- calling `yylex' with the right arguments. */
|
/* YYLEX -- calling `yylex' with the right arguments. */
|
||||||
#define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
|
#define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
|
||||||
|
|
||||||
@@ -577,7 +530,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
|
|||||||
do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
|
do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
|
||||||
while (YYID (0))
|
while (YYID (0))
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
|
|
||||||
# ifndef YYFPRINTF
|
# ifndef YYFPRINTF
|
||||||
# define YYFPRINTF fprintf
|
# define YYFPRINTF fprintf
|
||||||
@@ -605,12 +558,12 @@ do { \
|
|||||||
multiple parsers can coexist. */
|
multiple parsers can coexist. */
|
||||||
int yydebug;
|
int yydebug;
|
||||||
|
|
||||||
#else /* !YYDEBUG */
|
#else /* !]b4_api_PREFIX[DEBUG */
|
||||||
|
|
||||||
# define YYDPRINTF(Args)
|
# define YYDPRINTF(Args)
|
||||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||||
|
|
||||||
#endif /* !YYDEBUG */
|
#endif /* !]b4_api_PREFIX[DEBUG */
|
||||||
|
|
||||||
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
||||||
#ifndef YYINITDEPTH
|
#ifndef YYINITDEPTH
|
||||||
@@ -637,8 +590,8 @@ int yydebug;
|
|||||||
|
|
||||||
#ifndef YYSTACKEXPANDABLE
|
#ifndef YYSTACKEXPANDABLE
|
||||||
# if (! defined __cplusplus \
|
# if (! defined __cplusplus \
|
||||||
|| (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
|
|| (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
|
||||||
&& ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))
|
&& ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL))
|
||||||
# define YYSTACKEXPANDABLE 1
|
# define YYSTACKEXPANDABLE 1
|
||||||
# else
|
# else
|
||||||
# define YYSTACKEXPANDABLE 0
|
# define YYSTACKEXPANDABLE 0
|
||||||
@@ -849,7 +802,7 @@ yyMemoryExhausted (yyGLRStack* yystackp)
|
|||||||
YYLONGJMP (yystackp->yyexception_buffer, 2);
|
YYLONGJMP (yystackp->yyexception_buffer, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YYDEBUG || YYERROR_VERBOSE
|
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE
|
||||||
/** A printable representation of TOKEN. */
|
/** A printable representation of TOKEN. */
|
||||||
static inline const char*
|
static inline const char*
|
||||||
yytokenName (yySymbol yytoken)
|
yytokenName (yySymbol yytoken)
|
||||||
@@ -986,7 +939,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
|
|||||||
&yys->yysemantics.yysval]b4_locuser_args([&yys->yyloc])[);
|
&yys->yysemantics.yysval]b4_locuser_args([&yys->yyloc])[);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
if (yydebug)
|
if (yydebug)
|
||||||
{
|
{
|
||||||
if (yys->yysemantics.yyfirstVal)
|
if (yys->yysemantics.yyfirstVal)
|
||||||
@@ -1415,7 +1368,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !YYDEBUG
|
#if !]b4_api_PREFIX[DEBUG
|
||||||
# define YY_REDUCE_PRINT(Args)
|
# define YY_REDUCE_PRINT(Args)
|
||||||
#else
|
#else
|
||||||
# define YY_REDUCE_PRINT(Args) \
|
# define YY_REDUCE_PRINT(Args) \
|
||||||
@@ -1736,7 +1689,7 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
|
|||||||
return yyflag;
|
return yyflag;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
static void
|
static void
|
||||||
yyreportTree (yySemanticOption* yyx, int yyindent)
|
yyreportTree (yySemanticOption* yyx, int yyindent)
|
||||||
{
|
{
|
||||||
@@ -1791,7 +1744,7 @@ yyreportAmbiguity (yySemanticOption* yyx0,
|
|||||||
YYUSE (yyx0);
|
YYUSE (yyx0);
|
||||||
YYUSE (yyx1);
|
YYUSE (yyx1);
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
YYFPRINTF (stderr, "Ambiguity detected.\n");
|
YYFPRINTF (stderr, "Ambiguity detected.\n");
|
||||||
YYFPRINTF (stderr, "Option 1,\n");
|
YYFPRINTF (stderr, "Option 1,\n");
|
||||||
yyreportTree (yyx0, 2);
|
yyreportTree (yyx0, 2);
|
||||||
@@ -2343,18 +2296,16 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
|||||||
yychar = YYEMPTY;
|
yychar = YYEMPTY;
|
||||||
yylval = yyval_default;
|
yylval = yyval_default;
|
||||||
]b4_locations_if([
|
]b4_locations_if([
|
||||||
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||||
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
|
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
|
||||||
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
|
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
|
||||||
#endif
|
#endif
|
||||||
])
|
])
|
||||||
m4_ifdef([b4_initial_action], [
|
m4_ifdef([b4_initial_action], [
|
||||||
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
||||||
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
/* User initialization code. */
|
||||||
/* User initialization code. */
|
b4_user_initial_action
|
||||||
b4_user_initial_action
|
b4_dollar_popdef])[]dnl
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
|
||||||
m4_popdef([b4_at_dollar])])dnl
|
|
||||||
[
|
[
|
||||||
if (! yyinitGLRStack (yystackp, YYINITDEPTH))
|
if (! yyinitGLRStack (yystackp, YYINITDEPTH))
|
||||||
goto yyexhaustedlab;
|
goto yyexhaustedlab;
|
||||||
@@ -2575,7 +2526,7 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* DEBUGGING ONLY */
|
/* DEBUGGING ONLY */
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
static void yypstack (yyGLRStack* yystackp, size_t yyk)
|
static void yypstack (yyGLRStack* yystackp, size_t yyk)
|
||||||
__attribute__ ((__unused__));
|
__attribute__ ((__unused__));
|
||||||
static void yypdumpstack (yyGLRStack* yystackp) __attribute__ ((__unused__));
|
static void yypdumpstack (yyGLRStack* yystackp) __attribute__ ((__unused__));
|
||||||
@@ -2648,9 +2599,7 @@ yypdumpstack (yyGLRStack* yystackp)
|
|||||||
YYFPRINTF (stderr, "\n");
|
YYFPRINTF (stderr, "\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
]
|
]b4_epilogue[]dnl
|
||||||
|
|
||||||
b4_epilogue
|
|
||||||
dnl
|
dnl
|
||||||
dnl glr.cc produces its own header.
|
dnl glr.cc produces its own header.
|
||||||
dnl
|
dnl
|
||||||
@@ -2658,15 +2607,10 @@ m4_if(b4_skeleton, ["glr.c"],
|
|||||||
[b4_defines_if(
|
[b4_defines_if(
|
||||||
[@output(b4_spec_defines_file@)@
|
[@output(b4_spec_defines_file@)@
|
||||||
b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
||||||
[2002-2012])
|
[2002-2012])[
|
||||||
|
|
||||||
b4_shared_declarations
|
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
|
]b4_shared_declarations[
|
||||||
b4_pure_if([],
|
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||||
[[extern YYSTYPE ]b4_prefix[lval;]])
|
]])])dnl
|
||||||
|
|
||||||
b4_locations_if([b4_pure_if([],
|
|
||||||
[extern YYLTYPE ]b4_prefix[lloc;])
|
|
||||||
])
|
|
||||||
])])
|
|
||||||
m4_divert_pop(0)
|
m4_divert_pop(0)
|
||||||
|
|||||||
+41
-68
@@ -78,9 +78,9 @@ m4_define([b4_yy_symbol_print_generate],
|
|||||||
[static void],
|
[static void],
|
||||||
[[FILE *], []],
|
[[FILE *], []],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
[[const b4_namespace_ref::b4_parser_class_name::semantic_type *yyvaluep],
|
[[const ]b4_namespace_ref::b4_parser_class_name[::semantic_type *yyvaluep],
|
||||||
[yyvaluep]],
|
[yyvaluep]],
|
||||||
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
|
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
||||||
[yylocationp]],
|
[yylocationp]],
|
||||||
b4_parse_param)[
|
b4_parse_param)[
|
||||||
{
|
{
|
||||||
@@ -90,19 +90,22 @@ m4_define([b4_yy_symbol_print_generate],
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
# Declare yyerror.
|
# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT
|
||||||
|
# and declaration of yyerror.
|
||||||
m4_append([b4_post_prologue],
|
m4_append([b4_post_prologue],
|
||||||
[b4_syncline([@oline@], [@ofile@])
|
[b4_syncline([@oline@], [@ofile@])[
|
||||||
|
]b4_yylloc_default_define[
|
||||||
b4_c_ansi_function_decl([yyerror],
|
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
|
||||||
|
]b4_c_ansi_function_decl([yyerror],
|
||||||
[static void],
|
[static void],
|
||||||
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
|
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
||||||
[yylocationp]],
|
[yylocationp]],
|
||||||
b4_parse_param,
|
b4_parse_param,
|
||||||
[[const char* msg], [msg]])])
|
[[const char* msg], [msg]])])
|
||||||
|
|
||||||
|
|
||||||
# Define yyerror.
|
# Hijack the epilogue to define implementations (yyerror, parser member
|
||||||
|
# functions etc.).
|
||||||
m4_append([b4_epilogue],
|
m4_append([b4_epilogue],
|
||||||
[b4_syncline([@oline@], [@ofile@])[
|
[b4_syncline([@oline@], [@ofile@])[
|
||||||
/*------------------.
|
/*------------------.
|
||||||
@@ -111,7 +114,7 @@ m4_append([b4_epilogue],
|
|||||||
|
|
||||||
]b4_c_ansi_function_def([yyerror],
|
]b4_c_ansi_function_def([yyerror],
|
||||||
[static void],
|
[static void],
|
||||||
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
|
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
||||||
[yylocationp]],
|
[yylocationp]],
|
||||||
b4_parse_param,
|
b4_parse_param,
|
||||||
[[const char* msg], [msg]])[
|
[[const char* msg], [msg]])[
|
||||||
@@ -127,8 +130,8 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
[ /// Build a parser object.
|
[ /// Build a parser object.
|
||||||
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
||||||
:])[
|
:])[
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),
|
]m4_ifset([b4_parse_param], [ ], [ :])[
|
||||||
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
||||||
#endif]b4_parse_param_cons[
|
#endif]b4_parse_param_cons[
|
||||||
{
|
{
|
||||||
@@ -144,7 +147,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
return ::yyparse (*this]b4_user_args[);
|
return ::yyparse (*this]b4_user_args[);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/*--------------------.
|
/*--------------------.
|
||||||
| Print this symbol. |
|
| Print this symbol. |
|
||||||
`--------------------*/
|
`--------------------*/
|
||||||
@@ -196,29 +199,28 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
]b4_parser_class_name[::debug_level_type
|
]b4_parser_class_name[::debug_level_type
|
||||||
]b4_parser_class_name[::debug_level () const
|
]b4_parser_class_name[::debug_level () const
|
||||||
{
|
{
|
||||||
return yydebug_;
|
return yydebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::set_debug_level (debug_level_type l)
|
]b4_parser_class_name[::set_debug_level (debug_level_type l)
|
||||||
{
|
{
|
||||||
yydebug_ = l;
|
// Actually, it is yydebug which is really used.
|
||||||
|
yydebug = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
]m4_popdef([b4_parse_param])dnl
|
]m4_popdef([b4_parse_param])dnl
|
||||||
b4_namespace_close[
|
b4_namespace_close])
|
||||||
|
|
||||||
]])
|
|
||||||
|
|
||||||
|
|
||||||
# Let glr.c believe that the user arguments include the parser itself.
|
# Let glr.c believe that the user arguments include the parser itself.
|
||||||
m4_ifset([b4_parse_param],
|
m4_ifset([b4_parse_param],
|
||||||
[m4_pushdef([b4_parse_param],
|
[m4_pushdef([b4_parse_param],
|
||||||
m4_dquote([[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]],]
|
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],]
|
||||||
m4_defn([b4_parse_param])))],
|
m4_defn([b4_parse_param]))],
|
||||||
[m4_pushdef([b4_parse_param],
|
[m4_pushdef([b4_parse_param],
|
||||||
[[[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]]]])
|
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]])
|
||||||
])
|
])
|
||||||
m4_include(b4_pkgdatadir/[glr.c])
|
m4_include(b4_pkgdatadir/[glr.c])
|
||||||
m4_popdef([b4_parse_param])
|
m4_popdef([b4_parse_param])
|
||||||
@@ -230,42 +232,16 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
|||||||
|
|
||||||
/* C++ GLR parser skeleton written by Akim Demaille. */
|
/* C++ GLR parser skeleton written by Akim Demaille. */
|
||||||
|
|
||||||
#ifndef PARSER_HEADER_H
|
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
# define PARSER_HEADER_H
|
|
||||||
|
|
||||||
]b4_percent_code_get([[requires]])[
|
]b4_percent_code_get([[requires]])[
|
||||||
|
|
||||||
#include <string>
|
# include <string>
|
||||||
#include <iostream>
|
# include <iostream>
|
||||||
]b4_percent_define_ifdef([[location_type]], [],
|
]b4_percent_define_ifdef([[location_type]], [],
|
||||||
[[#include "location.hh"]])[
|
[[# include "location.hh"]])[
|
||||||
|
|
||||||
/* Using locations. */
|
]b4_YYDEBUG_define[
|
||||||
#define YYLSP_NEEDED ]b4_locations_flag[
|
|
||||||
|
|
||||||
/* Enabling traces. */
|
|
||||||
#ifndef YYDEBUG
|
|
||||||
# define YYDEBUG ]b4_debug_flag[
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
|
||||||
If N is 0, then set CURRENT to the empty location which ends
|
|
||||||
the previous symbol: RHS[0] (always defined). */
|
|
||||||
|
|
||||||
#ifndef YYLLOC_DEFAULT
|
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
|
||||||
do \
|
|
||||||
if (N) \
|
|
||||||
{ \
|
|
||||||
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
|
||||||
(Current).end = YYRHSLOC (Rhs, N).end; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
|
||||||
} \
|
|
||||||
while (/*CONSTCOND*/ 0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
]b4_namespace_open[
|
]b4_namespace_open[
|
||||||
/// A Bison parser.
|
/// A Bison parser.
|
||||||
@@ -273,7 +249,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Symbol semantic values.
|
/// Symbol semantic values.
|
||||||
#ifndef YYSTYPE
|
# ifndef ]b4_api_PREFIX[STYPE
|
||||||
]m4_ifdef([b4_stype],
|
]m4_ifdef([b4_stype],
|
||||||
[ union semantic_type
|
[ union semantic_type
|
||||||
{
|
{
|
||||||
@@ -281,10 +257,10 @@ b4_user_stype
|
|||||||
};],
|
};],
|
||||||
[m4_if(b4_tag_seen_flag, 0,
|
[m4_if(b4_tag_seen_flag, 0,
|
||||||
[[ typedef int semantic_type;]],
|
[[ typedef int semantic_type;]],
|
||||||
[[ typedef YYSTYPE semantic_type;]])])[
|
[[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])[
|
||||||
#else
|
# else
|
||||||
typedef YYSTYPE semantic_type;
|
typedef ]b4_api_PREFIX[STYPE semantic_type;
|
||||||
#endif
|
# endif
|
||||||
/// Symbol locations.
|
/// Symbol locations.
|
||||||
typedef ]b4_percent_define_get([[location_type]],
|
typedef ]b4_percent_define_get([[location_type]],
|
||||||
[[location]])[ location_type;
|
[[location]])[ location_type;
|
||||||
@@ -325,7 +301,7 @@ b4_user_stype
|
|||||||
virtual void error (const location_type& loc, const std::string& msg);
|
virtual void error (const location_type& loc, const std::string& msg);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#if YYDEBUG
|
# if ]b4_api_PREFIX[DEBUG
|
||||||
public:
|
public:
|
||||||
/// \brief Report a symbol value on the debug stream.
|
/// \brief Report a symbol value on the debug stream.
|
||||||
/// \param yytype The token type.
|
/// \param yytype The token type.
|
||||||
@@ -343,9 +319,8 @@ b4_user_stype
|
|||||||
const location_type* yylocationp);
|
const location_type* yylocationp);
|
||||||
private:
|
private:
|
||||||
/* Debugging. */
|
/* Debugging. */
|
||||||
int yydebug_;
|
|
||||||
std::ostream* yycdebug_;
|
std::ostream* yycdebug_;
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
]b4_parse_param_vars[
|
]b4_parse_param_vars[
|
||||||
};
|
};
|
||||||
@@ -354,16 +329,14 @@ b4_user_stype
|
|||||||
b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||||
[b4_token_defines(b4_tokens)])
|
[b4_token_defines(b4_tokens)])
|
||||||
[
|
[
|
||||||
#ifndef YYSTYPE
|
#ifndef ]b4_api_PREFIX[STYPE
|
||||||
# define YYSTYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
|
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
|
||||||
#endif
|
#endif
|
||||||
#ifndef YYLTYPE
|
#ifndef ]b4_api_PREFIX[LTYPE
|
||||||
# define YYLTYPE ]b4_namespace_ref[::]b4_parser_class_name[::location_type
|
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class_name[::location_type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
|
]b4_percent_code_get([[provides]])[
|
||||||
]b4_percent_code_get([[provides]])[]dnl
|
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||||
|
]m4_divert_pop(0)
|
||||||
[#endif /* ! defined PARSER_HEADER_H */]
|
|
||||||
m4_divert_pop(0)
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
m4_include(b4_pkgdatadir/[c-like.m4])
|
||||||
|
|
||||||
# b4_comment(TEXT)
|
# b4_comment(TEXT)
|
||||||
# ----------------
|
# ----------------
|
||||||
|
|||||||
+37
-75
@@ -55,25 +55,7 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
|
|||||||
]b4_percent_define_ifdef([[location_type]], [],
|
]b4_percent_define_ifdef([[location_type]], [],
|
||||||
[[#include "location.hh"]])[
|
[[#include "location.hh"]])[
|
||||||
|
|
||||||
]b4_null_define[
|
]b4_YYDEBUG_define[
|
||||||
|
|
||||||
/* Enabling traces. */
|
|
||||||
#ifndef YYDEBUG
|
|
||||||
# define YYDEBUG ]b4_debug_flag[
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enabling verbose error messages. */
|
|
||||||
#ifdef YYERROR_VERBOSE
|
|
||||||
# undef YYERROR_VERBOSE
|
|
||||||
# define YYERROR_VERBOSE 1
|
|
||||||
#else
|
|
||||||
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enabling the token table. */
|
|
||||||
#ifndef YYTOKEN_TABLE
|
|
||||||
# define YYTOKEN_TABLE ]b4_token_table[
|
|
||||||
#endif
|
|
||||||
|
|
||||||
]b4_namespace_open[
|
]b4_namespace_open[
|
||||||
|
|
||||||
@@ -82,7 +64,7 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Symbol semantic values.
|
/// Symbol semantic values.
|
||||||
#ifndef YYSTYPE
|
#ifndef ]b4_api_PREFIX[STYPE
|
||||||
]m4_ifdef([b4_stype],
|
]m4_ifdef([b4_stype],
|
||||||
[ union semantic_type
|
[ union semantic_type
|
||||||
{
|
{
|
||||||
@@ -90,9 +72,9 @@ b4_user_stype
|
|||||||
};],
|
};],
|
||||||
[m4_if(b4_tag_seen_flag, 0,
|
[m4_if(b4_tag_seen_flag, 0,
|
||||||
[[ typedef int semantic_type;]],
|
[[ typedef int semantic_type;]],
|
||||||
[[ typedef YYSTYPE semantic_type;]])])[
|
[[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])[
|
||||||
#else
|
#else
|
||||||
typedef YYSTYPE semantic_type;
|
typedef ]b4_api_PREFIX[STYPE semantic_type;
|
||||||
#endif
|
#endif
|
||||||
/// Symbol locations.
|
/// Symbol locations.
|
||||||
typedef ]b4_percent_define_get([[location_type]],
|
typedef ]b4_percent_define_get([[location_type]],
|
||||||
@@ -113,7 +95,7 @@ b4_user_stype
|
|||||||
/// \returns 0 iff parsing succeeded.
|
/// \returns 0 iff parsing succeeded.
|
||||||
virtual int parse ();
|
virtual int parse ();
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/// The current debugging stream.
|
/// The current debugging stream.
|
||||||
std::ostream& debug_stream () const;
|
std::ostream& debug_stream () const;
|
||||||
/// Set the current debugging stream.
|
/// Set the current debugging stream.
|
||||||
@@ -138,7 +120,7 @@ b4_user_stype
|
|||||||
/// \param tok the lookahead token.
|
/// \param tok the lookahead token.
|
||||||
virtual std::string yysyntax_error_ (int yystate, int tok);
|
virtual std::string yysyntax_error_ (int yystate, int tok);
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/// \brief Report a symbol value on the debug stream.
|
/// \brief Report a symbol value on the debug stream.
|
||||||
/// \param yytype The token type.
|
/// \param yytype The token type.
|
||||||
/// \param yyvaluep Its semantic value.
|
/// \param yyvaluep Its semantic value.
|
||||||
@@ -211,17 +193,15 @@ b4_user_stype
|
|||||||
/// For a rule, its LHS.
|
/// For a rule, its LHS.
|
||||||
static const ]b4_int_type_for([b4_r1])[ yyr1_[];
|
static const ]b4_int_type_for([b4_r1])[ yyr1_[];
|
||||||
/// For a rule, its RHS length.
|
/// For a rule, its RHS length.
|
||||||
static const ]b4_int_type_for([b4_r2])[ yyr2_[];
|
static const ]b4_int_type_for([b4_r2])[ yyr2_[]; ]b4_error_verbose_if([
|
||||||
|
|
||||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
|
||||||
/// For a symbol, its name in clear.
|
|
||||||
static const char* const yytname_[];
|
|
||||||
#endif]b4_error_verbose_if([
|
|
||||||
|
|
||||||
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
||||||
static std::string yytnamerr_ (const char *n);])[
|
static std::string yytnamerr_ (const char *n);])[
|
||||||
|
|
||||||
#if YYDEBUG
|
]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
|
||||||
|
/// For a symbol, its name in clear.
|
||||||
|
static const char* const yytname_[];
|
||||||
|
]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[
|
||||||
/// A type to store symbol numbers and -1.
|
/// A type to store symbol numbers and -1.
|
||||||
typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type;
|
typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type;
|
||||||
/// A `-1'-separated list of the rules' RHS.
|
/// A `-1'-separated list of the rules' RHS.
|
||||||
@@ -277,9 +257,9 @@ b4_user_stype
|
|||||||
]b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
]b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||||
[b4_token_defines(b4_tokens)
|
[b4_token_defines(b4_tokens)
|
||||||
|
|
||||||
#ifndef YYSTYPE
|
#ifndef ]b4_api_PREFIX[STYPE
|
||||||
/* Redirection for backward compatibility. */
|
/* Redirection for backward compatibility. */
|
||||||
# define YYSTYPE b4_namespace_ref::b4_parser_class_name::semantic_type
|
# define ]b4_api_PREFIX[STYPE b4_namespace_ref::b4_parser_class_name::semantic_type
|
||||||
#endif
|
#endif
|
||||||
])[
|
])[
|
||||||
]b4_percent_code_get([[provides]])[
|
]b4_percent_code_get([[provides]])[
|
||||||
@@ -295,16 +275,18 @@ 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_user_pre_prologue
|
]b4_user_pre_prologue[
|
||||||
|
|
||||||
b4_defines_if([[
|
]b4_defines_if([[
|
||||||
#include "@basename(]b4_spec_defines_file[@)"]])[
|
#include "@basename(]b4_spec_defines_file[@)"]])[
|
||||||
|
|
||||||
/* User implementation prologue. */
|
/* User implementation prologue. */
|
||||||
]b4_user_post_prologue
|
]b4_user_post_prologue[
|
||||||
b4_percent_code_get[]dnl
|
]b4_percent_code_get[
|
||||||
|
|
||||||
[#ifndef YY_
|
]b4_null_define[
|
||||||
|
|
||||||
|
#ifndef YY_
|
||||||
# if defined YYENABLE_NLS && YYENABLE_NLS
|
# if defined YYENABLE_NLS && YYENABLE_NLS
|
||||||
# if ENABLE_NLS
|
# if ENABLE_NLS
|
||||||
# include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
|
# include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
|
||||||
@@ -316,31 +298,14 @@ b4_percent_code_get[]dnl
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
|
||||||
If N is 0, then set CURRENT to the empty location which ends
|
|
||||||
the previous symbol: RHS[0] (always defined). */
|
|
||||||
|
|
||||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
||||||
#ifndef YYLLOC_DEFAULT
|
]b4_yylloc_default_define[
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
|
||||||
do \
|
|
||||||
if (N) \
|
|
||||||
{ \
|
|
||||||
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
|
||||||
(Current).end = YYRHSLOC (Rhs, N).end; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
|
||||||
} \
|
|
||||||
while (false)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Suppress unused-variable warnings by "using" E. */
|
/* Suppress unused-variable warnings by "using" E. */
|
||||||
#define YYUSE(e) ((void) (e))
|
#define YYUSE(e) ((void) (e))
|
||||||
|
|
||||||
/* Enable debugging if requested. */
|
/* Enable debugging if requested. */
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
|
|
||||||
/* A pseudo ostream that takes yydebug_ into account. */
|
/* A pseudo ostream that takes yydebug_ into account. */
|
||||||
# define YYCDEBUG if (yydebug_) (*yycdebug_)
|
# define YYCDEBUG if (yydebug_) (*yycdebug_)
|
||||||
@@ -367,14 +332,14 @@ do { \
|
|||||||
yystack_print_ (); \
|
yystack_print_ (); \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
#else /* !YYDEBUG */
|
#else /* !]b4_api_PREFIX[DEBUG */
|
||||||
|
|
||||||
# define YYCDEBUG if (false) std::cerr
|
# define YYCDEBUG if (false) std::cerr
|
||||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||||
# define YY_REDUCE_PRINT(Rule)
|
# define YY_REDUCE_PRINT(Rule)
|
||||||
# define YY_STACK_PRINT()
|
# define YY_STACK_PRINT()
|
||||||
|
|
||||||
#endif /* !YYDEBUG */
|
#endif /* !]b4_api_PREFIX[DEBUG */
|
||||||
|
|
||||||
#define yyerrok (yyerrstatus_ = 0)
|
#define yyerrok (yyerrstatus_ = 0)
|
||||||
#define yyclearin (yychar = yyempty_)
|
#define yyclearin (yychar = yyempty_)
|
||||||
@@ -427,7 +392,7 @@ do { \
|
|||||||
/// Build a parser object.
|
/// Build a parser object.
|
||||||
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
||||||
:])[
|
:])[
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),
|
]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),
|
||||||
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
||||||
#endif]b4_parse_param_cons[
|
#endif]b4_parse_param_cons[
|
||||||
@@ -438,7 +403,7 @@ do { \
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/*--------------------------------.
|
/*--------------------------------.
|
||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
`--------------------------------*/
|
`--------------------------------*/
|
||||||
@@ -499,7 +464,7 @@ do { \
|
|||||||
yylocation_stack_.pop (n);
|
yylocation_stack_.pop (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
std::ostream&
|
std::ostream&
|
||||||
]b4_parser_class_name[::debug_stream () const
|
]b4_parser_class_name[::debug_stream () const
|
||||||
{
|
{
|
||||||
@@ -571,12 +536,10 @@ do { \
|
|||||||
YYCDEBUG << "Starting parse" << std::endl;
|
YYCDEBUG << "Starting parse" << std::endl;
|
||||||
|
|
||||||
]m4_ifdef([b4_initial_action], [
|
]m4_ifdef([b4_initial_action], [
|
||||||
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
||||||
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
/* User initialization code. */
|
||||||
/* User initialization code. */
|
b4_user_initial_action
|
||||||
b4_user_initial_action
|
b4_dollar_popdef])[]dnl
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
|
||||||
m4_popdef([b4_at_dollar])])dnl
|
|
||||||
|
|
||||||
[ /* Initialize the stacks. The initial state will be pushed in
|
[ /* Initialize the stacks. The initial state will be pushed in
|
||||||
yynewstate, since the latter expects the semantical and the
|
yynewstate, since the latter expects the semantical and the
|
||||||
@@ -612,7 +575,7 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
{
|
{
|
||||||
YYCDEBUG << "Reading a token: ";
|
YYCDEBUG << "Reading a token: ";
|
||||||
yychar = ]b4_c_function_call([yylex], [int],
|
yychar = ]b4_c_function_call([yylex], [int],
|
||||||
[[YYSTYPE*], [&yylval]][]dnl
|
[b4_api_PREFIX[STYPE*], [&yylval]][]dnl
|
||||||
b4_locations_if([, [[location*], [&yylloc]]])dnl
|
b4_locations_if([, [[location*], [&yylloc]]])dnl
|
||||||
m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
|
m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
|
||||||
}
|
}
|
||||||
@@ -1027,7 +990,7 @@ b4_error_verbose_if([int yystate, int yytoken],
|
|||||||
]b4_stos[
|
]b4_stos[
|
||||||
};
|
};
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
||||||
to YYLEX-NUM. */
|
to YYLEX-NUM. */
|
||||||
const ]b4_int_type_for([b4_toknum])[
|
const ]b4_int_type_for([b4_toknum])[
|
||||||
@@ -1051,7 +1014,7 @@ b4_error_verbose_if([int yystate, int yytoken],
|
|||||||
]b4_r2[
|
]b4_r2[
|
||||||
};
|
};
|
||||||
|
|
||||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
|
||||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
||||||
const char*
|
const char*
|
||||||
@@ -1059,9 +1022,8 @@ b4_error_verbose_if([int yystate, int yytoken],
|
|||||||
{
|
{
|
||||||
]b4_tname[
|
]b4_tname[
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
#if YYDEBUG
|
]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[
|
||||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||||
const ]b4_parser_class_name[::rhs_number_type
|
const ]b4_parser_class_name[::rhs_number_type
|
||||||
]b4_parser_class_name[::yyrhs_[] =
|
]b4_parser_class_name[::yyrhs_[] =
|
||||||
@@ -1111,7 +1073,7 @@ b4_error_verbose_if([int yystate, int yytoken],
|
|||||||
&]b4_rhs_value(yynrhs, yyi + 1)[,
|
&]b4_rhs_value(yynrhs, yyi + 1)[,
|
||||||
&]b4_rhs_location(yynrhs, yyi + 1)[);
|
&]b4_rhs_location(yynrhs, yyi + 1)[);
|
||||||
}
|
}
|
||||||
#endif // YYDEBUG
|
#endif // ]b4_api_PREFIX[DEBUG
|
||||||
|
|
||||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||||
]b4_parser_class_name[::token_number_type
|
]b4_parser_class_name[::token_number_type
|
||||||
@@ -1142,5 +1104,5 @@ b4_error_verbose_if([int yystate, int yytoken],
|
|||||||
const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
|
const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
|
||||||
|
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
]b4_epilogue
|
]b4_epilogue[]dnl
|
||||||
m4_divert_pop(0)
|
m4_divert_pop(0)
|
||||||
|
|||||||
+4
-6
@@ -458,12 +458,10 @@ b4_lexer_if([[
|
|||||||
yyerrstatus_ = 0;
|
yyerrstatus_ = 0;
|
||||||
|
|
||||||
]m4_ifdef([b4_initial_action], [
|
]m4_ifdef([b4_initial_action], [
|
||||||
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
||||||
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
/* User initialization code. */
|
||||||
/* User initialization code. */
|
b4_user_initial_action
|
||||||
b4_user_initial_action
|
b4_dollar_popdef])[]dnl
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
|
||||||
m4_popdef([b4_at_dollar])])dnl
|
|
||||||
|
|
||||||
[ /* Initialize the stack. */
|
[ /* Initialize the stack. */
|
||||||
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||||
|
|||||||
+2
-2
@@ -29,9 +29,9 @@ b4_copyright([Positions for Bison parsers in C++],
|
|||||||
|
|
||||||
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
|
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
|
||||||
|
|
||||||
# include <iostream>
|
# include <algorithm> // std::max
|
||||||
|
# include <iosfwd>
|
||||||
# include <string>
|
# include <string>
|
||||||
# include <algorithm>
|
|
||||||
|
|
||||||
]b4_null_define[
|
]b4_null_define[
|
||||||
|
|
||||||
|
|||||||
+107
-188
@@ -158,9 +158,9 @@ m4_define([b4_rhs_location],
|
|||||||
[(yylsp@{($2) - ($1)@})])
|
[(yylsp@{($2) - ($1)@})])
|
||||||
|
|
||||||
|
|
||||||
## ------------------ ##
|
## -------------- ##
|
||||||
## Parser variables. ##
|
## Declarations. ##
|
||||||
## ------------------ ##
|
## -------------- ##
|
||||||
|
|
||||||
# b4_declare_scanner_communication_variables
|
# b4_declare_scanner_communication_variables
|
||||||
# ------------------------------------------
|
# ------------------------------------------
|
||||||
@@ -225,9 +225,73 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
|
|||||||
YYSIZE_T yyes_capacity;]])])
|
YYSIZE_T yyes_capacity;]])])
|
||||||
|
|
||||||
|
|
||||||
## --------------------------------------------------------- ##
|
# b4_declare_yyparse_push_
|
||||||
## Defining symbol actions, e.g., printers and destructors. ##
|
# ------------------------
|
||||||
## --------------------------------------------------------- ##
|
# Declaration of yyparse (and dependencies) when using the push parser
|
||||||
|
# (including in pull mode).
|
||||||
|
m4_define([b4_declare_yyparse_push_],
|
||||||
|
[[#ifndef YYPUSH_MORE_DEFINED
|
||||||
|
# define YYPUSH_MORE_DEFINED
|
||||||
|
enum { YYPUSH_MORE = 4 };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
|
||||||
|
|
||||||
|
]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
|
||||||
|
])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
|
||||||
|
[[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([,
|
||||||
|
[[[int pushed_char]], [[pushed_char]]],
|
||||||
|
[[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([,
|
||||||
|
[[b4_api_PREFIX[LTYPE const *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [,
|
||||||
|
b4_parse_param]))
|
||||||
|
b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
|
||||||
|
[[b4_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [,
|
||||||
|
b4_parse_param]))])
|
||||||
|
b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
|
||||||
|
[[[void]], []])
|
||||||
|
b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
|
||||||
|
[[b4_prefix[pstate *ps]], [[ps]]])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4_declare_yyparse_
|
||||||
|
# -------------------
|
||||||
|
# When not the push parser.
|
||||||
|
m4_define([b4_declare_yyparse_],
|
||||||
|
[[#ifdef YYPARSE_PARAM
|
||||||
|
]b4_c_function_decl(b4_prefix[parse], [int],
|
||||||
|
[[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
|
||||||
|
#else /* ! YYPARSE_PARAM */
|
||||||
|
]b4_c_function_decl(b4_prefix[parse], [int], b4_parse_param)[
|
||||||
|
#endif /* ! YYPARSE_PARAM */]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_declare_yyparse
|
||||||
|
# ------------------
|
||||||
|
m4_define([b4_declare_yyparse],
|
||||||
|
[b4_push_if([b4_declare_yyparse_push_],
|
||||||
|
[b4_declare_yyparse_])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# 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_cpp_guard_open([b4_spec_defines_file])[
|
||||||
|
]b4_declare_yydebug[
|
||||||
|
]b4_percent_code_get([[requires]])[
|
||||||
|
]b4_token_enums_defines(b4_tokens)[
|
||||||
|
]b4_declare_yylstype[
|
||||||
|
]b4_declare_yyparse[
|
||||||
|
]b4_percent_code_get([[provides]])[
|
||||||
|
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Output files. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
# We do want M4 expansion after # for CPP macros.
|
# We do want M4 expansion after # for CPP macros.
|
||||||
m4_changecom()
|
m4_changecom()
|
||||||
@@ -248,7 +312,11 @@ b4_copyright([Bison implementation for Yacc-like parsers in C],
|
|||||||
|
|
||||||
]b4_identification
|
]b4_identification
|
||||||
b4_percent_code_get([[top]])[]dnl
|
b4_percent_code_get([[top]])[]dnl
|
||||||
m4_if(b4_prefix, [yy], [],
|
m4_if(b4_api_prefix, [yy], [],
|
||||||
|
[[/* Substitute the type names. */
|
||||||
|
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
|
||||||
|
#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
|
||||||
|
]m4_if(b4_prefix, [yy], [],
|
||||||
[[/* Substitute the variable and function names. */]b4_pull_if([[
|
[[/* Substitute the variable and function names. */]b4_pull_if([[
|
||||||
#define yyparse ]b4_prefix[parse]])b4_push_if([[
|
#define yyparse ]b4_prefix[parse]])b4_push_if([[
|
||||||
#define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[
|
#define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[
|
||||||
@@ -261,19 +329,14 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
#define yylval ]b4_prefix[lval
|
#define yylval ]b4_prefix[lval
|
||||||
#define yychar ]b4_prefix[char
|
#define yychar ]b4_prefix[char
|
||||||
#define yydebug ]b4_prefix[debug
|
#define yydebug ]b4_prefix[debug
|
||||||
#define yynerrs ]b4_prefix[nerrs
|
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
|
||||||
]b4_locations_if([[#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_user_pre_prologue[
|
]b4_user_pre_prologue[
|
||||||
|
|
||||||
]b4_null_define[
|
]b4_null_define[
|
||||||
|
|
||||||
/* Enabling traces. */
|
|
||||||
#ifndef YYDEBUG
|
|
||||||
# define YYDEBUG ]b4_debug_flag[
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enabling verbose error messages. */
|
/* Enabling verbose error messages. */
|
||||||
#ifdef YYERROR_VERBOSE
|
#ifdef YYERROR_VERBOSE
|
||||||
# undef YYERROR_VERBOSE
|
# undef YYERROR_VERBOSE
|
||||||
@@ -282,66 +345,11 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
|
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enabling the token table. */
|
/* In a future release of Bison, this section will be replaced
|
||||||
#ifndef YYTOKEN_TABLE
|
by #include "@basename(]b4_spec_defines_file[@)". */
|
||||||
# define YYTOKEN_TABLE ]b4_token_table[
|
]b4_shared_declarations[
|
||||||
#endif
|
|
||||||
|
|
||||||
]b4_percent_code_get([[requires]])[]dnl
|
/* Copy the second part of user declarations. */
|
||||||
|
|
||||||
b4_token_enums_defines(b4_tokens)[
|
|
||||||
|
|
||||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
|
||||||
]m4_ifdef([b4_stype],
|
|
||||||
[[typedef union ]b4_union_name[
|
|
||||||
{
|
|
||||||
]b4_user_stype[
|
|
||||||
} YYSTYPE;
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1]],
|
|
||||||
[m4_if(b4_tag_seen_flag, 0,
|
|
||||||
[[typedef int YYSTYPE;
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1]])])[
|
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
|
||||||
#endif]b4_locations_if([[
|
|
||||||
|
|
||||||
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
|
||||||
typedef struct YYLTYPE
|
|
||||||
{
|
|
||||||
int first_line;
|
|
||||||
int first_column;
|
|
||||||
int last_line;
|
|
||||||
int last_column;
|
|
||||||
} YYLTYPE;
|
|
||||||
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
|
|
||||||
# define YYLTYPE_IS_DECLARED 1
|
|
||||||
# define YYLTYPE_IS_TRIVIAL 1
|
|
||||||
#endif]])b4_push_if([[
|
|
||||||
|
|
||||||
#ifndef YYPUSH_DECLS
|
|
||||||
# define YYPUSH_DECLS
|
|
||||||
struct yypstate;
|
|
||||||
typedef struct yypstate yypstate;
|
|
||||||
enum { YYPUSH_MORE = 4 };
|
|
||||||
|
|
||||||
]b4_pull_if([b4_c_function_decl([[yyparse]], [[int]], b4_parse_param)
|
|
||||||
])b4_c_function_decl([[yypush_parse]], [[int]],
|
|
||||||
[[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
|
|
||||||
[[[int yypushed_char]], [[yypushed_char]]],
|
|
||||||
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
|
|
||||||
[[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
|
|
||||||
b4_parse_param]))
|
|
||||||
b4_pull_if([b4_c_function_decl([[yypull_parse]], [[int]],
|
|
||||||
[[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
|
|
||||||
b4_parse_param]))])
|
|
||||||
b4_c_function_decl([[yypstate_new]], [[yypstate *]], [[[void]], []])
|
|
||||||
b4_c_function_decl([[yypstate_delete]], [[void]],
|
|
||||||
[[[yypstate *yyps]], [[yyps]]])[
|
|
||||||
#endif]])
|
|
||||||
|
|
||||||
b4_percent_code_get([[provides]])[]dnl
|
|
||||||
|
|
||||||
[/* Copy the second part of user declarations. */
|
|
||||||
]b4_user_post_prologue
|
]b4_user_post_prologue
|
||||||
b4_percent_code_get[]dnl
|
b4_percent_code_get[]dnl
|
||||||
|
|
||||||
@@ -491,8 +499,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
|
|||||||
|
|
||||||
#if (! defined yyoverflow \
|
#if (! defined yyoverflow \
|
||||||
&& (! defined __cplusplus \
|
&& (! defined __cplusplus \
|
||||||
|| (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
|
|| (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
|
||||||
&& ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
&& ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
|
||||||
|
|
||||||
/* A type that is properly aligned for any stack member. */
|
/* A type that is properly aligned for any stack member. */
|
||||||
union yyalloc
|
union yyalloc
|
||||||
@@ -582,7 +590,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
|||||||
]b4_translate[
|
]b4_translate[
|
||||||
};
|
};
|
||||||
|
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
||||||
YYRHS. */
|
YYRHS. */
|
||||||
static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
|
static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
|
||||||
@@ -603,7 +611,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
|
||||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||||
static const char *const yytname[] =
|
static const char *const yytname[] =
|
||||||
@@ -737,31 +745,9 @@ while (YYID (0))
|
|||||||
#define YYTERROR 1
|
#define YYTERROR 1
|
||||||
#define YYERRCODE 256
|
#define YYERRCODE 256
|
||||||
|
|
||||||
|
]b4_yylloc_default_define[
|
||||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
|
||||||
If N is 0, then set CURRENT to the empty location which ends
|
|
||||||
the previous symbol: RHS[0] (always defined). */
|
|
||||||
|
|
||||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
||||||
#ifndef YYLLOC_DEFAULT
|
]b4_locations_if([[
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
|
||||||
do \
|
|
||||||
if (YYID (N)) \
|
|
||||||
{ \
|
|
||||||
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
|
||||||
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
|
||||||
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
|
||||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
(Current).first_line = (Current).last_line = \
|
|
||||||
YYRHSLOC (Rhs, 0).last_line; \
|
|
||||||
(Current).first_column = (Current).last_column = \
|
|
||||||
YYRHSLOC (Rhs, 0).last_column; \
|
|
||||||
} \
|
|
||||||
while (YYID (0))
|
|
||||||
#endif]b4_locations_if([[
|
|
||||||
|
|
||||||
|
|
||||||
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
||||||
@@ -769,7 +755,7 @@ while (YYID (0))
|
|||||||
we won't break user code: when these are the locations we know. */
|
we won't break user code: when these are the locations we know. */
|
||||||
|
|
||||||
#ifndef YY_LOCATION_PRINT
|
#ifndef YY_LOCATION_PRINT
|
||||||
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||||
# define YY_LOCATION_PRINT(File, Loc) \
|
# define YY_LOCATION_PRINT(File, Loc) \
|
||||||
fprintf (File, "%d.%d-%d.%d", \
|
fprintf (File, "%d.%d-%d.%d", \
|
||||||
(Loc).first_line, (Loc).first_column, \
|
(Loc).first_line, (Loc).first_column, \
|
||||||
@@ -796,7 +782,7 @@ while (YYID (0))
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enable debugging if requested. */
|
/* Enable debugging if requested. */
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
|
|
||||||
# ifndef YYFPRINTF
|
# ifndef YYFPRINTF
|
||||||
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
|
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
@@ -883,12 +869,12 @@ do { \
|
|||||||
/* Nonzero means print parse trace. It is left uninitialized so that
|
/* Nonzero means print parse trace. It is left uninitialized so that
|
||||||
multiple parsers can coexist. */
|
multiple parsers can coexist. */
|
||||||
int yydebug;
|
int yydebug;
|
||||||
#else /* !YYDEBUG */
|
#else /* !]b4_api_PREFIX[DEBUG */
|
||||||
# define YYDPRINTF(Args)
|
# define YYDPRINTF(Args)
|
||||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||||
# define YY_STACK_PRINT(Bottom, Top)
|
# define YY_STACK_PRINT(Bottom, Top)
|
||||||
# define YY_REDUCE_PRINT(Rule)
|
# define YY_REDUCE_PRINT(Rule)
|
||||||
#endif /* !YYDEBUG */
|
#endif /* !]b4_api_PREFIX[DEBUG */
|
||||||
|
|
||||||
|
|
||||||
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
||||||
@@ -919,7 +905,7 @@ int yydebug;
|
|||||||
required. Return 1 if memory is exhausted. */
|
required. Return 1 if memory is exhausted. */
|
||||||
static int
|
static int
|
||||||
yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
|
yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
char const *yydebug_prefix,
|
char const *yydebug_prefix,
|
||||||
char const *yydebug_suffix,
|
char const *yydebug_suffix,
|
||||||
#endif
|
#endif
|
||||||
@@ -1025,7 +1011,7 @@ do { \
|
|||||||
the parser stacks to try to find a new initial context in which the
|
the parser stacks to try to find a new initial context in which the
|
||||||
current lookahead is syntactically acceptable. If it fails to find
|
current lookahead is syntactically acceptable. If it fails to find
|
||||||
such a context, it discards the lookahead. */
|
such a context, it discards the lookahead. */
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
# define YY_LAC_DISCARD(Event) \
|
# define YY_LAC_DISCARD(Event) \
|
||||||
do { \
|
do { \
|
||||||
if (yy_lac_established) \
|
if (yy_lac_established) \
|
||||||
@@ -1128,7 +1114,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (yy_lac_stack_realloc (yyes_capacity, 1,
|
if (yy_lac_stack_realloc (yyes_capacity, 1,
|
||||||
#if YYDEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
" (", ")",
|
" (", ")",
|
||||||
#endif
|
#endif
|
||||||
yyes, yyesa, &yyesp, yyes_prev))
|
yyes, yyesa, &yyesp, yyes_prev))
|
||||||
@@ -1335,7 +1321,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
|||||||
yysize = yysize1;
|
yysize = yysize1;
|
||||||
}
|
}
|
||||||
}]b4_lac_if([[
|
}]b4_lac_if([[
|
||||||
# if YYDEBUG
|
# if ]b4_api_PREFIX[DEBUG
|
||||||
else if (yydebug)
|
else if (yydebug)
|
||||||
YYFPRINTF (stderr, "No expected tokens.\n");
|
YYFPRINTF (stderr, "No expected tokens.\n");
|
||||||
# endif]])[
|
# endif]])[
|
||||||
@@ -1392,20 +1378,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
|||||||
}
|
}
|
||||||
#endif /* YYERROR_VERBOSE */
|
#endif /* YYERROR_VERBOSE */
|
||||||
|
|
||||||
]b4_yydestruct_generate([b4_c_function_def])b4_push_if([], [[
|
]b4_yydestruct_generate([b4_c_function_def])[
|
||||||
|
|
||||||
|
]b4_pure_if([], [
|
||||||
/* Prevent warnings from -Wmissing-prototypes. */
|
|
||||||
#ifdef YYPARSE_PARAM
|
|
||||||
]b4_c_function_decl([yyparse], [int],
|
|
||||||
[[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
|
|
||||||
#else /* ! YYPARSE_PARAM */
|
|
||||||
]b4_c_function_decl([yyparse], [int], b4_parse_param)[
|
|
||||||
#endif /* ! YYPARSE_PARAM */]])b4_pure_if([], [
|
|
||||||
|
|
||||||
b4_declare_scanner_communication_variables])[]b4_push_if([[
|
b4_declare_scanner_communication_variables])[]b4_push_if([[
|
||||||
|
|
||||||
|
|
||||||
struct yypstate
|
struct yypstate
|
||||||
{]b4_declare_parser_state_variables[
|
{]b4_declare_parser_state_variables[
|
||||||
/* Used to determine if this is the first time this instance has
|
/* Used to determine if this is the first time this instance has
|
||||||
@@ -1586,23 +1564,22 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
|
|||||||
yyvsp = yyvs;]b4_locations_if([[
|
yyvsp = yyvs;]b4_locations_if([[
|
||||||
yylsp = yyls;
|
yylsp = yyls;
|
||||||
|
|
||||||
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||||
/* Initialize the default location before parsing starts. */
|
/* Initialize the default location before parsing starts. */
|
||||||
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
|
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
|
||||||
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
|
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
|
||||||
#endif]])
|
#endif]])
|
||||||
m4_ifdef([b4_initial_action],[
|
m4_ifdef([b4_initial_action],[
|
||||||
m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl
|
b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [],
|
||||||
m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl
|
[m4_define([b4_at_dollar_used])yylloc])dnl
|
||||||
/* User initialization code. */
|
/* User initialization code. */
|
||||||
b4_user_initial_action
|
b4_user_initial_action
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
b4_dollar_popdef[]dnl
|
||||||
m4_popdef([b4_at_dollar])])dnl
|
|
||||||
m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
|
m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
|
||||||
]])dnl
|
]])dnl
|
||||||
m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
|
m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
|
||||||
]])[
|
]])])dnl
|
||||||
goto yysetstate;
|
[ goto yysetstate;
|
||||||
|
|
||||||
/*------------------------------------------------------------.
|
/*------------------------------------------------------------.
|
||||||
| yynewstate -- Push a new state, which is found in yystate. |
|
| yynewstate -- Push a new state, which is found in yystate. |
|
||||||
@@ -2068,70 +2045,12 @@ yypushreturn:]])[
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
]b4_epilogue
|
]b4_epilogue[]dnl
|
||||||
b4_defines_if(
|
b4_defines_if(
|
||||||
[@output(b4_spec_defines_file@)@
|
[@output(b4_spec_defines_file@)@
|
||||||
b4_copyright([Bison interface for Yacc-like parsers in C],
|
b4_copyright([Bison interface for Yacc-like parsers in C],
|
||||||
[1984, 1989-1990, 2000-2012])
|
[1984, 1989-1990, 2000-2012])[
|
||||||
|
|
||||||
b4_percent_code_get([[requires]])[]dnl
|
]b4_shared_declarations[
|
||||||
|
]])dnl b4_defines_if
|
||||||
b4_token_enums_defines(b4_tokens)
|
|
||||||
|
|
||||||
[#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
|
||||||
]m4_ifdef([b4_stype],
|
|
||||||
[[typedef union ]b4_union_name[
|
|
||||||
{
|
|
||||||
]b4_user_stype[
|
|
||||||
} YYSTYPE;
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1]],
|
|
||||||
[m4_if(b4_tag_seen_flag, 0,
|
|
||||||
[[typedef int YYSTYPE;
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1]])])[
|
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;]])
|
|
||||||
|
|
||||||
b4_locations_if(
|
|
||||||
[#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
|
||||||
typedef struct YYLTYPE
|
|
||||||
{
|
|
||||||
int first_line;
|
|
||||||
int first_column;
|
|
||||||
int last_line;
|
|
||||||
int last_column;
|
|
||||||
} YYLTYPE;
|
|
||||||
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
|
|
||||||
# define YYLTYPE_IS_DECLARED 1
|
|
||||||
# define YYLTYPE_IS_TRIVIAL 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
]b4_pure_if([], [[extern YYLTYPE ]b4_prefix[lloc;]])
|
|
||||||
)dnl b4_locations_if
|
|
||||||
b4_push_if([[
|
|
||||||
#ifndef YYPUSH_DECLS
|
|
||||||
# define YYPUSH_DECLS
|
|
||||||
struct ]b4_prefix[pstate;
|
|
||||||
typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
|
|
||||||
enum { YYPUSH_MORE = 4 };
|
|
||||||
]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
|
|
||||||
])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
|
|
||||||
[[b4_prefix[pstate *yyps]], [[yyps]]]b4_pure_if([,
|
|
||||||
[[[int yypushed_char]], [[yypushed_char]]],
|
|
||||||
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
|
|
||||||
[[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
|
|
||||||
b4_parse_param]))
|
|
||||||
b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
|
|
||||||
[[b4_prefix[pstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
|
|
||||||
b4_parse_param]))])
|
|
||||||
b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
|
|
||||||
[[[void]], []])
|
|
||||||
b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
|
|
||||||
[[b4_prefix[pstate *yyps]], [[yyps]]])[
|
|
||||||
#endif
|
|
||||||
]])
|
|
||||||
b4_percent_code_get([[provides]])[]dnl
|
|
||||||
])dnl b4_defines_if
|
|
||||||
m4_divert_pop(0)
|
m4_divert_pop(0)
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
AM_MAKEINFOFLAGS = --no-split
|
AM_MAKEINFOFLAGS = --no-split
|
||||||
info_TEXINFOS = bison.texinfo
|
info_TEXINFOS = bison.texi
|
||||||
bison_TEXINFOS = $(srcdir)/cross-options.texi gpl-3.0.texi fdl.texi
|
bison_TEXINFOS = $(srcdir)/cross-options.texi gpl-3.0.texi fdl.texi
|
||||||
|
|
||||||
CLEANFILES = bison.fns
|
CLEANFILES = bison.fns
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ Reference sections:
|
|||||||
* Glossary:: Basic concepts are explained.
|
* Glossary:: Basic concepts are explained.
|
||||||
* Copying This Manual:: License for copying this manual.
|
* Copying This Manual:: License for copying this manual.
|
||||||
* Bibliography:: Publications cited in this manual.
|
* Bibliography:: Publications cited in this manual.
|
||||||
* Index:: Cross-references to the text.
|
* Index of Terms:: Cross-references to the text.
|
||||||
|
|
||||||
@detailmenu
|
@detailmenu
|
||||||
--- The Detailed Node Listing ---
|
--- The Detailed Node Listing ---
|
||||||
@@ -4552,9 +4552,9 @@ code.
|
|||||||
@deffn {Directive} %initial-action @{ @var{code} @}
|
@deffn {Directive} %initial-action @{ @var{code} @}
|
||||||
@findex %initial-action
|
@findex %initial-action
|
||||||
Declare that the braced @var{code} must be invoked before parsing each time
|
Declare that the braced @var{code} must be invoked before parsing each time
|
||||||
@code{yyparse} is called. The @var{code} may use @code{$$} and
|
@code{yyparse} is called. The @var{code} may use @code{$$} (or
|
||||||
@code{@@$} --- initial value and location of the lookahead --- and the
|
@code{$<@var{tag}>$}) and @code{@@$} --- initial value and location of the
|
||||||
@code{%parse-param}.
|
lookahead --- and the @code{%parse-param}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
For instance, if your locations use a file name, you may use
|
For instance, if your locations use a file name, you may use
|
||||||
@@ -4592,11 +4592,11 @@ symbol is automatically discarded.
|
|||||||
@deffn {Directive} %destructor @{ @var{code} @} @var{symbols}
|
@deffn {Directive} %destructor @{ @var{code} @} @var{symbols}
|
||||||
@findex %destructor
|
@findex %destructor
|
||||||
Invoke the braced @var{code} whenever the parser discards one of the
|
Invoke the braced @var{code} whenever the parser discards one of the
|
||||||
@var{symbols}.
|
@var{symbols}. Within @var{code}, @code{$$} (or @code{$<@var{tag}>$})
|
||||||
Within @var{code}, @code{$$} designates the semantic value associated
|
designates the semantic value associated with the discarded symbol, and
|
||||||
with the discarded symbol, and @code{@@$} designates its location.
|
@code{@@$} designates its location. The additional parser parameters are
|
||||||
The additional parser parameters are also available (@pxref{Parser Function, ,
|
also available (@pxref{Parser Function, , The Parser Function
|
||||||
The Parser Function @code{yyparse}}).
|
@code{yyparse}}).
|
||||||
|
|
||||||
When a symbol is listed among @var{symbols}, its @code{%destructor} is called a
|
When a symbol is listed among @var{symbols}, its @code{%destructor} is called a
|
||||||
per-symbol @code{%destructor}.
|
per-symbol @code{%destructor}.
|
||||||
@@ -4734,10 +4734,11 @@ Decl, , Freeing Discarded Symbols}).
|
|||||||
@c This is the same text as for %destructor.
|
@c This is the same text as for %destructor.
|
||||||
Invoke the braced @var{code} whenever the parser displays one of the
|
Invoke the braced @var{code} whenever the parser displays one of the
|
||||||
@var{symbols}. Within @var{code}, @code{yyoutput} denotes the output stream
|
@var{symbols}. Within @var{code}, @code{yyoutput} denotes the output stream
|
||||||
(a @code{FILE*} in C, and an @code{std::ostream&} in C++),
|
(a @code{FILE*} in C, and an @code{std::ostream&} in C++), @code{$$} (or
|
||||||
@code{$$} designates the semantic value associated with the symbol, and
|
@code{$<@var{tag}>$}) designates the semantic value associated with the
|
||||||
@code{@@$} its location. The additional parser parameters are also
|
symbol, and @code{@@$} its location. The additional parser parameters are
|
||||||
available (@pxref{Parser Function, , The Parser Function @code{yyparse}}).
|
also available (@pxref{Parser Function, , The Parser Function
|
||||||
|
@code{yyparse}}).
|
||||||
|
|
||||||
The @var{symbols} are defined as for @code{%destructor} (@pxref{Destructor
|
The @var{symbols} are defined as for @code{%destructor} (@pxref{Destructor
|
||||||
Decl, , Freeing Discarded Symbols}.): they can be per-type (e.g.,
|
Decl, , Freeing Discarded Symbols}.): they can be per-type (e.g.,
|
||||||
@@ -5074,9 +5075,11 @@ default location or at the location specified by @var{qualifier}.
|
|||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %debug
|
@deffn {Directive} %debug
|
||||||
In the parser implementation file, define the macro @code{YYDEBUG} to
|
In the parser implementation file, define the macro @code{YYDEBUG} (or
|
||||||
1 if it is not already defined, so that the debugging facilities are
|
@code{@var{prefix}DEBUG} with @samp{%define api.prefix @var{prefix}}), see
|
||||||
compiled. @xref{Tracing, ,Tracing Your Parser}.
|
@ref{Multiple Parsers, ,Multiple Parsers in the Same Program}) to 1 if it is
|
||||||
|
not already defined, so that the debugging facilities are compiled.
|
||||||
|
@xref{Tracing, ,Tracing Your Parser}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %define @var{variable}
|
@deffn {Directive} %define @var{variable}
|
||||||
@@ -5154,22 +5157,6 @@ grammar does not use it, using @samp{%locations} allows for more
|
|||||||
accurate syntax error messages.
|
accurate syntax error messages.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %name-prefix "@var{prefix}"
|
|
||||||
Rename the external symbols used in the parser so that they start with
|
|
||||||
@var{prefix} instead of @samp{yy}. The precise list of symbols renamed
|
|
||||||
in C parsers
|
|
||||||
is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
|
|
||||||
@code{yylval}, @code{yychar}, @code{yydebug}, and
|
|
||||||
(if locations are used) @code{yylloc}. If you use a push parser,
|
|
||||||
@code{yypush_parse}, @code{yypull_parse}, @code{yypstate},
|
|
||||||
@code{yypstate_new} and @code{yypstate_delete} will
|
|
||||||
also be renamed. For example, if you use @samp{%name-prefix "c_"}, the
|
|
||||||
names become @code{c_parse}, @code{c_lex}, and so on.
|
|
||||||
For C++ parsers, see the @code{%define namespace} documentation in this
|
|
||||||
section.
|
|
||||||
@xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
|
|
||||||
@end deffn
|
|
||||||
|
|
||||||
@ifset defaultprec
|
@ifset defaultprec
|
||||||
@deffn {Directive} %no-default-prec
|
@deffn {Directive} %no-default-prec
|
||||||
Do not assign a precedence to rules lacking an explicit @code{%prec}
|
Do not assign a precedence to rules lacking an explicit @code{%prec}
|
||||||
@@ -5317,8 +5304,25 @@ Unaccepted @var{variable}s produce an error.
|
|||||||
Some of the accepted @var{variable}s are:
|
Some of the accepted @var{variable}s are:
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
|
@c ================================================== api.prefix
|
||||||
|
@item @code{api.prefix}
|
||||||
|
@findex %define api.prefix
|
||||||
|
|
||||||
|
@itemize @bullet
|
||||||
|
@item Language(s): All
|
||||||
|
|
||||||
|
@item Purpose: Rename exported symbols
|
||||||
|
@xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
|
||||||
|
|
||||||
|
@item Accepted Values: String
|
||||||
|
|
||||||
|
@item Default Value: @code{yy}
|
||||||
|
|
||||||
|
@item History: introduced in Bison 2.6
|
||||||
|
@end itemize
|
||||||
|
|
||||||
@c ================================================== api.pure
|
@c ================================================== api.pure
|
||||||
@item api.pure
|
@item @code{api.pure}
|
||||||
@findex %define api.pure
|
@findex %define api.pure
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@@ -5332,7 +5336,9 @@ Some of the accepted @var{variable}s are:
|
|||||||
@item Default Value: @code{false}
|
@item Default Value: @code{false}
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
@item api.push-pull
|
@c ================================================== api.push-pull
|
||||||
|
|
||||||
|
@item @code{api.push-pull}
|
||||||
@findex %define api.push-pull
|
@findex %define api.push-pull
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@@ -5350,7 +5356,7 @@ More user feedback will help to stabilize it.)
|
|||||||
|
|
||||||
@c ================================================== lr.default-reductions
|
@c ================================================== lr.default-reductions
|
||||||
|
|
||||||
@item lr.default-reductions
|
@item @code{lr.default-reductions}
|
||||||
@findex %define lr.default-reductions
|
@findex %define lr.default-reductions
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@@ -5371,7 +5377,7 @@ feedback will help to stabilize it.)
|
|||||||
|
|
||||||
@c ============================================ lr.keep-unreachable-states
|
@c ============================================ lr.keep-unreachable-states
|
||||||
|
|
||||||
@item lr.keep-unreachable-states
|
@item @code{lr.keep-unreachable-states}
|
||||||
@findex %define lr.keep-unreachable-states
|
@findex %define lr.keep-unreachable-states
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@@ -5384,7 +5390,7 @@ remain in the parser tables. @xref{Unreachable States}.
|
|||||||
|
|
||||||
@c ================================================== lr.type
|
@c ================================================== lr.type
|
||||||
|
|
||||||
@item lr.type
|
@item @code{lr.type}
|
||||||
@findex %define lr.type
|
@findex %define lr.type
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@@ -5399,7 +5405,9 @@ More user feedback will help to stabilize it.)
|
|||||||
@item Default Value: @code{lalr}
|
@item Default Value: @code{lalr}
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
@item namespace
|
@c ================================================== namespace
|
||||||
|
|
||||||
|
@item @code{namespace}
|
||||||
@findex %define namespace
|
@findex %define namespace
|
||||||
|
|
||||||
@itemize
|
@itemize
|
||||||
@@ -5452,7 +5460,7 @@ The parser namespace is @code{foo} and @code{yylex} is referenced as
|
|||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
@c ================================================== parse.lac
|
@c ================================================== parse.lac
|
||||||
@item parse.lac
|
@item @code{parse.lac}
|
||||||
@findex %define parse.lac
|
@findex %define parse.lac
|
||||||
|
|
||||||
@itemize
|
@itemize
|
||||||
@@ -5585,34 +5593,88 @@ of the standard Bison skeletons.
|
|||||||
@section Multiple Parsers in the Same Program
|
@section Multiple Parsers in the Same Program
|
||||||
|
|
||||||
Most programs that use Bison parse only one language and therefore contain
|
Most programs that use Bison parse only one language and therefore contain
|
||||||
only one Bison parser. But what if you want to parse more than one
|
only one Bison parser. But what if you want to parse more than one language
|
||||||
language with the same program? Then you need to avoid a name conflict
|
with the same program? Then you need to avoid name conflicts between
|
||||||
between different definitions of @code{yyparse}, @code{yylval}, and so on.
|
different definitions of functions and variables such as @code{yyparse},
|
||||||
|
@code{yylval}. To use different parsers from the same compilation unit, you
|
||||||
|
also need to avoid conflicts on types and macros (e.g., @code{YYSTYPE})
|
||||||
|
exported in the generated header.
|
||||||
|
|
||||||
The easy way to do this is to use the option @samp{-p @var{prefix}}
|
The easy way to do this is to define the @code{%define} variable
|
||||||
(@pxref{Invocation, ,Invoking Bison}). This renames the interface
|
@code{api.prefix}. With different @code{api.prefix}s it is guaranteed that
|
||||||
functions and variables of the Bison parser to start with @var{prefix}
|
headers do not conflict when included together, and that compiled objects
|
||||||
instead of @samp{yy}. You can use this to give each parser distinct
|
can be linked together too. Specifying @samp{%define api.prefix
|
||||||
names that do not conflict.
|
@var{prefix}} (or passing the option @samp{-Dapi.prefix=@var{prefix}}, see
|
||||||
|
@ref{Invocation, ,Invoking Bison}) renames the interface functions and
|
||||||
|
variables of the Bison parser to start with @var{prefix} instead of
|
||||||
|
@samp{yy}, and all the macros to start by @var{PREFIX} (i.e., @var{prefix}
|
||||||
|
upper-cased) instead of @samp{YY}.
|
||||||
|
|
||||||
The precise list of symbols renamed is @code{yyparse}, @code{yylex},
|
The renamed symbols include @code{yyparse}, @code{yylex}, @code{yyerror},
|
||||||
@code{yyerror}, @code{yynerrs}, @code{yylval}, @code{yylloc},
|
@code{yynerrs}, @code{yylval}, @code{yylloc}, @code{yychar} and
|
||||||
@code{yychar} and @code{yydebug}. If you use a push parser,
|
@code{yydebug}. If you use a push parser, @code{yypush_parse},
|
||||||
@code{yypush_parse}, @code{yypull_parse}, @code{yypstate},
|
@code{yypull_parse}, @code{yypstate}, @code{yypstate_new} and
|
||||||
@code{yypstate_new} and @code{yypstate_delete} will also be renamed.
|
@code{yypstate_delete} will also be renamed. The renamed macros include
|
||||||
For example, if you use @samp{-p c}, the names become @code{cparse},
|
@code{YYSTYPE}, @code{YYLTYPE}, and @code{YYDEBUG}, which is treated
|
||||||
@code{clex}, and so on.
|
specifically --- more about this below.
|
||||||
|
|
||||||
@strong{All the other variables and macros associated with Bison are not
|
For example, if you use @samp{%define api.prefix c}, the names become
|
||||||
renamed.} These others are not global; there is no conflict if the same
|
@code{cparse}, @code{clex}, @dots{}, @code{CSTYPE}, @code{CLTYPE}, and so
|
||||||
name is used in different parsers. For example, @code{YYSTYPE} is not
|
on.
|
||||||
renamed, but defining this in different ways in different parsers causes
|
|
||||||
no trouble (@pxref{Value Type, ,Data Types of Semantic Values}).
|
|
||||||
|
|
||||||
The @samp{-p} option works by adding macro definitions to the
|
The @code{%define} variable @code{api.prefix} works in two different ways.
|
||||||
beginning of the parser implementation file, defining @code{yyparse}
|
In the implementation file, it works by adding macro definitions to the
|
||||||
as @code{@var{prefix}parse}, and so on. This effectively substitutes
|
beginning of the parser implementation file, defining @code{yyparse} as
|
||||||
one name for the other in the entire parser implementation file.
|
@code{@var{prefix}parse}, and so on:
|
||||||
|
|
||||||
|
@example
|
||||||
|
#define YYSTYPE CTYPE
|
||||||
|
#define yyparse cparse
|
||||||
|
#define yylval clval
|
||||||
|
...
|
||||||
|
YYSTYPE yylval;
|
||||||
|
int yyparse (void);
|
||||||
|
@end example
|
||||||
|
|
||||||
|
This effectively substitutes one name for the other in the entire parser
|
||||||
|
implementation file, thus the ``original'' names (@code{yylex},
|
||||||
|
@code{YYSTYPE}, @dots{}) are also usable in the parser implementation file.
|
||||||
|
|
||||||
|
However, in the parser header file, the symbols are defined renamed, for
|
||||||
|
instance:
|
||||||
|
|
||||||
|
@example
|
||||||
|
extern CSTYPE clval;
|
||||||
|
int cparse (void);
|
||||||
|
@end example
|
||||||
|
|
||||||
|
The macro @code{YYDEBUG} is commonly used to enable the tracing support in
|
||||||
|
parsers. To comply with this tradition, when @code{api.prefix} is used,
|
||||||
|
@code{YYDEBUG} (not renamed) is used as a default value:
|
||||||
|
|
||||||
|
@example
|
||||||
|
/* Enabling traces. */
|
||||||
|
#ifndef CDEBUG
|
||||||
|
# if defined YYDEBUG
|
||||||
|
# if YYDEBUG
|
||||||
|
# define CDEBUG 1
|
||||||
|
# else
|
||||||
|
# define CDEBUG 0
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define CDEBUG 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if CDEBUG
|
||||||
|
extern int cdebug;
|
||||||
|
#endif
|
||||||
|
@end example
|
||||||
|
|
||||||
|
@sp 2
|
||||||
|
|
||||||
|
Prior to Bison 2.6, a feature similar to @code{api.prefix} was provided by
|
||||||
|
the obsolete directive @code{%name-prefix} (@pxref{Table of Symbols, ,Bison
|
||||||
|
Symbols}) and the option @code{--name-prefix} (@pxref{Bison Options}).
|
||||||
|
|
||||||
@node Interface
|
@node Interface
|
||||||
@chapter Parser C-Language Interface
|
@chapter Parser C-Language Interface
|
||||||
@@ -5729,9 +5791,9 @@ function is available if either the @code{%define api.push-pull push} or
|
|||||||
@xref{Push Decl, ,A Push Parser}.
|
@xref{Push Decl, ,A Push Parser}.
|
||||||
|
|
||||||
@deftypefun int yypush_parse (yypstate *yyps)
|
@deftypefun int yypush_parse (yypstate *yyps)
|
||||||
The value returned by @code{yypush_parse} is the same as for yyparse with the
|
The value returned by @code{yypush_parse} is the same as for yyparse with
|
||||||
following exception. @code{yypush_parse} will return YYPUSH_MORE if more input
|
the following exception: it returns @code{YYPUSH_MORE} if more input is
|
||||||
is required to finish parsing the grammar.
|
required to finish parsing the grammar.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
@node Pull Parser Function
|
@node Pull Parser Function
|
||||||
@@ -6011,7 +6073,7 @@ For instance:
|
|||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
results in the following signature:
|
results in the following signatures:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
int yylex (int *nastiness);
|
int yylex (int *nastiness);
|
||||||
@@ -8437,18 +8499,24 @@ parser. This is compliant with POSIX Yacc. You could use
|
|||||||
YYDEBUG 1} in the prologue of the grammar file (@pxref{Prologue, , The
|
YYDEBUG 1} in the prologue of the grammar file (@pxref{Prologue, , The
|
||||||
Prologue}).
|
Prologue}).
|
||||||
|
|
||||||
@item the option @option{-t}, @option{--debug}
|
If the @code{%define} variable @code{api.prefix} is used (@pxref{Multiple
|
||||||
Use the @samp{-t} option when you run Bison (@pxref{Invocation,
|
Parsers, ,Multiple Parsers in the Same Program}), for instance @samp{%define
|
||||||
,Invoking Bison}). This is POSIX compliant too.
|
api.prefix x}, then if @code{CDEBUG} is defined, its value controls the
|
||||||
|
tracing feature (enabled iff nonzero); otherwise tracing is enabled iff
|
||||||
|
@code{YYDEBUG} is nonzero.
|
||||||
|
|
||||||
|
@item the option @option{-t} (POSIX Yacc compliant)
|
||||||
|
@itemx the option @option{--debug} (Bison extension)
|
||||||
|
Use the @samp{-t} option when you run Bison (@pxref{Invocation, ,Invoking
|
||||||
|
Bison}). With @samp{%define api.prefix c}, it defines @code{CDEBUG} to 1,
|
||||||
|
otherwise it defines @code{YYDEBUG} to 1.
|
||||||
|
|
||||||
@item the directive @samp{%debug}
|
@item the directive @samp{%debug}
|
||||||
@findex %debug
|
@findex %debug
|
||||||
Add the @code{%debug} directive (@pxref{Decl Summary, ,Bison
|
Add the @code{%debug} directive (@pxref{Decl Summary, ,Bison Declaration
|
||||||
Declaration Summary}). This is a Bison extension, which will prove
|
Summary}). This is a Bison extension, especially useful for languages that
|
||||||
useful when Bison will output parsers for languages that don't use a
|
don't use a preprocessor. Unless POSIX and Yacc portability matter to you,
|
||||||
preprocessor. Unless POSIX and Yacc portability matter to
|
this is the preferred solution.
|
||||||
you, this is
|
|
||||||
the preferred solution.
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
We suggest that you always enable the debug option so that debugging is
|
We suggest that you always enable the debug option so that debugging is
|
||||||
@@ -8924,8 +8992,9 @@ Pretend that @code{%locations} was specified. @xref{Decl Summary}.
|
|||||||
|
|
||||||
@item -p @var{prefix}
|
@item -p @var{prefix}
|
||||||
@itemx --name-prefix=@var{prefix}
|
@itemx --name-prefix=@var{prefix}
|
||||||
Pretend that @code{%name-prefix "@var{prefix}"} was specified.
|
Pretend that @code{%name-prefix "@var{prefix}"} was specified (@pxref{Decl
|
||||||
@xref{Decl Summary}.
|
Summary}). Obsoleted by @code{-Dapi.prefix=@var{prefix}}. @xref{Multiple
|
||||||
|
Parsers, ,Multiple Parsers in the Same Program}.
|
||||||
|
|
||||||
@item -l
|
@item -l
|
||||||
@itemx --no-lines
|
@itemx --no-lines
|
||||||
@@ -11054,9 +11123,24 @@ function is applied to the two semantic values to get a single result.
|
|||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %name-prefix "@var{prefix}"
|
@deffn {Directive} %name-prefix "@var{prefix}"
|
||||||
Bison declaration to rename the external symbols. @xref{Decl Summary}.
|
Obsoleted by the @code{%define} variable @code{api.prefix} (@pxref{Multiple
|
||||||
|
Parsers, ,Multiple Parsers in the Same Program}).
|
||||||
|
|
||||||
|
Rename the external symbols (variables and functions) used in the parser so
|
||||||
|
that they start with @var{prefix} instead of @samp{yy}. Contrary to
|
||||||
|
@code{api.prefix}, do no rename types and macros.
|
||||||
|
|
||||||
|
The precise list of symbols renamed in C parsers is @code{yyparse},
|
||||||
|
@code{yylex}, @code{yyerror}, @code{yynerrs}, @code{yylval}, @code{yychar},
|
||||||
|
@code{yydebug}, and (if locations are used) @code{yylloc}. If you use a
|
||||||
|
push parser, @code{yypush_parse}, @code{yypull_parse}, @code{yypstate},
|
||||||
|
@code{yypstate_new} and @code{yypstate_delete} will also be renamed. For
|
||||||
|
example, if you use @samp{%name-prefix "c_"}, the names become
|
||||||
|
@code{c_parse}, @code{c_lex}, and so on. For C++ parsers, see the
|
||||||
|
@code{%define namespace} documentation in this section.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
|
||||||
@ifset defaultprec
|
@ifset defaultprec
|
||||||
@deffn {Directive} %no-default-prec
|
@deffn {Directive} %no-default-prec
|
||||||
Do not assign a precedence to rules that lack an explicit @samp{%prec}
|
Do not assign a precedence to rules that lack an explicit @samp{%prec}
|
||||||
@@ -11216,7 +11300,8 @@ Reporting Function @code{yyerror}}.
|
|||||||
An obsolete macro that you define with @code{#define} in the prologue
|
An obsolete macro that you define with @code{#define} in the prologue
|
||||||
to request verbose, specific error message strings
|
to request verbose, specific error message strings
|
||||||
when @code{yyerror} is called. It doesn't matter what definition you
|
when @code{yyerror} is called. It doesn't matter what definition you
|
||||||
use for @code{YYERROR_VERBOSE}, just whether you define it. Using
|
use for @code{YYERROR_VERBOSE}, just whether you define it.
|
||||||
|
Supported by the C skeletons only; using
|
||||||
@code{%error-verbose} is preferred. @xref{Error Reporting}.
|
@code{%error-verbose} is preferred. @xref{Error Reporting}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@@ -11620,8 +11705,8 @@ London, Department of Computer Science, TR-00-12 (December 2000).
|
|||||||
@uref{http://www.cs.rhul.ac.uk/research/languages/publications/tomita_style_1.ps}
|
@uref{http://www.cs.rhul.ac.uk/research/languages/publications/tomita_style_1.ps}
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@node Index
|
@node Index of Terms
|
||||||
@unnumbered Index
|
@unnumbered Index of Terms
|
||||||
|
|
||||||
@printindex cp
|
@printindex cp
|
||||||
|
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
A directory of tools provided to people using CVS Bison. None of
|
|
||||||
these is distributed.
|
|
||||||
|
|
||||||
* bench.pl
|
* bench.pl
|
||||||
A primitive Perl script to run benches. Currently its only bench is
|
A primitive Perl script to run benches. Currently its only bench is
|
||||||
the usual calculator: it has a lightweight processing part (but not
|
the usual calculator: it has a lightweight processing part (but not
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ $(BISON): $(BISON_IN)
|
|||||||
## Extracting. ##
|
## Extracting. ##
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
|
|
||||||
doc = $(top_srcdir)/doc/bison.texinfo
|
doc = $(top_srcdir)/doc/bison.texi
|
||||||
extexi = $(top_srcdir)/examples/extexi
|
extexi = $(top_srcdir)/examples/extexi
|
||||||
# Extract in src.
|
# Extract in src.
|
||||||
$(srcdir)/calc.stamp: $(doc) $(extexi)
|
$(srcdir)/calc.stamp: $(doc) $(extexi)
|
||||||
@@ -36,7 +36,7 @@ $(srcdir)/calc.stamp: $(doc) $(extexi)
|
|||||||
$(AM_V_at)touch $@.tmp
|
$(AM_V_at)touch $@.tmp
|
||||||
$(AM_V_at)cd $(srcdir) && \
|
$(AM_V_at)cd $(srcdir) && \
|
||||||
$(AWK) -f ../extexi -v VERSION="$(VERSION)" \
|
$(AWK) -f ../extexi -v VERSION="$(VERSION)" \
|
||||||
../../doc/bison.texinfo -- calc++-parser.yy \
|
../../doc/bison.texi -- calc++-parser.yy \
|
||||||
calc++-scanner.ll calc++.cc calc++-driver.hh calc++-driver.cc
|
calc++-scanner.ll calc++.cc calc++-driver.hh calc++-driver.cc
|
||||||
$(AM_V_at)mv $@.tmp $@
|
$(AM_V_at)mv $@.tmp $@
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule gnulib updated: 338dd5d436...bd54a45e6e
@@ -268,3 +268,4 @@
|
|||||||
/xmemdup0.c
|
/xmemdup0.c
|
||||||
/xmemdup0.h
|
/xmemdup0.h
|
||||||
/sys_types.in.h
|
/sys_types.in.h
|
||||||
|
/obstack_printf.c
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
/lock.c
|
||||||
|
/lock.h
|
||||||
|
/threadlib.c
|
||||||
+4
-2
@@ -34,6 +34,7 @@
|
|||||||
/fprintf-posix.m4
|
/fprintf-posix.m4
|
||||||
/frexp.m4
|
/frexp.m4
|
||||||
/frexpl.m4
|
/frexpl.m4
|
||||||
|
/fseterr.m4
|
||||||
/fstat.m4
|
/fstat.m4
|
||||||
/getdtablesize.m4
|
/getdtablesize.m4
|
||||||
/getopt.m4
|
/getopt.m4
|
||||||
@@ -95,6 +96,7 @@
|
|||||||
/multiarch.m4
|
/multiarch.m4
|
||||||
/nls.m4
|
/nls.m4
|
||||||
/nocrash.m4
|
/nocrash.m4
|
||||||
|
/off_t.m4
|
||||||
/open.m4
|
/open.m4
|
||||||
/pathmax.m4
|
/pathmax.m4
|
||||||
/perror.m4
|
/perror.m4
|
||||||
@@ -150,6 +152,7 @@
|
|||||||
/sys_ioctl_h.m4
|
/sys_ioctl_h.m4
|
||||||
/sys_socket_h.m4
|
/sys_socket_h.m4
|
||||||
/sys_stat_h.m4
|
/sys_stat_h.m4
|
||||||
|
/sys_types_h.m4
|
||||||
/sys_wait_h.m4
|
/sys_wait_h.m4
|
||||||
/sysexits.m4
|
/sysexits.m4
|
||||||
/threadlib.m4
|
/threadlib.m4
|
||||||
@@ -176,5 +179,4 @@
|
|||||||
/xalloc.m4
|
/xalloc.m4
|
||||||
/xsize.m4
|
/xsize.m4
|
||||||
/xstrndup.m4
|
/xstrndup.m4
|
||||||
/off_t.m4
|
/obstack-printf.m4
|
||||||
/sys_types_h.m4
|
|
||||||
|
|||||||
+16
-16
@@ -73,7 +73,7 @@ log_resolution (rule *r, symbol_number token,
|
|||||||
{
|
{
|
||||||
case shift_resolution:
|
case shift_resolution:
|
||||||
case right_resolution:
|
case right_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
obstack_printf (&solved_conflicts_obstack,
|
||||||
_(" Conflict between rule %d and token %s"
|
_(" Conflict between rule %d and token %s"
|
||||||
" resolved as shift"),
|
" resolved as shift"),
|
||||||
r->number,
|
r->number,
|
||||||
@@ -82,7 +82,7 @@ log_resolution (rule *r, symbol_number token,
|
|||||||
|
|
||||||
case reduce_resolution:
|
case reduce_resolution:
|
||||||
case left_resolution:
|
case left_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
obstack_printf (&solved_conflicts_obstack,
|
||||||
_(" Conflict between rule %d and token %s"
|
_(" Conflict between rule %d and token %s"
|
||||||
" resolved as reduce"),
|
" resolved as reduce"),
|
||||||
r->number,
|
r->number,
|
||||||
@@ -90,7 +90,7 @@ log_resolution (rule *r, symbol_number token,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case nonassoc_resolution:
|
case nonassoc_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
obstack_printf (&solved_conflicts_obstack,
|
||||||
_(" Conflict between rule %d and token %s"
|
_(" Conflict between rule %d and token %s"
|
||||||
" resolved as an error"),
|
" resolved as an error"),
|
||||||
r->number,
|
r->number,
|
||||||
@@ -102,33 +102,33 @@ log_resolution (rule *r, symbol_number token,
|
|||||||
switch (resolution)
|
switch (resolution)
|
||||||
{
|
{
|
||||||
case shift_resolution:
|
case shift_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
obstack_printf (&solved_conflicts_obstack,
|
||||||
" (%s < %s)",
|
" (%s < %s)",
|
||||||
r->prec->tag,
|
r->prec->tag,
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case reduce_resolution:
|
case reduce_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
obstack_printf (&solved_conflicts_obstack,
|
||||||
" (%s < %s)",
|
" (%s < %s)",
|
||||||
symbols[token]->tag,
|
symbols[token]->tag,
|
||||||
r->prec->tag);
|
r->prec->tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case left_resolution:
|
case left_resolution:
|
||||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
obstack_printf (&solved_conflicts_obstack,
|
||||||
" (%%left %s)",
|
" (%%left %s)",
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case right_resolution:
|
case right_resolution:
|
||||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
obstack_printf (&solved_conflicts_obstack,
|
||||||
" (%%right %s)",
|
" (%%right %s)",
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nonassoc_resolution:
|
case nonassoc_resolution:
|
||||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
obstack_printf (&solved_conflicts_obstack,
|
||||||
" (%%nonassoc %s)",
|
" (%%nonassoc %s)",
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
@@ -145,7 +145,7 @@ log_resolution (rule *r, symbol_number token,
|
|||||||
{
|
{
|
||||||
case shift_resolution:
|
case shift_resolution:
|
||||||
case right_resolution:
|
case right_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_xml_obstack,
|
obstack_printf (&solved_conflicts_xml_obstack,
|
||||||
" <resolution rule=\"%d\" symbol=\"%s\""
|
" <resolution rule=\"%d\" symbol=\"%s\""
|
||||||
" type=\"shift\">",
|
" type=\"shift\">",
|
||||||
r->number,
|
r->number,
|
||||||
@@ -154,7 +154,7 @@ log_resolution (rule *r, symbol_number token,
|
|||||||
|
|
||||||
case reduce_resolution:
|
case reduce_resolution:
|
||||||
case left_resolution:
|
case left_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_xml_obstack,
|
obstack_printf (&solved_conflicts_xml_obstack,
|
||||||
" <resolution rule=\"%d\" symbol=\"%s\""
|
" <resolution rule=\"%d\" symbol=\"%s\""
|
||||||
" type=\"reduce\">",
|
" type=\"reduce\">",
|
||||||
r->number,
|
r->number,
|
||||||
@@ -162,7 +162,7 @@ log_resolution (rule *r, symbol_number token,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case nonassoc_resolution:
|
case nonassoc_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_xml_obstack,
|
obstack_printf (&solved_conflicts_xml_obstack,
|
||||||
" <resolution rule=\"%d\" symbol=\"%s\""
|
" <resolution rule=\"%d\" symbol=\"%s\""
|
||||||
" type=\"error\">",
|
" type=\"error\">",
|
||||||
r->number,
|
r->number,
|
||||||
@@ -174,33 +174,33 @@ log_resolution (rule *r, symbol_number token,
|
|||||||
switch (resolution)
|
switch (resolution)
|
||||||
{
|
{
|
||||||
case shift_resolution:
|
case shift_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_xml_obstack,
|
obstack_printf (&solved_conflicts_xml_obstack,
|
||||||
"%s < %s",
|
"%s < %s",
|
||||||
xml_escape_n (0, r->prec->tag),
|
xml_escape_n (0, r->prec->tag),
|
||||||
xml_escape_n (1, symbols[token]->tag));
|
xml_escape_n (1, symbols[token]->tag));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case reduce_resolution:
|
case reduce_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_xml_obstack,
|
obstack_printf (&solved_conflicts_xml_obstack,
|
||||||
"%s < %s",
|
"%s < %s",
|
||||||
xml_escape_n (0, symbols[token]->tag),
|
xml_escape_n (0, symbols[token]->tag),
|
||||||
xml_escape_n (1, r->prec->tag));
|
xml_escape_n (1, r->prec->tag));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case left_resolution:
|
case left_resolution:
|
||||||
obstack_fgrow1 (&solved_conflicts_xml_obstack,
|
obstack_printf (&solved_conflicts_xml_obstack,
|
||||||
"%%left %s",
|
"%%left %s",
|
||||||
xml_escape (symbols[token]->tag));
|
xml_escape (symbols[token]->tag));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case right_resolution:
|
case right_resolution:
|
||||||
obstack_fgrow1 (&solved_conflicts_xml_obstack,
|
obstack_printf (&solved_conflicts_xml_obstack,
|
||||||
"%%right %s",
|
"%%right %s",
|
||||||
xml_escape (symbols[token]->tag));
|
xml_escape (symbols[token]->tag));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nonassoc_resolution:
|
case nonassoc_resolution:
|
||||||
obstack_fgrow1 (&solved_conflicts_xml_obstack,
|
obstack_printf (&solved_conflicts_xml_obstack,
|
||||||
"%%nonassoc %s",
|
"%%nonassoc %s",
|
||||||
xml_escape (symbols[token]->tag));
|
xml_escape (symbols[token]->tag));
|
||||||
break;
|
break;
|
||||||
|
|||||||
+4
-3
@@ -311,10 +311,11 @@ Parser:\n\
|
|||||||
-S, --skeleton=FILE specify the skeleton to use\n\
|
-S, --skeleton=FILE specify the skeleton to use\n\
|
||||||
-t, --debug instrument the parser for debugging\n\
|
-t, --debug instrument the parser for debugging\n\
|
||||||
--locations enable location support\n\
|
--locations enable location support\n\
|
||||||
-D, --define=NAME[=VALUE] similar to `%define NAME \"VALUE\"'\n\
|
-D, --define=NAME[=VALUE] similar to '%define NAME \"VALUE\"'\n\
|
||||||
-F, --force-define=NAME[=VALUE] override `%define NAME \"VALUE\"'\n\
|
-F, --force-define=NAME[=VALUE] override '%define NAME \"VALUE\"'\n\
|
||||||
-p, --name-prefix=PREFIX prepend PREFIX to the external symbols\n\
|
-p, --name-prefix=PREFIX prepend PREFIX to the external symbols\n\
|
||||||
-l, --no-lines don't generate `#line' directives\n\
|
deprecated by '-Dapi.prefix=PREFIX'\n\
|
||||||
|
-l, --no-lines don't generate '#line' directives\n\
|
||||||
-k, --token-table include a table of token names\n\
|
-k, --token-table include a table of token names\n\
|
||||||
\n\
|
\n\
|
||||||
"), stdout);
|
"), stdout);
|
||||||
|
|||||||
+53
-45
@@ -177,10 +177,10 @@ static void
|
|||||||
muscle_syncline_grow (char const *key, location loc)
|
muscle_syncline_grow (char const *key, location loc)
|
||||||
{
|
{
|
||||||
char *extension = NULL;
|
char *extension = NULL;
|
||||||
obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
|
obstack_printf (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line);
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
|
obstack_quote (&muscle_obstack,
|
||||||
quotearg_style (c_quoting_style, loc.start.file));
|
quotearg_style (c_quoting_style, loc.start.file));
|
||||||
obstack_sgrow (&muscle_obstack, "]])[");
|
obstack_sgrow (&muscle_obstack, ")[");
|
||||||
obstack_1grow (&muscle_obstack, 0);
|
obstack_1grow (&muscle_obstack, 0);
|
||||||
extension = obstack_finish (&muscle_obstack);
|
extension = obstack_finish (&muscle_obstack);
|
||||||
muscle_grow (key, extension, "");
|
muscle_grow (key, extension, "");
|
||||||
@@ -205,11 +205,11 @@ void muscle_pair_list_grow (const char *muscle,
|
|||||||
const char *a1, const char *a2)
|
const char *a1, const char *a2)
|
||||||
{
|
{
|
||||||
char *pair;
|
char *pair;
|
||||||
obstack_sgrow (&muscle_obstack, "[[[");
|
obstack_sgrow (&muscle_obstack, "[");
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, a1);
|
obstack_quote (&muscle_obstack, a1);
|
||||||
obstack_sgrow (&muscle_obstack, "]], [[");
|
obstack_sgrow (&muscle_obstack, ", ");
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, a2);
|
obstack_quote (&muscle_obstack, a2);
|
||||||
obstack_sgrow (&muscle_obstack, "]]]");
|
obstack_sgrow (&muscle_obstack, "]");
|
||||||
obstack_1grow (&muscle_obstack, 0);
|
obstack_1grow (&muscle_obstack, 0);
|
||||||
pair = obstack_finish (&muscle_obstack);
|
pair = obstack_finish (&muscle_obstack);
|
||||||
muscle_grow (muscle, pair, ",\n");
|
muscle_grow (muscle, pair, ",\n");
|
||||||
@@ -259,53 +259,61 @@ muscle_find (char const *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
/* In the format `file_name:line.column', append BOUND to MUSCLE. Use
|
||||||
|
digraphs for special characters in the file name. */
|
||||||
|
|
||||||
|
static void
|
||||||
muscle_boundary_grow (char const *key, boundary bound)
|
muscle_boundary_grow (char const *key, boundary bound)
|
||||||
{
|
{
|
||||||
char *extension;
|
char *extension;
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, bound.file);
|
obstack_sgrow (&muscle_obstack, "[[");
|
||||||
obstack_1grow (&muscle_obstack, ':');
|
obstack_escape (&muscle_obstack, bound.file);
|
||||||
obstack_fgrow1 (&muscle_obstack, "%d", bound.line);
|
obstack_1grow (&muscle_obstack, ':');
|
||||||
obstack_1grow (&muscle_obstack, '.');
|
obstack_printf (&muscle_obstack, "%d", bound.line);
|
||||||
obstack_fgrow1 (&muscle_obstack, "%d", bound.column);
|
obstack_1grow (&muscle_obstack, '.');
|
||||||
obstack_1grow (&muscle_obstack, '\0');
|
obstack_printf (&muscle_obstack, "%d", bound.column);
|
||||||
|
obstack_sgrow (&muscle_obstack, "]]");
|
||||||
|
obstack_1grow (&muscle_obstack, '\0');
|
||||||
extension = obstack_finish (&muscle_obstack);
|
extension = obstack_finish (&muscle_obstack);
|
||||||
muscle_grow (key, extension, "");
|
muscle_grow (key, extension, "");
|
||||||
obstack_free (&muscle_obstack, extension);
|
obstack_free (&muscle_obstack, extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
|
/* In the format `[[file_name:line.column]], [[file_name:line.column]]',
|
||||||
|
append LOC to MUSCLE. Use digraphs for special characters in each
|
||||||
|
file name. */
|
||||||
|
|
||||||
|
static void
|
||||||
muscle_location_grow (char const *key, location loc)
|
muscle_location_grow (char const *key, location loc)
|
||||||
{
|
{
|
||||||
muscle_grow (key, "[[", "");
|
|
||||||
muscle_boundary_grow (key, loc.start);
|
muscle_boundary_grow (key, loc.start);
|
||||||
muscle_grow (key, "]], [[", "");
|
muscle_grow (key, "", ", ");
|
||||||
muscle_boundary_grow (key, loc.end);
|
muscle_boundary_grow (key, loc.end);
|
||||||
muscle_grow (key, "]]", "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MUSCLE_COMMON_DECODE(Value) \
|
#define COMMON_DECODE(Value) \
|
||||||
case '$': \
|
case '$': \
|
||||||
aver (*++(Value) == ']'); \
|
aver (*++(Value) == ']'); \
|
||||||
aver (*++(Value) == '['); \
|
aver (*++(Value) == '['); \
|
||||||
obstack_sgrow (&muscle_obstack, "$"); \
|
obstack_sgrow (&muscle_obstack, "$"); \
|
||||||
break; \
|
break; \
|
||||||
case '@': \
|
case '@': \
|
||||||
switch (*++(Value)) \
|
switch (*++(Value)) \
|
||||||
{ \
|
{ \
|
||||||
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
|
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
|
||||||
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
|
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
|
||||||
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
|
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
|
||||||
default: aver (false); break; \
|
default: aver (false); break; \
|
||||||
} \
|
} \
|
||||||
break; \
|
break; \
|
||||||
default: \
|
default: \
|
||||||
obstack_1grow (&muscle_obstack, *(Value)); \
|
obstack_1grow (&muscle_obstack, *(Value)); \
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Reverse of MUSCLE_OBSTACK_SGROW. */
|
/* Reverse of obstack_escape. */
|
||||||
static char *
|
static char *
|
||||||
muscle_string_decode (char const *key)
|
string_decode (char const *key)
|
||||||
{
|
{
|
||||||
char const *value;
|
char const *value;
|
||||||
char *value_decoded;
|
char *value_decoded;
|
||||||
@@ -317,7 +325,7 @@ muscle_string_decode (char const *key)
|
|||||||
do {
|
do {
|
||||||
switch (*value)
|
switch (*value)
|
||||||
{
|
{
|
||||||
MUSCLE_COMMON_DECODE (value)
|
COMMON_DECODE (value)
|
||||||
case '[':
|
case '[':
|
||||||
case ']':
|
case ']':
|
||||||
aver (false);
|
aver (false);
|
||||||
@@ -332,7 +340,7 @@ muscle_string_decode (char const *key)
|
|||||||
|
|
||||||
/* Reverse of muscle_location_grow. */
|
/* Reverse of muscle_location_grow. */
|
||||||
static location
|
static location
|
||||||
muscle_location_decode (char const *key)
|
location_decode (char const *key)
|
||||||
{
|
{
|
||||||
location loc;
|
location loc;
|
||||||
char const *value = muscle_find_const (key);
|
char const *value = muscle_find_const (key);
|
||||||
@@ -342,7 +350,7 @@ muscle_location_decode (char const *key)
|
|||||||
while (*++value)
|
while (*++value)
|
||||||
switch (*value)
|
switch (*value)
|
||||||
{
|
{
|
||||||
MUSCLE_COMMON_DECODE (value)
|
COMMON_DECODE (value)
|
||||||
case '[':
|
case '[':
|
||||||
aver (false);
|
aver (false);
|
||||||
break;
|
break;
|
||||||
@@ -455,7 +463,7 @@ muscle_percent_define_get (char const *variable)
|
|||||||
variable, ")");
|
variable, ")");
|
||||||
|
|
||||||
muscle_insert (usage_name, "");
|
muscle_insert (usage_name, "");
|
||||||
value = muscle_string_decode (name);
|
value = string_decode (name);
|
||||||
if (!value)
|
if (!value)
|
||||||
value = xstrdup ("");
|
value = xstrdup ("");
|
||||||
return value;
|
return value;
|
||||||
@@ -469,7 +477,7 @@ muscle_percent_define_get_loc (char const *variable)
|
|||||||
if (!muscle_find_const (loc_name))
|
if (!muscle_find_const (loc_name))
|
||||||
fatal(_("%s: undefined %%define variable %s"),
|
fatal(_("%s: undefined %%define variable %s"),
|
||||||
"muscle_percent_define_get_loc", quote (variable));
|
"muscle_percent_define_get_loc", quote (variable));
|
||||||
return muscle_location_decode (loc_name);
|
return location_decode (loc_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
char const *
|
char const *
|
||||||
@@ -573,7 +581,7 @@ muscle_percent_define_check_values (char const * const *values)
|
|||||||
|
|
||||||
name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
|
name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
|
||||||
|
|
||||||
value = muscle_string_decode (name);
|
value = string_decode (name);
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
for (++values; *values; ++values)
|
for (++values; *values; ++values)
|
||||||
|
|||||||
+37
-60
@@ -35,62 +35,47 @@ void muscle_free (void);
|
|||||||
/* An obstack dedicated to receive muscle keys and values. */
|
/* An obstack dedicated to receive muscle keys and values. */
|
||||||
extern struct obstack muscle_obstack;
|
extern struct obstack muscle_obstack;
|
||||||
|
|
||||||
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
int v = Value; \
|
int v = Value; \
|
||||||
MUSCLE_INSERT_INT (Key, v); \
|
MUSCLE_INSERT_INT (Key, v); \
|
||||||
} while(0)
|
} while (0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_INT(Key, Value) \
|
#define MUSCLE_INSERT_INT(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
|
obstack_printf (&muscle_obstack, "%d", Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while (0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
|
obstack_printf (&muscle_obstack, "%ld", Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while (0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
obstack_sgrow (&muscle_obstack, Value); \
|
obstack_sgrow (&muscle_obstack, Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while (0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_STRING(Key, Value) \
|
#define MUSCLE_INSERT_STRING(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
|
obstack_escape (&muscle_obstack, Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while (0)
|
||||||
|
|
||||||
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
|
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
char const *p; \
|
obstack_escape (&muscle_obstack, \
|
||||||
for (p = Value; *p; p++) \
|
quotearg_style (c_quoting_style, Value)); \
|
||||||
switch (*p) \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
{ \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
case '$': obstack_sgrow (Obstack, "$]["); break; \
|
} while (0)
|
||||||
case '@': obstack_sgrow (Obstack, "@@" ); break; \
|
|
||||||
case '[': obstack_sgrow (Obstack, "@{" ); break; \
|
|
||||||
case ']': obstack_sgrow (Obstack, "@}" ); break; \
|
|
||||||
default: obstack_1grow (Obstack, *p); break; \
|
|
||||||
} \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
|
||||||
do { \
|
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
|
|
||||||
quotearg_style (c_quoting_style, \
|
|
||||||
Value)); \
|
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
/* Append VALUE to the current value of KEY. If KEY did not already
|
/* Append VALUE to the current value of KEY. If KEY did not already
|
||||||
exist, create it. Use MUSCLE_OBSTACK. De-allocate the previously
|
exist, create it. Use MUSCLE_OBSTACK. De-allocate the previously
|
||||||
@@ -110,15 +95,7 @@ void muscle_code_grow (const char *key, const char *value, location loc);
|
|||||||
muscle values are output *double* quoted, one needs to strip the first level
|
muscle values are output *double* quoted, one needs to strip the first level
|
||||||
of quotes to reach the list itself. */
|
of quotes to reach the list itself. */
|
||||||
void muscle_pair_list_grow (const char *muscle,
|
void muscle_pair_list_grow (const char *muscle,
|
||||||
const char *a1, const char *a2);
|
const char *a1, const char *a2);
|
||||||
|
|
||||||
/* In the format `[[file_name:line.column]], [[file_name:line.column]]', append
|
|
||||||
LOC to MUSCLE. Use digraphs for special characters in each file name. */
|
|
||||||
void muscle_location_grow (char const *key, location loc);
|
|
||||||
|
|
||||||
/* In the format `file_name:line.column', append BOUND to MUSCLE. Use digraphs
|
|
||||||
for special characters in the file name. */
|
|
||||||
void muscle_boundary_grow (char const *key, boundary bound);
|
|
||||||
|
|
||||||
/* Grow KEY for the occurrence of the name USER_NAME at LOC appropriately for
|
/* Grow KEY for the occurrence of the name USER_NAME at LOC appropriately for
|
||||||
use with b4_check_user_names in ../data/bison.m4. USER_NAME is not escaped
|
use with b4_check_user_names in ../data/bison.m4. USER_NAME is not escaped
|
||||||
|
|||||||
+31
-18
@@ -70,7 +70,7 @@ Name (char const *name, \
|
|||||||
int i; \
|
int i; \
|
||||||
int j = 1; \
|
int j = 1; \
|
||||||
\
|
\
|
||||||
obstack_fgrow1 (&format_obstack, "%6d", first); \
|
obstack_printf (&format_obstack, "%6d", first); \
|
||||||
for (i = begin; i < end; ++i) \
|
for (i = begin; i < end; ++i) \
|
||||||
{ \
|
{ \
|
||||||
obstack_1grow (&format_obstack, ','); \
|
obstack_1grow (&format_obstack, ','); \
|
||||||
@@ -81,7 +81,7 @@ Name (char const *name, \
|
|||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
++j; \
|
++j; \
|
||||||
obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
|
obstack_printf (&format_obstack, "%6d", table_data[i]); \
|
||||||
if (table_data[i] < min) \
|
if (table_data[i] < min) \
|
||||||
min = table_data[i]; \
|
min = table_data[i]; \
|
||||||
if (max < table_data[i]) \
|
if (max < table_data[i]) \
|
||||||
@@ -93,10 +93,10 @@ Name (char const *name, \
|
|||||||
lmin = min; \
|
lmin = min; \
|
||||||
lmax = max; \
|
lmax = max; \
|
||||||
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
|
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
|
||||||
obstack_fgrow1 (&format_obstack, "%s_min", name); \
|
obstack_printf (&format_obstack, "%s_min", name); \
|
||||||
obstack_1grow (&format_obstack, 0); \
|
obstack_1grow (&format_obstack, 0); \
|
||||||
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
|
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
|
||||||
obstack_fgrow1 (&format_obstack, "%s_max", name); \
|
obstack_printf (&format_obstack, "%s_max", name); \
|
||||||
obstack_1grow (&format_obstack, 0); \
|
obstack_1grow (&format_obstack, 0); \
|
||||||
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
|
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
|
||||||
}
|
}
|
||||||
@@ -110,29 +110,39 @@ GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_item_number_table, item_number)
|
|||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
|
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------.
|
/*----------------------------------------------------------------.
|
||||||
| Print to OUT a representation of STRING escaped both for C and M4. |
|
| Print to OUT a representation of CP quoted and escaped for M4. |
|
||||||
`--------------------------------------------------------------------*/
|
`----------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
escaped_output (FILE *out, char const *string)
|
quoted_output (FILE *out, char const *cp)
|
||||||
{
|
{
|
||||||
char const *p;
|
|
||||||
fprintf (out, "[[");
|
fprintf (out, "[[");
|
||||||
|
|
||||||
for (p = quotearg_style (c_quoting_style, string); *p; p++)
|
for (; *cp; cp++)
|
||||||
switch (*p)
|
switch (*cp)
|
||||||
{
|
{
|
||||||
case '$': fputs ("$][", out); break;
|
case '$': fputs ("$][", out); break;
|
||||||
case '@': fputs ("@@", out); break;
|
case '@': fputs ("@@", out); break;
|
||||||
case '[': fputs ("@{", out); break;
|
case '[': fputs ("@{", out); break;
|
||||||
case ']': fputs ("@}", out); break;
|
case ']': fputs ("@}", out); break;
|
||||||
default: fputc (*p, out); break;
|
default: fputc (*cp, out); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (out, "]]");
|
fprintf (out, "]]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------.
|
||||||
|
| Print to OUT a representation of STRING quoted and escaped both |
|
||||||
|
| for C and M4. |
|
||||||
|
`----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
string_output (FILE *out, char const *string)
|
||||||
|
{
|
||||||
|
quoted_output (out, quotearg_style (c_quoting_style, string));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------.
|
/*------------------------------------------------------------------.
|
||||||
| Prepare the muscles related to the symbols: translate, tname, and |
|
| Prepare the muscles related to the symbols: translate, tname, and |
|
||||||
@@ -142,7 +152,6 @@ escaped_output (FILE *out, char const *string)
|
|||||||
static void
|
static void
|
||||||
prepare_symbols (void)
|
prepare_symbols (void)
|
||||||
{
|
{
|
||||||
MUSCLE_INSERT_BOOL ("token_table", token_table_flag);
|
|
||||||
MUSCLE_INSERT_INT ("tokens_number", ntokens);
|
MUSCLE_INSERT_INT ("tokens_number", ntokens);
|
||||||
MUSCLE_INSERT_INT ("nterms_number", nvars);
|
MUSCLE_INSERT_INT ("nterms_number", nvars);
|
||||||
MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
|
MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
|
||||||
@@ -176,7 +185,7 @@ prepare_symbols (void)
|
|||||||
|
|
||||||
if (i)
|
if (i)
|
||||||
obstack_1grow (&format_obstack, ' ');
|
obstack_1grow (&format_obstack, ' ');
|
||||||
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
|
obstack_escape (&format_obstack, cp);
|
||||||
free (cp);
|
free (cp);
|
||||||
obstack_1grow (&format_obstack, ',');
|
obstack_1grow (&format_obstack, ',');
|
||||||
j += width;
|
j += width;
|
||||||
@@ -300,7 +309,7 @@ user_actions_output (FILE *out)
|
|||||||
{
|
{
|
||||||
fprintf (out, "b4_case(%d, [b4_syncline(%d, ", r + 1,
|
fprintf (out, "b4_case(%d, [b4_syncline(%d, ", r + 1,
|
||||||
rules[r].action_location.start.line);
|
rules[r].action_location.start.line);
|
||||||
escaped_output (out, rules[r].action_location.start.file);
|
string_output (out, rules[r].action_location.start.file);
|
||||||
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
|
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
|
||||||
}
|
}
|
||||||
fputs ("])\n\n", out);
|
fputs ("])\n\n", out);
|
||||||
@@ -406,12 +415,15 @@ symbol_code_props_output (FILE *out, char const *what,
|
|||||||
code, optional typename. */
|
code, optional typename. */
|
||||||
fprintf (out, "%s[", sep);
|
fprintf (out, "%s[", sep);
|
||||||
sep = ",\n";
|
sep = ",\n";
|
||||||
escaped_output (out, loc.start.file);
|
string_output (out, loc.start.file);
|
||||||
fprintf (out, ", %d, ", loc.start.line);
|
fprintf (out, ", %d, ", loc.start.line);
|
||||||
escaped_output (out, sym->tag);
|
quoted_output (out, sym->tag);
|
||||||
fprintf (out, ", %d, [[%s]]", sym->number, code);
|
fprintf (out, ", %d, [[%s]]", sym->number, code);
|
||||||
if (sym->type_name)
|
if (sym->type_name)
|
||||||
fprintf (out, ", [[%s]]", sym->type_name);
|
{
|
||||||
|
fputs (", ", out);
|
||||||
|
quoted_output (out, sym->type_name);
|
||||||
|
}
|
||||||
fputc (']', out);
|
fputc (']', out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -624,6 +636,7 @@ prepare (void)
|
|||||||
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
|
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
|
||||||
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
|
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
|
||||||
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
|
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
|
||||||
|
MUSCLE_INSERT_BOOL ("token_table_flag", token_table_flag);
|
||||||
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
|
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
|
||||||
MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag);
|
MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag);
|
||||||
|
|
||||||
|
|||||||
+333
-455
File diff suppressed because it is too large
Load Diff
+27
-9
@@ -1,4 +1,4 @@
|
|||||||
/* A Bison parser, made by GNU Bison 2.5.1_rc2. */
|
/* A Bison parser, made by GNU Bison 2.6.1.12-3153-dirty. */
|
||||||
|
|
||||||
/* Bison interface for Yacc-like parsers in C
|
/* Bison interface for Yacc-like parsers in C
|
||||||
|
|
||||||
@@ -30,6 +30,15 @@
|
|||||||
This special exception was added by the Free Software Foundation in
|
This special exception was added by the Free Software Foundation in
|
||||||
version 2.2 of Bison. */
|
version 2.2 of Bison. */
|
||||||
|
|
||||||
|
#ifndef GRAM__________SRC_PARSE_GRAM_H
|
||||||
|
# define GRAM__________SRC_PARSE_GRAM_H
|
||||||
|
/* Enabling traces. */
|
||||||
|
#ifndef YYDEBUG
|
||||||
|
# define YYDEBUG 1
|
||||||
|
#endif
|
||||||
|
#if YYDEBUG
|
||||||
|
extern int gram_debug;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
#ifndef YYTOKENTYPE
|
#ifndef YYTOKENTYPE
|
||||||
@@ -155,12 +164,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||||
typedef union YYSTYPE
|
typedef union YYSTYPE
|
||||||
{
|
{
|
||||||
|
/* Line 2049 of yacc.c */
|
||||||
/* Line 2072 of yacc.c */
|
|
||||||
#line 114 "parse-gram.y"
|
#line 114 "parse-gram.y"
|
||||||
|
|
||||||
symbol *symbol;
|
symbol *symbol;
|
||||||
@@ -174,17 +181,14 @@ typedef union YYSTYPE
|
|||||||
named_ref *named_ref;
|
named_ref *named_ref;
|
||||||
|
|
||||||
|
|
||||||
|
/* Line 2049 of yacc.c */
|
||||||
/* Line 2072 of yacc.c */
|
#line 186 "parse-gram.h"
|
||||||
#line 180 "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 */
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
||||||
typedef struct YYLTYPE
|
typedef struct YYLTYPE
|
||||||
{
|
{
|
||||||
@@ -199,4 +203,18 @@ typedef struct YYLTYPE
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef YYPARSE_PARAM
|
||||||
|
#if defined __STDC__ || defined __cplusplus
|
||||||
|
int gram_parse (void *YYPARSE_PARAM);
|
||||||
|
#else
|
||||||
|
int gram_parse ();
|
||||||
|
#endif
|
||||||
|
#else /* ! YYPARSE_PARAM */
|
||||||
|
#if defined __STDC__ || defined __cplusplus
|
||||||
|
int gram_parse (void);
|
||||||
|
#else
|
||||||
|
int gram_parse ();
|
||||||
|
#endif
|
||||||
|
#endif /* ! YYPARSE_PARAM */
|
||||||
|
|
||||||
|
#endif /* !GRAM__________SRC_PARSE_GRAM_H */
|
||||||
|
|||||||
+24
-12
@@ -347,17 +347,27 @@ grammar_declaration:
|
|||||||
}
|
}
|
||||||
| "%destructor" "{...}" generic_symlist
|
| "%destructor" "{...}" generic_symlist
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
code_props code;
|
||||||
for (list = $3; list; list = list->next)
|
code_props_symbol_action_init (&code, $2, @2);
|
||||||
symbol_list_destructor_set (list, $2, @2);
|
code_props_translate_code (&code);
|
||||||
symbol_list_free ($3);
|
{
|
||||||
|
symbol_list *list;
|
||||||
|
for (list = $3; list; list = list->next)
|
||||||
|
symbol_list_destructor_set (list, &code);
|
||||||
|
symbol_list_free ($3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| "%printer" "{...}" generic_symlist
|
| "%printer" "{...}" generic_symlist
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
code_props code;
|
||||||
for (list = $3; list; list = list->next)
|
code_props_symbol_action_init (&code, $2, @2);
|
||||||
symbol_list_printer_set (list, $2, @2);
|
code_props_translate_code (&code);
|
||||||
symbol_list_free ($3);
|
{
|
||||||
|
symbol_list *list;
|
||||||
|
for (list = $3; list; list = list->next)
|
||||||
|
symbol_list_printer_set (list, &code);
|
||||||
|
symbol_list_free ($3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| "%default-prec"
|
| "%default-prec"
|
||||||
{
|
{
|
||||||
@@ -724,11 +734,13 @@ add_param (char const *type, char *decl, location loc)
|
|||||||
|
|
||||||
/* Strip the surrounding '{' and '}', and any blanks just inside
|
/* Strip the surrounding '{' and '}', and any blanks just inside
|
||||||
the braces. */
|
the braces. */
|
||||||
while (*--p == ' ' || *p == '\t')
|
--p;
|
||||||
continue;
|
while (isspace ((unsigned char) *p))
|
||||||
|
--p;
|
||||||
p[1] = '\0';
|
p[1] = '\0';
|
||||||
while (*++decl == ' ' || *decl == '\t')
|
++decl;
|
||||||
continue;
|
while (isspace ((unsigned char) *decl))
|
||||||
|
++decl;
|
||||||
|
|
||||||
if (! name_start)
|
if (! name_start)
|
||||||
complain_at (loc, _("missing identifier in parameter declaration"));
|
complain_at (loc, _("missing identifier in parameter declaration"));
|
||||||
|
|||||||
+5
-5
@@ -54,7 +54,7 @@ print_core (struct obstack *oout, state *s)
|
|||||||
snritems = nitemset;
|
snritems = nitemset;
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_fgrow1 (oout, "%d", s->number);
|
obstack_printf (oout, "%d", s->number);
|
||||||
for (i = 0; i < snritems; i++)
|
for (i = 0; i < snritems; i++)
|
||||||
{
|
{
|
||||||
item_number *sp;
|
item_number *sp;
|
||||||
@@ -68,15 +68,15 @@ print_core (struct obstack *oout, state *s)
|
|||||||
|
|
||||||
r = item_number_as_rule_number (*sp);
|
r = item_number_as_rule_number (*sp);
|
||||||
|
|
||||||
obstack_fgrow1 (oout, "\n%s -> ", rules[r].lhs->tag);
|
obstack_printf (oout, "\n%s -> ", rules[r].lhs->tag);
|
||||||
|
|
||||||
for (sp = rules[r].rhs; sp < sp1; sp++)
|
for (sp = rules[r].rhs; sp < sp1; sp++)
|
||||||
obstack_fgrow1 (oout, "%s ", symbols[*sp]->tag);
|
obstack_printf (oout, "%s ", symbols[*sp]->tag);
|
||||||
|
|
||||||
obstack_1grow (oout, '.');
|
obstack_1grow (oout, '.');
|
||||||
|
|
||||||
for (/* Nothing */; *sp >= 0; ++sp)
|
for (/* Nothing */; *sp >= 0; ++sp)
|
||||||
obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
|
obstack_printf (oout, " %s", symbols[*sp]->tag);
|
||||||
|
|
||||||
/* Experimental feature: display the lookahead tokens. */
|
/* Experimental feature: display the lookahead tokens. */
|
||||||
if (report_flag & report_lookahead_tokens
|
if (report_flag & report_lookahead_tokens
|
||||||
@@ -95,7 +95,7 @@ print_core (struct obstack *oout, state *s)
|
|||||||
obstack_sgrow (oout, "[");
|
obstack_sgrow (oout, "[");
|
||||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
|
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
|
||||||
{
|
{
|
||||||
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
|
obstack_printf (oout, "%s%s", sep, symbols[k]->tag);
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
obstack_sgrow (oout, "]");
|
obstack_sgrow (oout, "]");
|
||||||
|
|||||||
+4
-1
@@ -45,7 +45,10 @@ typedef struct code_props {
|
|||||||
CODE_PROPS_SYMBOL_ACTION, CODE_PROPS_RULE_ACTION
|
CODE_PROPS_SYMBOL_ACTION, CODE_PROPS_RULE_ACTION
|
||||||
} kind;
|
} kind;
|
||||||
|
|
||||||
/** \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE. */
|
/**
|
||||||
|
* \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE.
|
||||||
|
* Memory is allocated in an obstack freed elsewhere.
|
||||||
|
*/
|
||||||
char const *code;
|
char const *code;
|
||||||
/** Undefined iff \c code_props::code is \c NULL. */
|
/** Undefined iff \c code_props::code is \c NULL. */
|
||||||
location location;
|
location location;
|
||||||
|
|||||||
+88
-87
@@ -46,6 +46,9 @@ YY_DECL;
|
|||||||
|
|
||||||
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
|
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
|
||||||
|
|
||||||
|
static char *fetch_type_name (char *cp, char const **type_name,
|
||||||
|
location dollar_loc);
|
||||||
|
|
||||||
static void handle_action_dollar (symbol_list *rule, char *cp,
|
static void handle_action_dollar (symbol_list *rule, char *cp,
|
||||||
location dollar_loc);
|
location dollar_loc);
|
||||||
static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
|
static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
|
||||||
@@ -95,11 +98,15 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
int braces_level = 0;
|
int braces_level = 0;
|
||||||
|
|
||||||
/* Whether a semicolon is probably needed.
|
/* Whether a semicolon is probably needed.
|
||||||
The heuristic is that a semicolon is not needed after '{', '}', ';',
|
|
||||||
or a C preprocessor directive, and that whitespaces and comments
|
The heuristic is that a semicolon is not needed after '{', '}',
|
||||||
do not affect this flag.
|
';', or a C preprocessor directive, and that whitespaces and
|
||||||
Note that '{' does not need a semicolon because of '{}'.
|
comments do not affect this flag. Note that '{' does not need a
|
||||||
A semicolon may be needed before a cpp direcive, but don't bother. */
|
semicolon because of '{}'. A semicolon may be needed before a
|
||||||
|
cpp directive, but don't bother.
|
||||||
|
|
||||||
|
While it is maintained in several start-conditions (factoring
|
||||||
|
opportunities), it is meaningful only for SC_RULE_ACTION. */
|
||||||
bool need_semicolon = false;
|
bool need_semicolon = false;
|
||||||
|
|
||||||
/* Whether in a C preprocessor directive. Don't use a start condition
|
/* Whether in a C preprocessor directive. Don't use a start condition
|
||||||
@@ -157,7 +164,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<SC_RULE_ACTION,SC_SYMBOL_ACTION>{
|
<SC_RULE_ACTION,SC_SYMBOL_ACTION>
|
||||||
|
{
|
||||||
"'" {
|
"'" {
|
||||||
STRING_GROW;
|
STRING_GROW;
|
||||||
BEGIN SC_CHARACTER;
|
BEGIN SC_CHARACTER;
|
||||||
@@ -176,42 +184,31 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
STRING_GROW;
|
STRING_GROW;
|
||||||
BEGIN SC_LINE_COMMENT;
|
BEGIN SC_LINE_COMMENT;
|
||||||
}
|
}
|
||||||
|
[$@] {
|
||||||
|
warn_at (*loc, _("stray '%s'"), yytext);
|
||||||
|
obstack_escape (&obstack_for_string, yytext);
|
||||||
|
need_semicolon = true;
|
||||||
|
}
|
||||||
|
[\[\]] {
|
||||||
|
obstack_escape (&obstack_for_string, yytext);
|
||||||
|
need_semicolon = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_RULE_ACTION>
|
<SC_RULE_ACTION>
|
||||||
{
|
{
|
||||||
"$"("<"{tag}">")?{ref} {
|
"$"("<"{tag}">")?{ref} {
|
||||||
ref_tail_fields = 0;
|
ref_tail_fields = NULL;
|
||||||
handle_action_dollar (self->rule, yytext, *loc);
|
handle_action_dollar (self->rule, yytext, *loc);
|
||||||
if (ref_tail_fields) {
|
if (ref_tail_fields)
|
||||||
obstack_sgrow (&obstack_for_string, ref_tail_fields);
|
obstack_sgrow (&obstack_for_string, ref_tail_fields);
|
||||||
}
|
|
||||||
need_semicolon = true;
|
need_semicolon = true;
|
||||||
}
|
}
|
||||||
"@"{ref} {
|
"@"{ref} {
|
||||||
ref_tail_fields = 0;
|
ref_tail_fields = NULL;
|
||||||
handle_action_at (self->rule, yytext, *loc);
|
handle_action_at (self->rule, yytext, *loc);
|
||||||
if (ref_tail_fields) {
|
if (ref_tail_fields)
|
||||||
obstack_sgrow (&obstack_for_string, ref_tail_fields);
|
obstack_sgrow (&obstack_for_string, ref_tail_fields);
|
||||||
}
|
|
||||||
need_semicolon = true;
|
|
||||||
}
|
|
||||||
"$" {
|
|
||||||
warn_at (*loc, _("stray '$'"));
|
|
||||||
obstack_sgrow (&obstack_for_string, "$][");
|
|
||||||
need_semicolon = true;
|
|
||||||
}
|
|
||||||
"@" {
|
|
||||||
warn_at (*loc, _("stray '@'"));
|
|
||||||
obstack_sgrow (&obstack_for_string, "@@");
|
|
||||||
need_semicolon = true;
|
|
||||||
}
|
|
||||||
"[" {
|
|
||||||
obstack_sgrow (&obstack_for_string, "@{");
|
|
||||||
need_semicolon = true;
|
|
||||||
}
|
|
||||||
"]" {
|
|
||||||
obstack_sgrow (&obstack_for_string, "@}");
|
|
||||||
need_semicolon = true;
|
need_semicolon = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,8 +260,12 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
|
|
||||||
<SC_SYMBOL_ACTION>
|
<SC_SYMBOL_ACTION>
|
||||||
{
|
{
|
||||||
"$$" {
|
"$"("<"{tag}">")?"$" {
|
||||||
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar[");
|
const char *type_name = NULL;
|
||||||
|
fetch_type_name (yytext + 1, &type_name, *loc)[-1] = 0;
|
||||||
|
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar(");
|
||||||
|
obstack_quote (&obstack_for_string, type_name);
|
||||||
|
obstack_sgrow (&obstack_for_string, ")[");
|
||||||
self->is_value_used = true;
|
self->is_value_used = true;
|
||||||
}
|
}
|
||||||
"@$" {
|
"@$" {
|
||||||
@@ -274,30 +275,18 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------.
|
|
||||||
| Escape M4 quoting characters in C code. |
|
|
||||||
`-----------------------------------------*/
|
|
||||||
|
|
||||||
<*>
|
<*>
|
||||||
{
|
{
|
||||||
\$ obstack_sgrow (&obstack_for_string, "$][");
|
/* Escape M4 quoting characters in C code. */
|
||||||
\@ obstack_sgrow (&obstack_for_string, "@@");
|
[$@\[\]] obstack_escape (&obstack_for_string, yytext);
|
||||||
\[ obstack_sgrow (&obstack_for_string, "@{");
|
|
||||||
\] obstack_sgrow (&obstack_for_string, "@}");
|
/* By default, grow the string obstack with the input. */
|
||||||
|
.|\n STRING_GROW;
|
||||||
|
|
||||||
|
/* End of processing. */
|
||||||
|
<<EOF>> STRING_FINISH; return last_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------.
|
|
||||||
| By default, grow the string obstack with the input. |
|
|
||||||
`-----------------------------------------------------*/
|
|
||||||
|
|
||||||
<*>.|\n STRING_GROW;
|
|
||||||
|
|
||||||
/* End of processing. */
|
|
||||||
<*><<EOF>> {
|
|
||||||
STRING_FINISH;
|
|
||||||
return last_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
@@ -345,7 +334,7 @@ typedef struct
|
|||||||
not visible from current midrule. */
|
not visible from current midrule. */
|
||||||
#define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2)
|
#define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2)
|
||||||
|
|
||||||
static variant *variant_table = 0;
|
static variant *variant_table = NULL;
|
||||||
static unsigned variant_table_size = 0;
|
static unsigned variant_table_size = 0;
|
||||||
static unsigned variant_count = 0;
|
static unsigned variant_count = 0;
|
||||||
|
|
||||||
@@ -367,7 +356,7 @@ static void
|
|||||||
variant_table_free (void)
|
variant_table_free (void)
|
||||||
{
|
{
|
||||||
free (variant_table);
|
free (variant_table);
|
||||||
variant_table = 0;
|
variant_table = NULL;
|
||||||
variant_table_size = variant_count = 0;
|
variant_table_size = variant_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +399,7 @@ variant_add (uniqstr id, location id_loc, unsigned symbol_index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
get_at_spec(unsigned symbol_index)
|
get_at_spec (unsigned symbol_index)
|
||||||
{
|
{
|
||||||
static char at_buf[20];
|
static char at_buf[20];
|
||||||
if (symbol_index == 0)
|
if (symbol_index == 0)
|
||||||
@@ -454,30 +443,30 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
|
|||||||
/* Create the explanation message. */
|
/* Create the explanation message. */
|
||||||
obstack_init (&msg_buf);
|
obstack_init (&msg_buf);
|
||||||
|
|
||||||
obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at);
|
obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at);
|
||||||
if (contains_dot_or_dash (id))
|
if (contains_dot_or_dash (id))
|
||||||
obstack_fgrow1 (&msg_buf, "[%s]", id);
|
obstack_printf (&msg_buf, "[%s]", id);
|
||||||
else
|
else
|
||||||
obstack_sgrow (&msg_buf, id);
|
obstack_sgrow (&msg_buf, id);
|
||||||
obstack_sgrow (&msg_buf, tail);
|
obstack_sgrow (&msg_buf, tail);
|
||||||
|
|
||||||
if (var->err & VARIANT_HIDDEN)
|
if (var->err & VARIANT_HIDDEN)
|
||||||
{
|
{
|
||||||
obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at);
|
obstack_printf (&msg_buf, _(", hiding %c"), dollar_or_at);
|
||||||
if (contains_dot_or_dash (var->id))
|
if (contains_dot_or_dash (var->id))
|
||||||
obstack_fgrow1 (&msg_buf, "[%s]", var->id);
|
obstack_printf (&msg_buf, "[%s]", var->id);
|
||||||
else
|
else
|
||||||
obstack_sgrow (&msg_buf, var->id);
|
obstack_sgrow (&msg_buf, var->id);
|
||||||
obstack_sgrow (&msg_buf, tail);
|
obstack_sgrow (&msg_buf, tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_fgrow1 (&msg_buf, _(" at %s"), at_spec);
|
obstack_printf (&msg_buf, _(" at %s"), at_spec);
|
||||||
|
|
||||||
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
|
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
|
||||||
{
|
{
|
||||||
const char *format =
|
const char *format =
|
||||||
_(", cannot be accessed from mid-rule action at $%d");
|
_(", cannot be accessed from mid-rule action at $%d");
|
||||||
obstack_fgrow1 (&msg_buf, format, midrule_rhs_index);
|
obstack_printf (&msg_buf, format, midrule_rhs_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_1grow (&msg_buf, '\0');
|
obstack_1grow (&msg_buf, '\0');
|
||||||
@@ -688,6 +677,31 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
|||||||
int max_left_semantic_context = 0;
|
int max_left_semantic_context = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* If CP points to a typename (i.e., <.*?>), set TYPE_NAME to its
|
||||||
|
beginning (i.e., after the opening "<", and return the pointer
|
||||||
|
immediately after it. */
|
||||||
|
|
||||||
|
static
|
||||||
|
char *
|
||||||
|
fetch_type_name (char *cp, char const **type_name,
|
||||||
|
location dollar_loc)
|
||||||
|
{
|
||||||
|
if (*cp == '<')
|
||||||
|
{
|
||||||
|
*type_name = ++cp;
|
||||||
|
while (*cp != '>')
|
||||||
|
++cp;
|
||||||
|
|
||||||
|
/* The '>' symbol will be later replaced by '\0'. Original
|
||||||
|
'text' is needed for error messages. */
|
||||||
|
++cp;
|
||||||
|
if (untyped_var_seen)
|
||||||
|
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
|
||||||
|
tag_seen = true;
|
||||||
|
}
|
||||||
|
return cp;
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------.
|
/*------------------------------------------------------------------.
|
||||||
| TEXT is pointing to a wannabee semantic value (i.e., a '$'). |
|
| TEXT is pointing to a wannabee semantic value (i.e., a '$'). |
|
||||||
| |
|
| |
|
||||||
@@ -701,7 +715,6 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
|||||||
{
|
{
|
||||||
char const *type_name = NULL;
|
char const *type_name = NULL;
|
||||||
char *cp = text + 1;
|
char *cp = text + 1;
|
||||||
char *gt_ptr = 0;
|
|
||||||
symbol_list *effective_rule;
|
symbol_list *effective_rule;
|
||||||
int effective_rule_length;
|
int effective_rule_length;
|
||||||
int n;
|
int n;
|
||||||
@@ -718,26 +731,14 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the type name if explicit. */
|
/* Get the type name if explicit. */
|
||||||
if (*cp == '<')
|
cp = fetch_type_name (cp, &type_name, dollar_loc);
|
||||||
{
|
|
||||||
type_name = ++cp;
|
|
||||||
while (*cp != '>')
|
|
||||||
++cp;
|
|
||||||
|
|
||||||
/* The '>' symbol will be later replaced by '\0'. Original
|
|
||||||
'text' is needed for error messages. */
|
|
||||||
gt_ptr = cp;
|
|
||||||
++cp;
|
|
||||||
if (untyped_var_seen)
|
|
||||||
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
|
|
||||||
tag_seen = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
n = parse_ref (cp, effective_rule, effective_rule_length,
|
n = parse_ref (cp, effective_rule, effective_rule_length,
|
||||||
rule->midrule_parent_rhs_index, text, dollar_loc, '$');
|
rule->midrule_parent_rhs_index, text, dollar_loc, '$');
|
||||||
|
|
||||||
if (gt_ptr)
|
/* End type_name. */
|
||||||
*gt_ptr = '\0';
|
if (type_name)
|
||||||
|
cp[-1] = '\0';
|
||||||
|
|
||||||
switch (n)
|
switch (n)
|
||||||
{
|
{
|
||||||
@@ -764,11 +765,11 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
untyped_var_seen = true;
|
untyped_var_seen = true;
|
||||||
type_name = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_fgrow1 (&obstack_for_string,
|
obstack_sgrow (&obstack_for_string, "]b4_lhs_value(");
|
||||||
"]b4_lhs_value([%s])[", type_name);
|
obstack_quote (&obstack_for_string, type_name);
|
||||||
|
obstack_sgrow (&obstack_for_string, ")[");
|
||||||
rule->action_props.is_value_used = true;
|
rule->action_props.is_value_used = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -785,12 +786,12 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
|||||||
cp, quote (effective_rule->content.sym->tag));
|
cp, quote (effective_rule->content.sym->tag));
|
||||||
else
|
else
|
||||||
untyped_var_seen = true;
|
untyped_var_seen = true;
|
||||||
type_name = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_fgrow3 (&obstack_for_string,
|
obstack_printf (&obstack_for_string,
|
||||||
"]b4_rhs_value(%d, %d, [%s])[",
|
"]b4_rhs_value(%d, %d, ", effective_rule_length, n);
|
||||||
effective_rule_length, n, type_name);
|
obstack_quote (&obstack_for_string, type_name);
|
||||||
|
obstack_sgrow (&obstack_for_string, ")[");
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
|
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
|
||||||
true;
|
true;
|
||||||
@@ -826,7 +827,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
|
|||||||
locations_flag = true;
|
locations_flag = true;
|
||||||
|
|
||||||
n = parse_ref (cp, effective_rule, effective_rule_length,
|
n = parse_ref (cp, effective_rule, effective_rule_length,
|
||||||
rule->midrule_parent_rhs_index, text, at_loc, '@');
|
rule->midrule_parent_rhs_index, text, at_loc, '@');
|
||||||
switch (n)
|
switch (n)
|
||||||
{
|
{
|
||||||
case INVALID_REF:
|
case INVALID_REF:
|
||||||
@@ -837,7 +838,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
|
obstack_printf (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
|
||||||
effective_rule_length, n);
|
effective_rule_length, n);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-18
@@ -72,8 +72,8 @@ static void fail_for_invalid_at (char const *at);
|
|||||||
"@@" fputc ('@', yyout);
|
"@@" fputc ('@', yyout);
|
||||||
"@{" fputc ('[', yyout);
|
"@{" fputc ('[', yyout);
|
||||||
"@}" fputc (']', yyout);
|
"@}" fputc (']', yyout);
|
||||||
"@`" /* Empty. Used by b4_cat in ../data/bison.m4. */
|
"@`" continue; /* Used by b4_cat in ../data/bison.m4. */
|
||||||
@\n /* Likewise. */
|
@\n continue;
|
||||||
|
|
||||||
"@oline@" fprintf (yyout, "%d", out_lineno + 1);
|
"@oline@" fprintf (yyout, "%d", out_lineno + 1);
|
||||||
"@ofile@" QPUTS (outname);
|
"@ofile@" QPUTS (outname);
|
||||||
@@ -87,9 +87,9 @@ static void fail_for_invalid_at (char const *at);
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This pattern must not match more than the previous @ patterns. */
|
/* This pattern must not match more than the previous @ patterns. */
|
||||||
@[^@{}`(\n]* fail_for_invalid_at (yytext);
|
@[^@{}`(\n]* fail_for_invalid_at (yytext);
|
||||||
\n out_lineno++; ECHO;
|
\n out_lineno++; ECHO;
|
||||||
[^@\n]+ ECHO;
|
[^@\n]+ ECHO;
|
||||||
|
|
||||||
<INITIAL><<EOF>> {
|
<INITIAL><<EOF>> {
|
||||||
if (outname)
|
if (outname)
|
||||||
@@ -100,15 +100,15 @@ static void fail_for_invalid_at (char const *at);
|
|||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_AT_DIRECTIVE_ARGS>{
|
<SC_AT_DIRECTIVE_ARGS>
|
||||||
[^@]+ { STRING_GROW; }
|
{
|
||||||
|
[^@]+ STRING_GROW;
|
||||||
|
|
||||||
"@@" { obstack_1grow (&obstack_for_string, '@'); }
|
"@@" obstack_1grow (&obstack_for_string, '@');
|
||||||
"@{" { obstack_1grow (&obstack_for_string, '['); }
|
"@{" obstack_1grow (&obstack_for_string, '[');
|
||||||
"@}" { obstack_1grow (&obstack_for_string, ']'); }
|
"@}" obstack_1grow (&obstack_for_string, ']');
|
||||||
"@`" /* Empty. Useful for starting an argument
|
"@`" continue; /* For starting an argument that begins with whitespace. */
|
||||||
that begins with whitespace. */
|
@\n continue;
|
||||||
@\n /* Empty. */
|
|
||||||
|
|
||||||
@[,)] {
|
@[,)] {
|
||||||
if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX)
|
if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX)
|
||||||
@@ -131,15 +131,17 @@ static void fail_for_invalid_at (char const *at);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@.? { fail_for_invalid_at (yytext); }
|
@.? fail_for_invalid_at (yytext);
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_AT_DIRECTIVE_SKIP_WS>{
|
<SC_AT_DIRECTIVE_SKIP_WS>
|
||||||
[ \t\r\n]
|
{
|
||||||
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
|
[ \t\r\n] continue;
|
||||||
|
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>{
|
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>
|
||||||
|
{
|
||||||
<<EOF>> {
|
<<EOF>> {
|
||||||
fatal (_("unclosed %s directive in skeleton"), at_directive_argv[0]);
|
fatal (_("unclosed %s directive in skeleton"), at_directive_argv[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-16
@@ -223,49 +223,43 @@ symbol_list_null (symbol_list *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
symbol_list_destructor_set (symbol_list *node, char const *code, location loc)
|
symbol_list_destructor_set (symbol_list *node, code_props const *destructor)
|
||||||
{
|
{
|
||||||
code_props destructor;
|
|
||||||
code_props_symbol_action_init (&destructor, code, loc);
|
|
||||||
code_props_translate_code (&destructor);
|
|
||||||
switch (node->content_type)
|
switch (node->content_type)
|
||||||
{
|
{
|
||||||
case SYMLIST_SYMBOL:
|
case SYMLIST_SYMBOL:
|
||||||
symbol_destructor_set (node->content.sym, &destructor);
|
symbol_destructor_set (node->content.sym, destructor);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_TYPE:
|
case SYMLIST_TYPE:
|
||||||
semantic_type_destructor_set (
|
semantic_type_destructor_set (
|
||||||
semantic_type_get (node->content.type_name), &destructor);
|
semantic_type_get (node->content.type_name), destructor);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_DEFAULT_TAGGED:
|
case SYMLIST_DEFAULT_TAGGED:
|
||||||
default_tagged_destructor_set (&destructor);
|
default_tagged_destructor_set (destructor);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_DEFAULT_TAGLESS:
|
case SYMLIST_DEFAULT_TAGLESS:
|
||||||
default_tagless_destructor_set (&destructor);
|
default_tagless_destructor_set (destructor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
symbol_list_printer_set (symbol_list *node, char const *code, location loc)
|
symbol_list_printer_set (symbol_list *node, code_props const *printer)
|
||||||
{
|
{
|
||||||
code_props printer;
|
|
||||||
code_props_symbol_action_init (&printer, code, loc);
|
|
||||||
code_props_translate_code (&printer);
|
|
||||||
switch (node->content_type)
|
switch (node->content_type)
|
||||||
{
|
{
|
||||||
case SYMLIST_SYMBOL:
|
case SYMLIST_SYMBOL:
|
||||||
symbol_printer_set (node->content.sym, &printer);
|
symbol_printer_set (node->content.sym, printer);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_TYPE:
|
case SYMLIST_TYPE:
|
||||||
semantic_type_printer_set (
|
semantic_type_printer_set (
|
||||||
semantic_type_get (node->content.type_name), &printer);
|
semantic_type_get (node->content.type_name), printer);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_DEFAULT_TAGGED:
|
case SYMLIST_DEFAULT_TAGGED:
|
||||||
default_tagged_printer_set (&printer);
|
default_tagged_printer_set (printer);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_DEFAULT_TAGLESS:
|
case SYMLIST_DEFAULT_TAGLESS:
|
||||||
default_tagless_printer_set (&printer);
|
default_tagless_printer_set (printer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -119,11 +119,11 @@ uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n);
|
|||||||
bool symbol_list_null (symbol_list *node);
|
bool symbol_list_null (symbol_list *node);
|
||||||
|
|
||||||
/** Set the \c \%destructor for \c node as \c code at \c loc. */
|
/** Set the \c \%destructor for \c node as \c code at \c loc. */
|
||||||
void symbol_list_destructor_set (symbol_list *node, char const *code,
|
void symbol_list_destructor_set (symbol_list *node,
|
||||||
location loc);
|
code_props const *destructor);
|
||||||
|
|
||||||
/** Set the \c \%printer for \c node as \c code at \c loc. */
|
/** Set the \c \%printer for \c node as \c code at \c loc. */
|
||||||
void symbol_list_printer_set (symbol_list *node, char const *code,
|
void symbol_list_printer_set (symbol_list *node,
|
||||||
location loc);
|
code_props const *printer);
|
||||||
|
|
||||||
#endif /* !SYMLIST_H_ */
|
#endif /* !SYMLIST_H_ */
|
||||||
|
|||||||
+14
-7
@@ -60,23 +60,30 @@ struct symbol
|
|||||||
/** The location of its first occurrence. */
|
/** The location of its first occurrence. */
|
||||||
location location;
|
location location;
|
||||||
|
|
||||||
/** Its \c \%type. */
|
/** Its \c \%type.
|
||||||
|
|
||||||
|
Beware that this is the type_name as was entered by the user,
|
||||||
|
including silly things such as "]" if she entered "%token <]> t".
|
||||||
|
Therefore, when outputting type_name to M4, be sure to escape it
|
||||||
|
into "@}". See quoted_output for instance. */
|
||||||
uniqstr type_name;
|
uniqstr type_name;
|
||||||
|
|
||||||
/** Its \c \%type's location. */
|
/** Its \c \%type's location. */
|
||||||
location type_location;
|
location type_location;
|
||||||
|
|
||||||
/** Any \c \%destructor declared specifically for this symbol.
|
/** Any \c \%destructor declared specifically for this symbol.
|
||||||
|
|
||||||
Access this field only through <tt>symbol</tt>'s interface functions. For
|
Access this field only through <tt>symbol</tt>'s interface
|
||||||
example, if <tt>symbol::destructor = NULL</tt>, a default \c \%destructor
|
functions. For example, if <tt>symbol::destructor = NULL</tt>, a
|
||||||
or a per-type \c \%destructor might be appropriate, and
|
default \c \%destructor or a per-type \c \%destructor might be
|
||||||
\c symbol_destructor_get will compute the correct one. */
|
appropriate, and \c symbol_destructor_get will compute the
|
||||||
|
correct one. */
|
||||||
code_props destructor;
|
code_props destructor;
|
||||||
|
|
||||||
/** Any \c \%printer declared specifically for this symbol.
|
/** Any \c \%printer declared specifically for this symbol.
|
||||||
|
|
||||||
Access this field only through <tt>symbol</tt>'s interface functions.
|
Access this field only through <tt>symbol</tt>'s interface functions.
|
||||||
\sa symbol::destructor */
|
\sa symbol::destructor */
|
||||||
code_props printer;
|
code_props printer;
|
||||||
|
|
||||||
symbol_number number;
|
symbol_number number;
|
||||||
|
|||||||
+48
-38
@@ -160,36 +160,50 @@ typedef size_t uintptr_t;
|
|||||||
# define obstack_chunk_free free
|
# define obstack_chunk_free free
|
||||||
# include <obstack.h>
|
# include <obstack.h>
|
||||||
|
|
||||||
# define obstack_sgrow(Obs, Str) \
|
# define obstack_sgrow(Obs, Str) \
|
||||||
obstack_grow (Obs, Str, strlen (Str))
|
obstack_grow (Obs, Str, strlen (Str))
|
||||||
|
|
||||||
# define obstack_fgrow1(Obs, Format, Arg1) \
|
/* Output Str escaped for our postprocessing (i.e., escape M4 special
|
||||||
do { \
|
characters).
|
||||||
char buf[4096]; \
|
|
||||||
sprintf (buf, Format, Arg1); \
|
|
||||||
obstack_grow (Obs, buf, strlen (buf)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
# define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
|
For instance "[foo]" -> "@{foo@}", "$$" -> "$][$][". */
|
||||||
do { \
|
|
||||||
char buf[4096]; \
|
# define obstack_escape(Obs, Str) \
|
||||||
sprintf (buf, Format, Arg1, Arg2); \
|
do { \
|
||||||
obstack_grow (Obs, buf, strlen (buf)); \
|
char const *p; \
|
||||||
} while (0)
|
for (p = Str; *p; p++) \
|
||||||
|
switch (*p) \
|
||||||
|
{ \
|
||||||
|
case '$': obstack_sgrow (Obs, "$]["); break; \
|
||||||
|
case '@': obstack_sgrow (Obs, "@@" ); break; \
|
||||||
|
case '[': obstack_sgrow (Obs, "@{" ); break; \
|
||||||
|
case ']': obstack_sgrow (Obs, "@}" ); break; \
|
||||||
|
default: obstack_1grow (Obs, *p ); break; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
/* Output Str both quoted for M4 (i.e., embed in [[...]]), and escaped
|
||||||
|
for our postprocessing (i.e., escape M4 special characters). If
|
||||||
|
Str is empty (or NULL), output "[]" instead of "[[]]" as it make M4
|
||||||
|
programming easier (m4_ifval can be used).
|
||||||
|
|
||||||
|
For instance "[foo]" -> "[[@{foo@}]]", "$$" -> "[[$][$][]]". */
|
||||||
|
|
||||||
|
# define obstack_quote(Obs, Str) \
|
||||||
|
do { \
|
||||||
|
char const* obstack_quote_p = Str; \
|
||||||
|
if (obstack_quote_p && obstack_quote_p[0]) \
|
||||||
|
{ \
|
||||||
|
obstack_sgrow (Obs, "[["); \
|
||||||
|
obstack_escape (Obs, obstack_quote_p); \
|
||||||
|
obstack_sgrow (Obs, "]]"); \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
obstack_sgrow (Obs, "[]"); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
# define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
|
|
||||||
do { \
|
|
||||||
char buf[4096]; \
|
|
||||||
sprintf (buf, Format, Arg1, Arg2, Arg3); \
|
|
||||||
obstack_grow (Obs, buf, strlen (buf)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
# define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
|
|
||||||
do { \
|
|
||||||
char buf[4096]; \
|
|
||||||
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
|
|
||||||
obstack_grow (Obs, buf, strlen (buf)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -205,25 +219,21 @@ do { \
|
|||||||
# define TAB_EXT ".tab"
|
# define TAB_EXT ".tab"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef DEFAULT_TMPDIR
|
|
||||||
# define DEFAULT_TMPDIR "/tmp"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------.
|
/*---------------------.
|
||||||
| Free a linked list. |
|
| Free a linked list. |
|
||||||
`---------------------*/
|
`---------------------*/
|
||||||
|
|
||||||
# define LIST_FREE(Type, List) \
|
# define LIST_FREE(Type, List) \
|
||||||
do { \
|
do { \
|
||||||
Type *_node, *_next; \
|
Type *_node, *_next; \
|
||||||
for (_node = List; _node; _node = _next) \
|
for (_node = List; _node; _node = _next) \
|
||||||
{ \
|
{ \
|
||||||
_next = _node->next; \
|
_next = _node->next; \
|
||||||
free (_node); \
|
free (_node); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------.
|
/*---------------------------------------------.
|
||||||
|
|||||||
+5
-5
@@ -73,23 +73,23 @@ check-local: atconfig atlocal $(TESTSUITE)
|
|||||||
check_SCRIPTS = bison
|
check_SCRIPTS = bison
|
||||||
|
|
||||||
# Run the test suite on the *installed* tree.
|
# Run the test suite on the *installed* tree.
|
||||||
installcheck-local:
|
installcheck-local: atconfig atlocal $(TESTSUITE)
|
||||||
$(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
|
$(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
|
||||||
|
|
||||||
# Be real mean with it.
|
# Be real mean with it.
|
||||||
.PHONY: maintainer-check-g++
|
.PHONY: maintainer-check-g++
|
||||||
maintainer-check-g++: $(TESTSUITE)
|
maintainer-check-g++: atconfig atlocal $(TESTSUITE)
|
||||||
$(TESTSUITE) $(TESTSUITEFLAGS) --compile-c-with-cxx
|
$(TESTSUITE) $(TESTSUITEFLAGS) --compile-c-with-cxx
|
||||||
|
|
||||||
.PHONY: maintainer-check-posix
|
.PHONY: maintainer-check-posix
|
||||||
maintainer-check-posix: $(TESTSUITE)
|
maintainer-check-posix: atconfig atlocal $(TESTSUITE)
|
||||||
$(TESTSUITE) $(TESTSUITEFLAGS) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112
|
$(TESTSUITE) $(TESTSUITEFLAGS) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112
|
||||||
|
|
||||||
.PHONY: maintainer-check-valgrind
|
.PHONY: maintainer-check-valgrind
|
||||||
maintainer-check-valgrind: $(TESTSUITE)
|
maintainer-check-valgrind: atconfig atlocal $(TESTSUITE)
|
||||||
test -z '$(VALGRIND)' || \
|
test -z '$(VALGRIND)' || \
|
||||||
$(TESTSUITE) $(TESTSUITEFLAGS) \
|
$(TESTSUITE) $(TESTSUITEFLAGS) \
|
||||||
PREBISON='$(VALGRIND) -q' PREPARSER='$(VALGRIND) -q' \
|
PREBISON='$(VALGRIND_PREBISON)' PREPARSER='$(VALGRIND) -q' \
|
||||||
VALGRIND_OPTS='--leak-check=full --show-reachable=yes'
|
VALGRIND_OPTS='--leak-check=full --show-reachable=yes'
|
||||||
|
|
||||||
.PHONY: maintainer-check
|
.PHONY: maintainer-check
|
||||||
|
|||||||
+284
-286
File diff suppressed because it is too large
Load Diff
+8
-3
@@ -29,9 +29,11 @@ CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@"
|
|||||||
# Is the compiler GCC?
|
# Is the compiler GCC?
|
||||||
GCC='@GCC@'
|
GCC='@GCC@'
|
||||||
|
|
||||||
# We want no optimization.
|
# We want no optimization, as they uncover warnings (therefore,
|
||||||
O0CFLAGS=`echo '@CFLAGS@' | sed 's/-O[0-9] *//'`
|
# failures) about uninitialized variables in the test suite. FIXME:
|
||||||
O0CXXFLAGS=`echo '@CXXFLAGS@' | sed 's/-O[0-9] *//'`
|
# fix the warnings, not the flags.
|
||||||
|
O0CFLAGS=`echo '@CFLAGS@' | sed 's/-O[0-9s] *//g'`
|
||||||
|
O0CXXFLAGS=`echo '@CXXFLAGS@' | sed 's/-O[0-9s] *//g'`
|
||||||
|
|
||||||
# Sometimes a test group needs to ignore gcc warnings, so it locally
|
# Sometimes a test group needs to ignore gcc warnings, so it locally
|
||||||
# sets CFLAGS to this.
|
# sets CFLAGS to this.
|
||||||
@@ -47,10 +49,13 @@ BISON_CXX_WORKS='@BISON_CXX_WORKS@'
|
|||||||
|
|
||||||
# Handle --compile-c-with-cxx here, once CXX and CXXFLAGS are known.
|
# Handle --compile-c-with-cxx here, once CXX and CXXFLAGS are known.
|
||||||
if "$at_arg_compile_c_with_cxx"; then
|
if "$at_arg_compile_c_with_cxx"; then
|
||||||
|
CC_IS_CXX=1
|
||||||
CC=$CXX
|
CC=$CXX
|
||||||
O0CFLAGS=$O0CXXFLAGS
|
O0CFLAGS=$O0CXXFLAGS
|
||||||
NO_WERROR_CFLAGS=$NO_WERROR_CXXFLAGS
|
NO_WERROR_CFLAGS=$NO_WERROR_CXXFLAGS
|
||||||
CFLAGS=$CXXFLAGS
|
CFLAGS=$CXXFLAGS
|
||||||
|
else
|
||||||
|
CC_IS_CXX=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+153
-124
@@ -33,21 +33,90 @@
|
|||||||
# Don't call this macro directly, because it contains some occurrences
|
# Don't call this macro directly, because it contains some occurrences
|
||||||
# of `$1' etc. which will be interpreted by m4. So you should call it
|
# of `$1' etc. which will be interpreted by m4. So you should call it
|
||||||
# with $1, $2, and $3 as arguments, which is what AT_DATA_CALC_Y does.
|
# with $1, $2, and $3 as arguments, which is what AT_DATA_CALC_Y does.
|
||||||
|
#
|
||||||
|
# When %defines is not passed, generate a single self-contained file.
|
||||||
|
# Otherwise, generate three: calc.y with the parser, calc-lex.c with
|
||||||
|
# the scanner, and calc-main.c with "main()". This is in order to
|
||||||
|
# stress the use of the generated parser header. To avoid code
|
||||||
|
# duplication, AT_CALC_LEX and AT_CALC_MAIN contain the body of these
|
||||||
|
# two later files.
|
||||||
m4_define([_AT_DATA_CALC_Y],
|
m4_define([_AT_DATA_CALC_Y],
|
||||||
[m4_if([$1$2$3], $[1]$[2]$[3], [],
|
[m4_if([$1$2$3], $[1]$[2]$[3], [],
|
||||||
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
||||||
|
|
||||||
|
m4_pushdef([AT_CALC_MAIN],
|
||||||
|
[#include <assert.h>
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#else
|
||||||
|
# undef alarm
|
||||||
|
# define alarm(seconds) /* empty */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AT_SKEL_CC_IF([[
|
||||||
|
/* A C++ ]AT_NAME_PREFIX[parse that simulates the C signature. */
|
||||||
|
int
|
||||||
|
]AT_NAME_PREFIX[parse (]AT_PARAM_IF([semantic_value *result, int *count]))[
|
||||||
|
{
|
||||||
|
]AT_NAME_PREFIX[::parser parser]AT_PARAM_IF([ (result, count)])[;
|
||||||
|
#if ]AT_API_PREFIX[DEBUG
|
||||||
|
parser.set_debug_level (1);
|
||||||
|
#endif
|
||||||
|
return parser.parse ();
|
||||||
|
}
|
||||||
|
]])[
|
||||||
|
|
||||||
|
semantic_value global_result = 0;
|
||||||
|
int global_count = 0;
|
||||||
|
|
||||||
|
/* A C main function. */
|
||||||
|
int
|
||||||
|
main (int argc, const char **argv)
|
||||||
|
{
|
||||||
|
semantic_value result = 0;
|
||||||
|
int count = 0;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
/* This used to be alarm (10), but that isn't enough time for
|
||||||
|
a July 1995 vintage DEC Alphastation 200 4/100 system,
|
||||||
|
according to Nelson H. F. Beebe. 100 seconds is enough. */
|
||||||
|
alarm (100);
|
||||||
|
|
||||||
|
if (argc == 2)
|
||||||
|
input = fopen (argv[1], "r");
|
||||||
|
else
|
||||||
|
input = stdin;
|
||||||
|
|
||||||
|
if (!input)
|
||||||
|
{
|
||||||
|
perror (argv[1]);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
]AT_SKEL_CC_IF([], [m4_bmatch([$4], [%debug],
|
||||||
|
[ ]AT_NAME_PREFIX[debug = 1;])])[
|
||||||
|
status = ]AT_NAME_PREFIX[parse (]AT_PARAM_IF([[&result, &count]])[);
|
||||||
|
if (fclose (input))
|
||||||
|
perror ("fclose");
|
||||||
|
assert (global_result == result);
|
||||||
|
assert (global_count == count);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
m4_pushdef([AT_CALC_LEX],
|
m4_pushdef([AT_CALC_LEX],
|
||||||
[[#include <ctype.h>
|
[[#include <ctype.h>
|
||||||
|
|
||||||
int ]AT_NAME_PREFIX[lex (]AT_LEX_FORMALS[);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
static int get_char (]AT_LEX_FORMALS[);
|
static int get_char (]AT_YYLEX_FORMALS[);
|
||||||
static void unget_char (]AT_LEX_PRE_FORMALS[ int c);
|
static void unget_char (]AT_YYLEX_PRE_FORMALS[ int c);
|
||||||
|
|
||||||
]AT_LOCATION_IF([
|
]AT_LOCATION_IF([
|
||||||
static YYLTYPE last_yylloc;
|
static AT_YYLTYPE last_yylloc;
|
||||||
])[
|
])[
|
||||||
static int
|
static int
|
||||||
get_char (]AT_LEX_FORMALS[)
|
get_char (]AT_YYLEX_FORMALS[)
|
||||||
{
|
{
|
||||||
int res = getc (input);
|
int res = getc (input);
|
||||||
]AT_USE_LEX_ARGS[;
|
]AT_USE_LEX_ARGS[;
|
||||||
@@ -65,7 +134,7 @@ get_char (]AT_LEX_FORMALS[)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unget_char (]AT_LEX_PRE_FORMALS[ int c)
|
unget_char (]AT_YYLEX_PRE_FORMALS[ int c)
|
||||||
{
|
{
|
||||||
]AT_USE_LEX_ARGS[;
|
]AT_USE_LEX_ARGS[;
|
||||||
]AT_LOCATION_IF([
|
]AT_LOCATION_IF([
|
||||||
@@ -76,26 +145,26 @@ unget_char (]AT_LEX_PRE_FORMALS[ int c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
read_signed_integer (]AT_LEX_FORMALS[)
|
read_signed_integer (]AT_YYLEX_FORMALS[)
|
||||||
{
|
{
|
||||||
int c = get_char (]AT_LEX_ARGS[);
|
int c = get_char (]AT_YYLEX_ARGS[);
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
]AT_USE_LEX_ARGS[;
|
]AT_USE_LEX_ARGS[;
|
||||||
if (c == '-')
|
if (c == '-')
|
||||||
{
|
{
|
||||||
c = get_char (]AT_LEX_ARGS[);
|
c = get_char (]AT_YYLEX_ARGS[);
|
||||||
sign = -1;
|
sign = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (isdigit (c))
|
while (isdigit (c))
|
||||||
{
|
{
|
||||||
n = 10 * n + (c - '0');
|
n = 10 * n + (c - '0');
|
||||||
c = get_char (]AT_LEX_ARGS[);
|
c = get_char (]AT_YYLEX_ARGS[);
|
||||||
}
|
}
|
||||||
|
|
||||||
unget_char (]AT_LEX_PRE_ARGS[ c);
|
unget_char (]AT_YYLEX_PRE_ARGS[ c);
|
||||||
|
|
||||||
return sign * n;
|
return sign * n;
|
||||||
}
|
}
|
||||||
@@ -107,8 +176,7 @@ read_signed_integer (]AT_LEX_FORMALS[)
|
|||||||
| blanks and tabs, returns 0 for EOF. |
|
| blanks and tabs, returns 0 for EOF. |
|
||||||
`---------------------------------------------------------------*/
|
`---------------------------------------------------------------*/
|
||||||
|
|
||||||
int
|
]AT_YYLEX_PROTOTYPE[
|
||||||
]AT_NAME_PREFIX[lex (]AT_LEX_FORMALS[)
|
|
||||||
{
|
{
|
||||||
static int init = 1;
|
static int init = 1;
|
||||||
int c;
|
int c;
|
||||||
@@ -130,13 +198,13 @@ int
|
|||||||
AT_LOC_FIRST_LINE = AT_LOC_LAST_LINE;
|
AT_LOC_FIRST_LINE = AT_LOC_LAST_LINE;
|
||||||
])[
|
])[
|
||||||
}
|
}
|
||||||
while ((c = get_char (]AT_LEX_ARGS[)) == ' ' || c == '\t');
|
while ((c = get_char (]AT_YYLEX_ARGS[)) == ' ' || c == '\t');
|
||||||
|
|
||||||
/* process numbers */
|
/* process numbers */
|
||||||
if (c == '.' || isdigit (c))
|
if (c == '.' || isdigit (c))
|
||||||
{
|
{
|
||||||
unget_char (]AT_LEX_PRE_ARGS[ c);
|
unget_char (]AT_YYLEX_PRE_ARGS[ c);
|
||||||
]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
|
]AT_VAL[.ival = read_signed_integer (]AT_YYLEX_ARGS[);
|
||||||
return NUM;
|
return NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,61 +264,47 @@ AT_SKEL_CC_IF(
|
|||||||
|
|
||||||
%code provides
|
%code provides
|
||||||
{
|
{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
/* The input. */
|
/* The input. */
|
||||||
extern FILE *input;]AT_SKEL_CC_IF([[
|
extern FILE *input;
|
||||||
#ifndef YYLTYPE
|
extern semantic_value global_result;
|
||||||
# define YYLTYPE ]AT_NAME_PREFIX[::parser::location_type
|
extern int global_count;
|
||||||
#endif
|
|
||||||
]])[
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%code
|
%code
|
||||||
{
|
{
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#if HAVE_UNISTD_H
|
|
||||||
# include <unistd.h>
|
|
||||||
#else
|
|
||||||
# undef alarm
|
|
||||||
# define alarm(seconds) /* empty */
|
|
||||||
#endif
|
|
||||||
#define USE(Var)
|
#define USE(Var)
|
||||||
|
|
||||||
FILE *input;
|
FILE *input;
|
||||||
static semantic_value global_result = 0;
|
|
||||||
static int global_count = 0;
|
|
||||||
static int power (int base, int exponent);
|
static int power (int base, int exponent);
|
||||||
|
|
||||||
]AT_SKEL_CC_IF(,
|
]AT_SKEL_CC_IF(,
|
||||||
[/* yyerror receives the location if:
|
[static void yyerror (AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])
|
||||||
- %location & %pure & %glr
|
|
||||||
- %location & %pure & %yacc & %parse-param. */
|
|
||||||
static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
|
|
||||||
AT_PARAM_IF([semantic_value *result, int *count, ])
|
AT_PARAM_IF([semantic_value *result, int *count, ])
|
||||||
const char *s
|
const char *s
|
||||||
);])[
|
);])[
|
||||||
int yylex (]AT_LEX_FORMALS[);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
}
|
}
|
||||||
|
|
||||||
]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [
|
]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [[
|
||||||
/* The lalr1.cc skeleton, for backward compatibility, defines
|
/* The lalr1.cc skeleton, for backward compatibility, defines
|
||||||
a constructor for position that initializes the filename. The
|
a constructor for position that initializes the filename. The
|
||||||
glr.cc skeleton does not (and in fact cannot: location/position
|
glr.cc skeleton does not (and in fact cannot: location/position
|
||||||
are stored in a union, from which objects with constructors are
|
are stored in a union, from which objects with constructors are
|
||||||
excluded in C++. */
|
excluded in C++). */
|
||||||
%initial-action {
|
%initial-action {
|
||||||
@$.initialize ();
|
@$.initialize ();
|
||||||
}
|
}
|
||||||
])])[
|
]])])[
|
||||||
|
|
||||||
/* Bison Declarations */
|
/* Bison Declarations */
|
||||||
%token CALC_EOF 0 "end of input"
|
%token CALC_EOF 0 "end of input"
|
||||||
%token <ival> NUM "number"
|
%token <ival> NUM "number"
|
||||||
%type <ival> exp
|
%type <ival> exp
|
||||||
|
|
||||||
%nonassoc '=' /* comparison */
|
%nonassoc '=' /* comparison */
|
||||||
%left '-' '+'
|
%left '-' '+'
|
||||||
%left '*' '/'
|
%left '*' '/'
|
||||||
%left NEG /* negation--unary minus */
|
%left NEG /* negation--unary minus */
|
||||||
@@ -289,6 +343,16 @@ exp:
|
|||||||
;
|
;
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
static int
|
||||||
|
power (int base, int exponent)
|
||||||
|
{
|
||||||
|
int res = 1;
|
||||||
|
assert (0 <= exponent);
|
||||||
|
for (/* Niente */; exponent; --exponent)
|
||||||
|
res *= base;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
]AT_SKEL_CC_IF(
|
]AT_SKEL_CC_IF(
|
||||||
[AT_LOCATION_TYPE_IF([[
|
[AT_LOCATION_TYPE_IF([[
|
||||||
std::ostream&
|
std::ostream&
|
||||||
@@ -302,29 +366,10 @@ exp:
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_YYERROR_DEFINE],
|
||||||
/* A C++ error reporting function. */
|
|
||||||
void
|
|
||||||
AT_NAME_PREFIX::parser::error (const location_type& l, const std::string& m)
|
|
||||||
{
|
|
||||||
(void) l;
|
|
||||||
std::cerr << AT_LOCATION_IF([l << ": " << ])m << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A C++ yyparse that simulates the C signature. */
|
|
||||||
int
|
|
||||||
yyparse (AT_PARAM_IF([semantic_value *result, int *count]))
|
|
||||||
{
|
|
||||||
AT_NAME_PREFIX::parser parser[]AT_PARAM_IF([ (result, count)]);
|
|
||||||
#if YYDEBUG
|
|
||||||
parser.set_debug_level (1);
|
|
||||||
#endif
|
|
||||||
return parser.parse ();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[/* A C error reporting function. */
|
[/* A C error reporting function. */
|
||||||
static void
|
static void
|
||||||
yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
|
yyerror (AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])
|
||||||
AT_PARAM_IF([semantic_value *result, int *count, ])
|
AT_PARAM_IF([semantic_value *result, int *count, ])
|
||||||
const char *s)
|
const char *s)
|
||||||
{
|
{
|
||||||
@@ -334,67 +379,27 @@ AT_YYERROR_SEES_LOC_IF([
|
|||||||
AT_LOC_FIRST_LINE, AT_LOC_FIRST_COLUMN);
|
AT_LOC_FIRST_LINE, AT_LOC_FIRST_COLUMN);
|
||||||
if (AT_LOC_FIRST_LINE != AT_LOC_LAST_LINE)
|
if (AT_LOC_FIRST_LINE != AT_LOC_LAST_LINE)
|
||||||
fprintf (stderr, "-%d.%d",
|
fprintf (stderr, "-%d.%d",
|
||||||
AT_LOC_LAST_LINE, AT_LOC_LAST_COLUMN - 1);
|
AT_LOC_LAST_LINE, AT_LOC_LAST_COLUMN - 1);
|
||||||
else if (AT_LOC_FIRST_COLUMN != AT_LOC_LAST_COLUMN - 1)
|
else if (AT_LOC_FIRST_COLUMN != AT_LOC_LAST_COLUMN - 1)
|
||||||
fprintf (stderr, "-%d",
|
fprintf (stderr, "-%d",
|
||||||
AT_LOC_LAST_COLUMN - 1);
|
AT_LOC_LAST_COLUMN - 1);
|
||||||
fprintf (stderr, ": ");])
|
fprintf (stderr, ": ");])
|
||||||
fprintf (stderr, "%s\n", s);
|
fprintf (stderr, "%s\n", s);
|
||||||
}])[
|
}])[
|
||||||
|
]AT_DEFINES_IF([],
|
||||||
|
[AT_CALC_LEX
|
||||||
|
AT_CALC_MAIN])])
|
||||||
|
|
||||||
]AT_DEFINES_IF(, [AT_CALC_LEX])[
|
|
||||||
|
|
||||||
static int
|
|
||||||
power (int base, int exponent)
|
|
||||||
{
|
|
||||||
int res = 1;
|
|
||||||
assert (0 <= exponent);
|
|
||||||
for (/* Niente */; exponent; --exponent)
|
|
||||||
res *= base;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* A C main function. */
|
|
||||||
int
|
|
||||||
main (int argc, const char **argv)
|
|
||||||
{
|
|
||||||
semantic_value result = 0;
|
|
||||||
int count = 0;
|
|
||||||
int status;
|
|
||||||
|
|
||||||
/* This used to be alarm (10), but that isn't enough time for
|
|
||||||
a July 1995 vintage DEC Alphastation 200 4/100 system,
|
|
||||||
according to Nelson H. F. Beebe. 100 seconds is enough. */
|
|
||||||
alarm (100);
|
|
||||||
|
|
||||||
if (argc == 2)
|
|
||||||
input = fopen (argv[1], "r");
|
|
||||||
else
|
|
||||||
input = stdin;
|
|
||||||
|
|
||||||
if (!input)
|
|
||||||
{
|
|
||||||
perror (argv[1]);
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
]AT_SKEL_CC_IF([], [m4_bmatch([$4], [%debug],
|
|
||||||
[ yydebug = 1;])])[
|
|
||||||
status = yyparse (]AT_PARAM_IF([[&result, &count]])[);
|
|
||||||
if (fclose (input))
|
|
||||||
perror ("fclose");
|
|
||||||
if (global_result != result)
|
|
||||||
abort ();
|
|
||||||
if (global_count != count)
|
|
||||||
abort ();
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
]])
|
|
||||||
AT_DEFINES_IF([AT_DATA_SOURCE([[calc-lex.c]AT_SKEL_CC_IF([[c]])],
|
AT_DEFINES_IF([AT_DATA_SOURCE([[calc-lex.c]AT_SKEL_CC_IF([[c]])],
|
||||||
[[#include "calc.h]AT_SKEL_CC_IF([[h]])["
|
[[#include "calc.h]AT_SKEL_CC_IF([[h]])["
|
||||||
|
|
||||||
]AT_CALC_LEX])])
|
]AT_CALC_LEX])
|
||||||
|
AT_DATA_SOURCE([[calc-main.c]AT_SKEL_CC_IF([[c]])],
|
||||||
|
[[#include "calc.h]AT_SKEL_CC_IF([[h]])["
|
||||||
|
|
||||||
|
]AT_CALC_MAIN])
|
||||||
|
])
|
||||||
|
m4_popdef([AT_CALC_MAIN])
|
||||||
m4_popdef([AT_CALC_LEX])
|
m4_popdef([AT_CALC_LEX])
|
||||||
])# _AT_DATA_CALC_Y
|
])# _AT_DATA_CALC_Y
|
||||||
|
|
||||||
@@ -493,21 +498,36 @@ AT_CHECK([cat stderr], 0, [expout])
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
# AT_CHECK_CALC([BISON-OPTIONS, [EXPECTED-TO-FAIL]])
|
# AT_CHECK_SPACES([FILE])
|
||||||
# --------------------------------------------------
|
# -----------------------
|
||||||
|
# Make sure we did not introduce bad spaces. Checked here because all
|
||||||
|
# the skeletons are (or should be) exercized here.
|
||||||
|
m4_define([AT_CHECK_SPACES],
|
||||||
|
[# No initial empty lines.
|
||||||
|
AT_CHECK([sed -ne '/./q;=;p;' $1])
|
||||||
|
# No trailing spaces.
|
||||||
|
# FIXME: For 2.7: AT_CHECK([sed -ne '/[ ]$/{=;p;}' $1])
|
||||||
|
# No final empty lines.
|
||||||
|
AT_CHECK([sed -ne '${/^$/{=;p;};}' $1])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# AT_CHECK_CALC([BISON-OPTIONS])
|
||||||
|
# ------------------------------
|
||||||
# Start a testing chunk which compiles `calc' grammar with
|
# Start a testing chunk which compiles `calc' grammar with
|
||||||
# BISON-OPTIONS, and performs several tests over the parser.
|
# BISON-OPTIONS, and performs several tests over the parser.
|
||||||
# However, if EXPECTED-TO-FAIL is nonempty, this test is expected to fail.
|
|
||||||
m4_define([AT_CHECK_CALC],
|
m4_define([AT_CHECK_CALC],
|
||||||
[# We use integers to avoid dependencies upon the precision of doubles.
|
[m4_ifval([$2], [m4_fatal([$0: expected a single argument])])
|
||||||
AT_SETUP([Calculator $1])
|
|
||||||
|
|
||||||
m4_ifval([$2], [AT_CHECK([exit 77])])
|
# We use integers to avoid dependencies upon the precision of doubles.
|
||||||
|
AT_SETUP([Calculator $1])
|
||||||
|
|
||||||
AT_BISON_OPTION_PUSHDEFS([$1])
|
AT_BISON_OPTION_PUSHDEFS([$1])
|
||||||
|
|
||||||
AT_DATA_CALC_Y([$1])
|
AT_DATA_CALC_Y([$1])
|
||||||
AT_FULL_COMPILE([calc], [AT_DEFINES_IF([[lex]])])
|
AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]]))
|
||||||
|
AT_CHECK_SPACES([calc.AT_SKEL_CC_IF([cc], [c])])
|
||||||
|
AT_DEFINES_IF([AT_CHECK_SPACES([calc.AT_SKEL_CC_IF([hh], [h])])])
|
||||||
|
|
||||||
# Test the priorities.
|
# Test the priorities.
|
||||||
_AT_CHECK_CALC([$1],
|
_AT_CHECK_CALC([$1],
|
||||||
@@ -622,14 +642,16 @@ AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %locations])
|
|||||||
AT_CHECK_CALC_LALR([%error-verbose %locations])
|
AT_CHECK_CALC_LALR([%error-verbose %locations])
|
||||||
|
|
||||||
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||||
|
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %define api.prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_LALR([%debug])
|
AT_CHECK_CALC_LALR([%debug])
|
||||||
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||||
|
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||||
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||||
|
|
||||||
|
|
||||||
# ----------------------- #
|
# ----------------------- #
|
||||||
@@ -651,6 +673,7 @@ AT_CHECK_CALC_GLR()
|
|||||||
AT_CHECK_CALC_GLR([%defines])
|
AT_CHECK_CALC_GLR([%defines])
|
||||||
AT_CHECK_CALC_GLR([%locations])
|
AT_CHECK_CALC_GLR([%locations])
|
||||||
AT_CHECK_CALC_GLR([%name-prefix "calc"])
|
AT_CHECK_CALC_GLR([%name-prefix "calc"])
|
||||||
|
AT_CHECK_CALC_GLR([%define api.prefix "calc"])
|
||||||
AT_CHECK_CALC_GLR([%verbose])
|
AT_CHECK_CALC_GLR([%verbose])
|
||||||
AT_CHECK_CALC_GLR([%yacc])
|
AT_CHECK_CALC_GLR([%yacc])
|
||||||
AT_CHECK_CALC_GLR([%error-verbose])
|
AT_CHECK_CALC_GLR([%error-verbose])
|
||||||
@@ -662,10 +685,12 @@ AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbo
|
|||||||
|
|
||||||
AT_CHECK_CALC_GLR([%debug])
|
AT_CHECK_CALC_GLR([%debug])
|
||||||
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||||
|
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||||
|
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------- #
|
# ----------------------------- #
|
||||||
@@ -687,11 +712,13 @@ m4_define([AT_CHECK_CALC_LALR1_CC],
|
|||||||
AT_CHECK_CALC_LALR1_CC([])
|
AT_CHECK_CALC_LALR1_CC([])
|
||||||
AT_CHECK_CALC_LALR1_CC([%define location_type Span])
|
AT_CHECK_CALC_LALR1_CC([%define location_type Span])
|
||||||
AT_CHECK_CALC_LALR1_CC([%error-verbose %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR1_CC([%error-verbose %name-prefix "calc" %verbose %yacc])
|
||||||
|
AT_CHECK_CALC_LALR1_CC([%error-verbose %define api.prefix "calc" %verbose %yacc])
|
||||||
AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||||
|
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -714,6 +741,7 @@ m4_define([AT_CHECK_CALC_GLR_CC],
|
|||||||
AT_CHECK_CALC_GLR_CC([])
|
AT_CHECK_CALC_GLR_CC([])
|
||||||
AT_CHECK_CALC_GLR_CC([%define location_type Span])
|
AT_CHECK_CALC_GLR_CC([%define location_type Span])
|
||||||
AT_CHECK_CALC_GLR_CC([%error-verbose %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_GLR_CC([%error-verbose %name-prefix "calc" %verbose %yacc])
|
||||||
|
AT_CHECK_CALC_GLR_CC([%error-verbose %define api.prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR_CC([%debug])
|
AT_CHECK_CALC_GLR_CC([%debug])
|
||||||
AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
||||||
@@ -721,3 +749,4 @@ AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
|||||||
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||||
|
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||||
|
|||||||
+15
-48
@@ -50,20 +50,17 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([%nonassoc and eof])
|
AT_SETUP([%nonassoc and eof])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#define YYERROR_VERBOSE 1
|
#define YYERROR_VERBOSE 1
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The current argument. */
|
/* The current argument. */
|
||||||
static const char *input;
|
static const char *input;
|
||||||
|
|
||||||
@@ -71,8 +68,7 @@ static int
|
|||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
static size_t toknum;
|
static size_t toknum;
|
||||||
if (! (toknum <= strlen (input)))
|
assert (toknum <= strlen (input));
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
return input[toknum++];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +89,7 @@ main (int argc, const char *argv[])
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
m4_pushdef([AT_NONASSOC_AND_EOF_CHECK],
|
m4_pushdef([AT_NONASSOC_AND_EOF_CHECK],
|
||||||
[AT_BISON_CHECK([$1[ -o input.c input.y]])
|
[AT_BISON_CHECK([$1[ -o input.c input.y]])
|
||||||
@@ -171,7 +168,7 @@ AT_SKEL_JAVA_IF([AT_DATA], [AT_DATA_GRAMMAR])([input.y],
|
|||||||
#include <string>]], [[
|
#include <string>]], [[
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *msg);]])[
|
]AT_YYERROR_DECLARE])[
|
||||||
]AT_YYLEX_PROTOTYPE[;
|
]AT_YYLEX_PROTOTYPE[;
|
||||||
#define USE(Var)
|
#define USE(Var)
|
||||||
}
|
}
|
||||||
@@ -212,31 +209,11 @@ public Object getLVal ()
|
|||||||
*lvalp = 1;
|
*lvalp = 1;
|
||||||
return *input++;
|
return *input++;
|
||||||
}]])[
|
}]])[
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
/*----------.
|
]AT_SKEL_JAVA_IF([[
|
||||||
| yyerror. |
|
|
||||||
`----------*/]AT_SKEL_JAVA_IF([[
|
|
||||||
|
|
||||||
public void yyerror (String msg)
|
|
||||||
{
|
|
||||||
System.err.println (msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
%%]], [AT_SKEL_CC_IF([[
|
%%]])[
|
||||||
|
|
||||||
void
|
|
||||||
yy::parser::error (const yy::location &, std::string const &msg)
|
|
||||||
{
|
|
||||||
std::cerr << msg << std::endl;
|
|
||||||
}]], [[
|
|
||||||
|
|
||||||
void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}]])])[
|
|
||||||
|
|
||||||
/*-------.
|
/*-------.
|
||||||
| main. |
|
| main. |
|
||||||
@@ -471,12 +448,12 @@ AT_CLEANUP
|
|||||||
# with minimal LR parser tables.
|
# with minimal LR parser tables.
|
||||||
|
|
||||||
AT_SETUP([[LAC: %nonassoc requires splitting canonical LR states]])
|
AT_SETUP([[LAC: %nonassoc requires splitting canonical LR states]])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
}
|
}
|
||||||
|
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@@ -513,19 +490,8 @@ look:
|
|||||||
reduce-nonassoc: %prec 'a';
|
reduce-nonassoc: %prec 'a';
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
void
|
]AT_YYLEX_DEFINE(["aaa"])[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
char const *input = "aaa";
|
|
||||||
return *input++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -533,6 +499,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
# Show canonical LR's failure.
|
# Show canonical LR's failure.
|
||||||
AT_BISON_CHECK([[-Dlr.type=canonical-lr -o input.c input.y]],
|
AT_BISON_CHECK([[-Dlr.type=canonical-lr -o input.c input.y]],
|
||||||
|
|||||||
+51
-70
@@ -23,15 +23,15 @@ AT_BANNER([[C++ Type Syntax (GLR).]])
|
|||||||
# and with RESOLVE1 and RESOLVE2 as annotations on the conflicted rule for
|
# and with RESOLVE1 and RESOLVE2 as annotations on the conflicted rule for
|
||||||
# stmt. Then compile the result.
|
# stmt. Then compile the result.
|
||||||
m4_define([_AT_TEST_GLR_CXXTYPES],
|
m4_define([_AT_TEST_GLR_CXXTYPES],
|
||||||
[
|
[AT_BISON_OPTION_PUSHDEFS([%glr-parser $1])
|
||||||
AT_BISON_OPTION_PUSHDEFS([$1])
|
|
||||||
|
|
||||||
AT_DATA_GRAMMAR([types.y],
|
AT_DATA_GRAMMAR([types.y],
|
||||||
[[/* Simplified C++ Type and Expression Grammar. */
|
[[/* Simplified C++ Type and Expression Grammar. */
|
||||||
|
|
||||||
$1
|
$1
|
||||||
|
|
||||||
%{
|
%code requires
|
||||||
|
{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
union Node {
|
union Node {
|
||||||
struct {
|
struct {
|
||||||
@@ -51,33 +51,22 @@ $1
|
|||||||
} term;
|
} term;
|
||||||
};
|
};
|
||||||
typedef union Node Node;
|
typedef union Node Node;
|
||||||
|
#define YYSTYPE Node *
|
||||||
|
}
|
||||||
|
|
||||||
|
%code
|
||||||
|
{
|
||||||
static Node *new_nterm (char const *, Node *, Node *, Node *);
|
static Node *new_nterm (char const *, Node *, Node *, Node *);
|
||||||
static Node *new_term (char *);
|
static Node *new_term (char *);
|
||||||
static void free_node (Node *);
|
static void free_node (Node *);
|
||||||
static char *node_to_string (Node *);
|
static char *node_to_string (Node *);
|
||||||
#define YYSTYPE Node *
|
|
||||||
]m4_bmatch([$2], [stmtMerge],
|
]m4_bmatch([$2], [stmtMerge],
|
||||||
[ static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);])[
|
[ static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);])[
|
||||||
#define YYINITDEPTH 10
|
#define YYINITDEPTH 10
|
||||||
#define YYSTACKEXPANDABLE 1
|
#define YYSTACKEXPANDABLE 1
|
||||||
struct YYLTYPE;
|
]AT_YYERROR_DECLARE[
|
||||||
#if YYPURE
|
]AT_YYLEX_DECLARE[
|
||||||
# if YYLSP_NEEDED
|
}
|
||||||
# define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
|
|
||||||
# define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
|
|
||||||
# else
|
|
||||||
# define LEX_PARAMETERS YYSTYPE *lvalp
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifndef LEX_PARAMETERS
|
|
||||||
# define LEX_PARAMETERS void
|
|
||||||
#endif
|
|
||||||
#ifndef ERROR_PARAMETERS
|
|
||||||
# define ERROR_PARAMETERS char const *s
|
|
||||||
#endif
|
|
||||||
int yylex (LEX_PARAMETERS);
|
|
||||||
void yyerror (ERROR_PARAMETERS);
|
|
||||||
%}
|
|
||||||
|
|
||||||
%token TYPENAME ID
|
%token TYPENAME ID
|
||||||
|
|
||||||
@@ -133,19 +122,20 @@ declarator : ID
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
assert (argc == 2);
|
||||||
abort ();
|
|
||||||
if (!freopen (argv[1], "r", stdin))
|
if (!freopen (argv[1], "r", stdin))
|
||||||
return 3;
|
return 3;
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
]AT_YYERROR_DEFINE[
|
||||||
yylex (LEX_PARAMETERS)
|
|
||||||
|
]AT_YYLEX_PROTOTYPE[
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
int c;
|
int c;
|
||||||
@@ -162,8 +152,7 @@ yylex (LEX_PARAMETERS)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (feof (stdin))
|
assert (!feof (stdin));
|
||||||
abort ();
|
|
||||||
c = getchar ();
|
c = getchar ();
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
@@ -181,11 +170,9 @@ yylex (LEX_PARAMETERS)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
int tok;
|
int tok;]AT_LOCATION_IF([[
|
||||||
#if YYLSP_NEEDED
|
|
||||||
yylloc.first_line = yylloc.last_line = lineNum;
|
yylloc.first_line = yylloc.last_line = lineNum;
|
||||||
yylloc.first_column = colNum;
|
yylloc.first_column = colNum;]])[
|
||||||
#endif
|
|
||||||
if (isalpha (c))
|
if (isalpha (c))
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
@@ -194,8 +181,7 @@ yylex (LEX_PARAMETERS)
|
|||||||
{
|
{
|
||||||
buffer[i++] = c;
|
buffer[i++] = c;
|
||||||
colNum += 1;
|
colNum += 1;
|
||||||
if (i == sizeof buffer - 1)
|
assert (i != sizeof buffer - 1);
|
||||||
abort ();
|
|
||||||
c = getchar ();
|
c = getchar ();
|
||||||
}
|
}
|
||||||
while (isalnum (c) || c == '_');
|
while (isalnum (c) || c == '_');
|
||||||
@@ -210,27 +196,14 @@ yylex (LEX_PARAMETERS)
|
|||||||
colNum += 1;
|
colNum += 1;
|
||||||
tok = c;
|
tok = c;
|
||||||
yylval = YY_NULL;
|
yylval = YY_NULL;
|
||||||
}
|
}]AT_LOCATION_IF([[
|
||||||
#if YYLSP_NEEDED
|
yylloc.last_column = colNum-1;]])[
|
||||||
yylloc.last_column = colNum-1;
|
|
||||||
#endif
|
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
yyerror (ERROR_PARAMETERS)
|
|
||||||
{
|
|
||||||
#if YYPURE && YYLSP_NEEDED
|
|
||||||
/* Pacify GCC by using llocp. */
|
|
||||||
if (! llocp)
|
|
||||||
abort ();
|
|
||||||
#endif
|
|
||||||
fprintf (stderr, "%s\n", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Node *
|
static Node *
|
||||||
new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
|
new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
|
||||||
{
|
{
|
||||||
@@ -351,7 +324,7 @@ AT_BISON_OPTION_POPDEFS
|
|||||||
])
|
])
|
||||||
|
|
||||||
m4_define([_AT_RESOLVED_GLR_OUTPUT],
|
m4_define([_AT_RESOLVED_GLR_OUTPUT],
|
||||||
[[[+(z,q)
|
[[+(z,q)
|
||||||
<declare>(T,x)
|
<declare>(T,x)
|
||||||
<init-declare>(T,x,y)
|
<init-declare>(T,x,y)
|
||||||
=(x,y)
|
=(x,y)
|
||||||
@@ -360,10 +333,10 @@ m4_define([_AT_RESOLVED_GLR_OUTPUT],
|
|||||||
<init-declare>(T,y,+(z,q))
|
<init-declare>(T,y,+(z,q))
|
||||||
<error>
|
<error>
|
||||||
+(z,q)
|
+(z,q)
|
||||||
]]])
|
]])
|
||||||
|
|
||||||
m4_define([_AT_RESOLVED_GLR_OUTPUT_WITH_LOC],
|
m4_define([_AT_RESOLVED_GLR_OUTPUT_WITH_LOC],
|
||||||
[[[3.0-3.5: +(z,q)
|
[[3.0-3.5: +(z,q)
|
||||||
5.0-5.3: <declare>(T,x)
|
5.0-5.3: <declare>(T,x)
|
||||||
7.0-7.7: <init-declare>(T,x,y)
|
7.0-7.7: <init-declare>(T,x,y)
|
||||||
9.0-9.5: =(x,y)
|
9.0-9.5: =(x,y)
|
||||||
@@ -372,10 +345,10 @@ m4_define([_AT_RESOLVED_GLR_OUTPUT_WITH_LOC],
|
|||||||
15.0-15.13: <init-declare>(T,y,+(z,q))
|
15.0-15.13: <init-declare>(T,y,+(z,q))
|
||||||
17.0-17.15: <error>
|
17.0-17.15: <error>
|
||||||
19.0-19.5: +(z,q)
|
19.0-19.5: +(z,q)
|
||||||
]]])
|
]])
|
||||||
|
|
||||||
m4_define([_AT_AMBIG_GLR_OUTPUT],
|
m4_define([_AT_AMBIG_GLR_OUTPUT],
|
||||||
[[[+(z,q)
|
[[+(z,q)
|
||||||
<declare>(T,x)
|
<declare>(T,x)
|
||||||
<init-declare>(T,x,y)
|
<init-declare>(T,x,y)
|
||||||
=(x,y)
|
=(x,y)
|
||||||
@@ -384,10 +357,10 @@ m4_define([_AT_AMBIG_GLR_OUTPUT],
|
|||||||
<OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
|
<OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
|
||||||
<error>
|
<error>
|
||||||
+(z,q)
|
+(z,q)
|
||||||
]]])
|
]])
|
||||||
|
|
||||||
m4_define([_AT_AMBIG_GLR_OUTPUT_WITH_LOC],
|
m4_define([_AT_AMBIG_GLR_OUTPUT_WITH_LOC],
|
||||||
[[[3.0-3.5: +(z,q)
|
[[3.0-3.5: +(z,q)
|
||||||
5.0-5.3: <declare>(T,x)
|
5.0-5.3: <declare>(T,x)
|
||||||
7.0-7.7: <init-declare>(T,x,y)
|
7.0-7.7: <init-declare>(T,x,y)
|
||||||
9.0-9.5: =(x,y)
|
9.0-9.5: =(x,y)
|
||||||
@@ -396,15 +369,23 @@ m4_define([_AT_AMBIG_GLR_OUTPUT_WITH_LOC],
|
|||||||
15.0-15.13: <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
|
15.0-15.13: <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
|
||||||
17.0-17.15: <error>
|
17.0-17.15: <error>
|
||||||
19.0-19.5: +(z,q)
|
19.0-19.5: +(z,q)
|
||||||
]]])
|
]])
|
||||||
|
|
||||||
m4_define([_AT_GLR_STDERR],
|
m4_define([_AT_GLR_STDERR],
|
||||||
[[[syntax error
|
[[syntax error
|
||||||
]]])
|
]])
|
||||||
|
|
||||||
|
m4_define([_AT_GLR_STDERR_WITH_LOC],
|
||||||
|
[[17.5-4: syntax error
|
||||||
|
]])
|
||||||
|
|
||||||
m4_define([_AT_VERBOSE_GLR_STDERR],
|
m4_define([_AT_VERBOSE_GLR_STDERR],
|
||||||
[[[syntax error, unexpected ID, expecting '=' or '+' or ')'
|
[[syntax error, unexpected ID, expecting '=' or '+' or ')'
|
||||||
]]])
|
]])
|
||||||
|
|
||||||
|
m4_define([_AT_VERBOSE_GLR_STDERR_WITH_LOC],
|
||||||
|
[[17.5-4: syntax error, unexpected ID, expecting '=' or '+' or ')'
|
||||||
|
]])
|
||||||
|
|
||||||
## ---------------------------------------------------- ##
|
## ---------------------------------------------------- ##
|
||||||
## Compile the grammar described in the documentation. ##
|
## Compile the grammar described in the documentation. ##
|
||||||
@@ -414,59 +395,59 @@ AT_SETUP([GLR: Resolve ambiguity, impure, no locations])
|
|||||||
_AT_TEST_GLR_CXXTYPES([],
|
_AT_TEST_GLR_CXXTYPES([],
|
||||||
[%dprec 1], [%dprec 2])
|
[%dprec 1], [%dprec 2])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
|
[_AT_RESOLVED_GLR_OUTPUT], [_AT_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Resolve ambiguity, impure, locations])
|
AT_SETUP([GLR: Resolve ambiguity, impure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%locations],[%dprec 1],[%dprec 2])
|
_AT_TEST_GLR_CXXTYPES([%locations],[%dprec 1],[%dprec 2])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
|
[_AT_RESOLVED_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Resolve ambiguity, pure, no locations])
|
AT_SETUP([GLR: Resolve ambiguity, pure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
||||||
[%dprec 1], [%dprec 2])
|
[%dprec 1], [%dprec 2])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
|
[_AT_RESOLVED_GLR_OUTPUT], [_AT_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Resolve ambiguity, pure, locations])
|
AT_SETUP([GLR: Resolve ambiguity, pure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
|
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
|
||||||
[%dprec 1], [%dprec 2])
|
[%dprec 1], [%dprec 2])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
|
[_AT_RESOLVED_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
|
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([],
|
_AT_TEST_GLR_CXXTYPES([],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
|
[_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
|
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%locations],
|
_AT_TEST_GLR_CXXTYPES([%locations],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
|
[_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
|
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
|
[_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
|
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
|
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
|
||||||
[%merge <stmtMerge>],[%merge <stmtMerge>])
|
[%merge <stmtMerge>],[%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
|
[_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
|
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%error-verbose],
|
_AT_TEST_GLR_CXXTYPES([%error-verbose],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_AMBIG_GLR_OUTPUT, _AT_VERBOSE_GLR_STDERR)
|
[_AT_AMBIG_GLR_OUTPUT], [_AT_VERBOSE_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|||||||
+138
-282
@@ -24,6 +24,7 @@ AT_BANNER([[GLR Regression Tests]])
|
|||||||
|
|
||||||
AT_SETUP([Badly Collapsed GLR States])
|
AT_SETUP([Badly Collapsed GLR States])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr1.y],
|
AT_DATA_GRAMMAR([glr-regr1.y],
|
||||||
[[/* Regression Test: Improper state compression */
|
[[/* Regression Test: Improper state compression */
|
||||||
/* Reported by Scott McPeak */
|
/* Reported by Scott McPeak */
|
||||||
@@ -31,11 +32,12 @@ AT_DATA_GRAMMAR([glr-regr1.y],
|
|||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#define YYSTYPE int
|
#define YYSTYPE int
|
||||||
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
|
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
|
||||||
int yylex (void);
|
]AT_YYERROR_DECLARE[
|
||||||
void yyerror (char const *msg);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,12 +73,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
@@ -84,8 +81,7 @@ yylex (void)
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
if (feof (stdin))
|
assert (!feof (stdin));
|
||||||
abort ();
|
|
||||||
ch = getchar ();
|
ch = getchar ();
|
||||||
if (ch == EOF)
|
if (ch == EOF)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -94,6 +90,7 @@ yylex (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr1.c glr-regr1.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr1.c glr-regr1.y]], 0, [],
|
||||||
[glr-regr1.y: conflicts: 1 shift/reduce
|
[glr-regr1.y: conflicts: 1 shift/reduce
|
||||||
@@ -119,6 +116,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Improper handling of embedded actions and dollar(-N) in GLR parsers])
|
AT_SETUP([Improper handling of embedded actions and dollar(-N) in GLR parsers])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr2a.y],
|
AT_DATA_GRAMMAR([glr-regr2a.y],
|
||||||
[[/* Regression Test: Improper handling of embedded actions and $-N */
|
[[/* Regression Test: Improper handling of embedded actions and $-N */
|
||||||
/* Reported by S. Eken */
|
/* Reported by S. Eken */
|
||||||
@@ -130,8 +128,9 @@ AT_DATA_GRAMMAR([glr-regr2a.y],
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
int yylex (void);
|
#include <assert.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -171,7 +170,7 @@ var_printer: 'v'
|
|||||||
{ printf ("Variable: '%s'\n", $-1); }
|
{ printf ("Variable: '%s'\n", $-1); }
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
FILE *input;
|
FILE *input;
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -179,9 +178,9 @@ yylex (void)
|
|||||||
{
|
{
|
||||||
char buf[50];
|
char buf[50];
|
||||||
char *s;
|
char *s;
|
||||||
if (feof (stdin))
|
assert (!feof (stdin));
|
||||||
abort ();
|
switch (fscanf (input, " %1[a-z,]", buf))
|
||||||
switch (fscanf (input, " %1[a-z,]", buf)) {
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return buf[0];
|
return buf[0];
|
||||||
case EOF:
|
case EOF:
|
||||||
@@ -191,19 +190,13 @@ yylex (void)
|
|||||||
}
|
}
|
||||||
if (fscanf (input, "%49s", buf) != 1)
|
if (fscanf (input, "%49s", buf) != 1)
|
||||||
return 0;
|
return 0;
|
||||||
if (sizeof buf - 1 <= strlen (buf))
|
assert (strlen (buf) < sizeof buf - 1);
|
||||||
abort ();
|
|
||||||
s = (char *) malloc (strlen (buf) + 1);
|
s = (char *) malloc (strlen (buf) + 1);
|
||||||
strcpy (s, buf);
|
strcpy (s, buf);
|
||||||
yylval = s;
|
yylval = s;
|
||||||
return 'V';
|
return 'V';
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
yyerror (char const *s)
|
|
||||||
{ printf ("%s\n", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -212,6 +205,7 @@ main (int argc, char **argv)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr2a.c glr-regr2a.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr2a.c glr-regr2a.y]], 0, [],
|
||||||
[glr-regr2a.y: conflicts: 2 shift/reduce
|
[glr-regr2a.y: conflicts: 2 shift/reduce
|
||||||
@@ -238,6 +232,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Improper merging of GLR delayed action sets])
|
AT_SETUP([Improper merging of GLR delayed action sets])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr3.y],
|
AT_DATA_GRAMMAR([glr-regr3.y],
|
||||||
[[/* Regression Test: Improper merging of GLR delayed action sets. */
|
[[/* Regression Test: Improper merging of GLR delayed action sets. */
|
||||||
/* Reported by M. Rosien */
|
/* Reported by M. Rosien */
|
||||||
@@ -246,10 +241,11 @@ AT_DATA_GRAMMAR([glr-regr3.y],
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
static int MergeRule (int x0, int x1);
|
static int MergeRule (int x0, int x1);
|
||||||
static void yyerror (char const * s);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
|
|
||||||
#define RULE(x) (1 << (x))
|
#define RULE(x) (1 << (x))
|
||||||
|
|
||||||
@@ -290,13 +286,12 @@ NT6 : P1 NT1 O1 T3 P2 { $$ = RULE(11) | $2; } %merge<MergeRule>
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static int MergeRule (int x0, int x1) {
|
static int
|
||||||
|
MergeRule (int x0, int x1)
|
||||||
|
{
|
||||||
return x0 | x1;
|
return x0 | x1;
|
||||||
}
|
}
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void yyerror(char const * s) {
|
|
||||||
fprintf(stderr,"error: %s\n",s);
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE *input = YY_NULL;
|
FILE *input = YY_NULL;
|
||||||
|
|
||||||
@@ -307,8 +302,7 @@ int T[] = { T1, T2, T3, T4 };
|
|||||||
int yylex (void)
|
int yylex (void)
|
||||||
{
|
{
|
||||||
char inp[3];
|
char inp[3];
|
||||||
if (feof (stdin))
|
assert (!feof (stdin));
|
||||||
abort ();
|
|
||||||
if (fscanf (input, "%2s", inp) == EOF)
|
if (fscanf (input, "%2s", inp) == EOF)
|
||||||
return 0;
|
return 0;
|
||||||
switch (inp[0])
|
switch (inp[0])
|
||||||
@@ -320,12 +314,15 @@ int yylex (void)
|
|||||||
return BAD_CHAR;
|
return BAD_CHAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int
|
||||||
|
main(int argc, char* argv[])
|
||||||
|
{
|
||||||
input = stdin;
|
input = stdin;
|
||||||
if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
|
if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr3.c glr-regr3.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr3.c glr-regr3.y]], 0, [],
|
||||||
[glr-regr3.y: conflicts: 1 shift/reduce, 1 reduce/reduce
|
[glr-regr3.y: conflicts: 1 shift/reduce, 1 reduce/reduce
|
||||||
@@ -347,6 +344,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Duplicate representation of merged trees])
|
AT_SETUP([Duplicate representation of merged trees])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr4.y],
|
AT_DATA_GRAMMAR([glr-regr4.y],
|
||||||
[[
|
[[
|
||||||
%union { char *ptr; }
|
%union { char *ptr; }
|
||||||
@@ -359,8 +357,8 @@ AT_DATA_GRAMMAR([glr-regr4.y],
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
static char *merge (YYSTYPE, YYSTYPE);
|
static char *merge (YYSTYPE, YYSTYPE);
|
||||||
static char *make_value (char const *, char const *);
|
static char *make_value (char const *, char const *);
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static char *ptrs[100];
|
static char *ptrs[100];
|
||||||
static char **ptrs_next = ptrs;
|
static char **ptrs_next = ptrs;
|
||||||
%}
|
%}
|
||||||
@@ -384,16 +382,8 @@ A2: 'a' { $$ = make_value ("A2", "'a'"); } ;
|
|||||||
B: 'a' { $$ = make_value ("B", "'a'"); } ;
|
B: 'a' { $$ = make_value ("B", "'a'"); } ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
]AT_YYLEX_DEFINE(["a"])[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "a";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -423,13 +413,8 @@ merge (YYSTYPE s1, YYSTYPE s2)
|
|||||||
sprintf (value, format, s1.ptr, s2.ptr);
|
sprintf (value, format, s1.ptr, s2.ptr);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr4.c glr-regr4.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr4.c glr-regr4.y]], 0, [],
|
||||||
[glr-regr4.y: conflicts: 1 reduce/reduce
|
[glr-regr4.y: conflicts: 1 reduce/reduce
|
||||||
@@ -450,13 +435,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([User destructor for unresolved GLR semantic value])
|
AT_SETUP([User destructor for unresolved GLR semantic value])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr5.y],
|
AT_DATA_GRAMMAR([glr-regr5.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
enum { MAGIC_VALUE = -1057808125 }; /* originally chosen at random */
|
enum { MAGIC_VALUE = -1057808125 }; /* originally chosen at random */
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -480,29 +466,15 @@ start:
|
|||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYLEX_DEFINE(["a"])[
|
||||||
static int
|
]AT_YYERROR_DEFINE[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "a";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse () != 1;
|
return yyparse () != 1;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr5.c glr-regr5.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr5.c glr-regr5.y]], 0, [],
|
||||||
[glr-regr5.y: conflicts: 1 reduce/reduce
|
[glr-regr5.y: conflicts: 1 reduce/reduce
|
||||||
@@ -523,13 +495,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([User destructor after an error during a split parse])
|
AT_SETUP([User destructor after an error during a split parse])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr6.y],
|
AT_DATA_GRAMMAR([glr-regr6.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -545,29 +518,15 @@ AT_DATA_GRAMMAR([glr-regr6.y],
|
|||||||
start: 'a' | 'a' ;
|
start: 'a' | 'a' ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
]AT_YYLEX_DEFINE(["a"])[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "a";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse () != 1;
|
return yyparse () != 1;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr6.c glr-regr6.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr6.c glr-regr6.y]], 0, [],
|
||||||
[glr-regr6.y: conflicts: 1 reduce/reduce
|
[glr-regr6.y: conflicts: 1 reduce/reduce
|
||||||
@@ -590,13 +549,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Duplicated user destructor for lookahead])
|
AT_SETUP([Duplicated user destructor for lookahead])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr7.y],
|
AT_DATA_GRAMMAR([glr-regr7.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
#define YYSTACKEXPANDABLE 0
|
#define YYSTACKEXPANDABLE 0
|
||||||
typedef struct count_node {
|
typedef struct count_node {
|
||||||
int count;
|
int count;
|
||||||
@@ -641,12 +601,7 @@ yylex (void)
|
|||||||
return 'a';
|
return 'a';
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -660,6 +615,7 @@ main (void)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr7.c glr-regr7.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr7.c glr-regr7.y]], 0, [],
|
||||||
[glr-regr7.y: conflicts: 2 reduce/reduce
|
[glr-regr7.y: conflicts: 2 reduce/reduce
|
||||||
@@ -682,14 +638,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Incorrectly initialized location for empty right-hand side in GLR])
|
AT_SETUP([Incorrectly initialized location for empty right-hand side in GLR])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr8.y],
|
AT_DATA_GRAMMAR([glr-regr8.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (char const *msg);
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%token T_CONSTANT
|
%token T_CONSTANT
|
||||||
@@ -723,12 +679,7 @@ OptSignalWord : /* empty */
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lexIndex;
|
static int lexIndex;
|
||||||
|
|
||||||
int yylex (void)
|
int yylex (void)
|
||||||
@@ -758,6 +709,7 @@ main (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr8.c glr-regr8.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr8.c glr-regr8.y]], 0, [],
|
||||||
[glr-regr8.y: conflicts: 1 reduce/reduce
|
[glr-regr8.y: conflicts: 1 reduce/reduce
|
||||||
@@ -780,13 +732,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([No users destructors if stack 0 deleted])
|
AT_SETUP([No users destructors if stack 0 deleted])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr9.y],
|
AT_DATA_GRAMMAR([glr-regr9.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
# define YYSTACKEXPANDABLE 0
|
# define YYSTACKEXPANDABLE 0
|
||||||
static int tokens = 0;
|
static int tokens = 0;
|
||||||
static int destructors = 0;
|
static int destructors = 0;
|
||||||
@@ -822,12 +775,7 @@ yylex (void)
|
|||||||
return 'a';
|
return 'a';
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -841,6 +789,7 @@ main (void)
|
|||||||
return !exit_status;
|
return !exit_status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr9.c glr-regr9.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr9.c glr-regr9.y]], 0, [],
|
||||||
[glr-regr9.y: conflicts: 1 reduce/reduce
|
[glr-regr9.y: conflicts: 1 reduce/reduce
|
||||||
@@ -860,13 +809,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Corrupted semantic options if user action cuts parse])
|
AT_SETUP([Corrupted semantic options if user action cuts parse])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr10.y],
|
AT_DATA_GRAMMAR([glr-regr10.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
#define GARBAGE_SIZE 50
|
#define GARBAGE_SIZE 50
|
||||||
static char garbage[GARBAGE_SIZE];
|
static char garbage[GARBAGE_SIZE];
|
||||||
%}
|
%}
|
||||||
@@ -883,21 +833,8 @@ start:
|
|||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void
|
]AT_YYLEX_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static int called;
|
|
||||||
if (called++)
|
|
||||||
abort ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -908,6 +845,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr10.c glr-regr10.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr10.c glr-regr10.y]], 0, [],
|
||||||
[glr-regr10.y: conflicts: 1 reduce/reduce
|
[glr-regr10.y: conflicts: 1 reduce/reduce
|
||||||
@@ -925,12 +863,13 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Undesirable destructors if user action cuts parse])
|
AT_SETUP([Undesirable destructors if user action cuts parse])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr11.y],
|
AT_DATA_GRAMMAR([glr-regr11.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static int destructors = 0;
|
static int destructors = 0;
|
||||||
# define USE(val)
|
# define USE(val)
|
||||||
%}
|
%}
|
||||||
@@ -949,21 +888,8 @@ start:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
]AT_YYLEX_DEFINE(["a"])[
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "a";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -977,6 +903,7 @@ main (void)
|
|||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr11.c glr-regr11.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr11.c glr-regr11.y]], 0, [],
|
||||||
[glr-regr11.y: conflicts: 1 reduce/reduce
|
[glr-regr11.y: conflicts: 1 reduce/reduce
|
||||||
@@ -994,6 +921,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Leaked semantic values if user action cuts parse])
|
AT_SETUP([Leaked semantic values if user action cuts parse])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr12.y],
|
AT_DATA_GRAMMAR([glr-regr12.y],
|
||||||
[[
|
[[
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -1006,9 +934,10 @@ AT_DATA_GRAMMAR([glr-regr12.y],
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
|
# include <assert.h>
|
||||||
static int merge (YYSTYPE, YYSTYPE);
|
static int merge (YYSTYPE, YYSTYPE);
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static int parent_rhs_before_value = 0;
|
static int parent_rhs_before_value = 0;
|
||||||
static int merged_value = 0;
|
static int merged_value = 0;
|
||||||
static int parent_rhs_after_value = 0;
|
static int parent_rhs_after_value = 0;
|
||||||
@@ -1068,23 +997,10 @@ merge (YYSTYPE s1, YYSTYPE s2)
|
|||||||
return dummy;
|
return dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
]AT_YYLEX_DEFINE([{ PARENT_RHS_AFTER, 0 }],
|
||||||
{
|
[if (res == PARENT_RHS_AFTER)
|
||||||
fprintf (stderr, "%s\n", msg);
|
parent_rhs_after_value = 1;])[
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static int const input[] = { PARENT_RHS_AFTER, 0 };
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input / sizeof *input))
|
|
||||||
abort ();
|
|
||||||
if (input[toknum] == PARENT_RHS_AFTER)
|
|
||||||
parent_rhs_after_value = 1;
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -1108,6 +1024,7 @@ main (void)
|
|||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr12.c glr-regr12.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr12.c glr-regr12.y]], 0, [],
|
||||||
[glr-regr12.y: conflicts: 1 shift/reduce, 1 reduce/reduce
|
[glr-regr12.y: conflicts: 1 shift/reduce, 1 reduce/reduce
|
||||||
@@ -1127,6 +1044,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Incorrect lookahead during deterministic GLR])
|
AT_SETUP([Incorrect lookahead during deterministic GLR])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr13.y],
|
AT_DATA_GRAMMAR([glr-regr13.y],
|
||||||
[[
|
[[
|
||||||
/* Tests:
|
/* Tests:
|
||||||
@@ -1138,8 +1056,9 @@ AT_DATA_GRAMMAR([glr-regr13.y],
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static void yyerror (char const *);
|
#include <assert.h>
|
||||||
static int yylex (void);
|
]AT_YYERROR_DECLARE[
|
||||||
|
]AT_YYLEX_DECLARE[
|
||||||
static void print_lookahead (char const *);
|
static void print_lookahead (char const *);
|
||||||
#define USE(value)
|
#define USE(value)
|
||||||
%}
|
%}
|
||||||
@@ -1190,24 +1109,9 @@ change_lookahead:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
]AT_YYLEX_DEFINE(["ab"],
|
||||||
{
|
[yylval.value = res + 'A' - 'a'])[
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "ab";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
yylloc.first_line = yylloc.last_line = 1;
|
|
||||||
yylloc.first_column = yylloc.last_column = toknum + 1;
|
|
||||||
yylval.value = input[toknum] + 'A' - 'a';
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_lookahead (char const *reduction)
|
print_lookahead (char const *reduction)
|
||||||
@@ -1237,6 +1141,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr13.c glr-regr13.y]], 0, [], [])
|
AT_BISON_CHECK([[-o glr-regr13.c glr-regr13.y]], 0, [], [])
|
||||||
AT_COMPILE([glr-regr13])
|
AT_COMPILE([glr-regr13])
|
||||||
@@ -1263,6 +1168,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Incorrect lookahead during nondeterministic GLR])
|
AT_SETUP([Incorrect lookahead during nondeterministic GLR])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr14.y],
|
AT_DATA_GRAMMAR([glr-regr14.y],
|
||||||
[[
|
[[
|
||||||
/* Tests:
|
/* Tests:
|
||||||
@@ -1289,8 +1195,9 @@ AT_DATA_GRAMMAR([glr-regr14.y],
|
|||||||
%{
|
%{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static void yyerror (char const *);
|
#include <assert.h>
|
||||||
static int yylex (void);
|
]AT_YYERROR_DECLARE[
|
||||||
|
]AT_YYLEX_DECLARE[
|
||||||
static void print_lookahead (char const *);
|
static void print_lookahead (char const *);
|
||||||
static char merge (union YYSTYPE, union YYSTYPE);
|
static char merge (union YYSTYPE, union YYSTYPE);
|
||||||
#define USE(value)
|
#define USE(value)
|
||||||
@@ -1399,19 +1306,13 @@ no_look:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
static char const input[] = "abcdddd";
|
static char const input[] = "abcdddd";
|
||||||
static size_t toknum;
|
static size_t toknum;
|
||||||
if (! (toknum < sizeof input))
|
assert (toknum < sizeof input);
|
||||||
abort ();
|
|
||||||
yylloc.first_line = yylloc.last_line = 1;
|
yylloc.first_line = yylloc.last_line = 1;
|
||||||
yylloc.first_column = yylloc.last_column = toknum + 1;
|
yylloc.first_column = yylloc.last_column = toknum + 1;
|
||||||
yylval.value = input[toknum] + 'A' - 'a';
|
yylval.value = input[toknum] + 'A' - 'a';
|
||||||
@@ -1453,6 +1354,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr14.c glr-regr14.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr14.c glr-regr14.y]], 0, [],
|
||||||
[glr-regr14.y: conflicts: 3 reduce/reduce
|
[glr-regr14.y: conflicts: 3 reduce/reduce
|
||||||
@@ -1483,6 +1385,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Leaked semantic values when reporting ambiguity])
|
AT_SETUP([Leaked semantic values when reporting ambiguity])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr15.y],
|
AT_DATA_GRAMMAR([glr-regr15.y],
|
||||||
[[
|
[[
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -1490,8 +1393,8 @@ AT_DATA_GRAMMAR([glr-regr15.y],
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static int parent_rhs_before_value = 0;
|
static int parent_rhs_before_value = 0;
|
||||||
# define USE(val)
|
# define USE(val)
|
||||||
%}
|
%}
|
||||||
@@ -1529,21 +1432,8 @@ ambiguity1: ;
|
|||||||
ambiguity2: ;
|
ambiguity2: ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void
|
]AT_YYLEX_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static int called;
|
|
||||||
if (called++)
|
|
||||||
abort ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -1557,6 +1447,7 @@ main (void)
|
|||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr15.c glr-regr15.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr15.c glr-regr15.y]], 0, [],
|
||||||
[glr-regr15.y: conflicts: 2 reduce/reduce
|
[glr-regr15.y: conflicts: 2 reduce/reduce
|
||||||
@@ -1575,6 +1466,8 @@ AT_CLEANUP
|
|||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Leaked lookahead after nondeterministic parse syntax error])
|
AT_SETUP([Leaked lookahead after nondeterministic parse syntax error])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr16.y],
|
AT_DATA_GRAMMAR([glr-regr16.y],
|
||||||
[[
|
[[
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -1582,8 +1475,9 @@ AT_DATA_GRAMMAR([glr-regr16.y],
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
# include <assert.h>
|
||||||
static int yylex (void);
|
]AT_YYERROR_DECLARE[
|
||||||
|
]AT_YYLEX_DECLARE[
|
||||||
static int lookahead_value = 0;
|
static int lookahead_value = 0;
|
||||||
# define USE(val)
|
# define USE(val)
|
||||||
%}
|
%}
|
||||||
@@ -1596,23 +1490,10 @@ alt2: ;
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
]AT_YYLEX_DEFINE(["ab"],
|
||||||
{
|
[if (res == 'b')
|
||||||
fprintf (stderr, "%s\n", msg);
|
lookahead_value = 1])[
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "ab";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
if (input[toknum] == 'b')
|
|
||||||
lookahead_value = 1;
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -1626,6 +1507,7 @@ main (void)
|
|||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr16.c glr-regr16.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr16.c glr-regr16.y]], 0, [],
|
||||||
[glr-regr16.y: conflicts: 1 reduce/reduce
|
[glr-regr16.y: conflicts: 1 reduce/reduce
|
||||||
@@ -1644,6 +1526,9 @@ AT_CLEANUP
|
|||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Uninitialized location when reporting ambiguity])
|
AT_SETUP([Uninitialized location when reporting ambiguity])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([%glr-parser %locations %define api.pure])
|
||||||
|
|
||||||
AT_DATA_GRAMMAR([glr-regr17.y],
|
AT_DATA_GRAMMAR([glr-regr17.y],
|
||||||
[[
|
[[
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -1654,8 +1539,8 @@ AT_DATA_GRAMMAR([glr-regr17.y],
|
|||||||
%union { int dummy; }
|
%union { int dummy; }
|
||||||
|
|
||||||
%{
|
%{
|
||||||
static void yyerror (YYLTYPE *, char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (YYSTYPE *, YYLTYPE *);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%initial-action {
|
%initial-action {
|
||||||
@@ -1685,21 +1570,15 @@ empty1: ;
|
|||||||
empty2: ;
|
empty2: ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
# include <assert.h>
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (YYLTYPE *locp, char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%d.%d-%d.%d: %s.\n", locp->first_line,
|
|
||||||
locp->first_column, locp->last_line, locp->last_column, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
|
yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
|
||||||
{
|
{
|
||||||
static char const input[] = "ab";
|
static char const input[] = "ab";
|
||||||
static size_t toknum;
|
static size_t toknum;
|
||||||
if (! (toknum < sizeof input))
|
assert (toknum < sizeof input);
|
||||||
abort ();
|
|
||||||
lvalp->dummy = 0;
|
lvalp->dummy = 0;
|
||||||
llocp->first_line = llocp->last_line = 2;
|
llocp->first_line = llocp->last_line = 2;
|
||||||
llocp->first_column = toknum + 1;
|
llocp->first_column = toknum + 1;
|
||||||
@@ -1713,6 +1592,7 @@ main (void)
|
|||||||
return yyparse () != 1;
|
return yyparse () != 1;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
|
||||||
[glr-regr17.y: conflicts: 3 reduce/reduce
|
[glr-regr17.y: conflicts: 3 reduce/reduce
|
||||||
@@ -1720,7 +1600,7 @@ AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
|
|||||||
AT_COMPILE([glr-regr17])
|
AT_COMPILE([glr-regr17])
|
||||||
|
|
||||||
AT_PARSER_CHECK([[./glr-regr17]], 0, [],
|
AT_PARSER_CHECK([[./glr-regr17]], 0, [],
|
||||||
[1.1-2.3: syntax is ambiguous.
|
[1.1-2.2: syntax is ambiguous
|
||||||
])
|
])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
@@ -1731,13 +1611,15 @@ AT_CLEANUP
|
|||||||
## -------------------------------------------------------------##
|
## -------------------------------------------------------------##
|
||||||
|
|
||||||
AT_SETUP([Missed %merge type warnings when LHS type is declared later])
|
AT_SETUP([Missed %merge type warnings when LHS type is declared later])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr18.y],
|
AT_DATA_GRAMMAR([glr-regr18.y],
|
||||||
[[%glr-parser
|
[[%glr-parser
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex ();
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
@@ -1757,28 +1639,15 @@ sym3: %merge<merge> { $$ = 0; } ;
|
|||||||
%type <type3> sym3;
|
%type <type3> sym3;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void
|
]AT_YYLEX_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex ()
|
|
||||||
{
|
|
||||||
static int called;
|
|
||||||
if (called++)
|
|
||||||
abort ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
|
AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
|
||||||
[glr-regr18.y:26.18-24: result type clash on merge function 'merge': <type2> != <type1>
|
[glr-regr18.y:26.18-24: result type clash on merge function 'merge': <type2> != <type1>
|
||||||
@@ -1796,13 +1665,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Ambiguity reports])
|
AT_SETUP([Ambiguity reports])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%debug
|
%debug
|
||||||
@@ -1816,23 +1686,8 @@ start:
|
|||||||
b: 'b';
|
b: 'b';
|
||||||
d: /* nada. */;
|
d: /* nada. */;
|
||||||
%%
|
%%
|
||||||
|
]AT_YYLEX_DEFINE(["abc"])[
|
||||||
static int
|
]AT_YYERROR_DEFINE[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "abc";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -1840,6 +1695,7 @@ main (void)
|
|||||||
return !!yyparse ();
|
return !!yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]], 0, [],
|
AT_BISON_CHECK([[-o input.c input.y]], 0, [],
|
||||||
[input.y: conflicts: 1 reduce/reduce
|
[input.y: conflicts: 1 reduce/reduce
|
||||||
|
|||||||
+141
-34
@@ -19,47 +19,26 @@
|
|||||||
AT_BANNER([[Parser Headers.]])
|
AT_BANNER([[Parser Headers.]])
|
||||||
|
|
||||||
|
|
||||||
## ---------------------- ##
|
|
||||||
## %union and --defines. ##
|
|
||||||
## ---------------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
AT_SETUP([%union and --defines])
|
|
||||||
|
|
||||||
AT_DATA([input.y],
|
|
||||||
[%union
|
|
||||||
{
|
|
||||||
int integer;
|
|
||||||
char *string ;
|
|
||||||
}
|
|
||||||
%%
|
|
||||||
exp: {};
|
|
||||||
])
|
|
||||||
|
|
||||||
AT_BISON_CHECK([--defines input.y])
|
|
||||||
|
|
||||||
AT_CLEANUP
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
## Invalid CPP headers. ##
|
## Invalid CPP headers. ##
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
|
|
||||||
# AT_TEST_CPP_GUARD_H([INPUT-FILE-BASE)
|
# AT_TEST_CPP_GUARD_H(BASE-NAME, [DIRECTIVES])
|
||||||
# -------------------------------------
|
# --------------------------------------------
|
||||||
|
# FIXME: Much of this can be covered by calc.at.
|
||||||
m4_define([AT_TEST_CPP_GUARD_H],
|
m4_define([AT_TEST_CPP_GUARD_H],
|
||||||
[AT_SETUP([Invalid CPP guards: $1])
|
[AT_SETUP([Invalid CPP guards: $2 --defines=$1.h])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([$2])
|
||||||
# Possibly create inner directories.
|
# Possibly create inner directories.
|
||||||
dirname=`AS_DIRNAME([$1])`
|
dirname=`AS_DIRNAME([$1])`
|
||||||
AS_MKDIR_P([$dirname])
|
AS_MKDIR_P([$dirname])
|
||||||
|
|
||||||
AT_DATA_GRAMMAR([$1.y],
|
AT_DATA_GRAMMAR([$1.y],
|
||||||
[%{
|
[$2
|
||||||
|
%{
|
||||||
#include <$1.h>
|
#include <$1.h>
|
||||||
void yyerror (const char *);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
dummy:;
|
dummy:;
|
||||||
@@ -67,15 +46,18 @@ dummy:;
|
|||||||
#include <$1.h>
|
#include <$1.h>
|
||||||
])
|
])
|
||||||
|
|
||||||
AT_BISON_CHECK([--defines=$1.h --output=y.tab.c $1.y])
|
AT_BISON_CHECK([--defines=$1.h --output=$1.c $1.y])
|
||||||
|
|
||||||
AT_COMPILE([y.tab.o], [-I. -c y.tab.c])
|
AT_COMPILE([$1.o], [-I. -c $1.c])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
])
|
])
|
||||||
|
|
||||||
AT_TEST_CPP_GUARD_H([input/input])
|
AT_TEST_CPP_GUARD_H([input/input])
|
||||||
AT_TEST_CPP_GUARD_H([9foo])
|
AT_TEST_CPP_GUARD_H([9foo])
|
||||||
|
AT_TEST_CPP_GUARD_H([input/input], [%glr-parser])
|
||||||
|
AT_TEST_CPP_GUARD_H([9foo], [%glr-parser])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -129,9 +111,134 @@ main (void)
|
|||||||
|
|
||||||
# Link and execute, just to make sure everything is fine (and in
|
# Link and execute, just to make sure everything is fine (and in
|
||||||
# particular, that MY_LLOC is indeed defined somewhere).
|
# particular, that MY_LLOC is indeed defined somewhere).
|
||||||
AT_COMPILE([caller.o], [-c caller.c])
|
AT_COMPILE([caller.o])
|
||||||
AT_COMPILE([input.o], [-c input.c])
|
AT_COMPILE([input.o])
|
||||||
AT_COMPILE([caller], [caller.o input.o])
|
AT_COMPILE([caller], [caller.o input.o])
|
||||||
AT_PARSER_CHECK([./caller])
|
AT_PARSER_CHECK([./caller])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
## ----------------- ##
|
||||||
|
## Several parsers. ##
|
||||||
|
## ----------------- ##
|
||||||
|
|
||||||
|
AT_SETUP([Several parsers])
|
||||||
|
|
||||||
|
# AT_TEST([PREFIX], [DIRECTIVES])
|
||||||
|
# -------------------------------
|
||||||
|
# Generate and compile to *.o. Make sure there is no YY* nor yy* in
|
||||||
|
# the header (but YYDEBUG and YYPARSE_PARAM).
|
||||||
|
m4_pushdef([AT_TEST],
|
||||||
|
[AT_BISON_OPTION_PUSHDEFS([%define api.prefix "$1_" $2])
|
||||||
|
AT_DATA_GRAMMAR([$1.AT_SKEL_CC_IF([yy], [y])],
|
||||||
|
[[%define api.prefix "$1_"
|
||||||
|
$2
|
||||||
|
%error-verbose
|
||||||
|
%union
|
||||||
|
{
|
||||||
|
int integer;
|
||||||
|
}
|
||||||
|
%{
|
||||||
|
#include <stdio.h>
|
||||||
|
]AT_YYERROR_DECLARE[
|
||||||
|
]AT_YYLEX_DECLARE[
|
||||||
|
%}
|
||||||
|
%%
|
||||||
|
exp:
|
||||||
|
'x' '1' { printf ("x1\n"); }
|
||||||
|
| 'x' '2' { printf ("x2\n"); }
|
||||||
|
| 'x' '3' { printf ("x3\n"); }
|
||||||
|
| 'x' '4' { printf ("x4\n"); }
|
||||||
|
| 'x' '5' { printf ("x5\n"); }
|
||||||
|
| 'x' '6' { printf ("x6\n"); }
|
||||||
|
| 'x' '7' { printf ("x7\n"); }
|
||||||
|
| 'x' '8' { printf ("x8\n"); }
|
||||||
|
;
|
||||||
|
|
||||||
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
|
]AT_YYLEX_DEFINE(["$1"])[
|
||||||
|
]])
|
||||||
|
|
||||||
|
AT_BISON_CHECK([-d -o AT_SKEL_CC_IF([$1.cc $1.yy], [$1.c $1.y])])
|
||||||
|
# C++ output relies on namespaces and still uses yy a lot.
|
||||||
|
AT_SKEL_CC_IF([],
|
||||||
|
[AT_CHECK([$EGREP yy $1.h], [1])])
|
||||||
|
|
||||||
|
# Ignore comments. Ignore YYPARSE_PARAM (obsolete) and
|
||||||
|
# YYPUSH_MORE(_DEFINED)? (whose definition is constant).
|
||||||
|
#
|
||||||
|
# YYDEBUG (not renamed) can be read, but not changed.
|
||||||
|
AT_CHECK([[sed -ne 's,/\*[^*]*\*/,,g;s,//.*,,' \
|
||||||
|
-e '/YY/p' ]$1.AT_SKEL_CC_IF([hh], [h])[ |
|
||||||
|
$EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?)|(defined|if) YYDEBUG']],
|
||||||
|
[1])
|
||||||
|
AT_LANG_COMPILE([$1.o])
|
||||||
|
|
||||||
|
AT_CHECK([[echo "$1" >>expout]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
])# AT_TEST
|
||||||
|
|
||||||
|
AT_DATA([main.cc],
|
||||||
|
[AT_DATA_SOURCE_PROLOGUE
|
||||||
|
[// If we are compiling with CC=$CXX, then do not load the C headers
|
||||||
|
// inside extern "C", since they were _not_ compiled this way.
|
||||||
|
#if ! CC_IS_CXX
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
#include "x1.h"
|
||||||
|
#include "x2.h"
|
||||||
|
#include "x3.h"
|
||||||
|
#include "x4.h"
|
||||||
|
#include "x6.h"
|
||||||
|
#include "x7.h"
|
||||||
|
#include "x8.h"
|
||||||
|
#if ! CC_IS_CXX
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#include "x5.hh"
|
||||||
|
//#include "x6.hh"
|
||||||
|
|
||||||
|
#define RUN(S) \
|
||||||
|
do { \
|
||||||
|
int res = S; \
|
||||||
|
if (res) \
|
||||||
|
std::cerr << #S": " << res << std::endl; \
|
||||||
|
} while (false)
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
RUN(x1_parse());
|
||||||
|
RUN(x2_parse());
|
||||||
|
RUN(x3_parse());
|
||||||
|
RUN(x4_parse());
|
||||||
|
x5_::parser p5;
|
||||||
|
RUN(p5.parse());
|
||||||
|
RUN(x6_parse());
|
||||||
|
RUN(x7_parse());
|
||||||
|
RUN(x8_parse());
|
||||||
|
// x6_::parser p6;
|
||||||
|
// RUN(p6.parse());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
]])# main.cc
|
||||||
|
|
||||||
|
AT_TEST([x1], [])
|
||||||
|
AT_TEST([x2], [%locations %debug])
|
||||||
|
AT_TEST([x3], [%glr-parser])
|
||||||
|
AT_TEST([x4], [%locations %debug %glr-parser])
|
||||||
|
AT_TEST([x5], [%locations %debug %language "c++"])
|
||||||
|
AT_TEST([x6], [%define api.pure])
|
||||||
|
AT_TEST([x7], [%define api.push-pull both])
|
||||||
|
AT_TEST([x8], [%define api.pure %define api.push-pull both])
|
||||||
|
#AT_TEST([x5], [%locations %language "c++" %glr-parser])
|
||||||
|
|
||||||
|
AT_COMPILE_CXX([parser], [[x[1-8].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
|
||||||
|
AT_CHECK([./parser], [0], [[expout]])
|
||||||
|
|
||||||
|
m4_popdef([AT_TEST])
|
||||||
|
|
||||||
|
AT_CLEANUP
|
||||||
|
|||||||
+144
-19
@@ -69,7 +69,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
|
|
||||||
# _AT_UNUSED_VALUES_DECLARATIONS()
|
# _AT_UNUSED_VALUES_DECLARATIONS()
|
||||||
# --------------------------------------------
|
# --------------------------------
|
||||||
# Generate the token, type, and destructor
|
# Generate the token, type, and destructor
|
||||||
# declarations for the unused values tests.
|
# declarations for the unused values tests.
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Torturing the Scanner])
|
AT_SETUP([Torturing the Scanner])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA([input.y], [])
|
AT_DATA([input.y], [])
|
||||||
AT_BISON_CHECK([input.y], [1], [],
|
AT_BISON_CHECK([input.y], [1], [],
|
||||||
[[input.y:1.1: syntax error, unexpected end of file
|
[[input.y:1.1: syntax error, unexpected end of file
|
||||||
@@ -442,6 +442,7 @@ char apostrophe = '\'';
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
%}
|
%}
|
||||||
/* %{ and %} can be here too. */
|
/* %{ and %} can be here too. */
|
||||||
|
|
||||||
@@ -468,8 +469,8 @@ char quote[] = "@:>@@:>@,";
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
%{
|
%{
|
||||||
static void yyerror (const char *s);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%type <ival> '@<:@'
|
%type <ival> '@<:@'
|
||||||
@@ -501,7 +502,7 @@ value_as_yystype (value val)
|
|||||||
res.ival = val;
|
res.ival = val;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -509,20 +510,13 @@ yylex (void)
|
|||||||
#output "; /* "
|
#output "; /* "
|
||||||
*/
|
*/
|
||||||
static size_t toknum;
|
static size_t toknum;
|
||||||
if (! (toknum < sizeof input))
|
assert (toknum < sizeof input);
|
||||||
abort ();
|
|
||||||
yylval = value_as_yystype (input[toknum]);
|
yylval = value_as_yystype (input[toknum]);
|
||||||
return input[toknum++];
|
return input[toknum++];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
# Pacify Emacs'font-lock-mode: "
|
# Pacify Emacs' font-lock-mode: "
|
||||||
|
|
||||||
AT_DATA([main.c],
|
AT_DATA([main.c],
|
||||||
[[typedef int value;
|
[[typedef int value;
|
||||||
@@ -536,10 +530,11 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-d -v -o input.c input.y])
|
AT_BISON_CHECK([-d -v -o input.c input.y])
|
||||||
AT_COMPILE([input.o], [-c input.c])
|
AT_COMPILE([input.o])
|
||||||
AT_COMPILE([main.o], [-c main.c])
|
AT_COMPILE([main.o])
|
||||||
AT_COMPILE([input], [input.o main.o])
|
AT_COMPILE([input], [input.o main.o])
|
||||||
AT_PARSER_CHECK([./input], 0,
|
AT_PARSER_CHECK([./input], 0,
|
||||||
[[[@<:@],
|
[[[@<:@],
|
||||||
@@ -621,14 +616,15 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Symbols])
|
AT_SETUP([Symbols])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%token WITH-DASH
|
[[%token WITH-DASH
|
||||||
%token WITHOUT_DASH "WITHOUT-DASH"
|
%token WITHOUT_DASH "WITHOUT-DASH"
|
||||||
%token WITH.PERIOD
|
%token WITH.PERIOD
|
||||||
%token WITHOUT_PERIOD "WITHOUT.PERIOD"
|
%token WITHOUT_PERIOD "WITHOUT.PERIOD"
|
||||||
%code {
|
%code {
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
}
|
}
|
||||||
%%
|
%%
|
||||||
start: with-dash without_dash with.period without_period;
|
start: with-dash without_dash with.period without_period;
|
||||||
@@ -637,7 +633,10 @@ without_dash: "WITHOUT-DASH";
|
|||||||
with.period: WITH.PERIOD;
|
with.period: WITH.PERIOD;
|
||||||
without_period: "WITHOUT.PERIOD";
|
without_period: "WITHOUT.PERIOD";
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
|
]AT_YYLEX_DEFINE[
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
# POSIX Yacc accept periods, but not dashes.
|
# POSIX Yacc accept periods, but not dashes.
|
||||||
AT_BISON_CHECK([--yacc input.y], [1], [],
|
AT_BISON_CHECK([--yacc input.y], [1], [],
|
||||||
@@ -655,7 +654,7 @@ input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash
|
|||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
|
|
||||||
# Make sure we don't export silly token identifiers with periods or dashes.
|
# Make sure we don't export silly token identifiers with periods or dashes.
|
||||||
AT_COMPILE([input.o], [-c input.c])
|
AT_COMPILE([input.o])
|
||||||
|
|
||||||
|
|
||||||
# Periods are genuine letters, they can start identifiers.
|
# Periods are genuine letters, they can start identifiers.
|
||||||
@@ -1341,3 +1340,129 @@ input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar
|
|||||||
AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]])
|
AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------------------------------------------ ##
|
||||||
|
## %name-prefix and %define api.prefix are incompatible. ##
|
||||||
|
## ------------------------------------------------------ ##
|
||||||
|
|
||||||
|
AT_SETUP([[%name-prefix and %define api.prefix are incompatible]])
|
||||||
|
|
||||||
|
# AT_TEST(DIRECTIVES, OPTIONS, ERROR-LOCATION)
|
||||||
|
# --------------------------------------------
|
||||||
|
m4_pushdef([AT_TEST],
|
||||||
|
[AT_DATA([[input.y]],
|
||||||
|
[[$1
|
||||||
|
%%
|
||||||
|
exp:;
|
||||||
|
]])
|
||||||
|
AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
|
||||||
|
[[$3: '%name-prefix' and '%define api.prefix' cannot be used together
|
||||||
|
]])
|
||||||
|
])
|
||||||
|
|
||||||
|
AT_TEST([%define api.prefix foo %name-prefix "bar"], [], [input.y:1.9-18])
|
||||||
|
AT_TEST([], [-Dapi.prefix=foo -p bar], [<command line>:2])
|
||||||
|
AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [<command line>:2])
|
||||||
|
AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18])
|
||||||
|
|
||||||
|
m4_popdef([AT_TEST])
|
||||||
|
|
||||||
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Stray $ or @. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
AT_SETUP([[Stray $ or @]])
|
||||||
|
|
||||||
|
# Give %printer and %destructor "<*> exp TOK" instead of "<*>" to
|
||||||
|
# check that the warnings are reported once, not three times.
|
||||||
|
|
||||||
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
|
[[%token TOK
|
||||||
|
%destructor { $%; @%; } <*> exp TOK;
|
||||||
|
%initial-action { $%; @%; };
|
||||||
|
%printer { $%; @%; } <*> exp TOK;
|
||||||
|
%%
|
||||||
|
exp: TOK { $%; @%; $$ = $1; };
|
||||||
|
]])
|
||||||
|
|
||||||
|
AT_BISON_CHECK([[input.y]], 0, [],
|
||||||
|
[[input.y:10.19: warning: stray '$'
|
||||||
|
input.y:10.23: warning: stray '@'
|
||||||
|
input.y:11.19: warning: stray '$'
|
||||||
|
input.y:11.23: warning: stray '@'
|
||||||
|
input.y:12.19: warning: stray '$'
|
||||||
|
input.y:12.23: warning: stray '@'
|
||||||
|
input.y:14.19: warning: stray '$'
|
||||||
|
input.y:14.23: warning: stray '@'
|
||||||
|
]])
|
||||||
|
|
||||||
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Code injection. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
AT_SETUP([[Code injection]])
|
||||||
|
|
||||||
|
m4_pattern_allow([^m4_errprintn$])
|
||||||
|
|
||||||
|
# AT_TEST([MACRO])
|
||||||
|
# ----------------
|
||||||
|
# Try to have MACRO be run by bison.
|
||||||
|
m4_pushdef([AT_TEST],
|
||||||
|
[AT_DATA([[input.y]],
|
||||||
|
[[%type <$1(DEAD %type)> exp
|
||||||
|
%token <$1(DEAD %token)> a
|
||||||
|
%initial-action
|
||||||
|
{
|
||||||
|
$$;
|
||||||
|
$<$1(DEAD %initial-action)>$
|
||||||
|
};
|
||||||
|
%printer
|
||||||
|
{
|
||||||
|
$$
|
||||||
|
$<$1(DEAD %printer)>$
|
||||||
|
} <> <*>;
|
||||||
|
%lex-param
|
||||||
|
{
|
||||||
|
$1(DEAD %lex-param)
|
||||||
|
};
|
||||||
|
%parse-param
|
||||||
|
{
|
||||||
|
$1(DEAD %parse-param)
|
||||||
|
};
|
||||||
|
%%
|
||||||
|
exp:
|
||||||
|
a a[last]
|
||||||
|
{
|
||||||
|
$$;
|
||||||
|
$][1;
|
||||||
|
$<$1(DEAD action 1)>$
|
||||||
|
$<$1(DEAD action 2)>1
|
||||||
|
$<$1(DEAD action 3)>last
|
||||||
|
$<$1(DEAD action 4)>0
|
||||||
|
;
|
||||||
|
};
|
||||||
|
]])
|
||||||
|
|
||||||
|
# FIXME: Provide a means to iterate over all the skeletons.
|
||||||
|
AT_BISON_CHECK([[-d input.y]])
|
||||||
|
AT_BISON_CHECK([[-d -S glr.c input.y]])
|
||||||
|
AT_BISON_CHECK([[-d -S lalr1.cc input.y]])
|
||||||
|
AT_BISON_CHECK([[-d -S glr.cc input.y]])
|
||||||
|
AT_BISON_CHECK([[ -S lalr1.java input.y]])
|
||||||
|
])
|
||||||
|
|
||||||
|
AT_TEST([m4_errprintn])
|
||||||
|
AT_TEST([@:>@m4_errprintn])
|
||||||
|
|
||||||
|
m4_popdef([AT_TEST])
|
||||||
|
|
||||||
|
AT_CLEANUP
|
||||||
|
|||||||
+5
-15
@@ -32,6 +32,7 @@ AT_BANNER([[Java Calculator.]])
|
|||||||
m4_define([_AT_DATA_JAVA_CALC_Y],
|
m4_define([_AT_DATA_JAVA_CALC_Y],
|
||||||
[m4_if([$1$2$3], $[1]$[2]$[3], [],
|
[m4_if([$1$2$3], $[1]$[2]$[3], [],
|
||||||
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([%language "Java" $4])
|
||||||
AT_DATA([Calc.y],
|
AT_DATA([Calc.y],
|
||||||
[[/* Infix notation calculator--calc */
|
[[/* Infix notation calculator--calc */
|
||||||
%language "Java"
|
%language "Java"
|
||||||
@@ -122,20 +123,8 @@ AT_LOCATION_IF([[
|
|||||||
public Position getEndPos() {
|
public Position getEndPos() {
|
||||||
return yypos;
|
return yypos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void yyerror (Calc.Location l, String s)
|
|
||||||
{
|
|
||||||
if (l == null)
|
|
||||||
System.err.println (s);
|
|
||||||
else
|
|
||||||
System.err.println (l + ": " + s);
|
|
||||||
}
|
|
||||||
]], [[
|
|
||||||
public void yyerror (String s)
|
|
||||||
{
|
|
||||||
System.err.println (s);
|
|
||||||
}
|
|
||||||
]])[
|
]])[
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
|
|
||||||
Integer yylval;
|
Integer yylval;
|
||||||
|
|
||||||
@@ -211,11 +200,12 @@ class Position {
|
|||||||
}
|
}
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
])# _AT_DATA_JAVA_CALC_Y
|
])# _AT_DATA_JAVA_CALC_Y
|
||||||
|
|
||||||
|
|
||||||
# AT_DATA_CALC_Y([BISON-OPTIONS])
|
# AT_DATA_CALC_Y([BISON-OPTIONS])
|
||||||
# -------------------------------------------------
|
# -------------------------------
|
||||||
# Produce `calc.y'.
|
# Produce `calc.y'.
|
||||||
m4_define([AT_DATA_JAVA_CALC_Y],
|
m4_define([AT_DATA_JAVA_CALC_Y],
|
||||||
[_AT_DATA_JAVA_CALC_Y($[1], $[2], $[3], [$1])
|
[_AT_DATA_JAVA_CALC_Y($[1], $[2], $[3], [$1])
|
||||||
@@ -224,7 +214,7 @@ m4_define([AT_DATA_JAVA_CALC_Y],
|
|||||||
|
|
||||||
# _AT_CHECK_JAVA_CALC_ERROR(BISON-OPTIONS, INPUT,
|
# _AT_CHECK_JAVA_CALC_ERROR(BISON-OPTIONS, INPUT,
|
||||||
# [VERBOSE-AND-LOCATED-ERROR-MESSAGE])
|
# [VERBOSE-AND-LOCATED-ERROR-MESSAGE])
|
||||||
# ---------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Run `calc' on INPUT, and expect a `syntax error' message.
|
# Run `calc' on INPUT, and expect a `syntax error' message.
|
||||||
#
|
#
|
||||||
# If INPUT starts with a slash, it is used as absolute input file name,
|
# If INPUT starts with a slash, it is used as absolute input file name,
|
||||||
|
|||||||
+324
-128
@@ -17,10 +17,18 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# We want a recent Autotest.
|
|
||||||
m4_version_prereq([2.58])
|
m4_version_prereq([2.58])
|
||||||
|
|
||||||
|
|
||||||
|
# m4_null_if(VAL, IF-TRUE, IF-FALSE)
|
||||||
|
# ----------------------------------
|
||||||
|
# If VAL evaluates to empty or 0, run IF-TRUE, otherwise IF-FALSE.
|
||||||
|
m4_define([m4_null_if],
|
||||||
|
[m4_case(m4_quote($1),
|
||||||
|
[0], [$2],
|
||||||
|
[], [$2],
|
||||||
|
[$3])])
|
||||||
|
|
||||||
## ------------- ##
|
## ------------- ##
|
||||||
## Basic tests. ##
|
## Basic tests. ##
|
||||||
## ------------- ##
|
## ------------- ##
|
||||||
@@ -45,6 +53,8 @@ m4_divert_text([PREPARE_TESTS],
|
|||||||
{
|
{
|
||||||
for at_save_file in stderr experr expout
|
for at_save_file in stderr experr expout
|
||||||
do
|
do
|
||||||
|
test ! -f at-bison-check-$at_save_file.bak ||
|
||||||
|
as_fn_error 1 "fatal error: back-up on top of a back-up"
|
||||||
test ! -f $at_save_file || mv $at_save_file at-bison-check-$at_save_file.bak
|
test ! -f $at_save_file || mv $at_save_file at-bison-check-$at_save_file.bak
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -91,7 +101,8 @@ m4_popdef([AT_LOC_LAST_COLUMN])])
|
|||||||
# AT_BISON_OPTION_PUSHDEFS([BISON-OPTIONS])
|
# AT_BISON_OPTION_PUSHDEFS([BISON-OPTIONS])
|
||||||
# -----------------------------------------
|
# -----------------------------------------
|
||||||
m4_define([AT_BISON_OPTION_PUSHDEFS],
|
m4_define([AT_BISON_OPTION_PUSHDEFS],
|
||||||
[_AT_BISON_OPTION_PUSHDEFS($[1], $[2], [$1])])
|
[m4_divert_text([KILL],
|
||||||
|
[_AT_BISON_OPTION_PUSHDEFS($[1], $[2], [$1])])])
|
||||||
|
|
||||||
|
|
||||||
# _AT_BISON_OPTION_PUSHDEFS($1, $2, [BISON-OPTIONS])
|
# _AT_BISON_OPTION_PUSHDEFS($1, $2, [BISON-OPTIONS])
|
||||||
@@ -108,8 +119,12 @@ m4_pushdef([AT_SKEL_CC_IF],
|
|||||||
[m4_bmatch([$3], [%language "[Cc]\+\+"\|%skeleton "[a-z0-9]+\.cc"], [$1], [$2])])
|
[m4_bmatch([$3], [%language "[Cc]\+\+"\|%skeleton "[a-z0-9]+\.cc"], [$1], [$2])])
|
||||||
m4_pushdef([AT_SKEL_JAVA_IF],
|
m4_pushdef([AT_SKEL_JAVA_IF],
|
||||||
[m4_bmatch([$3], [%language "[Jj][Aa][Vv][Aa]"\|%skeleton "[a-z0-9]+\.java"], [$1], [$2])])
|
[m4_bmatch([$3], [%language "[Jj][Aa][Vv][Aa]"\|%skeleton "[a-z0-9]+\.java"], [$1], [$2])])
|
||||||
|
m4_pushdef([AT_LANG],
|
||||||
|
[AT_SKEL_JAVA_IF([java],
|
||||||
|
[AT_SKEL_CC_IF([c++],
|
||||||
|
[c])])])
|
||||||
m4_pushdef([AT_GLR_IF],
|
m4_pushdef([AT_GLR_IF],
|
||||||
[m4_bmatch([$3], [%glr-parser\|%skeleton "glr\.], [$1], [$2])])
|
[m4_bmatch([$3], [%glr-parser\|%skeleton "glr\..*"], [$1], [$2])])
|
||||||
m4_pushdef([AT_LALR1_CC_IF],
|
m4_pushdef([AT_LALR1_CC_IF],
|
||||||
[AT_SKEL_CC_IF([AT_GLR_IF([$2], [$1])], [$2])])
|
[AT_SKEL_CC_IF([AT_GLR_IF([$2], [$1])], [$2])])
|
||||||
m4_pushdef([AT_GLR_CC_IF],
|
m4_pushdef([AT_GLR_CC_IF],
|
||||||
@@ -134,9 +149,15 @@ m4_pushdef([AT_PURE_AND_LOC_IF],
|
|||||||
m4_pushdef([AT_GLR_OR_PARAM_IF],
|
m4_pushdef([AT_GLR_OR_PARAM_IF],
|
||||||
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
|
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
|
||||||
m4_pushdef([AT_NAME_PREFIX],
|
m4_pushdef([AT_NAME_PREFIX],
|
||||||
[m4_bmatch([$3], [%name-prefix ".*"],
|
[m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"],
|
||||||
[m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])],
|
[m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])],
|
||||||
[yy])])
|
[yy])])
|
||||||
|
m4_pushdef([AT_API_prefix],
|
||||||
|
[m4_bmatch([$3], [%define api\.prefix ".*"],
|
||||||
|
[m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])],
|
||||||
|
[yy])])
|
||||||
|
m4_pushdef([AT_API_PREFIX],
|
||||||
|
[m4_toupper(AT_API_prefix)])
|
||||||
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
|
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
|
||||||
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
||||||
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
||||||
@@ -155,27 +176,35 @@ m4_pushdef([AT_PURE_LEX_IF],
|
|||||||
[AT_PURE_IF([$1],
|
[AT_PURE_IF([$1],
|
||||||
[AT_SKEL_CC_IF([$1], [$2])])])
|
[AT_SKEL_CC_IF([$1], [$2])])])
|
||||||
|
|
||||||
|
m4_pushdef([AT_YYSTYPE],
|
||||||
|
[AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::semantic_type]],
|
||||||
|
[AT_API_PREFIX[STYPE]])])
|
||||||
|
m4_pushdef([AT_YYLTYPE],
|
||||||
|
[AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::location_type]],
|
||||||
|
[AT_API_PREFIX[LTYPE]])])
|
||||||
|
|
||||||
|
|
||||||
AT_PURE_LEX_IF(
|
AT_PURE_LEX_IF(
|
||||||
[m4_pushdef([AT_LOC], [(*llocp)])
|
[m4_pushdef([AT_LOC], [(*llocp)])
|
||||||
m4_pushdef([AT_VAL], [(*lvalp)])
|
m4_pushdef([AT_VAL], [(*lvalp)])
|
||||||
m4_pushdef([AT_LEX_FORMALS],
|
m4_pushdef([AT_YYLEX_FORMALS],
|
||||||
[YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
|
[AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])])
|
||||||
m4_pushdef([AT_LEX_ARGS],
|
m4_pushdef([AT_YYLEX_ARGS],
|
||||||
[lvalp[]AT_LOCATION_IF([, llocp])])
|
[lvalp[]AT_LOCATION_IF([, llocp])])
|
||||||
m4_pushdef([AT_USE_LEX_ARGS],
|
m4_pushdef([AT_USE_LEX_ARGS],
|
||||||
[(void) lvalp;AT_LOCATION_IF([(void) llocp])])
|
[(void) lvalp;AT_LOCATION_IF([(void) llocp])])
|
||||||
m4_pushdef([AT_LEX_PRE_FORMALS],
|
m4_pushdef([AT_YYLEX_PRE_FORMALS],
|
||||||
[AT_LEX_FORMALS, ])
|
[AT_YYLEX_FORMALS, ])
|
||||||
m4_pushdef([AT_LEX_PRE_ARGS],
|
m4_pushdef([AT_YYLEX_PRE_ARGS],
|
||||||
[AT_LEX_ARGS, ])
|
[AT_YYLEX_ARGS, ])
|
||||||
],
|
],
|
||||||
[m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
|
[m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
|
||||||
m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
|
m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
|
||||||
m4_pushdef([AT_LEX_FORMALS], [void])
|
m4_pushdef([AT_YYLEX_FORMALS], [void])
|
||||||
m4_pushdef([AT_LEX_ARGS], [])
|
m4_pushdef([AT_YYLEX_ARGS], [])
|
||||||
m4_pushdef([AT_USE_LEX_ARGS], [])
|
m4_pushdef([AT_USE_LEX_ARGS], [])
|
||||||
m4_pushdef([AT_LEX_PRE_FORMALS], [])
|
m4_pushdef([AT_YYLEX_PRE_FORMALS], [])
|
||||||
m4_pushdef([AT_LEX_PRE_ARGS], [])
|
m4_pushdef([AT_YYLEX_PRE_ARGS], [])
|
||||||
])
|
])
|
||||||
|
|
||||||
# Handle the different types of location components.
|
# Handle the different types of location components.
|
||||||
@@ -192,16 +221,21 @@ AT_SKEL_CC_IF(
|
|||||||
# AT_BISON_OPTION_POPDEFS
|
# AT_BISON_OPTION_POPDEFS
|
||||||
# -----------------------
|
# -----------------------
|
||||||
m4_define([AT_BISON_OPTION_POPDEFS],
|
m4_define([AT_BISON_OPTION_POPDEFS],
|
||||||
[m4_popdef([AT_LEX_PRE_ARGS])
|
[m4_divert_text([KILL],
|
||||||
m4_popdef([AT_LEX_PRE_FORMALS])
|
[m4_popdef([AT_YYLEX_PRE_ARGS])
|
||||||
|
m4_popdef([AT_YYLEX_PRE_FORMALS])
|
||||||
m4_popdef([AT_USE_LEX_ARGS])
|
m4_popdef([AT_USE_LEX_ARGS])
|
||||||
m4_popdef([AT_LEX_ARGS])
|
m4_popdef([AT_YYLEX_ARGS])
|
||||||
m4_popdef([AT_LEX_FORMALS])
|
m4_popdef([AT_YYLEX_FORMALS])
|
||||||
|
m4_popdef([AT_YYLTYPE])
|
||||||
|
m4_popdef([AT_YYSTYPE])
|
||||||
m4_popdef([AT_VAL])
|
m4_popdef([AT_VAL])
|
||||||
m4_popdef([AT_LOC])
|
m4_popdef([AT_LOC])
|
||||||
m4_popdef([AT_PURE_LEX_IF])
|
m4_popdef([AT_PURE_LEX_IF])
|
||||||
m4_popdef([AT_YYERROR_SEES_LOC_IF])
|
m4_popdef([AT_YYERROR_SEES_LOC_IF])
|
||||||
m4_popdef([AT_YYERROR_ARG_LOC_IF])
|
m4_popdef([AT_YYERROR_ARG_LOC_IF])
|
||||||
|
m4_popdef([AT_API_PREFIX])
|
||||||
|
m4_popdef([AT_API_prefix])
|
||||||
m4_popdef([AT_NAME_PREFIX])
|
m4_popdef([AT_NAME_PREFIX])
|
||||||
m4_popdef([AT_GLR_OR_PARAM_IF])
|
m4_popdef([AT_GLR_OR_PARAM_IF])
|
||||||
m4_popdef([AT_PURE_AND_LOC_IF])
|
m4_popdef([AT_PURE_AND_LOC_IF])
|
||||||
@@ -212,11 +246,12 @@ m4_popdef([AT_LEXPARAM_IF])
|
|||||||
m4_popdef([AT_YACC_IF])
|
m4_popdef([AT_YACC_IF])
|
||||||
m4_popdef([AT_GLR_IF])
|
m4_popdef([AT_GLR_IF])
|
||||||
m4_popdef([AT_SKEL_CC_IF])
|
m4_popdef([AT_SKEL_CC_IF])
|
||||||
|
m4_popdef([AT_LANG])
|
||||||
m4_popdef([AT_SKEL_JAVA_IF])
|
m4_popdef([AT_SKEL_JAVA_IF])
|
||||||
m4_popdef([AT_GLR_CC_IF])
|
m4_popdef([AT_GLR_CC_IF])
|
||||||
m4_popdef([AT_LALR1_CC_IF])
|
m4_popdef([AT_LALR1_CC_IF])
|
||||||
m4_popdef([AT_DEFINES_IF])
|
m4_popdef([AT_DEFINES_IF])
|
||||||
AT_LOC_POPDEF
|
AT_LOC_POPDEF])dnl
|
||||||
])# AT_BISON_OPTION_POPDEFS
|
])# AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
|
|
||||||
@@ -267,8 +302,122 @@ m4_define([AT_DATA_GRAMMAR],
|
|||||||
$2])
|
$2])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# AT_YYLEX_PROTOTYPE
|
||||||
|
# AT_YYLEX_DECLARE_EXTERN
|
||||||
|
# AT_YYLEX_DECLARE
|
||||||
|
# AT_YYLEX_DEFINE([INPUT], [ACTION])
|
||||||
|
# ----------------------------------
|
||||||
|
# INPUT can be empty, or in double quotes, or a list (in braces).
|
||||||
|
# ACTION may compute yylval for instance, using "res" as token type,
|
||||||
|
# and "toknum" as the number of calls to yylex (starting at 0).
|
||||||
|
m4_define([AT_YYLEX_PROTOTYPE],
|
||||||
|
[int AT_NAME_PREFIX[]lex (]AT_YYLEX_FORMALS[)[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYLEX_DECLARE_EXTERN],
|
||||||
|
[AT_YYLEX_PROTOTYPE;dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYLEX_DECLARE],
|
||||||
|
[static AT_YYLEX_DECLARE_EXTERN[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYLEX_DEFINE],
|
||||||
|
[[#include <assert.h>
|
||||||
|
static
|
||||||
|
]AT_YYLEX_PROTOTYPE[
|
||||||
|
{
|
||||||
|
]m4_bmatch([$1], [^\(".*"\)?$],
|
||||||
|
[[static char const input[] = ]m4_default([$1], [""])],
|
||||||
|
[[static int const input[] = ]$1])[;
|
||||||
|
static size_t toknum = 0;
|
||||||
|
int res;
|
||||||
|
]AT_USE_LEX_ARGS[;
|
||||||
|
assert (toknum < sizeof input / sizeof input[0]);
|
||||||
|
res = input[toknum++];
|
||||||
|
]$2[;]AT_LOCATION_IF([[
|
||||||
|
]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1;
|
||||||
|
]AT_LOC_FIRST_COLUMN[ = ]AT_LOC_LAST_COLUMN[ = toknum;]])[
|
||||||
|
return res;
|
||||||
|
}]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# AT_YYERROR_PROTOTYPE
|
||||||
|
# AT_YYERROR_DECLARE_EXTERN
|
||||||
|
# AT_YYERROR_DECLARE
|
||||||
|
# AT_YYERROR_DEFINE
|
||||||
|
# -------------------------
|
||||||
|
# Must be called inside a AT_BISON_OPTION_PUSHDEFS/POPDEFS pair.
|
||||||
|
m4_define([AT_YYERROR_FORMALS],
|
||||||
|
[m4_case(AT_LANG,
|
||||||
|
[c], [AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])[const char *msg]])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYERROR_PROTOTYPE],
|
||||||
|
[m4_case(AT_LANG,
|
||||||
|
[c], [[void ]AT_NAME_PREFIX[error (]AT_YYERROR_FORMALS[)]])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYERROR_DECLARE_EXTERN],
|
||||||
|
[m4_case(AT_LANG,
|
||||||
|
[c], [AT_YYERROR_PROTOTYPE;])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYERROR_DECLARE],
|
||||||
|
[m4_case(AT_LANG,
|
||||||
|
[c], [static AT_YYERROR_DECLARE_EXTERN])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYERROR_DEFINE],
|
||||||
|
[m4_case(AT_LANG,
|
||||||
|
[c], [[#include <stdio.h>
|
||||||
|
/* A C error reporting function. */
|
||||||
|
static
|
||||||
|
]AT_YYERROR_PROTOTYPE[
|
||||||
|
{
|
||||||
|
]AT_YYERROR_SEES_LOC_IF([[
|
||||||
|
fprintf (stderr, "%d.%d",
|
||||||
|
]AT_LOC_FIRST_LINE[, ]AT_LOC_FIRST_COLUMN[);
|
||||||
|
if (]AT_LOC_FIRST_LINE[ != ]AT_LOC_LAST_LINE[)
|
||||||
|
fprintf (stderr, "-%d.%d",
|
||||||
|
]AT_LOC_LAST_LINE[, ]AT_LOC_LAST_COLUMN[ - 1);
|
||||||
|
else if (]AT_LOC_FIRST_COLUMN[ != ]AT_LOC_LAST_COLUMN[ - 1)
|
||||||
|
fprintf (stderr, "-%d",
|
||||||
|
]AT_LOC_LAST_COLUMN[ - 1);
|
||||||
|
fprintf (stderr, ": ");]])[
|
||||||
|
fprintf (stderr, "%s\n", msg);
|
||||||
|
}]],
|
||||||
|
[c++], [[/* A C++ error reporting function. */
|
||||||
|
void
|
||||||
|
]AT_NAME_PREFIX[::parser::error (const location_type& l, const std::string& m)
|
||||||
|
{
|
||||||
|
(void) l;
|
||||||
|
std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
|
||||||
|
}]],
|
||||||
|
[java], [AT_LOCATION_IF([[public void yyerror (Calc.Location l, String s)
|
||||||
|
{
|
||||||
|
if (l == null)
|
||||||
|
System.err.println (s);
|
||||||
|
else
|
||||||
|
System.err.println (l + ": " + s);
|
||||||
|
}
|
||||||
|
]], [[
|
||||||
|
public void yyerror (String s)
|
||||||
|
{
|
||||||
|
System.err.println (s);
|
||||||
|
}]])])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
## --------------- ##
|
||||||
|
## Running Bison. ##
|
||||||
|
## --------------- ##
|
||||||
|
|
||||||
# AT_BISON_CHECK(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
# AT_BISON_CHECK(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
|
# High-level routine that may call bison several times, under different
|
||||||
|
# conditions.
|
||||||
|
#
|
||||||
# Check Bison by invoking `bison BISON_ARGS'. BISON_ARGS should not contain
|
# Check Bison by invoking `bison BISON_ARGS'. BISON_ARGS should not contain
|
||||||
# shell constructs (such as redirection or pipes) that would prevent
|
# shell constructs (such as redirection or pipes) that would prevent
|
||||||
# appending additional command-line arguments for bison. OTHER_AT_CHECK_ARGS
|
# appending additional command-line arguments for bison. OTHER_AT_CHECK_ARGS
|
||||||
@@ -289,83 +438,93 @@ $2])
|
|||||||
#
|
#
|
||||||
# 4. If stderr contains a warning, -Wnone and --warnings=none suppress it.
|
# 4. If stderr contains a warning, -Wnone and --warnings=none suppress it.
|
||||||
m4_define([AT_BISON_CHECK],
|
m4_define([AT_BISON_CHECK],
|
||||||
[m4_if(m4_quote($2), [0], [AT_BISON_CHECK_XML($@)],
|
[m4_null_if([$2], [AT_BISON_CHECK_XML($@)])
|
||||||
m4_quote($2), [], [AT_BISON_CHECK_XML($@)])
|
|
||||||
AT_BISON_CHECK_NO_XML($@)])
|
AT_BISON_CHECK_NO_XML($@)])
|
||||||
|
|
||||||
m4_define([AT_BISON_WERROR_MSG],
|
m4_define([AT_BISON_WERROR_MSG],
|
||||||
[[bison: warnings being treated as errors]])
|
[[bison: warnings being treated as errors]])
|
||||||
|
|
||||||
|
|
||||||
|
# AT_BISON_CHECK_(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Low-level macro to run bison once.
|
||||||
|
m4_define([AT_BISON_CHECK_],
|
||||||
|
[AT_CHECK(AT_QUELL_VALGRIND[[ bison ]]$@)])
|
||||||
|
|
||||||
|
|
||||||
|
# AT_BISON_CHECK_WARNINGS(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# Check that warnings (if some are expected) are correctly
|
||||||
|
# turned into errors with -Werror, etc.
|
||||||
|
m4_define([AT_BISON_CHECK_WARNINGS],
|
||||||
|
[m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
|
||||||
|
[m4_null_if([$2], [AT_BISON_CHECK_WARNINGS_($@)])])])
|
||||||
|
|
||||||
|
m4_define([AT_BISON_CHECK_WARNINGS_],
|
||||||
|
[[# Defining POSIXLY_CORRECT causes bison to complain if options
|
||||||
|
# are added after the grammar file name, so skip these checks
|
||||||
|
# in that case.
|
||||||
|
if test -z "${POSIXLY_CORRECT+set}"; then
|
||||||
|
]AT_SAVE_SPECIAL_FILES[
|
||||||
|
|
||||||
|
# To avoid expanding it repeatedly, store specified stdout.
|
||||||
|
]AT_DATA([expout], [$3])[
|
||||||
|
|
||||||
|
# Run with -Werror.
|
||||||
|
]AT_BISON_CHECK_([$1[ -Werror]], [[1]], [expout], [stderr])[
|
||||||
|
|
||||||
|
# Build expected stderr up to and including the "warnings being
|
||||||
|
# treated as errors" message.
|
||||||
|
]AT_DATA([[at-bison-check-warnings]], [$4])[
|
||||||
|
at_bison_check_first=`sed -n \
|
||||||
|
'/: warning: /{=;q;}' at-bison-check-warnings`
|
||||||
|
: ${at_bison_check_first:=1}
|
||||||
|
at_bison_check_first_tmp=`sed -n \
|
||||||
|
'/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings`
|
||||||
|
: ${at_bison_check_first_tmp:=1}
|
||||||
|
if test $at_bison_check_first_tmp -lt $at_bison_check_first; then
|
||||||
|
at_bison_check_first=$at_bison_check_first_tmp
|
||||||
|
fi
|
||||||
|
if test $at_bison_check_first -gt 1; then
|
||||||
|
sed -n "1,`expr $at_bison_check_first - 1`"p \
|
||||||
|
at-bison-check-warnings > experr
|
||||||
|
fi
|
||||||
|
echo ']AT_BISON_WERROR_MSG[' >> experr
|
||||||
|
|
||||||
|
# Finish building expected stderr and check. Unlike warnings,
|
||||||
|
# complaints cause bison to exit early. Thus, with -Werror, bison
|
||||||
|
# does not necessarily report all warnings that it does without
|
||||||
|
# -Werror, but it at least reports one.
|
||||||
|
at_bison_check_last=`sed -n '$=' stderr`
|
||||||
|
: ${at_bison_check_last:=1}
|
||||||
|
at_bison_check_last=`expr $at_bison_check_last - 1`
|
||||||
|
sed -n "$at_bison_check_first,$at_bison_check_last"p \
|
||||||
|
at-bison-check-warnings >> experr
|
||||||
|
]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \
|
||||||
|
stderr 1>&2]], [[0]], [[]], [experr])[
|
||||||
|
|
||||||
|
# Now check --warnings=error.
|
||||||
|
cp stderr experr
|
||||||
|
]AT_BISON_CHECK_([$1[ --warnings=error]], [[1]], [expout], [experr])[
|
||||||
|
|
||||||
|
# Now check -Wnone and --warnings=none by making sure that
|
||||||
|
# -Werror doesn't change the exit status when -Wnone or
|
||||||
|
# --warnings=none is specified.
|
||||||
|
]AT_BISON_CHECK_([$1[ -Wnone -Werror]], [[0]], [expout])[
|
||||||
|
]AT_BISON_CHECK_([$1[ --warnings=none -Werror]], [[0]], [expout])[
|
||||||
|
|
||||||
|
]AT_RESTORE_SPECIAL_FILES[
|
||||||
|
fi]dnl
|
||||||
|
])
|
||||||
|
|
||||||
# AT_BISON_CHECK_NO_XML(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
# AT_BISON_CHECK_NO_XML(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
||||||
# --------------------------------------------------------
|
# --------------------------------------------------------
|
||||||
# Same as AT_BISON_CHECK except don't perform XML/XSLT checks. This is useful
|
# Same as AT_BISON_CHECK except don't perform XML/XSLT checks. This is useful
|
||||||
# when a tortured grammar's XML is known to be too large for xsltproc to
|
# when a tortured grammar's XML is known to be too large for xsltproc to
|
||||||
# handle.
|
# handle.
|
||||||
m4_define([AT_BISON_CHECK_NO_XML],
|
m4_define([AT_BISON_CHECK_NO_XML],
|
||||||
[AT_CHECK(m4_if(m4_quote($2), [0], [], m4_quote($2), [], [],
|
[AT_CHECK(m4_null_if([$2], [], [AT_QUELL_VALGRIND ])[[bison ]]$@)
|
||||||
[AT_QUELL_VALGRIND ])[[bison ]]$@)
|
AT_BISON_CHECK_WARNINGS($@)])
|
||||||
m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
|
|
||||||
m4_quote(m4_if(m4_quote($2), [], [0], [$2])), [0], [[
|
|
||||||
# Defining POSIXLY_CORRECT causes bison to complain if options
|
|
||||||
# are added after the grammar file name, so skip these checks
|
|
||||||
# in that case.
|
|
||||||
if test -z "${POSIXLY_CORRECT+set}"; then
|
|
||||||
]AT_SAVE_SPECIAL_FILES[
|
|
||||||
|
|
||||||
# To avoid expanding it repeatedly, store specified stdout.
|
|
||||||
]AT_DATA([expout], [$3])[
|
|
||||||
|
|
||||||
# Run with -Werror.
|
|
||||||
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Werror]],
|
|
||||||
[[1]], [expout], [stderr])[
|
|
||||||
|
|
||||||
# Build expected stderr up to and including the "warnings being
|
|
||||||
# treated as errors" message.
|
|
||||||
]AT_DATA([[at-bison-check-warnings]], [$4])[
|
|
||||||
at_bison_check_first=`sed -n \
|
|
||||||
'/: warning: /{=;q;}' at-bison-check-warnings`
|
|
||||||
: ${at_bison_check_first:=1}
|
|
||||||
at_bison_check_first_tmp=`sed -n \
|
|
||||||
'/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings`
|
|
||||||
: ${at_bison_check_first_tmp:=1}
|
|
||||||
if test $at_bison_check_first_tmp -lt $at_bison_check_first; then
|
|
||||||
at_bison_check_first=$at_bison_check_first_tmp
|
|
||||||
fi
|
|
||||||
if test $at_bison_check_first -gt 1; then
|
|
||||||
sed -n "1,`expr $at_bison_check_first - 1`"p \
|
|
||||||
at-bison-check-warnings > experr
|
|
||||||
fi
|
|
||||||
echo ']AT_BISON_WERROR_MSG[' >> experr
|
|
||||||
|
|
||||||
# Finish building expected stderr and check. Unlike warnings,
|
|
||||||
# complaints cause bison to exit early. Thus, with -Werror, bison
|
|
||||||
# does not necessarily report all warnings that it does without
|
|
||||||
# -Werror, but it at least reports one.
|
|
||||||
at_bison_check_last=`sed -n '$=' stderr`
|
|
||||||
: ${at_bison_check_last:=1}
|
|
||||||
at_bison_check_last=`expr $at_bison_check_last - 1`
|
|
||||||
sed -n "$at_bison_check_first,$at_bison_check_last"p \
|
|
||||||
at-bison-check-warnings >> experr
|
|
||||||
]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \
|
|
||||||
stderr 1>&2]], [[0]], [[]], [experr])[
|
|
||||||
|
|
||||||
# Now check --warnings=error.
|
|
||||||
cp stderr experr
|
|
||||||
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=error]],
|
|
||||||
[[1]], [expout], [experr])[
|
|
||||||
|
|
||||||
# Now check -Wnone and --warnings=none by making sure that
|
|
||||||
# -Werror doesn't change the exit status when -Wnone or
|
|
||||||
# --warnings=none is specified.
|
|
||||||
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Wnone -Werror]],
|
|
||||||
[[0]], [expout])[
|
|
||||||
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=none \
|
|
||||||
-Werror]], [[0]], [expout])[
|
|
||||||
|
|
||||||
]AT_RESTORE_SPECIAL_FILES[
|
|
||||||
fi
|
|
||||||
]])
|
|
||||||
])
|
|
||||||
|
|
||||||
# AT_BISON_CHECK_XML(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
# AT_BISON_CHECK_XML(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
@@ -383,11 +542,11 @@ m4_define([AT_BISON_CHECK_XML],
|
|||||||
[--xml=[^][ ]*], [])])dnl
|
[--xml=[^][ ]*], [])])dnl
|
||||||
# Don't combine these Bison invocations since we want to be sure that
|
# Don't combine these Bison invocations since we want to be sure that
|
||||||
# --report=all isn't required to get the full XML file.
|
# --report=all isn't required to get the full XML file.
|
||||||
AT_CHECK([[bison --report=all --report-file=xml-tests/test.output \
|
AT_BISON_CHECK_([[--report=all --report-file=xml-tests/test.output \
|
||||||
--graph=xml-tests/test.dot ]]AT_BISON_ARGS,
|
--graph=xml-tests/test.dot ]]AT_BISON_ARGS,
|
||||||
[[0]], [ignore], [ignore])
|
[[0]], [ignore], [ignore])
|
||||||
AT_CHECK([[bison --xml=xml-tests/test.xml ]]AT_BISON_ARGS,
|
AT_BISON_CHECK_([[--xml=xml-tests/test.xml ]]AT_BISON_ARGS,
|
||||||
[[0]], [ignore], [ignore])
|
[[0]], [ignore], [ignore])
|
||||||
m4_popdef([AT_BISON_ARGS])dnl
|
m4_popdef([AT_BISON_ARGS])dnl
|
||||||
[cp xml-tests/test.output expout]
|
[cp xml-tests/test.output expout]
|
||||||
AT_CHECK([[$XSLTPROC \
|
AT_CHECK([[$XSLTPROC \
|
||||||
@@ -415,6 +574,8 @@ m4_define([AT_BISON_CHECK_XML],
|
|||||||
m4_define([AT_QUELL_VALGRIND],
|
m4_define([AT_QUELL_VALGRIND],
|
||||||
[[[VALGRIND_OPTS="$VALGRIND_OPTS --leak-check=summary --show-reachable=no"; export VALGRIND_OPTS;]]])
|
[[[VALGRIND_OPTS="$VALGRIND_OPTS --leak-check=summary --show-reachable=no"; export VALGRIND_OPTS;]]])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ------------------------ ##
|
## ------------------------ ##
|
||||||
## Compiling C, C++ Files. ##
|
## Compiling C, C++ Files. ##
|
||||||
## ------------------------ ##
|
## ------------------------ ##
|
||||||
@@ -422,21 +583,37 @@ m4_define([AT_QUELL_VALGRIND],
|
|||||||
|
|
||||||
# AT_COMPILE(OUTPUT, [SOURCES = OUTPUT.c])
|
# AT_COMPILE(OUTPUT, [SOURCES = OUTPUT.c])
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.',
|
# Compile SOURCES into OUTPUT.
|
||||||
# assume that we are linking too; this is a hack.
|
#
|
||||||
|
# If OUTPUT does not contain '.', assume that we are linking too,
|
||||||
|
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
|
||||||
|
# with trailing .o removed, and ".c" appended.
|
||||||
m4_define([AT_COMPILE],
|
m4_define([AT_COMPILE],
|
||||||
[AT_CHECK([$CC $CFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.c])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
|
[AT_CHECK(m4_join([ ],
|
||||||
|
[$CC $CFLAGS $CPPFLAGS],
|
||||||
|
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
|
||||||
|
[-o $1],
|
||||||
|
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).c])],
|
||||||
|
[m4_bmatch([$1], [[.]], [], [$LIBS])]),
|
||||||
0, [ignore], [ignore])])
|
0, [ignore], [ignore])])
|
||||||
|
|
||||||
# AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
|
# AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
|
||||||
# --------------------------------------------
|
# ---------------------------------------------
|
||||||
# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.',
|
# Compile SOURCES into OUTPUT. If the C++ compiler does not work,
|
||||||
# assume that we are linking too; this is a hack.
|
# ignore the test.
|
||||||
# If the C++ compiler does not work, ignore the test.
|
#
|
||||||
|
# If OUTPUT does not contain '.', assume that we are linking too,
|
||||||
|
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
|
||||||
|
# with trailing .o removed, and ".cc" appended.
|
||||||
m4_define([AT_COMPILE_CXX],
|
m4_define([AT_COMPILE_CXX],
|
||||||
[AT_KEYWORDS(c++)
|
[AT_KEYWORDS(c++)
|
||||||
AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
|
AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
|
||||||
AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.cc])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
|
AT_CHECK(m4_join([ ],
|
||||||
|
[$CXX $CXXFLAGS $CPPFLAGS],
|
||||||
|
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
|
||||||
|
[-o $1],
|
||||||
|
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])],
|
||||||
|
[m4_bmatch([$1], [[.]], [], [$LIBS])]),
|
||||||
0, [ignore], [ignore])])
|
0, [ignore], [ignore])])
|
||||||
|
|
||||||
# AT_JAVA_COMPILE(SOURCES)
|
# AT_JAVA_COMPILE(SOURCES)
|
||||||
@@ -445,32 +622,56 @@ AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1
|
|||||||
# is not installed.
|
# is not installed.
|
||||||
m4_define([AT_JAVA_COMPILE],
|
m4_define([AT_JAVA_COMPILE],
|
||||||
[AT_KEYWORDS(java)
|
[AT_KEYWORDS(java)
|
||||||
AT_CHECK([[test -n "$CONF_JAVA" || exit 77
|
AT_SKIP_IF([[test -z "$CONF_JAVAC"]])
|
||||||
test -n "$CONF_JAVAC" || exit 77]])
|
AT_SKIP_IF([[test -z "$CONF_JAVA"]])
|
||||||
AT_CHECK([[$SHELL ../../../javacomp.sh ]$1],
|
AT_CHECK([[$SHELL ../../../javacomp.sh ]$1],
|
||||||
[[0]], [ignore], [ignore])])
|
[[0]], [ignore], [ignore])])
|
||||||
|
|
||||||
# AT_FULL_COMPILE(OUTPUT, [OTHER])
|
# AT_LANG_COMPILE(OUTPUT, [SOURCES = OUTPUT.c]
|
||||||
# --------------------------------
|
# --------------------------------------------
|
||||||
|
# Compile SOURCES into OUTPUT. Skip if compiler does not work.
|
||||||
|
#
|
||||||
|
# If OUTPUT does not contain '.', assume that we are linking too,
|
||||||
|
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
|
||||||
|
# with trailing .o removed, and ".c"/".cc" appended.
|
||||||
|
m4_define([AT_LANG_COMPILE],
|
||||||
|
[m4_case(AT_LANG,
|
||||||
|
[c], [AT_COMPILE([$1], [$2])],
|
||||||
|
[c++], [AT_COMPILE_CXX([$1], [$2])],
|
||||||
|
[java], [AT_JAVA_COMPILE([$1.java], [$2])],
|
||||||
|
[m4_fatal([unknown language: ]m4_defn([AT_LANG]))])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# AT_FULL_COMPILE(OUTPUT, [OTHER1], [OTHER2])
|
||||||
|
# -------------------------------------------
|
||||||
# Compile OUTPUT.y to OUTPUT.c, OUTPUT.cc, or OUTPUT.java, and then
|
# Compile OUTPUT.y to OUTPUT.c, OUTPUT.cc, or OUTPUT.java, and then
|
||||||
# compile it to OUTPUT or OUTPUT.class. If OTHER is specified, compile
|
# compile it to OUTPUT or OUTPUT.class. If OTHER is specified, compile
|
||||||
# OUTPUT-OTHER.c, OUTPUT-OTHER.cc, or OUTPUT-OTHER.java to OUTPUT or
|
# OUTPUT-OTHER.c, OUTPUT-OTHER.cc, or OUTPUT-OTHER.java to OUTPUT or
|
||||||
# OUTPUT.java along with it. Relies on AT_SKEL_CC_IF and
|
# OUTPUT.java along with it. Relies on AT_SKEL_CC_IF and
|
||||||
# AT_SKEL_JAVA_IF.
|
# AT_SKEL_JAVA_IF.
|
||||||
m4_define([AT_FULL_COMPILE], [
|
m4_define([AT_FULL_COMPILE],
|
||||||
AT_SKEL_JAVA_IF([
|
[m4_case(AT_LANG,
|
||||||
AT_BISON_CHECK([[-o ]$1[.java ]$1[.y]])
|
[java],
|
||||||
AT_JAVA_COMPILE([$1[.java]]m4_ifval($2,
|
[AT_BISON_CHECK([-o $1.java $1.y])
|
||||||
[[$1[.java ]$1[-]$2[.java]]]))
|
AT_LANG_COMPILE([$1],
|
||||||
], [
|
m4_join([ ],
|
||||||
AT_SKEL_CC_IF([
|
[$1.java],
|
||||||
AT_BISON_CHECK([[-o ]$1[.cc ]$1[.y]])
|
m4_ifval($2, [[$1-$2.java]]),
|
||||||
AT_COMPILE_CXX([$1]m4_ifval($2, [, [$1[.cc ]$1[-]$2[.cc]]]))
|
m4_ifval($3, [[$1-$3.java]])))],
|
||||||
], [
|
[c++],
|
||||||
AT_BISON_CHECK([[-o ]$1[.c ]$1[.y]])
|
[AT_BISON_CHECK([-o $1.cc $1.y])
|
||||||
AT_COMPILE([$1]m4_ifval($2, [, [$1[.c ]$1[-]$2[.c]]]))
|
AT_LANG_COMPILE([$1],
|
||||||
])
|
m4_join([ ],
|
||||||
])
|
[$1.cc],
|
||||||
|
m4_ifval($2, [[$1-$2.cc]]),
|
||||||
|
m4_ifval($3, [[$1-$3.cc]])))],
|
||||||
|
[c],
|
||||||
|
[AT_BISON_CHECK([-o $1.c $1.y])
|
||||||
|
AT_LANG_COMPILE([$1],
|
||||||
|
m4_join([ ],
|
||||||
|
[$1.c],
|
||||||
|
m4_ifval($2, [[$1-$2.c]]),
|
||||||
|
m4_ifval($3, [[$1-$3.c]])))])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -577,12 +778,12 @@ m4_define([AT_TEST_TABLES_AND_PARSE],
|
|||||||
[m4_pushdef([AT_COND_CASE], [m4_case([$2], $][@)])
|
[m4_pushdef([AT_COND_CASE], [m4_case([$2], $][@)])
|
||||||
|
|
||||||
AT_SETUP([$1])
|
AT_SETUP([$1])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([$4])
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
}
|
}
|
||||||
|
|
||||||
]$4[
|
]$4[
|
||||||
@@ -592,13 +793,7 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
]$5[
|
]$5[
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -654,6 +849,7 @@ AT_PARSER_CHECK([[./input]],
|
|||||||
m4_ifval([$11], [m4_dquote($11)]),
|
m4_ifval([$11], [m4_dquote($11)]),
|
||||||
m4_ifval([$12], [m4_dquote($12)]))
|
m4_ifval([$12], [m4_dquote($12)]))
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
m4_popdef([AT_COND_CASE])])
|
m4_popdef([AT_COND_CASE])])
|
||||||
|
|||||||
+13
-17
@@ -19,7 +19,7 @@
|
|||||||
AT_BANNER([[Named references tests.]])
|
AT_BANNER([[Named references tests.]])
|
||||||
|
|
||||||
AT_SETUP([Tutorial calculator])
|
AT_SETUP([Tutorial calculator])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([test.y],
|
AT_DATA_GRAMMAR([test.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
@@ -33,8 +33,8 @@ FILE *input;
|
|||||||
static semantic_value global_result = 0;
|
static semantic_value global_result = 0;
|
||||||
static int global_count = 0;
|
static int global_count = 0;
|
||||||
static int power (int base, int exponent);
|
static int power (int base, int exponent);
|
||||||
static void yyerror (const char *s);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union
|
%union
|
||||||
@@ -83,12 +83,7 @@ exp:
|
|||||||
| '-' error { $$ = 0; YYERROR; }
|
| '-' error { $$ = 0; YYERROR; }
|
||||||
;
|
;
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void yyerror (const char *s)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_char (void)
|
static int get_char (void)
|
||||||
{
|
{
|
||||||
int res = getc (input);
|
int res = getc (input);
|
||||||
@@ -119,7 +114,8 @@ static int read_signed_integer (void)
|
|||||||
return sign * n;
|
return sign * n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int yylex (void)
|
static int
|
||||||
|
yylex (void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
/* Skip white space. */
|
/* Skip white space. */
|
||||||
@@ -166,10 +162,8 @@ int main (int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
status = yyparse ();
|
status = yyparse ();
|
||||||
fclose (input);
|
fclose (input);
|
||||||
if (global_result != result)
|
assert (global_result == result);
|
||||||
abort ();
|
assert (global_count == count);
|
||||||
if (global_count != count)
|
|
||||||
abort ();
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
@@ -190,6 +184,7 @@ AT_DATA([input.txt],
|
|||||||
AT_BISON_CHECK([-o test.c test.y])
|
AT_BISON_CHECK([-o test.c test.y])
|
||||||
AT_COMPILE([[test]])
|
AT_COMPILE([[test]])
|
||||||
AT_PARSER_CHECK([./test input.txt], 0, [], [stderr])
|
AT_PARSER_CHECK([./test input.txt], 0, [], [stderr])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
@@ -198,13 +193,13 @@ AT_CLEANUP
|
|||||||
|
|
||||||
|
|
||||||
AT_SETUP([Undefined and ambiguous references])
|
AT_SETUP([Undefined and ambiguous references])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([test.y],
|
AT_DATA_GRAMMAR([test.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
static int power (int base, int exponent);
|
static int power (int base, int exponent);
|
||||||
static void yyerror (const char *s);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union
|
%union
|
||||||
@@ -268,6 +263,7 @@ test.y:55.3-53: symbol not found in production: r12
|
|||||||
test.y:56.29-33: invalid reference: '$expo'
|
test.y:56.29-33: invalid reference: '$expo'
|
||||||
test.y:56.3-46: symbol not found in production: expo
|
test.y:56.3-46: symbol not found in production: expo
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|||||||
+5
-3
@@ -176,10 +176,11 @@ AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
|
|||||||
|
|
||||||
|
|
||||||
# AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
|
# AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
|
||||||
# -----------------------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
m4_define([AT_CHECK_OUTPUT_FILE_NAME],
|
m4_define([AT_CHECK_OUTPUT_FILE_NAME],
|
||||||
[AT_SETUP([Output file name: $1])
|
[AT_SETUP([Output file name: $1])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
# Skip if platform doesn't support file name. For example, Cygwin
|
# Skip if platform doesn't support file name. For example, Cygwin
|
||||||
# doesn't support file names containing ":" or "\".
|
# doesn't support file names containing ":" or "\".
|
||||||
AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]])
|
AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]])
|
||||||
@@ -187,8 +188,8 @@ AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]])
|
|||||||
AT_DATA_GRAMMAR([glr.y],
|
AT_DATA_GRAMMAR([glr.y],
|
||||||
[[%glr-parser
|
[[%glr-parser
|
||||||
%code {
|
%code {
|
||||||
int yylex (void);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
void yyerror (const char *);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
}
|
}
|
||||||
%%
|
%%
|
||||||
start: {};
|
start: {};
|
||||||
@@ -209,6 +210,7 @@ AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
|
|||||||
AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.c])"])
|
AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.c])"])
|
||||||
$2
|
$2
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
+15
-25
@@ -24,17 +24,18 @@ AT_BANNER([[Push Parsing Tests]])
|
|||||||
AT_SETUP([[Memory Leak for Early Deletion]])
|
AT_SETUP([[Memory Leak for Early Deletion]])
|
||||||
|
|
||||||
# Requires Valgrind.
|
# Requires Valgrind.
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define YYINITDEPTH 1
|
#define YYINITDEPTH 1
|
||||||
void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%define api.pure %define api.push-pull push
|
%define api.pure
|
||||||
|
%define api.push-pull push
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@@ -42,11 +43,7 @@ start: 'a' 'b' 'c' ;
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -71,6 +68,7 @@ main (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]])
|
AT_BISON_CHECK([[-o input.c input.y]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
@@ -85,13 +83,14 @@ AT_CLEANUP
|
|||||||
AT_SETUP([[Multiple impure instances]])
|
AT_SETUP([[Multiple impure instances]])
|
||||||
|
|
||||||
m4_pushdef([AT_MULTIPLE_IMPURE_INSTANCES_CHECK], [
|
m4_pushdef([AT_MULTIPLE_IMPURE_INSTANCES_CHECK], [
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([%define api.push-pull $1])
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]m4_if([$1], [[both]], [AT_YYLEX_DECLARE([])])[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%define api.push-pull ]$1[
|
%define api.push-pull ]$1[
|
||||||
@@ -101,28 +100,16 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
start: ;
|
start: ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
void
|
]m4_if([$1], [[both]], [AT_YYLEX_DEFINE])[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
yypstate *ps;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 2; ++i)
|
for (i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
ps = yypstate_new ();
|
yypstate *ps = yypstate_new ();
|
||||||
assert (ps);
|
assert (ps);
|
||||||
assert (yypstate_new () == YY_NULL);
|
assert (yypstate_new () == YY_NULL);
|
||||||
]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
|
]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
|
||||||
@@ -140,6 +127,7 @@ main (void)
|
|||||||
AT_BISON_CHECK([[-o input.c input.y]])
|
AT_BISON_CHECK([[-o input.c input.y]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
AT_PARSER_CHECK([[./input]])
|
AT_PARSER_CHECK([[./input]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
])
|
])
|
||||||
|
|
||||||
AT_MULTIPLE_IMPURE_INSTANCES_CHECK([[both]])
|
AT_MULTIPLE_IMPURE_INSTANCES_CHECK([[both]])
|
||||||
@@ -155,12 +143,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([[Unsupported Skeletons]])
|
AT_SETUP([[Unsupported Skeletons]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA([[input.y]],
|
AT_DATA([[input.y]],
|
||||||
[[%glr-parser
|
[[%glr-parser
|
||||||
%define api.push-pull push
|
%define api.push-pull push
|
||||||
%%
|
%%
|
||||||
start: ;
|
start: ;
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[input.y]], [[1]], [],
|
AT_BISON_CHECK([[input.y]], [[1]], [],
|
||||||
[[input.y:2.9-21: %define variable 'api.push-pull' is not used
|
[[input.y:2.9-21: %define variable 'api.push-pull' is not used
|
||||||
|
|||||||
+191
-197
@@ -24,10 +24,11 @@ AT_BANNER([[Regression tests.]])
|
|||||||
|
|
||||||
AT_SETUP([Trivial grammars])
|
AT_SETUP([Trivial grammars])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
#define YYSTYPE int *
|
#define YYSTYPE int *
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -37,9 +38,10 @@ int yylex (void);
|
|||||||
|
|
||||||
program: 'x';
|
program: 'x';
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_COMPILE([input.o], [-c input.c])
|
AT_COMPILE([input.o])
|
||||||
AT_COMPILE([input.o], [-DYYDEBUG -c input.c])
|
AT_COMPILE([input.o], [-DYYDEBUG -c input.c])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
@@ -52,10 +54,11 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([YYSTYPE typedef])
|
AT_SETUP([YYSTYPE typedef])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
typedef union { char const *val; } YYSTYPE;
|
typedef union { char const *val; } YYSTYPE;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -65,9 +68,10 @@ typedef union { char const *val; } YYSTYPE;
|
|||||||
|
|
||||||
program: { $$ = ""; };
|
program: { $$ = ""; };
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_COMPILE([input.o], [-c input.c])
|
AT_COMPILE([input.o])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
@@ -83,10 +87,11 @@ AT_SETUP([Early token definitions with --yacc])
|
|||||||
# Found in GCJ: they expect the tokens to be defined before the user
|
# Found in GCJ: they expect the tokens to be defined before the user
|
||||||
# prologue, so that they can use the token definitions in it.
|
# prologue, so that they can use the token definitions in it.
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union
|
%union
|
||||||
@@ -103,9 +108,10 @@ int yylex (void);
|
|||||||
exp: MY_TOKEN;
|
exp: MY_TOKEN;
|
||||||
%%
|
%%
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-y -o input.c input.y])
|
AT_BISON_CHECK([-y -o input.c input.y])
|
||||||
AT_COMPILE([input.o], [-c input.c])
|
AT_COMPILE([input.o])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
@@ -121,11 +127,12 @@ AT_SETUP([Early token definitions without --yacc])
|
|||||||
# Found in GCJ: they expect the tokens to be defined before the user
|
# Found in GCJ: they expect the tokens to be defined before the user
|
||||||
# prologue, so that they can use the token definitions in it.
|
# prologue, so that they can use the token definitions in it.
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
void print_my_token (void);
|
void print_my_token (void);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -146,9 +153,10 @@ print_my_token (void)
|
|||||||
exp: MY_TOKEN;
|
exp: MY_TOKEN;
|
||||||
%%
|
%%
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_COMPILE([input.o], [-c input.c])
|
AT_COMPILE([input.o])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
@@ -161,6 +169,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Braces parsing])
|
AT_SETUP([Braces parsing])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA([input.y],
|
AT_DATA([input.y],
|
||||||
[[/* Bison used to swallow the character after '}'. */
|
[[/* Bison used to swallow the character after '}'. */
|
||||||
|
|
||||||
@@ -168,6 +177,7 @@ AT_DATA([input.y],
|
|||||||
exp: { tests = {{{{{{{{{{}}}}}}}}}}; };
|
exp: { tests = {{{{{{{{{{}}}}}}}}}}; };
|
||||||
%%
|
%%
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-v -o input.c input.y])
|
AT_BISON_CHECK([-v -o input.c input.y])
|
||||||
|
|
||||||
@@ -183,6 +193,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Duplicate string])
|
AT_SETUP([Duplicate string])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA([input.y],
|
AT_DATA([input.y],
|
||||||
[[/* 'Bison -v' used to dump core when two tokens are defined with the same
|
[[/* 'Bison -v' used to dump core when two tokens are defined with the same
|
||||||
string, as LE and GE below. */
|
string, as LE and GE below. */
|
||||||
@@ -195,6 +206,7 @@ AT_DATA([input.y],
|
|||||||
exp: '(' exp ')' | NUM ;
|
exp: '(' exp ')' | NUM ;
|
||||||
%%
|
%%
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-v -o input.c input.y], 0, [],
|
AT_BISON_CHECK([-v -o input.c input.y], 0, [],
|
||||||
[[input.y:6.8-14: warning: symbol "<=" used more than once as a literal string
|
[[input.y:6.8-14: warning: symbol "<=" used more than once as a literal string
|
||||||
@@ -211,6 +223,7 @@ AT_SETUP([Rule Line Numbers])
|
|||||||
|
|
||||||
AT_KEYWORDS([report])
|
AT_KEYWORDS([report])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA([input.y],
|
AT_DATA([input.y],
|
||||||
[[%%
|
[[%%
|
||||||
expr:
|
expr:
|
||||||
@@ -240,6 +253,7 @@ expr:
|
|||||||
|
|
||||||
};
|
};
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-o input.c -v input.y])
|
AT_BISON_CHECK([-o input.c -v input.y])
|
||||||
|
|
||||||
@@ -428,13 +442,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Token definitions])
|
AT_SETUP([Token definitions])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
# Bison managed, when fed with '%token 'f' "f"' to #define 'f'!
|
# Bison managed, when fed with '%token 'f' "f"' to #define 'f'!
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[%{
|
[%{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
[%error-verbose
|
[%error-verbose
|
||||||
%token MYEOF 0 "end of file"
|
%token MYEOF 0 "end of file"
|
||||||
@@ -447,20 +462,8 @@ int yylex (void);
|
|||||||
%%
|
%%
|
||||||
exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!";
|
exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!";
|
||||||
%%
|
%%
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *s)
|
]AT_YYLEX_DEFINE([{ SPECIAL }])[
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static int called;
|
|
||||||
if (called++)
|
|
||||||
abort ();
|
|
||||||
return SPECIAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -468,6 +471,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
# Checking the warning message guarantees that the trigraph "??!" isn't
|
# Checking the warning message guarantees that the trigraph "??!" isn't
|
||||||
# unnecessarily escaped here even though it would need to be if encoded in a
|
# unnecessarily escaped here even though it would need to be if encoded in a
|
||||||
@@ -498,22 +502,24 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Characters Escapes])
|
AT_SETUP([Characters Escapes])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[%{
|
[%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
[%%
|
[%%
|
||||||
exp:
|
exp:
|
||||||
'\'' "\'"
|
'\'' "\'"
|
||||||
| '\"' "\""
|
| '\"' "\""
|
||||||
| '"' "'"
|
| '"' "'" /* Pacify font-lock-mode: ". */
|
||||||
;
|
;
|
||||||
]])
|
]])
|
||||||
# Pacify font-lock-mode: "
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_COMPILE([input.o], [-c input.c])
|
AT_COMPILE([input.o])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
@@ -832,13 +838,11 @@ AT_CLEANUP
|
|||||||
# so that possible bound checking compilers could check all the skeletons.
|
# so that possible bound checking compilers could check all the skeletons.
|
||||||
m4_define([_AT_DATA_DANCER_Y],
|
m4_define([_AT_DATA_DANCER_Y],
|
||||||
[AT_DATA_GRAMMAR([dancer.y],
|
[AT_DATA_GRAMMAR([dancer.y],
|
||||||
[%{
|
[[%code provides
|
||||||
static int yylex (AT_LALR1_CC_IF([int *], [void]));
|
{
|
||||||
AT_LALR1_CC_IF([],
|
]AT_YYERROR_DECLARE[
|
||||||
[#include <stdlib.h>
|
]AT_YYLEX_DECLARE[
|
||||||
#include <stdio.h>
|
}
|
||||||
static void yyerror (const char *);])
|
|
||||||
%}
|
|
||||||
$1
|
$1
|
||||||
%token ARROW INVALID NUMBER STRING DATA
|
%token ARROW INVALID NUMBER STRING DATA
|
||||||
%defines
|
%defines
|
||||||
@@ -883,15 +887,10 @@ member: STRING
|
|||||||
| INVALID
|
| INVALID
|
||||||
;
|
;
|
||||||
%%
|
%%
|
||||||
AT_LALR1_CC_IF(
|
]AT_YYERROR_DEFINE[
|
||||||
[/* A C++ error reporting function. */
|
]AT_YYLEX_DEFINE([":"])[
|
||||||
void
|
]AT_LALR1_CC_IF(
|
||||||
yy::parser::error (const location&, const std::string& m)
|
[int
|
||||||
{
|
|
||||||
std::cerr << m << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yyparse ()
|
yyparse ()
|
||||||
{
|
{
|
||||||
yy::parser parser;
|
yy::parser parser;
|
||||||
@@ -900,33 +899,14 @@ yyparse ()
|
|||||||
#endif
|
#endif
|
||||||
return parser.parse ();
|
return parser.parse ();
|
||||||
}
|
}
|
||||||
],
|
])[
|
||||||
[static void
|
|
||||||
yyerror (const char *s)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", s);
|
|
||||||
}])
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (AT_LALR1_CC_IF([int *lval], [void]))
|
|
||||||
[{
|
|
||||||
static int const tokens[] =
|
|
||||||
{
|
|
||||||
':', -1
|
|
||||||
};
|
|
||||||
static size_t toknum;
|
|
||||||
]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
|
|
||||||
if (! (toknum < sizeof tokens / sizeof *tokens))
|
|
||||||
abort ();
|
|
||||||
return tokens[toknum++];
|
|
||||||
}]
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
])
|
]])
|
||||||
])# _AT_DATA_DANCER_Y
|
])# _AT_DATA_DANCER_Y
|
||||||
|
|
||||||
|
|
||||||
@@ -937,7 +917,6 @@ m4_define([AT_CHECK_DANCER],
|
|||||||
[AT_SETUP([Dancer $1])
|
[AT_SETUP([Dancer $1])
|
||||||
AT_BISON_OPTION_PUSHDEFS([$1])
|
AT_BISON_OPTION_PUSHDEFS([$1])
|
||||||
_AT_DATA_DANCER_Y([$1])
|
_AT_DATA_DANCER_Y([$1])
|
||||||
AT_BISON_CHECK([-o dancer.c dancer.y])
|
|
||||||
AT_FULL_COMPILE([dancer])
|
AT_FULL_COMPILE([dancer])
|
||||||
AT_PARSER_CHECK([./dancer], 1, [],
|
AT_PARSER_CHECK([./dancer], 1, [],
|
||||||
[syntax error, unexpected ':'
|
[syntax error, unexpected ':'
|
||||||
@@ -960,12 +939,12 @@ AT_CHECK_DANCER([%skeleton "lalr1.cc"])
|
|||||||
# --------------------------------
|
# --------------------------------
|
||||||
m4_define([_AT_DATA_EXPECT2_Y],
|
m4_define([_AT_DATA_EXPECT2_Y],
|
||||||
[AT_DATA_GRAMMAR([expect2.y],
|
[AT_DATA_GRAMMAR([expect2.y],
|
||||||
[%{
|
[[%{
|
||||||
static int yylex (AT_LALR1_CC_IF([int *], [void]));
|
static int yylex (]AT_LALR1_CC_IF([int *], [void]));
|
||||||
AT_LALR1_CC_IF([],
|
AT_LALR1_CC_IF([],
|
||||||
[#include <stdio.h>
|
[[#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (const char *);])
|
]AT_YYERROR_DECLARE])[
|
||||||
%}
|
%}
|
||||||
$1
|
$1
|
||||||
%defines
|
%defines
|
||||||
@@ -982,58 +961,46 @@ e: e '+' t | t;
|
|||||||
t: A | B;
|
t: A | B;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
AT_LALR1_CC_IF(
|
]AT_YYERROR_DEFINE[
|
||||||
[/* A C++ error reporting function. */
|
]AT_LALR1_CC_IF(
|
||||||
void
|
[int
|
||||||
yy::parser::error (const location&, const std::string& m)
|
|
||||||
{
|
|
||||||
std::cerr << m << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yyparse ()
|
yyparse ()
|
||||||
{
|
{
|
||||||
yy::parser parser;
|
yy::parser parser;
|
||||||
return parser.parse ();
|
return parser.parse ();
|
||||||
}
|
}
|
||||||
],
|
])[
|
||||||
[static void
|
|
||||||
yyerror (const char *s)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", s);
|
|
||||||
}])
|
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
static int
|
static int
|
||||||
yylex (AT_LALR1_CC_IF([int *lval], [void]))
|
yylex (]AT_LALR1_CC_IF([int *lval], [void])[)
|
||||||
[{
|
{
|
||||||
static int const tokens[] =
|
static int const tokens[] =
|
||||||
{
|
{
|
||||||
1000, '+', '+', -1
|
1000, '+', '+', -1
|
||||||
};
|
};
|
||||||
static size_t toknum;
|
static size_t toknum;
|
||||||
]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
|
]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
|
||||||
if (! (toknum < sizeof tokens / sizeof *tokens))
|
assert (toknum < sizeof tokens / sizeof *tokens);
|
||||||
abort ();
|
|
||||||
return tokens[toknum++];
|
return tokens[toknum++];
|
||||||
}]
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
])
|
]])
|
||||||
])# _AT_DATA_EXPECT2_Y
|
])# _AT_DATA_EXPECT2_Y
|
||||||
|
|
||||||
|
|
||||||
# AT_CHECK_EXPECT2(BISON-OPTIONS)
|
# AT_CHECK_EXPECT2(BISON-OPTIONS)
|
||||||
# ------------------------------
|
# -------------------------------
|
||||||
# Generate the grammar, compile it, run it.
|
# Generate the grammar, compile it, run it.
|
||||||
m4_define([AT_CHECK_EXPECT2],
|
m4_define([AT_CHECK_EXPECT2],
|
||||||
[AT_SETUP([Expecting two tokens $1])
|
[AT_SETUP([Expecting two tokens $1])
|
||||||
AT_BISON_OPTION_PUSHDEFS([$1])
|
AT_BISON_OPTION_PUSHDEFS([$1])
|
||||||
_AT_DATA_EXPECT2_Y([$1])
|
_AT_DATA_EXPECT2_Y([$1])
|
||||||
AT_BISON_CHECK([-o expect2.c expect2.y])
|
|
||||||
AT_FULL_COMPILE([expect2])
|
AT_FULL_COMPILE([expect2])
|
||||||
AT_PARSER_CHECK([./expect2], 1, [],
|
AT_PARSER_CHECK([./expect2], 1, [],
|
||||||
[syntax error, unexpected '+', expecting A or B
|
[syntax error, unexpected '+', expecting A or B
|
||||||
@@ -1056,12 +1023,12 @@ AT_SETUP([Braced code in declaration in rules section])
|
|||||||
|
|
||||||
# Bison once mistook braced code in a declaration in the rules section to be a
|
# Bison once mistook braced code in a declaration in the rules section to be a
|
||||||
# rule action.
|
# rule action.
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@@ -1079,18 +1046,8 @@ start:
|
|||||||
%printer { fprintf (yyoutput, "PRINTER"); } 'a';
|
%printer { fprintf (yyoutput, "PRINTER"); } 'a';
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void
|
]AT_YYLEX_DEFINE(["a"])[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
return 'a';
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -1099,6 +1056,7 @@ main (void)
|
|||||||
return !yyparse ();
|
return !yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-t -o input.c input.y])
|
AT_BISON_CHECK([-t -o input.c input.y])
|
||||||
AT_COMPILE([input])
|
AT_COMPILE([input])
|
||||||
@@ -1196,12 +1154,12 @@ AT_SETUP([[Token number in precedence declaration]])
|
|||||||
|
|
||||||
# POSIX says token numbers can be declared in %left, %right, and %nonassoc, but
|
# POSIX says token numbers can be declared in %left, %right, and %nonassoc, but
|
||||||
# we lost this in Bison 1.50.
|
# we lost this in Bison 1.50.
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@@ -1221,19 +1179,8 @@ sr_conflict:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
]AT_YYLEX_DEFINE([{ 1, 2, 3, 0 }])[
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static int const input[] = { 1, 2, 3, 0 };
|
|
||||||
static int const *inputp = input;
|
|
||||||
return *inputp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -1241,6 +1188,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
|
AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
|
||||||
[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start
|
[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start
|
||||||
@@ -1283,11 +1231,12 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([[%error-verbose and YYSTACK_USE_ALLOCA]])
|
AT_SETUP([[%error-verbose and YYSTACK_USE_ALLOCA]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
#define YYSTACK_USE_ALLOCA 1
|
#define YYSTACK_USE_ALLOCA 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1323,28 +1272,18 @@ syntax_error:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
/* Induce two syntax error messages (which requires full error
|
||||||
{
|
recovery by shifting 3 tokens) in order to detect any loss of the
|
||||||
fprintf (stderr, "%s\n", msg);
|
reallocated buffer. */
|
||||||
}
|
]AT_YYLEX_DEFINE(["abc"])[
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
/* Induce two syntax error messages (which requires full error
|
|
||||||
recovery by shifting 3 tokens) in order to detect any loss of the
|
|
||||||
reallocated buffer. */
|
|
||||||
static char const *input = "abc";
|
|
||||||
return *input++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]])
|
AT_BISON_CHECK([[-o input.c input.y]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
@@ -1370,12 +1309,12 @@ AT_CLEANUP
|
|||||||
# yyparse would invoke yyerror using the old contents of yymsg.
|
# yyparse would invoke yyerror using the old contents of yymsg.
|
||||||
|
|
||||||
AT_SETUP([[%error-verbose overflow]])
|
AT_SETUP([[%error-verbose overflow]])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
|
|
||||||
/* This prevents this test case from having to induce error messages
|
/* This prevents this test case from having to induce error messages
|
||||||
large enough to overflow size_t. */
|
large enough to overflow size_t. */
|
||||||
@@ -1441,21 +1380,10 @@ syntax_error2:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
/* Induce two syntax error messages (which requires full error
|
||||||
{
|
recovery by shifting 3 tokens). */
|
||||||
fprintf (stderr, "%s\n", msg);
|
]AT_YYLEX_DEFINE(["abc"])[
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
/* Induce two syntax error messages (which requires full error
|
|
||||||
recovery by shifting 3 tokens). */
|
|
||||||
static char const *input = "abc";
|
|
||||||
return *input++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -1481,7 +1409,7 @@ AT_PARSER_CHECK([[./input]], [[2]], [],
|
|||||||
syntax error
|
syntax error
|
||||||
memory exhausted
|
memory exhausted
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
@@ -1499,7 +1427,7 @@ AT_BISON_OPTION_PUSHDEFS([$1])
|
|||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (]AT_PURE_IF([[YYSTYPE *]], [[void]])[);
|
int yylex (]AT_PURE_IF([[YYSTYPE *]], [[void]])[);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1520,13 +1448,7 @@ B: 'b' ;
|
|||||||
C: /*empty*/ { printf ("consistent default reduction\n"); } ;
|
C: /*empty*/ { printf ("consistent default reduction\n"); } ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
yylex (]AT_PURE_IF([[YYSTYPE *v]], [[void]])[)
|
yylex (]AT_PURE_IF([[YYSTYPE *v]], [[void]])[)
|
||||||
{
|
{
|
||||||
@@ -1592,13 +1514,13 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([[LAC: Memory exhaustion]])
|
AT_SETUP([[LAC: Memory exhaustion]])
|
||||||
|
|
||||||
m4_pushdef([AT_LAC_CHECK], [
|
m4_pushdef([AT_LAC_CHECK],
|
||||||
|
[AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
#define YYMAXDEPTH 8
|
#define YYMAXDEPTH 8
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1610,20 +1532,8 @@ S: A A A A A A A A A ;
|
|||||||
A: /*empty*/ | 'a' ;
|
A: /*empty*/ | 'a' ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
void
|
]AT_YYLEX_DEFINE(["$1"])[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const *input = "]$1[";
|
|
||||||
return *input++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -1637,12 +1547,12 @@ AT_BISON_CHECK([[-Dparse.lac=full -Dparse.lac.es-capacity-initial=1 \
|
|||||||
[[input.y: conflicts: 8 shift/reduce
|
[[input.y: conflicts: 8 shift/reduce
|
||||||
]])
|
]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
])
|
])
|
||||||
|
|
||||||
# Check for memory exhaustion during parsing.
|
# Check for memory exhaustion during parsing.
|
||||||
AT_LAC_CHECK([[]])
|
AT_LAC_CHECK([])
|
||||||
AT_PARSER_CHECK([[./input]], [[2]], [[]],
|
AT_PARSER_CHECK([[./input]], [[2]], [],
|
||||||
[[Starting parse
|
[[Starting parse
|
||||||
Entering state 0
|
Entering state 0
|
||||||
Reading a token: Now at end of input.
|
Reading a token: Now at end of input.
|
||||||
@@ -1655,8 +1565,8 @@ Stack now 0
|
|||||||
|
|
||||||
# Induce an immediate syntax error with an undefined token, and check
|
# Induce an immediate syntax error with an undefined token, and check
|
||||||
# for memory exhaustion while building syntax error message.
|
# for memory exhaustion while building syntax error message.
|
||||||
AT_LAC_CHECK([[z]], [[0]])
|
AT_LAC_CHECK([z], [[0]])
|
||||||
AT_PARSER_CHECK([[./input]], [[2]], [[]],
|
AT_PARSER_CHECK([[./input]], [[2]], [],
|
||||||
[[Starting parse
|
[[Starting parse
|
||||||
Entering state 0
|
Entering state 0
|
||||||
Reading a token: Next token is token $undefined ()
|
Reading a token: Next token is token $undefined ()
|
||||||
@@ -1673,3 +1583,87 @@ Stack now 0
|
|||||||
m4_popdef([AT_LAC_CHECK])
|
m4_popdef([AT_LAC_CHECK])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------------- ##
|
||||||
|
## Lex and parse params. ##
|
||||||
|
## ---------------------- ##
|
||||||
|
|
||||||
|
# AT_TEST(SKELETON)
|
||||||
|
# -----------------
|
||||||
|
# Check that the identifier of the params is properly fetched
|
||||||
|
# even when there are trailing blanks.
|
||||||
|
|
||||||
|
m4_pushdef([AT_TEST],
|
||||||
|
[AT_SETUP([[Lex and parse params: $1]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton $1])
|
||||||
|
|
||||||
|
## FIXME: Improve parsing of parse-param and use the generated
|
||||||
|
## yyerror.
|
||||||
|
AT_DATA_GRAMMAR([input.y],
|
||||||
|
[[%defines
|
||||||
|
%locations
|
||||||
|
%skeleton $1
|
||||||
|
%union { int ival; }
|
||||||
|
%parse-param { int x }
|
||||||
|
// Spaces, tabs, and new lines.
|
||||||
|
%parse-param { @&t@
|
||||||
|
int y @&t@
|
||||||
|
@&t@
|
||||||
|
@&t@
|
||||||
|
}
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
]AT_SKEL_CC_IF([], [[
|
||||||
|
static
|
||||||
|
void
|
||||||
|
yyerror (int x, int y, const char *msg)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "x: %d, y: %d, %s\n", x, y, msg);
|
||||||
|
}]])[
|
||||||
|
|
||||||
|
]AT_YYLEX_DECLARE[
|
||||||
|
%}
|
||||||
|
|
||||||
|
%%
|
||||||
|
exp: 'a' { fprintf (stdout, "x: %d, y: %d\n", x, y); };
|
||||||
|
%%
|
||||||
|
]AT_YYLEX_DEFINE(["a"])[
|
||||||
|
|
||||||
|
]AT_SKEL_CC_IF(
|
||||||
|
[AT_YYERROR_DEFINE
|
||||||
|
|
||||||
|
int
|
||||||
|
yyparse (int x, int y)
|
||||||
|
{
|
||||||
|
yy::parser parser(x, y);
|
||||||
|
return parser.parse ();
|
||||||
|
}
|
||||||
|
])[
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
return !!yyparse(1, 2);
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
|
||||||
|
AT_FULL_COMPILE([input])
|
||||||
|
AT_CHECK([./input], 0, [[x: 1, y: 2
|
||||||
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
|
AT_CLEANUP
|
||||||
|
])
|
||||||
|
|
||||||
|
## FIXME: test Java, and iterate over skeletons.
|
||||||
|
AT_TEST("yacc.c")
|
||||||
|
AT_TEST("glr.c")
|
||||||
|
AT_TEST("lalr1.cc")
|
||||||
|
AT_TEST("glr.cc")
|
||||||
|
|
||||||
|
m4_popdef([AT_TEST])
|
||||||
|
|||||||
+4
-7
@@ -83,10 +83,11 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([[Installed skeleton file names]])
|
AT_SETUP([[Installed skeleton file names]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
m4_pushdef([AT_GRAM],
|
m4_pushdef([AT_GRAM],
|
||||||
[[%{
|
[[%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
int yylex (void);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -99,12 +100,7 @@ start: ;
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -139,6 +135,7 @@ AT_PARSER_CHECK([[./input-gram]], [[1]], [],
|
|||||||
|
|
||||||
m4_popdef([AT_GRAM])
|
m4_popdef([AT_GRAM])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+59
-40
@@ -27,6 +27,11 @@ AT_BANNER([[User Actions.]])
|
|||||||
# errors.
|
# errors.
|
||||||
m4_define([AT_SYNCLINES_COMPILE],
|
m4_define([AT_SYNCLINES_COMPILE],
|
||||||
[AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
|
[AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
|
||||||
|
|
||||||
|
# Transform stderr into something like this:
|
||||||
|
#
|
||||||
|
# input.y:4: #error "4"
|
||||||
|
#
|
||||||
# In case GCC displays column information, strip it down.
|
# In case GCC displays column information, strip it down.
|
||||||
#
|
#
|
||||||
# input.y:4:2: #error "4" or
|
# input.y:4:2: #error "4" or
|
||||||
@@ -42,6 +47,11 @@ m4_define([AT_SYNCLINES_COMPILE],
|
|||||||
# =>
|
# =>
|
||||||
# input.y:4: #error "8"
|
# input.y:4: #error "8"
|
||||||
#
|
#
|
||||||
|
# The message may include a caret-error:
|
||||||
|
#
|
||||||
|
# input.y:1:2: error: #error "1"
|
||||||
|
# #error "1"
|
||||||
|
# ^
|
||||||
#
|
#
|
||||||
# And possibly distcc adds its bits.
|
# And possibly distcc adds its bits.
|
||||||
#
|
#
|
||||||
@@ -54,21 +64,24 @@ m4_define([AT_SYNCLINES_COMPILE],
|
|||||||
# distcc[35882] (dcc_connect_by_name) ERROR: failed to look up host "chrisimac": Unknown host
|
# distcc[35882] (dcc_connect_by_name) ERROR: failed to look up host "chrisimac": Unknown host
|
||||||
# distcc[35882] Warning: failed to distribute input.c to chrisimac/4, running locally instead
|
# distcc[35882] Warning: failed to distribute input.c to chrisimac/4, running locally instead
|
||||||
|
|
||||||
AT_CHECK([[sed -e '/^distcc\[[0-9]*\] /d' \
|
AT_CHECK([[perl -p -0777 - stderr <<\EOF
|
||||||
-e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' \
|
s/^distcc\[\d+\] .*\n//gm;
|
||||||
-e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' \
|
s/^([^:]+:\d+)[.:][^:]+:(.+)$/$][1:$][2/gm;
|
||||||
-e "/^[^:]*: In function '[^\']*':$/d" \
|
s/^([^:]+:\d+):[^#]*( #error)/$][1:$][2/gm;
|
||||||
stderr]],
|
s/^[^:]*: In function '[^']+':\n//gm;
|
||||||
0, [stdout])
|
s/^\ +#error.*\n\ *\^\n//gm;
|
||||||
|
EOF
|
||||||
|
]],
|
||||||
|
0, [stdout])
|
||||||
])
|
])
|
||||||
|
|
||||||
# AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
|
# AT_TEST(TITLE, INPUT, ERROR-MSG)
|
||||||
# -----------------------------------------
|
# --------------------------------
|
||||||
# Check that compiling the parser produced from INPUT cause GCC
|
# Check that compiling the parser produced from INPUT cause GCC
|
||||||
# to issue ERROR-MSG.
|
# to issue ERROR-MSG.
|
||||||
m4_define([AT_TEST_SYNCLINE],
|
m4_pushdef([AT_TEST],
|
||||||
[AT_SETUP([$1])
|
[AT_SETUP([$1])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
# It seems impossible to find a generic scheme to check the location
|
# It seems impossible to find a generic scheme to check the location
|
||||||
# of an error. Even requiring GCC is not sufficient, since for instance
|
# of an error. Even requiring GCC is not sufficient, since for instance
|
||||||
# the version modified by Apple:
|
# the version modified by Apple:
|
||||||
@@ -98,56 +111,59 @@ AT_DATA([[input.y]], [$2])
|
|||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_SYNCLINES_COMPILE([input.c])
|
AT_SYNCLINES_COMPILE([input.c])
|
||||||
AT_CHECK([cat stdout], 0, [$3])
|
AT_CHECK([cat stdout], 0, [$3])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## --------------------- ##
|
## ------------------- ##
|
||||||
## Prologue synch line. ##
|
## Prologue syncline. ##
|
||||||
## --------------------- ##
|
## ------------------- ##
|
||||||
|
|
||||||
|
|
||||||
AT_TEST_SYNCLINE([Prologue synch line],
|
AT_TEST([Prologue syncline],
|
||||||
[[%{
|
[[%{
|
||||||
#error "2"
|
#error "2"
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp: '0';
|
exp: '0';
|
||||||
|
%%
|
||||||
]],
|
]],
|
||||||
[input.y:2: #error "2"
|
[input.y:2: #error "2"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## ------------------- ##
|
## ----------------- ##
|
||||||
## %union synch line. ##
|
## %union syncline. ##
|
||||||
## ------------------- ##
|
## ----------------- ##
|
||||||
|
|
||||||
AT_TEST_SYNCLINE([%union synch line],
|
AT_TEST([%union syncline],
|
||||||
[[%union {
|
[[%union {
|
||||||
#error "2"
|
#error "2"
|
||||||
char dummy;
|
char dummy;
|
||||||
}
|
}
|
||||||
%{
|
%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp: '0';
|
exp: '0';
|
||||||
|
%%
|
||||||
]],
|
]],
|
||||||
[input.y:2: #error "2"
|
[input.y:2: #error "2"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## ------------------------- ##
|
## ----------------------- ##
|
||||||
## Postprologue synch line. ##
|
## Postprologue syncline. ##
|
||||||
## ------------------------- ##
|
## ----------------------- ##
|
||||||
|
|
||||||
AT_TEST_SYNCLINE([Postprologue synch line],
|
AT_TEST([Postprologue syncline],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
@@ -158,19 +174,20 @@ int yylex (void);
|
|||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp: '0';
|
exp: '0';
|
||||||
|
%%
|
||||||
]],
|
]],
|
||||||
[input.y:10: #error "10"
|
[input.y:10: #error "10"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## ------------------- ##
|
## ----------------- ##
|
||||||
## Action synch line. ##
|
## Action syncline. ##
|
||||||
## ------------------- ##
|
## ----------------- ##
|
||||||
|
|
||||||
AT_TEST_SYNCLINE([Action synch line],
|
AT_TEST([Action syncline],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp:
|
exp:
|
||||||
@@ -182,14 +199,14 @@ exp:
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## --------------------- ##
|
## ------------------- ##
|
||||||
## Epilogue synch line. ##
|
## Epilogue syncline. ##
|
||||||
## --------------------- ##
|
## ------------------- ##
|
||||||
|
|
||||||
AT_TEST_SYNCLINE([Epilogue synch line],
|
AT_TEST([Epilogue syncline],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp: '0';
|
exp: '0';
|
||||||
@@ -198,3 +215,5 @@ exp: '0';
|
|||||||
]],
|
]],
|
||||||
[input.y:8: #error "8"
|
[input.y:8: #error "8"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
m4_popdef([AT_TEST])
|
||||||
|
|||||||
+47
-62
@@ -42,7 +42,8 @@ esac])
|
|||||||
# Create FILE-NAME, containing a self checking parser for a huge
|
# Create FILE-NAME, containing a self checking parser for a huge
|
||||||
# triangular grammar.
|
# triangular grammar.
|
||||||
m4_define([AT_DATA_TRIANGULAR_GRAMMAR],
|
m4_define([AT_DATA_TRIANGULAR_GRAMMAR],
|
||||||
[AT_DATA([[gengram.pl]],
|
[AT_BISON_OPTION_PUSHDEFS
|
||||||
|
AT_DATA([[gengram.pl]],
|
||||||
[[#! /usr/bin/perl -w
|
[[#! /usr/bin/perl -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@@ -55,9 +56,10 @@ print <<EOF;
|
|||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
static int yylex (void);
|
#define MAX $max
|
||||||
static void yyerror (const char *msg);
|
]AT_YYLEX_DECLARE[
|
||||||
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
@@ -76,8 +78,8 @@ for my $size (1 .. $max)
|
|||||||
print <<EOF;
|
print <<EOF;
|
||||||
%%
|
%%
|
||||||
input:
|
input:
|
||||||
exp { if (\@S|@1 != 0) abort (); \$\$ = \@S|@1; }
|
exp { assert (\@S|@1 == 0); \$\$ = \@S|@1; }
|
||||||
| input exp { if (\@S|@2 != \@S|@1 + 1) abort (); \$\$ = \@S|@2; }
|
| input exp { assert (\@S|@2 == \@S|@1 + 1); \$\$ = \@S|@2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
exp:
|
exp:
|
||||||
@@ -95,14 +97,15 @@ for my $size (1 .. $max)
|
|||||||
};
|
};
|
||||||
print ";\n";
|
print ";\n";
|
||||||
|
|
||||||
print <<EOF;
|
print <<\EOF;
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
static int inner = 1;
|
static int inner = 1;
|
||||||
static int outer = 0;
|
static int outer = 0;
|
||||||
if (outer > $max)
|
if (outer > MAX)
|
||||||
return 0;
|
return 0;
|
||||||
else if (inner > outer)
|
else if (inner > outer)
|
||||||
{
|
{
|
||||||
@@ -112,13 +115,6 @@ yylex (void)
|
|||||||
}
|
}
|
||||||
return inner++;
|
return inner++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -127,6 +123,7 @@ main (void)
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
||||||
mv stdout $1
|
mv stdout $1
|
||||||
@@ -157,7 +154,8 @@ AT_CLEANUP
|
|||||||
# Create FILE-NAME, containing a self checking parser for a huge
|
# Create FILE-NAME, containing a self checking parser for a huge
|
||||||
# horizontal grammar.
|
# horizontal grammar.
|
||||||
m4_define([AT_DATA_HORIZONTAL_GRAMMAR],
|
m4_define([AT_DATA_HORIZONTAL_GRAMMAR],
|
||||||
[AT_DATA([[gengram.pl]],
|
[AT_BISON_OPTION_PUSHDEFS
|
||||||
|
AT_DATA([[gengram.pl]],
|
||||||
[[#! /usr/bin/perl -w
|
[[#! /usr/bin/perl -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@@ -170,9 +168,9 @@ print <<EOF;
|
|||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#define MAX $max
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%token
|
%token
|
||||||
@@ -193,25 +191,20 @@ print
|
|||||||
(map { "\"$_\"" } (1 .. $max)), ";"),
|
(map { "\"$_\"" } (1 .. $max)), ";"),
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
print <<EOF;
|
print <<\EOF;
|
||||||
%%
|
%%
|
||||||
|
#include <assert.h>
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
static int counter = 1;
|
static int counter = 1;
|
||||||
if (counter <= $max)
|
if (counter <= MAX)
|
||||||
return counter++;
|
return counter++;
|
||||||
if (counter++ != $max + 1)
|
assert (counter++ == MAX + 1);
|
||||||
abort ();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -223,6 +216,7 @@ EOF
|
|||||||
|
|
||||||
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
||||||
mv stdout $1
|
mv stdout $1
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -263,7 +257,8 @@ AT_CLEANUP
|
|||||||
# Create FILE-NAME, containing a self checking parser for a grammar
|
# Create FILE-NAME, containing a self checking parser for a grammar
|
||||||
# requiring SIZE lookahead tokens.
|
# requiring SIZE lookahead tokens.
|
||||||
m4_define([AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR],
|
m4_define([AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR],
|
||||||
[AT_DATA([[gengram.pl]],
|
[AT_BISON_OPTION_PUSHDEFS
|
||||||
|
AT_DATA([[gengram.pl]],
|
||||||
[[#! /usr/bin/perl -w
|
[[#! /usr/bin/perl -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@@ -277,9 +272,9 @@ print <<EOF;
|
|||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
|
# define MAX $max
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
@@ -324,17 +319,17 @@ for my $count (1 .. $max)
|
|||||||
print "n$count: token { \$\$ = $count; };\n";
|
print "n$count: token { \$\$ = $count; };\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
print <<EOF;
|
print <<\EOF;
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
static int return_token = 1;
|
static int return_token = 1;
|
||||||
static int counter = 1;
|
static int counter = 1;
|
||||||
if (counter > $max)
|
if (counter > MAX)
|
||||||
{
|
{
|
||||||
if (counter++ != $max + 1)
|
assert (counter++ == MAX + 1);
|
||||||
abort ();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (return_token)
|
if (return_token)
|
||||||
@@ -346,12 +341,6 @@ yylex (void)
|
|||||||
return counter++;
|
return counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -363,6 +352,7 @@ EOF
|
|||||||
|
|
||||||
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
||||||
mv stdout $1
|
mv stdout $1
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -390,7 +380,8 @@ AT_CLEANUP
|
|||||||
# ------------------------------------------------
|
# ------------------------------------------------
|
||||||
# A parser specialized in torturing the stack size.
|
# A parser specialized in torturing the stack size.
|
||||||
m4_define([AT_DATA_STACK_TORTURE],
|
m4_define([AT_DATA_STACK_TORTURE],
|
||||||
[# A grammar of parens growing the stack thanks to right recursion.
|
[AT_BISON_OPTION_PUSHDEFS([$2])
|
||||||
|
# A grammar of parens growing the stack thanks to right recursion.
|
||||||
# exp:
|
# exp:
|
||||||
AT_DATA([input.y],
|
AT_DATA([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
@@ -399,8 +390,8 @@ AT_DATA([input.y],
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
]$1[
|
]$1[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
]$2[
|
]$2[
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@@ -409,17 +400,12 @@ AT_DATA([input.y],
|
|||||||
%%
|
%%
|
||||||
exp: WAIT_FOR_EOF exp | ;
|
exp: WAIT_FOR_EOF exp | ;
|
||||||
%%
|
%%
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (const char *msg)
|
#include <assert.h>
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
if (yylval < 0)
|
assert (0 <= yylval);
|
||||||
abort ();
|
|
||||||
if (yylval--)
|
if (yylval--)
|
||||||
return WAIT_FOR_EOF;
|
return WAIT_FOR_EOF;
|
||||||
else
|
else
|
||||||
@@ -431,13 +417,12 @@ main (int argc, const char **argv)
|
|||||||
{
|
{
|
||||||
char *endp;
|
char *endp;
|
||||||
YYSTYPE yylval_init;
|
YYSTYPE yylval_init;
|
||||||
if (argc != 2)
|
assert (argc == 2);
|
||||||
abort ();
|
|
||||||
yylval_init = strtol (argv[1], &endp, 10);
|
yylval_init = strtol (argv[1], &endp, 10);
|
||||||
if (! (argv[1] != endp
|
assert (argv[1] != endp);
|
||||||
&& 0 <= yylval_init && yylval_init <= INT_MAX
|
assert (0 <= yylval_init);
|
||||||
&& errno != ERANGE))
|
assert (yylval_init <= INT_MAX);
|
||||||
abort ();
|
assert (errno != ERANGE);
|
||||||
yydebug = 1;
|
yydebug = 1;
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
@@ -452,8 +437,7 @@ main (int argc, const char **argv)
|
|||||||
[[ new_status = yypull_parse (ps);
|
[[ new_status = yypull_parse (ps);
|
||||||
]],
|
]],
|
||||||
[[ new_status = yyparse ();
|
[[ new_status = yyparse ();
|
||||||
]])[ if (count > 0 && new_status != status)
|
]])[ assert (0 <= count || new_status == status);
|
||||||
abort ();
|
|
||||||
status = new_status;
|
status = new_status;
|
||||||
}
|
}
|
||||||
]m4_bmatch([$2], [%push-],
|
]m4_bmatch([$2], [%push-],
|
||||||
@@ -462,6 +446,7 @@ main (int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS([$2])
|
||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_COMPILE([input])
|
AT_COMPILE([input])
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user