mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-16 22:25:14 +00:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f5542fe2d | ||
|
|
d065cb3853 | ||
|
|
49964a4fe0 | ||
|
|
68f91d58f1 | ||
|
|
42bcf1ce44 | ||
|
|
de7331a075 | ||
|
|
b0db817ff2 | ||
|
|
a565f73276 | ||
|
|
3cf3393bd4 | ||
|
|
e83be476a5 | ||
|
|
80a2826e69 | ||
|
|
657ed6d3be |
+444
-2891
File diff suppressed because it is too large
Load Diff
+22
-44
@@ -1,7 +1,7 @@
|
|||||||
## Process this file with automake to produce Makefile.in.
|
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||||
|
|
||||||
|
## Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# Copyright (C) 2001-2013 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
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
@@ -15,51 +15,29 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
AUTOMAKE_OPTIONS = subdir-objects
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
SUBDIRS = po runtime-po .
|
SUBDIRS = build-aux po runtime-po lib data src doc examples tests etc
|
||||||
|
|
||||||
# Files installed for use by Automake.
|
# Files installed for use by Automake.
|
||||||
aclocaldir = @aclocaldir@
|
aclocaldir = @aclocaldir@
|
||||||
aclocal_DATA = m4/bison-i18n.m4
|
aclocal_DATA = m4/bison-i18n.m4
|
||||||
|
|
||||||
EXTRA_DIST = .prev-version .version \
|
EXTRA_DIST = .prev-version .version \
|
||||||
cfg.mk ChangeLog-1998 ChangeLog-2012 PACKAGING
|
cfg.mk ChangeLog-1998 ChangeLog-2012 PACKAGING \
|
||||||
|
djgpp/Makefile.maint djgpp/README.in djgpp/config.bat \
|
||||||
|
djgpp/config.sed djgpp/config.site djgpp/config_h.sed \
|
||||||
|
djgpp/subpipe.c djgpp/subpipe.h djgpp/djunpack.bat \
|
||||||
|
djgpp/fnchange.lst djgpp/testsuite.sed
|
||||||
|
|
||||||
## Running the bison from this tarball. To generate our own parser,
|
MAINTAINER_CHECKS = \
|
||||||
## but also to run the tests. Of course, you ought to keep a sane
|
maintainer-check \
|
||||||
## version of Bison nearby...
|
maintainer-push-check \
|
||||||
BISON = $(top_builddir)/tests/bison
|
maintainer-xml-check \
|
||||||
BISON_IN = $(top_srcdir)/tests/bison.in
|
maintainer-release-check
|
||||||
YACC = $(BISON) -y
|
.PHONY: $(MAINTAINER_CHECKS)
|
||||||
AM_YFLAGS = -d -v --warnings=all,error --report=all
|
$(MAINTAINER_CHECKS):
|
||||||
|
$(AM_V_GEN)cd tests && $(MAKE) $(AM_MAKEFLAGS) $@
|
||||||
# Initialization before completion by local.mk's.
|
|
||||||
AM_CFLAGS = $(WARN_CFLAGS)
|
|
||||||
# Find builddir/src/scan-code.c etc.
|
|
||||||
AM_CPPFLAGS = -I. -Ilib -I$(top_srcdir) -I$(top_srcdir)/lib
|
|
||||||
BUILT_SOURCES =
|
|
||||||
CLEANFILES =
|
|
||||||
DISTCLEANFILES =
|
|
||||||
EXTRA_DIST += $(dist_TESTS)
|
|
||||||
MOSTLYCLEANDIRS =
|
|
||||||
MOSTLYCLEANFILES =
|
|
||||||
SUFFIXES =
|
|
||||||
TESTS = $(dist_TESTS)
|
|
||||||
check_PROGRAMS =
|
|
||||||
dist_TESTS =
|
|
||||||
noinst_LIBRARIES =
|
|
||||||
|
|
||||||
include build-aux/local.mk
|
|
||||||
include data/local.mk
|
|
||||||
include djgpp/local.mk
|
|
||||||
include doc/local.mk
|
|
||||||
include etc/local.mk
|
|
||||||
include examples/local.mk
|
|
||||||
include lib/local.mk
|
|
||||||
include src/local.mk
|
|
||||||
include tests/local.mk
|
|
||||||
|
|
||||||
# See comments in build-aux/git-version-gen. However, we make .version depend
|
# See comments in build-aux/git-version-gen. However, we make .version depend
|
||||||
# on configure so that .version and VERSION/PACKAGE_VERSION stay in sync in the
|
# on configure so that .version and VERSION/PACKAGE_VERSION stay in sync in the
|
||||||
@@ -70,19 +48,19 @@ include tests/local.mk
|
|||||||
# a developer might naively reference .version in a test case while the bison
|
# a developer might naively reference .version in a test case while the bison
|
||||||
# executable still compiles with VERSION, and so the test case might fail or
|
# executable still compiles with VERSION, and so the test case might fail or
|
||||||
# pass incorrectly.
|
# pass incorrectly.
|
||||||
BUILT_SOURCES += $(top_srcdir)/.version
|
BUILT_SOURCES = $(top_srcdir)/.version
|
||||||
$(top_srcdir)/.version: configure
|
$(top_srcdir)/.version: configure
|
||||||
echo $(VERSION) > $@-t && mv $@-t $@
|
$(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
|
||||||
dist-hook: gen-ChangeLog
|
dist-hook: gen-ChangeLog
|
||||||
echo $(VERSION) > $(distdir)/.tarball-version
|
$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
|
||||||
|
|
||||||
.PHONY: update-b4-copyright update-package-copyright-year
|
.PHONY: update-b4-copyright update-package-copyright-year
|
||||||
update-b4-copyright:
|
update-b4-copyright:
|
||||||
find $(srcdir)/data -type f \
|
$(AM_V_GEN)find $(srcdir)/data -type f \
|
||||||
| xargs $(srcdir)/build-aux/$@
|
| xargs $(srcdir)/build-aux/$@
|
||||||
@echo 'warning: src/parse-gram.[hc] may need to be regenerated.'
|
@echo 'warning: src/parse-gram.[hc] may need to be regenerated.'
|
||||||
update-package-copyright-year:
|
update-package-copyright-year:
|
||||||
$(srcdir)/build-aux/$@ $(srcdir)/configure.ac
|
$(AM_V_GEN)$(srcdir)/build-aux/$@ $(srcdir)/configure.ac
|
||||||
|
|
||||||
gen_start_date = 2012-01-16
|
gen_start_date = 2012-01-16
|
||||||
.PHONY: gen-ChangeLog
|
.PHONY: gen-ChangeLog
|
||||||
|
|||||||
@@ -1,307 +1,14 @@
|
|||||||
GNU Bison NEWS
|
GNU Bison NEWS
|
||||||
|
|
||||||
* Noteworthy changes in release ?.? (????-??-??) [?]
|
* Noteworthy changes in release 2.7.1 (2013-04-15) [stable]
|
||||||
|
|
||||||
** WARNING: Future backward-incompatibilities!
|
|
||||||
|
|
||||||
Bison will stop adding a semicolon at the end of the actions (as announced
|
|
||||||
in the release 2.5):
|
|
||||||
|
|
||||||
foo.y:2.22: warning: a ';' might be needed at the end of action code
|
|
||||||
exp: "num" { $$ = $1 }
|
|
||||||
^
|
|
||||||
foo.y:2.22: future versions of Bison will not add the ';'
|
|
||||||
|
|
||||||
Like other GNU packages, Bison will start using some of the C99 features
|
|
||||||
for its own code, especially the definition of variables after statements.
|
|
||||||
The generated C parsers still aim at C90.
|
|
||||||
|
|
||||||
** Backward incompatible changes
|
|
||||||
|
|
||||||
*** Obsolete features
|
|
||||||
|
|
||||||
Support for YYFAIL is removed (deprecated in Bison 2.4.2): use YYERROR.
|
|
||||||
|
|
||||||
Support for yystype and yyltype is removed (deprecated in Bison 1.875):
|
|
||||||
use YYSTYPE and YYLTYPE.
|
|
||||||
|
|
||||||
Support for YYLEX_PARAM and YYPARSE_PARAM is removed (deprecated in Bison
|
|
||||||
1.875): use %lex-param, %parse-param, or %param.
|
|
||||||
|
|
||||||
** Bug fixes
|
** Bug fixes
|
||||||
|
|
||||||
*** The epilogue is no longer affected by internal #defines
|
*** Fix compiler attribute portability (yacc.c)
|
||||||
|
|
||||||
The glr.c skeleton uses defines such as #define yylval (yystackp->yyval) in
|
With locations enabled, __attribute__ was used unprotected.
|
||||||
generated code. These weren't properly undefined before the inclusion of
|
|
||||||
the user epilogue, so functions such as the following were butchered by the
|
|
||||||
preprocessor expansion:
|
|
||||||
|
|
||||||
int yylex (YYSTYPE *yylval);
|
*** Fix some compiler warnings (lalr1.cc)
|
||||||
|
|
||||||
This is has been fixed: yylval, yynerrs, yychar, and yylloc are now valid
|
|
||||||
identifiers for user-provided variables.
|
|
||||||
|
|
||||||
*** stdio.h is no longer needed when locations are enabled (yacc.c)
|
|
||||||
|
|
||||||
Changes in Bison 2.7 introduced a dependency on FILE and fprintf when
|
|
||||||
locations are enabled. This is fixed.
|
|
||||||
|
|
||||||
** Diagnostics reported by Bison
|
|
||||||
|
|
||||||
Most of these features were contributed by Théophile Ranquet and Victor
|
|
||||||
Santet.
|
|
||||||
|
|
||||||
*** Carets
|
|
||||||
|
|
||||||
Version 2.7 introduced caret errors, for a prettier output. These are now
|
|
||||||
activated by default. The old format can still be used by invoking Bison
|
|
||||||
with -fno-caret (or -fnone).
|
|
||||||
|
|
||||||
*** Enhancements of the -Werror option
|
|
||||||
|
|
||||||
The -Werror=CATEGORY option is now recognized, and will treat specified
|
|
||||||
warnings as errors. The warnings need not have been explicitly activated
|
|
||||||
using the -W option, this is similar to what GCC 4.7 does.
|
|
||||||
|
|
||||||
For example, given the following command line, Bison will treat both
|
|
||||||
warnings related to POSIX Yacc incompatibilities and S/R conflicts as
|
|
||||||
errors (and only those):
|
|
||||||
|
|
||||||
$ bison -Werror=yacc,error=conflicts-sr input.y
|
|
||||||
|
|
||||||
If no categories are specified, -Werror will make all active warnings into
|
|
||||||
errors. For example, the following line does the same the previous example:
|
|
||||||
|
|
||||||
$ bison -Werror -Wnone -Wyacc -Wconflicts-sr input.y
|
|
||||||
|
|
||||||
(By default -Wconflicts-sr,conflicts-rr,deprecated,other is enabled.)
|
|
||||||
|
|
||||||
Note that the categories in this -Werror option may not be prefixed with
|
|
||||||
"no-". However, -Wno-error[=CATEGORY] is valid.
|
|
||||||
|
|
||||||
Note that -y enables -Werror=yacc. Therefore it is now possible to require
|
|
||||||
Yacc-like behavior (e.g., always generate y.tab.c), but to report
|
|
||||||
incompatibilities as warnings: "-y -Wno-error=yacc".
|
|
||||||
|
|
||||||
*** The display of warnings is now richer
|
|
||||||
|
|
||||||
The option that controls a given warning is now displayed:
|
|
||||||
|
|
||||||
foo.y:4.6: warning: type clash on default action: <foo> != <bar> [-Wother]
|
|
||||||
|
|
||||||
In the case of warnings treated as errors, the prefix is changed from
|
|
||||||
"warning: " to "error: ", and the suffix is displayed, in a manner similar
|
|
||||||
to GCC, as [-Werror=CATEGORY].
|
|
||||||
|
|
||||||
For instance, where the previous version of Bison would report (and exit
|
|
||||||
with failure):
|
|
||||||
|
|
||||||
bison: warnings being treated as errors
|
|
||||||
input.y:1.1: warning: stray ',' treated as white space
|
|
||||||
|
|
||||||
it now reports:
|
|
||||||
|
|
||||||
input.y:1.1: error: stray ',' treated as white space [-Werror=other]
|
|
||||||
|
|
||||||
*** Deprecated constructs
|
|
||||||
|
|
||||||
The new 'deprecated' warning category flags obsolete constructs whose
|
|
||||||
support will be discontinued. It is enabled by default. These warnings
|
|
||||||
used to be reported as 'other' warnings.
|
|
||||||
|
|
||||||
*** Useless semantic types
|
|
||||||
|
|
||||||
Bison now warns about useless (uninhabited) semantic types. Since
|
|
||||||
semantic types are not declared to Bison (they are defined in the opaque
|
|
||||||
%union structure), it is %printer/%destructor directives about useless
|
|
||||||
types that trigger the warning:
|
|
||||||
|
|
||||||
%token <type1> term
|
|
||||||
%type <type2> nterm
|
|
||||||
%printer {} <type1> <type3>
|
|
||||||
%destructor {} <type2> <type4>
|
|
||||||
%%
|
|
||||||
nterm: term { $$ = $1; };
|
|
||||||
|
|
||||||
3.28-34: warning: type <type3> is used, but is not associated to any symbol
|
|
||||||
4.28-34: warning: type <type4> is used, but is not associated to any symbol
|
|
||||||
|
|
||||||
*** Undefined but unused symbols
|
|
||||||
|
|
||||||
Bison used to raise an error for undefined symbols that are not used in
|
|
||||||
the grammar. This is now only a warning.
|
|
||||||
|
|
||||||
%printer {} symbol1
|
|
||||||
%destructor {} symbol2
|
|
||||||
%type <type> symbol3
|
|
||||||
%%
|
|
||||||
exp: "a";
|
|
||||||
|
|
||||||
*** Useless destructors or printers
|
|
||||||
|
|
||||||
Bison now warns about useless destructors or printers. In the following
|
|
||||||
example, the printer for <type1>, and the destructor for <type2> are
|
|
||||||
useless: all symbols of <type1> (token1) already have a printer, and all
|
|
||||||
symbols of type <type2> (token2) already have a destructor.
|
|
||||||
|
|
||||||
%token <type1> token1
|
|
||||||
<type2> token2
|
|
||||||
<type3> token3
|
|
||||||
<type4> token4
|
|
||||||
%printer {} token1 <type1> <type3>
|
|
||||||
%destructor {} token2 <type2> <type4>
|
|
||||||
|
|
||||||
*** Conflicts
|
|
||||||
|
|
||||||
The warnings and error messages about shift/reduce and reduce/reduce
|
|
||||||
conflicts have been normalized. For instance on the following foo.y file:
|
|
||||||
|
|
||||||
%glr-parser
|
|
||||||
%%
|
|
||||||
exp: exp '+' exp | '0' | '0';
|
|
||||||
|
|
||||||
compare the previous version of bison:
|
|
||||||
|
|
||||||
$ bison foo.y
|
|
||||||
foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce
|
|
||||||
$ bison -Werror foo.y
|
|
||||||
bison: warnings being treated as errors
|
|
||||||
foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce
|
|
||||||
|
|
||||||
with the new behavior:
|
|
||||||
|
|
||||||
$ bison foo.y
|
|
||||||
foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
|
|
||||||
foo.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
|
|
||||||
$ bison -Werror foo.y
|
|
||||||
foo.y: error: 1 shift/reduce conflict [-Werror=conflicts-sr]
|
|
||||||
foo.y: error: 2 reduce/reduce conflicts [-Werror=conflicts-rr]
|
|
||||||
|
|
||||||
When %expect or %expect-rr is used, such as with bar.y:
|
|
||||||
|
|
||||||
%expect 0
|
|
||||||
%glr-parser
|
|
||||||
%%
|
|
||||||
exp: exp '+' exp | '0' | '0';
|
|
||||||
|
|
||||||
Former behavior:
|
|
||||||
|
|
||||||
$ bison bar.y
|
|
||||||
bar.y: conflicts: 1 shift/reduce, 2 reduce/reduce
|
|
||||||
bar.y: expected 0 shift/reduce conflicts
|
|
||||||
bar.y: expected 0 reduce/reduce conflicts
|
|
||||||
|
|
||||||
New one:
|
|
||||||
|
|
||||||
$ bison bar.y
|
|
||||||
bar.y: error: shift/reduce conflicts: 1 found, 0 expected
|
|
||||||
bar.y: error: reduce/reduce conflicts: 2 found, 0 expected
|
|
||||||
|
|
||||||
*** Useless precedence
|
|
||||||
|
|
||||||
Bison now warns about symbols with a declared precedence but no declared
|
|
||||||
associativity (i.e. declared with %precedence), and whose precedence is
|
|
||||||
never used. In that case, the symbol can be safely declared with %token
|
|
||||||
instead, without modifying the parsing tables.
|
|
||||||
|
|
||||||
** Additional yylex/yyparse arguments
|
|
||||||
|
|
||||||
The new directive %param declares additional arguments to both yylex and
|
|
||||||
yyparse. The %lex-param, %parse-param, and %param directives support one
|
|
||||||
or more arguments. Instead of
|
|
||||||
|
|
||||||
%lex-param {arg1_type *arg1}
|
|
||||||
%lex-param {arg2_type *arg2}
|
|
||||||
%parse-param {arg1_type *arg1}
|
|
||||||
%parse-param {arg2_type *arg2}
|
|
||||||
|
|
||||||
one may now declare
|
|
||||||
|
|
||||||
%param {arg1_type *arg1} {arg2_type *arg2}
|
|
||||||
|
|
||||||
** Java skeleton improvements
|
|
||||||
|
|
||||||
Contributed by Paolo Bonzini.
|
|
||||||
|
|
||||||
The constants for token names were moved to the Lexer interface. Also, it
|
|
||||||
is possible to add code to the parser's constructors using "%code init"
|
|
||||||
and "%define init_throws".
|
|
||||||
|
|
||||||
** C++ skeletons improvements
|
|
||||||
|
|
||||||
*** The parser header is no longer mandatory (lalr1.cc, glr.cc)
|
|
||||||
|
|
||||||
Using %defines is now optional. Without it, the needed support classes
|
|
||||||
are defined in the generated parser, instead of additional files (such as
|
|
||||||
location.hh, position.hh and stack.hh).
|
|
||||||
|
|
||||||
*** Locations are no longer mandatory (lalr1.cc, glr.cc)
|
|
||||||
|
|
||||||
Both lalr1.cc and glr.cc no longer require %location.
|
|
||||||
|
|
||||||
*** syntax_error exception (lalr1.cc)
|
|
||||||
|
|
||||||
The C++ parser features a syntax_error exception, which can be
|
|
||||||
thrown from the scanner or from user rules to raise syntax errors.
|
|
||||||
This facilitates reporting errors caught in sub-functions (e.g.,
|
|
||||||
rejecting too large integral literals from a conversion function
|
|
||||||
used by the scanner, or rejecting invalid combinations from a
|
|
||||||
factory invoked by the user actions).
|
|
||||||
|
|
||||||
** Renamed %define variables
|
|
||||||
|
|
||||||
The following variables have been renamed for consistency. Backward
|
|
||||||
compatibility is ensured, but upgrading is recommended.
|
|
||||||
|
|
||||||
lr.default-reductions -> lr.default-reduction
|
|
||||||
lr.keep-unreachable-states -> lr.keep-unreachable-state
|
|
||||||
namespace -> api.namespace
|
|
||||||
stype -> api.value.type
|
|
||||||
|
|
||||||
** Variable api.token.prefix
|
|
||||||
|
|
||||||
The variable api.token.prefix changes the way tokens are identified in
|
|
||||||
the generated files. This is especially useful to avoid collisions
|
|
||||||
with identifiers in the target language. For instance
|
|
||||||
|
|
||||||
%token FILE for ERROR
|
|
||||||
%define api.token.prefix "TOK_"
|
|
||||||
%%
|
|
||||||
start: FILE for ERROR;
|
|
||||||
|
|
||||||
will generate the definition of the symbols TOK_FILE, TOK_for, and
|
|
||||||
TOK_ERROR in the generated sources. In particular, the scanner must
|
|
||||||
use these prefixed token names, although the grammar itself still
|
|
||||||
uses the short names (as in the sample rule given above).
|
|
||||||
|
|
||||||
** Variable parse.error
|
|
||||||
|
|
||||||
This variable controls the verbosity of error messages. The use of the
|
|
||||||
%error-verbose directive is deprecated in favor of "%define parse.error
|
|
||||||
verbose".
|
|
||||||
|
|
||||||
** Semantic predicates
|
|
||||||
|
|
||||||
Contributed by Paul Hilfinger.
|
|
||||||
|
|
||||||
The new, experimental, semantic-predicate feature allows actions of the
|
|
||||||
form "%?{ BOOLEAN-EXPRESSION }", which cause syntax errors (as for
|
|
||||||
YYERROR) if the expression evaluates to 0, and are evaluated immediately
|
|
||||||
in GLR parsers, rather than being deferred. The result is that they allow
|
|
||||||
the programmer to prune possible parses based on the values of run-time
|
|
||||||
expressions.
|
|
||||||
|
|
||||||
** The directive %expect-rr is now an error in non GLR mode
|
|
||||||
|
|
||||||
It used to be an error only if used in non GLR mode, _and_ if there are
|
|
||||||
reduce/reduce conflicts.
|
|
||||||
|
|
||||||
** Token numbering has changed to preserve the user-defined order
|
|
||||||
|
|
||||||
When declaring %token A B, the numbering for A is inferior to B. Up to now,
|
|
||||||
when declaring associativity at the same time, with %left (or %right,
|
|
||||||
%precedence, %nonassoc), B was inferior to A.
|
|
||||||
|
|
||||||
* Noteworthy changes in release 2.7 (2012-12-12) [stable]
|
* Noteworthy changes in release 2.7 (2012-12-12) [stable]
|
||||||
|
|
||||||
@@ -313,8 +20,6 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
** Diagnostics are improved
|
** Diagnostics are improved
|
||||||
|
|
||||||
Contributed by Théophile Ranquet.
|
|
||||||
|
|
||||||
*** Changes in the format of error messages
|
*** Changes in the format of error messages
|
||||||
|
|
||||||
This used to be the format of many error reports:
|
This used to be the format of many error reports:
|
||||||
@@ -400,8 +105,6 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
** Graph improvements in DOT and XSLT
|
** Graph improvements in DOT and XSLT
|
||||||
|
|
||||||
Contributed by Théophile Ranquet.
|
|
||||||
|
|
||||||
The graphical presentation of the states is more readable: their shape is
|
The graphical presentation of the states is more readable: their shape is
|
||||||
now rectangular, the state number is clearly displayed, and the items are
|
now rectangular, the state number is clearly displayed, and the items are
|
||||||
numbered and left-justified.
|
numbered and left-justified.
|
||||||
@@ -550,7 +253,7 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
* Noteworthy changes in release 2.6 (2012-07-19) [stable]
|
* Noteworthy changes in release 2.6 (2012-07-19) [stable]
|
||||||
|
|
||||||
** Future changes
|
** Future Changes
|
||||||
|
|
||||||
The next major release of Bison will drop support for the following
|
The next major release of Bison will drop support for the following
|
||||||
deprecated features. Please report disagreements to [email protected].
|
deprecated features. Please report disagreements to [email protected].
|
||||||
@@ -843,9 +546,7 @@ GNU Bison NEWS
|
|||||||
These features are experimental. More user feedback will help to
|
These features are experimental. More user feedback will help to
|
||||||
stabilize them.
|
stabilize them.
|
||||||
|
|
||||||
** LAC (Lookahead Correction) for syntax error handling
|
** LAC (Lookahead Correction) for syntax error handling:
|
||||||
|
|
||||||
Contributed by Joel E. Denny.
|
|
||||||
|
|
||||||
Canonical LR, IELR, and LALR can suffer from a couple of problems
|
Canonical LR, IELR, and LALR can suffer from a couple of problems
|
||||||
upon encountering a syntax error. First, the parser might perform
|
upon encountering a syntax error. First, the parser might perform
|
||||||
@@ -2356,8 +2057,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
|
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
|
||||||
LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
|
LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
|
||||||
LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
|
LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
|
||||||
LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp Wother nterm arg init
|
LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp calc yyo fval Wmaybe
|
||||||
LocalWords: TOK calc yyo fval Wconflicts
|
LocalWords: yyvsp pragmas noreturn java's
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: outline
|
mode: outline
|
||||||
|
|||||||
@@ -35,13 +35,6 @@ of the .output file etc. This excludes impossible error messages
|
|||||||
(comparable to assert/abort), and all the --trace output which is
|
(comparable to assert/abort), and all the --trace output which is
|
||||||
meant for the maintainers only.
|
meant for the maintainers only.
|
||||||
|
|
||||||
** Horizontal tabs
|
|
||||||
Do not add horizontal tab characters to any file in Bison's repository
|
|
||||||
except where required. For example, do not use tabs to format C code.
|
|
||||||
However, make files, ChangeLog, and some regular expressions require
|
|
||||||
tabs. Also, test cases might need to contain tabs to check that Bison
|
|
||||||
properly processes tabs in its input.
|
|
||||||
|
|
||||||
|
|
||||||
* Working from the repository
|
* Working from the repository
|
||||||
|
|
||||||
@@ -176,28 +169,6 @@ decide whether to update.
|
|||||||
** make check
|
** make check
|
||||||
Use liberally.
|
Use liberally.
|
||||||
|
|
||||||
** TESTSUITEFLAGS
|
|
||||||
|
|
||||||
The default is for make check to run all tests sequentially. This can be
|
|
||||||
very time consumming when checking repeatedly or on slower setups. This can
|
|
||||||
be sped up in two ways:
|
|
||||||
|
|
||||||
Using -j, in a make-like fashion, for example:
|
|
||||||
$ make check TESTSUITEFLAGS='-j8'
|
|
||||||
|
|
||||||
Running only the tests of a certain category, as specified in the AT files
|
|
||||||
with AT_KEYWORDS([[category]]). Categories include:
|
|
||||||
- c++, for c++ parsers
|
|
||||||
- deprec, for tests concerning deprecated constructs.
|
|
||||||
- glr, for glr parsers
|
|
||||||
- java, for java parsers
|
|
||||||
- report, for automaton dumps
|
|
||||||
|
|
||||||
To run a specific set of tests, use -k (for "keyword"). For example:
|
|
||||||
$ make check TESTSUITEFLAGS='-k c++'
|
|
||||||
|
|
||||||
Both can be combined.
|
|
||||||
|
|
||||||
** Typical errors
|
** Typical errors
|
||||||
If the test suite shows failures such as the following one
|
If the test suite shows failures such as the following one
|
||||||
|
|
||||||
@@ -269,9 +240,6 @@ release:
|
|||||||
that it does not make sense for glr.c, which should be ANSI, but
|
that it does not make sense for glr.c, which should be ANSI, but
|
||||||
currently is actually GNU C, nor for lalr1.cc.
|
currently is actually GNU C, nor for lalr1.cc.
|
||||||
|
|
||||||
- Test with a very recent version of GCC for both C and C++. Testing
|
|
||||||
with older versions that are still in use is nice too.
|
|
||||||
|
|
||||||
|
|
||||||
* Release Procedure
|
* Release Procedure
|
||||||
This section needs to be updated to take into account features from
|
This section needs to be updated to take into account features from
|
||||||
|
|||||||
@@ -12,41 +12,15 @@ the pretty format of states from .output in the .dot
|
|||||||
Also, the underscore in print_graph.[ch] isn't very fitting considering
|
Also, the underscore in print_graph.[ch] isn't very fitting considering
|
||||||
the dashes in the other filenames.
|
the dashes in the other filenames.
|
||||||
|
|
||||||
** push-parser
|
** Variable names.
|
||||||
Check it too when checking the different kinds of parsers. And be
|
What should we name `variant' and `lex_symbol'?
|
||||||
sure to check that the initial-action is performed once per parsing.
|
|
||||||
|
|
||||||
** m4 names
|
** Use b4_symbol in all the skeleton
|
||||||
b4_shared_declarations is no longer what it is. Make it
|
Move its definition in the more standard places and deploy it in other
|
||||||
b4_parser_declaration for instance.
|
skeletons. Then remove the older system, including the tables
|
||||||
|
generated by output.c
|
||||||
|
|
||||||
** yychar in lalr1.cc
|
** Update the documentation on gnu.org
|
||||||
There is a large difference bw maint and master on the handling of
|
|
||||||
yychar (which was removed in lalr1.cc). See what needs to be
|
|
||||||
back-ported.
|
|
||||||
|
|
||||||
|
|
||||||
/* User semantic actions sometimes alter yychar, and that requires
|
|
||||||
that yytoken be updated with the new translation. We take the
|
|
||||||
approach of translating immediately before every use of yytoken.
|
|
||||||
One alternative is translating here after every semantic action,
|
|
||||||
but that translation would be missed if the semantic action
|
|
||||||
invokes YYABORT, YYACCEPT, or YYERROR immediately after altering
|
|
||||||
yychar. In the case of YYABORT or YYACCEPT, an incorrect
|
|
||||||
destructor might then be invoked immediately. In the case of
|
|
||||||
YYERROR, subsequent parser actions might lead to an incorrect
|
|
||||||
destructor call or verbose syntax error message before the
|
|
||||||
lookahead is translated. */
|
|
||||||
|
|
||||||
/* Make sure we have latest lookahead translation. See comments at
|
|
||||||
user semantic actions for why this is necessary. */
|
|
||||||
yytoken = yytranslate_ (yychar);
|
|
||||||
|
|
||||||
|
|
||||||
** stack.hh
|
|
||||||
Get rid of it. The original idea is nice, but actually it makes
|
|
||||||
the code harder to follow, and uselessly different from the other
|
|
||||||
skeletons.
|
|
||||||
|
|
||||||
** Get rid of fake #lines [Bison: ...]
|
** Get rid of fake #lines [Bison: ...]
|
||||||
Possibly as simple as checking whether the column number is nonnegative.
|
Possibly as simple as checking whether the column number is nonnegative.
|
||||||
@@ -74,7 +48,14 @@ since it is no longer bound to a particular parser, it's just a
|
|||||||
** Rename LR0.cc
|
** Rename LR0.cc
|
||||||
as lr0.cc, why upper case?
|
as lr0.cc, why upper case?
|
||||||
|
|
||||||
|
** bench several bisons.
|
||||||
|
Enhance bench.pl with %b to run different bisons.
|
||||||
|
|
||||||
* Various
|
* Various
|
||||||
|
** Warnings
|
||||||
|
Warnings about type tags that are used in printer and dtors, but not
|
||||||
|
for symbols?
|
||||||
|
|
||||||
** YYERRCODE
|
** YYERRCODE
|
||||||
Defined to 256, but not used, not documented. Probably the token
|
Defined to 256, but not used, not documented. Probably the token
|
||||||
number for the error token, which POSIX wants to be 256, but which
|
number for the error token, which POSIX wants to be 256, but which
|
||||||
@@ -120,6 +101,9 @@ so both 256 and 257 are "mysterious".
|
|||||||
"\"end of command\"", "error", "$undefined", "\"=\"", "\"break\"",
|
"\"end of command\"", "error", "$undefined", "\"=\"", "\"break\"",
|
||||||
|
|
||||||
|
|
||||||
|
** YYFAIL
|
||||||
|
It is seems to be *really* obsolete now, shall we remove it?
|
||||||
|
|
||||||
** yychar == yyempty_
|
** yychar == yyempty_
|
||||||
The code in yyerrlab reads:
|
The code in yyerrlab reads:
|
||||||
|
|
||||||
@@ -137,6 +121,12 @@ really possible? The test suite does not exercise this case.
|
|||||||
This shows that it would be interesting to manage to install skeleton
|
This shows that it would be interesting to manage to install skeleton
|
||||||
coverage analysis to the test suite.
|
coverage analysis to the test suite.
|
||||||
|
|
||||||
|
** Table definitions
|
||||||
|
It should be very easy to factor the definition of the various tables,
|
||||||
|
including the separation bw declaration and definition. See for
|
||||||
|
instance b4_table_define in lalr1.cc. This way, we could even factor
|
||||||
|
C vs. C++ definitions.
|
||||||
|
|
||||||
* From lalr1.cc to yacc.c
|
* From lalr1.cc to yacc.c
|
||||||
** Single stack
|
** Single stack
|
||||||
Merging the three stacks in lalr1.cc simplified the code, prompted for
|
Merging the three stacks in lalr1.cc simplified the code, prompted for
|
||||||
@@ -262,6 +252,9 @@ Paul notes:
|
|||||||
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
||||||
the source code. This should get fixed.
|
the source code. This should get fixed.
|
||||||
|
|
||||||
|
* --graph
|
||||||
|
Show reductions.
|
||||||
|
|
||||||
* Broken options ?
|
* Broken options ?
|
||||||
** %token-table
|
** %token-table
|
||||||
** Skeleton strategy
|
** Skeleton strategy
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Print a version string.
|
# Print a version string.
|
||||||
scriptversion=2012-12-28.10; # UTC
|
scriptversion=2013-03-08.16; # UTC
|
||||||
|
|
||||||
# Bootstrap this package from checked-out sources.
|
# Bootstrap this package from checked-out sources.
|
||||||
|
|
||||||
@@ -306,34 +306,34 @@ if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
|
|||||||
die "Bootstrapping from a non-checked-out distribution is risky."
|
die "Bootstrapping from a non-checked-out distribution is risky."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure that lines starting with ! sort last, per gitignore conventions
|
# Strip blank and comment lines to leave significant entries.
|
||||||
# for whitelisting exceptions after a more generic blacklist pattern.
|
gitignore_entries() {
|
||||||
sort_patterns() {
|
sed '/^#/d; /^$/d' "$@"
|
||||||
sort -u "$@" | sed '/^!/ {
|
|
||||||
H
|
|
||||||
d
|
|
||||||
}
|
|
||||||
$ {
|
|
||||||
P
|
|
||||||
x
|
|
||||||
s/^\n//
|
|
||||||
}' | sed '/^$/d'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# If $STR is not already on a line by itself in $FILE, insert it,
|
# If $STR is not already on a line by itself in $FILE, insert it at the start.
|
||||||
# sorting the new contents of the file and replacing $FILE with the result.
|
# Entries are inserted at the start of the ignore list to ensure existing
|
||||||
insert_sorted_if_absent() {
|
# entries starting with ! are not overridden. Such entries support
|
||||||
|
# whitelisting exceptions after a more generic blacklist pattern.
|
||||||
|
insert_if_absent() {
|
||||||
file=$1
|
file=$1
|
||||||
str=$2
|
str=$2
|
||||||
test -f $file || touch $file
|
test -f $file || touch $file
|
||||||
echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
|
test -r $file || die "Error: failed to read ignore file: $file"
|
||||||
|| { echo "$str" | sort_patterns - $file > $file.bak \
|
duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
|
||||||
&& mv $file.bak $file; } \
|
if [ "$duplicate_entries" ] ; then
|
||||||
|| die "insert_sorted_if_absent $file $str: failed"
|
die "Error: Duplicate entries in $file: " $duplicate_entries
|
||||||
|
fi
|
||||||
|
linesold=$(gitignore_entries $file | wc -l)
|
||||||
|
linesnew=$(echo "$str" | gitignore_entries - $file | sort -u | wc -l)
|
||||||
|
if [ $linesold != $linesnew ] ; then
|
||||||
|
{ echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
|
||||||
|
|| die "insert_if_absent $file $str: failed"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
|
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
|
||||||
# insert_sorted_if_absent.
|
# insert_if_absent.
|
||||||
insert_vc_ignore() {
|
insert_vc_ignore() {
|
||||||
vc_ignore_file="$1"
|
vc_ignore_file="$1"
|
||||||
pattern="$2"
|
pattern="$2"
|
||||||
@@ -344,7 +344,7 @@ insert_vc_ignore() {
|
|||||||
# .gitignore entry.
|
# .gitignore entry.
|
||||||
pattern=$(echo "$pattern" | sed s,^,/,);;
|
pattern=$(echo "$pattern" | sed s,^,/,);;
|
||||||
esac
|
esac
|
||||||
insert_sorted_if_absent "$vc_ignore_file" "$pattern"
|
insert_if_absent "$vc_ignore_file" "$pattern"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
|
# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
|
||||||
@@ -630,9 +630,13 @@ esac
|
|||||||
if $bootstrap_sync; then
|
if $bootstrap_sync; then
|
||||||
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
|
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
|
||||||
echo "$0: updating bootstrap and restarting..."
|
echo "$0: updating bootstrap and restarting..."
|
||||||
|
case $(sh -c 'echo "$1"' -- a) in
|
||||||
|
a) ignored=--;;
|
||||||
|
*) ignored=ignored;;
|
||||||
|
esac
|
||||||
exec sh -c \
|
exec sh -c \
|
||||||
'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
|
'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
|
||||||
-- "$GNULIB_SRCDIR/build-aux/bootstrap" \
|
$ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
|
||||||
"$0" "$@" --no-bootstrap-sync
|
"$0" "$@" --no-bootstrap-sync
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|||||||
+6
-12
@@ -21,12 +21,12 @@ gnulib_modules='
|
|||||||
configmake
|
configmake
|
||||||
dirname
|
dirname
|
||||||
error extensions fdl fopen-safer
|
error extensions fdl fopen-safer
|
||||||
|
getline
|
||||||
getopt-gnu
|
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 malloc-gnu
|
javaexec-script ldexpl malloc-gnu mbschr mbsrchr
|
||||||
mbswidth
|
mbswidth
|
||||||
non-recursive-gnulib-prefix-hack
|
|
||||||
obstack
|
obstack
|
||||||
obstack-printf
|
obstack-printf
|
||||||
perror progname
|
perror progname
|
||||||
@@ -36,11 +36,7 @@ gnulib_modules='
|
|||||||
spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp
|
spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp
|
||||||
unistd unistd-safer unlocked-io update-copyright unsetenv verify
|
unistd unistd-safer unlocked-io update-copyright unsetenv verify
|
||||||
warnings
|
warnings
|
||||||
xalloc
|
xalloc xalloc-die xmemdup0 xstrndup
|
||||||
xalloc-die
|
|
||||||
xconcat-filename
|
|
||||||
xmemdup0
|
|
||||||
xstrndup
|
|
||||||
|
|
||||||
fprintf-posix printf-posix snprintf-posix sprintf-posix
|
fprintf-posix printf-posix snprintf-posix sprintf-posix
|
||||||
vsnprintf-posix vsprintf-posix
|
vsnprintf-posix vsprintf-posix
|
||||||
@@ -50,8 +46,9 @@ gnulib_modules='
|
|||||||
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||||
--from-code=UTF-8\\\
|
--from-code=UTF-8\\\
|
||||||
--flag=asprintf:2:c-format\\\
|
--flag=asprintf:2:c-format\\\
|
||||||
--flag=complain:3:c-format\\\
|
--flag=complain:1:c-format --flag=complain_at:2:c-format\\\
|
||||||
--flag=complain_indent:4:c-format\\\
|
--flag=fatal:1:c-format --flag=fatal_at:2:c-format\\\
|
||||||
|
--flag=warn:1:c-format --flag=warn_at:2:c-format\\\
|
||||||
--flag=unexpected_end:2:c-format\\\
|
--flag=unexpected_end:2:c-format\\\
|
||||||
'
|
'
|
||||||
XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
|
XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
|
||||||
@@ -79,9 +76,6 @@ gnulib_tool_option_extras='--symlink --makefile-name=gnulib.mk'
|
|||||||
|
|
||||||
bootstrap_post_import_hook()
|
bootstrap_post_import_hook()
|
||||||
{
|
{
|
||||||
# Massage lib/gnulib.mk before using it later in the bootstrapping process.
|
|
||||||
build-aux/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk
|
|
||||||
|
|
||||||
# Ensure that ChangeLog exists, for automake.
|
# Ensure that ChangeLog exists, for automake.
|
||||||
test -f ChangeLog || touch ChangeLog
|
test -f ChangeLog || touch ChangeLog
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
/Makefile
|
||||||
|
/Makefile.in
|
||||||
/announce-gen
|
/announce-gen
|
||||||
/arg-nonnull.h
|
/arg-nonnull.h
|
||||||
/c++defs.h
|
/c++defs.h
|
||||||
/compile
|
/compile
|
||||||
/config.guess
|
/config.guess
|
||||||
/config.rpath
|
/config.rpath
|
||||||
/config.rpath~
|
|
||||||
/config.sub
|
/config.sub
|
||||||
/depcomp
|
/depcomp
|
||||||
/do-release-commit-and-tag
|
/do-release-commit-and-tag
|
||||||
@@ -19,11 +20,9 @@
|
|||||||
/link-warning.h
|
/link-warning.h
|
||||||
/mdate-sh
|
/mdate-sh
|
||||||
/missing
|
/missing
|
||||||
/test-driver
|
|
||||||
/texinfo.tex
|
/texinfo.tex
|
||||||
/update-copyright
|
/update-copyright
|
||||||
/useless-if-before-free
|
/useless-if-before-free
|
||||||
/vc-list-files
|
/vc-list-files
|
||||||
/warn-on-use.h
|
/warn-on-use.h
|
||||||
/ylwrap
|
/ylwrap
|
||||||
/prefix-gnulib-mk
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
## Makefile for Bison testsuite.
|
## Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# Copyright (C) 2000-2013 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
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
@@ -15,9 +13,8 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST = \
|
||||||
build-aux/cross-options.pl \
|
cross-options.pl \
|
||||||
build-aux/darwin11.4.0.valgrind \
|
darwin11.4.0.valgrind \
|
||||||
build-aux/move-if-change \
|
prev-version.txt \
|
||||||
build-aux/prev-version.txt \
|
update-b4-copyright
|
||||||
build-aux/update-b4-copyright
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../gnulib/build-aux/move-if-change
|
|
||||||
@@ -37,9 +37,15 @@ url_dir_list = \
|
|||||||
ftp://$(gnu_rel_host)/gnu/bison
|
ftp://$(gnu_rel_host)/gnu/bison
|
||||||
|
|
||||||
# Tests not to run as part of "make distcheck".
|
# Tests not to run as part of "make distcheck".
|
||||||
|
# Exclude changelog-check here so that there's less churn in ChangeLog
|
||||||
|
# files -- otherwise, you'd need to have the upcoming version number
|
||||||
|
# at the top of the file for each `make distcheck' run.
|
||||||
local-checks-to-skip = \
|
local-checks-to-skip = \
|
||||||
|
changelog-check \
|
||||||
sc_immutable_NEWS \
|
sc_immutable_NEWS \
|
||||||
sc_prohibit_atoi_atof
|
sc_prohibit_always_true_header_tests \
|
||||||
|
sc_prohibit_atoi_atof \
|
||||||
|
sc_prohibit_strcmp
|
||||||
|
|
||||||
# The local directory containing the checked-out copy of gnulib used in
|
# The local directory containing the checked-out copy of gnulib used in
|
||||||
# this release. Used solely to get a date for the "announcement" target.
|
# this release. Used solely to get a date for the "announcement" target.
|
||||||
@@ -55,11 +61,6 @@ 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
|
||||||
|
|
||||||
|
|
||||||
## -------------------- ##
|
|
||||||
## More syntax-checks. ##
|
|
||||||
## -------------------- ##
|
|
||||||
|
|
||||||
# At least for Mac OS X's grep, the order between . and [ in "[^.[]"
|
# At least for Mac OS X's grep, the order between . and [ in "[^.[]"
|
||||||
# matters:
|
# matters:
|
||||||
# $ LC_ALL=fr_FR grep -nE '[^[.]' /dev/null
|
# $ LC_ALL=fr_FR grep -nE '[^[.]' /dev/null
|
||||||
@@ -72,108 +73,21 @@ sc_at_parser_check:
|
|||||||
halt='use AT_PARSER_CHECK for and only for generated parsers' \
|
halt='use AT_PARSER_CHECK for and only for generated parsers' \
|
||||||
$(_sc_search_regexp)
|
$(_sc_search_regexp)
|
||||||
|
|
||||||
# Indent only with spaces.
|
|
||||||
# Taken from Coreutils.
|
|
||||||
sc_prohibit_tab_based_indentation:
|
|
||||||
@prohibit='^ * ' \
|
|
||||||
halt='TAB in indentation; use only spaces' \
|
|
||||||
$(_sc_search_regexp)
|
|
||||||
|
|
||||||
# Prohibit the use of `...` in tests/. Use $(...) instead.
|
|
||||||
# Taken from Coreutils.
|
|
||||||
# Not ready for Bison yet.
|
|
||||||
#sc_prohibit_test_backticks:
|
|
||||||
# @prohibit='`' in_vc_files='^tests/' \
|
|
||||||
# halt='use $$(...), not `...` in tests/' \
|
|
||||||
# $(_sc_search_regexp)
|
|
||||||
|
|
||||||
# Enforce recommended preprocessor indentation style.
|
|
||||||
# Taken from Coreutils.
|
|
||||||
sc_preprocessor_indentation:
|
|
||||||
@if cppi --version >/dev/null 2>&1; then \
|
|
||||||
$(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c \
|
|
||||||
|| { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
|
|
||||||
exit 1; }; \
|
|
||||||
else \
|
|
||||||
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
###########################################################
|
|
||||||
# Taken from Coreutils.
|
|
||||||
_p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
|
|
||||||
_pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
|
|
||||||
_pre_anchored = ^\($(_pre)\)
|
|
||||||
_comment_and_close = [^*]\|[*][^/*]\)*[*][*]*/
|
|
||||||
# help font-lock mode: '
|
|
||||||
|
|
||||||
# A sed expression that removes ANSI C and ISO C99 comments.
|
|
||||||
# Derived from the one in GNU gettext's 'moopp' preprocessor.
|
|
||||||
_sed_remove_comments = \
|
|
||||||
/[/][/*]/{ \
|
|
||||||
ta; \
|
|
||||||
:a; \
|
|
||||||
s,$(_pre_anchored)//.*,\1,; \
|
|
||||||
te; \
|
|
||||||
s,$(_pre_anchored)/[*]\($(_comment_and_close),\1 ,; \
|
|
||||||
ta; \
|
|
||||||
/^$(_pre)[/][*]/{ \
|
|
||||||
s,$(_pre_anchored)/[*].*,\1 ,; \
|
|
||||||
tu; \
|
|
||||||
:u; \
|
|
||||||
n; \
|
|
||||||
s,^\($(_comment_and_close),,; \
|
|
||||||
tv; \
|
|
||||||
s,^.*$$,,; \
|
|
||||||
bu; \
|
|
||||||
:v; \
|
|
||||||
}; \
|
|
||||||
:e; \
|
|
||||||
}
|
|
||||||
# Quote all single quotes.
|
|
||||||
_sed_rm_comments_q = $(subst ','\'',$(_sed_remove_comments))
|
|
||||||
# help font-lock mode: '
|
|
||||||
|
|
||||||
_space_before_paren_exempt =? \\n\\$$
|
|
||||||
_space_before_paren_exempt = \
|
|
||||||
(^ *\#|\\n\\$$|%s\(to %s|(date|group|character)\(s\))
|
|
||||||
# Ensure that there is a space before each open parenthesis in C code.
|
|
||||||
sc_space_before_open_paren:
|
|
||||||
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
|
|
||||||
fail=0; \
|
|
||||||
for c in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do \
|
|
||||||
sed '$(_sed_rm_comments_q)' $$c 2>/dev/null \
|
|
||||||
| grep -i '[[:alnum:]](' \
|
|
||||||
| grep -vE '$(_space_before_paren_exempt)' \
|
|
||||||
| grep . && { fail=1; echo "*** $$c"; }; \
|
|
||||||
done; \
|
|
||||||
test $$fail = 1 && \
|
|
||||||
{ echo '$(ME): the above files lack a space-before-open-paren' \
|
|
||||||
1>&2; exit 1; } || :; \
|
|
||||||
else :; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
## -------------------------- ##
|
|
||||||
## syntax-checks exceptions. ##
|
|
||||||
## -------------------------- ##
|
|
||||||
|
|
||||||
exclude = \
|
exclude = \
|
||||||
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
||||||
$(call exclude, \
|
$(call exclude, \
|
||||||
bindtextdomain=^lib/main.c$$ \
|
bindtextdomain=^lib/main.c$$ \
|
||||||
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
|
||||||
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_always_true_header_tests=^djgpp/subpipe.h$$|^lib/timevar.c$$ \
|
|
||||||
prohibit_always_true_header_tests+=?|^m4/timevar.m4$$ \
|
|
||||||
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
|
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
|
||||||
prohibit_doubled_word=^tests/named-refs.at$$ \
|
prohibit_doubled_word=^tests/named-refs.at$$ \
|
||||||
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
||||||
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
||||||
prohibit_strcmp=^doc/bison\.texi|tests/local\.at$$ \
|
|
||||||
prohibit_tab_based_indentation=\.(am|mk)$$|^djgpp/|^\.git \
|
|
||||||
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$$ \
|
||||||
|
trailing_blank=^src/parse-gram.[ch]$$ \
|
||||||
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \
|
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \
|
||||||
)
|
)
|
||||||
|
|||||||
+13
-8
@@ -45,9 +45,7 @@ AC_CONFIG_MACRO_DIR([m4])
|
|||||||
# releases, we want to be able run make dist without being required to
|
# releases, we want to be able run make dist without being required to
|
||||||
# add a bogus NEWS entry. In that case, the version string
|
# add a bogus NEWS entry. In that case, the version string
|
||||||
# automatically contains a dash, which we also let disable gnits.
|
# automatically contains a dash, which we also let disable gnits.
|
||||||
AM_INIT_AUTOMAKE([1.11.1 dist-xz nostdinc
|
AM_INIT_AUTOMAKE([1.11.1 dist-xz silent-rules]
|
||||||
color-tests parallel-tests
|
|
||||||
silent-rules]
|
|
||||||
m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
|
m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
|
||||||
[gnu], [gnits]))
|
[gnu], [gnits]))
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
@@ -161,8 +159,8 @@ AC_ARG_ENABLE([yacc],
|
|||||||
, [enable_yacc=yes])
|
, [enable_yacc=yes])
|
||||||
case $enable_yacc in
|
case $enable_yacc in
|
||||||
yes)
|
yes)
|
||||||
YACC_SCRIPT=src/yacc
|
YACC_SCRIPT=yacc
|
||||||
YACC_LIBRARY=lib/liby.a;;
|
YACC_LIBRARY=liby.a;;
|
||||||
*)
|
*)
|
||||||
YACC_SCRIPT=
|
YACC_SCRIPT=
|
||||||
YACC_LIBRARY=;;
|
YACC_LIBRARY=;;
|
||||||
@@ -220,8 +218,8 @@ AC_SUBST([aclocaldir])
|
|||||||
AC_CONFIG_FILES([etc/bench.pl], [chmod +x etc/bench.pl])
|
AC_CONFIG_FILES([etc/bench.pl], [chmod +x etc/bench.pl])
|
||||||
|
|
||||||
# Initialize the test suite.
|
# Initialize the test suite.
|
||||||
AC_CONFIG_TESTDIR([tests], [$ac_abs_top_builddir/tests])
|
AC_CONFIG_TESTDIR(tests)
|
||||||
AC_CONFIG_FILES([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
|
case $VALGRIND:$host_os in
|
||||||
@@ -238,10 +236,17 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
|||||||
# Needed by tests/atlocal.in.
|
# Needed by tests/atlocal.in.
|
||||||
AC_SUBST([GCC])
|
AC_SUBST([GCC])
|
||||||
|
|
||||||
gt_JAVACOMP([1.3], [1.4])
|
gt_JAVACOMP([1.3])
|
||||||
gt_JAVAEXEC
|
gt_JAVAEXEC
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
|
build-aux/Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
|
data/Makefile
|
||||||
|
etc/Makefile
|
||||||
|
examples/Makefile
|
||||||
|
examples/calc++/Makefile
|
||||||
|
lib/Makefile src/Makefile
|
||||||
|
doc/Makefile
|
||||||
doc/yacc.1])
|
doc/yacc.1])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Makefile.in
|
||||||
|
Makefile
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
/Makefile.in
|
||||||
|
/Makefile
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
## Copyright (C) 2002, 2005-2013 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/>.
|
||||||
|
|
||||||
|
dist_pkgdata_DATA = README bison.m4 \
|
||||||
|
c-like.m4 \
|
||||||
|
c-skel.m4 c.m4 yacc.c glr.c \
|
||||||
|
c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \
|
||||||
|
java-skel.m4 java.m4 lalr1.java
|
||||||
|
|
||||||
|
m4sugardir = $(pkgdatadir)/m4sugar
|
||||||
|
dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/foreach.m4
|
||||||
|
|
||||||
|
xsltdir = $(pkgdatadir)/xslt
|
||||||
|
dist_xslt_DATA = \
|
||||||
|
xslt/bison.xsl \
|
||||||
|
xslt/xml2dot.xsl \
|
||||||
|
xslt/xml2text.xsl \
|
||||||
|
xslt/xml2xhtml.xsl
|
||||||
+51
-391
@@ -22,17 +22,14 @@
|
|||||||
## Identification. ##
|
## Identification. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
# b4_copyright(TITLE, [YEARS])
|
# b4_copyright(TITLE, YEARS)
|
||||||
# ----------------------------
|
# --------------------------
|
||||||
# If YEARS are not defined, use b4_copyright_years.
|
|
||||||
m4_define([b4_copyright],
|
m4_define([b4_copyright],
|
||||||
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
|
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
|
||||||
|
|
||||||
b4_comment([$1
|
b4_comment([$1
|
||||||
|
|
||||||
]m4_dquote(m4_text_wrap([Copyright (C)
|
m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ])
|
||||||
]m4_ifval([$2], [[$2]], [m4_defn([b4_copyright_years])])[
|
|
||||||
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
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -106,16 +103,30 @@ _m4eof
|
|||||||
])dnl
|
])dnl
|
||||||
m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])])
|
m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])])
|
||||||
|
|
||||||
# b4_error(KIND, START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_error(KIND, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -------------------------------------------------------
|
# -------------------------------------------
|
||||||
# Write @KIND(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
# Write @KIND(FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
||||||
#
|
#
|
||||||
# For example:
|
# For example:
|
||||||
#
|
#
|
||||||
# b4_error([[complain]], [[input.y:2.3]], [[input.y:5.4]],
|
# b4_error([[warn]], [[invalid value for '%s': %s]], [[foo]], [[3]])
|
||||||
# [[invalid %s]], [[foo]])
|
|
||||||
m4_define([b4_error],
|
m4_define([b4_error],
|
||||||
[b4_cat([[@complain][(]$1[@,]$2[@,]$3[@,]$4[]]dnl
|
[b4_cat([[@]$1[(]$2[]]dnl
|
||||||
|
[m4_if([$#], [2], [],
|
||||||
|
[m4_foreach([b4_arg],
|
||||||
|
m4_dquote(m4_shift(m4_shift($@))),
|
||||||
|
[[@,]b4_arg])])[@)]])])
|
||||||
|
|
||||||
|
# b4_error_at(KIND, START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# Write @KIND_at(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
||||||
|
#
|
||||||
|
# For example:
|
||||||
|
#
|
||||||
|
# b4_error_at([[complain]], [[input.y:2.3]], [[input.y:5.4]],
|
||||||
|
# [[invalid %s]], [[foo]])
|
||||||
|
m4_define([b4_error_at],
|
||||||
|
[b4_cat([[@]$1[_at(]$2[@,]$3[@,]$4[]]dnl
|
||||||
[m4_if([$#], [4], [],
|
[m4_if([$#], [4], [],
|
||||||
[m4_foreach([b4_arg],
|
[m4_foreach([b4_arg],
|
||||||
m4_dquote(m4_shift(m4_shift(m4_shift(m4_shift($@))))),
|
m4_dquote(m4_shift(m4_shift(m4_shift(m4_shift($@))))),
|
||||||
@@ -135,21 +146,21 @@ m4_define([b4_error],
|
|||||||
# m4_define([asdf], [ASDF])
|
# m4_define([asdf], [ASDF])
|
||||||
# m4_define([fsa], [FSA])
|
# m4_define([fsa], [FSA])
|
||||||
# m4_define([fdsa], [FDSA])
|
# m4_define([fdsa], [FDSA])
|
||||||
# b4_warn_at([[[asdf), asdf]]], [[[fsa), fsa]]], [[[fdsa), fdsa]]])
|
# b4_warn([[[asdf), asdf]]], [[[fsa), fsa]]], [[[fdsa), fdsa]]])
|
||||||
# b4_warn_at([[asdf), asdf]], [[fsa), fsa]], [[fdsa), fdsa]])
|
# b4_warn([[asdf), asdf]], [[fsa), fsa]], [[fdsa), fdsa]])
|
||||||
# b4_warn_at()
|
# b4_warn()
|
||||||
# b4_warn_at(1)
|
# b4_warn(1)
|
||||||
# b4_warn_at(1, 2)
|
# b4_warn(1, 2)
|
||||||
#
|
#
|
||||||
# Should produce this without newlines:
|
# Should produce this without newlines:
|
||||||
#
|
#
|
||||||
# @warn_at([asdf), asdf]@,@,@,[fsa), fsa]@,[fdsa), fdsa]@)
|
# @warn([asdf), asdf]@,[fsa), fsa]@,[fdsa), fdsa]@)
|
||||||
# @warn(asdf), asdf@,@,@,fsa), fsa@,fdsa), fdsa@)
|
# @warn(asdf), asdf@,fsa), fsa@,fdsa), fdsa@)
|
||||||
# @warn(@)
|
# @warn(@)
|
||||||
# @warn(1@)
|
# @warn(1@)
|
||||||
# @warn(1@,2@)
|
# @warn(1@,2@)
|
||||||
m4_define([b4_warn],
|
m4_define([b4_warn],
|
||||||
[b4_error([[warn]], [], [], $@)])
|
[b4_error([[warn]], $@)])
|
||||||
|
|
||||||
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
@@ -159,15 +170,15 @@ m4_define([b4_warn],
|
|||||||
#
|
#
|
||||||
# b4_warn_at([[input.y:2.3]], [[input.y:5.4]], [[invalid %s]], [[foo]])
|
# b4_warn_at([[input.y:2.3]], [[input.y:5.4]], [[invalid %s]], [[foo]])
|
||||||
m4_define([b4_warn_at],
|
m4_define([b4_warn_at],
|
||||||
[b4_error([[warn]], $@)])
|
[b4_error_at([[warn]], $@)])
|
||||||
|
|
||||||
# b4_complain(FORMAT, [ARG1], [ARG2], ...)
|
# b4_complain(FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
# Bounce to b4_complain_at.
|
# Write @complain(FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
||||||
#
|
#
|
||||||
# See b4_warn example.
|
# See b4_warn example.
|
||||||
m4_define([b4_complain],
|
m4_define([b4_complain],
|
||||||
[b4_error([[complain]], [], [], $@)])
|
[b4_error([[complain]], $@)])
|
||||||
|
|
||||||
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -------------------------------------------------------
|
# -------------------------------------------------------
|
||||||
@@ -175,15 +186,15 @@ m4_define([b4_complain],
|
|||||||
#
|
#
|
||||||
# See b4_warn_at example.
|
# See b4_warn_at example.
|
||||||
m4_define([b4_complain_at],
|
m4_define([b4_complain_at],
|
||||||
[b4_error([[complain]], $@)])
|
[b4_error_at([[complain]], $@)])
|
||||||
|
|
||||||
# b4_fatal(FORMAT, [ARG1], [ARG2], ...)
|
# b4_fatal(FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -------------------------------------
|
# -------------------------------------
|
||||||
# Bounce to b4_fatal_at.
|
# Write @fatal(FORMAT@,ARG1@,ARG2@,...@) to stdout and exit.
|
||||||
#
|
#
|
||||||
# See b4_warn example.
|
# See b4_warn example.
|
||||||
m4_define([b4_fatal],
|
m4_define([b4_fatal],
|
||||||
[b4_error([[fatal]], [], [], $@)dnl
|
[b4_error([[fatal]], $@)dnl
|
||||||
m4_exit(1)])
|
m4_exit(1)])
|
||||||
|
|
||||||
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
@@ -192,7 +203,7 @@ m4_exit(1)])
|
|||||||
#
|
#
|
||||||
# See b4_warn_at example.
|
# See b4_warn_at example.
|
||||||
m4_define([b4_fatal_at],
|
m4_define([b4_fatal_at],
|
||||||
[b4_error([[fatal]], $@)dnl
|
[b4_error_at([[fatal]], $@)dnl
|
||||||
m4_exit(1)])
|
m4_exit(1)])
|
||||||
|
|
||||||
|
|
||||||
@@ -207,87 +218,6 @@ m4_define([b4_ints_in],
|
|||||||
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
|
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
|
||||||
|
|
||||||
|
|
||||||
# b4_subtract(LHS, RHS)
|
|
||||||
# ---------------------
|
|
||||||
# Evaluate LHS - RHS if they are integer literals, otherwise expand
|
|
||||||
# to (LHS) - (RHS).
|
|
||||||
m4_define([b4_subtract],
|
|
||||||
[m4_bmatch([$1$2], [^[0123456789]*$],
|
|
||||||
[m4_eval([$1 - $2])],
|
|
||||||
[($1) - ($2)])])
|
|
||||||
|
|
||||||
# b4_join(ARG1, ...)
|
|
||||||
# _b4_join(ARG1, ...)
|
|
||||||
# -------------------
|
|
||||||
# Join with comma, skipping empty arguments.
|
|
||||||
# b4_join calls itself recursively until it sees the first non-empty
|
|
||||||
# argument, then calls _b4_join which prepends each non-empty argument
|
|
||||||
# with a comma.
|
|
||||||
m4_define([b4_join],
|
|
||||||
[m4_if([$#$1],
|
|
||||||
[1], [],
|
|
||||||
[m4_ifval([$1],
|
|
||||||
[$1[]_$0(m4_shift($@))],
|
|
||||||
[$0(m4_shift($@))])])])
|
|
||||||
|
|
||||||
# _b4_join(ARGS1, ...)
|
|
||||||
# --------------------
|
|
||||||
m4_define([_b4_join],
|
|
||||||
[m4_if([$#$1],
|
|
||||||
[1], [],
|
|
||||||
[m4_ifval([$1], [, $1])[]$0(m4_shift($@))])])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# b4_integral_parser_tables_map(MACRO)
|
|
||||||
# -------------------------------------
|
|
||||||
# Map MACRO on all the integral tables. MACRO is expected to have
|
|
||||||
# the signature MACRO(TABLE-NAME, CONTENT, COMMENT).
|
|
||||||
m4_define([b4_integral_parser_tables_map],
|
|
||||||
[$1([pact], [b4_pact],
|
|
||||||
[[YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
|
||||||
STATE-NUM.]])
|
|
||||||
|
|
||||||
$1([defact], [b4_defact],
|
|
||||||
[[YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
|
|
||||||
Performed when YYTABLE does not specify something else to do. Zero
|
|
||||||
means the default is an error.]])
|
|
||||||
|
|
||||||
$1([pgoto], [b4_pgoto], [[YYPGOTO[NTERM-NUM].]])
|
|
||||||
|
|
||||||
$1([defgoto], [b4_defgoto], [[YYDEFGOTO[NTERM-NUM].]])
|
|
||||||
|
|
||||||
$1([table], [b4_table],
|
|
||||||
[[YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
|
|
||||||
positive, shift that token. If negative, reduce the rule whose
|
|
||||||
number is the opposite. If YYTABLE_NINF, syntax error.]])
|
|
||||||
|
|
||||||
$1([check], [b4_check])
|
|
||||||
|
|
||||||
$1([stos], [b4_stos],
|
|
||||||
[[YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
|
||||||
symbol of state STATE-NUM.]])
|
|
||||||
|
|
||||||
$1([r1], [b4_r1],
|
|
||||||
[[YYR1[YYN] -- Symbol number of symbol that rule YYN derives.]])
|
|
||||||
|
|
||||||
$1([r2], [b4_r2],
|
|
||||||
[[YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.]])
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_parser_tables_declare
|
|
||||||
# b4_parser_tables_define
|
|
||||||
# ------------------------
|
|
||||||
# Define/declare the (deterministic) parser tables.
|
|
||||||
m4_define([b4_parser_tables_declare],
|
|
||||||
[b4_integral_parser_tables_map([b4_integral_parser_table_declare])])
|
|
||||||
|
|
||||||
m4_define([b4_parser_tables_define],
|
|
||||||
[b4_integral_parser_tables_map([b4_integral_parser_table_define])])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ------------------ ##
|
## ------------------ ##
|
||||||
## Decoding options. ##
|
## Decoding options. ##
|
||||||
@@ -300,7 +230,7 @@ m4_define([b4_flag_if],
|
|||||||
[m4_case(b4_$1_flag,
|
[m4_case(b4_$1_flag,
|
||||||
[0], [$3],
|
[0], [$3],
|
||||||
[1], [$2],
|
[1], [$2],
|
||||||
[m4_fatal([invalid $1 value: ]b4_$1_flag)])])
|
[m4_fatal([invalid $1 value: ]$1)])])
|
||||||
|
|
||||||
|
|
||||||
# b4_define_flag_if(FLAG)
|
# b4_define_flag_if(FLAG)
|
||||||
@@ -326,202 +256,15 @@ m4_define([b4_$3_if],
|
|||||||
# -----------------------------
|
# -----------------------------
|
||||||
# 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([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([nondeterministic]) # Whether conflicts should be handled.
|
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
||||||
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
||||||
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
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])])
|
||||||
## Symbols. ##
|
|
||||||
## --------- ##
|
|
||||||
|
|
||||||
# In order to unify the handling of the various aspects of symbols
|
|
||||||
# (tag, type_name, whether terminal, etc.), bison.exe defines one
|
|
||||||
# macro per (token, field), where field can has_id, id, etc.: see
|
|
||||||
# src/output.c:prepare_symbols_definitions().
|
|
||||||
#
|
|
||||||
# The various FIELDS are:
|
|
||||||
#
|
|
||||||
# - has_id: 0 or 1.
|
|
||||||
# Whether the symbol has an id.
|
|
||||||
# - id: string
|
|
||||||
# If has_id, the id. Guaranteed to be usable as a C identifier.
|
|
||||||
# - tag: string.
|
|
||||||
# A representat of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
|
||||||
# - user_number: integer
|
|
||||||
# The assigned (external) number as used by yylex.
|
|
||||||
# - is_token: 0 or 1
|
|
||||||
# Whether this is a terminal symbol.
|
|
||||||
# - number: integer
|
|
||||||
# The internalized number (used after yytranslate).
|
|
||||||
# - has_type: 0, 1
|
|
||||||
# Whether has a semantic value.
|
|
||||||
# - type
|
|
||||||
# If it has a semantic value, its type tag, or, if variant are used,
|
|
||||||
# its type.
|
|
||||||
# - has_printer: 0, 1
|
|
||||||
# - printer: string
|
|
||||||
# - printer_file: string
|
|
||||||
# - printer_line: integer
|
|
||||||
# If the symbol has a printer, everything about it.
|
|
||||||
# - has_destructor, destructor, destructor_file, destructor_line
|
|
||||||
# Likewise.
|
|
||||||
#
|
|
||||||
# The following macros provide access to these values.
|
|
||||||
|
|
||||||
# b4_symbol_(NUM, FIELD)
|
|
||||||
# ----------------------
|
|
||||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
|
||||||
# undefined.
|
|
||||||
m4_define([b4_symbol_],
|
|
||||||
[m4_indir([b4_symbol($1, $2)])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol(NUM, FIELD)
|
|
||||||
# ---------------------
|
|
||||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
|
||||||
# undefined. If FIELD = id, prepend the token prefix.
|
|
||||||
m4_define([b4_symbol],
|
|
||||||
[m4_case([$2],
|
|
||||||
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
|
|
||||||
[b4_symbol_([$1], [id])])],
|
|
||||||
[b4_symbol_($@)])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
|
|
||||||
# -------------------------------------------
|
|
||||||
# If FIELD about symbol #NUM is 1 expand IF-TRUE, if is 0, expand IF-FALSE.
|
|
||||||
# Otherwise an error.
|
|
||||||
m4_define([b4_symbol_if],
|
|
||||||
[m4_case(b4_symbol([$1], [$2]),
|
|
||||||
[1], [$3],
|
|
||||||
[0], [$4],
|
|
||||||
[m4_fatal([$0: field $2 of $1 is not a Boolean:] b4_symbol([$1], [$2]))])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_tag_comment(SYMBOL-NUM)
|
|
||||||
# ---------------------------------
|
|
||||||
# Issue a comment giving the tag of symbol NUM.
|
|
||||||
m4_define([b4_symbol_tag_comment],
|
|
||||||
[b4_comment([b4_symbol([$1], [tag])])
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_action_location(SYMBOL-NUM, KIND)
|
|
||||||
# -------------------------------------------
|
|
||||||
# Report the location of the KIND action as FILE:LINE.
|
|
||||||
m4_define([b4_symbol_action_location],
|
|
||||||
[b4_symbol([$1], [$2_file]):b4_syncline([b4_symbol([$1], [$2_line])])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_action(SYMBOL-NUM, KIND)
|
|
||||||
# ----------------------------------
|
|
||||||
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
|
|
||||||
# Same as in C, but using references instead of pointers.
|
|
||||||
m4_define([b4_symbol_action],
|
|
||||||
[b4_symbol_if([$1], [has_$2],
|
|
||||||
[b4_dollar_pushdef([(*yyvaluep)],
|
|
||||||
b4_symbol_if([$1], [has_type],
|
|
||||||
[m4_dquote(b4_symbol([$1], [type]))]),
|
|
||||||
[(*yylocationp)])dnl
|
|
||||||
b4_symbol_case_([$1])[]dnl
|
|
||||||
b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"])
|
|
||||||
b4_symbol([$1], [$2])
|
|
||||||
b4_syncline([@oline@], [@ofile@])
|
|
||||||
break;
|
|
||||||
|
|
||||||
b4_dollar_popdef[]dnl
|
|
||||||
])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_destructor(SYMBOL-NUM)
|
|
||||||
# b4_symbol_printer(SYMBOL-NUM)
|
|
||||||
# --------------------------------
|
|
||||||
m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])])
|
|
||||||
m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_case_(SYMBOL-NUM)
|
|
||||||
# ---------------------------
|
|
||||||
# Issue a "case NUM" for SYMBOL-NUM.
|
|
||||||
m4_define([b4_symbol_case_],
|
|
||||||
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_foreach(MACRO)
|
|
||||||
# ------------------------
|
|
||||||
# Invoke MACRO(SYMBOL-NUM) for each SYMBOL-NUM.
|
|
||||||
m4_define([b4_symbol_foreach],
|
|
||||||
[m4_map([$1], m4_defn([b4_symbol_numbers]))])
|
|
||||||
|
|
||||||
# b4_symbol_map(MACRO)
|
|
||||||
# --------------------
|
|
||||||
# Return a list (possibly empty elements) of MACRO invoked for each
|
|
||||||
# SYMBOL-NUM.
|
|
||||||
m4_define([b4_symbol_map],
|
|
||||||
[m4_map_args_sep([$1(], [)], [,], b4_symbol_numbers)])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE)
|
|
||||||
# -------------------------------------------
|
|
||||||
# Whether NUM denotes a token that has an exported definition (i.e.,
|
|
||||||
# shows in enum yytokentype).
|
|
||||||
m4_define([b4_token_visible_if],
|
|
||||||
[b4_symbol_if([$1], [is_token],
|
|
||||||
[b4_symbol_if([$1], [has_id], [$2], [$3])],
|
|
||||||
[$3])])
|
|
||||||
|
|
||||||
# b4_token_has_definition(NUM)
|
|
||||||
# ----------------------------
|
|
||||||
# 1 if NUM is visible, nothing otherwise.
|
|
||||||
m4_define([b4_token_has_definition],
|
|
||||||
[b4_token_visible_if([$1], [1])])
|
|
||||||
|
|
||||||
# b4_any_token_visible_if([IF-TRUE], [IF-FALSE])
|
|
||||||
# ----------------------------------------------
|
|
||||||
# Whether there is a token that needs to be defined.
|
|
||||||
m4_define([b4_any_token_visible_if],
|
|
||||||
[m4_ifval(b4_symbol_foreach([b4_token_has_definition]),
|
|
||||||
[$1], [$2])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_token_format(FORMAT, NUM)
|
|
||||||
# ----------------------------
|
|
||||||
m4_define([b4_token_format],
|
|
||||||
[b4_token_visible_if([$2],
|
|
||||||
[m4_quote(m4_format([$1],
|
|
||||||
[b4_symbol([$2], [id])],
|
|
||||||
[b4_symbol([$2], [user_number])]))])])
|
|
||||||
|
|
||||||
|
|
||||||
## ------- ##
|
|
||||||
## Types. ##
|
|
||||||
## ------- ##
|
|
||||||
|
|
||||||
# b4_type_action_(NUMS)
|
|
||||||
# ---------------------
|
|
||||||
# Run actions for the symbol NUMS that all have the same type-name.
|
|
||||||
# Skip NUMS that have no type-name.
|
|
||||||
#
|
|
||||||
# To specify the action to run, define b4_dollar_dollar(NUMBER,
|
|
||||||
# TAG, TYPE).
|
|
||||||
m4_define([b4_type_action_],
|
|
||||||
[b4_symbol_if([$1], [has_type],
|
|
||||||
[m4_map([ b4_symbol_case_], [$@])[]dnl
|
|
||||||
b4_dollar_dollar([b4_symbol([$1], [number])],
|
|
||||||
[b4_symbol([$1], [tag])],
|
|
||||||
[b4_symbol([$1], [type])]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
])])
|
|
||||||
|
|
||||||
# b4_type_foreach(MACRO)
|
|
||||||
# ----------------------
|
|
||||||
# Invoke MACRO(SYMBOL-NUMS) for each set of SYMBOL-NUMS for each type set.
|
|
||||||
m4_define([b4_type_foreach],
|
|
||||||
[m4_map([$1], m4_defn([b4_type_names]))])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -541,21 +284,11 @@ m4_define([b4_basename],
|
|||||||
# -----------------------
|
# -----------------------
|
||||||
m4_define([b4_syncline],
|
m4_define([b4_syncline],
|
||||||
[b4_flag_if([synclines],
|
[b4_flag_if([synclines],
|
||||||
[b4_sync_start([$1], [$2]) b4_sync_end([__line__],
|
[b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
||||||
[b4_basename(m4_quote(__file__))])[]dnl
|
b4_sync_start([$1], [$2])])])
|
||||||
])])
|
|
||||||
|
|
||||||
# b4_sync_start(LINE, FILE)
|
|
||||||
# -----------------------
|
|
||||||
# Syncline for the new place. Typically a directive for the compiler.
|
|
||||||
m4_define([b4_sync_start], [b4_comment([$2:$1])])
|
|
||||||
|
|
||||||
# b4_sync_end(LINE, FILE)
|
|
||||||
# -----------------------
|
|
||||||
# Syncline for the current place, which ends. Typically a comment
|
|
||||||
# left for the reader.
|
|
||||||
m4_define([b4_sync_end], [b4_comment([$2:$1])])
|
|
||||||
|
|
||||||
|
m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
|
||||||
|
m4_define([b4_sync_start], [b4_comment([Line $1 of $2])])
|
||||||
|
|
||||||
# b4_user_code(USER-CODE)
|
# b4_user_code(USER-CODE)
|
||||||
# -----------------------
|
# -----------------------
|
||||||
@@ -640,6 +373,7 @@ m4_popdef([b4_end])dnl
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
## b4_percent_define_*. ##
|
## b4_percent_define_*. ##
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
@@ -669,6 +403,7 @@ m4_ifdef([b4_percent_define(]$1[)],
|
|||||||
[m4_indir([b4_percent_define(]$1[)])],
|
[m4_indir([b4_percent_define(]$1[)])],
|
||||||
[$2])])
|
[$2])])
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_get_loc(VARIABLE)
|
# b4_percent_define_get_loc(VARIABLE)
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,
|
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,
|
||||||
@@ -717,15 +452,9 @@ m4_define([b4_percent_define_get_syncline],
|
|||||||
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
||||||
m4_define([b4_percent_define_ifdef],
|
m4_define([b4_percent_define_ifdef],
|
||||||
[m4_ifdef([b4_percent_define(]$1[)],
|
[m4_ifdef([b4_percent_define(]$1[)],
|
||||||
[b4_percent_define_use([$1])$2],
|
[m4_define([b4_percent_define_bison_variables(]$1[)])$2],
|
||||||
[$3])])
|
[$3])])
|
||||||
|
|
||||||
|
|
||||||
## --------- ##
|
|
||||||
## Options. ##
|
|
||||||
## --------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE])
|
# b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE])
|
||||||
# --------------------------------------------------------
|
# --------------------------------------------------------
|
||||||
# Mimic muscle_percent_define_flag_if in ../src/muscle-tab.h exactly. That is,
|
# Mimic muscle_percent_define_flag_if in ../src/muscle-tab.h exactly. That is,
|
||||||
@@ -749,7 +478,6 @@ m4_define([b4_percent_define_flag_if],
|
|||||||
[[b4_percent_define_flag_if($1)]])])],
|
[[b4_percent_define_flag_if($1)]])])],
|
||||||
[b4_fatal([[b4_percent_define_flag_if: undefined %%define variable '%s']], [$1])])])
|
[b4_fatal([[b4_percent_define_flag_if: undefined %%define variable '%s']], [$1])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_default(VARIABLE, DEFAULT)
|
# b4_percent_define_default(VARIABLE, DEFAULT)
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is,
|
# Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is,
|
||||||
@@ -768,21 +496,6 @@ m4_define([b4_percent_define_default],
|
|||||||
[[<skeleton default value>:-1.-1]]]])dnl
|
[[<skeleton default value>:-1.-1]]]])dnl
|
||||||
m4_define([b4_percent_define_syncline(]$1[)], [[]])])])
|
m4_define([b4_percent_define_syncline(]$1[)], [[]])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_if_define(NAME, [VARIABLE = NAME])
|
|
||||||
# ----------------------------------------------------
|
|
||||||
# Define b4_NAME_if that executes its $1 or $2 depending whether
|
|
||||||
# VARIABLE was %defined. The characters `.' and `-' in VARIABLE are mapped
|
|
||||||
# to `_'.
|
|
||||||
m4_define([b4_percent_define_if_define_],
|
|
||||||
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
|
|
||||||
[b4_percent_define_flag_if(m4_default([$2], [$1]),
|
|
||||||
[$3], [$4])])])
|
|
||||||
m4_define([b4_percent_define_if_define],
|
|
||||||
[b4_percent_define_default([m4_default([$2], [$1])], [[false]])
|
|
||||||
b4_percent_define_if_define_([$1], [$2], $[1], $[2])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_check_values(VALUES)
|
# b4_percent_define_check_values(VALUES)
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly
|
# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly
|
||||||
@@ -816,7 +529,7 @@ m4_define([_b4_percent_define_check_values],
|
|||||||
[$1],
|
[$1],
|
||||||
m4_dquote(m4_indir([b4_percent_define(]$1[)])))
|
m4_dquote(m4_indir([b4_percent_define(]$1[)])))
|
||||||
m4_foreach([b4_value], m4_dquote(m4_shift($@)),
|
m4_foreach([b4_value], m4_dquote(m4_shift($@)),
|
||||||
[b4_error([[note]], b4_percent_define_get_loc([$1]), []
|
[b4_complain_at(b4_percent_define_get_loc([$1]),
|
||||||
[[accepted value: '%s']],
|
[[accepted value: '%s']],
|
||||||
m4_dquote(b4_value))])])dnl
|
m4_dquote(b4_value))])])dnl
|
||||||
m4_popdef([b4_good_value])],
|
m4_popdef([b4_good_value])],
|
||||||
@@ -857,59 +570,6 @@ m4_define([b4_percent_code_ifdef],
|
|||||||
[$3])])
|
[$3])])
|
||||||
|
|
||||||
|
|
||||||
## ------------------ ##
|
|
||||||
## Common variables. ##
|
|
||||||
## ------------------ ##
|
|
||||||
|
|
||||||
# Default values for %define.
|
|
||||||
# ---------------------------
|
|
||||||
# If the api.token.prefix, it is empty.
|
|
||||||
m4_percent_define_default([[api.token.prefix]], [[]])
|
|
||||||
|
|
||||||
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
|
|
||||||
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
|
||||||
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
|
|
||||||
# ----------------------------------------------
|
|
||||||
b4_percent_define_if_define([token_ctor], [api.token.constructor])
|
|
||||||
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
|
||||||
b4_percent_define_if_define([parse.assert])
|
|
||||||
b4_percent_define_if_define([parse.trace])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_bison_locations_if([IF-TRUE])
|
|
||||||
# --------------------------------
|
|
||||||
# Expand IF-TRUE if using locations, and using the default location
|
|
||||||
# type.
|
|
||||||
m4_define([b4_bison_locations_if],
|
|
||||||
[b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [], [$1])])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
|
|
||||||
# ------------------------------------------------------
|
|
||||||
# Map %define parse.error "(simple|verbose)" to b4_error_verbose_if and
|
|
||||||
# b4_error_verbose_flag.
|
|
||||||
b4_percent_define_default([[parse.error]], [[simple]])
|
|
||||||
b4_percent_define_check_values([[[[parse.error]],
|
|
||||||
[[simple]], [[verbose]]]])
|
|
||||||
m4_define([b4_error_verbose_flag],
|
|
||||||
[m4_case(b4_percent_define_get([[parse.error]]),
|
|
||||||
[simple], [[0]],
|
|
||||||
[verbose], [[1]])])
|
|
||||||
b4_define_flag_if([error_verbose])
|
|
||||||
|
|
||||||
# yytoken_table is needed to support verbose errors.
|
|
||||||
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
|
|
||||||
# ----------------------------------------------
|
|
||||||
b4_percent_define_if_define([variant])
|
|
||||||
m4_case(b4_percent_define_get([[api.value.type]]),
|
|
||||||
[variant], [m4_define([b4_variant_flag], [[1]])],
|
|
||||||
[m4_define([b4_variant_flag], [[0]])])
|
|
||||||
b4_define_flag_if([variant])
|
|
||||||
|
|
||||||
|
|
||||||
## ----------------------------------------------------------- ##
|
## ----------------------------------------------------------- ##
|
||||||
## After processing the skeletons, check that all the user's ##
|
## After processing the skeletons, check that all the user's ##
|
||||||
## %define variables and %code qualifiers were used by Bison. ##
|
## %define variables and %code qualifiers were used by Bison. ##
|
||||||
|
|||||||
+18
-335
@@ -19,17 +19,11 @@
|
|||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c.m4])
|
m4_include(b4_pkgdatadir/[c.m4])
|
||||||
|
|
||||||
# b4_comment(TEXT, [PREFIX])
|
|
||||||
# --------------------------
|
|
||||||
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
|
||||||
m4_define([b4_comment],
|
|
||||||
[b4_comment_([$1], [$2// ], [$2// ])])
|
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Default values. ##
|
## Default values. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
|
# Default parser class name.
|
||||||
b4_percent_define_default([[parser_class_name]], [[parser]])
|
b4_percent_define_default([[parser_class_name]], [[parser]])
|
||||||
|
|
||||||
# Don't do that so that we remember whether we're using a user
|
# Don't do that so that we remember whether we're using a user
|
||||||
@@ -38,21 +32,18 @@ b4_percent_define_default([[parser_class_name]], [[parser]])
|
|||||||
# b4_percent_define_default([[api.location.type]], [[location]])
|
# b4_percent_define_default([[api.location.type]], [[location]])
|
||||||
|
|
||||||
b4_percent_define_default([[filename_type]], [[std::string]])
|
b4_percent_define_default([[filename_type]], [[std::string]])
|
||||||
b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
|
b4_percent_define_default([[namespace]], m4_defn([b4_prefix]))
|
||||||
|
|
||||||
b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
|
b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
|
||||||
b4_percent_define_default([[define_location_comparison]],
|
b4_percent_define_default([[define_location_comparison]],
|
||||||
[m4_if(b4_percent_define_get([[filename_type]]),
|
[m4_if(b4_percent_define_get([[filename_type]]),
|
||||||
[std::string], [[true]], [[false]])])
|
[std::string], [[true]], [[false]])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ----------- ##
|
## ----------- ##
|
||||||
## Namespace. ##
|
## Namespace. ##
|
||||||
## ----------- ##
|
## ----------- ##
|
||||||
|
|
||||||
m4_define([b4_namespace_ref], [b4_percent_define_get([[api.namespace]])])
|
m4_define([b4_namespace_ref], [b4_percent_define_get([[namespace]])])
|
||||||
|
|
||||||
|
|
||||||
# Don't permit an empty b4_namespace_ref. Any `::parser::foo' appended to it
|
# Don't permit an empty b4_namespace_ref. Any `::parser::foo' appended to it
|
||||||
# would compile as an absolute reference with `parser' in the global namespace.
|
# would compile as an absolute reference with `parser' in the global namespace.
|
||||||
@@ -62,7 +53,7 @@ m4_define([b4_namespace_ref], [b4_percent_define_get([[api.namespace]])])
|
|||||||
# include the header, which is always generated. If we ever need to permit
|
# include the header, which is always generated. If we ever need to permit
|
||||||
# internal linkage somehow, surely we can find a cleaner approach.
|
# internal linkage somehow, surely we can find a cleaner approach.
|
||||||
m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
||||||
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
[b4_complain_at(b4_percent_define_get_loc([[namespace]]),
|
||||||
[[namespace reference is empty]])])
|
[[namespace reference is empty]])])
|
||||||
|
|
||||||
# Instead of assuming the C++ compiler will do it, Bison should reject any
|
# Instead of assuming the C++ compiler will do it, Bison should reject any
|
||||||
@@ -73,36 +64,36 @@ m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
|||||||
# Specifically, don't allow empty names as b4_namespace_open would just convert
|
# Specifically, don't allow empty names as b4_namespace_open would just convert
|
||||||
# those into anonymous namespaces, and that might tempt some users.
|
# those into anonymous namespaces, and that might tempt some users.
|
||||||
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [],
|
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [],
|
||||||
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
[b4_complain_at(b4_percent_define_get_loc([[namespace]]),
|
||||||
[[namespace reference has consecutive "::"]])])
|
[[namespace reference has consecutive "::"]])])
|
||||||
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
|
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
|
||||||
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
[b4_complain_at(b4_percent_define_get_loc([[namespace]]),
|
||||||
[[namespace reference has a trailing "::"]])])
|
[[namespace reference has a trailing "::"]])])
|
||||||
|
|
||||||
m4_define([b4_namespace_open],
|
m4_define([b4_namespace_open],
|
||||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
|
[b4_user_code([b4_percent_define_get_syncline([[namespace]])
|
||||||
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
|
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
|
||||||
[^\(.\)[ ]*::], [\1])),
|
[^\(.\)[ ]*::], [\1])),
|
||||||
[::], [ { namespace ])[ {]])])
|
[::], [ { namespace ])[ {]])])
|
||||||
|
|
||||||
m4_define([b4_namespace_close],
|
m4_define([b4_namespace_close],
|
||||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
|
[b4_user_code([b4_percent_define_get_syncline([[namespace]])
|
||||||
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
||||||
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
||||||
[\1])),
|
[\1])),
|
||||||
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums
|
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||||
# --------------
|
# -----------------------------------------------------
|
||||||
# Output the definition of the tokens as enums.
|
# Output the definition of the tokens as enums.
|
||||||
m4_define([b4_token_enums],
|
m4_define([b4_token_enums],
|
||||||
[[enum yytokentype
|
[/* Tokens. */
|
||||||
{
|
enum yytokentype {
|
||||||
]m4_join([,
|
m4_map_sep([ b4_token_enum], [,
|
||||||
],
|
],
|
||||||
b4_symbol_map([b4_token_enum]))[
|
[$@])
|
||||||
};]dnl
|
};
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -112,319 +103,12 @@ m4_define([b4_token_enums],
|
|||||||
## Semantic Values. ##
|
## Semantic Values. ##
|
||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
|
|
||||||
# b4_semantic_type_declare
|
|
||||||
# ------------------------
|
|
||||||
# Declare semantic_type.
|
|
||||||
m4_define([b4_semantic_type_declare],
|
|
||||||
[ /// Symbol semantic values.
|
|
||||||
m4_ifdef([b4_stype],
|
|
||||||
[ union semantic_type
|
|
||||||
{
|
|
||||||
b4_user_stype
|
|
||||||
};],
|
|
||||||
[m4_if(b4_tag_seen_flag, 0,
|
|
||||||
[[ typedef int semantic_type;]],
|
|
||||||
[[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_public_types_declare
|
|
||||||
# -----------------------
|
|
||||||
# Define the public types: token, semantic value, location, and so forth.
|
|
||||||
# Depending on %define token_lex, may be output in the header or source file.
|
|
||||||
m4_define([b4_public_types_declare],
|
|
||||||
[[#ifndef ]b4_api_PREFIX[STYPE
|
|
||||||
]b4_semantic_type_declare[
|
|
||||||
#else
|
|
||||||
typedef ]b4_api_PREFIX[STYPE semantic_type;
|
|
||||||
#endif]b4_locations_if([
|
|
||||||
/// Symbol locations.
|
|
||||||
typedef b4_percent_define_get([[api.location.type]],
|
|
||||||
[[location]]) location_type;])[
|
|
||||||
|
|
||||||
/// Syntax errors thrown from user actions.
|
|
||||||
struct syntax_error : std::runtime_error
|
|
||||||
{
|
|
||||||
syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m);]b4_locations_if([
|
|
||||||
location_type location;])[
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Tokens.
|
|
||||||
struct token
|
|
||||||
{
|
|
||||||
]b4_token_enums[
|
|
||||||
};
|
|
||||||
|
|
||||||
/// (External) token type, as returned by yylex.
|
|
||||||
typedef token::yytokentype token_type;
|
|
||||||
|
|
||||||
/// Internal symbol number.
|
|
||||||
typedef int symbol_number_type;
|
|
||||||
|
|
||||||
/// Internal symbol number for tokens (subsumed by symbol_number_type).
|
|
||||||
typedef ]b4_int_type_for([b4_translate])[ token_number_type;
|
|
||||||
|
|
||||||
/// A complete symbol.
|
|
||||||
///
|
|
||||||
/// Expects its Base type to provide access to the symbol type
|
|
||||||
/// via type_get().
|
|
||||||
///
|
|
||||||
/// Provide access to semantic value]b4_locations_if([ and location])[.
|
|
||||||
template <typename Base>
|
|
||||||
struct basic_symbol : Base
|
|
||||||
{
|
|
||||||
/// Alias to Base.
|
|
||||||
typedef Base super_type;
|
|
||||||
|
|
||||||
/// Default constructor.
|
|
||||||
basic_symbol ();
|
|
||||||
|
|
||||||
/// Copy constructor.
|
|
||||||
basic_symbol (const basic_symbol& other);
|
|
||||||
]b4_variant_if([[
|
|
||||||
/// Constructor for valueless symbols, and symbols from each type.
|
|
||||||
]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[
|
|
||||||
/// Constructor for valueless symbols.
|
|
||||||
basic_symbol (typename Base::kind_type t]b4_locations_if([,
|
|
||||||
const location_type& l])[);]])[
|
|
||||||
|
|
||||||
/// Constructor for symbols with semantic value.
|
|
||||||
basic_symbol (typename Base::kind_type t,
|
|
||||||
const semantic_type& v]b4_locations_if([,
|
|
||||||
const location_type& l])[);
|
|
||||||
|
|
||||||
~basic_symbol ();
|
|
||||||
|
|
||||||
/// Destructive move, \a s is emptied into this.
|
|
||||||
void move (basic_symbol& s);
|
|
||||||
|
|
||||||
/// The semantic value.
|
|
||||||
semantic_type value;]b4_locations_if([
|
|
||||||
|
|
||||||
/// The location.
|
|
||||||
location_type location;])[
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Assignment operator.
|
|
||||||
basic_symbol& operator= (const basic_symbol& other);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Type access provider for token (enum) based symbols.
|
|
||||||
struct by_type
|
|
||||||
{
|
|
||||||
/// Default constructor.
|
|
||||||
by_type ();
|
|
||||||
|
|
||||||
/// Copy constructor.
|
|
||||||
by_type (const by_type& other);
|
|
||||||
|
|
||||||
/// The symbol type as needed by the constructor.
|
|
||||||
typedef token_type kind_type;
|
|
||||||
|
|
||||||
/// Constructor from (external) token numbers.
|
|
||||||
by_type (kind_type t);
|
|
||||||
|
|
||||||
/// Steal the symbol type from \a that.
|
|
||||||
void move (by_type& that);
|
|
||||||
|
|
||||||
/// The (internal) type number (corresponding to \a type).
|
|
||||||
/// -1 when this symbol is empty.
|
|
||||||
symbol_number_type type_get () const;
|
|
||||||
|
|
||||||
/// The token.
|
|
||||||
token_type token () const;
|
|
||||||
|
|
||||||
enum { empty = 0 };
|
|
||||||
|
|
||||||
/// The symbol type.
|
|
||||||
/// -1 when this symbol is empty.
|
|
||||||
token_number_type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// "External" symbols: returned by the scanner.
|
|
||||||
typedef basic_symbol<by_type> symbol_type;
|
|
||||||
|
|
||||||
]b4_symbol_constructor_declare])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_public_types_define
|
|
||||||
# ----------------------
|
|
||||||
# Provide the implementation needed by the public types.
|
|
||||||
m4_define([b4_public_types_define],
|
|
||||||
[[ inline
|
|
||||||
]b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
|
|
||||||
: std::runtime_error (m)]b4_locations_if([
|
|
||||||
, location (l)])[
|
|
||||||
{}
|
|
||||||
|
|
||||||
// basic_symbol.
|
|
||||||
template <typename Base>
|
|
||||||
inline
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()
|
|
||||||
: value ()
|
|
||||||
{}
|
|
||||||
|
|
||||||
template <typename Base>
|
|
||||||
inline
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
|
|
||||||
: Base (other)
|
|
||||||
, value ()]b4_locations_if([
|
|
||||||
, location (other.location)])[
|
|
||||||
{
|
|
||||||
]b4_variant_if([b4_symbol_variant([other.type_get ()], [value], [copy],
|
|
||||||
[other.value])],
|
|
||||||
[value = other.value;])[
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <typename Base>
|
|
||||||
inline
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
|
||||||
[typename Base::kind_type t],
|
|
||||||
[const semantic_type& v],
|
|
||||||
b4_locations_if([const location_type& l]))[)
|
|
||||||
: Base (t)
|
|
||||||
, value (]b4_variant_if([], [v])[)]b4_locations_if([
|
|
||||||
, location (l)])[
|
|
||||||
{]b4_variant_if([[
|
|
||||||
(void) v;
|
|
||||||
]b4_symbol_variant([this->type_get ()], [value], [copy], [v])])[}
|
|
||||||
|
|
||||||
]b4_variant_if([[
|
|
||||||
// Implementation of basic_symbol constructor for each type.
|
|
||||||
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
|
|
||||||
/// Constructor for valueless symbols.
|
|
||||||
template <typename Base>
|
|
||||||
inline
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
|
||||||
[typename Base::kind_type t],
|
|
||||||
b4_locations_if([const location_type& l]))[)
|
|
||||||
: Base (t)
|
|
||||||
, value ()]b4_locations_if([
|
|
||||||
, location (l)])[
|
|
||||||
{}]])[
|
|
||||||
|
|
||||||
template <typename Base>
|
|
||||||
inline
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
|
|
||||||
{]b4_variant_if([[
|
|
||||||
// User destructor.
|
|
||||||
symbol_number_type yytype = this->type_get ();
|
|
||||||
switch (yytype)
|
|
||||||
{
|
|
||||||
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
|
||||||
[ default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Type destructor.
|
|
||||||
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Base>
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s)
|
|
||||||
{
|
|
||||||
super_type::move(s);
|
|
||||||
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move],
|
|
||||||
[s.value])],
|
|
||||||
[value = s.value;])[]b4_locations_if([
|
|
||||||
location = s.location;])[
|
|
||||||
}
|
|
||||||
|
|
||||||
// by_type.
|
|
||||||
inline
|
|
||||||
]b4_parser_class_name[::by_type::by_type ()
|
|
||||||
: type (empty)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline
|
|
||||||
]b4_parser_class_name[::by_type::by_type (const by_type& other)
|
|
||||||
: type (other.type)
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline
|
|
||||||
]b4_parser_class_name[::by_type::by_type (token_type t)
|
|
||||||
: type (yytranslate_ (t))
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
]b4_parser_class_name[::by_type::move (by_type& that)
|
|
||||||
{
|
|
||||||
type = that.type;
|
|
||||||
that.type = empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
int
|
|
||||||
]b4_parser_class_name[::by_type::type_get () const
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
]b4_token_ctor_if([[
|
|
||||||
inline
|
|
||||||
]b4_parser_class_name[::token_type
|
|
||||||
]b4_parser_class_name[::by_type::token () const
|
|
||||||
{
|
|
||||||
// YYTOKNUM[NUM] -- (External) token number corresponding to the
|
|
||||||
// (internal) symbol number NUM (which must be that of a token). */
|
|
||||||
static
|
|
||||||
const ]b4_int_type_for([b4_toknum])[
|
|
||||||
yytoken_number_[] =
|
|
||||||
{
|
|
||||||
]b4_toknum[
|
|
||||||
};
|
|
||||||
return static_cast<token_type> (yytoken_number_[type]);
|
|
||||||
}
|
|
||||||
]])[]dnl
|
|
||||||
b4_symbol_constructor_define])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_constructor_declare
|
|
||||||
# b4_symbol_constructor_define
|
|
||||||
# -----------------------------
|
|
||||||
# Declare/define symbol constructors for all the value types.
|
|
||||||
# Use at class-level. Redefined in variant.hh.
|
|
||||||
m4_define([b4_symbol_constructor_declare], [])
|
|
||||||
m4_define([b4_symbol_constructor_define], [])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_yytranslate_define
|
|
||||||
# ---------------------
|
|
||||||
# Define yytranslate_. Sometimes used in the header file,
|
|
||||||
# sometimes in the cc file.
|
|
||||||
m4_define([b4_yytranslate_define],
|
|
||||||
[[ // Symbol number corresponding to token number t.
|
|
||||||
inline
|
|
||||||
]b4_parser_class_name[::token_number_type
|
|
||||||
]b4_parser_class_name[::yytranslate_ (]b4_token_ctor_if([token_type],
|
|
||||||
[int])[ t)
|
|
||||||
{
|
|
||||||
static
|
|
||||||
const token_number_type
|
|
||||||
translate_table[] =
|
|
||||||
{
|
|
||||||
]b4_translate[
|
|
||||||
};
|
|
||||||
const unsigned int user_token_number_max_ = ]b4_user_token_number_max[;
|
|
||||||
const token_number_type undef_token_ = ]b4_undef_token_number[;
|
|
||||||
|
|
||||||
if (static_cast<int>(t) <= yyeof_)
|
|
||||||
return yyeof_;
|
|
||||||
else if (static_cast<unsigned int> (t) <= user_token_number_max_)
|
|
||||||
return translate_table[t];
|
|
||||||
else
|
|
||||||
return undef_token_;
|
|
||||||
}
|
|
||||||
]])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_lhs_value([TYPE])
|
# b4_lhs_value([TYPE])
|
||||||
# --------------------
|
# --------------------
|
||||||
# Expansion of $<TYPE>$.
|
# Expansion of $<TYPE>$.
|
||||||
m4_define([b4_lhs_value],
|
m4_define([b4_lhs_value],
|
||||||
[b4_symbol_value([yyval], [$1])])
|
[(yyval[]m4_ifval([$1], [.$1]))])
|
||||||
|
|
||||||
|
|
||||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
||||||
@@ -432,8 +116,7 @@ m4_define([b4_lhs_value],
|
|||||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||||
# symbols on RHS.
|
# symbols on RHS.
|
||||||
m4_define([b4_rhs_value],
|
m4_define([b4_rhs_value],
|
||||||
[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
|
[(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))])
|
||||||
|
|
||||||
|
|
||||||
# b4_lhs_location()
|
# b4_lhs_location()
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -484,7 +167,7 @@ m4_define([b4_cc_constructor_call],
|
|||||||
m4_define([b4_parse_param_vars],
|
m4_define([b4_parse_param_vars],
|
||||||
[m4_ifset([b4_parse_param],
|
[m4_ifset([b4_parse_param],
|
||||||
[
|
[
|
||||||
// User arguments.
|
/* User arguments. */
|
||||||
b4_cc_var_decls(b4_parse_param)])])
|
b4_cc_var_decls(b4_parse_param)])])
|
||||||
m4_define([b4_cc_var_decls],
|
m4_define([b4_cc_var_decls],
|
||||||
[m4_map_sep([b4_cc_var_decl], [
|
[m4_map_sep([b4_cc_var_decl], [
|
||||||
|
|||||||
+4
-25
@@ -17,37 +17,16 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
# b4_comment_(TEXT, OPEN, CONTINUE, END)
|
|
||||||
# --------------------------------------
|
|
||||||
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
|
||||||
# Avoid adding indentation to the first line, as the indentation comes
|
|
||||||
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
|
||||||
#
|
|
||||||
# Prefix all the output lines with PREFIX.
|
|
||||||
m4_define([b4_comment_],
|
|
||||||
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
|
|
||||||
\(.\)], [
|
|
||||||
$3\1])$4])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_comment(TEXT, [PREFIX])
|
|
||||||
# --------------------------
|
|
||||||
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
|
||||||
m4_define([b4_comment],
|
|
||||||
[b4_comment_([$1], [$2/* ], [$2 ], [ */])])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)
|
# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
|
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
|
||||||
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
|
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
|
||||||
# pointer.
|
# pointer.
|
||||||
m4_define([b4_dollar_dollar_],
|
m4_define([b4_dollar_dollar_],
|
||||||
[b4_symbol_value([$1],
|
[m4_if([$2], [[]],
|
||||||
m4_if([$2], [[]],
|
[m4_ifval([$3], [($1.$3)],
|
||||||
[[$3]], [[$2]]))])
|
[$1])],
|
||||||
|
[($1.$2)])])
|
||||||
|
|
||||||
# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION)
|
# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION)
|
||||||
# b4_dollar_popdef
|
# b4_dollar_popdef
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ m4_define([b4_cpp_guard_close],
|
|||||||
## Identification. ##
|
## Identification. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
|
# b4_comment(TEXT)
|
||||||
|
# ----------------
|
||||||
|
m4_define([b4_comment], [/* m4_bpatsubst([$1], [
|
||||||
|
], [
|
||||||
|
]) */])
|
||||||
|
|
||||||
# b4_identification
|
# b4_identification
|
||||||
# -----------------
|
# -----------------
|
||||||
# Depends on individual skeletons to define b4_pure_flag, b4_push_flag, or
|
# Depends on individual skeletons to define b4_pure_flag, b4_push_flag, or
|
||||||
@@ -104,27 +110,10 @@ m4_define_default([b4_union_name], [b4_api_PREFIX[]STYPE])
|
|||||||
## Pure/impure interfaces. ##
|
## Pure/impure interfaces. ##
|
||||||
## ------------------------ ##
|
## ------------------------ ##
|
||||||
|
|
||||||
# b4_lex_formals
|
|
||||||
# --------------
|
|
||||||
# All the yylex formal arguments.
|
|
||||||
# b4_lex_param arrives quoted twice, but we want to keep only one level.
|
|
||||||
m4_define([b4_lex_formals],
|
|
||||||
[b4_pure_if([[[[YYSTYPE *yylvalp]], [[&yylval]]][]dnl
|
|
||||||
b4_locations_if([, [[YYLTYPE *yyllocp], [&yylloc]]])])dnl
|
|
||||||
m4_ifdef([b4_lex_param], [, ]b4_lex_param)])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_lex
|
|
||||||
# ------
|
|
||||||
# Call yylex.
|
|
||||||
m4_define([b4_lex],
|
|
||||||
[b4_function_call([yylex], [int], b4_lex_formals)])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_user_args
|
# b4_user_args
|
||||||
# ------------
|
# ------------
|
||||||
m4_define([b4_user_args],
|
m4_define([b4_user_args],
|
||||||
[m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])])
|
[m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])])
|
||||||
|
|
||||||
|
|
||||||
# b4_parse_param
|
# b4_parse_param
|
||||||
@@ -148,13 +137,11 @@ m4_popdef([$2])dnl
|
|||||||
m4_popdef([$1])dnl
|
m4_popdef([$1])dnl
|
||||||
])])
|
])])
|
||||||
|
|
||||||
# b4_parse_param_use([VAL], [LOC])
|
# b4_parse_param_use
|
||||||
# --------------------------------
|
# ------------------
|
||||||
# `YYUSE' VAL, LOC if locations are enabled, and all the parse-params.
|
# `YYUSE' all the parse-params.
|
||||||
m4_define([b4_parse_param_use],
|
m4_define([b4_parse_param_use],
|
||||||
[m4_ifvaln([$1], [ YYUSE ([$1]);])dnl
|
[b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
|
||||||
b4_locations_if([m4_ifvaln([$2], [ YYUSE ([$2]);])])dnl
|
|
||||||
b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
|
|
||||||
])dnl
|
])dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -191,17 +178,38 @@ m4_define([b4_int_type_for],
|
|||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# Without inducing a comparison warning from the compiler, check if the
|
# Without inducing a comparison warning from the compiler, check if the
|
||||||
# literal value LITERAL equals VALUE from table TABLE, which must have
|
# literal value LITERAL equals VALUE from table TABLE, which must have
|
||||||
# TABLE_min and TABLE_max defined.
|
# TABLE_min and TABLE_max defined. YYID must be defined as an identity
|
||||||
|
# function that suppresses warnings about constant conditions.
|
||||||
m4_define([b4_table_value_equals],
|
m4_define([b4_table_value_equals],
|
||||||
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|
||||||
|| m4_indir([b4_]$1[_max]) < $3), [1],
|
|| m4_indir([b4_]$1[_max]) < $3), [1],
|
||||||
[[0]],
|
[[YYID (0)]],
|
||||||
[(!!(($2) == ($3)))])])
|
[(!!(($2) == ($3)))])])
|
||||||
|
|
||||||
|
|
||||||
## ---------##
|
## ----------------- ##
|
||||||
## Values. ##
|
## Compiler issues. ##
|
||||||
## ---------##
|
## ----------------- ##
|
||||||
|
|
||||||
|
# b4_attribute_define
|
||||||
|
# -------------------
|
||||||
|
# Provide portability for __attribute__.
|
||||||
|
m4_define([b4_attribute_define],
|
||||||
|
[#ifndef __attribute__
|
||||||
|
/* This feature is available in gcc versions 2.5 and later. */
|
||||||
|
# if (! defined __GNUC__ || __GNUC__ < 2 \
|
||||||
|
|| (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
|
||||||
|
# define __attribute__(Spec) /* empty */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Suppress unused-variable warnings by "using" E. */
|
||||||
|
#if ! defined lint || defined __GNUC__
|
||||||
|
# define YYUSE(E) ((void) (E))
|
||||||
|
#else
|
||||||
|
# define YYUSE(E) /* empty */
|
||||||
|
#endif
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_null_define
|
# b4_null_define
|
||||||
@@ -224,148 +232,191 @@ m4_define([b4_null_define],
|
|||||||
# Return a null pointer constant.
|
# Return a null pointer constant.
|
||||||
m4_define([b4_null], [YY_NULL])
|
m4_define([b4_null], [YY_NULL])
|
||||||
|
|
||||||
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
|
|
||||||
# -------------------------------------------------------------
|
|
||||||
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
|
|
||||||
m4_define([b4_integral_parser_table_define],
|
|
||||||
[m4_ifvaln([$3], [b4_comment([$3], [ ])])dnl
|
|
||||||
static const b4_int_type_for([$2]) yy$1[[]] =
|
|
||||||
{
|
|
||||||
$2
|
|
||||||
};dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
## ------------------------- ##
|
## ------------------------- ##
|
||||||
## Assigning token numbers. ##
|
## Assigning token numbers. ##
|
||||||
## ------------------------- ##
|
## ------------------------- ##
|
||||||
|
|
||||||
# b4_token_define(TOKEN-NUM)
|
# b4_token_define(TOKEN-NAME, TOKEN-NUMBER)
|
||||||
# --------------------------
|
# -----------------------------------------
|
||||||
# Output the definition of this token as #define.
|
# Output the definition of this token as #define.
|
||||||
m4_define([b4_token_define],
|
m4_define([b4_token_define],
|
||||||
[b4_token_format([#define %s %s], [$1])])
|
[#define $1 $2
|
||||||
|
])
|
||||||
|
|
||||||
# b4_token_defines
|
|
||||||
# ----------------
|
# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||||
# Output the definition of the tokens.
|
# -------------------------------------------------------
|
||||||
|
# Output the definition of the tokens (if there are) as #defines.
|
||||||
m4_define([b4_token_defines],
|
m4_define([b4_token_defines],
|
||||||
[b4_any_token_visible_if([/* Tokens. */
|
[m4_if([$#$1], [1], [],
|
||||||
m4_join([
|
[/* Tokens. */
|
||||||
], b4_symbol_map([b4_token_define]))
|
m4_map([b4_token_define], [$@])])
|
||||||
])])
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enum(TOKEN-NUM)
|
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||||
# ------------------------
|
# ---------------------------------------
|
||||||
# Output the definition of this token as an enum.
|
# Output the definition of this token as an enum.
|
||||||
m4_define([b4_token_enum],
|
m4_define([b4_token_enum],
|
||||||
[b4_token_format([%s = %s], [$1])])
|
[$1 = $2])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums
|
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||||
# --------------
|
# -----------------------------------------------------
|
||||||
# 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],
|
||||||
[b4_any_token_visible_if([[/* Token type. */
|
[m4_if([$#$1], [1], [],
|
||||||
|
[[/* Tokens. */
|
||||||
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
||||||
# define ]b4_api_PREFIX[TOKENTYPE
|
# define ]b4_api_PREFIX[TOKENTYPE
|
||||||
enum ]b4_api_prefix[tokentype
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
{
|
know about them. */
|
||||||
]m4_join([,
|
enum ]b4_api_prefix[tokentype {
|
||||||
|
]m4_map_sep([ b4_token_enum], [,
|
||||||
],
|
],
|
||||||
b4_symbol_map([b4_token_enum]))[
|
[$@])[
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
]])])
|
]])])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums_defines
|
# b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||||
# ----------------------
|
# -------------------------------------------------------------
|
||||||
# Output the definition of the tokens (if there are any) as enums and,
|
# Output the definition of the tokens (if there are any) as enums and, if POSIX
|
||||||
# if POSIX Yacc is enabled, as #defines.
|
# Yacc is enabled, as #defines.
|
||||||
m4_define([b4_token_enums_defines],
|
m4_define([b4_token_enums_defines],
|
||||||
[b4_token_enums[]b4_yacc_if([b4_token_defines])])
|
[b4_token_enums($@)b4_yacc_if([b4_token_defines($@)], [])
|
||||||
|
|
||||||
|
|
||||||
## ----------------- ##
|
|
||||||
## Semantic Values. ##
|
|
||||||
## ----------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_value(VAL, [TYPE])
|
|
||||||
# ----------------------------
|
|
||||||
# Given a semantic value VAL ($$, $1 etc.), extract its value of type
|
|
||||||
# TYPE if TYPE is given, otherwise just return VAL. The result can be
|
|
||||||
# used safetly, it is put in parens to avoid nasty precedence issues.
|
|
||||||
# TYPE is *not* put in braces, provide some if needed.
|
|
||||||
m4_define([b4_symbol_value],
|
|
||||||
[($1[]m4_ifval([$2], [.$2]))])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ---------------------- ##
|
|
||||||
## Defining C functions. ##
|
|
||||||
## ---------------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# b4_function_define(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
|
||||||
# -----------------------------------------------------------
|
|
||||||
# Declare the function NAME in C.
|
|
||||||
m4_define([b4_function_define],
|
|
||||||
[$2
|
|
||||||
$1 (b4_formals(m4_shift2($@)))[]dnl
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_formals([DECL1, NAME1], ...)
|
|
||||||
# -------------------------------
|
## --------------------------------------------- ##
|
||||||
# The formal arguments of a C function definition.
|
## Defining C functions in both K&R and ANSI-C. ##
|
||||||
m4_define([b4_formals],
|
## --------------------------------------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_modern_c
|
||||||
|
# -----------
|
||||||
|
# A predicate useful in #if to determine whether C is ancient or modern.
|
||||||
|
#
|
||||||
|
# If __STDC__ is defined, the compiler is modern. IBM xlc 7.0 when run
|
||||||
|
# as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic
|
||||||
|
# reasons, but it defines __C99__FUNC__ so check that as well.
|
||||||
|
# Microsoft C normally doesn't define these macros, but it defines _MSC_VER.
|
||||||
|
# Consider a C++ compiler to be modern if it defines __cplusplus.
|
||||||
|
#
|
||||||
|
m4_define([b4_c_modern],
|
||||||
|
[[(defined __STDC__ || defined __C99__FUNC__ \
|
||||||
|
|| defined __cplusplus || defined _MSC_VER)]])
|
||||||
|
|
||||||
|
# b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# Declare the function NAME.
|
||||||
|
m4_define([b4_c_function_def],
|
||||||
|
[#if b4_c_modern
|
||||||
|
b4_c_ansi_function_def($@)
|
||||||
|
#else
|
||||||
|
$2
|
||||||
|
$1 (b4_c_knr_formal_names(m4_shift2($@)))
|
||||||
|
b4_c_knr_formal_decls(m4_shift2($@))
|
||||||
|
#endif[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_ansi_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# Declare the function NAME in ANSI.
|
||||||
|
m4_define([b4_c_ansi_function_def],
|
||||||
|
[$2
|
||||||
|
$1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_ansi_formals([DECL1, NAME1], ...)
|
||||||
|
# --------------------------------------
|
||||||
|
# Output the arguments ANSI-C definition.
|
||||||
|
m4_define([b4_c_ansi_formals],
|
||||||
[m4_if([$#], [0], [void],
|
[m4_if([$#], [0], [void],
|
||||||
[$#$1], [1], [void],
|
[$#$1], [1], [void],
|
||||||
[m4_map_sep([b4_formal], [, ], [$@])])])
|
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
|
||||||
|
|
||||||
m4_define([b4_formal],
|
m4_define([b4_c_ansi_formal],
|
||||||
[$1])
|
[$1])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_knr_formal_names([DECL1, NAME1], ...)
|
||||||
|
# ------------------------------------------
|
||||||
|
# Output the argument names.
|
||||||
|
m4_define([b4_c_knr_formal_names],
|
||||||
|
[m4_map_sep([b4_c_knr_formal_name], [, ], [$@])])
|
||||||
|
|
||||||
## ----------------------- ##
|
m4_define([b4_c_knr_formal_name],
|
||||||
## Declaring C functions. ##
|
[$2])
|
||||||
## ----------------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# b4_function_declare(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
# b4_c_knr_formal_decls([DECL1, NAME1], ...)
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------
|
||||||
# Declare the function NAME.
|
# Output the K&R argument declarations.
|
||||||
m4_define([b4_function_declare],
|
m4_define([b4_c_knr_formal_decls],
|
||||||
[$2 $1 (b4_formals(m4_shift2($@)));[]dnl
|
[m4_map_sep([b4_c_knr_formal_decl],
|
||||||
|
[
|
||||||
|
],
|
||||||
|
[$@])])
|
||||||
|
|
||||||
|
m4_define([b4_c_knr_formal_decl],
|
||||||
|
[ $1;])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------------------------------------------------ ##
|
||||||
|
## Declaring (prototyping) C functions in both K&R and ANSI-C. ##
|
||||||
|
## ------------------------------------------------------------ ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# Declare the function NAME ANSI C style.
|
||||||
|
m4_define([b4_c_ansi_function_decl],
|
||||||
|
[$2 $1 (b4_c_ansi_formals(m4_shift2($@)));[]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||||
|
# -----------------------------------------------------------
|
||||||
|
# Declare the function NAME in both K&R and ANSI C.
|
||||||
|
m4_define([b4_c_function_decl],
|
||||||
|
[#if defined __STDC__ || defined __cplusplus
|
||||||
|
b4_c_ansi_function_decl($@)
|
||||||
|
#else
|
||||||
|
$2 $1 ();
|
||||||
|
#endif[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
## Calling C functions. ##
|
## Calling C functions. ##
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
|
|
||||||
|
|
||||||
# b4_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
# b4_c_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||||
# -----------------------------------------------------------
|
# -----------------------------------------------------------
|
||||||
# Call the function NAME with arguments NAME1, NAME2 etc.
|
# Call the function NAME with arguments NAME1, NAME2 etc.
|
||||||
m4_define([b4_function_call],
|
m4_define([b4_c_function_call],
|
||||||
[$1 (b4_args(m4_shift2($@)))[]dnl
|
[$1 (b4_c_args(m4_shift2($@)))[]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_args([DECL1, NAME1], ...)
|
# b4_c_args([DECL1, NAME1], ...)
|
||||||
# ----------------------------
|
# ------------------------------
|
||||||
# Output the arguments NAME1, NAME2...
|
# Output the arguments NAME1, NAME2...
|
||||||
m4_define([b4_args],
|
m4_define([b4_c_args],
|
||||||
[m4_map_sep([b4_arg], [, ], [$@])])
|
[m4_map_sep([b4_c_arg], [, ], [$@])])
|
||||||
|
|
||||||
m4_define([b4_arg],
|
m4_define([b4_c_arg],
|
||||||
[$2])
|
[$2])
|
||||||
|
|
||||||
|
|
||||||
@@ -387,28 +438,53 @@ m4_define([b4_sync_start], [[#]line $1 $2])
|
|||||||
m4_define([b4_case],
|
m4_define([b4_case],
|
||||||
[ case $1:
|
[ case $1:
|
||||||
$2
|
$2
|
||||||
b4_syncline([@oline@], [@ofile@])
|
|
||||||
break;])
|
break;])
|
||||||
|
|
||||||
|
# _b4_symbol_actions(FILENAME, LINENO,
|
||||||
# b4_predicate_case(LABEL, CONDITIONS)
|
# SYMBOL-TAG, SYMBOL-NUM,
|
||||||
# ------------------------------------
|
# SYMBOL-ACTION, SYMBOL-TYPENAME)
|
||||||
m4_define([b4_predicate_case],
|
# --------------------------------------------------
|
||||||
[ case $1:
|
# Issue the code for a symbol action (e.g., %printer).
|
||||||
if (! ($2)) YYERROR;
|
#
|
||||||
|
# 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],
|
||||||
|
[b4_dollar_pushdef([(*yyvaluep)], [$6], [(*yylocationp)])dnl
|
||||||
|
case $4: /* $3 */
|
||||||
|
b4_syncline([$2], [$1])
|
||||||
|
$5;
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])
|
||||||
break;])
|
break;
|
||||||
|
b4_dollar_popdef[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4_symbol_actions(KIND)
|
||||||
|
# -----------------------
|
||||||
|
# Emit the symbol actions for KIND ("printers" or "destructors").
|
||||||
|
# Dispatch on "yytype".
|
||||||
|
m4_define([b4_symbol_actions],
|
||||||
|
[m4_ifval(m4_defn([b4_symbol_$1]),
|
||||||
|
[[switch (yytype)
|
||||||
|
{
|
||||||
|
]m4_map([_b4_symbol_actions], m4_defn([b4_symbol_$1]))[
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}]],
|
||||||
|
[YYUSE (yytype);])])
|
||||||
|
|
||||||
|
|
||||||
# b4_yydestruct_define
|
# b4_yydestruct_generate(FUNCTION-DECLARATOR)
|
||||||
# --------------------
|
# -------------------------------------------
|
||||||
# Define the "yydestruct" function.
|
# Generate the "yydestruct" function, which declaration is issued using
|
||||||
m4_define_default([b4_yydestruct_define],
|
# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
|
||||||
|
# or "b4_c_function_def" for K&R.
|
||||||
|
m4_define_default([b4_yydestruct_generate],
|
||||||
[[/*-----------------------------------------------.
|
[[/*-----------------------------------------------.
|
||||||
| Release the memory associated to this symbol. |
|
| Release the memory associated to this symbol. |
|
||||||
`-----------------------------------------------*/
|
`-----------------------------------------------*/
|
||||||
|
|
||||||
]b4_function_define([yydestruct],
|
/*ARGSUSED*/
|
||||||
|
]$1([yydestruct],
|
||||||
[static void],
|
[static void],
|
||||||
[[const char *yymsg], [yymsg]],
|
[[const char *yymsg], [yymsg]],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
@@ -416,31 +492,33 @@ m4_define_default([b4_yydestruct_define],
|
|||||||
b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
|
b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
|
||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||||
{
|
{
|
||||||
]b4_parse_param_use([yyvaluep], [yylocationp])dnl
|
YYUSE (yyvaluep);
|
||||||
[ if (!yymsg)
|
]b4_locations_if([ YYUSE (yylocationp);
|
||||||
|
])dnl
|
||||||
|
b4_parse_param_use[]dnl
|
||||||
|
[
|
||||||
|
if (!yymsg)
|
||||||
yymsg = "Deleting";
|
yymsg = "Deleting";
|
||||||
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
||||||
|
|
||||||
switch (yytype)
|
]b4_symbol_actions([destructors])[
|
||||||
{
|
|
||||||
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
|
||||||
[ default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}]dnl
|
}]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_yy_symbol_print_define
|
# b4_yy_symbol_print_generate(FUNCTION-DECLARATOR)
|
||||||
# -------------------------
|
# ------------------------------------------------
|
||||||
# Define the "yy_symbol_print" function.
|
# Generate the "yy_symbol_print" function, which declaration is issued using
|
||||||
m4_define_default([b4_yy_symbol_print_define],
|
# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
|
||||||
|
# or "b4_c_function_def" for K&R.
|
||||||
|
m4_define_default([b4_yy_symbol_print_generate],
|
||||||
[[
|
[[
|
||||||
/*--------------------------------.
|
/*--------------------------------.
|
||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
`--------------------------------*/
|
`--------------------------------*/
|
||||||
|
|
||||||
]b4_function_define([yy_symbol_value_print],
|
/*ARGSUSED*/
|
||||||
|
]$1([yy_symbol_value_print],
|
||||||
[static void],
|
[static void],
|
||||||
[[FILE *yyoutput], [yyoutput]],
|
[[FILE *yyoutput], [yyoutput]],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
@@ -449,22 +527,19 @@ b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
|||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||||
{
|
{
|
||||||
FILE *yyo = yyoutput;
|
FILE *yyo = yyoutput;
|
||||||
]b4_parse_param_use([yyo], [yylocationp])dnl
|
YYUSE (yyo);
|
||||||
[ if (!yyvaluep)
|
if (!yyvaluep)
|
||||||
return;]
|
return;
|
||||||
dnl glr.c does not feature yytoknum.
|
]b4_locations_if([ YYUSE (yylocationp);
|
||||||
m4_if(b4_skeleton, ["yacc.c"],
|
])dnl
|
||||||
[[# ifdef YYPRINT
|
b4_parse_param_use[]dnl
|
||||||
|
[# ifdef YYPRINT
|
||||||
if (yytype < YYNTOKENS)
|
if (yytype < YYNTOKENS)
|
||||||
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
|
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
|
||||||
|
# else
|
||||||
|
YYUSE (yyoutput);
|
||||||
# endif
|
# endif
|
||||||
]])dnl
|
]b4_symbol_actions([printers])[
|
||||||
[ switch (yytype)
|
|
||||||
{
|
|
||||||
]b4_symbol_foreach([b4_symbol_printer])dnl
|
|
||||||
[ default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -472,7 +547,7 @@ m4_if(b4_skeleton, ["yacc.c"],
|
|||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
`--------------------------------*/
|
`--------------------------------*/
|
||||||
|
|
||||||
]b4_function_define([yy_symbol_print],
|
]$1([yy_symbol_print],
|
||||||
[static void],
|
[static void],
|
||||||
[[FILE *yyoutput], [yyoutput]],
|
[[FILE *yyoutput], [yyoutput]],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
@@ -480,8 +555,10 @@ m4_if(b4_skeleton, ["yacc.c"],
|
|||||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||||
{
|
{
|
||||||
YYFPRINTF (yyoutput, "%s %s (",
|
if (yytype < YYNTOKENS)
|
||||||
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
|
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
|
||||||
|
else
|
||||||
|
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
|
||||||
|
|
||||||
]b4_locations_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);
|
]b4_locations_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);
|
||||||
YYFPRINTF (yyoutput, ": ");
|
YYFPRINTF (yyoutput, ": ");
|
||||||
@@ -496,65 +573,49 @@ b4_locations_if([, yylocationp])[]b4_user_args[);
|
|||||||
## Declarations. ##
|
## Declarations. ##
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
|
|
||||||
# b4_value_type_define
|
|
||||||
# --------------------
|
|
||||||
m4_define([b4_value_type_define],
|
|
||||||
[[/* Value type. */
|
|
||||||
#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
|
||||||
]m4_ifdef([b4_stype],
|
|
||||||
[[typedef union ]b4_union_name[ ]b4_api_PREFIX[STYPE;
|
|
||||||
union ]b4_union_name[
|
|
||||||
{
|
|
||||||
]b4_user_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_IS_DECLARED 1
|
|
||||||
#endif
|
|
||||||
]])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_location_type_define
|
|
||||||
# -----------------------
|
|
||||||
m4_define([b4_location_type_define],
|
|
||||||
[[/* Location type. */
|
|
||||||
#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
|
|
||||||
typedef struct ]b4_api_PREFIX[LTYPE ]b4_api_PREFIX[LTYPE;
|
|
||||||
struct ]b4_api_PREFIX[LTYPE
|
|
||||||
{
|
|
||||||
int first_line;
|
|
||||||
int first_column;
|
|
||||||
int last_line;
|
|
||||||
int last_column;
|
|
||||||
};
|
|
||||||
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
|
|
||||||
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
|
|
||||||
#endif
|
|
||||||
]])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_declare_yylstype
|
# b4_declare_yylstype
|
||||||
# -------------------
|
# -------------------
|
||||||
# Declarations that might either go into the header (if --defines) or
|
# Declarations that might either go into the header (if --defines) or
|
||||||
# in the parser body. Declare YYSTYPE/YYLTYPE, and yylval/yylloc.
|
# in the parser body. Declare YYSTYPE/YYLTYPE, and yylval/yylloc.
|
||||||
m4_define([b4_declare_yylstype],
|
m4_define([b4_declare_yylstype],
|
||||||
[b4_value_type_define[]b4_locations_if([
|
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
||||||
b4_location_type_define])
|
]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_pure_if([], [[extern ]b4_api_PREFIX[STYPE ]b4_prefix[lval;
|
||||||
]b4_locations_if([[extern ]b4_api_PREFIX[LTYPE ]b4_prefix[lloc;]])])[]dnl
|
]b4_locations_if([[extern ]b4_api_PREFIX[LTYPE ]b4_prefix[lloc;]])])[]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
# b4_YYDEBUG_define
|
# b4_YYDEBUG_define
|
||||||
# ------------------
|
# ------------------
|
||||||
m4_define([b4_YYDEBUG_define],
|
m4_define([b4_YYDEBUG_define],
|
||||||
[[/* Debug traces. */
|
[[/* Enabling traces. */
|
||||||
]m4_if(b4_api_prefix, [yy],
|
]m4_if(b4_api_prefix, [yy],
|
||||||
[[#ifndef YYDEBUG
|
[[#ifndef YYDEBUG
|
||||||
# define YYDEBUG ]b4_parse_trace_if([1], [0])[
|
# define YYDEBUG ]b4_debug_flag[
|
||||||
#endif]],
|
#endif]],
|
||||||
[[#ifndef ]b4_api_PREFIX[DEBUG
|
[[#ifndef ]b4_api_PREFIX[DEBUG
|
||||||
# if defined YYDEBUG
|
# if defined YYDEBUG
|
||||||
@@ -564,7 +625,7 @@ m4_define([b4_YYDEBUG_define],
|
|||||||
# define ]b4_api_PREFIX[DEBUG 0
|
# define ]b4_api_PREFIX[DEBUG 0
|
||||||
# endif
|
# endif
|
||||||
# else /* ! defined YYDEBUG */
|
# else /* ! defined YYDEBUG */
|
||||||
# define ]b4_api_PREFIX[DEBUG ]b4_parse_trace_if([1], [0])[
|
# define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[
|
||||||
# endif /* ! defined YYDEBUG */
|
# endif /* ! defined YYDEBUG */
|
||||||
#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
|
#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
|
||||||
])
|
])
|
||||||
@@ -589,7 +650,7 @@ m4_define([b4_yylloc_default_define],
|
|||||||
#ifndef YYLLOC_DEFAULT
|
#ifndef YYLLOC_DEFAULT
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
do \
|
do \
|
||||||
if (N) \
|
if (YYID (N)) \
|
||||||
{ \
|
{ \
|
||||||
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
||||||
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
||||||
@@ -603,7 +664,7 @@ m4_define([b4_yylloc_default_define],
|
|||||||
(Current).first_column = (Current).last_column = \
|
(Current).first_column = (Current).last_column = \
|
||||||
YYRHSLOC (Rhs, 0).last_column; \
|
YYRHSLOC (Rhs, 0).last_column; \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (YYID (0))
|
||||||
#endif
|
#endif
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -622,7 +683,7 @@ m4_define([b4_yy_location_print_define],
|
|||||||
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||||
|
|
||||||
__attribute__((__unused__))
|
__attribute__((__unused__))
|
||||||
]b4_function_define([yy_location_print_],
|
]b4_c_function_def([yy_location_print_],
|
||||||
[static unsigned],
|
[static unsigned],
|
||||||
[[FILE *yyo], [yyo]],
|
[[FILE *yyo], [yyo]],
|
||||||
[[YYLTYPE const * const yylocp], [yylocp]])[
|
[[YYLTYPE const * const yylocp], [yylocp]])[
|
||||||
@@ -631,20 +692,20 @@ __attribute__((__unused__))
|
|||||||
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
|
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
|
||||||
if (0 <= yylocp->first_line)
|
if (0 <= yylocp->first_line)
|
||||||
{
|
{
|
||||||
res += YYFPRINTF (yyo, "%d", yylocp->first_line);
|
res += fprintf (yyo, "%d", yylocp->first_line);
|
||||||
if (0 <= yylocp->first_column)
|
if (0 <= yylocp->first_column)
|
||||||
res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
|
res += fprintf (yyo, ".%d", yylocp->first_column);
|
||||||
}
|
}
|
||||||
if (0 <= yylocp->last_line)
|
if (0 <= yylocp->last_line)
|
||||||
{
|
{
|
||||||
if (yylocp->first_line < yylocp->last_line)
|
if (yylocp->first_line < yylocp->last_line)
|
||||||
{
|
{
|
||||||
res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
|
res += fprintf (yyo, "-%d", yylocp->last_line);
|
||||||
if (0 <= end_col)
|
if (0 <= end_col)
|
||||||
res += YYFPRINTF (yyo, ".%d", end_col);
|
res += fprintf (yyo, ".%d", end_col);
|
||||||
}
|
}
|
||||||
else if (0 <= end_col && yylocp->first_column < end_col)
|
else if (0 <= end_col && yylocp->first_column < end_col)
|
||||||
res += YYFPRINTF (yyo, "-%d", end_col);
|
res += fprintf (yyo, "-%d", end_col);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
+271
-279
File diff suppressed because it is too large
Load Diff
+105
-119
@@ -1,3 +1,5 @@
|
|||||||
|
-*- C -*-
|
||||||
|
|
||||||
# C++ GLR skeleton for Bison
|
# C++ GLR skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||||
@@ -27,7 +29,7 @@
|
|||||||
#
|
#
|
||||||
# The additional arguments are stored as members of the parser
|
# The additional arguments are stored as members of the parser
|
||||||
# object, yyparser. The C routines need to carry yyparser
|
# object, yyparser. The C routines need to carry yyparser
|
||||||
# throughout the C parser; that's easy: make yyparser an
|
# throughout the C parser; that easy: just let yyparser become an
|
||||||
# additional parse-param. But because the C++ skeleton needs to
|
# additional parse-param. But because the C++ skeleton needs to
|
||||||
# know the "real" original parse-param, we save them
|
# know the "real" original parse-param, we save them
|
||||||
# (b4_parse_param_orig). Note that b4_parse_param is overquoted
|
# (b4_parse_param_orig). Note that b4_parse_param is overquoted
|
||||||
@@ -37,23 +39,23 @@
|
|||||||
# The locations
|
# The locations
|
||||||
#
|
#
|
||||||
# We use location.cc just like lalr1.cc, but because glr.c stores
|
# We use location.cc just like lalr1.cc, but because glr.c stores
|
||||||
# the locations in a union, the position and location classes
|
# the locations in a (C++) union, the position and location classes
|
||||||
# must not have a constructor. Therefore, contrary to lalr1.cc, we
|
# must not have a constructor. Therefore, contrary to lalr1.cc, we
|
||||||
# must not define "b4_location_constructors". As a consequence the
|
# must not define "b4_location_constructors". As a consequence the
|
||||||
# user must initialize the first positions (in particular the
|
# user must initialize the first positions (in particular the
|
||||||
# filename member).
|
# filename member).
|
||||||
|
|
||||||
b4_token_ctor_if([b4_variant_if([],
|
# We require a pure interface using locations.
|
||||||
[b4_fatal_at(b4_percent_define_get_loc(api.token.constructor),
|
m4_define([b4_locations_flag], [1])
|
||||||
[cannot use '%s' without '%s'],
|
|
||||||
[%define api.token.constructor],
|
|
||||||
[%define api.value.type variant]))])])
|
|
||||||
|
|
||||||
# We require a pure interface.
|
|
||||||
m4_define([b4_pure_flag], [1])
|
m4_define([b4_pure_flag], [1])
|
||||||
|
|
||||||
|
# The header is mandatory.
|
||||||
|
b4_defines_if([],
|
||||||
|
[b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c++.m4])
|
m4_include(b4_pkgdatadir/[c++.m4])
|
||||||
b4_bison_locations_if([m4_include(b4_pkgdatadir/[location.cc])])
|
b4_percent_define_ifdef([[api.location.type]], [],
|
||||||
|
[m4_include(b4_pkgdatadir/[location.cc])])
|
||||||
|
|
||||||
m4_define([b4_parser_class_name],
|
m4_define([b4_parser_class_name],
|
||||||
[b4_percent_define_get([[parser_class_name]])])
|
[b4_percent_define_get([[parser_class_name]])])
|
||||||
@@ -61,37 +63,25 @@ m4_define([b4_parser_class_name],
|
|||||||
# Save the parse parameters.
|
# Save the parse parameters.
|
||||||
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
|
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
|
||||||
|
|
||||||
# b4_parse_param_wrap
|
|
||||||
# -------------------
|
|
||||||
# New ones.
|
|
||||||
m4_ifset([b4_parse_param],
|
|
||||||
[m4_define([b4_parse_param_wrap],
|
|
||||||
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],]
|
|
||||||
m4_defn([b4_parse_param]))],
|
|
||||||
[m4_define([b4_parse_param_wrap],
|
|
||||||
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]])
|
|
||||||
])
|
|
||||||
|
|
||||||
|
# b4_yy_symbol_print_generate
|
||||||
# b4_yy_symbol_print_define
|
# ---------------------------
|
||||||
# -------------------------
|
|
||||||
# Bypass the default implementation to generate the "yy_symbol_print"
|
# Bypass the default implementation to generate the "yy_symbol_print"
|
||||||
# and "yy_symbol_value_print" functions.
|
# and "yy_symbol_value_print" functions.
|
||||||
m4_define([b4_yy_symbol_print_define],
|
m4_define([b4_yy_symbol_print_generate],
|
||||||
[[
|
[[
|
||||||
/*--------------------.
|
/*--------------------.
|
||||||
| Print this symbol. |
|
| Print this symbol. |
|
||||||
`--------------------*/
|
`--------------------*/
|
||||||
|
|
||||||
]b4_function_define([yy_symbol_print],
|
]b4_c_ansi_function_def([yy_symbol_print],
|
||||||
[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]][]dnl
|
[yyvaluep]],
|
||||||
b4_locations_if([,
|
|
||||||
[[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)[
|
||||||
{
|
{
|
||||||
]b4_parse_param_use[]dnl
|
]b4_parse_param_use[]dnl
|
||||||
@@ -100,9 +90,10 @@ b4_locations_if([,
|
|||||||
]])[
|
]])[
|
||||||
|
|
||||||
# Hijack the initial action to initialize the locations.
|
# Hijack the initial action to initialize the locations.
|
||||||
]b4_bison_locations_if([m4_define([b4_initial_action],
|
]b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
|
||||||
|
[m4_define([b4_initial_action],
|
||||||
[yylloc.initialize ();]m4_ifdef([b4_initial_action], [
|
[yylloc.initialize ();]m4_ifdef([b4_initial_action], [
|
||||||
m4_defn([b4_initial_action])]))])[
|
m4_defn([b4_initial_action])]))])])[
|
||||||
|
|
||||||
# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT
|
# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT
|
||||||
# and declaration of yyerror.
|
# and declaration of yyerror.
|
||||||
@@ -110,60 +101,43 @@ m4_defn([b4_initial_action])]))])[
|
|||||||
[b4_syncline([@oline@], [@ofile@])[
|
[b4_syncline([@oline@], [@ofile@])[
|
||||||
]b4_yylloc_default_define[
|
]b4_yylloc_default_define[
|
||||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
|
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
|
||||||
]b4_function_declare([yyerror],
|
]b4_c_ansi_function_decl([yyerror],
|
||||||
[static void],b4_locations_if([
|
[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]])])
|
||||||
|
|
||||||
|
|
||||||
#undef yynerrs
|
|
||||||
#undef yychar
|
|
||||||
#undef yylval]b4_locations_if([
|
|
||||||
#undef yylloc])
|
|
||||||
|
|
||||||
m4_if(b4_prefix, [yy], [],
|
|
||||||
[[/* Substitute the variable and function names. */
|
|
||||||
#define yyparse ]b4_prefix[parse
|
|
||||||
#define yylex ]b4_prefix[lex
|
|
||||||
#define yyerror ]b4_prefix[error
|
|
||||||
#define yydebug ]b4_prefix[debug
|
|
||||||
]]b4_pure_if([], [[
|
|
||||||
#define yylval ]b4_prefix[lval
|
|
||||||
#define yychar ]b4_prefix[char
|
|
||||||
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
|
|
||||||
#define yylloc ]b4_prefix[lloc]])]))
|
|
||||||
|
|
||||||
# Hijack the epilogue to define implementations (yyerror, parser member
|
# Hijack the epilogue to define implementations (yyerror, parser member
|
||||||
# functions etc.).
|
# functions etc.).
|
||||||
m4_append([b4_epilogue],
|
m4_append([b4_epilogue],
|
||||||
[b4_syncline([@oline@], [@ofile@])[
|
[b4_syncline([@oline@], [@ofile@])[
|
||||||
|
|
||||||
/*------------------.
|
/*------------------.
|
||||||
| Report an error. |
|
| Report an error. |
|
||||||
`------------------*/
|
`------------------*/
|
||||||
|
|
||||||
]b4_function_define([yyerror],
|
]b4_c_ansi_function_def([yyerror],
|
||||||
[static void],b4_locations_if([
|
[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]])[
|
||||||
{
|
{
|
||||||
]b4_parse_param_use[]dnl
|
]b4_parse_param_use[]dnl
|
||||||
[ yyparser.error (]b4_locations_if([[*yylocationp, ]])[msg);
|
[ yyparser.error (*yylocationp, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
]b4_namespace_open[
|
]b4_namespace_open[
|
||||||
]dnl In this section, the parse params are the original parse_params.
|
]dnl In this section, the parse param are the original parse_params.
|
||||||
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
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 ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
]m4_ifset([b4_parse_param], [ ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
]m4_ifset([b4_parse_param], [ ], [ :])[
|
||||||
|
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
||||||
#endif]b4_parse_param_cons[
|
#endif]b4_parse_param_cons[
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -185,32 +159,27 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
|
|
||||||
inline void
|
inline void
|
||||||
]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
|
]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
|
||||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
const semantic_type* yyvaluep,
|
||||||
const location_type* yylocationp]])[)
|
const location_type* yylocationp)
|
||||||
{]b4_locations_if([[
|
{
|
||||||
YYUSE (yylocationp);]])[
|
YYUSE (yylocationp);
|
||||||
YYUSE (yyvaluep);
|
YYUSE (yyvaluep);
|
||||||
std::ostream& yyoutput = debug_stream ();
|
std::ostream& yyoutput = debug_stream ();
|
||||||
std::ostream& yyo = yyoutput;
|
std::ostream& yyo = yyoutput;
|
||||||
YYUSE (yyo);
|
YYUSE (yyo);
|
||||||
switch (yytype)
|
]b4_symbol_actions([printers])[
|
||||||
{
|
|
||||||
]b4_symbol_foreach([b4_symbol_printer])dnl
|
|
||||||
[ default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::yy_symbol_print_ (int yytype,
|
]b4_parser_class_name[::yy_symbol_print_ (int yytype,
|
||||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
const semantic_type* yyvaluep,
|
||||||
const location_type* yylocationp]])[)
|
const location_type* yylocationp)
|
||||||
{
|
{
|
||||||
*yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
|
*yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
|
||||||
<< ' ' << yytname[yytype] << " ("]b4_locations_if([[
|
<< ' ' << yytname[yytype] << " ("
|
||||||
<< *yylocationp << ": "]])[;
|
<< *yylocationp << ": ";
|
||||||
yy_symbol_value_print_ (yytype, yyvaluep]b4_locations_if([[, yylocationp]])[);
|
yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
|
||||||
*yycdebug_ << ')';
|
*yycdebug_ << ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,31 +214,63 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
b4_namespace_close
|
b4_namespace_close
|
||||||
])
|
])
|
||||||
|
|
||||||
# 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],
|
|
||||||
[m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|
||||||
b4_percent_code_get([[requires]])[
|
|
||||||
|
|
||||||
#include <stdexcept>
|
# Let glr.c believe that the user arguments include the parser itself.
|
||||||
|
m4_ifset([b4_parse_param],
|
||||||
|
[m4_pushdef([b4_parse_param],
|
||||||
|
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],]
|
||||||
|
m4_defn([b4_parse_param]))],
|
||||||
|
[m4_pushdef([b4_parse_param],
|
||||||
|
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]])
|
||||||
|
])
|
||||||
|
m4_include(b4_pkgdatadir/[glr.c])
|
||||||
|
m4_popdef([b4_parse_param])
|
||||||
|
|
||||||
|
b4_output_begin([b4_spec_defines_file])
|
||||||
|
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||||
|
[2002-2006, 2009-2013])[
|
||||||
|
|
||||||
|
/* C++ GLR parser skeleton written by Akim Demaille. */
|
||||||
|
|
||||||
|
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
|
|
||||||
|
]b4_percent_code_get([[requires]])[
|
||||||
|
|
||||||
# include <string>
|
# include <string>
|
||||||
#include <iostream>]b4_defines_if([
|
# include <iostream>
|
||||||
b4_bison_locations_if([[#include "location.hh"]])])[
|
]b4_percent_define_ifdef([[api.location.type]], [],
|
||||||
|
[[# include "location.hh"]])[
|
||||||
|
|
||||||
]b4_YYDEBUG_define[
|
]b4_YYDEBUG_define[
|
||||||
|
|
||||||
]b4_namespace_open[
|
]b4_namespace_open[
|
||||||
]b4_defines_if([],
|
|
||||||
[b4_bison_locations_if([b4_position_define
|
|
||||||
b4_location_define])])[
|
|
||||||
|
|
||||||
/// A Bison parser.
|
/// A Bison parser.
|
||||||
class ]b4_parser_class_name[
|
class ]b4_parser_class_name[
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
]b4_public_types_declare[
|
/// Symbol semantic values.
|
||||||
|
# ifndef ]b4_api_PREFIX[STYPE
|
||||||
|
]m4_ifdef([b4_stype],
|
||||||
|
[ union semantic_type
|
||||||
|
{
|
||||||
|
b4_user_stype
|
||||||
|
};],
|
||||||
|
[m4_if(b4_tag_seen_flag, 0,
|
||||||
|
[[ typedef int semantic_type;]],
|
||||||
|
[[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])[
|
||||||
|
# else
|
||||||
|
typedef ]b4_api_PREFIX[STYPE semantic_type;
|
||||||
|
# endif
|
||||||
|
/// Symbol locations.
|
||||||
|
typedef ]b4_percent_define_get([[api.location.type]],
|
||||||
|
[[location]])[ location_type;
|
||||||
|
/// Tokens.
|
||||||
|
struct token
|
||||||
|
{
|
||||||
|
]b4_token_enums(b4_tokens)[
|
||||||
|
};
|
||||||
|
/// Token type.
|
||||||
|
typedef token::yytokentype token_type;
|
||||||
|
|
||||||
/// Build a parser object.
|
/// Build a parser object.
|
||||||
]b4_parser_class_name[ (]b4_parse_param_decl[);
|
]b4_parser_class_name[ (]b4_parse_param_decl[);
|
||||||
@@ -291,30 +292,33 @@ b4_location_define])])[
|
|||||||
/// Set the current debugging level.
|
/// Set the current debugging level.
|
||||||
void set_debug_level (debug_level_type l);
|
void set_debug_level (debug_level_type l);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Report a syntax error.]b4_locations_if([[
|
/// Report a syntax error.
|
||||||
/// \param loc where the syntax error is found.]])[
|
/// \param loc where the syntax error is found.
|
||||||
/// \param msg a description of the syntax error.
|
/// \param msg a description of the syntax error.
|
||||||
virtual void error (]b4_locations_if([[const location_type& loc, ]])[const std::string& msg);
|
virtual void error (const location_type& loc, const std::string& msg);
|
||||||
|
private:
|
||||||
|
|
||||||
# if ]b4_api_PREFIX[DEBUG
|
# 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.
|
||||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
/// \param yyvaluep Its semantic value.
|
||||||
/// \param yylocationp Its location.]])[
|
/// \param yylocationp Its location.
|
||||||
virtual void yy_symbol_value_print_ (int yytype,
|
virtual void yy_symbol_value_print_ (int yytype,
|
||||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
const semantic_type* yyvaluep,
|
||||||
const location_type* yylocationp]])[);
|
const location_type* yylocationp);
|
||||||
/// \brief Report a symbol on the debug stream.
|
/// \brief Report a symbol on the debug stream.
|
||||||
/// \param yytype The token type.
|
/// \param yytype The token type.
|
||||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
/// \param yyvaluep Its semantic value.
|
||||||
/// \param yylocationp Its location.]])[
|
/// \param yylocationp Its location.
|
||||||
virtual void yy_symbol_print_ (int yytype,
|
virtual void yy_symbol_print_ (int yytype,
|
||||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
const semantic_type* yyvaluep,
|
||||||
const location_type* yylocationp]])[);
|
const location_type* yylocationp);
|
||||||
private:
|
private:
|
||||||
// Debugging.
|
/* Debugging. */
|
||||||
std::ostream* yycdebug_;
|
std::ostream* yycdebug_;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -323,7 +327,7 @@ b4_location_define])])[
|
|||||||
|
|
||||||
]dnl Redirections for glr.c.
|
]dnl Redirections for glr.c.
|
||||||
b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||||
[b4_token_defines])
|
[b4_token_defines(b4_tokens)])
|
||||||
[
|
[
|
||||||
#ifndef ]b4_api_PREFIX[STYPE
|
#ifndef ]b4_api_PREFIX[STYPE
|
||||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
|
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
|
||||||
@@ -334,23 +338,5 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
|||||||
|
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
]b4_percent_code_get([[provides]])[
|
]b4_percent_code_get([[provides]])[
|
||||||
]m4_popdef([b4_parse_param])dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
b4_defines_if(
|
|
||||||
[b4_output_begin([b4_spec_defines_file])
|
|
||||||
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
|
||||||
[2002-2013])[
|
|
||||||
|
|
||||||
// C++ GLR parser skeleton written by Akim Demaille.
|
|
||||||
|
|
||||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
|
||||||
]b4_shared_declarations[
|
|
||||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||||
]b4_output_end()])
|
]b4_output_end()
|
||||||
|
|
||||||
# Let glr.c (and b4_shared_declarations) believe that the user
|
|
||||||
# arguments include the parser itself.
|
|
||||||
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_wrap]))
|
|
||||||
m4_include(b4_pkgdatadir/[glr.c])
|
|
||||||
m4_popdef([b4_parse_param])
|
|
||||||
|
|||||||
+23
-45
@@ -19,9 +19,15 @@
|
|||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c-like.m4])
|
m4_include(b4_pkgdatadir/[c-like.m4])
|
||||||
|
|
||||||
|
# b4_comment(TEXT)
|
||||||
|
# ----------------
|
||||||
|
m4_define([b4_comment], [/* m4_bpatsubst([$1], [
|
||||||
|
], [
|
||||||
|
]) */])
|
||||||
|
|
||||||
|
|
||||||
# b4_list2(LIST1, LIST2)
|
# b4_list2(LIST1, LIST2)
|
||||||
# ----------------------
|
# --------------------------
|
||||||
# Join two lists with a comma if necessary.
|
# Join two lists with a comma if necessary.
|
||||||
m4_define([b4_list2],
|
m4_define([b4_list2],
|
||||||
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
||||||
@@ -112,45 +118,27 @@ m4_define([b4_int_type_for],
|
|||||||
m4_define([b4_null], [null])
|
m4_define([b4_null], [null])
|
||||||
|
|
||||||
|
|
||||||
# b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT)
|
|
||||||
# -------------------------------------------------------
|
|
||||||
m4_define([b4_typed_parser_table_define],
|
|
||||||
[m4_ifval([$4], [b4_comment([$4])
|
|
||||||
])dnl
|
|
||||||
[private static final ]$1[ yy$2_[] = yy$2_init();
|
|
||||||
private static final ]$1[[] yy$2_init()
|
|
||||||
{
|
|
||||||
return new ]$1[[]
|
|
||||||
{
|
|
||||||
]$3[
|
|
||||||
};
|
|
||||||
}]])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_integral_parser_table_define(NAME, DATA, COMMENT)
|
|
||||||
#-----------------------------------------------------
|
|
||||||
m4_define([b4_integral_parser_table_define],
|
|
||||||
[b4_typed_parser_table_define([b4_int_type_for([$2])], [$1], [$2], [$3])])
|
|
||||||
|
|
||||||
|
|
||||||
## ------------------------- ##
|
## ------------------------- ##
|
||||||
## Assigning token numbers. ##
|
## Assigning token numbers. ##
|
||||||
## ------------------------- ##
|
## ------------------------- ##
|
||||||
|
|
||||||
# b4_token_enum(TOKEN-NUM)
|
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||||
# ------------------------
|
# ---------------------------------------
|
||||||
# Output the definition of this token as an enum.
|
# Output the definition of this token as an enum.
|
||||||
m4_define([b4_token_enum],
|
m4_define([b4_token_enum],
|
||||||
[b4_token_format([ /** Token number, to be returned by the scanner. */
|
[ /** Token number, to be returned by the scanner. */
|
||||||
static final int %s = %s;
|
public static final int $1 = $2;
|
||||||
], [$1])])
|
])
|
||||||
|
|
||||||
# b4_token_enums
|
|
||||||
# --------------
|
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||||
|
# -----------------------------------------------------
|
||||||
# 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],
|
||||||
[b4_any_token_visible_if([/* Tokens. */
|
[m4_if([$#$1], [1], [],
|
||||||
b4_symbol_foreach([b4_token_enum])])])
|
[/* Tokens. */
|
||||||
|
m4_map([b4_token_enum], [$@])])
|
||||||
|
])
|
||||||
|
|
||||||
# b4-case(ID, CODE)
|
# b4-case(ID, CODE)
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -161,20 +149,13 @@ m4_define([b4_case], [ case $1:
|
|||||||
break;
|
break;
|
||||||
])
|
])
|
||||||
|
|
||||||
# b4_predicate_case(LABEL, CONDITIONS)
|
|
||||||
# ------------------------------------
|
|
||||||
m4_define([b4_predicate_case], [ case $1:
|
|
||||||
if (! ($2)) YYERROR;
|
|
||||||
break;
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Default values. ##
|
## Default values. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
|
m4_define([b4_yystype], [b4_percent_define_get([[stype]])])
|
||||||
b4_percent_define_default([[api.value.type]], [[Object]])
|
b4_percent_define_default([[stype]], [[Object]])
|
||||||
|
|
||||||
# %name-prefix
|
# %name-prefix
|
||||||
m4_define_default([b4_prefix], [[YY]])
|
m4_define_default([b4_prefix], [[YY]])
|
||||||
@@ -188,9 +169,6 @@ m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])])
|
|||||||
b4_percent_define_default([[throws]], [])
|
b4_percent_define_default([[throws]], [])
|
||||||
m4_define([b4_throws], [b4_percent_define_get([[throws]])])
|
m4_define([b4_throws], [b4_percent_define_get([[throws]])])
|
||||||
|
|
||||||
b4_percent_define_default([[init_throws]], [])
|
|
||||||
m4_define([b4_init_throws], [b4_percent_define_get([[init_throws]])])
|
|
||||||
|
|
||||||
b4_percent_define_default([[api.location.type]], [Location])
|
b4_percent_define_default([[api.location.type]], [Location])
|
||||||
m4_define([b4_location_type], [b4_percent_define_get([[api.location.type]])])
|
m4_define([b4_location_type], [b4_percent_define_get([[api.location.type]])])
|
||||||
|
|
||||||
@@ -246,7 +224,7 @@ m4_define([b4_lex_param], b4_lex_param)
|
|||||||
m4_define([b4_parse_param], b4_parse_param)
|
m4_define([b4_parse_param], b4_parse_param)
|
||||||
|
|
||||||
# b4_lex_param_decl
|
# b4_lex_param_decl
|
||||||
# -----------------
|
# -------------------
|
||||||
# Extra formal arguments of the constructor.
|
# Extra formal arguments of the constructor.
|
||||||
m4_define([b4_lex_param_decl],
|
m4_define([b4_lex_param_decl],
|
||||||
[m4_ifset([b4_lex_param],
|
[m4_ifset([b4_lex_param],
|
||||||
@@ -274,7 +252,7 @@ m4_define([b4_parse_param_decl],
|
|||||||
|
|
||||||
|
|
||||||
# b4_lex_param_call
|
# b4_lex_param_call
|
||||||
# -----------------
|
# -------------------
|
||||||
# Delegating the lexer parameters to the lexer constructor.
|
# Delegating the lexer parameters to the lexer constructor.
|
||||||
m4_define([b4_lex_param_call],
|
m4_define([b4_lex_param_call],
|
||||||
[m4_ifset([b4_lex_param],
|
[m4_ifset([b4_lex_param],
|
||||||
|
|||||||
+534
-562
File diff suppressed because it is too large
Load Diff
+142
-91
@@ -17,18 +17,10 @@
|
|||||||
|
|
||||||
m4_include(b4_pkgdatadir/[java.m4])
|
m4_include(b4_pkgdatadir/[java.m4])
|
||||||
|
|
||||||
b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java],
|
b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], [b4_skeleton])])
|
||||||
[b4_skeleton])])
|
m4_ifval(m4_defn([b4_symbol_destructors]),
|
||||||
|
[b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])],
|
||||||
# We don't depend on %debug in Java, but pacify warnings about non-used flags.
|
[])
|
||||||
b4_parse_trace_if([0], [0])
|
|
||||||
|
|
||||||
m4_define([b4_symbol_no_destructor_assert],
|
|
||||||
[b4_symbol_if([$1], [has_destructor],
|
|
||||||
[b4_fatal([%s: %s: %%destructor does not make sense in Java],
|
|
||||||
[b4_skeleton],
|
|
||||||
[b4_symbol_action_location([$1], [destructor])])])])
|
|
||||||
b4_symbol_foreach([b4_symbol_no_destructor_assert])
|
|
||||||
|
|
||||||
b4_output_begin([b4_parser_file_name])
|
b4_output_begin([b4_parser_file_name])
|
||||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
||||||
@@ -36,16 +28,14 @@ b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
|||||||
|
|
||||||
b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
|
b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
|
||||||
])[/* First part of user declarations. */
|
])[/* First part of user declarations. */
|
||||||
]b4_user_pre_prologue
|
]b4_pre_prologue
|
||||||
b4_user_post_prologue
|
|
||||||
b4_percent_code_get([[imports]])
|
b4_percent_code_get([[imports]])
|
||||||
[/**
|
[/**
|
||||||
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
|
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
|
||||||
*
|
*
|
||||||
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
|
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
|
||||||
*/
|
*/
|
||||||
]b4_percent_define_get3([annotations], [], [ ])dnl
|
]b4_public_if([public ])dnl
|
||||||
b4_public_if([public ])dnl
|
|
||||||
b4_abstract_if([abstract ])dnl
|
b4_abstract_if([abstract ])dnl
|
||||||
b4_final_if([final ])dnl
|
b4_final_if([final ])dnl
|
||||||
b4_strictfp_if([strictfp ])dnl
|
b4_strictfp_if([strictfp ])dnl
|
||||||
@@ -54,22 +44,9 @@ b4_percent_define_get3([extends], [ extends ])dnl
|
|||||||
b4_percent_define_get3([implements], [ implements ])[
|
b4_percent_define_get3([implements], [ implements ])[
|
||||||
{
|
{
|
||||||
]b4_identification[
|
]b4_identification[
|
||||||
]b4_error_verbose_if([[
|
|
||||||
/** True if verbose error messages are enabled. */
|
/** True if verbose error messages are enabled. */
|
||||||
private boolean yyErrorVerbose = true;
|
public boolean errorVerbose = ]b4_flag_value([error_verbose]);
|
||||||
|
|
||||||
/**
|
|
||||||
* Return whether verbose error messages are enabled.
|
|
||||||
*/
|
|
||||||
public final boolean getErrorVerbose() { return yyErrorVerbose; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the verbosity of error messages.
|
|
||||||
* @@param verbose True to request verbose error messages.
|
|
||||||
*/
|
|
||||||
public final void setErrorVerbose(boolean verbose)
|
|
||||||
{ yyErrorVerbose = verbose; }
|
|
||||||
]])
|
|
||||||
|
|
||||||
b4_locations_if([[
|
b4_locations_if([[
|
||||||
/**
|
/**
|
||||||
@@ -115,6 +92,11 @@ b4_locations_if([[
|
|||||||
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
[ /** Token returned by the scanner to signal the end of its input. */
|
||||||
|
public static final int EOF = 0;]
|
||||||
|
|
||||||
|
b4_token_enums(b4_tokens)
|
||||||
|
|
||||||
b4_locations_if([[
|
b4_locations_if([[
|
||||||
private ]b4_location_type[ yylloc (YYStack rhs, int n)
|
private ]b4_location_type[ yylloc (YYStack rhs, int n)
|
||||||
{
|
{
|
||||||
@@ -129,11 +111,6 @@ b4_locations_if([[
|
|||||||
* parser <tt>]b4_parser_class_name[</tt>.
|
* parser <tt>]b4_parser_class_name[</tt>.
|
||||||
*/
|
*/
|
||||||
public interface Lexer {
|
public interface Lexer {
|
||||||
/** Token returned by the scanner to signal the end of its input. */
|
|
||||||
public static final int EOF = 0;
|
|
||||||
|
|
||||||
]b4_token_enums[
|
|
||||||
|
|
||||||
]b4_locations_if([[/**
|
]b4_locations_if([[/**
|
||||||
* Method to retrieve the beginning position of the last scanned token.
|
* Method to retrieve the beginning position of the last scanned token.
|
||||||
* @@return the position at which the last scanned token starts. */
|
* @@return the position at which the last scanned token starts. */
|
||||||
@@ -162,8 +139,8 @@ b4_locations_if([[
|
|||||||
*
|
*
|
||||||
* ]b4_locations_if([[@@param loc The location of the element to which the
|
* ]b4_locations_if([[@@param loc The location of the element to which the
|
||||||
* error message is related]])[
|
* error message is related]])[
|
||||||
* @@param msg The string for the error message. */
|
* @@param s The string for the error message. */
|
||||||
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String msg);]
|
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s);]
|
||||||
}
|
}
|
||||||
|
|
||||||
b4_lexer_if([[private class YYLexer implements Lexer {
|
b4_lexer_if([[private class YYLexer implements Lexer {
|
||||||
@@ -179,9 +156,7 @@ b4_lexer_if([[
|
|||||||
/**
|
/**
|
||||||
* Instantiates the Bison-generated parser.
|
* Instantiates the Bison-generated parser.
|
||||||
*/
|
*/
|
||||||
public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) ]b4_maybe_throws([b4_init_throws])[
|
public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) {
|
||||||
{
|
|
||||||
]b4_percent_code_get([[init]])[
|
|
||||||
this.yylexer = new YYLexer(]b4_lex_param_call[);
|
this.yylexer = new YYLexer(]b4_lex_param_call[);
|
||||||
]b4_parse_param_cons[
|
]b4_parse_param_cons[
|
||||||
}
|
}
|
||||||
@@ -191,9 +166,7 @@ b4_lexer_if([[
|
|||||||
* Instantiates the Bison-generated parser.
|
* Instantiates the Bison-generated parser.
|
||||||
* @@param yylexer The scanner that will supply tokens to the parser.
|
* @@param yylexer The scanner that will supply tokens to the parser.
|
||||||
*/
|
*/
|
||||||
b4_lexer_if([[protected]], [[public]]) b4_parser_class_name[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
|
b4_lexer_if([[protected]], [[public]]) b4_parser_class_name[ (]b4_parse_param_decl([[Lexer yylexer]])[) {
|
||||||
{
|
|
||||||
]b4_percent_code_get([[init]])[
|
|
||||||
this.yylexer = yylexer;
|
this.yylexer = yylexer;
|
||||||
]b4_parse_param_cons[
|
]b4_parse_param_cons[
|
||||||
}
|
}
|
||||||
@@ -227,35 +200,20 @@ b4_lexer_if([[
|
|||||||
*/
|
*/
|
||||||
public final void setDebugLevel(int level) { yydebug = level; }
|
public final void setDebugLevel(int level) { yydebug = level; }
|
||||||
|
|
||||||
/**
|
private final int yylex () ]b4_maybe_throws([b4_lex_throws]) [{
|
||||||
* Print an error message via the lexer.
|
return yylexer.yylex ();
|
||||||
*]b4_locations_if([[ Use a <code>null</code> location.]])[
|
|
||||||
* @@param msg The error message.
|
|
||||||
*/
|
|
||||||
public final void yyerror (String msg)
|
|
||||||
{
|
|
||||||
yylexer.yyerror (]b4_locations_if([[(]b4_location_type[)null, ]])[msg);
|
|
||||||
}
|
}
|
||||||
]b4_locations_if([[
|
protected final void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s) {
|
||||||
/**
|
yylexer.yyerror (]b4_locations_if([loc, ])[s);
|
||||||
* Print an error message via the lexer.
|
|
||||||
* @@param loc The location associated with the message.
|
|
||||||
* @@param msg The error message.
|
|
||||||
*/
|
|
||||||
public final void yyerror (]b4_location_type[ loc, String msg)
|
|
||||||
{
|
|
||||||
yylexer.yyerror (loc, msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
]b4_locations_if([
|
||||||
* Print an error message via the lexer.
|
protected final void yyerror (String s) {
|
||||||
* @@param pos The position associated with the message.
|
yylexer.yyerror ((]b4_location_type[)null, s);
|
||||||
* @@param msg The error message.
|
}
|
||||||
*/
|
protected final void yyerror (]b4_position_type[ loc, String s) {
|
||||||
public final void yyerror (]b4_position_type[ pos, String msg)
|
yylexer.yyerror (new ]b4_location_type[ (loc), s);
|
||||||
{
|
}])
|
||||||
yylexer.yyerror (new ]b4_location_type[ (pos), msg);
|
|
||||||
}]])
|
|
||||||
|
|
||||||
[protected final void yycdebug (String s) {
|
[protected final void yycdebug (String s) {
|
||||||
if (yydebug > 0)
|
if (yydebug > 0)
|
||||||
@@ -411,7 +369,6 @@ b4_lexer_if([[
|
|||||||
return YYNEWSTATE;
|
return YYNEWSTATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_error_verbose_if([[
|
|
||||||
/* Return YYSTR after stripping away unnecessary quotes and
|
/* Return YYSTR after stripping away unnecessary quotes and
|
||||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||||
that double-quoting is unnecessary unless the string contains an
|
that double-quoting is unnecessary unless the string contains an
|
||||||
@@ -446,7 +403,6 @@ b4_lexer_if([[
|
|||||||
|
|
||||||
return yystr;
|
return yystr;
|
||||||
}
|
}
|
||||||
]])[
|
|
||||||
|
|
||||||
/*--------------------------------.
|
/*--------------------------------.
|
||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
@@ -536,7 +492,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
if (yychar == yyempty_)
|
if (yychar == yyempty_)
|
||||||
{
|
{
|
||||||
yycdebug ("Reading a token: ");
|
yycdebug ("Reading a token: ");
|
||||||
yychar = yylexer.yylex ();]
|
yychar = yylex ();]
|
||||||
b4_locations_if([[
|
b4_locations_if([[
|
||||||
yylloc = new ]b4_location_type[(yylexer.getStartPos (),
|
yylloc = new ]b4_location_type[(yylexer.getStartPos (),
|
||||||
yylexer.getEndPos ());]])
|
yylexer.getEndPos ());]])
|
||||||
@@ -544,9 +500,9 @@ b4_dollar_popdef])[]dnl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert token to internal form. */
|
/* Convert token to internal form. */
|
||||||
if (yychar <= Lexer.EOF)
|
if (yychar <= EOF)
|
||||||
{
|
{
|
||||||
yychar = yytoken = Lexer.EOF;
|
yychar = yytoken = EOF;
|
||||||
yycdebug ("Now at end of input.\n");
|
yycdebug ("Now at end of input.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -633,10 +589,10 @@ b4_dollar_popdef])[]dnl
|
|||||||
/* If just tried and failed to reuse lookahead token after an
|
/* If just tried and failed to reuse lookahead token after an
|
||||||
error, discard it. */
|
error, discard it. */
|
||||||
|
|
||||||
if (yychar <= Lexer.EOF)
|
if (yychar <= EOF)
|
||||||
{
|
{
|
||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
if (yychar == Lexer.EOF)
|
if (yychar == EOF)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -721,10 +677,15 @@ b4_dollar_popdef])[]dnl
|
|||||||
|
|
||||||
// Generate an error message.
|
// Generate an error message.
|
||||||
private String yysyntax_error (int yystate, int tok)
|
private String yysyntax_error (int yystate, int tok)
|
||||||
{]b4_error_verbose_if([[
|
{
|
||||||
if (yyErrorVerbose)
|
if (errorVerbose)
|
||||||
{
|
{
|
||||||
/* There are many possibilities here to consider:
|
/* There are many possibilities here to consider:
|
||||||
|
- Assume YYFAIL is not used. It's too flawed to consider.
|
||||||
|
See
|
||||||
|
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
|
||||||
|
for details. YYERROR is fine as it does not invoke this
|
||||||
|
function.
|
||||||
- If this state is a consistent state with a default action,
|
- If this state is a consistent state with a default action,
|
||||||
then the only way this function was invoked is if the
|
then the only way this function was invoked is if the
|
||||||
default action is an error action. In that case, don't
|
default action is an error action. In that case, don't
|
||||||
@@ -788,7 +749,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
return res.toString ();
|
return res.toString ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]])[
|
|
||||||
return "syntax error";
|
return "syntax error";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -810,20 +771,107 @@ b4_dollar_popdef])[]dnl
|
|||||||
return yyvalue == yytable_ninf_;
|
return yyvalue == yytable_ninf_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
||||||
|
STATE-NUM. */
|
||||||
private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
|
private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
|
||||||
private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
|
private static final ]b4_int_type_for([b4_pact])[ yypact_[] =
|
||||||
|
{
|
||||||
|
]b4_pact[
|
||||||
|
};
|
||||||
|
|
||||||
]b4_parser_tables_define[
|
/* YYDEFACT[S] -- default reduction number in state S. Performed when
|
||||||
]b4_integral_parser_table_define([token_number], [b4_toknum],
|
YYTABLE doesn't specify something else to do. Zero means the
|
||||||
[[YYTOKEN_NUMBER[YYLEX-NUM] -- Internal symbol number corresponding
|
default is an error. */
|
||||||
to YYLEX-NUM.]])[
|
private static final ]b4_int_type_for([b4_defact])[ yydefact_[] =
|
||||||
|
{
|
||||||
|
]b4_defact[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYPGOTO[NTERM-NUM]. */
|
||||||
|
private static final ]b4_int_type_for([b4_pgoto])[ yypgoto_[] =
|
||||||
|
{
|
||||||
|
]b4_pgoto[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYDEFGOTO[NTERM-NUM]. */
|
||||||
|
private static final ]b4_int_type_for([b4_defgoto])[
|
||||||
|
yydefgoto_[] =
|
||||||
|
{
|
||||||
|
]b4_defgoto[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
||||||
|
positive, shift that token. If negative, reduce the rule which
|
||||||
|
number is the opposite. If YYTABLE_NINF_, syntax error. */
|
||||||
|
private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
|
||||||
|
private static final ]b4_int_type_for([b4_table])[
|
||||||
|
yytable_[] =
|
||||||
|
{
|
||||||
|
]b4_table[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYCHECK. */
|
||||||
|
private static final ]b4_int_type_for([b4_check])[
|
||||||
|
yycheck_[] =
|
||||||
|
{
|
||||||
|
]b4_check[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* STOS_[STATE-NUM] -- The (internal number of the) accessing
|
||||||
|
symbol of state STATE-NUM. */
|
||||||
|
private static final ]b4_int_type_for([b4_stos])[
|
||||||
|
yystos_[] =
|
||||||
|
{
|
||||||
|
]b4_stos[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
||||||
|
to YYLEX-NUM. */
|
||||||
|
private static final ]b4_int_type_for([b4_toknum])[
|
||||||
|
yytoken_number_[] =
|
||||||
|
{
|
||||||
|
]b4_toknum[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
||||||
|
private static final ]b4_int_type_for([b4_r1])[
|
||||||
|
yyr1_[] =
|
||||||
|
{
|
||||||
|
]b4_r1[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
||||||
|
private static final ]b4_int_type_for([b4_r2])[
|
||||||
|
yyr2_[] =
|
||||||
|
{
|
||||||
|
]b4_r2[
|
||||||
|
};
|
||||||
|
|
||||||
/* 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. */
|
||||||
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
private static final String yytname_[] =
|
||||||
|
{
|
||||||
|
]b4_tname[
|
||||||
|
};
|
||||||
|
|
||||||
]b4_integral_parser_table_define([rline], [b4_rline],
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||||
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
private static final ]b4_int_type_for([b4_rhs])[ yyrhs_[] =
|
||||||
|
{
|
||||||
|
]b4_rhs[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
||||||
|
YYRHS. */
|
||||||
|
private static final ]b4_int_type_for([b4_prhs])[ yyprhs_[] =
|
||||||
|
{
|
||||||
|
]b4_prhs[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
||||||
|
private static final ]b4_int_type_for([b4_rline])[ yyrline_[] =
|
||||||
|
{
|
||||||
|
]b4_rline[
|
||||||
|
};
|
||||||
|
|
||||||
// Report on the debug stream that the rule yyrule is going to be reduced.
|
// Report on the debug stream that the rule yyrule is going to be reduced.
|
||||||
private void yy_reduce_print (int yyrule, YYStack yystack)
|
private void yy_reduce_print (int yyrule, YYStack yystack)
|
||||||
@@ -840,13 +888,16 @@ b4_dollar_popdef])[]dnl
|
|||||||
/* The symbols being reduced. */
|
/* The symbols being reduced. */
|
||||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||||
yy_symbol_print (" $" + (yyi + 1) + " =",
|
yy_symbol_print (" $" + (yyi + 1) + " =",
|
||||||
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
|
yyrhs_[yyprhs_[yyrule] + yyi],
|
||||||
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
|
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
|
||||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||||
]b4_integral_parser_table_define([translate_table], [b4_translate])[
|
private static final ]b4_int_type_for([b4_translate])[ yytranslate_table_[] =
|
||||||
|
{
|
||||||
|
]b4_translate[
|
||||||
|
};
|
||||||
|
|
||||||
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
|
||||||
{
|
{
|
||||||
@@ -872,5 +923,5 @@ b4_percent_code_get[]dnl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b4_epilogue[]dnl
|
b4_epilogue
|
||||||
b4_output_end()
|
b4_output_end()
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
## Copyright (C) 2002, 2005-2013 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/>.
|
|
||||||
|
|
||||||
dist_pkgdata_DATA = \
|
|
||||||
data/README \
|
|
||||||
data/bison.m4 \
|
|
||||||
data/c++-skel.m4 \
|
|
||||||
data/c++.m4 \
|
|
||||||
data/c-like.m4 \
|
|
||||||
data/c-skel.m4 \
|
|
||||||
data/c.m4 \
|
|
||||||
data/glr.c \
|
|
||||||
data/glr.cc \
|
|
||||||
data/java-skel.m4 \
|
|
||||||
data/java.m4 \
|
|
||||||
data/lalr1.cc \
|
|
||||||
data/lalr1.java \
|
|
||||||
data/location.cc \
|
|
||||||
data/stack.hh \
|
|
||||||
data/variant.hh \
|
|
||||||
data/yacc.c
|
|
||||||
|
|
||||||
m4sugardir = $(pkgdatadir)/m4sugar
|
|
||||||
dist_m4sugar_DATA = \
|
|
||||||
data/m4sugar/foreach.m4 \
|
|
||||||
data/m4sugar/m4sugar.m4
|
|
||||||
|
|
||||||
xsltdir = $(pkgdatadir)/xslt
|
|
||||||
dist_xslt_DATA = \
|
|
||||||
data/xslt/bison.xsl \
|
|
||||||
data/xslt/xml2dot.xsl \
|
|
||||||
data/xslt/xml2text.xsl \
|
|
||||||
data/xslt/xml2xhtml.xsl
|
|
||||||
+49
-66
@@ -1,6 +1,6 @@
|
|||||||
# C++ skeleton for Bison
|
# C++ skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
# Copyright (C) 2002-2007, 2009-2013 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
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -15,14 +15,26 @@
|
|||||||
# 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_pushdef([b4_copyright_years],
|
|
||||||
[2002-2013])
|
|
||||||
|
|
||||||
# b4_position_define
|
b4_output_begin([b4_dir_prefix[]position.hh])
|
||||||
# ------------------
|
b4_copyright([Positions for Bison parsers in C++],
|
||||||
# Define class position.
|
[2002-2007, 2009-2013])[
|
||||||
m4_define([b4_position_define],
|
|
||||||
[[ /// Abstract a position.
|
/**
|
||||||
|
** \file ]b4_dir_prefix[position.hh
|
||||||
|
** Define the ]b4_namespace_ref[::position class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
|
||||||
|
|
||||||
|
# include <algorithm> // std::max
|
||||||
|
# include <iostream>
|
||||||
|
# include <string>
|
||||||
|
|
||||||
|
]b4_null_define[
|
||||||
|
|
||||||
|
]b4_namespace_open[
|
||||||
|
/// Abstract a position.
|
||||||
class position
|
class position
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -132,13 +144,28 @@ m4_define([b4_position_define],
|
|||||||
ostr << *pos.filename << ':';
|
ostr << *pos.filename << ':';
|
||||||
return ostr << pos.line << '.' << pos.column;
|
return ostr << pos.line << '.' << pos.column;
|
||||||
}
|
}
|
||||||
]])
|
|
||||||
|
]b4_namespace_close[
|
||||||
|
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
|
||||||
|
b4_output_end()
|
||||||
|
|
||||||
|
|
||||||
# b4_location_define
|
b4_output_begin([b4_dir_prefix[]location.hh])
|
||||||
# ------------------
|
b4_copyright([Locations for Bison parsers in C++],
|
||||||
m4_define([b4_location_define],
|
[2002-2007, 2009-2013])[
|
||||||
[[ /// Abstract a location.
|
|
||||||
|
/**
|
||||||
|
** \file ]b4_dir_prefix[location.hh
|
||||||
|
** Define the ]b4_namespace_ref[::location class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[
|
||||||
|
|
||||||
|
# include "position.hh"
|
||||||
|
|
||||||
|
]b4_namespace_open[
|
||||||
|
|
||||||
|
/// Abstract a location.
|
||||||
class location
|
class location
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -253,64 +280,20 @@ m4_define([b4_location_define],
|
|||||||
inline std::basic_ostream<YYChar>&
|
inline std::basic_ostream<YYChar>&
|
||||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
||||||
{
|
{
|
||||||
unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
|
position last = loc.end - 1;
|
||||||
ostr << loc.begin// << "(" << loc.end << ") "
|
ostr << loc.begin;
|
||||||
;
|
if (last.filename
|
||||||
if (loc.end.filename
|
|
||||||
&& (!loc.begin.filename
|
&& (!loc.begin.filename
|
||||||
|| *loc.begin.filename != *loc.end.filename))
|
|| *loc.begin.filename != *last.filename))
|
||||||
ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
|
ostr << '-' << last;
|
||||||
else if (loc.begin.line < loc.end.line)
|
else if (loc.begin.line != last.line)
|
||||||
ostr << '-' << loc.end.line << '.' << end_col;
|
ostr << '-' << last.line << '.' << last.column;
|
||||||
else if (loc.begin.column < end_col)
|
else if (loc.begin.column != last.column)
|
||||||
ostr << '-' << end_col;
|
ostr << '-' << last.column;
|
||||||
return ostr;
|
return ostr;
|
||||||
}
|
}
|
||||||
]])
|
|
||||||
|
|
||||||
|
|
||||||
b4_defines_if([
|
|
||||||
b4_output_begin([b4_dir_prefix[]position.hh])
|
|
||||||
b4_copyright([Positions for Bison parsers in C++])[
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file ]b4_dir_prefix[position.hh
|
|
||||||
** Define the ]b4_namespace_ref[::position class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
|
|
||||||
|
|
||||||
# include <algorithm> // std::max
|
|
||||||
# include <iostream>
|
|
||||||
# include <string>
|
|
||||||
|
|
||||||
]b4_null_define[
|
|
||||||
|
|
||||||
]b4_namespace_open[
|
|
||||||
]b4_position_define[
|
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
|
|
||||||
b4_output_end()
|
|
||||||
|
|
||||||
|
|
||||||
b4_output_begin([b4_dir_prefix[]location.hh])
|
|
||||||
b4_copyright([Locations for Bison parsers in C++])[
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file ]b4_dir_prefix[location.hh
|
|
||||||
** Define the ]b4_namespace_ref[::location class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[
|
|
||||||
|
|
||||||
# include "position.hh"
|
|
||||||
|
|
||||||
]b4_namespace_open[
|
|
||||||
]b4_location_define[
|
|
||||||
]b4_namespace_close[
|
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
|
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
|
||||||
b4_output_end()
|
b4_output_end()
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
m4_popdef([b4_copyright_years])
|
|
||||||
|
|||||||
+34
-51
@@ -18,10 +18,21 @@
|
|||||||
m4_pushdef([b4_copyright_years],
|
m4_pushdef([b4_copyright_years],
|
||||||
[2002-2013])
|
[2002-2013])
|
||||||
|
|
||||||
# b4_stack_define
|
b4_output_begin([b4_dir_prefix[]stack.hh])
|
||||||
# ---------------
|
b4_copyright([Stack handling for Bison parsers in C++],
|
||||||
m4_define([b4_stack_define],
|
[2002-2013])[
|
||||||
[[ template <class T, class S = std::vector<T> >
|
|
||||||
|
/**
|
||||||
|
** \file ]b4_dir_prefix[stack.hh
|
||||||
|
** Define the ]b4_namespace_ref[::stack class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
|
||||||
|
|
||||||
|
# include <deque>
|
||||||
|
|
||||||
|
]b4_namespace_open[
|
||||||
|
template <class T, class S = std::deque<T> >
|
||||||
class stack
|
class stack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -29,13 +40,11 @@ m4_define([b4_stack_define],
|
|||||||
typedef typename S::reverse_iterator iterator;
|
typedef typename S::reverse_iterator iterator;
|
||||||
typedef typename S::const_reverse_iterator const_iterator;
|
typedef typename S::const_reverse_iterator const_iterator;
|
||||||
|
|
||||||
stack ()
|
stack () : seq_ ()
|
||||||
: seq_ ()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
stack (unsigned int n)
|
stack (unsigned int n) : seq_ (n)
|
||||||
: seq_ (n)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,25 +52,21 @@ m4_define([b4_stack_define],
|
|||||||
T&
|
T&
|
||||||
operator [] (unsigned int i)
|
operator [] (unsigned int i)
|
||||||
{
|
{
|
||||||
return seq_[seq_.size () - 1 - i];
|
return seq_[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
const T&
|
const T&
|
||||||
operator [] (unsigned int i) const
|
operator [] (unsigned int i) const
|
||||||
{
|
{
|
||||||
return seq_[seq_.size () - 1 - i];
|
return seq_[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Steal the contents of \a t.
|
|
||||||
///
|
|
||||||
/// Close to move-semantics.
|
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
push (T& t)
|
push (const T& t)
|
||||||
{
|
{
|
||||||
seq_.push_back (T());
|
seq_.push_front (t);
|
||||||
operator[](0).move (t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@@ -69,32 +74,28 @@ m4_define([b4_stack_define],
|
|||||||
pop (unsigned int n = 1)
|
pop (unsigned int n = 1)
|
||||||
{
|
{
|
||||||
for (; n; --n)
|
for (; n; --n)
|
||||||
seq_.pop_back ();
|
seq_.pop_front ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clear ()
|
||||||
|
{
|
||||||
|
seq_.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
typename S::size_type
|
unsigned int
|
||||||
size () const
|
height () const
|
||||||
{
|
{
|
||||||
return seq_.size ();
|
return seq_.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline const_iterator begin () const { return seq_.rbegin (); }
|
||||||
const_iterator
|
inline const_iterator end () const { return seq_.rend (); }
|
||||||
begin () const
|
|
||||||
{
|
|
||||||
return seq_.rbegin ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
const_iterator
|
|
||||||
end () const
|
|
||||||
{
|
|
||||||
return seq_.rend ();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// The wrapped container.
|
stack (const stack&);
|
||||||
|
stack& operator= (const stack&);
|
||||||
S seq_;
|
S seq_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,27 +121,9 @@ m4_define([b4_stack_define],
|
|||||||
const S& stack_;
|
const S& stack_;
|
||||||
unsigned int range_;
|
unsigned int range_;
|
||||||
};
|
};
|
||||||
]])
|
|
||||||
|
|
||||||
b4_defines_if(
|
|
||||||
[b4_output_begin([b4_dir_prefix[]stack.hh])
|
|
||||||
b4_copyright([Stack handling for Bison parsers in C++])[
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file ]b4_dir_prefix[stack.hh
|
|
||||||
** Define the ]b4_namespace_ref[::stack class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
|
|
||||||
|
|
||||||
# include <vector>
|
|
||||||
|
|
||||||
]b4_namespace_open[
|
|
||||||
]b4_stack_define[
|
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
|
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
|
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
|
||||||
b4_output_end()
|
b4_output_end()
|
||||||
])
|
|
||||||
|
|
||||||
m4_popdef([b4_copyright_years])
|
m4_popdef([b4_copyright_years])
|
||||||
|
|||||||
-345
@@ -1,345 +0,0 @@
|
|||||||
# C++ skeleton for Bison
|
|
||||||
|
|
||||||
# Copyright (C) 2002-2013 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/>.
|
|
||||||
|
|
||||||
|
|
||||||
## --------- ##
|
|
||||||
## variant. ##
|
|
||||||
## --------- ##
|
|
||||||
|
|
||||||
# b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS])
|
|
||||||
# ------------------------------------------------
|
|
||||||
# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
|
|
||||||
# YYTYPE.
|
|
||||||
m4_define([b4_symbol_variant],
|
|
||||||
[m4_pushdef([b4_dollar_dollar],
|
|
||||||
[$2.$3< $][3 >(m4_shift3($@))])dnl
|
|
||||||
switch ($1)
|
|
||||||
{
|
|
||||||
b4_type_foreach([b4_type_action_])[]dnl
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# _b4_char_sizeof_counter
|
|
||||||
# -----------------------
|
|
||||||
# A counter used by _b4_char_sizeof_dummy to create fresh symbols.
|
|
||||||
m4_define([_b4_char_sizeof_counter],
|
|
||||||
[0])
|
|
||||||
|
|
||||||
# _b4_char_sizeof_dummy
|
|
||||||
# ---------------------
|
|
||||||
# At each call return a new C++ identifier.
|
|
||||||
m4_define([_b4_char_sizeof_dummy],
|
|
||||||
[m4_define([_b4_char_sizeof_counter], m4_incr(_b4_char_sizeof_counter))dnl
|
|
||||||
dummy[]_b4_char_sizeof_counter])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_char_sizeof(SYMBOL-NUMS)
|
|
||||||
# ---------------------------
|
|
||||||
# To be mapped on the list of type names to produce:
|
|
||||||
#
|
|
||||||
# char dummy1[sizeof(type_name_1)];
|
|
||||||
# char dummy2[sizeof(type_name_2)];
|
|
||||||
#
|
|
||||||
# for defined type names.
|
|
||||||
m4_define([b4_char_sizeof],
|
|
||||||
[b4_symbol_if([$1], [has_type],
|
|
||||||
[
|
|
||||||
m4_map([ b4_symbol_tag_comment], [$@])dnl
|
|
||||||
char _b4_char_sizeof_dummy@{sizeof([b4_symbol([$1], [type])])@};
|
|
||||||
])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_variant_includes
|
|
||||||
# -------------------
|
|
||||||
# The needed includes for variants support.
|
|
||||||
m4_define([b4_variant_includes],
|
|
||||||
[b4_parse_assert_if([[#include <typeinfo>]])[
|
|
||||||
#ifndef YYASSERT
|
|
||||||
# include <cassert>
|
|
||||||
# define YYASSERT assert
|
|
||||||
#endif
|
|
||||||
]])
|
|
||||||
|
|
||||||
# b4_variant_define
|
|
||||||
# -----------------
|
|
||||||
# Define "variant".
|
|
||||||
m4_define([b4_variant_define],
|
|
||||||
[[ /// A char[S] buffer to store and retrieve objects.
|
|
||||||
///
|
|
||||||
/// Sort of a variant, but does not keep track of the nature
|
|
||||||
/// of the stored data, since that knowledge is available
|
|
||||||
/// via the current state.
|
|
||||||
template <size_t S>
|
|
||||||
struct variant
|
|
||||||
{
|
|
||||||
/// Type of *this.
|
|
||||||
typedef variant<S> self_type;
|
|
||||||
|
|
||||||
/// Empty construction.
|
|
||||||
variant ()]b4_parse_assert_if([
|
|
||||||
: tname (YY_NULL)])[
|
|
||||||
{}
|
|
||||||
|
|
||||||
/// Construct and fill.
|
|
||||||
template <typename T>
|
|
||||||
variant (const T& t)]b4_parse_assert_if([
|
|
||||||
: tname (typeid (T).name ())])[
|
|
||||||
{
|
|
||||||
YYASSERT (sizeof (T) <= S);
|
|
||||||
new (buffer.raw) T (t);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destruction, allowed only if empty.
|
|
||||||
~variant ()
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (!tname);
|
|
||||||
])[}
|
|
||||||
|
|
||||||
/// Instantiate an empty \a T in here.
|
|
||||||
template <typename T>
|
|
||||||
T&
|
|
||||||
build ()
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (!tname);
|
|
||||||
YYASSERT (sizeof (T) <= S);
|
|
||||||
tname = typeid (T).name ();])[
|
|
||||||
return *new (buffer.raw) T;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Instantiate a \a T in here from \a t.
|
|
||||||
template <typename T>
|
|
||||||
T&
|
|
||||||
build (const T& t)
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (!tname);
|
|
||||||
YYASSERT (sizeof (T) <= S);
|
|
||||||
tname = typeid (T).name ();])[
|
|
||||||
return *new (buffer.raw) T (t);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Accessor to a built \a T.
|
|
||||||
template <typename T>
|
|
||||||
T&
|
|
||||||
as ()
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (tname == typeid (T).name ());
|
|
||||||
YYASSERT (sizeof (T) <= S);])[
|
|
||||||
return reinterpret_cast<T&> (buffer.raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Const accessor to a built \a T (for %printer).
|
|
||||||
template <typename T>
|
|
||||||
const T&
|
|
||||||
as () const
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (tname == typeid (T).name ());
|
|
||||||
YYASSERT (sizeof (T) <= S);])[
|
|
||||||
return reinterpret_cast<const T&> (buffer.raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Swap the content with \a other, of same type.
|
|
||||||
///
|
|
||||||
/// Both variants must be built beforehand, because swapping the actual
|
|
||||||
/// data requires reading it (with as()), and this is not possible on
|
|
||||||
/// unconstructed variants: it would require some dynamic testing, which
|
|
||||||
/// should not be the variant's responsability.
|
|
||||||
/// Swapping between built and (possibly) non-built is done with
|
|
||||||
/// variant::move ().
|
|
||||||
template <typename T>
|
|
||||||
void
|
|
||||||
swap (self_type& other)
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (tname);
|
|
||||||
YYASSERT (tname == other.tname);])[
|
|
||||||
std::swap (as<T>(), other.as<T>());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Move the content of \a other to this.
|
|
||||||
///
|
|
||||||
/// Destroys \a other.
|
|
||||||
template <typename T>
|
|
||||||
void
|
|
||||||
move (self_type& other)
|
|
||||||
{]b4_parse_assert_if([
|
|
||||||
YYASSERT (!tname);])[
|
|
||||||
build<T>();
|
|
||||||
swap<T>(other);
|
|
||||||
other.destroy<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Copy the content of \a other to this.
|
|
||||||
template <typename T>
|
|
||||||
void
|
|
||||||
copy (const self_type& other)
|
|
||||||
{
|
|
||||||
build<T> (other.as<T> ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destroy the stored \a T.
|
|
||||||
template <typename T>
|
|
||||||
void
|
|
||||||
destroy ()
|
|
||||||
{
|
|
||||||
as<T> ().~T ();]b4_parse_assert_if([
|
|
||||||
tname = YY_NULL;])[
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Prohibit blind copies.
|
|
||||||
self_type& operator=(const self_type&);
|
|
||||||
variant (const self_type&);
|
|
||||||
|
|
||||||
/// A buffer large enough to store any of the semantic values.
|
|
||||||
/// Long double is chosen as it has the strongest alignment
|
|
||||||
/// constraints.
|
|
||||||
union
|
|
||||||
{
|
|
||||||
long double align_me;
|
|
||||||
char raw[S];
|
|
||||||
} buffer;]b4_parse_assert_if([
|
|
||||||
|
|
||||||
/// Whether the content is built: if defined, the name of the stored type.
|
|
||||||
const char* tname;])[
|
|
||||||
};
|
|
||||||
]])
|
|
||||||
|
|
||||||
|
|
||||||
## -------------------------- ##
|
|
||||||
## Adjustments for variants. ##
|
|
||||||
## -------------------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# b4_semantic_type_declare
|
|
||||||
# ------------------------
|
|
||||||
# Declare semantic_type.
|
|
||||||
m4_define([b4_semantic_type_declare],
|
|
||||||
[ /// An auxiliary type to compute the largest semantic type.
|
|
||||||
union union_type
|
|
||||||
{]b4_type_foreach([b4_char_sizeof])[};
|
|
||||||
|
|
||||||
/// Symbol semantic values.
|
|
||||||
typedef variant<sizeof(union_type)> semantic_type;dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# How the semantic value is extracted when using variants.
|
|
||||||
|
|
||||||
# b4_symbol_value(VAL, [TYPE])
|
|
||||||
# ----------------------------
|
|
||||||
m4_define([b4_symbol_value],
|
|
||||||
[m4_ifval([$2],
|
|
||||||
[$1.as< $2 >()],
|
|
||||||
[$1])])
|
|
||||||
|
|
||||||
# b4_symbol_value_template(VAL, [TYPE])
|
|
||||||
# -------------------------------------
|
|
||||||
# Same as b4_symbol_value, but used in a template method.
|
|
||||||
m4_define([b4_symbol_value_template],
|
|
||||||
[m4_ifval([$2],
|
|
||||||
[$1.template as< $2 >()],
|
|
||||||
[$1])])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ------------- ##
|
|
||||||
## make_SYMBOL. ##
|
|
||||||
## ------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_constructor_declare_(SYMBOL-NUMBER)
|
|
||||||
# ---------------------------------------------
|
|
||||||
# Declare the overloaded version of make_symbol for the (common) type of
|
|
||||||
# these SYMBOL-NUMBERS. Use at class-level.
|
|
||||||
m4_define([b4_symbol_constructor_declare_],
|
|
||||||
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
|
|
||||||
[ static inline
|
|
||||||
symbol_type
|
|
||||||
make_[]b4_symbol_([$1], [id]) (dnl
|
|
||||||
b4_join(b4_symbol_if([$1], [has_type],
|
|
||||||
[const b4_symbol([$1], [type])& v]),
|
|
||||||
b4_locations_if([const location_type& l])));
|
|
||||||
|
|
||||||
])])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_constructor_declare
|
|
||||||
# -----------------------------
|
|
||||||
# Declare symbol constructors for all the value types.
|
|
||||||
# Use at class-level.
|
|
||||||
m4_define([b4_symbol_constructor_declare],
|
|
||||||
[ // Symbol constructors declarations.
|
|
||||||
b4_symbol_foreach([b4_symbol_constructor_declare_])])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_constructor_define_(SYMBOL-NUMBER)
|
|
||||||
# --------------------------------------------
|
|
||||||
# Define symbol constructor for this SYMBOL-NUMBER.
|
|
||||||
m4_define([b4_symbol_constructor_define_],
|
|
||||||
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
|
|
||||||
[ b4_parser_class_name::symbol_type
|
|
||||||
b4_parser_class_name::make_[]b4_symbol_([$1], [id]) (dnl
|
|
||||||
b4_join(b4_symbol_if([$1], [has_type],
|
|
||||||
[const b4_symbol([$1], [type])& v]),
|
|
||||||
b4_locations_if([const location_type& l])))
|
|
||||||
{
|
|
||||||
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
|
||||||
b4_symbol_if([$1], [has_type], [v]),
|
|
||||||
b4_locations_if([l])));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
])])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_basic_symbol_constructor_declare
|
|
||||||
# ----------------------------------
|
|
||||||
# Generate a constructor declaration for basic_symbol from given type.
|
|
||||||
m4_define([b4_basic_symbol_constructor_declare],
|
|
||||||
[[
|
|
||||||
basic_symbol (]b4_join(
|
|
||||||
[typename Base::kind_type t],
|
|
||||||
b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[ v]),
|
|
||||||
b4_locations_if([const location_type& l]))[);
|
|
||||||
]])
|
|
||||||
|
|
||||||
# b4_basic_symbol_constructor_define
|
|
||||||
# ----------------------------------
|
|
||||||
# Generate a constructor implementation for basic_symbol from given type.
|
|
||||||
m4_define([b4_basic_symbol_constructor_define],
|
|
||||||
[[
|
|
||||||
template <typename Base>
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
|
||||||
[typename Base::kind_type t],
|
|
||||||
b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[ v]),
|
|
||||||
b4_locations_if([const location_type& l]))[)
|
|
||||||
: Base (t)
|
|
||||||
, value (]b4_symbol_if([$1], [has_type], [v])[)]b4_locations_if([
|
|
||||||
, location (l)])[
|
|
||||||
{}
|
|
||||||
]])
|
|
||||||
|
|
||||||
# b4_symbol_constructor_define
|
|
||||||
# ----------------------------
|
|
||||||
# Define the overloaded versions of make_symbol for all the value types.
|
|
||||||
m4_define([b4_symbol_constructor_define],
|
|
||||||
[ // Implementation of make_symbol for each symbol type.
|
|
||||||
b4_symbol_foreach([b4_symbol_constructor_define_])])
|
|
||||||
+205
-83
@@ -1,12 +1,10 @@
|
|||||||
-*- C -*-
|
-*- C -*-
|
||||||
|
|
||||||
# Yacc compatible skeleton for Bison
|
# Yacc compatible skeleton for Bison
|
||||||
|
|
||||||
# Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation,
|
# Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation,
|
||||||
# Inc.
|
# Inc.
|
||||||
|
|
||||||
m4_pushdef([b4_copyright_years],
|
|
||||||
[1984, 1989-1990, 2000-2013])
|
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
@@ -97,9 +95,18 @@ m4_define([b4_yyerror_arg_loc_if],
|
|||||||
# Arguments passed to yyerror: user args plus yylloc.
|
# Arguments passed to yyerror: user args plus yylloc.
|
||||||
m4_define([b4_yyerror_args],
|
m4_define([b4_yyerror_args],
|
||||||
[b4_yyerror_arg_loc_if([&yylloc, ])dnl
|
[b4_yyerror_arg_loc_if([&yylloc, ])dnl
|
||||||
m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
|
m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_lex_param
|
||||||
|
# ------------
|
||||||
|
# Accumulate in b4_lex_param all the yylex arguments.
|
||||||
|
# b4_lex_param arrives quoted twice, but we want to keep only one level.
|
||||||
|
m4_define([b4_lex_param],
|
||||||
|
m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl
|
||||||
|
b4_locations_if([, [[YYLTYPE *], [&yylloc]]])m4_ifdef([b4_lex_param], [, ])])dnl
|
||||||
|
m4_ifdef([b4_lex_param], b4_lex_param)))
|
||||||
|
|
||||||
|
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
## Data Types. ##
|
## Data Types. ##
|
||||||
@@ -132,7 +139,7 @@ m4_define([b4_int_type],
|
|||||||
# --------------------
|
# --------------------
|
||||||
# Expansion of $<TYPE>$.
|
# Expansion of $<TYPE>$.
|
||||||
m4_define([b4_lhs_value],
|
m4_define([b4_lhs_value],
|
||||||
[b4_symbol_value(yyval, [$1])])
|
[(yyval[]m4_ifval([$1], [.$1]))])
|
||||||
|
|
||||||
|
|
||||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
||||||
@@ -140,7 +147,7 @@ m4_define([b4_lhs_value],
|
|||||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||||
# symbols on RHS.
|
# symbols on RHS.
|
||||||
m4_define([b4_rhs_value],
|
m4_define([b4_rhs_value],
|
||||||
[b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3])])
|
[(yyvsp@{($2) - ($1)@}m4_ifval([$3], [.$3]))])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -160,7 +167,7 @@ m4_define([b4_lhs_location],
|
|||||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
||||||
# on RHS.
|
# on RHS.
|
||||||
m4_define([b4_rhs_location],
|
m4_define([b4_rhs_location],
|
||||||
[(yylsp@{b4_subtract([$2], [$1])@})])
|
[(yylsp@{($2) - ($1)@})])
|
||||||
|
|
||||||
|
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
@@ -267,19 +274,19 @@ enum { YYPUSH_MORE = 4 };
|
|||||||
|
|
||||||
typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
|
typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
|
||||||
|
|
||||||
]b4_pull_if([b4_function_declare([b4_prefix[parse]], [[int]], b4_parse_param)
|
]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
|
||||||
])b4_function_declare([b4_prefix[push_parse]], [[int]],
|
])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
|
||||||
[[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([,
|
[[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([,
|
||||||
[[[int pushed_char]], [[pushed_char]]],
|
[[[int pushed_char]], [[pushed_char]]],
|
||||||
[[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([,
|
[[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([,
|
||||||
[[b4_api_PREFIX[LTYPE *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [,
|
[[b4_api_PREFIX[LTYPE *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [,
|
||||||
b4_parse_param]))
|
b4_parse_param]))
|
||||||
b4_pull_if([b4_function_declare([b4_prefix[pull_parse]], [[int]],
|
b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
|
||||||
[[b4_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [,
|
[[b4_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [,
|
||||||
b4_parse_param]))])
|
b4_parse_param]))])
|
||||||
b4_function_declare([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
|
b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
|
||||||
[[[void]], []])
|
[[[void]], []])
|
||||||
b4_function_declare([b4_prefix[pstate_delete]], [[void]],
|
b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
|
||||||
[[b4_prefix[pstate *ps]], [[ps]]])dnl
|
[[b4_prefix[pstate *ps]], [[ps]]])dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -287,7 +294,13 @@ b4_function_declare([b4_prefix[pstate_delete]], [[void]],
|
|||||||
# -------------------
|
# -------------------
|
||||||
# When not the push parser.
|
# When not the push parser.
|
||||||
m4_define([b4_declare_yyparse_],
|
m4_define([b4_declare_yyparse_],
|
||||||
[b4_function_declare(b4_prefix[parse], [int], b4_parse_param)])
|
[[#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
|
# b4_declare_yyparse
|
||||||
@@ -306,19 +319,21 @@ m4_define([b4_shared_declarations],
|
|||||||
[b4_cpp_guard_open([b4_spec_defines_file])[
|
[b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
]b4_declare_yydebug[
|
]b4_declare_yydebug[
|
||||||
]b4_percent_code_get([[requires]])[
|
]b4_percent_code_get([[requires]])[
|
||||||
]b4_token_enums_defines[
|
]b4_token_enums_defines(b4_tokens)[
|
||||||
]b4_declare_yylstype[
|
]b4_declare_yylstype[
|
||||||
]b4_declare_yyparse[
|
]b4_declare_yyparse[
|
||||||
]b4_percent_code_get([[provides]])[
|
]b4_percent_code_get([[provides]])[
|
||||||
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
|
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
## Output files. ##
|
## Output files. ##
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
|
|
||||||
b4_output_begin([b4_parser_file_name])
|
b4_output_begin([b4_parser_file_name])
|
||||||
b4_copyright([Bison implementation for Yacc-like parsers in C])[
|
b4_copyright([Bison implementation for Yacc-like parsers in C],
|
||||||
|
[1984, 1989-1990, 2000-2013])[
|
||||||
|
|
||||||
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
||||||
simplifying the original so-called "semantic" parser. */
|
simplifying the original so-called "semantic" parser. */
|
||||||
@@ -346,12 +361,11 @@ m4_if(b4_api_prefix, [yy], [],
|
|||||||
#define yypstate ]b4_prefix[pstate]])[
|
#define yypstate ]b4_prefix[pstate]])[
|
||||||
#define yylex ]b4_prefix[lex
|
#define yylex ]b4_prefix[lex
|
||||||
#define yyerror ]b4_prefix[error
|
#define yyerror ]b4_prefix[error
|
||||||
#define yydebug ]b4_prefix[debug
|
|
||||||
#define yynerrs ]b4_prefix[nerrs
|
|
||||||
]]b4_pure_if([], [[
|
|
||||||
#define yylval ]b4_prefix[lval
|
#define yylval ]b4_prefix[lval
|
||||||
#define yychar ]b4_prefix[char]b4_locations_if([[
|
#define yychar ]b4_prefix[char
|
||||||
#define yylloc ]b4_prefix[lloc]])]))[
|
#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[
|
||||||
@@ -363,7 +377,7 @@ m4_if(b4_api_prefix, [yy], [],
|
|||||||
# undef YYERROR_VERBOSE
|
# undef YYERROR_VERBOSE
|
||||||
# define YYERROR_VERBOSE 1
|
# define YYERROR_VERBOSE 1
|
||||||
#else
|
#else
|
||||||
# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
|
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]m4_ifval(m4_quote(b4_spec_defines_file),
|
]m4_ifval(m4_quote(b4_spec_defines_file),
|
||||||
@@ -388,8 +402,10 @@ typedef unsigned char yytype_uint8;
|
|||||||
|
|
||||||
#ifdef YYTYPE_INT8
|
#ifdef YYTYPE_INT8
|
||||||
typedef YYTYPE_INT8 yytype_int8;
|
typedef YYTYPE_INT8 yytype_int8;
|
||||||
#else
|
#elif ]b4_c_modern[
|
||||||
typedef signed char yytype_int8;
|
typedef signed char yytype_int8;
|
||||||
|
#else
|
||||||
|
typedef short int yytype_int8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef YYTYPE_UINT16
|
#ifdef YYTYPE_UINT16
|
||||||
@@ -409,7 +425,7 @@ typedef short int yytype_int16;
|
|||||||
# define YYSIZE_T __SIZE_TYPE__
|
# define YYSIZE_T __SIZE_TYPE__
|
||||||
# elif defined size_t
|
# elif defined size_t
|
||||||
# define YYSIZE_T size_t
|
# define YYSIZE_T size_t
|
||||||
# elif ! defined YYSIZE_T
|
# elif ! defined YYSIZE_T && ]b4_c_modern[
|
||||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
# define YYSIZE_T size_t
|
# define YYSIZE_T size_t
|
||||||
# else
|
# else
|
||||||
@@ -431,11 +447,16 @@ typedef short int yytype_int16;
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Suppress unused-variable warnings by "using" E. */
|
]b4_attribute_define[
|
||||||
#ifdef __GNUC__
|
|
||||||
# define YYUSE(E) ((void) (E))
|
/* Identity function, used to suppress warnings about constant conditions. */
|
||||||
|
#ifndef lint
|
||||||
|
# define YYID(N) (N)
|
||||||
#else
|
#else
|
||||||
# define YYUSE(E) /* empty */
|
]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[
|
||||||
|
{
|
||||||
|
return yyi;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[
|
#if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[
|
||||||
@@ -456,7 +477,7 @@ b4_push_if([], [b4_lac_if([], [[
|
|||||||
# define alloca _alloca
|
# define alloca _alloca
|
||||||
# else
|
# else
|
||||||
# define YYSTACK_ALLOC alloca
|
# define YYSTACK_ALLOC alloca
|
||||||
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
|
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && ]b4_c_modern[
|
||||||
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
|
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
|
||||||
# ifndef EXIT_SUCCESS
|
# ifndef EXIT_SUCCESS
|
||||||
@@ -469,7 +490,7 @@ b4_push_if([], [b4_lac_if([], [[
|
|||||||
|
|
||||||
# ifdef YYSTACK_ALLOC
|
# ifdef YYSTACK_ALLOC
|
||||||
/* Pacify GCC's `empty if-body' warning. */
|
/* Pacify GCC's `empty if-body' warning. */
|
||||||
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
|
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
|
||||||
# ifndef YYSTACK_ALLOC_MAXIMUM
|
# ifndef YYSTACK_ALLOC_MAXIMUM
|
||||||
/* The OS might guarantee only one guard page at the bottom of the stack,
|
/* The OS might guarantee only one guard page at the bottom of the stack,
|
||||||
and a page size can be as small as 4096 bytes. So we cannot safely
|
and a page size can be as small as 4096 bytes. So we cannot safely
|
||||||
@@ -493,13 +514,13 @@ b4_push_if([], [b4_lac_if([], [[
|
|||||||
# endif
|
# endif
|
||||||
# ifndef YYMALLOC
|
# ifndef YYMALLOC
|
||||||
# define YYMALLOC malloc
|
# define YYMALLOC malloc
|
||||||
# if ! defined malloc && ! defined EXIT_SUCCESS
|
# if ! defined malloc && ! defined EXIT_SUCCESS && ]b4_c_modern[
|
||||||
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
|
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# ifndef YYFREE
|
# ifndef YYFREE
|
||||||
# define YYFREE free
|
# define YYFREE free
|
||||||
# if ! defined free && ! defined EXIT_SUCCESS
|
# if ! defined free && ! defined EXIT_SUCCESS && ]b4_c_modern[
|
||||||
void free (void *); /* INFRINGES ON USER NAME SPACE */
|
void free (void *); /* INFRINGES ON USER NAME SPACE */
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
@@ -550,7 +571,7 @@ union yyalloc
|
|||||||
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
||||||
yyptr += yynewbytes / sizeof (*yyptr); \
|
yyptr += yynewbytes / sizeof (*yyptr); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (YYID (0))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -569,7 +590,7 @@ union yyalloc
|
|||||||
for (yyi = 0; yyi < (Count); yyi++) \
|
for (yyi = 0; yyi < (Count); yyi++) \
|
||||||
(Dst)[yyi] = (Src)[yyi]; \
|
(Dst)[yyi] = (Src)[yyi]; \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (YYID (0))
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif /* !YYCOPY_NEEDED */
|
#endif /* !YYCOPY_NEEDED */
|
||||||
@@ -585,27 +606,41 @@ union yyalloc
|
|||||||
#define YYNNTS ]b4_nterms_number[
|
#define YYNNTS ]b4_nterms_number[
|
||||||
/* YYNRULES -- Number of rules. */
|
/* YYNRULES -- Number of rules. */
|
||||||
#define YYNRULES ]b4_rules_number[
|
#define YYNRULES ]b4_rules_number[
|
||||||
/* YYNSTATES -- Number of states. */
|
/* YYNRULES -- Number of states. */
|
||||||
#define YYNSTATES ]b4_states_number[
|
#define YYNSTATES ]b4_states_number[
|
||||||
|
|
||||||
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||||
by yylex, with out-of-bounds checking. */
|
|
||||||
#define YYUNDEFTOK ]b4_undef_token_number[
|
#define YYUNDEFTOK ]b4_undef_token_number[
|
||||||
#define YYMAXUTOK ]b4_user_token_number_max[
|
#define YYMAXUTOK ]b4_user_token_number_max[
|
||||||
|
|
||||||
#define YYTRANSLATE(YYX) \
|
#define YYTRANSLATE(YYX) \
|
||||||
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||||
|
|
||||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
|
||||||
as returned by yylex, without out-of-bounds checking. */
|
|
||||||
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
||||||
{
|
{
|
||||||
]b4_translate[
|
]b4_translate[
|
||||||
};
|
};
|
||||||
|
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
]b4_integral_parser_table_define([rline], [b4_rline],
|
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
||||||
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
YYRHS. */
|
||||||
|
static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
|
||||||
|
{
|
||||||
|
]b4_prhs[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||||
|
static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
|
||||||
|
{
|
||||||
|
]b4_rhs[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||||
|
static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
||||||
|
{
|
||||||
|
]b4_rline[
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
|
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
|
||||||
@@ -618,25 +653,80 @@ static const char *const yytname[] =
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
# ifdef YYPRINT
|
# ifdef YYPRINT
|
||||||
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
|
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
|
||||||
(internal) symbol number NUM (which must be that of a token). */
|
token YYLEX-NUM. */
|
||||||
static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
|
static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
|
||||||
{
|
{
|
||||||
]b4_toknum[
|
]b4_toknum[
|
||||||
};
|
};
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
||||||
|
static const ]b4_int_type_for([b4_r1])[ yyr1[] =
|
||||||
|
{
|
||||||
|
]b4_r1[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
||||||
|
static const ]b4_int_type_for([b4_r2])[ yyr2[] =
|
||||||
|
{
|
||||||
|
]b4_r2[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
|
||||||
|
Performed when YYTABLE doesn't specify something else to do. Zero
|
||||||
|
means the default is an error. */
|
||||||
|
static const ]b4_int_type_for([b4_defact])[ yydefact[] =
|
||||||
|
{
|
||||||
|
]b4_defact[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYDEFGOTO[NTERM-NUM]. */
|
||||||
|
static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
|
||||||
|
{
|
||||||
|
]b4_defgoto[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
||||||
|
STATE-NUM. */
|
||||||
#define YYPACT_NINF ]b4_pact_ninf[
|
#define YYPACT_NINF ]b4_pact_ninf[
|
||||||
|
static const ]b4_int_type_for([b4_pact])[ yypact[] =
|
||||||
|
{
|
||||||
|
]b4_pact[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYPGOTO[NTERM-NUM]. */
|
||||||
|
static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
|
||||||
|
{
|
||||||
|
]b4_pgoto[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
||||||
|
positive, shift that token. If negative, reduce the rule which
|
||||||
|
number is the opposite. If YYTABLE_NINF, syntax error. */
|
||||||
|
#define YYTABLE_NINF ]b4_table_ninf[
|
||||||
|
static const ]b4_int_type_for([b4_table])[ yytable[] =
|
||||||
|
{
|
||||||
|
]b4_table[
|
||||||
|
};
|
||||||
|
|
||||||
#define yypact_value_is_default(Yystate) \
|
#define yypact_value_is_default(Yystate) \
|
||||||
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
|
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
|
||||||
|
|
||||||
#define YYTABLE_NINF ]b4_table_ninf[
|
|
||||||
|
|
||||||
#define yytable_value_is_error(Yytable_value) \
|
#define yytable_value_is_error(Yytable_value) \
|
||||||
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
|
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
|
||||||
|
|
||||||
]b4_parser_tables_define[
|
static const ]b4_int_type_for([b4_check])[ yycheck[] =
|
||||||
|
{
|
||||||
|
]b4_check[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
||||||
|
symbol of state STATE-NUM. */
|
||||||
|
static const ]b4_int_type_for([b4_stos])[ yystos[] =
|
||||||
|
{
|
||||||
|
]b4_stos[
|
||||||
|
};
|
||||||
|
|
||||||
#define yyerrok (yyerrstatus = 0)
|
#define yyerrok (yyerrstatus = 0)
|
||||||
#define yyclearin (yychar = YYEMPTY)
|
#define yyclearin (yychar = YYEMPTY)
|
||||||
@@ -648,6 +738,21 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
|
|||||||
#define YYERROR goto yyerrorlab
|
#define YYERROR goto yyerrorlab
|
||||||
|
|
||||||
|
|
||||||
|
/* Like YYERROR except do call yyerror. This remains here temporarily
|
||||||
|
to ease the transition to the new meaning of YYERROR, for GCC.
|
||||||
|
Once GCC version 2 has supplanted version 1, this can go. However,
|
||||||
|
YYFAIL appears to be in use. Nevertheless, it is formally deprecated
|
||||||
|
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
|
||||||
|
discussed. */
|
||||||
|
|
||||||
|
#define YYFAIL goto yyerrlab
|
||||||
|
#if defined YYFAIL
|
||||||
|
/* This is here to suppress warnings from the GCC cpp's
|
||||||
|
-Wunused-macros. Normally we don't worry about that warning, but
|
||||||
|
some users do, and we want to make it easy for users to remove
|
||||||
|
YYFAIL uses, which will produce warnings from Bison 2.5. */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define YYRECOVERING() (!!yyerrstatus)
|
#define YYRECOVERING() (!!yyerrstatus)
|
||||||
|
|
||||||
#define YYBACKUP(Token, Value) \
|
#define YYBACKUP(Token, Value) \
|
||||||
@@ -666,7 +771,7 @@ do \
|
|||||||
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
|
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
|
||||||
YYERROR; \
|
YYERROR; \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (YYID (0))
|
||||||
|
|
||||||
/* Error token number */
|
/* Error token number */
|
||||||
#define YYTERROR 1
|
#define YYTERROR 1
|
||||||
@@ -676,6 +781,14 @@ while (0)
|
|||||||
]b4_yylloc_default_define[
|
]b4_yylloc_default_define[
|
||||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
||||||
]])[
|
]])[
|
||||||
|
]b4_yy_location_print_define[
|
||||||
|
|
||||||
|
/* YYLEX -- calling `yylex' with the right arguments. */
|
||||||
|
#ifdef YYLEX_PARAM
|
||||||
|
# define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM)
|
||||||
|
#else
|
||||||
|
# define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Enable debugging if requested. */
|
/* Enable debugging if requested. */
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
@@ -689,9 +802,7 @@ while (0)
|
|||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
YYFPRINTF Args; \
|
YYFPRINTF Args; \
|
||||||
} while (0)
|
} while (YYID (0))
|
||||||
|
|
||||||
]b4_yy_location_print_define[
|
|
||||||
|
|
||||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||||
do { \
|
do { \
|
||||||
@@ -702,16 +813,16 @@ do { \
|
|||||||
Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
|
Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
|
||||||
YYFPRINTF (stderr, "\n"); \
|
YYFPRINTF (stderr, "\n"); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (YYID (0))
|
||||||
|
|
||||||
]b4_yy_symbol_print_define[
|
]b4_yy_symbol_print_generate([b4_c_function_def])[
|
||||||
|
|
||||||
/*------------------------------------------------------------------.
|
/*------------------------------------------------------------------.
|
||||||
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
|
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
|
||||||
| TOP (included). |
|
| TOP (included). |
|
||||||
`------------------------------------------------------------------*/
|
`------------------------------------------------------------------*/
|
||||||
|
|
||||||
]b4_function_define([yy_stack_print], [static void],
|
]b4_c_function_def([yy_stack_print], [static void],
|
||||||
[[yytype_int16 *yybottom], [yybottom]],
|
[[yytype_int16 *yybottom], [yybottom]],
|
||||||
[[yytype_int16 *yytop], [yytop]])[
|
[[yytype_int16 *yytop], [yytop]])[
|
||||||
{
|
{
|
||||||
@@ -728,31 +839,29 @@ do { \
|
|||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_stack_print ((Bottom), (Top)); \
|
yy_stack_print ((Bottom), (Top)); \
|
||||||
} while (0)
|
} while (YYID (0))
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------.
|
/*------------------------------------------------.
|
||||||
| Report that the YYRULE is going to be reduced. |
|
| Report that the YYRULE is going to be reduced. |
|
||||||
`------------------------------------------------*/
|
`------------------------------------------------*/
|
||||||
|
|
||||||
]b4_function_define([yy_reduce_print], [static void],
|
]b4_c_function_def([yy_reduce_print], [static void],
|
||||||
[[yytype_int16 *yyssp], [yyssp]],
|
|
||||||
[[YYSTYPE *yyvsp], [yyvsp]],
|
[[YYSTYPE *yyvsp], [yyvsp]],
|
||||||
b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
|
b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
|
||||||
])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
|
])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
|
||||||
b4_parse_param]))[
|
b4_parse_param]))[
|
||||||
{
|
{
|
||||||
unsigned long int yylno = yyrline[yyrule];
|
|
||||||
int yynrhs = yyr2[yyrule];
|
int yynrhs = yyr2[yyrule];
|
||||||
int yyi;
|
int yyi;
|
||||||
|
unsigned long int yylno = yyrline[yyrule];
|
||||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
||||||
yyrule - 1, yylno);
|
yyrule - 1, yylno);
|
||||||
/* The symbols being reduced. */
|
/* The symbols being reduced. */
|
||||||
for (yyi = 0; yyi < yynrhs; yyi++)
|
for (yyi = 0; yyi < yynrhs; yyi++)
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
||||||
yy_symbol_print (stderr,
|
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
|
||||||
yystos[yyssp[yyi + 1 - yynrhs]],
|
|
||||||
&]b4_rhs_value(yynrhs, yyi + 1)[
|
&]b4_rhs_value(yynrhs, yyi + 1)[
|
||||||
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
||||||
b4_user_args[);
|
b4_user_args[);
|
||||||
@@ -763,8 +872,8 @@ do { \
|
|||||||
# define YY_REDUCE_PRINT(Rule) \
|
# define YY_REDUCE_PRINT(Rule) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
|
yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
|
||||||
} while (0)
|
} while (YYID (0))
|
||||||
|
|
||||||
/* 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. */
|
||||||
@@ -898,7 +1007,7 @@ do { \
|
|||||||
goto yyerrlab; \
|
goto yyerrlab; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (YYID (0))
|
||||||
|
|
||||||
/* Discard any previous initial lookahead context because of Event,
|
/* Discard any previous initial lookahead context because of Event,
|
||||||
which may be a lookahead change or an invalidation of the currently
|
which may be a lookahead change or an invalidation of the currently
|
||||||
@@ -921,7 +1030,7 @@ do { \
|
|||||||
Event "\n"); \
|
Event "\n"); \
|
||||||
yy_lac_established = 0; \
|
yy_lac_established = 0; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (YYID (0))
|
||||||
#else
|
#else
|
||||||
# define YY_LAC_DISCARD(Event) yy_lac_established = 0
|
# define YY_LAC_DISCARD(Event) yy_lac_established = 0
|
||||||
#endif
|
#endif
|
||||||
@@ -1037,7 +1146,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
|||||||
# define yystrlen strlen
|
# define yystrlen strlen
|
||||||
# else
|
# else
|
||||||
/* Return the length of YYSTR. */
|
/* Return the length of YYSTR. */
|
||||||
]b4_function_define([yystrlen], [static YYSIZE_T],
|
]b4_c_function_def([yystrlen], [static YYSIZE_T],
|
||||||
[[const char *yystr], [yystr]])[
|
[[const char *yystr], [yystr]])[
|
||||||
{
|
{
|
||||||
YYSIZE_T yylen;
|
YYSIZE_T yylen;
|
||||||
@@ -1054,7 +1163,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
|
|||||||
# else
|
# else
|
||||||
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
|
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
|
||||||
YYDEST. */
|
YYDEST. */
|
||||||
]b4_function_define([yystpcpy], [static char *],
|
]b4_c_function_def([yystpcpy], [static char *],
|
||||||
[[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[
|
[[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[
|
||||||
{
|
{
|
||||||
char *yyd = yydest;
|
char *yyd = yydest;
|
||||||
@@ -1143,6 +1252,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
|||||||
int yycount = 0;
|
int yycount = 0;
|
||||||
|
|
||||||
/* There are many possibilities here to consider:
|
/* There are many possibilities here to consider:
|
||||||
|
- Assume YYFAIL is not used. It's too flawed to consider. See
|
||||||
|
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
|
||||||
|
for details. YYERROR is fine as it does not invoke this
|
||||||
|
function.
|
||||||
- If this state is a consistent state with a default action, then
|
- If this state is a consistent state with a default action, then
|
||||||
the only way this function was invoked is if the default action
|
the only way this function was invoked is if the default action
|
||||||
is an error action. In that case, don't check for expected
|
is an error action. In that case, don't check for expected
|
||||||
@@ -1277,7 +1390,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
|||||||
}
|
}
|
||||||
#endif /* YYERROR_VERBOSE */
|
#endif /* YYERROR_VERBOSE */
|
||||||
|
|
||||||
]b4_yydestruct_define[
|
]b4_yydestruct_generate([b4_c_function_def])[
|
||||||
|
|
||||||
]b4_pure_if([], [
|
]b4_pure_if([], [
|
||||||
|
|
||||||
@@ -1292,13 +1405,13 @@ struct yypstate
|
|||||||
|
|
||||||
static char yypstate_allocated = 0;]])b4_pull_if([
|
static char yypstate_allocated = 0;]])b4_pull_if([
|
||||||
|
|
||||||
b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
|
||||||
{
|
{
|
||||||
return yypull_parse (YY_NULL]m4_ifset([b4_parse_param],
|
return yypull_parse (YY_NULL]m4_ifset([b4_parse_param],
|
||||||
[[, ]b4_args(b4_parse_param)])[);
|
[[, ]b4_c_args(b4_parse_param)])[);
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_function_define([[yypull_parse]], [[int]],
|
]b4_c_function_def([[yypull_parse]], [[int]],
|
||||||
[[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
|
[[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
|
||||||
b4_parse_param]))[
|
b4_parse_param]))[
|
||||||
{
|
{
|
||||||
@@ -1322,9 +1435,9 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
yychar = ]b4_lex[;
|
yychar = YYLEX;
|
||||||
yystatus =
|
yystatus =
|
||||||
yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[);
|
yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])[);
|
||||||
} while (yystatus == YYPUSH_MORE);
|
} while (yystatus == YYPUSH_MORE);
|
||||||
if (!yyps)
|
if (!yyps)
|
||||||
yypstate_delete (yyps_local);
|
yypstate_delete (yyps_local);
|
||||||
@@ -1332,7 +1445,7 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
|||||||
}]])[
|
}]])[
|
||||||
|
|
||||||
/* Initialize the parser data structure. */
|
/* Initialize the parser data structure. */
|
||||||
]b4_function_define([[yypstate_new]], [[yypstate *]])[
|
]b4_c_function_def([[yypstate_new]], [[yypstate *]])[
|
||||||
{
|
{
|
||||||
yypstate *yyps;]b4_pure_if([], [[
|
yypstate *yyps;]b4_pure_if([], [[
|
||||||
if (yypstate_allocated)
|
if (yypstate_allocated)
|
||||||
@@ -1345,7 +1458,7 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
|||||||
return yyps;
|
return yyps;
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_function_define([[yypstate_delete]], [[void]],
|
]b4_c_function_def([[yypstate_delete]], [[void]],
|
||||||
[[[yypstate *yyps]], [[yyps]]])[
|
[[[yypstate *yyps]], [[yyps]]])[
|
||||||
{
|
{
|
||||||
#ifndef yyoverflow
|
#ifndef yyoverflow
|
||||||
@@ -1383,7 +1496,7 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
|||||||
| yypush_parse. |
|
| yypush_parse. |
|
||||||
`---------------*/
|
`---------------*/
|
||||||
|
|
||||||
]b4_function_define([[yypush_parse]], [[int]],
|
]b4_c_function_def([[yypush_parse]], [[int]],
|
||||||
[[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
|
[[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
|
||||||
[[[int yypushed_char]], [[yypushed_char]]],
|
[[[int yypushed_char]], [[yypushed_char]]],
|
||||||
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
|
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
|
||||||
@@ -1395,7 +1508,12 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
|||||||
| yyparse. |
|
| yyparse. |
|
||||||
`----------*/
|
`----------*/
|
||||||
|
|
||||||
]b4_function_define([yyparse], [int], b4_parse_param)])[
|
#ifdef YYPARSE_PARAM
|
||||||
|
]b4_c_function_def([yyparse], [int],
|
||||||
|
[[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
|
||||||
|
#else /* ! YYPARSE_PARAM */
|
||||||
|
]b4_c_function_def([yyparse], [int], b4_parse_param)[
|
||||||
|
#endif]])[
|
||||||
{]b4_pure_if([b4_declare_scanner_communication_variables
|
{]b4_pure_if([b4_declare_scanner_communication_variables
|
||||||
])b4_push_if([b4_pure_if([], [[
|
])b4_push_if([b4_pure_if([], [[
|
||||||
int yypushed_char = yychar;
|
int yypushed_char = yychar;
|
||||||
@@ -1583,7 +1701,7 @@ yyread_pushed_token:]])[
|
|||||||
yylval = *yypushed_val;]b4_locations_if([[
|
yylval = *yypushed_val;]b4_locations_if([[
|
||||||
if (yypushed_loc)
|
if (yypushed_loc)
|
||||||
yylloc = *yypushed_loc;]])])], [[
|
yylloc = *yypushed_loc;]])])], [[
|
||||||
yychar = ]b4_lex[;]])[
|
yychar = YYLEX;]])[
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yychar <= YYEOF)
|
if (yychar <= YYEOF)
|
||||||
@@ -1717,9 +1835,9 @@ yyreduce:
|
|||||||
goto yynewstate;
|
goto yynewstate;
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------.
|
/*------------------------------------.
|
||||||
| yyerrlab -- here on detecting error. |
|
| yyerrlab -- here on detecting error |
|
||||||
`--------------------------------------*/
|
`------------------------------------*/
|
||||||
yyerrlab:
|
yyerrlab:
|
||||||
/* Make sure we have latest lookahead translation. See comments at
|
/* Make sure we have latest lookahead translation. See comments at
|
||||||
user semantic actions for why this is necessary. */
|
user semantic actions for why this is necessary. */
|
||||||
@@ -1806,7 +1924,7 @@ yyerrorlab:
|
|||||||
goto yyerrorlab;
|
goto yyerrorlab;
|
||||||
|
|
||||||
]b4_locations_if([[ yyerror_range[1] = yylsp[1-yylen];
|
]b4_locations_if([[ yyerror_range[1] = yylsp[1-yylen];
|
||||||
]])[ /* Do not reclaim the symbols of the rule whose action triggered
|
]])[ /* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYERROR. */
|
this YYERROR. */
|
||||||
YYPOPSTACK (yylen);
|
YYPOPSTACK (yylen);
|
||||||
yylen = 0;
|
yylen = 0;
|
||||||
@@ -1901,7 +2019,7 @@ yyreturn:
|
|||||||
yydestruct ("Cleanup: discarding lookahead",
|
yydestruct ("Cleanup: discarding lookahead",
|
||||||
yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
|
yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
|
||||||
}
|
}
|
||||||
/* Do not reclaim the symbols of the rule whose action triggered
|
/* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYABORT or YYACCEPT. */
|
this YYABORT or YYACCEPT. */
|
||||||
YYPOPSTACK (yylen);
|
YYPOPSTACK (yylen);
|
||||||
YY_STACK_PRINT (yyss, yyssp);
|
YY_STACK_PRINT (yyss, yyssp);
|
||||||
@@ -1924,15 +2042,19 @@ yypushreturn:]])[
|
|||||||
if (yymsg != yymsgbuf)
|
if (yymsg != yymsgbuf)
|
||||||
YYSTACK_FREE (yymsg);
|
YYSTACK_FREE (yymsg);
|
||||||
#endif
|
#endif
|
||||||
return yyresult;
|
/* Make sure YYID is used. */
|
||||||
|
return YYID (yyresult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
]b4_epilogue[]dnl
|
]b4_epilogue[]dnl
|
||||||
b4_output_end()
|
b4_output_end()
|
||||||
|
|
||||||
b4_defines_if(
|
b4_defines_if(
|
||||||
[b4_output_begin([b4_spec_defines_file])[
|
[b4_output_begin([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-2013])[
|
||||||
|
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]b4_output_end()
|
]b4_output_end()
|
||||||
])# b4_defines_if
|
])
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
## Copyright (C) 2008-2013 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/>.
|
|
||||||
|
|
||||||
EXTRA_DIST += \
|
|
||||||
djgpp/Makefile.maint \
|
|
||||||
djgpp/README.in \
|
|
||||||
djgpp/config.bat \
|
|
||||||
djgpp/config.sed \
|
|
||||||
djgpp/config.site \
|
|
||||||
djgpp/config_h.sed \
|
|
||||||
djgpp/djunpack.bat \
|
|
||||||
djgpp/fnchange.lst \
|
|
||||||
djgpp/subpipe.c \
|
|
||||||
djgpp/subpipe.h \
|
|
||||||
djgpp/testsuite.sed
|
|
||||||
+2
-1
@@ -1,12 +1,13 @@
|
|||||||
/*~
|
/*~
|
||||||
/.dirstamp
|
/.dirstamp
|
||||||
|
/Makefile
|
||||||
|
/Makefile.in
|
||||||
/bison.1
|
/bison.1
|
||||||
/bison.aux
|
/bison.aux
|
||||||
/bison.cp
|
/bison.cp
|
||||||
/bison.cps
|
/bison.cps
|
||||||
/bison.dvi
|
/bison.dvi
|
||||||
/bison.fn
|
/bison.fn
|
||||||
/bison.help
|
|
||||||
/bison.html
|
/bison.html
|
||||||
/bison.info
|
/bison.info
|
||||||
/bison.ky
|
/bison.ky
|
||||||
|
|||||||
+163
-949
File diff suppressed because it is too large
Load Diff
+155
@@ -0,0 +1,155 @@
|
|||||||
|
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||||
|
|
||||||
|
## Copyright (C) 2001-2003, 2005-2013 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/>.
|
||||||
|
|
||||||
|
AM_MAKEINFOFLAGS = --no-split
|
||||||
|
info_TEXINFOS = bison.texi
|
||||||
|
bison_TEXINFOS = $(srcdir)/cross-options.texi gpl-3.0.texi fdl.texi
|
||||||
|
|
||||||
|
CLEANFILES = bison.fns
|
||||||
|
CLEANDIRS = *.t2d
|
||||||
|
clean-local:
|
||||||
|
rm -rf $(CLEANDIRS)
|
||||||
|
|
||||||
|
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
|
||||||
|
$(srcdir)/cross-options.texi: $(top_srcdir)/src/getargs.c $(CROSS_OPTIONS_PL)
|
||||||
|
$(AM_V_GEN)mv -f $@ $@~ || : >$@~
|
||||||
|
$(AM_V_at)rm -f $@.tmp
|
||||||
|
$(AM_V_at)cd $(top_builddir)/src && $(MAKE) $(AM_MAKEFLAGS) bison
|
||||||
|
$(AM_V_at)$(top_builddir)/src/bison --help \
|
||||||
|
| $(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
|
||||||
|
$(AM_V_at)diff -u $@~ $@.tmp || true
|
||||||
|
$(AM_V_at)mv $@.tmp $@
|
||||||
|
MAINTAINERCLEANFILES = $(srcdir)/cross-options.texi
|
||||||
|
|
||||||
|
## ---------- ##
|
||||||
|
## Ref card. ##
|
||||||
|
## ---------- ##
|
||||||
|
|
||||||
|
EXTRA_DIST = refcard.tex
|
||||||
|
CLEANFILES += refcard.dvi refcard.log refcard.ps
|
||||||
|
|
||||||
|
refcard.dvi: refcard.tex
|
||||||
|
$(AM_V_GEN)tex refcard.tex
|
||||||
|
|
||||||
|
refcard.ps: refcard.dvi
|
||||||
|
|
||||||
|
|
||||||
|
## ----------- ##
|
||||||
|
## Man Pages. ##
|
||||||
|
## ----------- ##
|
||||||
|
|
||||||
|
dist_man_MANS = $(srcdir)/bison.1
|
||||||
|
|
||||||
|
EXTRA_DIST += $(dist_man_MANS:.1=.x) common.x
|
||||||
|
MAINTAINERCLEANFILES += $(dist_man_MANS)
|
||||||
|
|
||||||
|
# Depend on configure to get version number changes.
|
||||||
|
common_dep = $(top_srcdir)/configure $(srcdir)/common.x
|
||||||
|
srcsrcdir = $(top_srcdir)/bin
|
||||||
|
$(srcdir)/bison.1: $(common_dep) $(top_srcdir)/src/getargs.c
|
||||||
|
|
||||||
|
# Differences to ignore when comparing the man page (the date).
|
||||||
|
remove_time_stamp = \
|
||||||
|
sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
|
||||||
|
|
||||||
|
MOSTLYCLEANFILES = $(srcdir)/*.t
|
||||||
|
|
||||||
|
SUFFIXES = .x .1
|
||||||
|
|
||||||
|
PREPATH = $(top_builddir)/src
|
||||||
|
.x.1:
|
||||||
|
$(AM_V_GEN)program=`expr "/$*" : '.*/\(.*\)'` && \
|
||||||
|
save_IFS=$IFS; \
|
||||||
|
IFS=$(PATH_SEPARATOR); \
|
||||||
|
for dir in $(PREPATH); do \
|
||||||
|
IFS=$save_IFS; \
|
||||||
|
echo cd $$dir '&&' $(MAKE) $(AM_MAKEFLAGS) $$program && \
|
||||||
|
(cd $$dir && $(MAKE) $(AM_MAKEFLAGS) $$program) || exit; \
|
||||||
|
done
|
||||||
|
$(AM_V_at)PATH="$(PREPATH)$(PATH_SEPARATOR)$$PATH"; \
|
||||||
|
export PATH; \
|
||||||
|
$(HELP2MAN) \
|
||||||
|
--include=$*.x \
|
||||||
|
--include=$(srcdir)/common.x \
|
||||||
|
--output=$@.t `echo '$*' | sed 's,.*/,,'`
|
||||||
|
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
|
||||||
|
$(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
|
||||||
|
touch $@; \
|
||||||
|
else \
|
||||||
|
mv $@.t $@; \
|
||||||
|
fi
|
||||||
|
$(AM_V_at)rm -f $@*.t
|
||||||
|
|
||||||
|
nodist_man_MANS = yacc.1
|
||||||
|
|
||||||
|
## ------------------------------ ##
|
||||||
|
## Graphviz examples generation. ##
|
||||||
|
## ------------------------------ ##
|
||||||
|
|
||||||
|
CLEANDIRS += figs
|
||||||
|
FIGS_DOT = figs/example.dot figs/example-reduce.dot figs/example-shift.dot
|
||||||
|
EXTRA_DIST += \
|
||||||
|
figs/example.y \
|
||||||
|
$(FIGS_DOT) \
|
||||||
|
$(FIGS_DOT:.dot=.eps) $(FIGS_DOT:.dot=.pdf) $(FIGS_DOT:.dot=.png)
|
||||||
|
SUFFIXES += .dot .eps .pdf .png
|
||||||
|
|
||||||
|
bison.dvi: $(FIGS_DOT:.dot=.eps)
|
||||||
|
bison.html: $(FIGS_DOT:.dot=.png)
|
||||||
|
bison.pdf: $(FIGS_DOT:.dot=.pdf)
|
||||||
|
|
||||||
|
.dot.eps:
|
||||||
|
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
||||||
|
$(AM_V_at) $(DOT) -Gmargin=0 -Teps $< >$@.tmp
|
||||||
|
$(AM_V_at) mv $@.tmp $@
|
||||||
|
|
||||||
|
.dot.pdf:
|
||||||
|
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
||||||
|
$(AM_V_at) $(DOT) -Gmargin=0 -Tpdf $< >$@.tmp
|
||||||
|
$(AM_V_at) mv $@.tmp $@
|
||||||
|
|
||||||
|
.dot.png:
|
||||||
|
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
||||||
|
$(AM_V_at) $(DOT) -Gmargin=0 -Tpng $< >$@.tmp
|
||||||
|
$(AM_V_at) mv $@.tmp $@
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## Doxygenation. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
DOXYGEN = doxygen
|
||||||
|
|
||||||
|
.PHONY: doc html
|
||||||
|
|
||||||
|
doc: html
|
||||||
|
|
||||||
|
html-local: Doxyfile
|
||||||
|
$(DOXYGEN)
|
||||||
|
|
||||||
|
edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
|
||||||
|
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
|
||||||
|
-e 's,@top_builddir\@,$(top_builddir),g' \
|
||||||
|
-e 's,@top_srcdir\@,$(top_srcdir),g'
|
||||||
|
|
||||||
|
EXTRA_DIST += Doxyfile.in
|
||||||
|
CLEANFILES += Doxyfile
|
||||||
|
# Sed is used to generate Doxyfile from Doxyfile.in instead of
|
||||||
|
# configure, because the former is way faster than the latter.
|
||||||
|
Doxyfile: $(srcdir)/Doxyfile.in
|
||||||
|
$(AM_V_GEN)$(edit) $(srcdir)/Doxyfile.in >Doxyfile
|
||||||
|
|
||||||
|
CLEANDIRS += html latex
|
||||||
+420
-1121
File diff suppressed because it is too large
Load Diff
+1
-6
@@ -39,7 +39,7 @@ This description of the options that can be given to
|
|||||||
is adapted from the node
|
is adapted from the node
|
||||||
.B Invocation
|
.B Invocation
|
||||||
in the
|
in the
|
||||||
.B bison.texi
|
.B bison.texinfo
|
||||||
manual, which should be taken as authoritative.
|
manual, which should be taken as authoritative.
|
||||||
.PP
|
.PP
|
||||||
.I Bison
|
.I Bison
|
||||||
@@ -53,8 +53,3 @@ are unique. When a long option takes an argument, like
|
|||||||
.BR \-\-file-prefix ,
|
.BR \-\-file-prefix ,
|
||||||
connect the option name and the argument with
|
connect the option name and the argument with
|
||||||
.BR = .
|
.BR = .
|
||||||
|
|
||||||
[see also]
|
|
||||||
.BR lex (1),
|
|
||||||
.BR flex (1),
|
|
||||||
.BR yacc (1).
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[see also]
|
||||||
|
.BR lex (1),
|
||||||
|
.BR flex (1),
|
||||||
|
.BR yacc (1).
|
||||||
-176
@@ -1,176 +0,0 @@
|
|||||||
## Copyright (C) 2001-2003, 2005-2013 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/>.
|
|
||||||
|
|
||||||
AM_MAKEINFOFLAGS = --no-split
|
|
||||||
info_TEXINFOS = doc/bison.texi
|
|
||||||
doc_bison_TEXINFOS = \
|
|
||||||
$(CROSS_OPTIONS_TEXI) \
|
|
||||||
doc/fdl.texi \
|
|
||||||
doc/gpl-3.0.texi
|
|
||||||
|
|
||||||
# Cannot express dependencies directly on file names because of Automake.
|
|
||||||
# Obfuscate with a variable.
|
|
||||||
doc_bison = doc/bison
|
|
||||||
$(doc_bison).dvi: $(FIGS_DOT:.dot=.eps)
|
|
||||||
$(doc_bison).pdf: $(FIGS_DOT:.dot=.pdf)
|
|
||||||
$(doc_bison).html: $(FIGS_DOT:.dot=.png)
|
|
||||||
|
|
||||||
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
|
|
||||||
CLEANDIRS = doc/bison.t2d
|
|
||||||
clean-local:
|
|
||||||
rm -rf $(CLEANDIRS)
|
|
||||||
|
|
||||||
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.t
|
|
||||||
|
|
||||||
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
|
|
||||||
CROSS_OPTIONS_TEXI = $(top_srcdir)/doc/cross-options.texi
|
|
||||||
$(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
|
|
||||||
# Create $@~ which is the previous contents. Don't use `mv' here so
|
|
||||||
# that even if we are interrupted, the file is still available for
|
|
||||||
# diff in the next run. Note that $@ might not exist yet.
|
|
||||||
$(AM_V_GEN){ test ! -f $@ || cat $@; } >$@~
|
|
||||||
$(AM_V_at)test ! -f $@.tmp || rm -f $@.tmp
|
|
||||||
$(AM_V_at)src/bison$(EXEEXT) --help | \
|
|
||||||
$(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
|
|
||||||
$(AM_V_at)diff -u $@~ $@.tmp || true
|
|
||||||
$(AM_V_at)mv $@.tmp $@
|
|
||||||
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
|
|
||||||
|
|
||||||
## ---------- ##
|
|
||||||
## Ref card. ##
|
|
||||||
## ---------- ##
|
|
||||||
|
|
||||||
EXTRA_DIST += doc/refcard.tex
|
|
||||||
CLEANFILES += doc/refcard.pdf
|
|
||||||
|
|
||||||
doc/refcard.pdf: doc/refcard.tex
|
|
||||||
$(AM_V_GEN) cd doc && pdftex $(abs_top_srcdir)/doc/refcard.tex
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
|
||||||
## doc/bison.help. ##
|
|
||||||
## ---------------- ##
|
|
||||||
|
|
||||||
# Some of our targets (cross-option.texi, bison.1) use "bison --help".
|
|
||||||
# Since we want to ship the generated file to avoid additional
|
|
||||||
# requirements over the user environment, we used not depend on
|
|
||||||
# src/bison itself, but on src/getargs.c and other files. Yet, we
|
|
||||||
# need "bison --help" to work to make help2man happy, so we used to
|
|
||||||
# include "make src/bison" in the commands. Then we may have a
|
|
||||||
# problem with concurrent builds, since one make might be aiming one
|
|
||||||
# of its jobs at compiling src/bison, and another job at generating
|
|
||||||
# the man page. If the latter is faster than the former, then we have
|
|
||||||
# two makes that concurrently try to compile src/bison. Doomed to
|
|
||||||
# failure.
|
|
||||||
#
|
|
||||||
# As a simple scheme to get our way out, make a stamp file,
|
|
||||||
# bison.help, which contains --version then --help. This file can
|
|
||||||
# depend on bison, which ensures its correctness. But update it
|
|
||||||
# *only* if needed (content changes). This way, we avoid useless
|
|
||||||
# compilations of cross-option.texi and bison.1. At the cost of
|
|
||||||
# repeated builds of bison.help.
|
|
||||||
|
|
||||||
EXTRA_DIST += $(top_srcdir)/doc/bison.help
|
|
||||||
MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help
|
|
||||||
$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT)
|
|
||||||
$(AM_V_GEN)src/bison$(EXEEXT) --version >doc/bison.help.tmp
|
|
||||||
$(AM_V_at) src/bison$(EXEEXT) --help >>doc/bison.help.tmp
|
|
||||||
$(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@
|
|
||||||
|
|
||||||
|
|
||||||
## ----------- ##
|
|
||||||
## Man Pages. ##
|
|
||||||
## ----------- ##
|
|
||||||
|
|
||||||
dist_man_MANS = $(top_srcdir)/doc/bison.1
|
|
||||||
|
|
||||||
EXTRA_DIST += $(dist_man_MANS:.1=.x)
|
|
||||||
MAINTAINERCLEANFILES += $(dist_man_MANS)
|
|
||||||
|
|
||||||
# Differences to ignore when comparing the man page (the date).
|
|
||||||
remove_time_stamp = \
|
|
||||||
sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
|
|
||||||
|
|
||||||
# Depend on configure to get version number changes.
|
|
||||||
$(top_srcdir)/doc/bison.1: doc/bison.help doc/bison.x $(top_srcdir)/configure
|
|
||||||
$(AM_V_GEN)$(HELP2MAN) \
|
|
||||||
--include=$(top_srcdir)/doc/bison.x \
|
|
||||||
--output=$@.t src/bison$(EXEEXT)
|
|
||||||
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
|
|
||||||
$(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
|
|
||||||
touch $@; \
|
|
||||||
else \
|
|
||||||
mv $@.t $@; \
|
|
||||||
fi
|
|
||||||
$(AM_V_at)rm -f $@*.t
|
|
||||||
|
|
||||||
nodist_man_MANS = doc/yacc.1
|
|
||||||
|
|
||||||
## ----------------------------- ##
|
|
||||||
## Graphviz examples generation. ##
|
|
||||||
## ----------------------------- ##
|
|
||||||
|
|
||||||
CLEANDIRS += doc/figs
|
|
||||||
FIGS_DOT = \
|
|
||||||
doc/figs/example.dot \
|
|
||||||
doc/figs/example-reduce.dot doc/figs/example-shift.dot
|
|
||||||
EXTRA_DIST += \
|
|
||||||
$(FIGS_DOT) \
|
|
||||||
$(FIGS_DOT:.dot=.eps) $(FIGS_DOT:.dot=.pdf) $(FIGS_DOT:.dot=.png)
|
|
||||||
SUFFIXES += .dot .eps .pdf .png
|
|
||||||
|
|
||||||
.dot.eps:
|
|
||||||
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
|
||||||
$(AM_V_at) $(DOT) -Gmargin=0 -Teps $< >$@.tmp
|
|
||||||
$(AM_V_at) mv $@.tmp $@
|
|
||||||
|
|
||||||
.dot.pdf:
|
|
||||||
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
|
||||||
$(AM_V_at) $(DOT) -Gmargin=0 -Tpdf $< >$@.tmp
|
|
||||||
$(AM_V_at) mv $@.tmp $@
|
|
||||||
|
|
||||||
.dot.png:
|
|
||||||
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
|
|
||||||
$(AM_V_at) $(DOT) -Gmargin=0 -Tpng $< >$@.tmp
|
|
||||||
$(AM_V_at) mv $@.tmp $@
|
|
||||||
|
|
||||||
## -------------- ##
|
|
||||||
## Doxygenation. ##
|
|
||||||
## -------------- ##
|
|
||||||
|
|
||||||
DOXYGEN = doxygen
|
|
||||||
|
|
||||||
.PHONY: doc html
|
|
||||||
|
|
||||||
doc: html
|
|
||||||
|
|
||||||
html-local: doc/Doxyfile
|
|
||||||
$(AM_V_GEN) $(DOXYGEN) doc/Doxyfile
|
|
||||||
|
|
||||||
edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
|
|
||||||
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
|
|
||||||
-e 's,@PERL\@,$(PERL),g' \
|
|
||||||
-e 's,@top_builddir\@,$(top_builddir),g' \
|
|
||||||
-e 's,@top_srcdir\@,$(top_srcdir),g'
|
|
||||||
|
|
||||||
EXTRA_DIST += doc/Doxyfile.in
|
|
||||||
CLEANFILES += doc/Doxyfile
|
|
||||||
# Sed is used to generate Doxyfile from Doxyfile.in instead of
|
|
||||||
# configure, because the former is way faster than the latter.
|
|
||||||
doc/Doxyfile: $(top_srcdir)/doc/Doxyfile.in
|
|
||||||
$(AM_V_GEN) $(edit) $(top_srcdir)/doc/Doxyfile.in >doc/Doxyfile
|
|
||||||
|
|
||||||
CLEANDIRS += doc/html
|
|
||||||
@@ -1 +1,3 @@
|
|||||||
|
/Makefile
|
||||||
|
/Makefile.in
|
||||||
/bench.pl
|
/bench.pl
|
||||||
|
|||||||
Executable → Regular
+2
-13
@@ -1,7 +1,5 @@
|
|||||||
#! /bin/sh
|
## Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# Copyright (C) 2005-2013 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
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
@@ -15,13 +13,4 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
cat >input <<EOF
|
nodist_noinst_SCRIPTS = bench.pl
|
||||||
1+2*3
|
|
||||||
EOF
|
|
||||||
run 0 7
|
|
||||||
|
|
||||||
cat >input <<EOF
|
|
||||||
(1+2) * 3
|
|
||||||
EOF
|
|
||||||
run 0 9
|
|
||||||
run 0 9 -p
|
|
||||||
+32
-797
@@ -17,236 +17,23 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
bench.pl - bench marks for Bison parsers.
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
./bench.pl [OPTIONS]... DIRECTIVES
|
|
||||||
|
|
||||||
=head1 DIRECTIVES
|
|
||||||
|
|
||||||
Specify the set of benches to run. The following grammar defines the
|
|
||||||
I<directives>:
|
|
||||||
|
|
||||||
directives ::=
|
|
||||||
directives | directives -- Alternation
|
|
||||||
| directives & directives -- Concatenation
|
|
||||||
| [ directives> ] -- Optional
|
|
||||||
| ( directives> ) -- Parentheses
|
|
||||||
| %b PATH -- Use bison at PATH for this bench
|
|
||||||
| #d NAME[=VALUE] -- %code { #define NAME [VALUE] }
|
|
||||||
| %d NAME[=VALUE] -- %define NAME ["VALUE"]
|
|
||||||
| %s skeleton -- %skeleton "skeleton"
|
|
||||||
| directive
|
|
||||||
|
|
||||||
Parentheses only group to override precedence. For instance:
|
|
||||||
|
|
||||||
[ %debug ] & [ %error-verbose ] & [ %define variant ]
|
|
||||||
|
|
||||||
will generate eight different cases.
|
|
||||||
|
|
||||||
=head1 OPTIONS
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item B<-b>, B<--bench>
|
|
||||||
|
|
||||||
Predefined benches, that is, combimation between a grammar and a I<directives>
|
|
||||||
request.
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item I<push>
|
|
||||||
|
|
||||||
Test the push parser vs. the pull interface. Use the C parser.
|
|
||||||
|
|
||||||
=item I<variant>
|
|
||||||
|
|
||||||
Test the use of variants instead of union in the C++ parser.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=item B<-c>, B<--cflags>=I<flags>
|
|
||||||
|
|
||||||
Flags to pass to the C or C++ compiler. Defaults to -O2.
|
|
||||||
|
|
||||||
=item B<-d>, B<--directive>=I<directives>
|
|
||||||
|
|
||||||
Add a set of Bison directives to bench against each other.
|
|
||||||
|
|
||||||
=item B<-g>, B<--grammar>=I<grammar>
|
|
||||||
|
|
||||||
Select the base I<grammar> to use. Defaults to I<calc>.
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item I<calc>
|
|
||||||
|
|
||||||
Traditional calculator.
|
|
||||||
|
|
||||||
=item I<list>
|
|
||||||
|
|
||||||
C++ grammar that uses std::string and std::list. Can be used with
|
|
||||||
or without %define variant.
|
|
||||||
|
|
||||||
=item I<triangular>
|
|
||||||
|
|
||||||
Artificial grammar with very long rules.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=item B<-h>, B<--help>
|
|
||||||
|
|
||||||
Display this message and exit succesfully. The more verbose, the more
|
|
||||||
details.
|
|
||||||
|
|
||||||
=item B<-i>, B<--iterations>=I<integer>
|
|
||||||
|
|
||||||
Say how many times a single test of the bench must be run. If
|
|
||||||
negative, specify the minimum number of CPU seconds to run. Defaults
|
|
||||||
to -1.
|
|
||||||
|
|
||||||
=item B<-q>, B<--quiet>
|
|
||||||
|
|
||||||
Decrease the verbosity level (defaults to 1).
|
|
||||||
|
|
||||||
=item B<-v>, B<--verbose>
|
|
||||||
|
|
||||||
Raise the verbosity level (defaults to 1).
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use IO::File;
|
use IO::File;
|
||||||
|
use Benchmark qw (:all);
|
||||||
|
|
||||||
|
my $bison = $ENV{'BISON'} || '@abs_top_builddir@/tests/bison';
|
||||||
|
my $cc = $ENV{'CC'} || 'gcc';
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
=head1 VARIABLES
|
sub triangular_grammar ($$$)
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item C<@bench>
|
|
||||||
|
|
||||||
The list of benches to run.
|
|
||||||
|
|
||||||
=item C<$bison>
|
|
||||||
|
|
||||||
The Bison program to use to compile the grammar.
|
|
||||||
|
|
||||||
=item C<$cc>
|
|
||||||
|
|
||||||
The C compiler.
|
|
||||||
|
|
||||||
=item C<$cxx>
|
|
||||||
|
|
||||||
The C++ compiler.
|
|
||||||
|
|
||||||
=item C<$cflags>
|
|
||||||
|
|
||||||
Compiler flags (C or C++).
|
|
||||||
|
|
||||||
=item C<@directive>
|
|
||||||
|
|
||||||
A list of directive sets to measure against each other.
|
|
||||||
|
|
||||||
=item C<$iterations>
|
|
||||||
|
|
||||||
The number of times the parser is run for a bench.
|
|
||||||
|
|
||||||
=item C<$verbose>
|
|
||||||
|
|
||||||
Verbosity level.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
my $bench;
|
|
||||||
my $bison = $ENV{'BISON'} || '@abs_top_builddir@/tests/bison';
|
|
||||||
my $cc = $ENV{'CC'} || 'gcc';
|
|
||||||
my $cxx = $ENV{'CXX'} || 'g++';
|
|
||||||
my $cflags = '-O2';
|
|
||||||
my @directive = ();
|
|
||||||
my $grammar = 'calc';
|
|
||||||
my $iterations = -1;
|
|
||||||
my $verbose = 1;
|
|
||||||
|
|
||||||
=head1 FUNCTIONS
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item C<verbose($level, $message)>
|
|
||||||
|
|
||||||
Report the C<$message> is C<$level> E<lt>= C<$verbose>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub verbose($$)
|
|
||||||
{
|
{
|
||||||
my ($level, $message) = @_;
|
my ($base, $max, $directives) = @_;
|
||||||
print STDERR $message
|
|
||||||
if $level <= $verbose;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
=item C<directives($bench, @directive)>
|
|
||||||
|
|
||||||
Format the list of directives for Bison for bench named C<$bench>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub directives($@)
|
|
||||||
{
|
|
||||||
my ($bench, @directive) = @_;
|
|
||||||
my $res = "/* Directives for bench `$bench'. */\n";
|
|
||||||
$res .= join ("\n", @directive) . "\n";
|
|
||||||
$res .= "/* End of directives for bench `$bench'. */\n";
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
=item C<generate_grammar_triangular ($base, $max, @directive)>
|
|
||||||
|
|
||||||
Create a large triangular grammar which looks like :
|
|
||||||
|
|
||||||
input:
|
|
||||||
exp { if ($1 != 0) abort (); $$ = $1; }
|
|
||||||
| input exp { if ($2 != $1 + 1) abort (); $$ = $2; }
|
|
||||||
;
|
|
||||||
|
|
||||||
exp:
|
|
||||||
END { $$ = 0; }
|
|
||||||
| "1" END { $$ = 1; }
|
|
||||||
| "1" "2" END { $$ = 2; }
|
|
||||||
| "1" "2" "3" END { $$ = 3; }
|
|
||||||
| "1" "2" "3" "4" END { $$ = 4; }
|
|
||||||
| "1" "2" "3" "4" "5" END { $$ = 5; }
|
|
||||||
;
|
|
||||||
|
|
||||||
C<$base> is the base name for the file to create (F<$base.y>).
|
|
||||||
C<$max> is the number of such rules (here, 5). You may pass
|
|
||||||
additional Bison C<@directive>.
|
|
||||||
|
|
||||||
The created parser is self contained: it includes its scanner, and
|
|
||||||
source of input.
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub generate_grammar_triangular ($$@)
|
|
||||||
{
|
|
||||||
my ($base, $max, @directive) = @_;
|
|
||||||
my $directives = directives ($base, @directive);
|
|
||||||
|
|
||||||
my $out = new IO::File ">$base.y"
|
my $out = new IO::File ">$base.y"
|
||||||
or die;
|
or die;
|
||||||
print $out <<EOF;
|
print $out <<EOF;
|
||||||
%error-verbose
|
%error-verbose
|
||||||
|
%debug
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -254,7 +41,6 @@ sub generate_grammar_triangular ($$@)
|
|||||||
static int yylex (void);
|
static int yylex (void);
|
||||||
static void yyerror (const char *msg);
|
static void yyerror (const char *msg);
|
||||||
%}
|
%}
|
||||||
$directives
|
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
@@ -318,9 +104,7 @@ yyerror (const char *msg)
|
|||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
#if YYDEBUG
|
|
||||||
yydebug = !!getenv ("YYDEBUG");
|
yydebug = !!getenv ("YYDEBUG");
|
||||||
#endif
|
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@@ -328,15 +112,6 @@ EOF
|
|||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
=item C<calc_input ($base, $max)>
|
|
||||||
|
|
||||||
Generate the input file F<$base.input> for the calc parser. The input
|
|
||||||
is composed of two expressions. The first one is using left recursion
|
|
||||||
only and consumes no stack. The second one requires a deep stack.
|
|
||||||
These two expressions are repeated C<$max> times in the output file.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub calc_input ($$)
|
sub calc_input ($$)
|
||||||
{
|
{
|
||||||
my ($base, $max) = @_;
|
my ($base, $max) = @_;
|
||||||
@@ -351,22 +126,9 @@ sub calc_input ($$)
|
|||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
=item C<generate_grammar_calc ($base, $max, @directive)>
|
sub calc_grammar ($$$)
|
||||||
|
|
||||||
Generate a Bison file F<$base.y> for a calculator parser in C. Pass
|
|
||||||
the additional Bison C<@directive>. C<$max> is ignored, but left to
|
|
||||||
have the same interface as C<triangular_grammar>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub generate_grammar_calc ($$@)
|
|
||||||
{
|
{
|
||||||
my ($base, $max, @directive) = @_;
|
my ($base, $max, $directives) = @_;
|
||||||
my $directives = directives ($base, @directive);
|
|
||||||
|
|
||||||
# Putting this request here is stupid, since the input will be
|
|
||||||
# generated each time we generate a grammar.
|
|
||||||
calc_input ('calc', 200);
|
|
||||||
|
|
||||||
my $out = new IO::File ">$base.y"
|
my $out = new IO::File ">$base.y"
|
||||||
or die;
|
or die;
|
||||||
@@ -386,9 +148,9 @@ static semantic_value global_result = 0;
|
|||||||
static int global_count = 0;
|
static int global_count = 0;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
/* Exercise %union. */
|
||||||
$directives
|
$directives
|
||||||
%error-verbose
|
%error-verbose
|
||||||
/* Exercise %union. */
|
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
semantic_value ival;
|
semantic_value ival;
|
||||||
@@ -544,10 +306,6 @@ main (int argc, const char **argv)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
#if YYDEBUG
|
|
||||||
yydebug = !!getenv ("YYDEBUG");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
input = fopen ("calc.input", "r");
|
input = fopen ("calc.input", "r");
|
||||||
if (!input)
|
if (!input)
|
||||||
{
|
{
|
||||||
@@ -568,567 +326,44 @@ EOF
|
|||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
=item C<generate_grammar_list ($base, $max, @directive)>
|
|
||||||
|
|
||||||
Generate a Bison file F<$base.y> for a C++ parser that uses C++
|
|
||||||
objects (std::string, std::list). Tailored for using %define variant.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub generate_grammar_list ($$@)
|
|
||||||
{
|
|
||||||
my ($base, $max, @directive) = @_;
|
|
||||||
my $directives = directives ($base, @directive);
|
|
||||||
my $variant = grep { /%define "?variant"?/ } @directive;
|
|
||||||
my $token_ctor = grep { /%define "?api.token.constructor"?/ } @directive;
|
|
||||||
my $out = new IO::File ">$base.y"
|
|
||||||
or die;
|
|
||||||
print $out <<EOF;
|
|
||||||
%language "C++"
|
|
||||||
%defines
|
|
||||||
%locations
|
|
||||||
$directives
|
|
||||||
|
|
||||||
%code requires // *.h
|
|
||||||
{
|
|
||||||
#include <string>
|
|
||||||
}
|
|
||||||
|
|
||||||
%code // *.c
|
|
||||||
{
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#define STAGE_MAX ($max * 10) // max = $max
|
|
||||||
|
|
||||||
#define USE_TOKEN_CTOR $token_ctor
|
|
||||||
#define USE_VARIANTS $variant
|
|
||||||
|
|
||||||
// Prototype of the yylex function providing subsequent tokens.
|
|
||||||
static
|
|
||||||
#if USE_TOKEN_CTOR
|
|
||||||
yy::parser::symbol_type yylex();
|
|
||||||
#else
|
|
||||||
yy::parser::token_type yylex(yy::parser::semantic_type* yylvalp,
|
|
||||||
yy::parser::location_type* yyllocp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Conversion to string.
|
|
||||||
template <typename T>
|
|
||||||
inline
|
|
||||||
std::string
|
|
||||||
string_cast (const T& t)
|
|
||||||
{
|
|
||||||
std::ostringstream o;
|
|
||||||
o << t;
|
|
||||||
return o.str ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
%token END_OF_FILE 0
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if ($variant)
|
|
||||||
{
|
|
||||||
print $out <<'EOF';
|
|
||||||
%token <std::string> TEXT
|
|
||||||
%token <int> NUMBER
|
|
||||||
%printer { std::cerr << "Number: " << $$; } <int>
|
|
||||||
%printer { std::cerr << "Text: " << $$; } <std::string>
|
|
||||||
%type <std::string> text result
|
|
||||||
|
|
||||||
%%
|
|
||||||
result:
|
|
||||||
text { /* Throw away the result. */ }
|
|
||||||
;
|
|
||||||
|
|
||||||
text:
|
|
||||||
/* nothing */ { /* This will generate an empty string */ }
|
|
||||||
| text TEXT { std::swap ($$, $2); }
|
|
||||||
| text NUMBER { $$ = string_cast($2); }
|
|
||||||
;
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
# Not using Bison variants.
|
|
||||||
print $out <<'EOF';
|
|
||||||
%union {int ival; std::string* sval;}
|
|
||||||
%token <sval> TEXT
|
|
||||||
%token <ival> NUMBER
|
|
||||||
%printer { std::cerr << "Number: " << $$; } <ival>
|
|
||||||
%printer { std::cerr << "Text: " << *$$; } <sval>
|
|
||||||
%type <sval> text result
|
|
||||||
|
|
||||||
%%
|
|
||||||
result:
|
|
||||||
text { delete $1; }
|
|
||||||
;
|
|
||||||
|
|
||||||
text:
|
|
||||||
/* nothing */ { $$ = new std::string; }
|
|
||||||
| text TEXT { delete $1; $$ = $2; }
|
|
||||||
| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
|
|
||||||
;
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
print $out <<'EOF';
|
|
||||||
%%
|
|
||||||
#
|
|
||||||
|
|
||||||
static
|
|
||||||
#if USE_TOKEN_CTOR
|
|
||||||
yy::parser::symbol_type yylex()
|
|
||||||
#else
|
|
||||||
yy::parser::token_type yylex(yy::parser::semantic_type* yylvalp,
|
|
||||||
yy::parser::location_type* yyllocp)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
typedef yy::parser::location_type location_type;
|
|
||||||
typedef yy::parser::token token;
|
|
||||||
static int stage = -1;
|
|
||||||
++stage;
|
|
||||||
if (stage == STAGE_MAX)
|
|
||||||
{
|
|
||||||
#if USE_TOKEN_CTOR
|
|
||||||
return yy::parser::make_END_OF_FILE (location_type ());
|
|
||||||
#else
|
|
||||||
*yyllocp = location_type ();
|
|
||||||
return token::END_OF_FILE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (stage % 2)
|
|
||||||
{
|
|
||||||
#if USE_TOKEN_CTOR
|
|
||||||
return yy::parser::make_NUMBER (stage, location_type ());
|
|
||||||
#else
|
|
||||||
# if defined ONE_STAGE_BUILD
|
|
||||||
yylvalp->build(stage);
|
|
||||||
# elif USE_VARIANTS
|
|
||||||
yylvalp->build<int>() = stage;
|
|
||||||
# else
|
|
||||||
yylvalp->ival = stage;
|
|
||||||
# endif
|
|
||||||
*yyllocp = location_type ();
|
|
||||||
return token::NUMBER;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if USE_TOKEN_CTOR
|
|
||||||
return yy::parser::make_TEXT ("A string.", location_type ());
|
|
||||||
#else
|
|
||||||
# if defined ONE_STAGE_BUILD
|
|
||||||
yylvalp->build(std::string("A string."));
|
|
||||||
# elif USE_VARIANTS
|
|
||||||
yylvalp->build<std::string>() = std::string("A string.");
|
|
||||||
# else
|
|
||||||
yylvalp->sval = new std::string("A string.");
|
|
||||||
# endif
|
|
||||||
*yyllocp = location_type ();
|
|
||||||
return token::TEXT;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mandatory error function
|
|
||||||
void
|
|
||||||
yy::parser::error(const yy::parser::location_type& loc, const std::string& msg)
|
|
||||||
{
|
|
||||||
std::cerr << loc << ": " << msg << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
yy::parser p;
|
|
||||||
#if YYDEBUG
|
|
||||||
p.set_debug_level(!!getenv("YYDEBUG"));
|
|
||||||
#endif
|
|
||||||
p.parse();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
##################################################################
|
|
||||||
|
|
||||||
=item C<generate_grammar ($name, $base, @directive)>
|
|
||||||
|
|
||||||
Generate F<$base.y> by calling C<&generate_grammar_$name>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub generate_grammar ($$@)
|
|
||||||
{
|
|
||||||
my ($name, $base, @directive) = @_;
|
|
||||||
verbose 3, "Generating $base.y\n";
|
|
||||||
my %generator =
|
|
||||||
(
|
|
||||||
"calc" => \&generate_grammar_calc,
|
|
||||||
"list" => \&generate_grammar_list,
|
|
||||||
"triangular" => \&generate_grammar_triangular,
|
|
||||||
);
|
|
||||||
&{$generator{$name}}($base, 200, @directive);
|
|
||||||
}
|
|
||||||
|
|
||||||
##################################################################
|
|
||||||
|
|
||||||
=item C<run ($command)>
|
|
||||||
|
|
||||||
Run, possibly verbosely, the shell C<$command>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub run ($)
|
|
||||||
{
|
|
||||||
my ($command) = @_;
|
|
||||||
verbose 3, "$command\n";
|
|
||||||
system ("$command") == 0
|
|
||||||
or die "$command failed";
|
|
||||||
}
|
|
||||||
|
|
||||||
##################################################################
|
|
||||||
|
|
||||||
=item C<compile ($base)>
|
|
||||||
|
|
||||||
Compile C<$base.y> to an executable C, Using the C or C++ compiler
|
|
||||||
depending on the %language specification in C<$base.y>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub compile ($)
|
sub compile ($)
|
||||||
{
|
{
|
||||||
my ($base) = @_;
|
my ($base) = @_;
|
||||||
my $language = `sed -ne '/%language "\\(.*\\)"/{s//\\1/;p;q;}' $base.y`;
|
system ("$bison $base.y -o $base.c") == 0
|
||||||
chomp $language;
|
or die;
|
||||||
|
system ("$cc -o $base $base.c") == 0
|
||||||
my $compiler = $language eq 'C++' ? $cxx : $cc;
|
or die;
|
||||||
|
|
||||||
my $my_bison = `sed -ne '/%bison "\\(.*\\)"/{s//\\1/;p;q;}' $base.y`;
|
|
||||||
run ((length $my_bison ? $my_bison : $bison) . " $base.y -o $base.c");
|
|
||||||
run "$compiler -o $base $cflags $base.c";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
sub bench_grammar ($)
|
||||||
|
|
||||||
=item C<bench ($grammar, @token)>
|
|
||||||
|
|
||||||
Generate benches for the C<$grammar> and the directive specification
|
|
||||||
given in the list of C<@token>.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub bench ($@)
|
|
||||||
{
|
{
|
||||||
my ($grammar, @token) = @_;
|
my ($gram) = @_;
|
||||||
use Benchmark qw (:all :hireswallclock);
|
my %test =
|
||||||
|
(
|
||||||
|
"pull-impure" => '',
|
||||||
|
"pull-pure" => '%define api.pure',
|
||||||
|
"push-impure" => '%define api.push-pull "both"',
|
||||||
|
"push-pure" => '%define api.push-pull "both" %define api.pure',
|
||||||
|
);
|
||||||
|
|
||||||
my @directive = parse (@token);
|
|
||||||
|
|
||||||
# Set up the benches as expected by timethese.
|
|
||||||
my %bench;
|
my %bench;
|
||||||
# A counter of directive sets.
|
while (my ($name, $directives) = each %test)
|
||||||
my $count = 1;
|
|
||||||
for my $d (@directive)
|
|
||||||
{
|
{
|
||||||
$bench{$count} = $d;
|
print STDERR "$name\n";
|
||||||
printf " %2d. %s\n", $count, join (' ', split ("\n", $d));
|
my $generator = "$gram" . "_grammar";
|
||||||
$count++;
|
&$generator ($name, 200, $directives);
|
||||||
};
|
|
||||||
|
|
||||||
# For each bench, capture the size.
|
|
||||||
my %size;
|
|
||||||
|
|
||||||
while (my ($name, $directives) = each %bench)
|
|
||||||
{
|
|
||||||
generate_grammar ($grammar, $name, $directives);
|
|
||||||
# Compile the executable.
|
|
||||||
compile ($name);
|
compile ($name);
|
||||||
$bench{$name} = "system ('./$name');";
|
$bench{$name} = "system ('./$name');";
|
||||||
chop($size{$name} = `wc -c <$name`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the benches.
|
print "$gram:\n";
|
||||||
#
|
my $res = timethese (50, \%bench, 'nop');
|
||||||
# STYLE can be any of 'all', 'none', 'noc', 'nop' or 'auto'. 'all'
|
|
||||||
# shows each of the 5 times available ('wallclock' time, user time,
|
|
||||||
# system time, user time of children, and system time of
|
|
||||||
# children). 'noc' shows all except the two children times. 'nop'
|
|
||||||
# shows only wallclock and the two children times. 'auto' (the
|
|
||||||
# default) will act as 'all' unless the children times are both
|
|
||||||
# zero, in which case it acts as 'noc'. 'none' prevents output.
|
|
||||||
verbose 3, "Running the benches for $grammar\n";
|
|
||||||
my $res = timethese ($iterations, \%bench, 'nop');
|
|
||||||
|
|
||||||
# Output the speed result.
|
|
||||||
cmpthese ($res, 'nop');
|
cmpthese ($res, 'nop');
|
||||||
|
|
||||||
# Display the sizes.
|
|
||||||
print "Sizes (decreasing):\n";
|
|
||||||
my $width = 10;
|
|
||||||
for my $bench (keys %size)
|
|
||||||
{
|
|
||||||
$width = length $bench
|
|
||||||
if $width < length $bench;
|
|
||||||
}
|
|
||||||
# Benches sorted by decreasing size.
|
|
||||||
my @benches_per_size = sort {$size{$b} <=> $size{$a}} keys %size;
|
|
||||||
for my $bench (@benches_per_size)
|
|
||||||
{
|
|
||||||
printf "%${width}s: %5.2fkB\n", $bench, $size{$bench} / 1024;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
print STDERR "Using $bison, $cc.\n";
|
||||||
|
calc_input ('calc', 200);
|
||||||
=item C<bench_push_parser ()>
|
bench_grammar ('calc');
|
||||||
|
|
||||||
Bench the C push parser against the pull parser, pure and impure
|
|
||||||
interfaces.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub bench_push_parser ()
|
|
||||||
{
|
|
||||||
bench ('calc',
|
|
||||||
qw(
|
|
||||||
[ %d api.pure ]
|
|
||||||
&
|
|
||||||
[ %d api.push-pull=both ]
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
=item C<bench_variant_parser ()>
|
|
||||||
|
|
||||||
Bench the C++ lalr1.cc parser using variants or %union.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub bench_variant_parser ()
|
|
||||||
{
|
|
||||||
bench ('list',
|
|
||||||
qw(
|
|
||||||
[
|
|
||||||
%d variant
|
|
||||||
&
|
|
||||||
[ #d ONE_STAGE_BUILD | %d api.token.constructor ]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
sub help ($)
|
|
||||||
{
|
|
||||||
my ($verbose) = @_;
|
|
||||||
use Pod::Usage;
|
|
||||||
# See <URL:http://perldoc.perl.org/pod2man.html#NOTES>.
|
|
||||||
pod2usage( { -message => "Bench Bison parsers",
|
|
||||||
-exitval => 0,
|
|
||||||
-verbose => $verbose,
|
|
||||||
-output => \*STDOUT });
|
|
||||||
}
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
# The end of the directives to parse.
|
|
||||||
my $eod = "end of directives";
|
|
||||||
# The list of tokens parsed by the following functions.
|
|
||||||
my @token;
|
|
||||||
|
|
||||||
# eat ($EXPECTED)
|
|
||||||
# ---------------
|
|
||||||
# Check that the current token is $EXPECTED, and move to the next.
|
|
||||||
sub eat ($)
|
|
||||||
{
|
|
||||||
my ($expected) = @_;
|
|
||||||
die "expected $expected, unexpected: $token[0] (@token)\n"
|
|
||||||
unless $token[0] eq $expected;
|
|
||||||
shift @token;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parse directive specifications:
|
|
||||||
# expr: term (| term)*
|
|
||||||
# term: fact (& fact)*
|
|
||||||
# fact: ( expr ) | [ expr ] | dirs
|
|
||||||
# dirs: %s SKELETON | #d NAME[=VALUE] | %d NAME[=VALUE] | directive
|
|
||||||
sub parse (@)
|
|
||||||
{
|
|
||||||
@token = (@_, $eod);
|
|
||||||
verbose 3, "Parsing: @token\n";
|
|
||||||
my @res = parse_expr ();
|
|
||||||
eat ($eod);
|
|
||||||
return @res;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub parse_expr ()
|
|
||||||
{
|
|
||||||
my @res = parse_term ();
|
|
||||||
while ($token[0] eq '|')
|
|
||||||
{
|
|
||||||
eat ('|');
|
|
||||||
# Alternation.
|
|
||||||
push @res, parse_term ();
|
|
||||||
}
|
|
||||||
return @res;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub parse_term ()
|
|
||||||
{
|
|
||||||
my @res = parse_fact ();
|
|
||||||
while ($token[0] eq '&')
|
|
||||||
{
|
|
||||||
eat ('&');
|
|
||||||
# Cartesian product.
|
|
||||||
my @lhs = @res;
|
|
||||||
@res = ();
|
|
||||||
for my $rhs (parse_fact ())
|
|
||||||
{
|
|
||||||
for my $lhs (@lhs)
|
|
||||||
{
|
|
||||||
push @res, $lhs . ($lhs && $rhs ? "\n" : "") . $rhs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return @res;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub parse_fact ()
|
|
||||||
{
|
|
||||||
my @res;
|
|
||||||
die "unexpected end of expression"
|
|
||||||
unless defined $token[0];
|
|
||||||
|
|
||||||
if ($token[0] eq '(')
|
|
||||||
{
|
|
||||||
eat ('(');
|
|
||||||
@res = parse_expr ();
|
|
||||||
eat (')');
|
|
||||||
}
|
|
||||||
elsif ($token[0] eq '[')
|
|
||||||
{
|
|
||||||
eat ('[');
|
|
||||||
@res = (parse_expr (), '');
|
|
||||||
eat (']');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
@res = parse_dirs ();
|
|
||||||
}
|
|
||||||
return @res;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub parse_dirs ()
|
|
||||||
{
|
|
||||||
my @res;
|
|
||||||
die "unexpected end of expression"
|
|
||||||
unless defined $token[0];
|
|
||||||
|
|
||||||
if ($token[0] eq '#d')
|
|
||||||
{
|
|
||||||
eat ('#d');
|
|
||||||
$token[0] =~ s/(.*?)=(.*)/$1 $2/;
|
|
||||||
@res = ("%code {\n#define $token[0]\n}");
|
|
||||||
shift @token;
|
|
||||||
}
|
|
||||||
elsif ($token[0] eq '%d')
|
|
||||||
{
|
|
||||||
shift @token;
|
|
||||||
$token[0] =~ s/(.*?)=(.*)/$1 "$2"/;
|
|
||||||
@res = ("%define $token[0]");
|
|
||||||
shift @token;
|
|
||||||
}
|
|
||||||
elsif ($token[0] eq '%s')
|
|
||||||
{
|
|
||||||
shift @token;
|
|
||||||
@res = ("%skeleton \"$token[0]\"");
|
|
||||||
shift @token;
|
|
||||||
}
|
|
||||||
elsif ($token[0] eq '%b')
|
|
||||||
{
|
|
||||||
shift @token;
|
|
||||||
@res = ("/*\n%bison \"$token[0]\"\\\n*/");
|
|
||||||
shift @token;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
@res = $token[0];
|
|
||||||
shift @token;
|
|
||||||
}
|
|
||||||
|
|
||||||
return @res;
|
|
||||||
}
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
sub getopt ()
|
|
||||||
{
|
|
||||||
use Getopt::Long;
|
|
||||||
my %option = (
|
|
||||||
"b|bench=s" => \$bench,
|
|
||||||
"c|cflags=s" => \$cflags,
|
|
||||||
"d|directive=s" => \@directive,
|
|
||||||
"g|grammar=s" => \$grammar,
|
|
||||||
"h|help" => sub { help ($verbose) },
|
|
||||||
"i|iterations=i" => \$iterations,
|
|
||||||
"q|quiet" => sub { --$verbose },
|
|
||||||
"v|verbose" => sub { ++$verbose },
|
|
||||||
);
|
|
||||||
Getopt::Long::Configure ("bundling", "pass_through");
|
|
||||||
GetOptions (%option)
|
|
||||||
or exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
getopt;
|
|
||||||
|
|
||||||
# Create the directory we work in.
|
|
||||||
mkdir "benches" or die "cannot create benches"
|
|
||||||
unless -d "benches";
|
|
||||||
my $count = 1;
|
|
||||||
++$count
|
|
||||||
while -d "benches/$count";
|
|
||||||
my $dir = "benches/$count";
|
|
||||||
mkdir $dir
|
|
||||||
or die "cannot create $dir";
|
|
||||||
chdir $dir
|
|
||||||
or die "cannot chdir $dir";
|
|
||||||
|
|
||||||
# The following message is tailored to please Emacs' compilation-mode.
|
|
||||||
verbose 1, "Entering directory `$dir'\n";
|
|
||||||
verbose 1, "Using bison=$bison.\n";
|
|
||||||
verbose 2, "Using cc=$cc.\n";
|
|
||||||
verbose 2, "Using cxx=$cxx.\n";
|
|
||||||
verbose 2, "Using cflags=$cflags.\n";
|
|
||||||
verbose 2, "Grammar: $grammar\n";
|
|
||||||
|
|
||||||
|
|
||||||
# Support -b: predefined benches.
|
|
||||||
my %bench =
|
|
||||||
(
|
|
||||||
"push" => \&bench_push_parser,
|
|
||||||
"variant" => \&bench_variant_parser,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (defined $bench)
|
|
||||||
{
|
|
||||||
die "invalid argument for --bench: $bench"
|
|
||||||
unless defined $bench{$bench};
|
|
||||||
&{$bench{$bench}}();
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
# Launch the bench marking.
|
|
||||||
bench ($grammar, @ARGV);
|
|
||||||
}
|
|
||||||
|
|
||||||
### Setup "GNU" style for perl-mode and cperl-mode.
|
### Setup "GNU" style for perl-mode and cperl-mode.
|
||||||
## Local Variables:
|
## Local Variables:
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
## Copyright (C) 2006, 2008-2013 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/>.
|
|
||||||
|
|
||||||
nodist_noinst_SCRIPTS = etc/bench.pl
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
/Makefile
|
||||||
|
/Makefile.in
|
||||||
Executable → Regular
+6
-31
@@ -1,7 +1,6 @@
|
|||||||
#! /bin/sh
|
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||||
|
## Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# Copyright (C) 2005-2013 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
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
@@ -15,32 +14,8 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
cat >input <<EOF
|
if BISON_CXX_WORKS
|
||||||
1 2 3 * +
|
SUBDIRS = calc++
|
||||||
EOF
|
endif
|
||||||
run 0 7
|
|
||||||
|
|
||||||
cat >input <<EOF
|
dist_noinst_SCRIPTS = extexi
|
||||||
1.1 2.2 3.3 * +
|
|
||||||
EOF
|
|
||||||
run 0 8.36
|
|
||||||
|
|
||||||
cat >input <<EOF
|
|
||||||
1 2 + 3 *
|
|
||||||
EOF
|
|
||||||
run 0 9
|
|
||||||
|
|
||||||
cat >input <<EOF
|
|
||||||
1 2 3 4 5 6 7 8 9 * * * * * * * *
|
|
||||||
EOF
|
|
||||||
run 0 362880
|
|
||||||
|
|
||||||
cat >input <<EOF
|
|
||||||
3 7 + 3 4 5 * + - n
|
|
||||||
EOF
|
|
||||||
run 0 13
|
|
||||||
|
|
||||||
cat >input <<EOF
|
|
||||||
3 4 ^
|
|
||||||
EOF
|
|
||||||
run 0 81
|
|
||||||
@@ -1,19 +1,13 @@
|
|||||||
|
/*.cc
|
||||||
|
/*.hh
|
||||||
|
/*.ll
|
||||||
/*.o
|
/*.o
|
||||||
|
/*.output
|
||||||
|
/*.stamp
|
||||||
/*.tmp
|
/*.tmp
|
||||||
|
/*.yy
|
||||||
/.deps
|
/.deps
|
||||||
|
/Makefile
|
||||||
|
/Makefile.in
|
||||||
/calc++
|
/calc++
|
||||||
/calc++-driver.cc
|
|
||||||
/calc++-driver.hh
|
|
||||||
/calc++-parser.cc
|
|
||||||
/calc++-parser.hh
|
|
||||||
/calc++-parser.output
|
|
||||||
/calc++-parser.stamp
|
|
||||||
/calc++-parser.yy
|
|
||||||
/calc++-scanner.cc
|
|
||||||
/calc++-scanner.ll
|
|
||||||
/calc++.cc
|
|
||||||
/calc++.exe
|
/calc++.exe
|
||||||
/calc.stamp
|
|
||||||
/location.hh
|
|
||||||
/position.hh
|
|
||||||
/stack.hh
|
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||||
|
## Copyright (C) 2005-2006, 2009-2013 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/>.
|
||||||
|
|
||||||
|
## ------------------------------------- ##
|
||||||
|
## Running the bison from this tarball. ##
|
||||||
|
## ------------------------------------- ##
|
||||||
|
|
||||||
|
BISON = $(top_builddir)/tests/bison
|
||||||
|
BISON_IN = $(top_srcdir)/tests/bison.in
|
||||||
|
|
||||||
|
$(BISON): $(BISON_IN)
|
||||||
|
$(AM_V_GEN)cd $(top_builddir)/tests && $(MAKE) $(AM_MAKEFLAGS) bison
|
||||||
|
|
||||||
|
## ------------ ##
|
||||||
|
## Extracting. ##
|
||||||
|
## ------------ ##
|
||||||
|
|
||||||
|
doc = $(top_srcdir)/doc/bison.texi
|
||||||
|
extexi = $(top_srcdir)/examples/extexi
|
||||||
|
# Extract in src.
|
||||||
|
$(srcdir)/calc.stamp: $(doc) $(extexi)
|
||||||
|
$(AM_V_GEN)rm -f $@ $@.tmp
|
||||||
|
$(AM_V_at)touch $@.tmp
|
||||||
|
$(AM_V_at)cd $(srcdir) && \
|
||||||
|
$(AWK) -f ../extexi -v VERSION="$(VERSION)" \
|
||||||
|
../../doc/bison.texi -- calc++-parser.yy \
|
||||||
|
calc++-scanner.ll calc++.cc calc++-driver.hh calc++-driver.cc
|
||||||
|
$(AM_V_at)mv $@.tmp $@
|
||||||
|
|
||||||
|
$(calc_extracted): $(srcdir)/calc.stamp
|
||||||
|
|
||||||
|
## ------------------- ##
|
||||||
|
## Parser generation. ##
|
||||||
|
## ------------------- ##
|
||||||
|
|
||||||
|
DEFAULT_INCLUDES = -I. -I$(srcdir)
|
||||||
|
BUILT_SOURCES = $(calc_extracted) $(calc_sources_generated)
|
||||||
|
CLEANFILES = $(srcdir)/*.output *.tmp
|
||||||
|
MAINTAINERCLEANFILES = $(srcdir)/*.stamp $(BUILT_SOURCES)
|
||||||
|
|
||||||
|
# Compile the parser and save cycles.
|
||||||
|
# This code comes from "Handling Tools that Produce Many Outputs",
|
||||||
|
# from the Automake documentation.
|
||||||
|
EXTRA_DIST = \
|
||||||
|
$(srcdir)/calc++-parser.stamp \
|
||||||
|
$(srcdir)/calc++-parser.yy \
|
||||||
|
$(srcdir)/calc.stamp
|
||||||
|
# Don't depend on $(BISON) otherwise we would rebuild these files
|
||||||
|
# in srcdir, including during distcheck, which is forbidden.
|
||||||
|
$(srcdir)/calc++-parser.stamp: $(srcdir)/calc++-parser.yy $(BISON_IN)
|
||||||
|
$(AM_V_GEN)rm -f calc++-parser.tmp
|
||||||
|
$(AM_V_at)touch calc++-parser.tmp
|
||||||
|
$(AM_V_at)$(BISON) -d -ra -S lalr1.cc -o $(srcdir)/calc++-parser.cc \
|
||||||
|
$(srcdir)/calc++-parser.yy
|
||||||
|
$(AM_V_at)mv -f calc++-parser.tmp $@
|
||||||
|
|
||||||
|
$(calc_sources_generated): $(srcdir)/calc++-parser.stamp
|
||||||
|
$(AM_V_GEN)if test -f $@; then :; else \
|
||||||
|
rm -f $(srcdir)/calc++-parser.stamp && \
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS) $(srcdir)/calc++-parser.stamp; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
## --------------------------- ##
|
||||||
|
## Building & testing calc++. ##
|
||||||
|
## --------------------------- ##
|
||||||
|
|
||||||
|
check_PROGRAMS = calc++
|
||||||
|
|
||||||
|
calc_sources_extracted = $(srcdir)/calc++-scanner.ll $(srcdir)/calc++.cc \
|
||||||
|
$(srcdir)/calc++-driver.hh $(srcdir)/calc++-driver.cc
|
||||||
|
calc_extracted = $(calc_sources_extracted) $(srcdir)/calc++-parser.yy
|
||||||
|
calc_sources_generated = \
|
||||||
|
$(srcdir)/stack.hh $(srcdir)/position.hh $(srcdir)/location.hh \
|
||||||
|
$(srcdir)/calc++-parser.hh $(srcdir)/calc++-parser.cc
|
||||||
|
|
||||||
|
calc___SOURCES = $(calc_sources_extracted) $(calc_sources_generated)
|
||||||
|
|
||||||
|
TESTS = test
|
||||||
|
EXTRA_DIST += $(TESTS)
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
# Copyright (C) 2005-2006, 2008-2013 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/>.
|
|
||||||
|
|
||||||
## ------------------- ##
|
|
||||||
## Parser generation. ##
|
|
||||||
## ------------------- ##
|
|
||||||
|
|
||||||
# Don't depend on $(BISON) otherwise we would rebuild these files
|
|
||||||
# in srcdir, including during distcheck, which is forbidden.
|
|
||||||
examples/calc++/calc++-parser.stamp: $(BISON_IN)
|
|
||||||
SUFFIXES += .yy .stamp
|
|
||||||
.yy.stamp:
|
|
||||||
$(AM_V_YACC)rm -f $@
|
|
||||||
$(AM_V_at)touch $@.tmp
|
|
||||||
$(AM_V_at)$(YACCCOMPILE) -o $*.cc $<
|
|
||||||
$(AM_V_at)mv -f $@.tmp $@
|
|
||||||
|
|
||||||
$(calc_sources_generated): examples/calc++/calc++-parser.stamp
|
|
||||||
@test -f $@ || rm -f examples/calc++/calc++-parser.stamp
|
|
||||||
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) examples/calc++/calc++-parser.stamp
|
|
||||||
CLEANFILES += \
|
|
||||||
$(calc_sources_generated) \
|
|
||||||
examples/calc++/calc++-parser.output \
|
|
||||||
examples/calc++/calc++-parser.stamp \
|
|
||||||
examples/calc++/calc++-scanner.cc
|
|
||||||
|
|
||||||
|
|
||||||
## -------------------- ##
|
|
||||||
## Building & testing. ##
|
|
||||||
## -------------------- ##
|
|
||||||
|
|
||||||
# Avoid using BUILT_SOURCES which is too global.
|
|
||||||
$(examples_calc___calc___OBJECTS): $(calc_sources_generated)
|
|
||||||
|
|
||||||
calc_sources_extracted = \
|
|
||||||
examples/calc++/calc++-driver.cc \
|
|
||||||
examples/calc++/calc++-driver.hh \
|
|
||||||
examples/calc++/calc++-scanner.ll \
|
|
||||||
examples/calc++/calc++.cc
|
|
||||||
calc_extracted = \
|
|
||||||
$(calc_sources_extracted) \
|
|
||||||
examples/calc++/calc++-parser.yy
|
|
||||||
extracted += $(calc_extracted)
|
|
||||||
calc_sources_generated = \
|
|
||||||
examples/calc++/calc++-parser.cc \
|
|
||||||
examples/calc++/calc++-parser.hh \
|
|
||||||
examples/calc++/location.hh \
|
|
||||||
examples/calc++/position.hh \
|
|
||||||
examples/calc++/stack.hh
|
|
||||||
calc_sources = \
|
|
||||||
$(calc_sources_extracted) \
|
|
||||||
$(calc_sources_generated)
|
|
||||||
|
|
||||||
if BISON_CXX_WORKS
|
|
||||||
check_PROGRAMS += examples/calc++/calc++
|
|
||||||
nodist_examples_calc___calc___SOURCES = \
|
|
||||||
$(calc_sources)
|
|
||||||
|
|
||||||
examples_calc___calc___CPPFLAGS = -I$(top_builddir)/examples/calc++
|
|
||||||
examples_calc___calc___CXXFLAGS = \
|
|
||||||
$(AM_CXXFLAGS) $(WARN_NO_NULL_CONVERSION_CXXFLAGS)
|
|
||||||
dist_TESTS += examples/calc++/calc++.test
|
|
||||||
endif
|
|
||||||
@@ -15,36 +15,32 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
|
test -z "$VERBOSE" && {
|
||||||
|
exec > /dev/null 2>&1
|
||||||
|
set -x
|
||||||
|
}
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
a := 1
|
||||||
|
b := 2
|
||||||
|
c := 3
|
||||||
|
d := a + b * c
|
||||||
|
d
|
||||||
|
EOF
|
||||||
|
|
||||||
|
./calc++ input
|
||||||
|
./calc++ -p input
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
a := 1
|
||||||
|
d := a + b * c
|
||||||
|
EOF
|
||||||
|
./calc++ input
|
||||||
|
|
||||||
cat >input <<EOF
|
cat >input <<EOF
|
||||||
toto := 1
|
toto := 1
|
||||||
toto
|
toto
|
||||||
EOF
|
EOF
|
||||||
run 0 1 -s
|
./calc++ -s input
|
||||||
|
|
||||||
|
rm input
|
||||||
cat >input <<EOF
|
|
||||||
a := 1
|
|
||||||
b := 2
|
|
||||||
c := 3
|
|
||||||
d := a + b * c
|
|
||||||
d
|
|
||||||
EOF
|
|
||||||
run 0 7
|
|
||||||
run 0 7 -p
|
|
||||||
|
|
||||||
|
|
||||||
cat >input <<EOF
|
|
||||||
a := 1
|
|
||||||
b := 2
|
|
||||||
c := 3
|
|
||||||
d := (a + b) * c
|
|
||||||
d
|
|
||||||
EOF
|
|
||||||
run 0 9
|
|
||||||
|
|
||||||
|
|
||||||
cat >input <<EOF
|
|
||||||
a := 1
|
|
||||||
d := a + b * c
|
|
||||||
EOF
|
|
||||||
run 1 ''
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
// Work around an Automake 1.11.2 bug: it asks for the creation of
|
|
||||||
// y.tab.c and y.tab.h and then renames them as calc++-parser.cc and
|
|
||||||
// calc++-parser.h, but in the former it does not convert the
|
|
||||||
// #include "y.tab.h". We don't want this to show in the
|
|
||||||
// documentation.
|
|
||||||
#include "calc++-parser.hh"
|
|
||||||
Executable → Regular
+98
-131
@@ -1,5 +1,4 @@
|
|||||||
#! /usr/bin/perl -w
|
# Extract all examples from the manual source. -*- AWK -*-
|
||||||
# Extract all examples from the manual source.
|
|
||||||
|
|
||||||
# This file is part of GNU Bison
|
# This file is part of GNU Bison
|
||||||
|
|
||||||
@@ -19,154 +18,122 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
|
# This script is for use with any Awk that conforms to POSIX.
|
||||||
|
# It was derived from a similar script tests/generate.awk in GNU m4.
|
||||||
|
#
|
||||||
# Usage: extexi input-file.texi ... -- [FILES to extract]
|
# Usage: extexi input-file.texi ... -- [FILES to extract]
|
||||||
|
BEGIN {
|
||||||
# Look for @example environments preceded with lines such as:
|
if (!output_dir)
|
||||||
#
|
output_dir = ".";
|
||||||
# @comment file calc.y
|
for (argc = 1; argc < ARGC; ++argc)
|
||||||
# or
|
if (ARGV[argc] == "--")
|
||||||
# @comment file calc.y: 3
|
break;
|
||||||
#
|
for (i = argc + 1; i < ARGC; ++i)
|
||||||
# and output their content in that file (calc.y). When numbers are
|
file_wanted[ARGV[i]] = 1;
|
||||||
# provided, use them to decide the output order (block numbered 1 is
|
ARGC = argc;
|
||||||
# output before block 2, even if the latter appears before). The same
|
|
||||||
# number may be used several time, in which case the order of
|
|
||||||
# appearance is used.
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
# normalize($block)
|
|
||||||
# -----------------
|
|
||||||
# Remove Texinfo mark up.
|
|
||||||
sub normalize($)
|
|
||||||
{
|
|
||||||
local ($_) = @_;
|
|
||||||
|
|
||||||
s/^\@(c |comment|dots|end (ignore|group)|ignore|group).*//mg;
|
|
||||||
s/\@value\{VERSION\}/$ENV{VERSION}/g;
|
|
||||||
s/^\@(error|result)\{\}//mg;
|
|
||||||
s/\@([{}@])/$1/g;
|
|
||||||
s/\@comment.*//;
|
|
||||||
$_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print messages only once.
|
/^@node / {
|
||||||
my %msg;
|
if (seq > 0)
|
||||||
sub message($)
|
print "AT_CLEANUP";
|
||||||
{
|
|
||||||
my ($msg) = @_;
|
split ($0, tmp, ",");
|
||||||
if (! $msg{$msg})
|
node = substr(tmp[1], 7);
|
||||||
{
|
seq = 0;
|
||||||
print STDERR "extexi: $msg\n";
|
|
||||||
$msg{$msg} = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# basename => full file name for files we should extract.
|
/^@comment file: / {
|
||||||
my %file_wanted;
|
if (!file_wanted[$3])
|
||||||
|
message("ignoring " $3);
|
||||||
sub process ($)
|
|
||||||
{
|
|
||||||
my ($in) = @_;
|
|
||||||
use IO::File;
|
|
||||||
my $f = new IO::File($in)
|
|
||||||
or die "$in: cannot open: $?";
|
|
||||||
# FILE-NAME => { BLOCK-NUM => CODE }
|
|
||||||
my %file;
|
|
||||||
|
|
||||||
# The latest "@comment file: FILE [BLOCK-NUM]" arguments.
|
|
||||||
my $file;
|
|
||||||
my $block;
|
|
||||||
# The @example block currently read.
|
|
||||||
my $input;
|
|
||||||
local $_;
|
|
||||||
while (<$f>)
|
|
||||||
{
|
|
||||||
if (/^\@comment file: ([^:\n]+)(?::\s*(\d+))?$/)
|
|
||||||
{
|
|
||||||
my $f = $1;
|
|
||||||
$block = $2 || 1;
|
|
||||||
if ($file_wanted{$f})
|
|
||||||
{
|
|
||||||
$file = $file_wanted{$f};
|
|
||||||
message(" GEN $file");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message("SKIP $f");
|
message("extracting " $3);
|
||||||
|
file = $3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ($file && /^\@(small)?example$/ .. /^\@end (small)?example$/)
|
|
||||||
|
/^@example$/, /^@end example$/ {
|
||||||
|
if (!file)
|
||||||
|
next;
|
||||||
|
|
||||||
|
if ($0 ~ /^@example$/)
|
||||||
{
|
{
|
||||||
if (/^\@(small)?example$/)
|
input = files_output[file] ? "\n" : "";
|
||||||
{
|
|
||||||
# Bison supports synclines, but not Flex.
|
# FNR is starting at 0 instead of 1, and
|
||||||
$input .= sprintf ("#line %s \"$in\"\n", $. + 1)
|
# #line report the line number of the *next* line.
|
||||||
if $file =~ /\.[chy]*$/;
|
# => + 2.
|
||||||
|
# Note that recent Bison support it, but not Flex.
|
||||||
|
if (file ~ /\.[chy]*$/)
|
||||||
|
input = "#line " (FNR + 1) " \"" FILENAME "\"\n";
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif (/^\@end (small)?example$/)
|
|
||||||
{
|
|
||||||
die "no contents: $file"
|
|
||||||
if $input eq "";
|
|
||||||
|
|
||||||
$file{$file}{$block} .= normalize($input);
|
if ($0 ~ /^@end example$/)
|
||||||
$file = $input = undef;
|
|
||||||
++$block;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
$input .= $_;
|
if (input == "")
|
||||||
}
|
fatal("no contents: " file);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Output the files.
|
input = normalize(input);
|
||||||
for my $file (keys %file)
|
|
||||||
{
|
|
||||||
# No spurious end of line: use printf.
|
# No spurious end of line: use printf.
|
||||||
my $o = new IO::File(">$file")
|
if (files_output[file])
|
||||||
or die "$file: cannot create: $?";
|
# The parens around the output file seem to be required
|
||||||
print $o $file{$file}{$_}
|
# by awk on Mac OS X Tiger (darwin 8.4.6).
|
||||||
for sort keys %{$file{$file}};
|
printf ("%s", input) >> (output_dir "/" file);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
my @input;
|
|
||||||
my $seen_dash = 0;
|
|
||||||
for my $arg (@ARGV)
|
|
||||||
{
|
|
||||||
if ($arg eq '--')
|
|
||||||
{
|
|
||||||
$seen_dash = 1;
|
|
||||||
}
|
|
||||||
elsif ($seen_dash)
|
|
||||||
{
|
|
||||||
use File::Basename;
|
|
||||||
$file_wanted{basename($arg)} = $arg;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
printf ("%s", input) > (output_dir "/" file);
|
||||||
|
close (output_dir "/" file);
|
||||||
|
files_output[file] = 1;
|
||||||
|
|
||||||
|
file = input = "";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
input = input $0 "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# We have to handle CONTENTS line per line, since anchors in AWK are
|
||||||
|
# referring to the whole string, not the lines.
|
||||||
|
function normalize(contents, i, lines, n, line, res) {
|
||||||
|
# Remove the Texinfo tags.
|
||||||
|
n = split (contents, lines, "\n");
|
||||||
|
# We don't want the last field which empty: it's behind the last \n.
|
||||||
|
for (i = 1; i < n; ++i)
|
||||||
{
|
{
|
||||||
push @input, $arg;
|
line = lines[i];
|
||||||
|
|
||||||
|
# Whole line commands.
|
||||||
|
if (line ~ /^@(c |comment|dots|end (ignore|group)|ignore|group)/)
|
||||||
|
# Gperf accepts empty lines as valid input!!!
|
||||||
|
if (file ~ /\.gperf$/)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
line = "";
|
||||||
|
|
||||||
|
gsub (/"@value\{VERSION\}"/, "\"" VERSION "\"", line)
|
||||||
|
gsub (/^@result\{\}/, "", line);
|
||||||
|
gsub (/^@error\{\}/, "", line);
|
||||||
|
gsub ("@[{]", "{", line);
|
||||||
|
gsub ("@}", "}", line);
|
||||||
|
gsub ("@@", "@", line);
|
||||||
|
gsub ("@comment.*", "", line);
|
||||||
|
|
||||||
|
res = res line "\n";
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
process $_
|
|
||||||
foreach @input;
|
|
||||||
|
|
||||||
|
|
||||||
### Setup "GNU" style for perl-mode and cperl-mode.
|
function message(msg) {
|
||||||
## Local Variables:
|
if (! message_printed[msg])
|
||||||
## perl-indent-level: 2
|
{
|
||||||
## perl-continued-statement-offset: 2
|
print "extexi: " msg > "/dev/stderr";
|
||||||
## perl-continued-brace-offset: 0
|
message_printed[msg] = 1;
|
||||||
## perl-brace-offset: 0
|
}
|
||||||
## perl-brace-imaginary-offset: 0
|
}
|
||||||
## perl-label-offset: -2
|
|
||||||
## cperl-indent-level: 2
|
function fatal(msg) {
|
||||||
## cperl-brace-offset: 0
|
message(msg);
|
||||||
## cperl-continued-brace-offset: 0
|
exit 1
|
||||||
## cperl-label-offset: -2
|
}
|
||||||
## cperl-extra-newline-before-brace: t
|
|
||||||
## cperl-merge-trailing-else: nil
|
|
||||||
## cperl-continued-statement-offset: 2
|
|
||||||
## End:
|
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
# Copyright (C) 2005, 2008-2013 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/>.
|
|
||||||
|
|
||||||
dist_noinst_SCRIPTS = examples/extexi examples/test
|
|
||||||
TEST_LOG_COMPILER = $(top_srcdir)/examples/test
|
|
||||||
|
|
||||||
AM_CXXFLAGS = \
|
|
||||||
$(NO_STRICT_ALIAS_CXXFLAGS) \
|
|
||||||
$(WARN_CXXFLAGS) $(WARN_CXXFLAGS_TEST) $(WERROR_CXXFLAGS)
|
|
||||||
|
|
||||||
## ------------ ##
|
|
||||||
## Extracting. ##
|
|
||||||
## ------------ ##
|
|
||||||
|
|
||||||
doc = $(top_srcdir)/doc/bison.texi
|
|
||||||
extexi = $(top_srcdir)/examples/extexi
|
|
||||||
extract = VERSION="$(VERSION)" $(PERL) -f $(extexi) $(doc) --
|
|
||||||
extracted =
|
|
||||||
CLEANFILES += $(extracted) examples/extracted.stamp
|
|
||||||
examples/extracted.stamp: $(doc) $(extexi)
|
|
||||||
$(AM_V_GEN)rm -f $@ $@.tmp
|
|
||||||
$(AM_V_at)touch $@.tmp
|
|
||||||
$(AM_V_at)$(extract) $(extracted)
|
|
||||||
$(AM_V_at)mv $@.tmp $@
|
|
||||||
|
|
||||||
$(extracted): examples/extracted.stamp
|
|
||||||
@test -f $@ || rm -f examples/extracted.stamp
|
|
||||||
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) examples/extracted.stamp
|
|
||||||
|
|
||||||
include examples/calc++/local.mk
|
|
||||||
include examples/mfcalc/local.mk
|
|
||||||
include examples/rpcalc/local.mk
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/*.o
|
|
||||||
/*.tmp
|
|
||||||
/.deps
|
|
||||||
/calc.h
|
|
||||||
/mfcalc
|
|
||||||
/mfcalc.c
|
|
||||||
/mfcalc.exe
|
|
||||||
/mfcalc.h
|
|
||||||
/mfcalc.output
|
|
||||||
/mfcalc.stamp
|
|
||||||
/mfcalc.y
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# Copyright (C) 2005-2006, 2008-2013 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/>.
|
|
||||||
|
|
||||||
## -------------------- ##
|
|
||||||
## Building & testing. ##
|
|
||||||
## -------------------- ##
|
|
||||||
|
|
||||||
BUILT_SOURCES += $(mfcalc_sources)
|
|
||||||
CLEANFILES += examples/mfcalc/mfcalc.[ch] examples/mfcalc/mfcalc.output
|
|
||||||
|
|
||||||
mfcalc_extracted = \
|
|
||||||
examples/mfcalc/calc.h \
|
|
||||||
examples/mfcalc/mfcalc.y
|
|
||||||
mfcalc_sources = \
|
|
||||||
$(mfcalc_extracted)
|
|
||||||
extracted += $(mfcalc_extracted)
|
|
||||||
|
|
||||||
check_PROGRAMS += examples/mfcalc/mfcalc
|
|
||||||
examples_mfcalc_mfcalc_LDADD = -lm
|
|
||||||
nodist_examples_mfcalc_mfcalc_SOURCES = \
|
|
||||||
$(mfcalc_sources)
|
|
||||||
|
|
||||||
examples_mfcalc_mfcalc_CPPFLAGS = -I$(top_builddir)/examples/mfcalc
|
|
||||||
dist_TESTS += examples/mfcalc/mfcalc.test
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
/calc.h
|
|
||||||
/rpcalc.c
|
|
||||||
/rpcalc.h
|
|
||||||
/rpcalc.output
|
|
||||||
/rpcalc.stamp
|
|
||||||
/rpcalc.y
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
# Copyright (C) 2005-2006, 2008-2013 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/>.
|
|
||||||
|
|
||||||
## -------------------- ##
|
|
||||||
## Building & testing. ##
|
|
||||||
## -------------------- ##
|
|
||||||
|
|
||||||
BUILT_SOURCES += $(rpcalc_sources)
|
|
||||||
CLEANFILES += examples/rpcalc/rpcalc.[ch] examples/rpcalc/rpcalc.output
|
|
||||||
|
|
||||||
rpcalc_extracted = \
|
|
||||||
examples/rpcalc/rpcalc.y
|
|
||||||
rpcalc_sources = \
|
|
||||||
$(rpcalc_extracted)
|
|
||||||
extracted += $(rpcalc_extracted)
|
|
||||||
|
|
||||||
check_PROGRAMS += examples/rpcalc/rpcalc
|
|
||||||
examples_rpcalc_rpcalc_LDADD = -lm
|
|
||||||
nodist_examples_rpcalc_rpcalc_SOURCES = \
|
|
||||||
$(rpcalc_sources)
|
|
||||||
|
|
||||||
examples_rpcalc_rpcalc_CPPFLAGS = -I$(top_builddir)/examples/rpcalc
|
|
||||||
dist_TESTS += examples/rpcalc/rpcalc.test
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
|
|
||||||
# Copyright (C) 2005-2013 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/>.
|
|
||||||
|
|
||||||
me=`basename $1 .test`
|
|
||||||
|
|
||||||
# Number of the current test.
|
|
||||||
number=1
|
|
||||||
|
|
||||||
# Exit status of this script.
|
|
||||||
exit=true
|
|
||||||
|
|
||||||
# top_buiddir.
|
|
||||||
cwd=`pwd`
|
|
||||||
|
|
||||||
# The exercised program.
|
|
||||||
prog=$cwd/examples/$me/$me
|
|
||||||
|
|
||||||
# cleanup
|
|
||||||
# -------
|
|
||||||
cleanup ()
|
|
||||||
{
|
|
||||||
local status=$?
|
|
||||||
if test -z "$DEBUG"; then
|
|
||||||
cd $cwd
|
|
||||||
rm -rf $$.dir
|
|
||||||
fi
|
|
||||||
exit $status
|
|
||||||
}
|
|
||||||
trap cleanup 0 1 2 13 15
|
|
||||||
mkdir $$.dir
|
|
||||||
cd $$.dir
|
|
||||||
|
|
||||||
# run EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS]
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
run ()
|
|
||||||
{
|
|
||||||
# Expected exit status.
|
|
||||||
local sta_exp=$1
|
|
||||||
shift
|
|
||||||
# Expected output.
|
|
||||||
local out_exp=$1
|
|
||||||
shift
|
|
||||||
# Effective exit status.
|
|
||||||
local sta_eff=0
|
|
||||||
$prog "$@" - <input >out_eff || sta_eff=$?
|
|
||||||
# Effective output.
|
|
||||||
local out_eff=`cat out_eff`
|
|
||||||
if test $sta_eff -eq $sta_exp; then
|
|
||||||
if test "$out_eff" = "$out_exp"; then
|
|
||||||
echo "$me: PASS: $number"
|
|
||||||
else
|
|
||||||
echo "$me: FAIL: $number (expected output: $out_exp, effective: $out_eff)"
|
|
||||||
exit=false
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "$me: FAIL: $number (expected status: $sta_exp, effective: $sta_eff)"
|
|
||||||
exit=false
|
|
||||||
fi
|
|
||||||
number=`expr $number + 1`
|
|
||||||
}
|
|
||||||
|
|
||||||
# We have cd'd one level deeper.
|
|
||||||
case $1 in
|
|
||||||
/*) . "$1";;
|
|
||||||
*) . "../$1";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
$exit
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2008-2013 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
%debug
|
|
||||||
%skeleton "lalr1.cc"
|
|
||||||
%defines
|
|
||||||
%define api.token.constructor
|
|
||||||
%define api.value.type variant
|
|
||||||
%define parse.assert
|
|
||||||
%locations
|
|
||||||
|
|
||||||
%code requires // *.hh
|
|
||||||
{
|
|
||||||
#include <list>
|
|
||||||
#include <string>
|
|
||||||
typedef std::list<std::string> strings_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
%code // *.cc
|
|
||||||
{
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <iterator>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
// Prototype of the yylex function providing subsequent tokens.
|
|
||||||
namespace yy
|
|
||||||
{
|
|
||||||
static parser::symbol_type yylex ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Printing a list of strings.
|
|
||||||
// Koening look up will look into std, since that's an std::list.
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
std::ostream&
|
|
||||||
operator<< (std::ostream& o, const strings_type& s)
|
|
||||||
{
|
|
||||||
std::copy (s.begin (), s.end (),
|
|
||||||
std::ostream_iterator<strings_type::value_type> (o, "\n"));
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Conversion to string.
|
|
||||||
template <typename T>
|
|
||||||
inline
|
|
||||||
std::string
|
|
||||||
string_cast (const T& t)
|
|
||||||
{
|
|
||||||
std::ostringstream o;
|
|
||||||
o << t;
|
|
||||||
return o.str ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
%token <::std::string> TEXT;
|
|
||||||
%token <int> NUMBER;
|
|
||||||
%printer { yyoutput << $$; } <*>;
|
|
||||||
%token END_OF_FILE 0;
|
|
||||||
|
|
||||||
%type <::std::string> item;
|
|
||||||
%type <::std::list<std::string>> list;
|
|
||||||
|
|
||||||
%%
|
|
||||||
|
|
||||||
result:
|
|
||||||
list { std::cout << $1 << std::endl; }
|
|
||||||
;
|
|
||||||
|
|
||||||
list:
|
|
||||||
/* nothing */ { /* Generates an empty string list */ }
|
|
||||||
| list item { std::swap ($$, $1); $$.push_back ($2); }
|
|
||||||
;
|
|
||||||
|
|
||||||
item:
|
|
||||||
TEXT { std::swap ($$, $1); }
|
|
||||||
| NUMBER { $$ = string_cast ($1); }
|
|
||||||
;
|
|
||||||
%%
|
|
||||||
|
|
||||||
namespace yy
|
|
||||||
{
|
|
||||||
// The yylex function providing subsequent tokens:
|
|
||||||
// TEXT "I have three numbers for you."
|
|
||||||
// NUMBER 1
|
|
||||||
// NUMBER 2
|
|
||||||
// NUMBER 3
|
|
||||||
// TEXT "And that's all!"
|
|
||||||
// END_OF_FILE
|
|
||||||
|
|
||||||
static
|
|
||||||
parser::symbol_type
|
|
||||||
yylex ()
|
|
||||||
{
|
|
||||||
static int stage = -1;
|
|
||||||
++stage;
|
|
||||||
parser::location_type loc(0, stage + 1, stage + 1);
|
|
||||||
switch (stage)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return parser::make_TEXT ("I have three numbers for you.", loc);
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
return parser::make_NUMBER (stage, loc);
|
|
||||||
case 4:
|
|
||||||
return parser::make_TEXT ("And that's all!", loc);
|
|
||||||
default:
|
|
||||||
return parser::make_END_OF_FILE (loc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mandatory error function
|
|
||||||
void
|
|
||||||
parser::error (const parser::location_type& loc, const std::string& msg)
|
|
||||||
{
|
|
||||||
std::cerr << loc << ": " << msg << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main ()
|
|
||||||
{
|
|
||||||
yy::parser p;
|
|
||||||
p.set_debug_level (!!getenv ("YYDEBUG"));
|
|
||||||
return p.parse ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Local Variables:
|
|
||||||
// mode: C++
|
|
||||||
// End:
|
|
||||||
+1
-1
Submodule gnulib updated: c67e3c0414...076ac82d1d
+15
-8
@@ -35,8 +35,6 @@
|
|||||||
/close.c
|
/close.c
|
||||||
/closeout.c
|
/closeout.c
|
||||||
/closeout.h
|
/closeout.h
|
||||||
/concat-filename.c
|
|
||||||
/concat-filename.h
|
|
||||||
/config.charset
|
/config.charset
|
||||||
/config.h
|
/config.h
|
||||||
/config.in.h
|
/config.in.h
|
||||||
@@ -64,7 +62,6 @@
|
|||||||
/fd-hook.h
|
/fd-hook.h
|
||||||
/fd-safer-flag.c
|
/fd-safer-flag.c
|
||||||
/fd-safer.c
|
/fd-safer.c
|
||||||
/filename.h
|
|
||||||
/float+.h
|
/float+.h
|
||||||
/float.c
|
/float.c
|
||||||
/float.h
|
/float.h
|
||||||
@@ -101,6 +98,7 @@
|
|||||||
/isnanf.c
|
/isnanf.c
|
||||||
/isnanl-nolibm.h
|
/isnanl-nolibm.h
|
||||||
/isnanl.c
|
/isnanl.c
|
||||||
|
/iswblank.c
|
||||||
/itold.c
|
/itold.c
|
||||||
/ldexpl.c
|
/ldexpl.c
|
||||||
/localcharset.c
|
/localcharset.c
|
||||||
@@ -108,10 +106,15 @@
|
|||||||
/malloc.c
|
/malloc.c
|
||||||
/math.h
|
/math.h
|
||||||
/math.in.h
|
/math.in.h
|
||||||
|
/mbchar.c
|
||||||
|
/mbchar.h
|
||||||
/mbrtowc.c
|
/mbrtowc.c
|
||||||
|
/mbschr.c
|
||||||
/mbsinit.c
|
/mbsinit.c
|
||||||
|
/mbsrchr.c
|
||||||
/mbswidth.c
|
/mbswidth.c
|
||||||
/mbswidth.h
|
/mbswidth.h
|
||||||
|
/mbuiter.h
|
||||||
/memchr.c
|
/memchr.c
|
||||||
/memchr.valgrind
|
/memchr.valgrind
|
||||||
/msvc-inval.c
|
/msvc-inval.c
|
||||||
@@ -122,7 +125,6 @@
|
|||||||
/nonblocking.h
|
/nonblocking.h
|
||||||
/obstack.c
|
/obstack.c
|
||||||
/obstack.h
|
/obstack.h
|
||||||
/obstack_printf.c
|
|
||||||
/open.c
|
/open.c
|
||||||
/pathmax.h
|
/pathmax.h
|
||||||
/perror.c
|
/perror.c
|
||||||
@@ -211,6 +213,8 @@
|
|||||||
/stripslash.c
|
/stripslash.c
|
||||||
/strndup.c
|
/strndup.c
|
||||||
/strnlen.c
|
/strnlen.c
|
||||||
|
/strnlen1.c
|
||||||
|
/strnlen1.h
|
||||||
/strtol.c
|
/strtol.c
|
||||||
/strtoul.c
|
/strtoul.c
|
||||||
/strverscmp.c
|
/strverscmp.c
|
||||||
@@ -221,7 +225,6 @@
|
|||||||
/sys_socket.in.h
|
/sys_socket.in.h
|
||||||
/sys_stat.h
|
/sys_stat.h
|
||||||
/sys_stat.in.h
|
/sys_stat.in.h
|
||||||
/sys_types.in.h
|
|
||||||
/sys_wait.h
|
/sys_wait.h
|
||||||
/sys_wait.in.h
|
/sys_wait.in.h
|
||||||
/sysexits.in.h
|
/sysexits.in.h
|
||||||
@@ -258,17 +261,21 @@
|
|||||||
/xalloc-die.c
|
/xalloc-die.c
|
||||||
/xalloc-oversized.h
|
/xalloc-oversized.h
|
||||||
/xalloc.h
|
/xalloc.h
|
||||||
/xconcat-filename.c
|
|
||||||
/xmalloc.c
|
/xmalloc.c
|
||||||
/xmemdup0.c
|
|
||||||
/xmemdup0.h
|
|
||||||
/xsize.h
|
/xsize.h
|
||||||
/xstrndup.c
|
/xstrndup.c
|
||||||
/xstrndup.h
|
/xstrndup.h
|
||||||
|
/xmemdup0.c
|
||||||
|
/xmemdup0.h
|
||||||
|
/sys_types.in.h
|
||||||
|
/obstack_printf.c
|
||||||
/binary-io.c
|
/binary-io.c
|
||||||
|
/mbuiter.c
|
||||||
/xsize.c
|
/xsize.c
|
||||||
/bitrotate.c
|
/bitrotate.c
|
||||||
/math.c
|
/math.c
|
||||||
/sig-handler.c
|
/sig-handler.c
|
||||||
/unistd.c
|
/unistd.c
|
||||||
/wctype-h.c
|
/wctype-h.c
|
||||||
|
/getdelim.c
|
||||||
|
/getline.c
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Make bison/lib.
|
||||||
|
|
||||||
|
# Copyright (C) 2001-2004, 2006, 2008-2013 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/>.
|
||||||
|
|
||||||
|
AM_CFLAGS =
|
||||||
|
AM_CPPFLAGS =
|
||||||
|
BUILT_SOURCES =
|
||||||
|
CLEANFILES =
|
||||||
|
EXTRA_DIST =
|
||||||
|
MOSTLYCLEANDIRS =
|
||||||
|
MOSTLYCLEANFILES =
|
||||||
|
SUFFIXES =
|
||||||
|
noinst_LIBRARIES =
|
||||||
|
|
||||||
|
include gnulib.mk
|
||||||
|
|
||||||
|
AM_CFLAGS += $(WARN_CFLAGS)
|
||||||
|
|
||||||
|
# Implementation of bitsets.
|
||||||
|
bitsets_sources = \
|
||||||
|
abitset.c abitset.h bbitset.h bitset.c bitset.h bitset_stats.c \
|
||||||
|
bitset_stats.h bitsetv.c bitsetv.h ebitset.c ebitset.h lbitset.c \
|
||||||
|
lbitset.h libiberty.h vbitset.c vbitset.h
|
||||||
|
|
||||||
|
# Additional bitset operations.
|
||||||
|
additional_bitsets_sources = \
|
||||||
|
bitsetv-print.h bitsetv-print.c
|
||||||
|
|
||||||
|
# timevars, stolen from GCC.
|
||||||
|
timevars_sources = \
|
||||||
|
timevar.h timevar.c timevar.def
|
||||||
|
|
||||||
|
# Non-gnulib sources in Bison's internal library.
|
||||||
|
libbison_a_SOURCES += \
|
||||||
|
get-errno.h get-errno.c \
|
||||||
|
$(bitsets_sources) $(additional_bitsets_sources) $(timevars_sources)
|
||||||
|
|
||||||
|
# The Yacc compatibility library.
|
||||||
|
lib_LIBRARIES = $(YACC_LIBRARY)
|
||||||
|
EXTRA_LIBRARIES = liby.a
|
||||||
|
liby_a_SOURCES = main.c yyerror.c
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
# Copyright (C) 2001-2013 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/>.
|
|
||||||
|
|
||||||
include lib/gnulib.mk
|
|
||||||
|
|
||||||
# Implementation of bitsets.
|
|
||||||
lib_libbison_a_SOURCES += \
|
|
||||||
lib/abitset.c \
|
|
||||||
lib/abitset.h \
|
|
||||||
lib/bbitset.h \
|
|
||||||
lib/bitset.c \
|
|
||||||
lib/bitset.h \
|
|
||||||
lib/bitset_stats.c \
|
|
||||||
lib/bitset_stats.h \
|
|
||||||
lib/bitsetv.c \
|
|
||||||
lib/bitsetv.h \
|
|
||||||
lib/ebitset.c \
|
|
||||||
lib/ebitset.h \
|
|
||||||
lib/lbitset.c \
|
|
||||||
lib/lbitset.h \
|
|
||||||
lib/libiberty.h \
|
|
||||||
lib/vbitset.c \
|
|
||||||
lib/vbitset.h
|
|
||||||
|
|
||||||
# Additional bitset operations.
|
|
||||||
lib_libbison_a_SOURCES += \
|
|
||||||
lib/bitsetv-print.h \
|
|
||||||
lib/bitsetv-print.c
|
|
||||||
|
|
||||||
# timevars, stolen from GCC.
|
|
||||||
lib_libbison_a_SOURCES += \
|
|
||||||
lib/timevar.h \
|
|
||||||
lib/timevar.c \
|
|
||||||
lib/timevar.def
|
|
||||||
|
|
||||||
# Non-gnulib sources in Bison's internal library.
|
|
||||||
lib_libbison_a_SOURCES += \
|
|
||||||
lib/get-errno.h \
|
|
||||||
lib/get-errno.c
|
|
||||||
|
|
||||||
# The Yacc compatibility library.
|
|
||||||
lib_LIBRARIES = $(YACC_LIBRARY)
|
|
||||||
EXTRA_LIBRARIES = lib/liby.a
|
|
||||||
lib_liby_a_SOURCES = lib/main.c lib/yyerror.c
|
|
||||||
@@ -18,7 +18,13 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#if HAVE_LOCALE_H
|
||||||
# include <locale.h>
|
# include <locale.h>
|
||||||
|
#endif
|
||||||
|
#if ! HAVE_SETLOCALE
|
||||||
|
# define setlocale(Category, Locale)
|
||||||
|
#endif
|
||||||
|
|
||||||
int yyparse (void);
|
int yyparse (void);
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -50,7 +50,6 @@
|
|||||||
/include_next.m4
|
/include_next.m4
|
||||||
/intdiv0.m4
|
/intdiv0.m4
|
||||||
/intl.m4
|
/intl.m4
|
||||||
/intl.m4~
|
|
||||||
/intldir.m4
|
/intldir.m4
|
||||||
/intlmacosx.m4
|
/intlmacosx.m4
|
||||||
/intmax.m4
|
/intmax.m4
|
||||||
@@ -63,6 +62,7 @@
|
|||||||
/isnand.m4
|
/isnand.m4
|
||||||
/isnanf.m4
|
/isnanf.m4
|
||||||
/isnanl.m4
|
/isnanl.m4
|
||||||
|
/iswblank.m4
|
||||||
/javacomp.m4
|
/javacomp.m4
|
||||||
/javaexec.m4
|
/javaexec.m4
|
||||||
/largefile.m4
|
/largefile.m4
|
||||||
@@ -81,6 +81,8 @@
|
|||||||
/longlong.m4
|
/longlong.m4
|
||||||
/malloc.m4
|
/malloc.m4
|
||||||
/math_h.m4
|
/math_h.m4
|
||||||
|
/mbchar.m4
|
||||||
|
/mbiter.m4
|
||||||
/mbrtowc.m4
|
/mbrtowc.m4
|
||||||
/mbsinit.m4
|
/mbsinit.m4
|
||||||
/mbstate_t.m4
|
/mbstate_t.m4
|
||||||
@@ -99,7 +101,6 @@
|
|||||||
/perror.m4
|
/perror.m4
|
||||||
/pipe2.m4
|
/pipe2.m4
|
||||||
/po.m4
|
/po.m4
|
||||||
/po.m4~
|
|
||||||
/posix_spawn.m4
|
/posix_spawn.m4
|
||||||
/printf-frexp.m4
|
/printf-frexp.m4
|
||||||
/printf-frexpl.m4
|
/printf-frexpl.m4
|
||||||
@@ -179,4 +180,5 @@
|
|||||||
/xstrndup.m4
|
/xstrndup.m4
|
||||||
/obstack-printf.m4
|
/obstack-printf.m4
|
||||||
/extern-inline.m4
|
/extern-inline.m4
|
||||||
/non-recursive-gnulib-prefix-hack.m4
|
/getdelim.m4
|
||||||
|
/getline.m4
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
/Makefile
|
/Makefile
|
||||||
/Makefile.in
|
/Makefile.in
|
||||||
/Makefile.in.in
|
/Makefile.in.in
|
||||||
/Makefile.in.in~
|
|
||||||
/Makevars
|
/Makevars
|
||||||
/Makevars.template
|
/Makevars.template
|
||||||
/POTFILES
|
/POTFILES
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
/Makefile
|
/Makefile
|
||||||
/Makefile.in
|
/Makefile.in
|
||||||
/Makefile.in.in
|
/Makefile.in.in
|
||||||
/Makefile.in.in~
|
|
||||||
/Makevars
|
/Makevars
|
||||||
/Makevars.template
|
/Makevars.template
|
||||||
/POTFILES
|
/POTFILES
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
/*.output
|
/*.output
|
||||||
/.deps
|
/.deps
|
||||||
/.dirstamp
|
/.dirstamp
|
||||||
|
/Makefile
|
||||||
|
/Makefile.in
|
||||||
/bison
|
/bison
|
||||||
/bison.exe
|
/bison.exe
|
||||||
/scan-code.c
|
/scan-code.c
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ typedef struct InadequacyList {
|
|||||||
* <tt>manifesting_state->reductions->num + 1</tt>.
|
* <tt>manifesting_state->reductions->num + 1</tt>.
|
||||||
* - If the set of all \c InadequacyList nodes with which the new
|
* - If the set of all \c InadequacyList nodes with which the new
|
||||||
* \c InadequacyList node might be compared is currently empty, then
|
* \c InadequacyList node might be compared is currently empty, then
|
||||||
* it is best if <tt>*node_count</tt> is zero so that the node count
|
* it is best if <tt>*node_count</t> is zero so that the node count
|
||||||
* does not eventually overflow. However, if that set is not
|
* does not eventually overflow. However, if that set is not
|
||||||
* currently empty, then <tt>*node_count</tt> has not been modified
|
* currently empty, then <tt>*node_count</tt> has not been modified
|
||||||
* by any function except \c InadequacyList__new_conflict since the
|
* by any function except \c InadequacyList__new_conflict since the
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* Generate the LR(0) parser states for Bison.
|
/* Generate the LR(0) parser states for Bison.
|
||||||
|
|
||||||
Copyright (C) 1984, 1986, 1989, 2000-2002, 2004-2013 Free Software
|
Copyright (C) 1984, 1986, 1989, 2000-2002, 2004-2007, 2009-2013 Free
|
||||||
Foundation, Inc.
|
Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
#include "getargs.h"
|
#include "getargs.h"
|
||||||
#include "gram.h"
|
#include "gram.h"
|
||||||
|
#include "gram.h"
|
||||||
#include "lalr.h"
|
#include "lalr.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "reduce.h"
|
#include "reduce.h"
|
||||||
|
|||||||
+117
@@ -0,0 +1,117 @@
|
|||||||
|
# Make bison/src.
|
||||||
|
|
||||||
|
# Copyright (C) 2001-2013 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/>.
|
||||||
|
|
||||||
|
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
|
||||||
|
AM_CPPFLAGS = -I$(top_srcdir)/lib
|
||||||
|
BISON = ../tests/bison
|
||||||
|
# Use our own Bison to build the parser. Of course, you ought to
|
||||||
|
# keep a sane version of Bison nearby...
|
||||||
|
YACC = $(BISON) -y
|
||||||
|
AM_YFLAGS = -d -v --warnings=all,error --report=all
|
||||||
|
|
||||||
|
LDADD = ../lib/libbison.a $(LIBINTL)
|
||||||
|
|
||||||
|
bin_PROGRAMS = bison
|
||||||
|
bin_SCRIPTS = $(YACC_SCRIPT)
|
||||||
|
EXTRA_SCRIPTS = yacc
|
||||||
|
|
||||||
|
bison_SOURCES = \
|
||||||
|
AnnotationList.c AnnotationList.h \
|
||||||
|
InadequacyList.c InadequacyList.h \
|
||||||
|
LR0.c LR0.h \
|
||||||
|
Sbitset.c Sbitset.h \
|
||||||
|
assoc.c assoc.h \
|
||||||
|
closure.c closure.h \
|
||||||
|
complain.c complain.h \
|
||||||
|
conflicts.c conflicts.h \
|
||||||
|
derives.c derives.h \
|
||||||
|
files.c files.h \
|
||||||
|
flex-scanner.h \
|
||||||
|
getargs.c getargs.h \
|
||||||
|
gram.c gram.h \
|
||||||
|
lalr.h lalr.c \
|
||||||
|
ielr.h ielr.c \
|
||||||
|
location.c location.h \
|
||||||
|
main.c \
|
||||||
|
muscle-tab.c muscle-tab.h \
|
||||||
|
named-ref.c named-ref.h \
|
||||||
|
nullable.c nullable.h \
|
||||||
|
output.c output.h \
|
||||||
|
parse-gram.y \
|
||||||
|
print.c print.h \
|
||||||
|
print_graph.c print_graph.h \
|
||||||
|
print-xml.c print-xml.h \
|
||||||
|
reader.c reader.h \
|
||||||
|
reduce.c reduce.h \
|
||||||
|
relation.c relation.h \
|
||||||
|
scan-code.h scan-code-c.c \
|
||||||
|
scan-gram.h scan-gram-c.c \
|
||||||
|
scan-skel.h scan-skel-c.c \
|
||||||
|
state.c state.h \
|
||||||
|
symlist.c symlist.h \
|
||||||
|
symtab.c symtab.h \
|
||||||
|
system.h \
|
||||||
|
tables.h tables.c \
|
||||||
|
uniqstr.c uniqstr.h \
|
||||||
|
graphviz.c graphviz.h
|
||||||
|
|
||||||
|
EXTRA_bison_SOURCES = scan-code.l scan-skel.l scan-gram.l
|
||||||
|
|
||||||
|
BUILT_SOURCES = \
|
||||||
|
parse-gram.c parse-gram.h \
|
||||||
|
scan-code.c \
|
||||||
|
scan-skel.c \
|
||||||
|
scan-gram.c
|
||||||
|
|
||||||
|
MOSTLYCLEANFILES = yacc
|
||||||
|
|
||||||
|
yacc:
|
||||||
|
$(AM_V_GEN)echo '#! /bin/sh' >$@
|
||||||
|
$(AM_V_at)echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@
|
||||||
|
$(AM_V_at)chmod a+x $@
|
||||||
|
|
||||||
|
|
||||||
|
# The following rule is not designed to be portable,
|
||||||
|
# and relies on tools that not everyone has.
|
||||||
|
|
||||||
|
# Most functions in src/*.c should have static scope.
|
||||||
|
# Any that don't must be marked with `extern', but `main'
|
||||||
|
# and `usage' are exceptions. They're always extern, but
|
||||||
|
# don't need to be marked.
|
||||||
|
#
|
||||||
|
# The second nm|grep checks for file-scope variables with `extern' scope.
|
||||||
|
sc_tight_scope: $(all_programs)
|
||||||
|
@t=exceptions-$$$$; \
|
||||||
|
trap 's=$$?; rm -f $$t; exit $$s' 0 1 2 13 15; \
|
||||||
|
( printf '^main$$\n^usage$$\n'; \
|
||||||
|
grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
|
||||||
|
| grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
|
||||||
|
if nm -e *.$(OBJEXT) \
|
||||||
|
| sed -n 's/.* T //p' \
|
||||||
|
| grep -Ev -f $$t; then \
|
||||||
|
echo 'the above functions should have static scope' 1>&2; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
( printf '^program_name$$\n'; \
|
||||||
|
sed -n 's/^extern .*[* ]\([a-zA-Z_][a-zA-Z_0-9]*\);$$/^\1$$/p' \
|
||||||
|
$$(ls $(SOURCES) | grep '\.h$$') /dev/null) > $$t; \
|
||||||
|
if nm -e *.$(OBJEXT) \
|
||||||
|
| sed -n 's/.* [BD] //p' \
|
||||||
|
| grep -Ev -f $$t; then \
|
||||||
|
echo 'the above variables should have static scope' 1>&2; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
+1
-4
@@ -1,6 +1,6 @@
|
|||||||
/* Associativity information.
|
/* Associativity information.
|
||||||
|
|
||||||
Copyright (C) 2002, 2005-2006, 2008-2013 Free Software Foundation,
|
Copyright (C) 2002, 2005-2006, 2009-2013 Free Software Foundation,
|
||||||
Inc.
|
Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
@@ -43,8 +43,5 @@ assoc_to_string (assoc a)
|
|||||||
|
|
||||||
case non_assoc:
|
case non_assoc:
|
||||||
return "%nonassoc";
|
return "%nonassoc";
|
||||||
|
|
||||||
case precedence_assoc:
|
|
||||||
return "%precedence";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-6
@@ -1,6 +1,6 @@
|
|||||||
/* Associativity information.
|
/* Associativity information.
|
||||||
|
|
||||||
Copyright (C) 2002, 2006, 2008-2013 Free Software Foundation, Inc.
|
Copyright (C) 2002, 2006, 2009-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -23,11 +23,10 @@
|
|||||||
/* Associativity values for tokens and rules. */
|
/* Associativity values for tokens and rules. */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
undef_assoc, /** Not defined. */
|
undef_assoc,
|
||||||
right_assoc, /** %right */
|
right_assoc,
|
||||||
left_assoc, /** %left */
|
left_assoc,
|
||||||
non_assoc, /** %nonassoc */
|
non_assoc
|
||||||
precedence_assoc /** %precedence */
|
|
||||||
} assoc;
|
} assoc;
|
||||||
|
|
||||||
char const *assoc_to_string (assoc a);
|
char const *assoc_to_string (assoc a);
|
||||||
|
|||||||
+9
-7
@@ -52,7 +52,7 @@ static bitsetv firsts = NULL;
|
|||||||
`-----------------*/
|
`-----------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_closure (char const *title, item_number const *array, size_t size)
|
print_closure (char const *title, item_number *array, size_t size)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
fprintf (stderr, "Closure: %s\n", title);
|
fprintf (stderr, "Closure: %s\n", title);
|
||||||
@@ -77,9 +77,12 @@ print_firsts (void)
|
|||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
{
|
{
|
||||||
bitset_iterator iter;
|
bitset_iterator iter;
|
||||||
fprintf (stderr, " %s firsts\n", symbols[i]->tag);
|
fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
|
||||||
BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
|
BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
|
||||||
fprintf (stderr, " %s\n", symbols[j + ntokens]->tag);
|
{
|
||||||
|
fprintf (stderr, "\t\t%s\n",
|
||||||
|
symbols[j + ntokens]->tag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr, "\n\n");
|
fprintf (stderr, "\n\n");
|
||||||
}
|
}
|
||||||
@@ -95,12 +98,11 @@ print_fderives (void)
|
|||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
{
|
{
|
||||||
bitset_iterator iter;
|
bitset_iterator iter;
|
||||||
fprintf (stderr, " %s derives\n", symbols[i]->tag);
|
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
||||||
BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
|
BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, " %3d ", r);
|
fprintf (stderr, "\t\t%3d ", r);
|
||||||
rule_rhs_print (&rules[r], stderr);
|
rule_rhs_print (&rules[r], stderr);
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr, "\n\n");
|
fprintf (stderr, "\n\n");
|
||||||
@@ -189,7 +191,7 @@ new_closure (unsigned int n)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
closure (item_number const *core, size_t n)
|
closure (item_number *core, size_t n)
|
||||||
{
|
{
|
||||||
/* Index over CORE. */
|
/* Index over CORE. */
|
||||||
size_t c;
|
size_t c;
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ void new_closure (unsigned int n);
|
|||||||
significant). CLOSURE places there the indices of all items which
|
significant). CLOSURE places there the indices of all items which
|
||||||
represent units of input that could arrive next. */
|
represent units of input that could arrive next. */
|
||||||
|
|
||||||
void closure (item_number const *items, size_t n);
|
void closure (item_number *items, size_t n);
|
||||||
|
|
||||||
|
|
||||||
/* Frees ITEMSET, RULESET and internal data. */
|
/* Frees ITEMSET, RULESET and internal data. */
|
||||||
|
|||||||
+128
-117
@@ -28,51 +28,16 @@
|
|||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
#include "files.h"
|
#include "files.h"
|
||||||
#include "getargs.h"
|
#include "getargs.h"
|
||||||
#include "quote.h"
|
|
||||||
|
|
||||||
warnings warnings_flag =
|
bool complaint_issued;
|
||||||
Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
|
|
||||||
|
|
||||||
warnings errors_flag;
|
|
||||||
|
|
||||||
err_status complaint_status = status_none;
|
|
||||||
static unsigned *indent_ptr = 0;
|
static unsigned *indent_ptr = 0;
|
||||||
|
|
||||||
void
|
|
||||||
warnings_print_categories (warnings warn_flags)
|
|
||||||
{
|
|
||||||
if (! (warn_flags & silent))
|
|
||||||
{
|
|
||||||
char const *warn_names[] =
|
|
||||||
{
|
|
||||||
"midrule-values",
|
|
||||||
"yacc",
|
|
||||||
"conflicts-sr",
|
|
||||||
"conflicts-rr",
|
|
||||||
"deprecated",
|
|
||||||
"other"
|
|
||||||
};
|
|
||||||
|
|
||||||
bool any = false;
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < ARRAY_CARDINALITY (warn_names); ++i)
|
|
||||||
if (warn_flags & 1 << i)
|
|
||||||
{
|
|
||||||
bool err = warn_flags & errors_flag;
|
|
||||||
fprintf (stderr, "%s-W", any ? ", " : " [");
|
|
||||||
fprintf (stderr, "%s%s", err ? "error=" : "" , warn_names[i]);
|
|
||||||
any = true;
|
|
||||||
}
|
|
||||||
if (any)
|
|
||||||
fprintf (stderr, "]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Report an error message.
|
/** Report an error message.
|
||||||
*
|
*
|
||||||
* \param loc the location, defaulting to the current file,
|
* \param loc the location, defaulting to the current file,
|
||||||
* or the program name.
|
* or the program name.
|
||||||
* \param flags the category for this message.
|
|
||||||
* \param prefix put before the message (e.g., "warning").
|
* \param prefix put before the message (e.g., "warning").
|
||||||
* \param message the error message, a printf format string. Iff it
|
* \param message the error message, a printf format string. Iff it
|
||||||
* ends with ": ", then no trailing newline is printed,
|
* ends with ": ", then no trailing newline is printed,
|
||||||
@@ -82,7 +47,8 @@ warnings_print_categories (warnings warn_flags)
|
|||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
error_message (const location *loc, warnings flags, const char *prefix,
|
error_message (location *loc,
|
||||||
|
const char *prefix,
|
||||||
const char *message, va_list args)
|
const char *message, va_list args)
|
||||||
{
|
{
|
||||||
unsigned pos = 0;
|
unsigned pos = 0;
|
||||||
@@ -95,8 +61,6 @@ error_message (const location *loc, warnings flags, const char *prefix,
|
|||||||
|
|
||||||
if (indent_ptr)
|
if (indent_ptr)
|
||||||
{
|
{
|
||||||
if (*indent_ptr)
|
|
||||||
prefix = NULL;
|
|
||||||
if (!*indent_ptr)
|
if (!*indent_ptr)
|
||||||
*indent_ptr = pos;
|
*indent_ptr = pos;
|
||||||
else if (*indent_ptr > pos)
|
else if (*indent_ptr > pos)
|
||||||
@@ -108,99 +72,146 @@ error_message (const location *loc, warnings flags, const char *prefix,
|
|||||||
fprintf (stderr, "%s: ", prefix);
|
fprintf (stderr, "%s: ", prefix);
|
||||||
|
|
||||||
vfprintf (stderr, message, args);
|
vfprintf (stderr, message, args);
|
||||||
warnings_print_categories (flags);
|
|
||||||
{
|
{
|
||||||
size_t l = strlen (message);
|
size_t l = strlen (message);
|
||||||
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')
|
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')
|
||||||
{
|
{
|
||||||
putc ('\n', stderr);
|
putc ('\n', stderr);
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
if (loc && feature_flag & feature_caret && !(flags & no_caret))
|
if (loc && feature_flag & feature_caret)
|
||||||
location_caret (stderr, *loc);
|
location_caret (stderr, *loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Raise a complaint. That can be a fatal error, a complaint or just a
|
/** Wrap error_message() with varargs handling. */
|
||||||
warning. */
|
#define ERROR_MESSAGE(Loc, Prefix, Message) \
|
||||||
static inline void
|
{ \
|
||||||
complains (const location *loc, warnings flags, const char *message,
|
va_list args; \
|
||||||
va_list args)
|
va_start (args, Message); \
|
||||||
{
|
error_message (Loc, Prefix, Message, args); \
|
||||||
const char* prefix =
|
va_end (args); \
|
||||||
flags & fatal ? _("fatal error")
|
}
|
||||||
: flags & (errors_flag | complaint) ? _("error")
|
|
||||||
: _("warning");
|
|
||||||
|
|
||||||
if ((flags & complaint) && complaint_status < status_complaint)
|
|
||||||
complaint_status = status_complaint;
|
/*--------------------------------.
|
||||||
else if ((flags & (warnings_flag & errors_flag)) && ! complaint_status)
|
| Report a warning, and proceed. |
|
||||||
complaint_status = status_warning_as_error;
|
`--------------------------------*/
|
||||||
if (flags & (warnings_flag | fatal | complaint))
|
|
||||||
error_message (loc, flags, prefix, message, args);
|
void
|
||||||
if (flags & fatal)
|
set_warning_issued (void)
|
||||||
|
{
|
||||||
|
static bool warning_issued = false;
|
||||||
|
if (!warning_issued && (warnings_flag & warnings_error))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: warnings being treated as errors\n", program_name);
|
||||||
|
complaint_issued = true;
|
||||||
|
}
|
||||||
|
warning_issued = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
warn_at (location loc, const char *message, ...)
|
||||||
|
{
|
||||||
|
if (!(warnings_flag & warnings_other))
|
||||||
|
return;
|
||||||
|
set_warning_issued ();
|
||||||
|
ERROR_MESSAGE (&loc, _("warning"), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
warn_at_indent (location loc, unsigned *indent,
|
||||||
|
const char *message, ...)
|
||||||
|
{
|
||||||
|
if (!(warnings_flag & warnings_other))
|
||||||
|
return;
|
||||||
|
set_warning_issued ();
|
||||||
|
indent_ptr = indent;
|
||||||
|
ERROR_MESSAGE (&loc, *indent ? NULL : _("warning"), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
warn (const char *message, ...)
|
||||||
|
{
|
||||||
|
if (!(warnings_flag & warnings_other))
|
||||||
|
return;
|
||||||
|
set_warning_issued ();
|
||||||
|
ERROR_MESSAGE (NULL, _("warning"), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------.
|
||||||
|
| An error has occurred, but we can proceed, and die later. |
|
||||||
|
`-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void
|
||||||
|
complain_at (location loc, const char *message, ...)
|
||||||
|
{
|
||||||
|
ERROR_MESSAGE (&loc, _("error"), message);
|
||||||
|
complaint_issued = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
complain_at_indent (location loc, unsigned *indent,
|
||||||
|
const char *message, ...)
|
||||||
|
{
|
||||||
|
indent_ptr = indent;
|
||||||
|
ERROR_MESSAGE (&loc, *indent ? NULL : _("error"), message);
|
||||||
|
complaint_issued = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
complain (const char *message, ...)
|
||||||
|
{
|
||||||
|
ERROR_MESSAGE (NULL, _("error"), message);
|
||||||
|
complaint_issued = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------.
|
||||||
|
| An incompatibility with POSIX Yacc: mapped either to warn* or |
|
||||||
|
| complain* depending on yacc_flag. |
|
||||||
|
`--------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void
|
||||||
|
yacc_at (location loc, const char *message, ...)
|
||||||
|
{
|
||||||
|
if (yacc_flag)
|
||||||
|
{
|
||||||
|
ERROR_MESSAGE (&loc, NULL, message);
|
||||||
|
complaint_issued = true;
|
||||||
|
}
|
||||||
|
else if (warnings_flag & warnings_yacc)
|
||||||
|
{
|
||||||
|
set_warning_issued ();
|
||||||
|
ERROR_MESSAGE (&loc, _("warning"), message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
midrule_value_at (location loc, const char *message, ...)
|
||||||
|
{
|
||||||
|
if (!(warnings_flag & warnings_midrule_values))
|
||||||
|
return;
|
||||||
|
set_warning_issued ();
|
||||||
|
ERROR_MESSAGE (&loc, _("warning"), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------.
|
||||||
|
| A severe error has occurred, we cannot proceed. |
|
||||||
|
`-------------------------------------------------*/
|
||||||
|
|
||||||
|
void
|
||||||
|
fatal_at (location loc, const char *message, ...)
|
||||||
|
{
|
||||||
|
ERROR_MESSAGE (&loc, _("fatal error"), message);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
complain (location const *loc, warnings flags, const char *message, ...)
|
fatal (const char *message, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
ERROR_MESSAGE (NULL, _("fatal error"), message);
|
||||||
va_start (args, message);
|
exit (EXIT_FAILURE);
|
||||||
complains (loc, flags, message, args);
|
|
||||||
va_end (args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
complain_indent (location const *loc, warnings flags, unsigned *indent,
|
|
||||||
const char *message, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
indent_ptr = indent;
|
|
||||||
va_start (args, message);
|
|
||||||
complains (loc, flags, message, args);
|
|
||||||
va_end (args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
complain_args (location const *loc, warnings w, unsigned *indent,
|
|
||||||
int argc, char *argv[])
|
|
||||||
{
|
|
||||||
switch (argc)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
complain_indent (loc, w, indent, "%s", _(argv[0]));
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
complain_indent (loc, w, indent, _(argv[0]), argv[1]);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
complain_indent (loc, w, indent, _(argv[0]), argv[1], argv[2]);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
complain_indent (loc, w, indent, _(argv[0]), argv[1], argv[2], argv[3]);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
complain_indent (loc, w, indent, _(argv[0]), argv[1], argv[2], argv[3],
|
|
||||||
argv[4]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
complain (loc, fatal, "too many arguments for complains");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
deprecated_directive (location const *loc, char const *old, char const *upd)
|
|
||||||
{
|
|
||||||
if (feature_flag & feature_caret)
|
|
||||||
complain (loc, Wdeprecated,
|
|
||||||
_("deprecated directive, use %s"),
|
|
||||||
quote_n (1, upd));
|
|
||||||
else
|
|
||||||
complain (loc, Wdeprecated,
|
|
||||||
_("deprecated directive: %s, use %s"),
|
|
||||||
quote (old), quote_n (1, upd));
|
|
||||||
}
|
}
|
||||||
|
|||||||
+56
-52
@@ -21,72 +21,76 @@
|
|||||||
|
|
||||||
# include "location.h"
|
# include "location.h"
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
/* Sub-messages indent. */
|
/* Sub-messages indent. */
|
||||||
#define SUB_INDENT (4)
|
#define SUB_INDENT (4)
|
||||||
|
|
||||||
/*-------------.
|
/** Record that a warning is about to be issued, and treat it as an
|
||||||
| --warnings. |
|
error if <tt>warnings_flag & warnings_error</tt>. This is exported
|
||||||
`-------------*/
|
only for the sake of Yacc-compatible conflict reports in conflicts.c.
|
||||||
|
All other warnings should be implemented in complain.c and should use
|
||||||
|
the normal warning format. */
|
||||||
|
void set_warning_issued (void);
|
||||||
|
|
||||||
typedef enum
|
/** Informative messages, but we proceed. Report iff
|
||||||
{
|
<tt>warnings_flag & warnings_other</tt>. */
|
||||||
Wnone = 0, /**< Issue no warnings. */
|
|
||||||
Wmidrule_values = 1 << 0, /**< Unset or unused midrule values. */
|
|
||||||
Wyacc = 1 << 1, /**< POSIXME. */
|
|
||||||
Wconflicts_sr = 1 << 2, /**< S/R conflicts. */
|
|
||||||
Wconflicts_rr = 1 << 3, /**< R/R conflicts. */
|
|
||||||
Wdeprecated = 1 << 4, /**< Obsolete constructs. */
|
|
||||||
Wother = 1 << 5, /**< All other warnings. */
|
|
||||||
|
|
||||||
Werror = 1 << 10, /** This bit is no longer used. */
|
void warn (char const *format, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
|
|
||||||
complaint = 1 << 11, /**< All complaints. */
|
void warn_at (location loc, char const *format, ...)
|
||||||
fatal = 1 << 12, /**< All fatal errors. */
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
silent = 1 << 13, /**< Do not display the warning type. */
|
|
||||||
no_caret = 1 << 14, /**< Do not display caret location. */
|
|
||||||
|
|
||||||
/**< All above warnings. */
|
/* Generate a message aligned by an indent.
|
||||||
Wall = ~complaint & ~fatal & ~silent
|
When *indent == 0, assign message's indent to *indent,
|
||||||
} warnings;
|
When *indent > 0, align the message by *indent value. */
|
||||||
|
void warn_at_indent (location loc, unsigned *indent,
|
||||||
/** What warnings are issued. */
|
char const *format, ...)
|
||||||
extern warnings warnings_flag;
|
|
||||||
|
|
||||||
/** What warnings are made errors. */
|
|
||||||
extern warnings errors_flag;
|
|
||||||
|
|
||||||
/** Display a "[-Wyacc]" like message on stderr. */
|
|
||||||
void warnings_print_categories (warnings warn_flags);
|
|
||||||
|
|
||||||
/** Make a complaint, with maybe a location. */
|
|
||||||
void complain (location const *loc, warnings flags, char const *message, ...)
|
|
||||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
|
|
||||||
/** Likewise, but with an \a argc/argv interface. */
|
/** An error, but we continue and die later. */
|
||||||
void complain_args (location const *loc, warnings w, unsigned *indent,
|
|
||||||
int argc, char *arg[]);
|
|
||||||
|
|
||||||
/** Make a complaint with location and some indentation. */
|
void complain (char const *format, ...)
|
||||||
void complain_indent (location const *loc, warnings flags, unsigned *indent,
|
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
char const *message, ...)
|
|
||||||
__attribute__ ((__format__ (__printf__, 4, 5)));
|
|
||||||
|
|
||||||
|
void complain_at (location loc, char const *format, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
|
||||||
/** Report an obsolete syntax, suggest the updated one. */
|
/* Generate a message aligned by an indent.
|
||||||
void deprecated_directive (location const *loc,
|
When *indent == 0, assign message's indent to *indent,
|
||||||
char const *obsolete, char const *updated);
|
When *indent > 0, align the message by *indent value. */
|
||||||
|
void complain_at_indent (location loc, unsigned *indent,
|
||||||
|
char const *format, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
|
|
||||||
/** Warnings treated as errors shouldn't stop the execution as regular errors
|
/** An incompatibility with POSIX Yacc: mapped either to warn* or
|
||||||
should (because due to their nature, it is safe to go on). Thus, there are
|
complain* depending on yacc_flag. */
|
||||||
three possible execution statuses. */
|
|
||||||
typedef enum
|
void yacc_at (location loc, char const *format, ...)
|
||||||
{
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
status_none,
|
|
||||||
status_warning_as_error,
|
/** A midrule-value warning. Report iff
|
||||||
status_complaint
|
<tt>warnings_flag & warnings_midrule_values</tt>. */
|
||||||
} err_status;
|
|
||||||
|
void midrule_value_at (location loc, char const *format, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
|
||||||
|
/** A fatal error, causing immediate exit. */
|
||||||
|
|
||||||
|
void fatal (char const *format, ...)
|
||||||
|
__attribute__ ((__noreturn__, __format__ (__printf__, 1, 2)));
|
||||||
|
|
||||||
|
void fatal_at (location loc, char const *format, ...)
|
||||||
|
__attribute__ ((__noreturn__, __format__ (__printf__, 2, 3)));
|
||||||
|
|
||||||
/** Whether an error was reported. */
|
/** Whether an error was reported. */
|
||||||
extern err_status complaint_status;
|
extern bool complaint_issued;
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif /* !COMPLAIN_H_ */
|
#endif /* !COMPLAIN_H_ */
|
||||||
|
|||||||
+116
-108
@@ -1,7 +1,7 @@
|
|||||||
/* Find and resolve or report lookahead conflicts for bison,
|
/* Find and resolve or report lookahead conflicts for bison,
|
||||||
|
|
||||||
Copyright (C) 1984, 1989, 1992, 2000-2013 Free Software Foundation,
|
Copyright (C) 1984, 1989, 1992, 2000-2007, 2009-2013 Free Software
|
||||||
Inc.
|
Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -276,46 +276,36 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs)
|
|||||||
The precedence of shifting is that of token i. */
|
The precedence of shifting is that of token i. */
|
||||||
if (symbols[i]->prec < redprec)
|
if (symbols[i]->prec < redprec)
|
||||||
{
|
{
|
||||||
register_precedence (redrule->prec->number, i);
|
|
||||||
log_resolution (redrule, i, reduce_resolution);
|
log_resolution (redrule, i, reduce_resolution);
|
||||||
flush_shift (s, i);
|
flush_shift (s, i);
|
||||||
}
|
}
|
||||||
else if (symbols[i]->prec > redprec)
|
else if (symbols[i]->prec > redprec)
|
||||||
{
|
{
|
||||||
register_precedence (i, redrule->prec->number);
|
|
||||||
log_resolution (redrule, i, shift_resolution);
|
log_resolution (redrule, i, shift_resolution);
|
||||||
flush_reduce (lookahead_tokens, i);
|
flush_reduce (lookahead_tokens, i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* Matching precedence levels.
|
/* Matching precedence levels.
|
||||||
For non-defined associativity, keep both: unexpected
|
For left association, keep only the reduction.
|
||||||
associativity conflict.
|
For right association, keep only the shift.
|
||||||
For left associativity, keep only the reduction.
|
For nonassociation, keep neither. */
|
||||||
For right associativity, keep only the shift.
|
|
||||||
For nonassociativity, keep neither. */
|
|
||||||
|
|
||||||
switch (symbols[i]->assoc)
|
switch (symbols[i]->assoc)
|
||||||
{
|
{
|
||||||
case undef_assoc:
|
default:
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
case precedence_assoc:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case right_assoc:
|
case right_assoc:
|
||||||
register_assoc (i, redrule->prec->number);
|
|
||||||
log_resolution (redrule, i, right_resolution);
|
log_resolution (redrule, i, right_resolution);
|
||||||
flush_reduce (lookahead_tokens, i);
|
flush_reduce (lookahead_tokens, i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case left_assoc:
|
case left_assoc:
|
||||||
register_assoc (i, redrule->prec->number);
|
|
||||||
log_resolution (redrule, i, left_resolution);
|
log_resolution (redrule, i, left_resolution);
|
||||||
flush_shift (s, i);
|
flush_shift (s, i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case non_assoc:
|
case non_assoc:
|
||||||
register_assoc (i, redrule->prec->number);
|
|
||||||
log_resolution (redrule, i, nonassoc_resolution);
|
log_resolution (redrule, i, nonassoc_resolution);
|
||||||
flush_shift (s, i);
|
flush_shift (s, i);
|
||||||
flush_reduce (lookahead_tokens, i);
|
flush_reduce (lookahead_tokens, i);
|
||||||
@@ -365,9 +355,15 @@ set_conflicts (state *s, symbol **errors)
|
|||||||
state_errs_set (s, nerrs, errors);
|
state_errs_set (s, nerrs, errors);
|
||||||
}
|
}
|
||||||
if (obstack_object_size (&solved_conflicts_obstack))
|
if (obstack_object_size (&solved_conflicts_obstack))
|
||||||
s->solved_conflicts = obstack_finish0 (&solved_conflicts_obstack);
|
{
|
||||||
|
obstack_1grow (&solved_conflicts_obstack, '\0');
|
||||||
|
s->solved_conflicts = obstack_finish (&solved_conflicts_obstack);
|
||||||
|
}
|
||||||
if (obstack_object_size (&solved_conflicts_xml_obstack))
|
if (obstack_object_size (&solved_conflicts_xml_obstack))
|
||||||
s->solved_conflicts_xml = obstack_finish0 (&solved_conflicts_xml_obstack);
|
{
|
||||||
|
obstack_1grow (&solved_conflicts_xml_obstack, '\0');
|
||||||
|
s->solved_conflicts_xml = obstack_finish (&solved_conflicts_xml_obstack);
|
||||||
|
}
|
||||||
|
|
||||||
/* Loop over all rules which require lookahead in this state. Check
|
/* Loop over all rules which require lookahead in this state. Check
|
||||||
for conflicts not resolved above. */
|
for conflicts not resolved above. */
|
||||||
@@ -427,10 +423,11 @@ conflicts_update_state_numbers (state_number old_to_new[],
|
|||||||
| Count the number of shift/reduce conflicts. |
|
| Count the number of shift/reduce conflicts. |
|
||||||
`---------------------------------------------*/
|
`---------------------------------------------*/
|
||||||
|
|
||||||
static size_t
|
static int
|
||||||
count_state_sr_conflicts (state *s)
|
count_sr_conflicts (state *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
int src_count = 0;
|
||||||
transitions *trans = s->transitions;
|
transitions *trans = s->transitions;
|
||||||
reductions *reds = s->reductions;
|
reductions *reds = s->reductions;
|
||||||
|
|
||||||
@@ -448,66 +445,56 @@ count_state_sr_conflicts (state *s)
|
|||||||
|
|
||||||
bitset_and (lookahead_set, lookahead_set, shift_set);
|
bitset_and (lookahead_set, lookahead_set, shift_set);
|
||||||
|
|
||||||
return bitset_count (lookahead_set);
|
src_count = bitset_count (lookahead_set);
|
||||||
|
|
||||||
|
return src_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------.
|
|
||||||
| The total number of shift/reduce conflicts. |
|
|
||||||
`---------------------------------------------*/
|
|
||||||
|
|
||||||
static size_t
|
|
||||||
count_sr_conflicts (void)
|
|
||||||
{
|
|
||||||
size_t res = 0;
|
|
||||||
state_number i;
|
|
||||||
|
|
||||||
/* Conflicts by state. */
|
|
||||||
for (i = 0; i < nstates; i++)
|
|
||||||
if (conflicts[i])
|
|
||||||
res += count_state_sr_conflicts (states[i]);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------.
|
/*----------------------------------------------------------------.
|
||||||
| Count the number of reduce/reduce conflicts. If ONE_PER_TOKEN, |
|
| Count the number of reduce/reduce conflicts. If ONE_PER_TOKEN, |
|
||||||
| count one conflict for each token that has any reduce/reduce |
|
| count one conflict for each token that has any reduce/reduce |
|
||||||
| conflicts. Otherwise, count one conflict for each pair of |
|
| conflicts. Otherwise, count one conflict for each pair of |
|
||||||
| conflicting reductions. |
|
| conflicting reductions. |
|
||||||
`----------------------------------------------------------------*/
|
+`----------------------------------------------------------------*/
|
||||||
|
|
||||||
static size_t
|
static int
|
||||||
count_state_rr_conflicts (state *s, bool one_per_token)
|
count_rr_conflicts (state *s, bool one_per_token)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
reductions *reds = s->reductions;
|
reductions *reds = s->reductions;
|
||||||
size_t res = 0;
|
int rrc_count = 0;
|
||||||
|
|
||||||
for (i = 0; i < ntokens; i++)
|
for (i = 0; i < ntokens; i++)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < reds->num; ++j)
|
for (j = 0; j < reds->num; ++j)
|
||||||
count += bitset_test (reds->lookahead_tokens[j], i);
|
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||||
|
count++;
|
||||||
|
|
||||||
if (count >= 2)
|
if (count >= 2)
|
||||||
res += one_per_token ? 1 : count-1;
|
rrc_count += one_per_token ? 1 : count-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return rrc_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
|
||||||
count_rr_conflicts (bool one_per_token)
|
/*--------------------------------------------------------.
|
||||||
|
| Report the number of conflicts, using the Yacc format. |
|
||||||
|
`--------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
conflict_report (FILE *out, int src_num, int rrc_num)
|
||||||
{
|
{
|
||||||
size_t res = 0;
|
if (src_num && rrc_num)
|
||||||
state_number i;
|
fprintf (out, _("conflicts: %d shift/reduce, %d reduce/reduce\n"),
|
||||||
|
src_num, rrc_num);
|
||||||
/* Conflicts by state. */
|
else if (src_num)
|
||||||
for (i = 0; i < nstates; i++)
|
fprintf (out, _("conflicts: %d shift/reduce\n"), src_num);
|
||||||
if (conflicts[i])
|
else if (rrc_num)
|
||||||
res += count_state_rr_conflicts (states[i], one_per_token);
|
fprintf (out, _("conflicts: %d reduce/reduce\n"), rrc_num);
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -525,17 +512,9 @@ conflicts_output (FILE *out)
|
|||||||
state *s = states[i];
|
state *s = states[i];
|
||||||
if (conflicts[i])
|
if (conflicts[i])
|
||||||
{
|
{
|
||||||
int src = count_state_sr_conflicts (s);
|
|
||||||
int rrc = count_state_rr_conflicts (s, true);
|
|
||||||
fprintf (out, _("State %d "), i);
|
fprintf (out, _("State %d "), i);
|
||||||
if (src && rrc)
|
conflict_report (out, count_sr_conflicts (s),
|
||||||
fprintf (out,
|
count_rr_conflicts (s, true));
|
||||||
_("conflicts: %d shift/reduce, %d reduce/reduce\n"),
|
|
||||||
src, rrc);
|
|
||||||
else if (src)
|
|
||||||
fprintf (out, _("conflicts: %d shift/reduce\n"), src);
|
|
||||||
else if (rrc)
|
|
||||||
fprintf (out, _("conflicts: %d reduce/reduce\n"), rrc);
|
|
||||||
printed_sth = true;
|
printed_sth = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -553,7 +532,18 @@ conflicts_output (FILE *out)
|
|||||||
int
|
int
|
||||||
conflicts_total_count (void)
|
conflicts_total_count (void)
|
||||||
{
|
{
|
||||||
return count_sr_conflicts () + count_rr_conflicts (false);
|
state_number i;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
/* Conflicts by state. */
|
||||||
|
count = 0;
|
||||||
|
for (i = 0; i < nstates; i++)
|
||||||
|
if (conflicts[i])
|
||||||
|
{
|
||||||
|
count += count_sr_conflicts (states[i]);
|
||||||
|
count += count_rr_conflicts (states[i], false);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -564,56 +554,74 @@ conflicts_total_count (void)
|
|||||||
void
|
void
|
||||||
conflicts_print (void)
|
conflicts_print (void)
|
||||||
{
|
{
|
||||||
if (! glr_parser && expected_rr_conflicts != -1)
|
/* Is the number of SR conflicts OK? Either EXPECTED_CONFLICTS is
|
||||||
|
not set, and then we want 0 SR, or else it is specified, in which
|
||||||
|
case we want equality. */
|
||||||
|
bool src_ok;
|
||||||
|
bool rrc_ok;
|
||||||
|
|
||||||
|
int src_total = 0;
|
||||||
|
int rrc_total = 0;
|
||||||
|
int src_expected;
|
||||||
|
int rrc_expected;
|
||||||
|
|
||||||
|
/* Conflicts by state. */
|
||||||
{
|
{
|
||||||
complain (NULL, Wother, _("%%expect-rr applies only to GLR parsers"));
|
state_number i;
|
||||||
|
|
||||||
|
for (i = 0; i < nstates; i++)
|
||||||
|
if (conflicts[i])
|
||||||
|
{
|
||||||
|
src_total += count_sr_conflicts (states[i]);
|
||||||
|
rrc_total += count_rr_conflicts (states[i], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! glr_parser && rrc_total > 0 && expected_rr_conflicts != -1)
|
||||||
|
{
|
||||||
|
warn (_("%%expect-rr applies only to GLR parsers"));
|
||||||
expected_rr_conflicts = -1;
|
expected_rr_conflicts = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Screams for factoring, but almost useless because of the
|
src_expected = expected_sr_conflicts == -1 ? 0 : expected_sr_conflicts;
|
||||||
different strings to translate. */
|
rrc_expected = expected_rr_conflicts == -1 ? 0 : expected_rr_conflicts;
|
||||||
|
src_ok = src_total == src_expected;
|
||||||
|
rrc_ok = rrc_total == rrc_expected;
|
||||||
|
|
||||||
|
/* If there are as many RR conflicts and SR conflicts as
|
||||||
|
expected, then there is nothing to report. */
|
||||||
|
if (rrc_ok & src_ok)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Report the total number of conflicts on STDERR. */
|
||||||
|
if (expected_sr_conflicts == -1 && expected_rr_conflicts == -1)
|
||||||
{
|
{
|
||||||
int total = count_sr_conflicts ();
|
if (!(warnings_flag & warnings_conflicts_sr))
|
||||||
/* If %expect is not used, but %expect-rr is, then expect 0 sr. */
|
src_total = 0;
|
||||||
int expected =
|
if (!(warnings_flag & warnings_conflicts_rr))
|
||||||
(expected_sr_conflicts == -1 && expected_rr_conflicts != -1)
|
rrc_total = 0;
|
||||||
? 0
|
|
||||||
: expected_sr_conflicts;
|
|
||||||
if (expected != -1)
|
|
||||||
{
|
|
||||||
if (expected != total)
|
|
||||||
complain (NULL, complaint,
|
|
||||||
_("shift/reduce conflicts: %d found, %d expected"),
|
|
||||||
total, expected);
|
|
||||||
}
|
}
|
||||||
else if (total)
|
if (src_total | rrc_total)
|
||||||
complain (NULL, Wconflicts_sr,
|
{
|
||||||
ngettext ("%d shift/reduce conflict",
|
if (expected_sr_conflicts == -1 && expected_rr_conflicts == -1)
|
||||||
"%d shift/reduce conflicts",
|
set_warning_issued ();
|
||||||
total),
|
if (! yacc_flag)
|
||||||
total);
|
fprintf (stderr, "%s: ", current_file);
|
||||||
|
conflict_report (stderr, src_total, rrc_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1)
|
||||||
{
|
{
|
||||||
int total = count_rr_conflicts (true);
|
if (! src_ok)
|
||||||
/* If %expect-rr is not used, but %expect is, then expect 0 rr. */
|
complain (ngettext ("expected %d shift/reduce conflict",
|
||||||
int expected =
|
"expected %d shift/reduce conflicts",
|
||||||
(expected_rr_conflicts == -1 && expected_sr_conflicts != -1)
|
src_expected),
|
||||||
? 0
|
src_expected);
|
||||||
: expected_rr_conflicts;
|
if (! rrc_ok)
|
||||||
if (expected != -1)
|
complain (ngettext ("expected %d reduce/reduce conflict",
|
||||||
{
|
"expected %d reduce/reduce conflicts",
|
||||||
if (expected != total)
|
rrc_expected),
|
||||||
complain (NULL, complaint,
|
rrc_expected);
|
||||||
_("reduce/reduce conflicts: %d found, %d expected"),
|
|
||||||
total, expected);
|
|
||||||
}
|
|
||||||
else if (total)
|
|
||||||
complain (NULL, Wconflicts_rr,
|
|
||||||
ngettext ("%d reduce/reduce conflict",
|
|
||||||
"%d reduce/reduce conflicts",
|
|
||||||
total),
|
|
||||||
total);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -47,12 +47,11 @@ print_derives (void)
|
|||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
{
|
{
|
||||||
rule **rp;
|
rule **rp;
|
||||||
fprintf (stderr, " %s derives\n", symbols[i]->tag);
|
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
||||||
for (rp = derives[i - ntokens]; *rp; ++rp)
|
for (rp = derives[i - ntokens]; *rp; ++rp)
|
||||||
{
|
{
|
||||||
fprintf (stderr, " %3d ", (*rp)->user_number);
|
fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
|
||||||
rule_rhs_print (*rp, stderr);
|
rule_rhs_print (*rp, stderr);
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-20
@@ -134,18 +134,6 @@ xfclose (FILE *ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FILE *
|
|
||||||
xfdopen (int fd, char const *mode)
|
|
||||||
{
|
|
||||||
FILE *res = fdopen (fd, mode);
|
|
||||||
if (! res)
|
|
||||||
error (EXIT_FAILURE, get_errno (),
|
|
||||||
/* On a separate line to please the "unmarked_diagnostics"
|
|
||||||
syntax-check. */
|
|
||||||
"fdopen");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------.
|
/*------------------------------------------------------------------.
|
||||||
| Compute ALL_BUT_EXT, ALL_BUT_TAB_EXT and output files extensions. |
|
| Compute ALL_BUT_EXT, ALL_BUT_TAB_EXT and output files extensions. |
|
||||||
`------------------------------------------------------------------*/
|
`------------------------------------------------------------------*/
|
||||||
@@ -154,7 +142,7 @@ xfdopen (int fd, char const *mode)
|
|||||||
static void
|
static void
|
||||||
compute_exts_from_gf (const char *ext)
|
compute_exts_from_gf (const char *ext)
|
||||||
{
|
{
|
||||||
if (STREQ (ext, ".y"))
|
if (strcmp (ext, ".y") == 0)
|
||||||
{
|
{
|
||||||
src_extension = xstrdup (language->src_extension);
|
src_extension = xstrdup (language->src_extension);
|
||||||
header_extension = xstrdup (language->header_extension);
|
header_extension = xstrdup (language->header_extension);
|
||||||
@@ -219,7 +207,7 @@ file_name_split (const char *file_name,
|
|||||||
*base = last_component (file_name);
|
*base = last_component (file_name);
|
||||||
|
|
||||||
/* Look for the extension, i.e., look for the last dot. */
|
/* Look for the extension, i.e., look for the last dot. */
|
||||||
*ext = strrchr (*base, '.');
|
*ext = mbsrchr (*base, '.');
|
||||||
*tab = NULL;
|
*tab = NULL;
|
||||||
|
|
||||||
/* If there is an extension, check if there is a `.tab' part right
|
/* If there is an extension, check if there is a `.tab' part right
|
||||||
@@ -227,9 +215,10 @@ file_name_split (const char *file_name,
|
|||||||
if (*ext)
|
if (*ext)
|
||||||
{
|
{
|
||||||
size_t baselen = *ext - *base;
|
size_t baselen = *ext - *base;
|
||||||
size_t dottablen = sizeof (TAB_EXT) - 1;
|
size_t dottablen = 4;
|
||||||
if (dottablen < baselen
|
if (dottablen < baselen
|
||||||
&& STRPREFIX_LIT (TAB_EXT, *ext - dottablen))
|
&& (strncmp (*ext - dottablen, ".tab", dottablen) == 0
|
||||||
|
|| strncmp (*ext - dottablen, "_tab", dottablen) == 0))
|
||||||
*tab = *ext - dottablen;
|
*tab = *ext - dottablen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -358,9 +347,9 @@ void
|
|||||||
output_file_name_check (char **file_name)
|
output_file_name_check (char **file_name)
|
||||||
{
|
{
|
||||||
bool conflict = false;
|
bool conflict = false;
|
||||||
if (STREQ (*file_name, grammar_file))
|
if (0 == strcmp (*file_name, grammar_file))
|
||||||
{
|
{
|
||||||
complain (NULL, complaint, _("refusing to overwrite the input file %s"),
|
complain (_("refusing to overwrite the input file %s"),
|
||||||
quote (*file_name));
|
quote (*file_name));
|
||||||
conflict = true;
|
conflict = true;
|
||||||
}
|
}
|
||||||
@@ -368,9 +357,9 @@ output_file_name_check (char **file_name)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < file_names_count; i++)
|
for (i = 0; i < file_names_count; i++)
|
||||||
if (STREQ (file_names[i], *file_name))
|
if (0 == strcmp (file_names[i], *file_name))
|
||||||
{
|
{
|
||||||
complain (NULL, Wother, _("conflicting outputs to file %s"),
|
warn (_("conflicting outputs to file %s"),
|
||||||
quote (*file_name));
|
quote (*file_name));
|
||||||
conflict = true;
|
conflict = true;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -65,8 +65,7 @@ void compute_output_file_names (void);
|
|||||||
void output_file_names_free (void);
|
void output_file_names_free (void);
|
||||||
void output_file_name_check (char **file_name);
|
void output_file_name_check (char **file_name);
|
||||||
|
|
||||||
FILE *xfopen (const char *name, char const *mode);
|
FILE *xfopen (const char *name, const char *mode);
|
||||||
void xfclose (FILE *ptr);
|
void xfclose (FILE *ptr);
|
||||||
FILE *xfdopen (int fd, char const *mode);
|
|
||||||
|
|
||||||
#endif /* !FILES_H_ */
|
#endif /* !FILES_H_ */
|
||||||
|
|||||||
+4
-1
@@ -80,7 +80,10 @@ static struct obstack obstack_for_string;
|
|||||||
obstack_grow (&obstack_for_string, yytext, yyleng)
|
obstack_grow (&obstack_for_string, yytext, yyleng)
|
||||||
|
|
||||||
# define STRING_FINISH \
|
# define STRING_FINISH \
|
||||||
(last_string = obstack_finish0 (&obstack_for_string))
|
do { \
|
||||||
|
obstack_1grow (&obstack_for_string, '\0'); \
|
||||||
|
last_string = obstack_finish (&obstack_for_string); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
# define STRING_FREE \
|
# define STRING_FREE \
|
||||||
obstack_free (&obstack_for_string, last_string)
|
obstack_free (&obstack_for_string, last_string)
|
||||||
|
|||||||
+69
-91
@@ -26,7 +26,20 @@
|
|||||||
#include <c-strcase.h>
|
#include <c-strcase.h>
|
||||||
#include <configmake.h>
|
#include <configmake.h>
|
||||||
#include <error.h>
|
#include <error.h>
|
||||||
|
|
||||||
|
/* Hack to get <getopt.h> to declare getopt with a prototype. */
|
||||||
|
#if lint && ! defined __GNU_LIBRARY__
|
||||||
|
# define __GNU_LIBRARY__
|
||||||
|
# define HACK_FOR___GNU_LIBRARY___PROTOTYPE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#ifdef HACK_FOR___GNU_LIBRARY___PROTOTYPE
|
||||||
|
# undef __GNU_LIBRARY__
|
||||||
|
# undef HACK_FOR___GNU_LIBRARY___PROTOTYPE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <progname.h>
|
#include <progname.h>
|
||||||
|
|
||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
@@ -36,19 +49,25 @@
|
|||||||
#include "quote.h"
|
#include "quote.h"
|
||||||
#include "uniqstr.h"
|
#include "uniqstr.h"
|
||||||
|
|
||||||
|
bool debug;
|
||||||
bool defines_flag;
|
bool defines_flag;
|
||||||
bool graph_flag;
|
bool graph_flag;
|
||||||
bool xml_flag;
|
bool xml_flag;
|
||||||
|
bool locations_flag;
|
||||||
bool no_lines_flag;
|
bool no_lines_flag;
|
||||||
bool token_table_flag;
|
bool token_table_flag;
|
||||||
bool yacc_flag; /* for -y */
|
bool yacc_flag; /* for -y */
|
||||||
|
|
||||||
|
bool error_verbose = false;
|
||||||
|
|
||||||
bool nondeterministic_parser = false;
|
bool nondeterministic_parser = false;
|
||||||
bool glr_parser = false;
|
bool glr_parser = false;
|
||||||
|
|
||||||
int feature_flag = feature_caret;
|
int feature_flag = feature_none;
|
||||||
int report_flag = report_none;
|
int report_flag = report_none;
|
||||||
int trace_flag = trace_none;
|
int trace_flag = trace_none;
|
||||||
|
int warnings_flag = warnings_conflicts_sr | warnings_conflicts_rr
|
||||||
|
| warnings_other;
|
||||||
|
|
||||||
static struct bison_language const valid_languages[] = {
|
static struct bison_language const valid_languages[] = {
|
||||||
{ "c", "c-skel.m4", ".c", ".h", true },
|
{ "c", "c-skel.m4", ".c", ".h", true },
|
||||||
@@ -63,57 +82,7 @@ int language_prio = default_prio;
|
|||||||
struct bison_language const *language = &valid_languages[0];
|
struct bison_language const *language = &valid_languages[0];
|
||||||
const char *include = NULL;
|
const char *include = NULL;
|
||||||
|
|
||||||
/** Decode an option's key.
|
|
||||||
*
|
|
||||||
* \param option option being decoded.
|
|
||||||
* \param keys array of valid subarguments.
|
|
||||||
* \param values array of corresponding (int) values.
|
|
||||||
* \param all the all value.
|
|
||||||
* \param flags the flags to update
|
|
||||||
* \param arg the subarguments to decode.
|
|
||||||
* If null, then activate all the flags.
|
|
||||||
* \param no length of the potential "no-" prefix.
|
|
||||||
* Can be 0 or 3. If 3, negate the action of the subargument.
|
|
||||||
* \param err length of a potential "error=".
|
|
||||||
* Can be 0 or 6. If 6, treat the subargument as a CATEGORY
|
|
||||||
*
|
|
||||||
* If VALUE != 0 then KEY sets flags and no-KEY clears them.
|
|
||||||
* If VALUE == 0 then KEY clears all flags from \c all and no-KEY sets all
|
|
||||||
* flags from \c all. Thus no-none = all and no-all = none.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
flag_argmatch (const char *option,
|
|
||||||
const char * const keys[], const int values[],
|
|
||||||
int all, int *flags, char *arg, size_t no, size_t err)
|
|
||||||
{
|
|
||||||
int value = 0;
|
|
||||||
if (!err || arg[no + err++] != '\0')
|
|
||||||
value = XARGMATCH (option, arg + no + err, keys, values);
|
|
||||||
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
if (no)
|
|
||||||
*flags &= ~value;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (err)
|
|
||||||
warnings_flag |= value;
|
|
||||||
*flags |= value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* With a simpler 'if (no)' version, -Werror means -Werror=all
|
|
||||||
(or rather, -Werror=no-none, but that syntax is invalid).
|
|
||||||
The difference is:
|
|
||||||
- Werror activates all errors, but not the warnings
|
|
||||||
- Werror=all activates errors, and all warnings */
|
|
||||||
if (no ? !err : err)
|
|
||||||
*flags |= all;
|
|
||||||
else
|
|
||||||
*flags &= ~all;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** Decode an option's set of keys.
|
/** Decode an option's set of keys.
|
||||||
*
|
*
|
||||||
* \param option option being decoded.
|
* \param option option being decoded.
|
||||||
@@ -123,6 +92,10 @@ flag_argmatch (const char *option,
|
|||||||
* \param flags the flags to update
|
* \param flags the flags to update
|
||||||
* \param args comma separated list of effective subarguments to decode.
|
* \param args comma separated list of effective subarguments to decode.
|
||||||
* If 0, then activate all the flags.
|
* If 0, then activate all the flags.
|
||||||
|
*
|
||||||
|
* If VALUE != 0 then KEY sets flags and no-KEY clears them.
|
||||||
|
* If VALUE == 0 then KEY clears all flags from \c all and no-KEY sets all
|
||||||
|
* flags from \c all. Thus no-none = all and no-all = none.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
flags_argmatch (const char *option,
|
flags_argmatch (const char *option,
|
||||||
@@ -130,14 +103,28 @@ flags_argmatch (const char *option,
|
|||||||
int all, int *flags, char *args)
|
int all, int *flags, char *args)
|
||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
for (args = strtok (args, ","); args; args = strtok (NULL, ","))
|
|
||||||
{
|
{
|
||||||
size_t no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
|
args = strtok (args, ",");
|
||||||
size_t err = STRPREFIX_LIT ("error", args + no) ? 5 : 0;
|
while (args)
|
||||||
|
{
|
||||||
flag_argmatch (option, keys,
|
int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
|
||||||
values, all, err ? &errors_flag : flags,
|
int value = XARGMATCH (option, args + no, keys, values);
|
||||||
args, no, err);
|
if (value == 0)
|
||||||
|
{
|
||||||
|
if (no)
|
||||||
|
*flags |= all;
|
||||||
|
else
|
||||||
|
*flags &= ~all;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (no)
|
||||||
|
*flags &= ~value;
|
||||||
|
else
|
||||||
|
*flags |= value;
|
||||||
|
}
|
||||||
|
args = strtok (NULL, ",");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*flags |= all;
|
*flags |= all;
|
||||||
@@ -147,15 +134,15 @@ flags_argmatch (const char *option,
|
|||||||
*
|
*
|
||||||
* \param FlagName the flag familly to update.
|
* \param FlagName the flag familly to update.
|
||||||
* \param Args the effective sub arguments to decode.
|
* \param Args the effective sub arguments to decode.
|
||||||
* \param All the "all" value.
|
|
||||||
*
|
*
|
||||||
* \arg FlagName_args the list of keys.
|
* \arg FlagName_args the list of keys.
|
||||||
* \arg FlagName_types the list of values.
|
* \arg FlagName_types the list of values.
|
||||||
|
* \arg FlagName_all the all value.
|
||||||
* \arg FlagName_flag the flag to update.
|
* \arg FlagName_flag the flag to update.
|
||||||
*/
|
*/
|
||||||
#define FLAGS_ARGMATCH(FlagName, Args, All) \
|
#define FLAGS_ARGMATCH(FlagName, Args) \
|
||||||
flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \
|
flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \
|
||||||
All, &FlagName ## _flag, Args)
|
FlagName ## _all, &FlagName ## _flag, Args)
|
||||||
|
|
||||||
|
|
||||||
/*----------------------.
|
/*----------------------.
|
||||||
@@ -251,7 +238,6 @@ static const char * const warnings_args[] =
|
|||||||
"yacc - incompatibilities with POSIX Yacc",
|
"yacc - incompatibilities with POSIX Yacc",
|
||||||
"conflicts-sr - S/R conflicts",
|
"conflicts-sr - S/R conflicts",
|
||||||
"conflicts-rr - R/R conflicts",
|
"conflicts-rr - R/R conflicts",
|
||||||
"deprecated - obsolete constructs",
|
|
||||||
"other - all other warnings",
|
"other - all other warnings",
|
||||||
"all - all of the above",
|
"all - all of the above",
|
||||||
"error - warnings are errors",
|
"error - warnings are errors",
|
||||||
@@ -260,15 +246,14 @@ static const char * const warnings_args[] =
|
|||||||
|
|
||||||
static const int warnings_types[] =
|
static const int warnings_types[] =
|
||||||
{
|
{
|
||||||
Wnone,
|
warnings_none,
|
||||||
Wmidrule_values,
|
warnings_midrule_values,
|
||||||
Wyacc,
|
warnings_yacc,
|
||||||
Wconflicts_sr,
|
warnings_conflicts_sr,
|
||||||
Wconflicts_rr,
|
warnings_conflicts_rr,
|
||||||
Wdeprecated,
|
warnings_other,
|
||||||
Wother,
|
warnings_all,
|
||||||
Wall,
|
warnings_error
|
||||||
Werror
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ARGMATCH_VERIFY (warnings_args, warnings_types);
|
ARGMATCH_VERIFY (warnings_args, warnings_types);
|
||||||
@@ -345,8 +330,7 @@ Operation modes:\n\
|
|||||||
Parser:\n\
|
Parser:\n\
|
||||||
-L, --language=LANGUAGE specify the output programming language\n\
|
-L, --language=LANGUAGE specify the output programming language\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 tracing\n\
|
-t, --debug instrument the parser for debugging\n\
|
||||||
same as `-Dparse.trace'\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\
|
||||||
@@ -385,7 +369,7 @@ Warning categories include:\n\
|
|||||||
`all' all the warnings\n\
|
`all' all the warnings\n\
|
||||||
`no-CATEGORY' turn off warnings in CATEGORY\n\
|
`no-CATEGORY' turn off warnings in CATEGORY\n\
|
||||||
`none' turn off all the warnings\n\
|
`none' turn off all the warnings\n\
|
||||||
`error[=CATEGORY]' treat warnings as errors\n\
|
`error' treat warnings as errors\n\
|
||||||
"), stdout);
|
"), stdout);
|
||||||
putc ('\n', stdout);
|
putc ('\n', stdout);
|
||||||
|
|
||||||
@@ -417,7 +401,7 @@ FEATURE is a list of comma separated words that can include:\n\
|
|||||||
Note we still output for 'C' so that it gets included in the
|
Note we still output for 'C' so that it gets included in the
|
||||||
man page. */
|
man page. */
|
||||||
const char *lc_messages = setlocale (LC_MESSAGES, NULL);
|
const char *lc_messages = setlocale (LC_MESSAGES, NULL);
|
||||||
if (lc_messages && !STREQ (lc_messages, "en_"))
|
if (lc_messages && strcmp (lc_messages, "en_"))
|
||||||
/* TRANSLATORS: Replace LANG_CODE in this URL with your language
|
/* TRANSLATORS: Replace LANG_CODE in this URL with your language
|
||||||
code <http://translationproject.org/team/LANG_CODE.html> to
|
code <http://translationproject.org/team/LANG_CODE.html> to
|
||||||
form one of the URLs at http://translationproject.org/team/.
|
form one of the URLs at http://translationproject.org/team/.
|
||||||
@@ -471,8 +455,7 @@ skeleton_arg (char const *arg, int prio, location loc)
|
|||||||
skeleton = arg;
|
skeleton = arg;
|
||||||
}
|
}
|
||||||
else if (prio == skeleton_prio)
|
else if (prio == skeleton_prio)
|
||||||
complain (&loc, complaint,
|
complain_at (loc, _("multiple skeleton declarations are invalid"));
|
||||||
_("multiple skeleton declarations are invalid"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -497,7 +480,7 @@ language_argmatch (char const *arg, int prio, location loc)
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
complain (&loc, complaint, msg, quotearg_colon (arg));
|
complain_at (loc, msg, quotearg_colon (arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------.
|
/*----------------------.
|
||||||
@@ -630,7 +613,7 @@ getargs (int argc, char *argv[])
|
|||||||
case 'F': /* -FNAME[=VALUE]. */
|
case 'F': /* -FNAME[=VALUE]. */
|
||||||
{
|
{
|
||||||
char* name = optarg;
|
char* name = optarg;
|
||||||
char* value = strchr (optarg, '=');
|
char* value = mbschr (optarg, '=');
|
||||||
if (value)
|
if (value)
|
||||||
*value++ = 0;
|
*value++ = 0;
|
||||||
muscle_percent_define_insert (name, command_line_location (),
|
muscle_percent_define_insert (name, command_line_location (),
|
||||||
@@ -655,7 +638,7 @@ getargs (int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'T':
|
case 'T':
|
||||||
FLAGS_ARGMATCH (trace, optarg, trace_all);
|
FLAGS_ARGMATCH (trace, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
@@ -663,11 +646,11 @@ getargs (int argc, char *argv[])
|
|||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
FLAGS_ARGMATCH (feature, optarg, feature_all);
|
FLAGS_ARGMATCH (feature, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'W':
|
case 'W':
|
||||||
FLAGS_ARGMATCH (warnings, optarg, Wall);
|
FLAGS_ARGMATCH (warnings, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
@@ -713,13 +696,11 @@ getargs (int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
FLAGS_ARGMATCH (report, optarg, report_all);
|
FLAGS_ARGMATCH (report, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
muscle_percent_define_insert ("parse.trace",
|
debug = true;
|
||||||
command_line_location (), "",
|
|
||||||
MUSCLE_PERCENT_DEFINE_D);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
@@ -736,14 +717,11 @@ getargs (int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'y':
|
case 'y':
|
||||||
warnings_flag |= Wyacc;
|
|
||||||
errors_flag |= Wyacc;
|
|
||||||
yacc_flag = true;
|
yacc_flag = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOCATIONS_OPTION:
|
case LOCATIONS_OPTION:
|
||||||
muscle_percent_define_ensure ("locations",
|
locations_flag = true;
|
||||||
command_line_location (), true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRINT_LOCALEDIR_OPTION:
|
case PRINT_LOCALEDIR_OPTION:
|
||||||
@@ -751,7 +729,7 @@ getargs (int argc, char *argv[])
|
|||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case PRINT_DATADIR_OPTION:
|
case PRINT_DATADIR_OPTION:
|
||||||
printf ("%s\n", pkgdatadir ());
|
printf ("%s\n", compute_pkgdatadir ());
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case REPORT_FILE_OPTION:
|
case REPORT_FILE_OPTION:
|
||||||
|
|||||||
@@ -34,13 +34,17 @@ extern int skeleton_prio;
|
|||||||
/* for -I */
|
/* for -I */
|
||||||
extern char const *include;
|
extern char const *include;
|
||||||
|
|
||||||
|
extern bool debug; /* for -t */
|
||||||
extern bool defines_flag; /* for -d */
|
extern bool defines_flag; /* for -d */
|
||||||
extern bool graph_flag; /* for -g */
|
extern bool graph_flag; /* for -g */
|
||||||
extern bool xml_flag; /* for -x */
|
extern bool xml_flag; /* for -x */
|
||||||
|
extern bool locations_flag;
|
||||||
extern bool no_lines_flag; /* for -l */
|
extern bool no_lines_flag; /* for -l */
|
||||||
extern bool token_table_flag; /* for -k */
|
extern bool token_table_flag; /* for -k */
|
||||||
extern bool yacc_flag; /* for -y */
|
extern bool yacc_flag; /* for -y */
|
||||||
|
|
||||||
|
extern bool error_verbose;
|
||||||
|
|
||||||
|
|
||||||
/* GLR_PARSER is true if the input file says to use the GLR
|
/* GLR_PARSER is true if the input file says to use the GLR
|
||||||
(Generalized LR) parser, and to output some additional information
|
(Generalized LR) parser, and to output some additional information
|
||||||
@@ -108,6 +112,24 @@ enum trace
|
|||||||
/** What debug items bison displays during its run. */
|
/** What debug items bison displays during its run. */
|
||||||
extern int trace_flag;
|
extern int trace_flag;
|
||||||
|
|
||||||
|
/*-------------.
|
||||||
|
| --warnings. |
|
||||||
|
`-------------*/
|
||||||
|
|
||||||
|
enum warnings
|
||||||
|
{
|
||||||
|
warnings_none = 0, /**< Issue no warnings. */
|
||||||
|
warnings_error = 1 << 0, /**< Warnings are treated as errors. */
|
||||||
|
warnings_midrule_values = 1 << 1, /**< Unset or unused midrule values. */
|
||||||
|
warnings_yacc = 1 << 2, /**< POSIXME. */
|
||||||
|
warnings_conflicts_sr = 1 << 3, /**< S/R conflicts. */
|
||||||
|
warnings_conflicts_rr = 1 << 4, /**< R/R conflicts. */
|
||||||
|
warnings_other = 1 << 5, /**< All other warnings. */
|
||||||
|
warnings_all = ~warnings_error /**< All above warnings. */
|
||||||
|
};
|
||||||
|
/** What warnings are issued. */
|
||||||
|
extern int warnings_flag;
|
||||||
|
|
||||||
/*-------------.
|
/*-------------.
|
||||||
| --features. |
|
| --features. |
|
||||||
`-------------*/
|
`-------------*/
|
||||||
|
|||||||
+29
-27
@@ -47,43 +47,50 @@ symbol_number *token_translations = NULL;
|
|||||||
int max_user_token_number = 256;
|
int max_user_token_number = 256;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
rule_useful_in_grammar_p (rule const *r)
|
rule_useful_in_grammar_p (rule *r)
|
||||||
{
|
{
|
||||||
return r->number < nrules;
|
return r->number < nrules;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
rule_useless_in_grammar_p (rule const *r)
|
rule_useless_in_grammar_p (rule *r)
|
||||||
{
|
{
|
||||||
return !rule_useful_in_grammar_p (r);
|
return !rule_useful_in_grammar_p (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
rule_useless_in_parser_p (rule const *r)
|
rule_useless_in_parser_p (rule *r)
|
||||||
{
|
{
|
||||||
return !r->useful && rule_useful_in_grammar_p (r);
|
return !r->useful && rule_useful_in_grammar_p (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rule_lhs_print (rule const *r, symbol const *previous_lhs, FILE *out)
|
rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out)
|
||||||
{
|
{
|
||||||
fprintf (out, " %3d ", r->number);
|
fprintf (out, " %3d ", r->number);
|
||||||
if (previous_lhs != r->lhs)
|
if (previous_lhs != r->lhs)
|
||||||
|
{
|
||||||
fprintf (out, "%s:", r->lhs->tag);
|
fprintf (out, "%s:", r->lhs->tag);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
fprintf (out, "%*s|", (int) strlen (previous_lhs->tag), "");
|
{
|
||||||
|
int n;
|
||||||
|
for (n = strlen (previous_lhs->tag); n > 0; --n)
|
||||||
|
fputc (' ', out);
|
||||||
|
fputc ('|', out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rule_lhs_print_xml (rule const *r, FILE *out, int level)
|
rule_lhs_print_xml (rule *r, FILE *out, int level)
|
||||||
{
|
{
|
||||||
xml_printf (out, level, "<lhs>%s</lhs>", r->lhs->tag);
|
xml_printf (out, level, "<lhs>%s</lhs>", r->lhs->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
int
|
||||||
rule_rhs_length (rule const *r)
|
rule_rhs_length (rule *r)
|
||||||
{
|
{
|
||||||
size_t res = 0;
|
int res = 0;
|
||||||
item_number *rhsp;
|
item_number *rhsp;
|
||||||
for (rhsp = r->rhs; *rhsp >= 0; ++rhsp)
|
for (rhsp = r->rhs; *rhsp >= 0; ++rhsp)
|
||||||
++res;
|
++res;
|
||||||
@@ -91,22 +98,23 @@ rule_rhs_length (rule const *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rule_rhs_print (rule const *r, FILE *out)
|
rule_rhs_print (rule *r, FILE *out)
|
||||||
{
|
{
|
||||||
if (*r->rhs >= 0)
|
if (*r->rhs >= 0)
|
||||||
{
|
{
|
||||||
item_number *rp;
|
item_number *rp;
|
||||||
for (rp = r->rhs; *rp >= 0; rp++)
|
for (rp = r->rhs; *rp >= 0; rp++)
|
||||||
fprintf (out, " %s", symbols[*rp]->tag);
|
fprintf (out, " %s", symbols[*rp]->tag);
|
||||||
|
fputc ('\n', out);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (out, " /* %s */", _("empty"));
|
fprintf (out, " /* %s */\n", _("empty"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rule_rhs_print_xml (rule const *r, FILE *out, int level)
|
rule_rhs_print_xml (rule *r, FILE *out, int level)
|
||||||
{
|
{
|
||||||
if (*r->rhs >= 0)
|
if (*r->rhs >= 0)
|
||||||
{
|
{
|
||||||
@@ -125,8 +133,8 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
rule_print (rule const *r, FILE *out)
|
rule_print (rule *r, FILE *out)
|
||||||
{
|
{
|
||||||
fprintf (out, "%s:", r->lhs->tag);
|
fprintf (out, "%s:", r->lhs->tag);
|
||||||
rule_rhs_print (r, out);
|
rule_rhs_print (r, out);
|
||||||
@@ -181,7 +189,6 @@ grammar_rules_partial_print (FILE *out, const char *title,
|
|||||||
first = false;
|
first = false;
|
||||||
rule_lhs_print (&rules[r], previous_lhs, out);
|
rule_lhs_print (&rules[r], previous_lhs, out);
|
||||||
rule_rhs_print (&rules[r], out);
|
rule_rhs_print (&rules[r], out);
|
||||||
fprintf (out, "\n");
|
|
||||||
previous_lhs = rules[r].lhs;
|
previous_lhs = rules[r].lhs;
|
||||||
}
|
}
|
||||||
if (!first)
|
if (!first)
|
||||||
@@ -256,12 +263,10 @@ grammar_dump (FILE *out, const char *title)
|
|||||||
fprintf (out, "Rules\n-----\n\n");
|
fprintf (out, "Rules\n-----\n\n");
|
||||||
{
|
{
|
||||||
rule_number i;
|
rule_number i;
|
||||||
fprintf (out,
|
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
|
||||||
"Num (Prec, Assoc, Useful, Ritem Range) Lhs"
|
|
||||||
" -> Rhs (Ritem range) [Num]\n");
|
|
||||||
for (i = 0; i < nrules + nuseless_productions; i++)
|
for (i = 0; i < nrules + nuseless_productions; i++)
|
||||||
{
|
{
|
||||||
rule const *rule_i = &rules[i];
|
rule *rule_i = &rules[i];
|
||||||
item_number *rp = NULL;
|
item_number *rp = NULL;
|
||||||
unsigned int rhs_itemno = rule_i->rhs - ritem;
|
unsigned int rhs_itemno = rule_i->rhs - ritem;
|
||||||
unsigned int rhs_count = 0;
|
unsigned int rhs_count = 0;
|
||||||
@@ -291,7 +296,6 @@ grammar_dump (FILE *out, const char *title)
|
|||||||
{
|
{
|
||||||
fprintf (out, "%-5d ", r);
|
fprintf (out, "%-5d ", r);
|
||||||
rule_print (&rules[r], out);
|
rule_print (&rules[r], out);
|
||||||
fprintf (out, "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (out, "\n\n");
|
fprintf (out, "\n\n");
|
||||||
@@ -299,22 +303,20 @@ grammar_dump (FILE *out, const char *title)
|
|||||||
|
|
||||||
void
|
void
|
||||||
grammar_rules_useless_report (const char *message)
|
grammar_rules_useless_report (const char *message)
|
||||||
{
|
|
||||||
warnings w = Wother;
|
|
||||||
if (warnings_flag & w)
|
|
||||||
{
|
{
|
||||||
rule_number r;
|
rule_number r;
|
||||||
for (r = 0; r < nrules ; ++r)
|
for (r = 0; r < nrules ; ++r)
|
||||||
if (!rules[r].useful)
|
if (!rules[r].useful)
|
||||||
{
|
{
|
||||||
if (feature_flag & feature_caret)
|
if (feature_flag & feature_caret)
|
||||||
complain (&rules[r].location, w, "%s", message);
|
warn_at (rules[r].location, "%s", message);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
complain (&rules[r].location, w | silent, "%s: ", message);
|
warn_at (rules[r].location, "%s: ", message);
|
||||||
|
if (warnings_flag & warnings_other)
|
||||||
|
{
|
||||||
rule_print (&rules[r], stderr);
|
rule_print (&rules[r], stderr);
|
||||||
warnings_print_categories (w);
|
fflush (stderr);
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-9
@@ -194,7 +194,6 @@ typedef struct
|
|||||||
|
|
||||||
location location;
|
location location;
|
||||||
bool useful;
|
bool useful;
|
||||||
bool is_predicate;
|
|
||||||
|
|
||||||
const char *action;
|
const char *action;
|
||||||
location action_location;
|
location action_location;
|
||||||
@@ -203,31 +202,34 @@ typedef struct
|
|||||||
extern rule *rules;
|
extern rule *rules;
|
||||||
|
|
||||||
/* A function that selects a rule. */
|
/* A function that selects a rule. */
|
||||||
typedef bool (*rule_filter) (rule const *);
|
typedef bool (*rule_filter) (rule *);
|
||||||
|
|
||||||
/* Return true IFF the rule has a `number' smaller than NRULES. That is, it is
|
/* Return true IFF the rule has a `number' smaller than NRULES. That is, it is
|
||||||
useful in the grammar. */
|
useful in the grammar. */
|
||||||
bool rule_useful_in_grammar_p (rule const *r);
|
bool rule_useful_in_grammar_p (rule *r);
|
||||||
|
|
||||||
/* Return true IFF the rule has a `number' higher than NRULES. That is, it is
|
/* Return true IFF the rule has a `number' higher than NRULES. That is, it is
|
||||||
useless in the grammar. */
|
useless in the grammar. */
|
||||||
bool rule_useless_in_grammar_p (rule const *r);
|
bool rule_useless_in_grammar_p (rule *r);
|
||||||
|
|
||||||
/* Return true IFF the rule is not flagged as useful but is useful in the
|
/* Return true IFF the rule is not flagged as useful but is useful in the
|
||||||
grammar. In other words, it was discarded because of conflicts. */
|
grammar. In other words, it was discarded because of conflicts. */
|
||||||
bool rule_useless_in_parser_p (rule const *r);
|
bool rule_useless_in_parser_p (rule *r);
|
||||||
|
|
||||||
/* Print this rule's number and lhs on OUT. If a PREVIOUS_LHS was
|
/* Print this rule's number and lhs on OUT. If a PREVIOUS_LHS was
|
||||||
already displayed (by a previous call for another rule), avoid
|
already displayed (by a previous call for another rule), avoid
|
||||||
useless repetitions. */
|
useless repetitions. */
|
||||||
void rule_lhs_print (rule const *r, symbol const *previous_lhs, FILE *out);
|
void rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out);
|
||||||
void rule_lhs_print_xml (rule const *r, FILE *out, int level);
|
void rule_lhs_print_xml (rule *r, FILE *out, int level);
|
||||||
|
|
||||||
/* Return the length of the RHS. */
|
/* Return the length of the RHS. */
|
||||||
size_t rule_rhs_length (rule const *r);
|
int rule_rhs_length (rule *r);
|
||||||
|
|
||||||
/* Print this rule's RHS on OUT. */
|
/* Print this rule's RHS on OUT. */
|
||||||
void rule_rhs_print (rule const *r, FILE *out);
|
void rule_rhs_print (rule *r, FILE *out);
|
||||||
|
|
||||||
|
/* Print this rule on OUT. */
|
||||||
|
void rule_print (rule *r, FILE *out);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1095,11 +1095,11 @@ ielr (void)
|
|||||||
/* Examine user options. */
|
/* Examine user options. */
|
||||||
{
|
{
|
||||||
char *type = muscle_percent_define_get ("lr.type");
|
char *type = muscle_percent_define_get ("lr.type");
|
||||||
if (STREQ (type, "lalr"))
|
if (0 == strcmp (type, "lalr"))
|
||||||
lr_type = LR_TYPE__LALR;
|
lr_type = LR_TYPE__LALR;
|
||||||
else if (STREQ (type, "ielr"))
|
else if (0 == strcmp (type, "ielr"))
|
||||||
lr_type = LR_TYPE__IELR;
|
lr_type = LR_TYPE__IELR;
|
||||||
else if (STREQ (type, "canonical-lr"))
|
else if (0 == strcmp (type, "canonical-lr"))
|
||||||
lr_type = LR_TYPE__CANONICAL_LR;
|
lr_type = LR_TYPE__CANONICAL_LR;
|
||||||
else
|
else
|
||||||
aver (false);
|
aver (false);
|
||||||
|
|||||||
+3
-2
@@ -371,8 +371,9 @@ initialize_LA (void)
|
|||||||
bool default_reduction_only_for_accept;
|
bool default_reduction_only_for_accept;
|
||||||
{
|
{
|
||||||
char *default_reductions =
|
char *default_reductions =
|
||||||
muscle_percent_define_get ("lr.default-reduction");
|
muscle_percent_define_get ("lr.default-reductions");
|
||||||
default_reduction_only_for_accept = STREQ (default_reductions, "accepting");
|
default_reduction_only_for_accept =
|
||||||
|
0 == strcmp (default_reductions, "accepting");
|
||||||
free (default_reductions);
|
free (default_reductions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-123
@@ -1,123 +0,0 @@
|
|||||||
# Copyright (C) 2001-2013 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/>.
|
|
||||||
|
|
||||||
LDADD = lib/libbison.a $(LIBINTL)
|
|
||||||
|
|
||||||
bin_PROGRAMS = src/bison
|
|
||||||
# Prettify Automake-computed names of compiled objects.
|
|
||||||
src_bison_SHORTNAME = bison
|
|
||||||
|
|
||||||
src_bison_CFLAGS = $(AM_CFLAGS) $(WERROR_CFLAGS)
|
|
||||||
src_bison_SOURCES = \
|
|
||||||
src/AnnotationList.c \
|
|
||||||
src/AnnotationList.h \
|
|
||||||
src/InadequacyList.c \
|
|
||||||
src/InadequacyList.h \
|
|
||||||
src/LR0.c \
|
|
||||||
src/LR0.h \
|
|
||||||
src/Sbitset.c \
|
|
||||||
src/Sbitset.h \
|
|
||||||
src/assoc.c \
|
|
||||||
src/assoc.h \
|
|
||||||
src/closure.c \
|
|
||||||
src/closure.h \
|
|
||||||
src/complain.c \
|
|
||||||
src/complain.h \
|
|
||||||
src/conflicts.c \
|
|
||||||
src/conflicts.h \
|
|
||||||
src/derives.c \
|
|
||||||
src/derives.h \
|
|
||||||
src/files.c \
|
|
||||||
src/files.h \
|
|
||||||
src/flex-scanner.h \
|
|
||||||
src/getargs.c \
|
|
||||||
src/getargs.h \
|
|
||||||
src/gram.c \
|
|
||||||
src/gram.h \
|
|
||||||
src/graphviz.c \
|
|
||||||
src/graphviz.h \
|
|
||||||
src/lalr.c \
|
|
||||||
src/lalr.h \
|
|
||||||
src/ielr.c \
|
|
||||||
src/ielr.h \
|
|
||||||
src/location.c \
|
|
||||||
src/location.h \
|
|
||||||
src/main.c \
|
|
||||||
src/muscle-tab.c \
|
|
||||||
src/muscle-tab.h \
|
|
||||||
src/named-ref.c \
|
|
||||||
src/named-ref.h \
|
|
||||||
src/nullable.c \
|
|
||||||
src/nullable.h \
|
|
||||||
src/output.c \
|
|
||||||
src/output.h \
|
|
||||||
src/parse-gram.y \
|
|
||||||
src/print-xml.c \
|
|
||||||
src/print-xml.h \
|
|
||||||
src/print.c \
|
|
||||||
src/print.h \
|
|
||||||
src/print_graph.c \
|
|
||||||
src/print_graph.h \
|
|
||||||
src/reader.c \
|
|
||||||
src/reader.h \
|
|
||||||
src/reduce.c \
|
|
||||||
src/reduce.h \
|
|
||||||
src/relation.c \
|
|
||||||
src/relation.h \
|
|
||||||
src/scan-code-c.c \
|
|
||||||
src/scan-code.h \
|
|
||||||
src/scan-gram-c.c \
|
|
||||||
src/scan-gram.h \
|
|
||||||
src/scan-skel-c.c \
|
|
||||||
src/scan-skel.h \
|
|
||||||
src/state.c \
|
|
||||||
src/state.h \
|
|
||||||
src/symlist.c \
|
|
||||||
src/symlist.h \
|
|
||||||
src/symtab.c \
|
|
||||||
src/symtab.h \
|
|
||||||
src/system.h \
|
|
||||||
src/tables.c \
|
|
||||||
src/tables.h \
|
|
||||||
src/uniqstr.c \
|
|
||||||
src/uniqstr.h
|
|
||||||
|
|
||||||
EXTRA_src_bison_SOURCES = \
|
|
||||||
src/scan-code.l \
|
|
||||||
src/scan-gram.l \
|
|
||||||
src/scan-skel.l
|
|
||||||
|
|
||||||
BUILT_SOURCES += \
|
|
||||||
src/parse-gram.c \
|
|
||||||
src/parse-gram.h \
|
|
||||||
src/scan-code.c \
|
|
||||||
src/scan-gram.c \
|
|
||||||
src/scan-skel.c
|
|
||||||
|
|
||||||
|
|
||||||
## ------ ##
|
|
||||||
## yacc. ##
|
|
||||||
## ------ ##
|
|
||||||
|
|
||||||
bin_SCRIPTS = $(YACC_SCRIPT)
|
|
||||||
EXTRA_SCRIPTS = src/yacc
|
|
||||||
MOSTLYCLEANFILES += src/yacc
|
|
||||||
|
|
||||||
src/yacc:
|
|
||||||
$(AM_V_GEN)rm -f $@ $@.tmp
|
|
||||||
$(AM_V_at)echo '#! /bin/sh' >$@.tmp
|
|
||||||
$(AM_V_at)echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@.tmp
|
|
||||||
$(AM_V_at)chmod a+x $@.tmp
|
|
||||||
$(AM_V_at)mv $@.tmp $@
|
|
||||||
+24
-28
@@ -90,9 +90,9 @@ location_compute (location *loc, boundary *cur, char const *token, size_t size)
|
|||||||
loc->end = *cur;
|
loc->end = *cur;
|
||||||
|
|
||||||
if (line == INT_MAX && loc->start.line != INT_MAX)
|
if (line == INT_MAX && loc->start.line != INT_MAX)
|
||||||
complain (loc, Wother, _("line number overflow"));
|
warn_at (*loc, _("line number overflow"));
|
||||||
if (column == INT_MAX && loc->start.column != INT_MAX)
|
if (column == INT_MAX && loc->start.column != INT_MAX)
|
||||||
complain (loc, Wother, _("column number overflow"));
|
warn_at (*loc, _("column number overflow"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -155,9 +155,6 @@ cleanup_caret ()
|
|||||||
{
|
{
|
||||||
if (caret_info.source)
|
if (caret_info.source)
|
||||||
fclose (caret_info.source);
|
fclose (caret_info.source);
|
||||||
caret_info.source = NULL;
|
|
||||||
caret_info.line = 1;
|
|
||||||
caret_info.offset = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -171,8 +168,8 @@ location_caret (FILE *out, location loc)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* If the line we want to quote is seekable (the same line as the previous
|
/* If the line we want to quote is seekable (the same line as the previous
|
||||||
location), just seek it. If it was a previous line, we lost track of it,
|
location), just seek it. If it was before, we lost track of it, so
|
||||||
so return to the start of file. */
|
return to the start of file. */
|
||||||
if (caret_info.line <= loc.start.line)
|
if (caret_info.line <= loc.start.line)
|
||||||
fseek (caret_info.source, caret_info.offset, SEEK_SET);
|
fseek (caret_info.source, caret_info.offset, SEEK_SET);
|
||||||
else
|
else
|
||||||
@@ -184,36 +181,35 @@ location_caret (FILE *out, location loc)
|
|||||||
|
|
||||||
/* Advance to the line's position, keeping track of the offset. */
|
/* Advance to the line's position, keeping track of the offset. */
|
||||||
while (caret_info.line < loc.start.line)
|
while (caret_info.line < loc.start.line)
|
||||||
caret_info.line += getc (caret_info.source) == '\n';
|
caret_info.line += fgetc (caret_info.source) == '\n';
|
||||||
caret_info.offset = ftell (caret_info.source);
|
caret_info.offset = ftell (caret_info.source);
|
||||||
|
|
||||||
/* Read the actual line. Don't update the offset, so that we keep a pointer
|
/* Read the actual line. Don't update the offset, so that we keep a pointer
|
||||||
to the start of the line. */
|
to the start of the line. */
|
||||||
{
|
{
|
||||||
char c = getc (caret_info.source);
|
char *buf = NULL;
|
||||||
if (c != EOF)
|
size_t size = 0;
|
||||||
{
|
ssize_t len = getline (&buf, &size, caret_info.source);
|
||||||
/* Quote the file, indent by a single column. */
|
if (0 < len)
|
||||||
putc (' ', out);
|
|
||||||
do
|
|
||||||
putc (c, out);
|
|
||||||
while ((c = getc (caret_info.source)) != EOF && c != '\n');
|
|
||||||
putc ('\n', out);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
/* The caret of a multiline location ends with the first line. */
|
/* The caret of a multiline location ends with the first line. */
|
||||||
size_t len = loc.start.line != loc.end.line
|
int end = loc.start.line != loc.end.line ? len : loc.end.column;
|
||||||
? ftell (caret_info.source) - caret_info.offset
|
|
||||||
: loc.end.column;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Print the carets (at least one), with the same indent as above.*/
|
/* Quote the file, indent by a single column. */
|
||||||
|
fputc (' ', out);
|
||||||
|
fwrite (buf, 1, len, out);
|
||||||
|
|
||||||
|
/* Print the caret, with the same indent as above. */
|
||||||
fprintf (out, " %*s", loc.start.column - 1, "");
|
fprintf (out, " %*s", loc.start.column - 1, "");
|
||||||
for (i = loc.start.column; i == loc.start.column || i < len; ++i)
|
{
|
||||||
putc ('^', out);
|
int i = loc.start.column;
|
||||||
|
do
|
||||||
|
fputc ('^', out);
|
||||||
|
while (++i < end);
|
||||||
}
|
}
|
||||||
putc ('\n', out);
|
fputc ('\n', out);
|
||||||
}
|
}
|
||||||
|
free (buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,11 +218,11 @@ boundary_set_from_string (boundary *bound, char *loc_str)
|
|||||||
{
|
{
|
||||||
/* Must search in reverse since the file name field may
|
/* Must search in reverse since the file name field may
|
||||||
* contain `.' or `:'. */
|
* contain `.' or `:'. */
|
||||||
char *delim = strrchr (loc_str, '.');
|
char *delim = mbsrchr (loc_str, '.');
|
||||||
aver (delim);
|
aver (delim);
|
||||||
*delim = '\0';
|
*delim = '\0';
|
||||||
bound->column = atoi (delim+1);
|
bound->column = atoi (delim+1);
|
||||||
delim = strrchr (loc_str, ':');
|
delim = mbsrchr (loc_str, ':');
|
||||||
aver (delim);
|
aver (delim);
|
||||||
*delim = '\0';
|
*delim = '\0';
|
||||||
bound->line = atoi (delim+1);
|
bound->line = atoi (delim+1);
|
||||||
|
|||||||
+7
-10
@@ -66,7 +66,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
{
|
{
|
||||||
char const *cp = getenv ("LC_CTYPE");
|
char const *cp = getenv ("LC_CTYPE");
|
||||||
if (cp && STREQ (cp, "C"))
|
if (cp && !strcmp (cp, "C"))
|
||||||
set_custom_quoting ("e_quoting_options, "'", "'");
|
set_custom_quoting ("e_quoting_options, "'", "'");
|
||||||
else
|
else
|
||||||
set_quoting_style ("e_quoting_options, locale_quoting_style);
|
set_quoting_style ("e_quoting_options, locale_quoting_style);
|
||||||
@@ -94,7 +94,7 @@ main (int argc, char *argv[])
|
|||||||
reader ();
|
reader ();
|
||||||
timevar_pop (TV_READER);
|
timevar_pop (TV_READER);
|
||||||
|
|
||||||
if (complaint_status == status_complaint)
|
if (complaint_issued)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
/* Find useless nonterminals and productions and reduce the grammar. */
|
/* Find useless nonterminals and productions and reduce the grammar. */
|
||||||
@@ -125,7 +125,7 @@ main (int argc, char *argv[])
|
|||||||
declarations. */
|
declarations. */
|
||||||
timevar_push (TV_CONFLICTS);
|
timevar_push (TV_CONFLICTS);
|
||||||
conflicts_solve ();
|
conflicts_solve ();
|
||||||
if (!muscle_percent_define_flag_if ("lr.keep-unreachable-state"))
|
if (!muscle_percent_define_flag_if ("lr.keep-unreachable-states"))
|
||||||
{
|
{
|
||||||
state_number *old_to_new = xnmalloc (nstates, sizeof *old_to_new);
|
state_number *old_to_new = xnmalloc (nstates, sizeof *old_to_new);
|
||||||
state_number nstates_old = nstates;
|
state_number nstates_old = nstates;
|
||||||
@@ -142,11 +142,8 @@ main (int argc, char *argv[])
|
|||||||
tables_generate ();
|
tables_generate ();
|
||||||
timevar_pop (TV_ACTIONS);
|
timevar_pop (TV_ACTIONS);
|
||||||
|
|
||||||
grammar_rules_useless_report (_("rule useless in parser due to conflicts"));
|
grammar_rules_useless_report
|
||||||
|
(_("rule useless in parser due to conflicts"));
|
||||||
print_precedence_warnings ();
|
|
||||||
|
|
||||||
print_assoc_warnings ();
|
|
||||||
|
|
||||||
/* Output file names. */
|
/* Output file names. */
|
||||||
compute_output_file_names ();
|
compute_output_file_names ();
|
||||||
@@ -177,7 +174,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
/* Stop if there were errors, to avoid trashing previous output
|
/* Stop if there were errors, to avoid trashing previous output
|
||||||
files. */
|
files. */
|
||||||
if (complaint_status == status_complaint)
|
if (complaint_issued)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
/* Lookahead tokens are no longer needed. */
|
/* Lookahead tokens are no longer needed. */
|
||||||
@@ -221,5 +218,5 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
cleanup_caret ();
|
cleanup_caret ();
|
||||||
|
|
||||||
return complaint_status ? EXIT_FAILURE : EXIT_SUCCESS;
|
return complaint_issued ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+94
-148
@@ -50,7 +50,7 @@ hash_compare_muscles (void const *x, void const *y)
|
|||||||
{
|
{
|
||||||
muscle_entry const *m1 = x;
|
muscle_entry const *m1 = x;
|
||||||
muscle_entry const *m2 = y;
|
muscle_entry const *m2 = y;
|
||||||
return STREQ (m1->key, m2->key);
|
return strcmp (m1->key, m2->key) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
@@ -157,9 +157,12 @@ muscle_grow (const char *key, const char *val, const char *separator)
|
|||||||
{
|
{
|
||||||
/* Grow the current value. */
|
/* Grow the current value. */
|
||||||
char *new_val;
|
char *new_val;
|
||||||
obstack_printf (&muscle_obstack, "%s%s%s", entry->value, separator, val);
|
obstack_sgrow (&muscle_obstack, entry->value);
|
||||||
free (entry->storage);
|
free (entry->storage);
|
||||||
new_val = obstack_finish0 (&muscle_obstack);
|
obstack_sgrow (&muscle_obstack, separator);
|
||||||
|
obstack_sgrow (&muscle_obstack, val);
|
||||||
|
obstack_1grow (&muscle_obstack, 0);
|
||||||
|
new_val = obstack_finish (&muscle_obstack);
|
||||||
entry->value = entry->storage = xstrdup (new_val);
|
entry->value = entry->storage = xstrdup (new_val);
|
||||||
obstack_free (&muscle_obstack, new_val);
|
obstack_free (&muscle_obstack, new_val);
|
||||||
}
|
}
|
||||||
@@ -178,7 +181,8 @@ muscle_syncline_grow (char const *key, location loc)
|
|||||||
obstack_quote (&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, ")[");
|
||||||
extension = obstack_finish0 (&muscle_obstack);
|
obstack_1grow (&muscle_obstack, 0);
|
||||||
|
extension = obstack_finish (&muscle_obstack);
|
||||||
muscle_grow (key, extension, "");
|
muscle_grow (key, extension, "");
|
||||||
obstack_free (&muscle_obstack, extension);
|
obstack_free (&muscle_obstack, extension);
|
||||||
}
|
}
|
||||||
@@ -206,7 +210,8 @@ void muscle_pair_list_grow (const char *muscle,
|
|||||||
obstack_sgrow (&muscle_obstack, ", ");
|
obstack_sgrow (&muscle_obstack, ", ");
|
||||||
obstack_quote (&muscle_obstack, a2);
|
obstack_quote (&muscle_obstack, a2);
|
||||||
obstack_sgrow (&muscle_obstack, "]");
|
obstack_sgrow (&muscle_obstack, "]");
|
||||||
pair = obstack_finish0 (&muscle_obstack);
|
obstack_1grow (&muscle_obstack, 0);
|
||||||
|
pair = obstack_finish (&muscle_obstack);
|
||||||
muscle_grow (muscle, pair, ",\n");
|
muscle_grow (muscle, pair, ",\n");
|
||||||
obstack_free (&muscle_obstack, pair);
|
obstack_free (&muscle_obstack, pair);
|
||||||
}
|
}
|
||||||
@@ -263,8 +268,13 @@ muscle_boundary_grow (char const *key, boundary bound)
|
|||||||
char *extension;
|
char *extension;
|
||||||
obstack_sgrow (&muscle_obstack, "[[");
|
obstack_sgrow (&muscle_obstack, "[[");
|
||||||
obstack_escape (&muscle_obstack, bound.file);
|
obstack_escape (&muscle_obstack, bound.file);
|
||||||
obstack_printf (&muscle_obstack, ":%d.%d]]", bound.line, bound.column);
|
obstack_1grow (&muscle_obstack, ':');
|
||||||
extension = obstack_finish0 (&muscle_obstack);
|
obstack_printf (&muscle_obstack, "%d", bound.line);
|
||||||
|
obstack_1grow (&muscle_obstack, '.');
|
||||||
|
obstack_printf (&muscle_obstack, "%d", bound.column);
|
||||||
|
obstack_sgrow (&muscle_obstack, "]]");
|
||||||
|
obstack_1grow (&muscle_obstack, '\0');
|
||||||
|
extension = obstack_finish (&muscle_obstack);
|
||||||
muscle_grow (key, extension, "");
|
muscle_grow (key, extension, "");
|
||||||
obstack_free (&muscle_obstack, extension);
|
obstack_free (&muscle_obstack, extension);
|
||||||
}
|
}
|
||||||
@@ -305,10 +315,11 @@ muscle_location_grow (char const *key, location loc)
|
|||||||
static char *
|
static char *
|
||||||
string_decode (char const *key)
|
string_decode (char const *key)
|
||||||
{
|
{
|
||||||
char const *value = muscle_find_const (key);
|
char const *value;
|
||||||
char *value_decoded;
|
char *value_decoded;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
|
value = muscle_find_const (key);
|
||||||
if (!value)
|
if (!value)
|
||||||
return NULL;
|
return NULL;
|
||||||
do {
|
do {
|
||||||
@@ -347,7 +358,8 @@ location_decode (char const *key)
|
|||||||
{
|
{
|
||||||
char *boundary_str;
|
char *boundary_str;
|
||||||
aver (*++value == ']');
|
aver (*++value == ']');
|
||||||
boundary_str = obstack_finish0 (&muscle_obstack);
|
obstack_1grow (&muscle_obstack, '\0');
|
||||||
|
boundary_str = obstack_finish (&muscle_obstack);
|
||||||
switch (*++value)
|
switch (*++value)
|
||||||
{
|
{
|
||||||
case ',':
|
case ',':
|
||||||
@@ -384,45 +396,11 @@ muscle_user_name_list_grow (char const *key, char const *user_name,
|
|||||||
muscle_grow (key, "]]", "");
|
muscle_grow (key, "]]", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Return an allocated string that represents the %define directive
|
|
||||||
that performs the assignment.
|
|
||||||
|
|
||||||
@param assignment "VAR", or "VAR=VAL".
|
|
||||||
@param value default value if VAL \a assignment has no '='.
|
|
||||||
|
|
||||||
For instance:
|
|
||||||
"foo", NULL => "%define foo"
|
|
||||||
"foo", "baz" => "%define foo baz"
|
|
||||||
"foo=bar", NULL => "%define foo bar"
|
|
||||||
"foo=bar", "baz" => "%define foo bar"
|
|
||||||
"foo=", NULL => "%define foo"
|
|
||||||
"foo=", "baz" => "%define foo"
|
|
||||||
*/
|
|
||||||
|
|
||||||
static
|
|
||||||
char *
|
|
||||||
define_directive (char const *assignment, char const *value)
|
|
||||||
{
|
|
||||||
char *eq = strchr (assignment, '=');
|
|
||||||
char const *fmt = !eq && value && *value ? "%%define %s %s" : "%%define %s";
|
|
||||||
char *res = xmalloc (strlen (fmt) + strlen (assignment)
|
|
||||||
+ (value ? strlen (value) : 0));
|
|
||||||
sprintf (res, fmt, assignment, value);
|
|
||||||
eq = strchr (res, '=');
|
|
||||||
if (eq)
|
|
||||||
*eq = eq[1] ? ' ' : '\0';
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** If the \a variable name is obsolete, return the name to use,
|
/** If the \a variable name is obsolete, return the name to use,
|
||||||
* otherwise \a variable. If the \a value is obsolete, update it too.
|
* otherwise \a variable. */
|
||||||
*
|
|
||||||
* Allocates the returned value. */
|
|
||||||
static
|
static
|
||||||
char *
|
char const *
|
||||||
muscle_percent_variable_update (char const *variable, location variable_loc,
|
muscle_percent_variable_update (char const *variable)
|
||||||
char const **value)
|
|
||||||
{
|
{
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -432,46 +410,19 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
|
|||||||
const conversion_type conversion[] =
|
const conversion_type conversion[] =
|
||||||
{
|
{
|
||||||
{ "api.push_pull", "api.push-pull", },
|
{ "api.push_pull", "api.push-pull", },
|
||||||
{ "api.tokens.prefix", "api.token.prefix", },
|
|
||||||
{ "lex_symbol", "api.token.constructor", },
|
|
||||||
{ "location_type", "api.location.type", },
|
{ "location_type", "api.location.type", },
|
||||||
{ "lr.default-reductions", "lr.default-reduction", },
|
{ "lr.keep_unreachable_states", "lr.keep-unreachable-states", },
|
||||||
{ "lr.keep-unreachable-states", "lr.keep-unreachable-state", },
|
|
||||||
{ "lr.keep_unreachable_states", "lr.keep-unreachable-state", },
|
|
||||||
{ "namespace", "api.namespace", },
|
|
||||||
{ "stype", "api.value.type", },
|
|
||||||
{ "variant=", "api.value.type=variant", },
|
|
||||||
{ "variant=true", "api.value.type=variant", },
|
|
||||||
{ NULL, NULL, }
|
|
||||||
};
|
};
|
||||||
conversion_type const *c;
|
char const *res = variable;
|
||||||
for (c = conversion; c->obsolete; ++c)
|
int i;
|
||||||
|
for (i = 0; i < ARRAY_CARDINALITY (conversion); ++i)
|
||||||
|
if (STREQ (conversion[i].obsolete, variable))
|
||||||
{
|
{
|
||||||
char const *eq = strchr (c->obsolete, '=');
|
res = conversion[i].updated;
|
||||||
if (eq
|
break;
|
||||||
? (!strncmp (c->obsolete, variable, eq - c->obsolete)
|
|
||||||
&& STREQ (eq + 1, *value))
|
|
||||||
: STREQ (c->obsolete, variable))
|
|
||||||
{
|
|
||||||
char *old = define_directive (c->obsolete, *value);
|
|
||||||
char *upd = define_directive (c->updated, *value);
|
|
||||||
deprecated_directive (&variable_loc, old, upd);
|
|
||||||
free (old);
|
|
||||||
free (upd);
|
|
||||||
char *res = xstrdup (c->updated);
|
|
||||||
{
|
|
||||||
char *eq2 = strchr (res, '=');
|
|
||||||
if (eq2)
|
|
||||||
{
|
|
||||||
*eq2 = '\0';
|
|
||||||
*value = eq2 + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return xstrdup (variable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
muscle_percent_define_insert (char const *var, location variable_loc,
|
muscle_percent_define_insert (char const *var, location variable_loc,
|
||||||
@@ -479,7 +430,7 @@ muscle_percent_define_insert (char const *var, location variable_loc,
|
|||||||
muscle_percent_define_how how)
|
muscle_percent_define_how how)
|
||||||
{
|
{
|
||||||
/* Backward compatibility. */
|
/* Backward compatibility. */
|
||||||
char *variable = muscle_percent_variable_update (var, variable_loc, &value);
|
char const *variable = muscle_percent_variable_update (var);
|
||||||
char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
||||||
char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
|
char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
|
||||||
char const *syncline_name =
|
char const *syncline_name =
|
||||||
@@ -490,16 +441,16 @@ muscle_percent_define_insert (char const *var, location variable_loc,
|
|||||||
if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
|
if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
|
||||||
&& muscle_find_const (name))
|
&& muscle_find_const (name))
|
||||||
{
|
{
|
||||||
muscle_percent_define_how how_old = atoi (muscle_find_const (how_name));
|
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
muscle_percent_define_how how_old =
|
||||||
|
atoi (muscle_find_const (how_name));
|
||||||
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
||||||
goto end;
|
return;
|
||||||
complain_indent (&variable_loc, complaint, &i,
|
complain_at_indent (variable_loc, &i,
|
||||||
_("%%define variable %s redefined"),
|
_("%%define variable %s redefined"), quote (variable));
|
||||||
quote (variable));
|
|
||||||
i += SUB_INDENT;
|
i += SUB_INDENT;
|
||||||
location loc = muscle_percent_define_get_loc (variable);
|
complain_at_indent (muscle_percent_define_get_loc (variable), &i,
|
||||||
complain_indent (&loc, complaint, &i, _("previous definition"));
|
_("previous definition"));
|
||||||
}
|
}
|
||||||
|
|
||||||
MUSCLE_INSERT_STRING (name, value);
|
MUSCLE_INSERT_STRING (name, value);
|
||||||
@@ -510,53 +461,33 @@ muscle_percent_define_insert (char const *var, location variable_loc,
|
|||||||
muscle_user_name_list_grow ("percent_define_user_variables", variable,
|
muscle_user_name_list_grow ("percent_define_user_variables", variable,
|
||||||
variable_loc);
|
variable_loc);
|
||||||
MUSCLE_INSERT_INT (how_name, how);
|
MUSCLE_INSERT_INT (how_name, how);
|
||||||
end:
|
|
||||||
free (variable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is used for backward compatibility, e.g., "%define api.pure"
|
|
||||||
supersedes "%pure-parser". */
|
|
||||||
void
|
|
||||||
muscle_percent_define_ensure (char const *variable, location loc,
|
|
||||||
bool value)
|
|
||||||
{
|
|
||||||
char const *val = value ? "" : "false";
|
|
||||||
char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
|
||||||
|
|
||||||
/* %pure-parser is deprecated in favor of `%define api.pure', so use
|
|
||||||
`%define api.pure' in a backward-compatible manner here. First,
|
|
||||||
don't complain if %pure-parser is specified multiple times. */
|
|
||||||
if (!muscle_find_const (name))
|
|
||||||
muscle_percent_define_insert (variable, loc, val,
|
|
||||||
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
|
||||||
/* In all cases, use api.pure now so that the backend doesn't complain if
|
|
||||||
the skeleton ignores api.pure, but do warn now if there's a previous
|
|
||||||
conflicting definition from an actual %define. */
|
|
||||||
if (muscle_percent_define_flag_if (variable) != value)
|
|
||||||
muscle_percent_define_insert (variable, loc, val,
|
|
||||||
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
muscle_percent_define_get (char const *variable)
|
muscle_percent_define_get (char const *variable)
|
||||||
{
|
{
|
||||||
char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
char const *name;
|
||||||
char const *usage_name =
|
char const *usage_name;
|
||||||
UNIQSTR_CONCAT ("percent_define_bison_variables(", variable, ")");
|
char *value;
|
||||||
char *value = string_decode (name);
|
|
||||||
if (!value)
|
name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
||||||
value = xstrdup ("");
|
usage_name = UNIQSTR_CONCAT ("percent_define_bison_variables(",
|
||||||
|
variable, ")");
|
||||||
|
|
||||||
muscle_insert (usage_name, "");
|
muscle_insert (usage_name, "");
|
||||||
|
value = string_decode (name);
|
||||||
|
if (!value)
|
||||||
|
value = xstrdup ("");
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
location
|
location
|
||||||
muscle_percent_define_get_loc (char const *variable)
|
muscle_percent_define_get_loc (char const *variable)
|
||||||
{
|
{
|
||||||
char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
|
char const *loc_name;
|
||||||
|
loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
|
||||||
if (!muscle_find_const (loc_name))
|
if (!muscle_find_const (loc_name))
|
||||||
complain (NULL, 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 location_decode (loc_name);
|
return location_decode (loc_name);
|
||||||
}
|
}
|
||||||
@@ -564,11 +495,13 @@ muscle_percent_define_get_loc (char const *variable)
|
|||||||
char const *
|
char const *
|
||||||
muscle_percent_define_get_syncline (char const *variable)
|
muscle_percent_define_get_syncline (char const *variable)
|
||||||
{
|
{
|
||||||
char const *syncline_name =
|
char const *syncline_name;
|
||||||
|
char const *syncline;
|
||||||
|
syncline_name =
|
||||||
UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
|
UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
|
||||||
char const *syncline = muscle_find_const (syncline_name);
|
syncline = muscle_find_const (syncline_name);
|
||||||
if (!syncline)
|
if (!syncline)
|
||||||
complain (NULL, fatal, _("%s: undefined %%define variable %s"),
|
fatal(_("%s: undefined %%define variable %s"),
|
||||||
"muscle_percent_define_get_syncline", quote (variable));
|
"muscle_percent_define_get_syncline", quote (variable));
|
||||||
return syncline;
|
return syncline;
|
||||||
}
|
}
|
||||||
@@ -576,10 +509,15 @@ muscle_percent_define_get_syncline (char const *variable)
|
|||||||
bool
|
bool
|
||||||
muscle_percent_define_ifdef (char const *variable)
|
muscle_percent_define_ifdef (char const *variable)
|
||||||
{
|
{
|
||||||
char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
char const *name;
|
||||||
char const *usage_name =
|
char const *usage_name;
|
||||||
|
char const *value;
|
||||||
|
|
||||||
|
name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
||||||
|
usage_name =
|
||||||
UNIQSTR_CONCAT ("percent_define_bison_variables(", variable, ")");
|
UNIQSTR_CONCAT ("percent_define_bison_variables(", variable, ")");
|
||||||
char const *value = muscle_find_const (name);
|
|
||||||
|
value = muscle_find_const (name);
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
muscle_insert (usage_name, "");
|
muscle_insert (usage_name, "");
|
||||||
@@ -592,29 +530,30 @@ muscle_percent_define_ifdef (char const *variable)
|
|||||||
bool
|
bool
|
||||||
muscle_percent_define_flag_if (char const *variable)
|
muscle_percent_define_flag_if (char const *variable)
|
||||||
{
|
{
|
||||||
char const *invalid_boolean_name =
|
char const *invalid_boolean_name;
|
||||||
UNIQSTR_CONCAT ("percent_define_invalid_boolean(", variable, ")");
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
|
invalid_boolean_name =
|
||||||
|
UNIQSTR_CONCAT ("percent_define_invalid_boolean(", variable, ")");
|
||||||
|
|
||||||
if (muscle_percent_define_ifdef (variable))
|
if (muscle_percent_define_ifdef (variable))
|
||||||
{
|
{
|
||||||
char *value = muscle_percent_define_get (variable);
|
char *value = muscle_percent_define_get (variable);
|
||||||
if (value[0] == '\0' || STREQ (value, "true"))
|
if (value[0] == '\0' || 0 == strcmp (value, "true"))
|
||||||
result = true;
|
result = true;
|
||||||
else if (STREQ (value, "false"))
|
else if (0 == strcmp (value, "false"))
|
||||||
result = false;
|
result = false;
|
||||||
else if (!muscle_find_const (invalid_boolean_name))
|
else if (!muscle_find_const (invalid_boolean_name))
|
||||||
{
|
{
|
||||||
muscle_insert (invalid_boolean_name, "");
|
muscle_insert (invalid_boolean_name, "");
|
||||||
location loc = muscle_percent_define_get_loc (variable);
|
complain_at(muscle_percent_define_get_loc (variable),
|
||||||
complain (&loc, complaint,
|
|
||||||
_("invalid value for %%define Boolean variable %s"),
|
_("invalid value for %%define Boolean variable %s"),
|
||||||
quote (variable));
|
quote (variable));
|
||||||
}
|
}
|
||||||
free (value);
|
free (value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
complain (NULL, fatal, _("%s: undefined %%define variable %s"),
|
fatal(_("%s: undefined %%define variable %s"),
|
||||||
"muscle_percent_define_flag", quote (variable));
|
"muscle_percent_define_flag", quote (variable));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -623,9 +562,12 @@ muscle_percent_define_flag_if (char const *variable)
|
|||||||
void
|
void
|
||||||
muscle_percent_define_default (char const *variable, char const *value)
|
muscle_percent_define_default (char const *variable, char const *value)
|
||||||
{
|
{
|
||||||
char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
char const *name;
|
||||||
char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
|
char const *loc_name;
|
||||||
char const *syncline_name =
|
char const *syncline_name;
|
||||||
|
name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
|
||||||
|
loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
|
||||||
|
syncline_name =
|
||||||
UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
|
UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
|
||||||
if (!muscle_find_const (name))
|
if (!muscle_find_const (name))
|
||||||
{
|
{
|
||||||
@@ -646,26 +588,30 @@ muscle_percent_define_check_values (char const * const *values)
|
|||||||
for (; *values; ++values)
|
for (; *values; ++values)
|
||||||
{
|
{
|
||||||
char const * const *variablep = values;
|
char const * const *variablep = values;
|
||||||
char const *name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
|
char const *name;
|
||||||
char *value = string_decode (name);
|
char *value;
|
||||||
|
|
||||||
|
name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
|
||||||
|
|
||||||
|
value = string_decode (name);
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
for (++values; *values; ++values)
|
for (++values; *values; ++values)
|
||||||
{
|
{
|
||||||
if (STREQ (value, *values))
|
if (0 == strcmp (value, *values))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!*values)
|
if (!*values)
|
||||||
{
|
{
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
location loc = muscle_percent_define_get_loc (*variablep);
|
location loc = muscle_percent_define_get_loc (*variablep);
|
||||||
complain_indent (&loc, complaint, &i,
|
complain_at_indent (loc, &i,
|
||||||
_("invalid value for %%define variable %s: %s"),
|
_("invalid value for %%define variable %s: %s"),
|
||||||
quote (*variablep), quote_n (1, value));
|
quote (*variablep), quote_n (1, value));
|
||||||
i += SUB_INDENT;
|
i += SUB_INDENT;
|
||||||
for (values = variablep + 1; *values; ++values)
|
for (values = variablep + 1; *values; ++values)
|
||||||
complain_indent (&loc, complaint | no_caret, &i,
|
complain_at_indent (loc, &i, _("accepted value: %s"),
|
||||||
_("accepted value: %s"), quote (*values));
|
quote (*values));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -675,7 +621,7 @@ muscle_percent_define_check_values (char const * const *values)
|
|||||||
free (value);
|
free (value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
complain (NULL, fatal, _("%s: undefined %%define variable %s"),
|
fatal (_("%s: undefined %%define variable %s"),
|
||||||
"muscle_percent_define_check_values", quote (*variablep));
|
"muscle_percent_define_check_values", quote (*variablep));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -684,7 +630,8 @@ void
|
|||||||
muscle_percent_code_grow (char const *qualifier, location qualifier_loc,
|
muscle_percent_code_grow (char const *qualifier, location qualifier_loc,
|
||||||
char const *code, location code_loc)
|
char const *code, location code_loc)
|
||||||
{
|
{
|
||||||
char const *name = UNIQSTR_CONCAT ("percent_code(", qualifier, ")");
|
char const *name;
|
||||||
|
name = UNIQSTR_CONCAT ("percent_code(", qualifier, ")");
|
||||||
muscle_code_grow (name, code, code_loc);
|
muscle_code_grow (name, code, code_loc);
|
||||||
muscle_user_name_list_grow ("percent_code_user_qualifiers", qualifier,
|
muscle_user_name_list_grow ("percent_code_user_qualifiers", qualifier,
|
||||||
qualifier_loc);
|
qualifier_loc);
|
||||||
@@ -698,9 +645,8 @@ muscle_percent_code_grow (char const *qualifier, location qualifier_loc,
|
|||||||
static inline bool
|
static inline bool
|
||||||
muscle_m4_output (muscle_entry *entry, FILE *out)
|
muscle_m4_output (muscle_entry *entry, FILE *out)
|
||||||
{
|
{
|
||||||
fprintf (out,
|
fprintf (out, "m4_define([b4_%s],\n", entry->key);
|
||||||
"m4_define([b4_%s],\n"
|
fprintf (out, "[[%s]])\n\n\n", entry->value);
|
||||||
"[[%s]])\n\n\n", entry->key, entry->value);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-23
@@ -1,6 +1,7 @@
|
|||||||
/* Muscle table manager for Bison,
|
/* Muscle table manager for Bison,
|
||||||
|
|
||||||
Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc.
|
Copyright (C) 2001-2003, 2006-2007, 2009-2013 Free Software
|
||||||
|
Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -36,38 +37,44 @@ 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)
|
|
||||||
|
|
||||||
# define MUSCLE_INSERTF(Key, Format, Value) \
|
|
||||||
do { \
|
|
||||||
obstack_printf (&muscle_obstack, Format, Value); \
|
|
||||||
muscle_insert (Key, obstack_finish0 (&muscle_obstack)); \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_INT(Key, Value) \
|
#define MUSCLE_INSERT_INT(Key, Value) \
|
||||||
MUSCLE_INSERTF(Key, "%d", Value)
|
do { \
|
||||||
|
obstack_printf (&muscle_obstack, "%d", Value); \
|
||||||
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
||||||
MUSCLE_INSERTF(Key, "%ld", Value)
|
do { \
|
||||||
|
obstack_printf (&muscle_obstack, "%ld", Value); \
|
||||||
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* Key -> Value, but don't apply escaping to Value. */
|
|
||||||
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
||||||
MUSCLE_INSERTF(Key, "%s", Value)
|
do { \
|
||||||
|
obstack_sgrow (&muscle_obstack, Value); \
|
||||||
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* Key -> Value, applying M4 escaping to Value. */
|
|
||||||
#define MUSCLE_INSERT_STRING(Key, Value) \
|
#define MUSCLE_INSERT_STRING(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
obstack_escape (&muscle_obstack, Value); \
|
obstack_escape (&muscle_obstack, Value); \
|
||||||
muscle_insert (Key, obstack_finish0 (&muscle_obstack)); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
obstack_escape (&muscle_obstack, \
|
obstack_escape (&muscle_obstack, \
|
||||||
quotearg_style (c_quoting_style, Value)); \
|
quotearg_style (c_quoting_style, Value)); \
|
||||||
muscle_insert (Key, obstack_finish0 (&muscle_obstack)); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while (0)
|
} 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
|
||||||
@@ -116,13 +123,6 @@ void muscle_percent_define_insert (char const *variable, location variable_loc,
|
|||||||
char const *value,
|
char const *value,
|
||||||
muscle_percent_define_how how);
|
muscle_percent_define_how how);
|
||||||
|
|
||||||
/* Make sure that VARIABLE is set to the boolean VALUE. Warn on mismatches
|
|
||||||
only, but accept repeated declaration. Used for backward compatibility
|
|
||||||
between old directives such as %pure-parser, and the recommended use of
|
|
||||||
variables (%define api.pure). */
|
|
||||||
void muscle_percent_define_ensure (char const *variable, location variable_loc,
|
|
||||||
bool value);
|
|
||||||
|
|
||||||
/* Mimic b4_percent_define_get in ../data/bison.m4 exactly. That is, if the
|
/* Mimic b4_percent_define_get in ../data/bison.m4 exactly. That is, if the
|
||||||
%define variable VARIABLE is defined, return its value. Otherwise, return
|
%define variable VARIABLE is defined, return its value. Otherwise, return
|
||||||
the empty string. Also, record Bison's usage of VARIABLE by defining
|
the empty string. Also, record Bison's usage of VARIABLE by defining
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ nullable_print (FILE *out)
|
|||||||
int i;
|
int i;
|
||||||
fputs ("NULLABLE\n", out);
|
fputs ("NULLABLE\n", out);
|
||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
fprintf (out, " %s: %s\n", symbols[i]->tag,
|
fprintf (out, "\t%s: %s\n", symbols[i]->tag,
|
||||||
nullable[i - ntokens] ? "yes" : "no");
|
nullable[i - ntokens] ? "yes" : "no");
|
||||||
fputs ("\n\n", out);
|
fputs ("\n\n", out);
|
||||||
}
|
}
|
||||||
|
|||||||
+181
-196
@@ -21,9 +21,8 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include <concat-filename.h>
|
|
||||||
#include <configmake.h>
|
#include <configmake.h>
|
||||||
#include <filename.h>
|
#include <error.h>
|
||||||
#include <get-errno.h>
|
#include <get-errno.h>
|
||||||
#include <quotearg.h>
|
#include <quotearg.h>
|
||||||
#include <spawn-pipe.h>
|
#include <spawn-pipe.h>
|
||||||
@@ -86,15 +85,18 @@ Name (char const *name, \
|
|||||||
if (max < table_data[i]) \
|
if (max < table_data[i]) \
|
||||||
max = table_data[i]; \
|
max = table_data[i]; \
|
||||||
} \
|
} \
|
||||||
muscle_insert (name, obstack_finish0 (&format_obstack)); \
|
obstack_1grow (&format_obstack, 0); \
|
||||||
|
muscle_insert (name, obstack_finish (&format_obstack)); \
|
||||||
\
|
\
|
||||||
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_printf (&format_obstack, "%s_min", name); \
|
obstack_printf (&format_obstack, "%s_min", name); \
|
||||||
MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmin); \
|
obstack_1grow (&format_obstack, 0); \
|
||||||
|
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
|
||||||
obstack_printf (&format_obstack, "%s_max", name); \
|
obstack_printf (&format_obstack, "%s_max", name); \
|
||||||
MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmax); \
|
obstack_1grow (&format_obstack, 0); \
|
||||||
|
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
|
||||||
}
|
}
|
||||||
|
|
||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int)
|
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int)
|
||||||
@@ -102,6 +104,7 @@ GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_int_table, int)
|
|||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_base_table, base_number)
|
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_base_table, base_number)
|
||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_rule_number_table, rule_number)
|
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_rule_number_table, rule_number)
|
||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_symbol_number_table, symbol_number)
|
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_symbol_number_table, symbol_number)
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
@@ -149,7 +152,6 @@ prepare_symbols (void)
|
|||||||
{
|
{
|
||||||
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 ("symbols_number", nsyms);
|
|
||||||
MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
|
MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
|
||||||
MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);
|
MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);
|
||||||
|
|
||||||
@@ -190,7 +192,8 @@ prepare_symbols (void)
|
|||||||
obstack_sgrow (&format_obstack, " ]b4_null[");
|
obstack_sgrow (&format_obstack, " ]b4_null[");
|
||||||
|
|
||||||
/* Finish table and store. */
|
/* Finish table and store. */
|
||||||
muscle_insert ("tname", obstack_finish0 (&format_obstack));
|
obstack_1grow (&format_obstack, 0);
|
||||||
|
muscle_insert ("tname", obstack_finish (&format_obstack));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output YYTOKNUM. */
|
/* Output YYTOKNUM. */
|
||||||
@@ -206,54 +209,65 @@ prepare_symbols (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------.
|
/*-------------------------------------------------------------.
|
||||||
| Prepare the muscles related to the rules: r1, r2, rline, dprec, |
|
| Prepare the muscles related to the rules: rhs, prhs, r1, r2, |
|
||||||
| merger, immediate. |
|
| rline, dprec, merger. |
|
||||||
`----------------------------------------------------------------*/
|
`-------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
prepare_rules (void)
|
prepare_rules (void)
|
||||||
{
|
{
|
||||||
|
rule_number r;
|
||||||
|
unsigned int i = 0;
|
||||||
|
item_number *rhs = xnmalloc (nritems, sizeof *rhs);
|
||||||
|
unsigned int *prhs = xnmalloc (nrules, sizeof *prhs);
|
||||||
unsigned int *rline = xnmalloc (nrules, sizeof *rline);
|
unsigned int *rline = xnmalloc (nrules, sizeof *rline);
|
||||||
symbol_number *r1 = xnmalloc (nrules, sizeof *r1);
|
symbol_number *r1 = xnmalloc (nrules, sizeof *r1);
|
||||||
unsigned int *r2 = xnmalloc (nrules, sizeof *r2);
|
unsigned int *r2 = xnmalloc (nrules, sizeof *r2);
|
||||||
int *dprec = xnmalloc (nrules, sizeof *dprec);
|
int *dprec = xnmalloc (nrules, sizeof *dprec);
|
||||||
int *merger = xnmalloc (nrules, sizeof *merger);
|
int *merger = xnmalloc (nrules, sizeof *merger);
|
||||||
int *immediate = xnmalloc (nrules, sizeof *immediate);
|
|
||||||
|
|
||||||
rule_number r;
|
|
||||||
for (r = 0; r < nrules; ++r)
|
for (r = 0; r < nrules; ++r)
|
||||||
{
|
{
|
||||||
|
item_number *rhsp = NULL;
|
||||||
|
/* Index of rule R in RHS. */
|
||||||
|
prhs[r] = i;
|
||||||
|
/* RHS of the rule R. */
|
||||||
|
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||||
|
rhs[i++] = *rhsp;
|
||||||
/* LHS of the rule R. */
|
/* LHS of the rule R. */
|
||||||
r1[r] = rules[r].lhs->number;
|
r1[r] = rules[r].lhs->number;
|
||||||
/* Length of rule R's RHS. */
|
/* Length of rule R's RHS. */
|
||||||
r2[r] = rule_rhs_length(&rules[r]);
|
r2[r] = i - prhs[r];
|
||||||
|
/* Separator in RHS. */
|
||||||
|
rhs[i++] = -1;
|
||||||
/* Line where rule was defined. */
|
/* Line where rule was defined. */
|
||||||
rline[r] = rules[r].location.start.line;
|
rline[r] = rules[r].location.start.line;
|
||||||
/* Dynamic precedence (GLR). */
|
/* Dynamic precedence (GLR). */
|
||||||
dprec[r] = rules[r].dprec;
|
dprec[r] = rules[r].dprec;
|
||||||
/* Merger-function index (GLR). */
|
/* Merger-function index (GLR). */
|
||||||
merger[r] = rules[r].merger;
|
merger[r] = rules[r].merger;
|
||||||
/* Immediate reduction flags (GLR). */
|
|
||||||
immediate[r] = rules[r].is_predicate;
|
|
||||||
}
|
}
|
||||||
|
aver (i == nritems);
|
||||||
|
|
||||||
|
muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);
|
||||||
|
muscle_insert_unsigned_int_table ("prhs", prhs, 0, 0, nrules);
|
||||||
muscle_insert_unsigned_int_table ("rline", rline, 0, 0, nrules);
|
muscle_insert_unsigned_int_table ("rline", rline, 0, 0, nrules);
|
||||||
muscle_insert_symbol_number_table ("r1", r1, 0, 0, nrules);
|
muscle_insert_symbol_number_table ("r1", r1, 0, 0, nrules);
|
||||||
muscle_insert_unsigned_int_table ("r2", r2, 0, 0, nrules);
|
muscle_insert_unsigned_int_table ("r2", r2, 0, 0, nrules);
|
||||||
muscle_insert_int_table ("dprec", dprec, 0, 0, nrules);
|
muscle_insert_int_table ("dprec", dprec, 0, 0, nrules);
|
||||||
muscle_insert_int_table ("merger", merger, 0, 0, nrules);
|
muscle_insert_int_table ("merger", merger, 0, 0, nrules);
|
||||||
muscle_insert_int_table ("immediate", immediate, 0, 0, nrules);
|
|
||||||
|
|
||||||
MUSCLE_INSERT_INT ("rules_number", nrules);
|
MUSCLE_INSERT_INT ("rules_number", nrules);
|
||||||
MUSCLE_INSERT_INT ("max_left_semantic_context", max_left_semantic_context);
|
MUSCLE_INSERT_INT ("max_left_semantic_context", max_left_semantic_context);
|
||||||
|
|
||||||
|
free (rhs);
|
||||||
|
free (prhs);
|
||||||
free (rline);
|
free (rline);
|
||||||
free (r1);
|
free (r1);
|
||||||
free (r2);
|
free (r2);
|
||||||
free (dprec);
|
free (dprec);
|
||||||
free (merger);
|
free (merger);
|
||||||
free (immediate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------.
|
/*--------------------------------------------.
|
||||||
@@ -277,73 +291,6 @@ prepare_states (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------.
|
|
||||||
| Compare two symbols by type-name, and then by number. |
|
|
||||||
`-------------------------------------------------------*/
|
|
||||||
|
|
||||||
static int
|
|
||||||
symbol_type_name_cmp (const symbol **lhs, const symbol **rhs)
|
|
||||||
{
|
|
||||||
int res = uniqstr_cmp ((*lhs)->type_name, (*rhs)->type_name);
|
|
||||||
if (!res)
|
|
||||||
res = (*lhs)->number - (*rhs)->number;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------.
|
|
||||||
| Return a (malloc'ed) table of the symbols sorted by type-name. |
|
|
||||||
`----------------------------------------------------------------*/
|
|
||||||
|
|
||||||
static symbol **
|
|
||||||
symbols_by_type_name (void)
|
|
||||||
{
|
|
||||||
typedef int (*qcmp_type) (const void *, const void *);
|
|
||||||
symbol **res = xmemdup (symbols, nsyms * sizeof *res);
|
|
||||||
qsort (res, nsyms, sizeof *res, (qcmp_type) &symbol_type_name_cmp);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------.
|
|
||||||
| Define b4_type_names, which is a list of (lists of the numbers of |
|
|
||||||
| symbols with same type-name). |
|
|
||||||
`------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
type_names_output (FILE *out)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
symbol **syms = symbols_by_type_name ();
|
|
||||||
fputs ("m4_define([b4_type_names],\n[", out);
|
|
||||||
for (i = 0; i < nsyms; /* nothing */)
|
|
||||||
{
|
|
||||||
/* The index of the first symbol of the current type-name. */
|
|
||||||
int i0 = i;
|
|
||||||
fputs (i ? ",\n[" : "[", out);
|
|
||||||
for (; i < nsyms && syms[i]->type_name == syms[i0]->type_name; ++i)
|
|
||||||
fprintf (out, "%s%d", i != i0 ? ", " : "", syms[i]->number);
|
|
||||||
fputs ("]", out);
|
|
||||||
}
|
|
||||||
fputs ("])\n\n", out);
|
|
||||||
free (syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------.
|
|
||||||
| The list of all the symbol numbers. |
|
|
||||||
`-------------------------------------*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
symbol_numbers_output (FILE *out)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
fputs ("m4_define([b4_symbol_numbers],\n[", out);
|
|
||||||
for (i = 0; i < nsyms; ++i)
|
|
||||||
fprintf (out, "%s[%d]", i ? ", " : "", i);
|
|
||||||
fputs ("])\n\n", out);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------.
|
/*---------------------------------.
|
||||||
| Output the user actions to OUT. |
|
| Output the user actions to OUT. |
|
||||||
@@ -358,18 +305,17 @@ user_actions_output (FILE *out)
|
|||||||
for (r = 0; r < nrules; ++r)
|
for (r = 0; r < nrules; ++r)
|
||||||
if (rules[r].action)
|
if (rules[r].action)
|
||||||
{
|
{
|
||||||
fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
|
fprintf (out, "b4_case(%d, [b4_syncline(%d, ", r + 1,
|
||||||
rules[r].is_predicate ? "predicate_" : "",
|
rules[r].action_location.start.line);
|
||||||
r + 1, rules[r].action_location.start.line);
|
|
||||||
string_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------.
|
/*--------------------------------------.
|
||||||
| Output the merge functions to OUT. |
|
| Output the merge functions to OUT. |
|
||||||
`------------------------------------*/
|
`--------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
merger_output (FILE *out)
|
merger_output (FILE *out)
|
||||||
@@ -390,86 +336,96 @@ merger_output (FILE *out)
|
|||||||
fputs ("]])\n\n", out);
|
fputs ("]])\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------.
|
||||||
/*---------------------------------------------.
|
| Output the tokens definition to OUT. |
|
||||||
| Prepare the muscles for symbol definitions. |
|
`--------------------------------------*/
|
||||||
`---------------------------------------------*/
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
prepare_symbol_definitions (void)
|
token_definitions_output (FILE *out)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
char const *sep = "";
|
||||||
|
|
||||||
|
fputs ("m4_define([b4_tokens], \n[", out);
|
||||||
|
for (i = 0; i < ntokens; ++i)
|
||||||
|
{
|
||||||
|
symbol *sym = symbols[i];
|
||||||
|
int number = sym->user_token_number;
|
||||||
|
|
||||||
|
/* At this stage, if there are literal string aliases, they are
|
||||||
|
part of SYMBOLS, so we should not find their aliased symbols
|
||||||
|
here. */
|
||||||
|
aver (number != USER_NUMBER_HAS_STRING_ALIAS);
|
||||||
|
|
||||||
|
/* Skip error token. */
|
||||||
|
if (sym == errtoken)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* If this string has an alias, then it is necessarily the alias
|
||||||
|
which is to be output. */
|
||||||
|
if (sym->alias)
|
||||||
|
sym = sym->alias;
|
||||||
|
|
||||||
|
/* Don't output literal chars or strings (when defined only as a
|
||||||
|
string). Note that must be done after the alias resolution:
|
||||||
|
think about `%token 'f' "f"'. */
|
||||||
|
if (sym->tag[0] == '\'' || sym->tag[0] == '\"')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Don't #define nonliteral tokens whose names contain periods,
|
||||||
|
dashes or '$' (as does the default value of the EOF token). */
|
||||||
|
if (mbschr (sym->tag, '.')
|
||||||
|
|| mbschr (sym->tag, '-')
|
||||||
|
|| mbschr (sym->tag, '$'))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fprintf (out, "%s[[[%s]], %d]",
|
||||||
|
sep, sym->tag, number);
|
||||||
|
sep = ",\n";
|
||||||
|
}
|
||||||
|
fputs ("])\n\n", out);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------.
|
||||||
|
| Output the symbol destructors or printers to OUT. |
|
||||||
|
`---------------------------------------------------*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
symbol_code_props_output (FILE *out, char const *what,
|
||||||
|
code_props const *(*get)(symbol const *))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char const *sep = "";
|
||||||
|
|
||||||
|
fputs ("m4_define([b4_symbol_", out);
|
||||||
|
fputs (what, out);
|
||||||
|
fputs ("], \n[", out);
|
||||||
for (i = 0; i < nsyms; ++i)
|
for (i = 0; i < nsyms; ++i)
|
||||||
{
|
{
|
||||||
symbol *sym = symbols[i];
|
symbol *sym = symbols[i];
|
||||||
const char *key;
|
char const *code = (*get) (sym)->code;
|
||||||
const char *value;
|
if (code)
|
||||||
|
|
||||||
#define SET_KEY(Entry) \
|
|
||||||
obstack_printf (&format_obstack, "symbol(%d, %s)", \
|
|
||||||
i, Entry); \
|
|
||||||
key = obstack_finish0 (&format_obstack);
|
|
||||||
|
|
||||||
#define SET_KEY2(Entry, Suffix) \
|
|
||||||
obstack_printf (&format_obstack, "symbol(%d, %s_%s)", \
|
|
||||||
i, Entry, Suffix); \
|
|
||||||
key = obstack_finish0 (&format_obstack);
|
|
||||||
|
|
||||||
/* Whether the symbol has an identifier. */
|
|
||||||
value = symbol_id_get (sym);
|
|
||||||
SET_KEY("has_id");
|
|
||||||
MUSCLE_INSERT_INT (key, !!value);
|
|
||||||
|
|
||||||
/* Its identifier. */
|
|
||||||
SET_KEY("id");
|
|
||||||
MUSCLE_INSERT_STRING (key, value ? value : "");
|
|
||||||
|
|
||||||
/* Its tag. Typically for documentation purpose. */
|
|
||||||
SET_KEY("tag");
|
|
||||||
MUSCLE_INSERT_STRING (key, sym->tag);
|
|
||||||
|
|
||||||
SET_KEY("user_number");
|
|
||||||
MUSCLE_INSERT_INT (key, sym->user_token_number);
|
|
||||||
|
|
||||||
SET_KEY("is_token");
|
|
||||||
MUSCLE_INSERT_INT (key,
|
|
||||||
i < ntokens && sym != errtoken && sym != undeftoken);
|
|
||||||
|
|
||||||
SET_KEY("number");
|
|
||||||
MUSCLE_INSERT_INT (key, sym->number);
|
|
||||||
|
|
||||||
SET_KEY("has_type");
|
|
||||||
MUSCLE_INSERT_INT (key, !!sym->type_name);
|
|
||||||
|
|
||||||
SET_KEY("type");
|
|
||||||
MUSCLE_INSERT_STRING (key, sym->type_name ? sym->type_name : "");
|
|
||||||
|
|
||||||
{
|
{
|
||||||
int j;
|
location loc = (*get) (sym)->location;
|
||||||
for (j = 0; j < CODE_PROPS_SIZE; ++j)
|
/* Filename, lineno,
|
||||||
|
Symbol-name, Symbol-number,
|
||||||
|
code, optional typename. */
|
||||||
|
fprintf (out, "%s[", sep);
|
||||||
|
sep = ",\n";
|
||||||
|
string_output (out, loc.start.file);
|
||||||
|
fprintf (out, ", %d, ", loc.start.line);
|
||||||
|
quoted_output (out, sym->tag);
|
||||||
|
fprintf (out, ", %d, [[%s]]", sym->number, code);
|
||||||
|
if (sym->type_name)
|
||||||
{
|
{
|
||||||
/* "printer", not "%printer". */
|
fputs (", ", out);
|
||||||
char const *pname = code_props_type_string (j) + 1;
|
quoted_output (out, sym->type_name);
|
||||||
code_props const *p = symbol_code_props_get (sym, j);
|
}
|
||||||
SET_KEY2("has", pname);
|
fputc (']', out);
|
||||||
MUSCLE_INSERT_INT (key, !!p->code);
|
|
||||||
|
|
||||||
if (p->code)
|
|
||||||
{
|
|
||||||
SET_KEY2(pname, "file");
|
|
||||||
MUSCLE_INSERT_STRING (key, p->location.start.file);
|
|
||||||
|
|
||||||
SET_KEY2(pname, "line");
|
|
||||||
MUSCLE_INSERT_INT (key, p->location.start.line);
|
|
||||||
|
|
||||||
SET_KEY(pname);
|
|
||||||
MUSCLE_INSERT_STRING_RAW (key, p->code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
fputs ("])\n\n", out);
|
||||||
#undef SET_KEY2
|
|
||||||
#undef SET_KEY
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -520,7 +476,6 @@ prepare_actions (void)
|
|||||||
0, 1, conflict_list_cnt);
|
0, 1, conflict_list_cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------.
|
/*--------------------------------------------.
|
||||||
| Output the definitions of all the muscles. |
|
| Output the definitions of all the muscles. |
|
||||||
`--------------------------------------------*/
|
`--------------------------------------------*/
|
||||||
@@ -529,11 +484,13 @@ static void
|
|||||||
muscles_output (FILE *out)
|
muscles_output (FILE *out)
|
||||||
{
|
{
|
||||||
fputs ("m4_init()\n", out);
|
fputs ("m4_init()\n", out);
|
||||||
merger_output (out);
|
|
||||||
symbol_numbers_output (out);
|
|
||||||
type_names_output (out);
|
|
||||||
user_actions_output (out);
|
user_actions_output (out);
|
||||||
/* Must be last. */
|
merger_output (out);
|
||||||
|
token_definitions_output (out);
|
||||||
|
symbol_code_props_output (out, "destructors", &symbol_destructor_get);
|
||||||
|
symbol_code_props_output (out, "printers", &symbol_printer_get);
|
||||||
|
|
||||||
muscles_m4_output (out);
|
muscles_m4_output (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,28 +501,48 @@ muscles_output (FILE *out)
|
|||||||
static void
|
static void
|
||||||
output_skeleton (void)
|
output_skeleton (void)
|
||||||
{
|
{
|
||||||
|
FILE *in;
|
||||||
int filter_fd[2];
|
int filter_fd[2];
|
||||||
|
char const *argv[10];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
/* Compute the names of the package data dir and skeleton files. */
|
/* Compute the names of the package data dir and skeleton files. */
|
||||||
char const *m4 = (m4 = getenv ("M4")) ? m4 : M4;
|
char const m4sugar[] = "m4sugar/m4sugar.m4";
|
||||||
char const *datadir = pkgdatadir ();
|
char const m4bison[] = "bison.m4";
|
||||||
char *m4sugar = xconcatenated_filename (datadir, "m4sugar/m4sugar.m4", NULL);
|
char *full_m4sugar;
|
||||||
char *m4bison = xconcatenated_filename (datadir, "bison.m4", NULL);
|
char *full_m4bison;
|
||||||
char *skel = (IS_PATH_WITH_DIR (skeleton)
|
char *full_skeleton;
|
||||||
? xstrdup (skeleton)
|
char const *p;
|
||||||
: xconcatenated_filename (datadir, skeleton, NULL));
|
char const *m4 = (p = getenv ("M4")) ? p : M4;
|
||||||
|
char const *pkgdatadir = compute_pkgdatadir ();
|
||||||
|
size_t skeleton_size = strlen (skeleton) + 1;
|
||||||
|
size_t pkgdatadirlen = strlen (pkgdatadir);
|
||||||
|
while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/')
|
||||||
|
pkgdatadirlen--;
|
||||||
|
full_skeleton = xmalloc (pkgdatadirlen + 1
|
||||||
|
+ (skeleton_size < sizeof m4sugar
|
||||||
|
? sizeof m4sugar : skeleton_size));
|
||||||
|
memcpy (full_skeleton, pkgdatadir, pkgdatadirlen);
|
||||||
|
full_skeleton[pkgdatadirlen] = '/';
|
||||||
|
strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
|
||||||
|
full_m4sugar = xstrdup (full_skeleton);
|
||||||
|
strcpy (full_skeleton + pkgdatadirlen + 1, m4bison);
|
||||||
|
full_m4bison = xstrdup (full_skeleton);
|
||||||
|
if (mbschr (skeleton, '/'))
|
||||||
|
strcpy (full_skeleton, skeleton);
|
||||||
|
else
|
||||||
|
strcpy (full_skeleton + pkgdatadirlen + 1, skeleton);
|
||||||
|
|
||||||
/* Test whether m4sugar.m4 is readable, to check for proper
|
/* Test whether m4sugar.m4 is readable, to check for proper
|
||||||
installation. A faulty installation can cause deadlock, so a
|
installation. A faulty installation can cause deadlock, so a
|
||||||
cheap sanity check is worthwhile. */
|
cheap sanity check is worthwhile. */
|
||||||
xfclose (xfopen (m4sugar, "r"));
|
xfclose (xfopen (full_m4sugar, "r"));
|
||||||
|
|
||||||
/* Create an m4 subprocess connected to us via two pipes. */
|
/* Create an m4 subprocess connected to us via two pipes. */
|
||||||
|
|
||||||
if (trace_flag & trace_tools)
|
if (trace_flag & trace_tools)
|
||||||
fprintf (stderr, "running: %s %s - %s %s\n",
|
fprintf (stderr, "running: %s %s - %s %s\n",
|
||||||
m4, m4sugar, m4bison, skel);
|
m4, full_m4sugar, full_m4bison, full_skeleton);
|
||||||
|
|
||||||
/* Some future version of GNU M4 (most likely 1.6) may treat the -dV in a
|
/* Some future version of GNU M4 (most likely 1.6) may treat the -dV in a
|
||||||
position-dependent manner. Keep it as the first argument so that all
|
position-dependent manner. Keep it as the first argument so that all
|
||||||
@@ -575,7 +552,6 @@ output_skeleton (void)
|
|||||||
<http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
|
<http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
|
||||||
for details. */
|
for details. */
|
||||||
{
|
{
|
||||||
char const *argv[10];
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
argv[i++] = m4;
|
argv[i++] = m4;
|
||||||
|
|
||||||
@@ -592,44 +568,47 @@ output_skeleton (void)
|
|||||||
argv[i++] = M4_GNU_OPTION;
|
argv[i++] = M4_GNU_OPTION;
|
||||||
|
|
||||||
argv[i++] = "-I";
|
argv[i++] = "-I";
|
||||||
argv[i++] = datadir;
|
argv[i++] = pkgdatadir;
|
||||||
if (trace_flag & trace_m4)
|
if (trace_flag & trace_m4)
|
||||||
argv[i++] = "-dV";
|
argv[i++] = "-dV";
|
||||||
argv[i++] = m4sugar;
|
argv[i++] = full_m4sugar;
|
||||||
argv[i++] = "-";
|
argv[i++] = "-";
|
||||||
argv[i++] = m4bison;
|
argv[i++] = full_m4bison;
|
||||||
argv[i++] = skel;
|
argv[i++] = full_skeleton;
|
||||||
argv[i++] = NULL;
|
argv[i++] = NULL;
|
||||||
aver (i <= ARRAY_CARDINALITY (argv));
|
aver (i <= ARRAY_CARDINALITY (argv));
|
||||||
|
}
|
||||||
|
|
||||||
/* The ugly cast is because gnulib gets the const-ness wrong. */
|
/* The ugly cast is because gnulib gets the const-ness wrong. */
|
||||||
pid = create_pipe_bidi ("m4", m4, (char **)(void*)argv, false, true,
|
pid = create_pipe_bidi ("m4", m4, (char **)(void*)argv, false, true,
|
||||||
true, filter_fd);
|
true, filter_fd);
|
||||||
}
|
free (full_m4sugar);
|
||||||
|
free (full_m4bison);
|
||||||
free (m4sugar);
|
free (full_skeleton);
|
||||||
free (m4bison);
|
|
||||||
free (skel);
|
|
||||||
|
|
||||||
if (trace_flag & trace_muscles)
|
if (trace_flag & trace_muscles)
|
||||||
muscles_output (stderr);
|
muscles_output (stderr);
|
||||||
{
|
{
|
||||||
FILE *out = xfdopen (filter_fd[1], "w");
|
FILE *out = fdopen (filter_fd[1], "w");
|
||||||
|
if (! out)
|
||||||
|
error (EXIT_FAILURE, get_errno (),
|
||||||
|
"fdopen");
|
||||||
muscles_output (out);
|
muscles_output (out);
|
||||||
xfclose (out);
|
xfclose (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read and process m4's output. */
|
/* Read and process m4's output. */
|
||||||
timevar_push (TV_M4);
|
timevar_push (TV_M4);
|
||||||
{
|
in = fdopen (filter_fd[0], "r");
|
||||||
FILE *in = xfdopen (filter_fd[0], "r");
|
if (! in)
|
||||||
|
error (EXIT_FAILURE, get_errno (),
|
||||||
|
"fdopen");
|
||||||
scan_skel (in);
|
scan_skel (in);
|
||||||
/* scan_skel should have read all of M4's output. Otherwise, when we
|
/* scan_skel should have read all of M4's output. Otherwise, when we
|
||||||
close the pipe, we risk letting M4 report a broken-pipe to the
|
close the pipe, we risk letting M4 report a broken-pipe to the
|
||||||
Bison user. */
|
Bison user. */
|
||||||
aver (feof (in));
|
aver (feof (in));
|
||||||
xfclose (in);
|
xfclose (in);
|
||||||
}
|
|
||||||
wait_subprocess (pid, "m4", false, false, true, true, NULL);
|
wait_subprocess (pid, "m4", false, false, true, true, NULL);
|
||||||
timevar_pop (TV_M4);
|
timevar_pop (TV_M4);
|
||||||
}
|
}
|
||||||
@@ -637,14 +616,21 @@ output_skeleton (void)
|
|||||||
static void
|
static void
|
||||||
prepare (void)
|
prepare (void)
|
||||||
{
|
{
|
||||||
/* BISON_USE_PUSH_FOR_PULL is for the test suite and should not be
|
/* BISON_USE_PUSH_FOR_PULL is for the test suite and should not be documented
|
||||||
documented for the user. */
|
for the user. */
|
||||||
char const *cp = getenv ("BISON_USE_PUSH_FOR_PULL");
|
char const *use_push_for_pull_env = getenv ("BISON_USE_PUSH_FOR_PULL");
|
||||||
bool use_push_for_pull_flag = cp && *cp && strtol (cp, 0, 10);
|
bool use_push_for_pull_flag = false;
|
||||||
|
if (use_push_for_pull_env != NULL
|
||||||
|
&& use_push_for_pull_env[0] != '\0'
|
||||||
|
&& 0 != strcmp (use_push_for_pull_env, "0"))
|
||||||
|
use_push_for_pull_flag = true;
|
||||||
|
|
||||||
/* Flags. */
|
/* Flags. */
|
||||||
|
MUSCLE_INSERT_BOOL ("debug_flag", debug);
|
||||||
MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
|
MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
|
||||||
|
MUSCLE_INSERT_BOOL ("error_verbose_flag", error_verbose);
|
||||||
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
|
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
|
||||||
|
MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
|
||||||
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);
|
||||||
@@ -680,7 +666,7 @@ prepare (void)
|
|||||||
/* b4_pkgdatadir is used inside m4_include in the skeletons, so digraphs
|
/* b4_pkgdatadir is used inside m4_include in the skeletons, so digraphs
|
||||||
would never be expanded. Hopefully no one has M4-special characters in
|
would never be expanded. Hopefully no one has M4-special characters in
|
||||||
his Bison installation path. */
|
his Bison installation path. */
|
||||||
MUSCLE_INSERT_STRING_RAW ("pkgdatadir", pkgdatadir ());
|
MUSCLE_INSERT_STRING_RAW ("pkgdatadir", compute_pkgdatadir ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -698,7 +684,6 @@ output (void)
|
|||||||
prepare_rules ();
|
prepare_rules ();
|
||||||
prepare_states ();
|
prepare_states ();
|
||||||
prepare_actions ();
|
prepare_actions ();
|
||||||
prepare_symbol_definitions ();
|
|
||||||
|
|
||||||
prepare ();
|
prepare ();
|
||||||
|
|
||||||
@@ -709,8 +694,8 @@ output (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char const *
|
char const *
|
||||||
pkgdatadir (void)
|
compute_pkgdatadir (void)
|
||||||
{
|
{
|
||||||
char const *cp = getenv ("BISON_PKGDATADIR");
|
char const *pkgdatadir = getenv ("BISON_PKGDATADIR");
|
||||||
return cp ? cp : PKGDATADIR;
|
return pkgdatadir ? pkgdatadir : PKGDATADIR;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
/* Output the parsing tables and the parser code to FTABLE. */
|
/* Output the parsing tables and the parser code to FTABLE. */
|
||||||
void output (void);
|
void output (void);
|
||||||
|
char const *compute_pkgdatadir (void);
|
||||||
/* Where our data files are installed. */
|
|
||||||
char const *pkgdatadir (void);
|
|
||||||
|
|
||||||
#endif /* !OUTPUT_H_ */
|
#endif /* !OUTPUT_H_ */
|
||||||
|
|||||||
+1175
-979
File diff suppressed because it is too large
Load Diff
+116
-122
@@ -1,4 +1,4 @@
|
|||||||
/* A Bison parser, made by GNU Bison 2.7.1021-bb417-dirty. */
|
/* A Bison parser, made by GNU Bison 2.7.12-4996. */
|
||||||
|
|
||||||
/* Bison interface for Yacc-like parsers in C
|
/* Bison interface for Yacc-like parsers in C
|
||||||
|
|
||||||
@@ -30,9 +30,9 @@
|
|||||||
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 YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED
|
#ifndef YY_GRAM__SRC_PARSE_GRAM_H_INCLUDED
|
||||||
# define YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED
|
# define YY_GRAM__SRC_PARSE_GRAM_H_INCLUDED
|
||||||
/* Debug traces. */
|
/* Enabling traces. */
|
||||||
#ifndef GRAM_DEBUG
|
#ifndef GRAM_DEBUG
|
||||||
# if defined YYDEBUG
|
# if defined YYDEBUG
|
||||||
# if YYDEBUG
|
# if YYDEBUG
|
||||||
@@ -47,28 +47,13 @@
|
|||||||
#if GRAM_DEBUG
|
#if GRAM_DEBUG
|
||||||
extern int gram_debug;
|
extern int gram_debug;
|
||||||
#endif
|
#endif
|
||||||
/* "%code requires" blocks. */
|
|
||||||
#line 223 "src/parse-gram.y" /* yacc.c:1932 */
|
|
||||||
|
|
||||||
# ifndef PARAM_TYPE
|
/* Tokens. */
|
||||||
# define PARAM_TYPE
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
param_none = 0,
|
|
||||||
param_lex = 1 << 0,
|
|
||||||
param_parse = 1 << 1,
|
|
||||||
param_both = param_lex | param_parse
|
|
||||||
} param_type;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
#line 66 "src/parse-gram.h" /* yacc.c:1932 */
|
|
||||||
|
|
||||||
/* Token type. */
|
|
||||||
#ifndef GRAM_TOKENTYPE
|
#ifndef GRAM_TOKENTYPE
|
||||||
# define GRAM_TOKENTYPE
|
# define GRAM_TOKENTYPE
|
||||||
enum gram_tokentype
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
{
|
know about them. */
|
||||||
|
enum gram_tokentype {
|
||||||
GRAM_EOF = 0,
|
GRAM_EOF = 0,
|
||||||
STRING = 258,
|
STRING = 258,
|
||||||
INT = 259,
|
INT = 259,
|
||||||
@@ -80,50 +65,51 @@ extern int gram_debug;
|
|||||||
PERCENT_LEFT = 265,
|
PERCENT_LEFT = 265,
|
||||||
PERCENT_RIGHT = 266,
|
PERCENT_RIGHT = 266,
|
||||||
PERCENT_NONASSOC = 267,
|
PERCENT_NONASSOC = 267,
|
||||||
PERCENT_PRECEDENCE = 268,
|
PERCENT_PREC = 268,
|
||||||
PERCENT_PREC = 269,
|
PERCENT_DPREC = 269,
|
||||||
PERCENT_DPREC = 270,
|
PERCENT_MERGE = 270,
|
||||||
PERCENT_MERGE = 271,
|
PERCENT_CODE = 271,
|
||||||
PERCENT_CODE = 272,
|
PERCENT_DEBUG = 272,
|
||||||
PERCENT_DEFAULT_PREC = 273,
|
PERCENT_DEFAULT_PREC = 273,
|
||||||
PERCENT_DEFINE = 274,
|
PERCENT_DEFINE = 274,
|
||||||
PERCENT_DEFINES = 275,
|
PERCENT_DEFINES = 275,
|
||||||
PERCENT_ERROR_VERBOSE = 276,
|
PERCENT_ERROR_VERBOSE = 276,
|
||||||
PERCENT_EXPECT = 277,
|
PERCENT_EXPECT = 277,
|
||||||
PERCENT_EXPECT_RR = 278,
|
PERCENT_EXPECT_RR = 278,
|
||||||
PERCENT_FLAG = 279,
|
PERCENT_FILE_PREFIX = 279,
|
||||||
PERCENT_FILE_PREFIX = 280,
|
PERCENT_GLR_PARSER = 280,
|
||||||
PERCENT_GLR_PARSER = 281,
|
PERCENT_INITIAL_ACTION = 281,
|
||||||
PERCENT_INITIAL_ACTION = 282,
|
PERCENT_LANGUAGE = 282,
|
||||||
PERCENT_LANGUAGE = 283,
|
PERCENT_LEX_PARAM = 283,
|
||||||
PERCENT_NAME_PREFIX = 284,
|
PERCENT_LOCATIONS = 284,
|
||||||
PERCENT_NO_DEFAULT_PREC = 285,
|
PERCENT_NAME_PREFIX = 285,
|
||||||
PERCENT_NO_LINES = 286,
|
PERCENT_NO_DEFAULT_PREC = 286,
|
||||||
PERCENT_NONDETERMINISTIC_PARSER = 287,
|
PERCENT_NO_LINES = 287,
|
||||||
PERCENT_OUTPUT = 288,
|
PERCENT_NONDETERMINISTIC_PARSER = 288,
|
||||||
PERCENT_REQUIRE = 289,
|
PERCENT_OUTPUT = 289,
|
||||||
PERCENT_SKELETON = 290,
|
PERCENT_PARSE_PARAM = 290,
|
||||||
PERCENT_START = 291,
|
PERCENT_PURE_PARSER = 291,
|
||||||
PERCENT_TOKEN_TABLE = 292,
|
PERCENT_REQUIRE = 292,
|
||||||
PERCENT_VERBOSE = 293,
|
PERCENT_SKELETON = 293,
|
||||||
PERCENT_YACC = 294,
|
PERCENT_START = 294,
|
||||||
BRACED_CODE = 295,
|
PERCENT_TOKEN_TABLE = 295,
|
||||||
BRACED_PREDICATE = 296,
|
PERCENT_VERBOSE = 296,
|
||||||
BRACKETED_ID = 297,
|
PERCENT_YACC = 297,
|
||||||
CHAR = 298,
|
BRACED_CODE = 298,
|
||||||
EPILOGUE = 299,
|
BRACKETED_ID = 299,
|
||||||
EQUAL = 300,
|
CHAR = 300,
|
||||||
ID = 301,
|
EPILOGUE = 301,
|
||||||
ID_COLON = 302,
|
EQUAL = 302,
|
||||||
PERCENT_PERCENT = 303,
|
ID = 303,
|
||||||
PIPE = 304,
|
ID_COLON = 304,
|
||||||
PROLOGUE = 305,
|
PERCENT_PERCENT = 305,
|
||||||
SEMICOLON = 306,
|
PIPE = 306,
|
||||||
TAG = 307,
|
PROLOGUE = 307,
|
||||||
TAG_ANY = 308,
|
SEMICOLON = 308,
|
||||||
TAG_NONE = 309,
|
TYPE = 309,
|
||||||
PERCENT_PARAM = 310,
|
TYPE_TAG_ANY = 310,
|
||||||
PERCENT_UNION = 311
|
TYPE_TAG_NONE = 311,
|
||||||
|
PERCENT_UNION = 312
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
@@ -138,97 +124,105 @@ extern int gram_debug;
|
|||||||
#define PERCENT_LEFT 265
|
#define PERCENT_LEFT 265
|
||||||
#define PERCENT_RIGHT 266
|
#define PERCENT_RIGHT 266
|
||||||
#define PERCENT_NONASSOC 267
|
#define PERCENT_NONASSOC 267
|
||||||
#define PERCENT_PRECEDENCE 268
|
#define PERCENT_PREC 268
|
||||||
#define PERCENT_PREC 269
|
#define PERCENT_DPREC 269
|
||||||
#define PERCENT_DPREC 270
|
#define PERCENT_MERGE 270
|
||||||
#define PERCENT_MERGE 271
|
#define PERCENT_CODE 271
|
||||||
#define PERCENT_CODE 272
|
#define PERCENT_DEBUG 272
|
||||||
#define PERCENT_DEFAULT_PREC 273
|
#define PERCENT_DEFAULT_PREC 273
|
||||||
#define PERCENT_DEFINE 274
|
#define PERCENT_DEFINE 274
|
||||||
#define PERCENT_DEFINES 275
|
#define PERCENT_DEFINES 275
|
||||||
#define PERCENT_ERROR_VERBOSE 276
|
#define PERCENT_ERROR_VERBOSE 276
|
||||||
#define PERCENT_EXPECT 277
|
#define PERCENT_EXPECT 277
|
||||||
#define PERCENT_EXPECT_RR 278
|
#define PERCENT_EXPECT_RR 278
|
||||||
#define PERCENT_FLAG 279
|
#define PERCENT_FILE_PREFIX 279
|
||||||
#define PERCENT_FILE_PREFIX 280
|
#define PERCENT_GLR_PARSER 280
|
||||||
#define PERCENT_GLR_PARSER 281
|
#define PERCENT_INITIAL_ACTION 281
|
||||||
#define PERCENT_INITIAL_ACTION 282
|
#define PERCENT_LANGUAGE 282
|
||||||
#define PERCENT_LANGUAGE 283
|
#define PERCENT_LEX_PARAM 283
|
||||||
#define PERCENT_NAME_PREFIX 284
|
#define PERCENT_LOCATIONS 284
|
||||||
#define PERCENT_NO_DEFAULT_PREC 285
|
#define PERCENT_NAME_PREFIX 285
|
||||||
#define PERCENT_NO_LINES 286
|
#define PERCENT_NO_DEFAULT_PREC 286
|
||||||
#define PERCENT_NONDETERMINISTIC_PARSER 287
|
#define PERCENT_NO_LINES 287
|
||||||
#define PERCENT_OUTPUT 288
|
#define PERCENT_NONDETERMINISTIC_PARSER 288
|
||||||
#define PERCENT_REQUIRE 289
|
#define PERCENT_OUTPUT 289
|
||||||
#define PERCENT_SKELETON 290
|
#define PERCENT_PARSE_PARAM 290
|
||||||
#define PERCENT_START 291
|
#define PERCENT_PURE_PARSER 291
|
||||||
#define PERCENT_TOKEN_TABLE 292
|
#define PERCENT_REQUIRE 292
|
||||||
#define PERCENT_VERBOSE 293
|
#define PERCENT_SKELETON 293
|
||||||
#define PERCENT_YACC 294
|
#define PERCENT_START 294
|
||||||
#define BRACED_CODE 295
|
#define PERCENT_TOKEN_TABLE 295
|
||||||
#define BRACED_PREDICATE 296
|
#define PERCENT_VERBOSE 296
|
||||||
#define BRACKETED_ID 297
|
#define PERCENT_YACC 297
|
||||||
#define CHAR 298
|
#define BRACED_CODE 298
|
||||||
#define EPILOGUE 299
|
#define BRACKETED_ID 299
|
||||||
#define EQUAL 300
|
#define CHAR 300
|
||||||
#define ID 301
|
#define EPILOGUE 301
|
||||||
#define ID_COLON 302
|
#define EQUAL 302
|
||||||
#define PERCENT_PERCENT 303
|
#define ID 303
|
||||||
#define PIPE 304
|
#define ID_COLON 304
|
||||||
#define PROLOGUE 305
|
#define PERCENT_PERCENT 305
|
||||||
#define SEMICOLON 306
|
#define PIPE 306
|
||||||
#define TAG 307
|
#define PROLOGUE 307
|
||||||
#define TAG_ANY 308
|
#define SEMICOLON 308
|
||||||
#define TAG_NONE 309
|
#define TYPE 309
|
||||||
#define PERCENT_PARAM 310
|
#define TYPE_TAG_ANY 310
|
||||||
#define PERCENT_UNION 311
|
#define TYPE_TAG_NONE 311
|
||||||
|
#define PERCENT_UNION 312
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Value type. */
|
|
||||||
#if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED
|
#if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED
|
||||||
typedef union GRAM_STYPE GRAM_STYPE;
|
typedef union GRAM_STYPE
|
||||||
union GRAM_STYPE
|
|
||||||
{
|
{
|
||||||
#line 109 "src/parse-gram.y" /* yacc.c:1932 */
|
/* Line 2053 of yacc.c */
|
||||||
|
#line 115 "parse-gram.y"
|
||||||
|
|
||||||
assoc assoc;
|
|
||||||
char *code;
|
|
||||||
char const *chars;
|
|
||||||
int integer;
|
|
||||||
named_ref *named_ref;
|
|
||||||
symbol *symbol;
|
symbol *symbol;
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
|
int integer;
|
||||||
|
char const *chars;
|
||||||
|
char *code;
|
||||||
|
assoc assoc;
|
||||||
uniqstr uniqstr;
|
uniqstr uniqstr;
|
||||||
unsigned char character;
|
unsigned char character;
|
||||||
|
named_ref *named_ref;
|
||||||
|
|
||||||
#line 247 "src/parse-gram.y" /* yacc.c:1932 */
|
|
||||||
|
|
||||||
param_type param;
|
/* Line 2053 of yacc.c */
|
||||||
|
#line 194 "parse-gram.h"
|
||||||
#line 423 "src/parse-gram.y" /* yacc.c:1932 */
|
} GRAM_STYPE;
|
||||||
code_props_type code_type;
|
|
||||||
|
|
||||||
#line 211 "src/parse-gram.h" /* yacc.c:1932 */
|
|
||||||
};
|
|
||||||
# define GRAM_STYPE_IS_TRIVIAL 1
|
# define GRAM_STYPE_IS_TRIVIAL 1
|
||||||
|
# define gram_stype GRAM_STYPE /* obsolescent; will be withdrawn */
|
||||||
# define GRAM_STYPE_IS_DECLARED 1
|
# define GRAM_STYPE_IS_DECLARED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Location type. */
|
|
||||||
#if ! defined GRAM_LTYPE && ! defined GRAM_LTYPE_IS_DECLARED
|
#if ! defined GRAM_LTYPE && ! defined GRAM_LTYPE_IS_DECLARED
|
||||||
typedef struct GRAM_LTYPE GRAM_LTYPE;
|
typedef struct GRAM_LTYPE
|
||||||
struct GRAM_LTYPE
|
|
||||||
{
|
{
|
||||||
int first_line;
|
int first_line;
|
||||||
int first_column;
|
int first_column;
|
||||||
int last_line;
|
int last_line;
|
||||||
int last_column;
|
int last_column;
|
||||||
};
|
} GRAM_LTYPE;
|
||||||
|
# define gram_ltype GRAM_LTYPE /* obsolescent; will be withdrawn */
|
||||||
# define GRAM_LTYPE_IS_DECLARED 1
|
# define GRAM_LTYPE_IS_DECLARED 1
|
||||||
# define GRAM_LTYPE_IS_TRIVIAL 1
|
# define GRAM_LTYPE_IS_TRIVIAL 1
|
||||||
#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);
|
int gram_parse (void);
|
||||||
|
#else
|
||||||
|
int gram_parse ();
|
||||||
|
#endif
|
||||||
|
#endif /* ! YYPARSE_PARAM */
|
||||||
|
|
||||||
#endif /* !YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED */
|
#endif /* !YY_GRAM__SRC_PARSE_GRAM_H_INCLUDED */
|
||||||
|
|||||||
+114
-155
@@ -31,7 +31,6 @@
|
|||||||
#include "quotearg.h"
|
#include "quotearg.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "symlist.h"
|
#include "symlist.h"
|
||||||
#include "symtab.h"
|
|
||||||
#include "scan-gram.h"
|
#include "scan-gram.h"
|
||||||
#include "scan-code.h"
|
#include "scan-code.h"
|
||||||
#include "xmemdup0.h"
|
#include "xmemdup0.h"
|
||||||
@@ -52,16 +51,22 @@ static void version_check (location const *loc, char const *version);
|
|||||||
static void gram_error (location const *, char const *);
|
static void gram_error (location const *, char const *);
|
||||||
|
|
||||||
static char const *char_name (char);
|
static char const *char_name (char);
|
||||||
%}
|
|
||||||
|
|
||||||
%code
|
/** Add a lex-param or a parse-param.
|
||||||
{
|
*
|
||||||
static int current_prec = 0;
|
* \param type \a lex_param or \a parse_param
|
||||||
static location current_lhs_location;
|
* \param decl the formal argument
|
||||||
static named_ref *current_lhs_named_ref;
|
* \param loc the location in the source.
|
||||||
static symbol *current_lhs_symbol;
|
*/
|
||||||
|
static void add_param (char const *type, char *decl, location loc);
|
||||||
|
|
||||||
|
|
||||||
static symbol_class current_class = unknown_sym;
|
static symbol_class current_class = unknown_sym;
|
||||||
static uniqstr current_type = NULL;
|
static uniqstr current_type = NULL;
|
||||||
|
static symbol *current_lhs_symbol;
|
||||||
|
static location current_lhs_location;
|
||||||
|
static named_ref *current_lhs_named_ref;
|
||||||
|
static int current_prec = 0;
|
||||||
|
|
||||||
/** Set the new current left-hand side symbol, possibly common
|
/** Set the new current left-hand side symbol, possibly common
|
||||||
* to several right-hand side parts of rule.
|
* to several right-hand side parts of rule.
|
||||||
@@ -81,20 +86,21 @@ static char const *char_name (char);
|
|||||||
current_lhs_named_ref = ref;
|
current_lhs_named_ref = ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define YYTYPE_INT16 int_fast16_t
|
#define YYTYPE_INT16 int_fast16_t
|
||||||
#define YYTYPE_INT8 int_fast8_t
|
#define YYTYPE_INT8 int_fast8_t
|
||||||
#define YYTYPE_UINT16 uint_fast16_t
|
#define YYTYPE_UINT16 uint_fast16_t
|
||||||
#define YYTYPE_UINT8 uint_fast8_t
|
#define YYTYPE_UINT8 uint_fast8_t
|
||||||
}
|
%}
|
||||||
|
|
||||||
|
%debug
|
||||||
%define api.prefix "gram_"
|
%define api.prefix "gram_"
|
||||||
%define api.pure
|
%define api.pure
|
||||||
%define locations
|
|
||||||
%define parse.error verbose
|
|
||||||
%define parse.lac full
|
%define parse.lac full
|
||||||
%define parse.trace
|
|
||||||
%defines
|
%defines
|
||||||
|
%error-verbose
|
||||||
%expect 0
|
%expect 0
|
||||||
|
%locations
|
||||||
%verbose
|
%verbose
|
||||||
|
|
||||||
%initial-action
|
%initial-action
|
||||||
@@ -107,15 +113,15 @@ static char const *char_name (char);
|
|||||||
|
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
assoc assoc;
|
|
||||||
char *code;
|
|
||||||
char const *chars;
|
|
||||||
int integer;
|
|
||||||
named_ref *named_ref;
|
|
||||||
symbol *symbol;
|
symbol *symbol;
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
|
int integer;
|
||||||
|
char const *chars;
|
||||||
|
char *code;
|
||||||
|
assoc assoc;
|
||||||
uniqstr uniqstr;
|
uniqstr uniqstr;
|
||||||
unsigned char character;
|
unsigned char character;
|
||||||
|
named_ref *named_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Define the tokens together with their human representation. */
|
/* Define the tokens together with their human representation. */
|
||||||
@@ -133,35 +139,39 @@ static char const *char_name (char);
|
|||||||
%token PERCENT_LEFT "%left"
|
%token PERCENT_LEFT "%left"
|
||||||
%token PERCENT_RIGHT "%right"
|
%token PERCENT_RIGHT "%right"
|
||||||
%token PERCENT_NONASSOC "%nonassoc"
|
%token PERCENT_NONASSOC "%nonassoc"
|
||||||
%token PERCENT_PRECEDENCE "%precedence"
|
|
||||||
|
|
||||||
%token PERCENT_PREC "%prec"
|
%token PERCENT_PREC "%prec"
|
||||||
%token PERCENT_DPREC "%dprec"
|
%token PERCENT_DPREC "%dprec"
|
||||||
%token PERCENT_MERGE "%merge"
|
%token PERCENT_MERGE "%merge"
|
||||||
|
|
||||||
|
|
||||||
/*----------------------.
|
/*----------------------.
|
||||||
| Global Declarations. |
|
| Global Declarations. |
|
||||||
`----------------------*/
|
`----------------------*/
|
||||||
|
|
||||||
%token
|
%token
|
||||||
PERCENT_CODE "%code"
|
PERCENT_CODE "%code"
|
||||||
|
PERCENT_DEBUG "%debug"
|
||||||
PERCENT_DEFAULT_PREC "%default-prec"
|
PERCENT_DEFAULT_PREC "%default-prec"
|
||||||
PERCENT_DEFINE "%define"
|
PERCENT_DEFINE "%define"
|
||||||
PERCENT_DEFINES "%defines"
|
PERCENT_DEFINES "%defines"
|
||||||
PERCENT_ERROR_VERBOSE "%error-verbose"
|
PERCENT_ERROR_VERBOSE "%error-verbose"
|
||||||
PERCENT_EXPECT "%expect"
|
PERCENT_EXPECT "%expect"
|
||||||
PERCENT_EXPECT_RR "%expect-rr"
|
PERCENT_EXPECT_RR "%expect-rr"
|
||||||
PERCENT_FLAG "%<flag>"
|
|
||||||
PERCENT_FILE_PREFIX "%file-prefix"
|
PERCENT_FILE_PREFIX "%file-prefix"
|
||||||
PERCENT_GLR_PARSER "%glr-parser"
|
PERCENT_GLR_PARSER "%glr-parser"
|
||||||
PERCENT_INITIAL_ACTION "%initial-action"
|
PERCENT_INITIAL_ACTION "%initial-action"
|
||||||
PERCENT_LANGUAGE "%language"
|
PERCENT_LANGUAGE "%language"
|
||||||
|
PERCENT_LEX_PARAM "%lex-param"
|
||||||
|
PERCENT_LOCATIONS "%locations"
|
||||||
PERCENT_NAME_PREFIX "%name-prefix"
|
PERCENT_NAME_PREFIX "%name-prefix"
|
||||||
PERCENT_NO_DEFAULT_PREC "%no-default-prec"
|
PERCENT_NO_DEFAULT_PREC "%no-default-prec"
|
||||||
PERCENT_NO_LINES "%no-lines"
|
PERCENT_NO_LINES "%no-lines"
|
||||||
PERCENT_NONDETERMINISTIC_PARSER
|
PERCENT_NONDETERMINISTIC_PARSER
|
||||||
"%nondeterministic-parser"
|
"%nondeterministic-parser"
|
||||||
PERCENT_OUTPUT "%output"
|
PERCENT_OUTPUT "%output"
|
||||||
|
PERCENT_PARSE_PARAM "%parse-param"
|
||||||
|
PERCENT_PURE_PARSER "%pure-parser"
|
||||||
PERCENT_REQUIRE "%require"
|
PERCENT_REQUIRE "%require"
|
||||||
PERCENT_SKELETON "%skeleton"
|
PERCENT_SKELETON "%skeleton"
|
||||||
PERCENT_START "%start"
|
PERCENT_START "%start"
|
||||||
@@ -171,7 +181,6 @@ static char const *char_name (char);
|
|||||||
;
|
;
|
||||||
|
|
||||||
%token BRACED_CODE "{...}"
|
%token BRACED_CODE "{...}"
|
||||||
%token BRACED_PREDICATE "%?{...}"
|
|
||||||
%token BRACKETED_ID "[identifier]"
|
%token BRACKETED_ID "[identifier]"
|
||||||
%token CHAR "char"
|
%token CHAR "char"
|
||||||
%token EPILOGUE "epilogue"
|
%token EPILOGUE "epilogue"
|
||||||
@@ -182,90 +191,39 @@ static char const *char_name (char);
|
|||||||
%token PIPE "|"
|
%token PIPE "|"
|
||||||
%token PROLOGUE "%{...%}"
|
%token PROLOGUE "%{...%}"
|
||||||
%token SEMICOLON ";"
|
%token SEMICOLON ";"
|
||||||
%token TAG "<tag>"
|
%token TYPE "type"
|
||||||
%token TAG_ANY "<*>"
|
%token TYPE_TAG_ANY "<*>"
|
||||||
%token TAG_NONE "<>"
|
%token TYPE_TAG_NONE "<>"
|
||||||
|
|
||||||
%type <character> CHAR
|
%type <character> CHAR
|
||||||
%printer { fputs (char_name ($$), yyo); } CHAR
|
%printer { fputs (char_name ($$), stderr); } CHAR
|
||||||
|
|
||||||
/* braceless is not to be used for rule or symbol actions, as it
|
/* braceless is not to be used for rule or symbol actions, as it
|
||||||
calls code_props_plain_init. */
|
calls code_props_plain_init. */
|
||||||
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
|
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
|
||||||
%type <code> "{...}" "%?{...}"
|
%type <code> "{...}"
|
||||||
%printer { fputs (quotearg_style (c_quoting_style, $$), yyo); }
|
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
||||||
STRING
|
STRING
|
||||||
%printer { fprintf (yyo, "{\n%s\n}", $$); }
|
%printer { fprintf (stderr, "{\n%s\n}", $$); }
|
||||||
braceless content.opt "{...}" "%{...%}" EPILOGUE
|
braceless content.opt "{...}" "%{...%}" EPILOGUE
|
||||||
|
|
||||||
%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG tag variable
|
%type <uniqstr> BRACKETED_ID ID ID_COLON TYPE variable
|
||||||
%printer { fputs ($$, yyo); } <uniqstr>
|
%printer { fputs ($$, stderr); } <uniqstr>
|
||||||
%printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
|
%printer { fprintf (stderr, "[%s]", $$); } BRACKETED_ID
|
||||||
%printer { fprintf (yyo, "%s:", $$); } ID_COLON
|
%printer { fprintf (stderr, "%s:", $$); } ID_COLON
|
||||||
%printer { fprintf (yyo, "%%%s", $$); } PERCENT_FLAG
|
%printer { fprintf (stderr, "<%s>", $$); } TYPE
|
||||||
%printer { fprintf (yyo, "<%s>", $$); } TAG tag
|
|
||||||
|
|
||||||
%type <integer> INT
|
%type <integer> INT
|
||||||
%printer { fprintf (yyo, "%d", $$); } <integer>
|
%printer { fprintf (stderr, "%d", $$); } <integer>
|
||||||
|
|
||||||
%type <symbol> id id_colon string_as_id symbol symbol.prec
|
%type <symbol> id id_colon string_as_id symbol symbol.prec
|
||||||
%printer { fprintf (yyo, "%s", $$->tag); } <symbol>
|
%printer { fprintf (stderr, "%s", $$->tag); } <symbol>
|
||||||
%printer { fprintf (yyo, "%s:", $$->tag); } id_colon
|
%printer { fprintf (stderr, "%s:", $$->tag); } id_colon
|
||||||
|
|
||||||
%type <assoc> precedence_declarator
|
%type <assoc> precedence_declarator
|
||||||
%type <list> symbols.1 symbols.prec generic_symlist generic_symlist_item
|
%type <list> symbols.1 symbols.prec generic_symlist generic_symlist_item
|
||||||
%type <named_ref> named_ref.opt
|
%type <named_ref> named_ref.opt
|
||||||
|
|
||||||
/*---------.
|
|
||||||
| %param. |
|
|
||||||
`---------*/
|
|
||||||
%code requires
|
|
||||||
{
|
|
||||||
# ifndef PARAM_TYPE
|
|
||||||
# define PARAM_TYPE
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
param_none = 0,
|
|
||||||
param_lex = 1 << 0,
|
|
||||||
param_parse = 1 << 1,
|
|
||||||
param_both = param_lex | param_parse
|
|
||||||
} param_type;
|
|
||||||
# endif
|
|
||||||
};
|
|
||||||
%code
|
|
||||||
{
|
|
||||||
/** Add a lex-param and/or a parse-param.
|
|
||||||
*
|
|
||||||
* \param type where to push this formal argument.
|
|
||||||
* \param decl the formal argument. Destroyed.
|
|
||||||
* \param loc the location in the source.
|
|
||||||
*/
|
|
||||||
static void add_param (param_type type, char *decl, location loc);
|
|
||||||
static param_type current_param = param_none;
|
|
||||||
};
|
|
||||||
%union
|
|
||||||
{
|
|
||||||
param_type param;
|
|
||||||
}
|
|
||||||
%token <param> PERCENT_PARAM "%param";
|
|
||||||
%printer
|
|
||||||
{
|
|
||||||
switch ($$)
|
|
||||||
{
|
|
||||||
#define CASE(In, Out) \
|
|
||||||
case param_ ## In: fputs ("%" #Out, stderr); break
|
|
||||||
CASE(lex, lex-param);
|
|
||||||
CASE(parse, parse-param);
|
|
||||||
CASE(both, param);
|
|
||||||
#undef CASE
|
|
||||||
case param_none: aver (false); break;
|
|
||||||
}
|
|
||||||
} <param>;
|
|
||||||
|
|
||||||
|
|
||||||
/*==========\
|
|
||||||
| Grammar. |
|
|
||||||
\==========*/
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
input:
|
input:
|
||||||
@@ -294,10 +252,7 @@ prologue_declaration:
|
|||||||
plain_code.code, @1);
|
plain_code.code, @1);
|
||||||
code_scanner_last_string_free ();
|
code_scanner_last_string_free ();
|
||||||
}
|
}
|
||||||
| "%<flag>"
|
| "%debug" { debug = true; }
|
||||||
{
|
|
||||||
muscle_percent_define_ensure ($1, @1, true);
|
|
||||||
}
|
|
||||||
| "%define" variable content.opt
|
| "%define" variable content.opt
|
||||||
{
|
{
|
||||||
muscle_percent_define_insert ($2, @2, $3,
|
muscle_percent_define_insert ($2, @2, $3,
|
||||||
@@ -309,14 +264,11 @@ prologue_declaration:
|
|||||||
defines_flag = true;
|
defines_flag = true;
|
||||||
spec_defines_file = xstrdup ($2);
|
spec_defines_file = xstrdup ($2);
|
||||||
}
|
}
|
||||||
| "%error-verbose"
|
| "%error-verbose" { error_verbose = true; }
|
||||||
{
|
|
||||||
muscle_percent_define_insert ("parse.error", @1, "verbose",
|
|
||||||
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
|
||||||
}
|
|
||||||
| "%expect" INT { expected_sr_conflicts = $2; }
|
| "%expect" INT { expected_sr_conflicts = $2; }
|
||||||
| "%expect-rr" INT { expected_rr_conflicts = $2; }
|
| "%expect-rr" INT { expected_rr_conflicts = $2; }
|
||||||
| "%file-prefix" STRING { spec_file_prefix = $2; }
|
| "%file-prefix" STRING { spec_file_prefix = $2; }
|
||||||
|
| "%file-prefix" "=" STRING { spec_file_prefix = $3; } /* deprecated */
|
||||||
| "%glr-parser"
|
| "%glr-parser"
|
||||||
{
|
{
|
||||||
nondeterministic_parser = true;
|
nondeterministic_parser = true;
|
||||||
@@ -332,16 +284,35 @@ prologue_declaration:
|
|||||||
code_scanner_last_string_free ();
|
code_scanner_last_string_free ();
|
||||||
}
|
}
|
||||||
| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
|
| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
|
||||||
|
| "%lex-param" "{...}" { add_param ("lex_param", $2, @2); }
|
||||||
|
| "%locations" { locations_flag = true; }
|
||||||
| "%name-prefix" STRING { spec_name_prefix = $2; }
|
| "%name-prefix" STRING { spec_name_prefix = $2; }
|
||||||
|
| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */
|
||||||
| "%no-lines" { no_lines_flag = true; }
|
| "%no-lines" { no_lines_flag = true; }
|
||||||
| "%nondeterministic-parser" { nondeterministic_parser = true; }
|
| "%nondeterministic-parser" { nondeterministic_parser = true; }
|
||||||
| "%output" STRING { spec_outfile = $2; }
|
| "%output" STRING { spec_outfile = $2; }
|
||||||
| "%param" { current_param = $1; } params { current_param = param_none; }
|
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
|
||||||
|
| "%parse-param" "{...}" { add_param ("parse_param", $2, @2); }
|
||||||
|
| "%pure-parser"
|
||||||
|
{
|
||||||
|
/* %pure-parser is deprecated in favor of `%define api.pure', so use
|
||||||
|
`%define api.pure' in a backward-compatible manner here. First, don't
|
||||||
|
complain if %pure-parser is specified multiple times. */
|
||||||
|
if (!muscle_find_const ("percent_define(api.pure)"))
|
||||||
|
muscle_percent_define_insert ("api.pure", @1, "",
|
||||||
|
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
||||||
|
/* In all cases, use api.pure now so that the backend doesn't complain if
|
||||||
|
the skeleton ignores api.pure, but do warn now if there's a previous
|
||||||
|
conflicting definition from an actual %define. */
|
||||||
|
if (!muscle_percent_define_flag_if ("api.pure"))
|
||||||
|
muscle_percent_define_insert ("api.pure", @1, "",
|
||||||
|
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
||||||
|
}
|
||||||
| "%require" STRING { version_check (&@2, $2); }
|
| "%require" STRING { version_check (&@2, $2); }
|
||||||
| "%skeleton" STRING
|
| "%skeleton" STRING
|
||||||
{
|
{
|
||||||
char const *skeleton_user = $2;
|
char const *skeleton_user = $2;
|
||||||
if (strchr (skeleton_user, '/'))
|
if (mbschr (skeleton_user, '/'))
|
||||||
{
|
{
|
||||||
size_t dir_length = strlen (current_file);
|
size_t dir_length = strlen (current_file);
|
||||||
char *skeleton_build;
|
char *skeleton_build;
|
||||||
@@ -368,16 +339,6 @@ prologue_declaration:
|
|||||||
| /*FIXME: Err? What is this horror doing here? */ ";"
|
| /*FIXME: Err? What is this horror doing here? */ ";"
|
||||||
;
|
;
|
||||||
|
|
||||||
params:
|
|
||||||
params "{...}" { add_param (current_param, $2, @2); }
|
|
||||||
| "{...}" { add_param (current_param, $1, @1); }
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------.
|
|
||||||
| grammar_declaration. |
|
|
||||||
`----------------------*/
|
|
||||||
|
|
||||||
grammar_declaration:
|
grammar_declaration:
|
||||||
precedence_declaration
|
precedence_declaration
|
||||||
| symbol_declaration
|
| symbol_declaration
|
||||||
@@ -385,7 +346,7 @@ grammar_declaration:
|
|||||||
{
|
{
|
||||||
grammar_start_symbol_set ($2, @2);
|
grammar_start_symbol_set ($2, @2);
|
||||||
}
|
}
|
||||||
| code_props_type "{...}" generic_symlist
|
| "%destructor" "{...}" generic_symlist
|
||||||
{
|
{
|
||||||
code_props code;
|
code_props code;
|
||||||
code_props_symbol_action_init (&code, $2, @2);
|
code_props_symbol_action_init (&code, $2, @2);
|
||||||
@@ -393,7 +354,19 @@ grammar_declaration:
|
|||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
for (list = $3; list; list = list->next)
|
for (list = $3; list; list = list->next)
|
||||||
symbol_list_code_props_set (list, $1, &code);
|
symbol_list_destructor_set (list, &code);
|
||||||
|
symbol_list_free ($3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| "%printer" "{...}" generic_symlist
|
||||||
|
{
|
||||||
|
code_props code;
|
||||||
|
code_props_symbol_action_init (&code, $2, @2);
|
||||||
|
code_props_translate_code (&code);
|
||||||
|
{
|
||||||
|
symbol_list *list;
|
||||||
|
for (list = $3; list; list = list->next)
|
||||||
|
symbol_list_printer_set (list, &code);
|
||||||
symbol_list_free ($3);
|
symbol_list_free ($3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,17 +392,10 @@ grammar_declaration:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
%type <code_type> code_props_type;
|
|
||||||
%union {code_props_type code_type;};
|
|
||||||
%printer { fprintf (yyo, "%s", code_props_type_string ($$)); } <code_type>;
|
|
||||||
code_props_type:
|
|
||||||
"%destructor" { $$ = destructor; }
|
|
||||||
| "%printer" { $$ = printer; }
|
|
||||||
;
|
|
||||||
|
|
||||||
/*---------.
|
/*----------*
|
||||||
| %union. |
|
| %union. |
|
||||||
`---------*/
|
*----------*/
|
||||||
|
|
||||||
%token PERCENT_UNION "%union";
|
%token PERCENT_UNION "%union";
|
||||||
|
|
||||||
@@ -461,7 +427,7 @@ symbol_declaration:
|
|||||||
current_class = unknown_sym;
|
current_class = unknown_sym;
|
||||||
current_type = NULL;
|
current_type = NULL;
|
||||||
}
|
}
|
||||||
| "%type" TAG symbols.1
|
| "%type" TYPE symbols.1
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
tag_seen = true;
|
tag_seen = true;
|
||||||
@@ -472,7 +438,7 @@ symbol_declaration:
|
|||||||
;
|
;
|
||||||
|
|
||||||
precedence_declaration:
|
precedence_declaration:
|
||||||
precedence_declarator tag.opt symbols.prec
|
precedence_declarator type.opt symbols.prec
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
++current_prec;
|
++current_prec;
|
||||||
@@ -490,12 +456,11 @@ precedence_declarator:
|
|||||||
"%left" { $$ = left_assoc; }
|
"%left" { $$ = left_assoc; }
|
||||||
| "%right" { $$ = right_assoc; }
|
| "%right" { $$ = right_assoc; }
|
||||||
| "%nonassoc" { $$ = non_assoc; }
|
| "%nonassoc" { $$ = non_assoc; }
|
||||||
| "%precedence" { $$ = precedence_assoc; }
|
|
||||||
;
|
;
|
||||||
|
|
||||||
tag.opt:
|
type.opt:
|
||||||
/* Nothing. */ { current_type = NULL; }
|
/* Nothing. */ { current_type = NULL; }
|
||||||
| TAG { current_type = $1; tag_seen = true; }
|
| TYPE { current_type = $1; tag_seen = true; }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Just like symbols.1 but accept INT for the sake of POSIX. */
|
/* Just like symbols.1 but accept INT for the sake of POSIX. */
|
||||||
@@ -503,7 +468,7 @@ symbols.prec:
|
|||||||
symbol.prec
|
symbol.prec
|
||||||
{ $$ = symbol_list_sym_new ($1, @1); }
|
{ $$ = symbol_list_sym_new ($1, @1); }
|
||||||
| symbols.prec symbol.prec
|
| symbols.prec symbol.prec
|
||||||
{ $$ = symbol_list_append ($1, symbol_list_sym_new ($2, @2)); }
|
{ $$ = symbol_list_prepend ($1, symbol_list_sym_new ($2, @2)); }
|
||||||
;
|
;
|
||||||
|
|
||||||
symbol.prec:
|
symbol.prec:
|
||||||
@@ -516,28 +481,24 @@ symbols.1:
|
|||||||
symbol
|
symbol
|
||||||
{ $$ = symbol_list_sym_new ($1, @1); }
|
{ $$ = symbol_list_sym_new ($1, @1); }
|
||||||
| symbols.1 symbol
|
| symbols.1 symbol
|
||||||
{ $$ = symbol_list_append ($1, symbol_list_sym_new ($2, @2)); }
|
{ $$ = symbol_list_prepend ($1, symbol_list_sym_new ($2, @2)); }
|
||||||
;
|
;
|
||||||
|
|
||||||
generic_symlist:
|
generic_symlist:
|
||||||
generic_symlist_item { $$ = $1; }
|
generic_symlist_item { $$ = $1; }
|
||||||
| generic_symlist generic_symlist_item { $$ = symbol_list_append ($1, $2); }
|
| generic_symlist generic_symlist_item { $$ = symbol_list_prepend ($1, $2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
generic_symlist_item:
|
generic_symlist_item:
|
||||||
symbol { $$ = symbol_list_sym_new ($1, @1); }
|
symbol { $$ = symbol_list_sym_new ($1, @1); }
|
||||||
| tag { $$ = symbol_list_type_new ($1, @1); }
|
| TYPE { $$ = symbol_list_type_new ($1, @1); }
|
||||||
;
|
| "<*>" { $$ = symbol_list_default_tagged_new (@1); }
|
||||||
|
| "<>" { $$ = symbol_list_default_tagless_new (@1); }
|
||||||
tag:
|
|
||||||
TAG
|
|
||||||
| "<*>" { $$ = uniqstr_new ("*"); }
|
|
||||||
| "<>" { $$ = uniqstr_new (""); }
|
|
||||||
;
|
;
|
||||||
|
|
||||||
/* One token definition. */
|
/* One token definition. */
|
||||||
symbol_def:
|
symbol_def:
|
||||||
TAG
|
TYPE
|
||||||
{
|
{
|
||||||
current_type = $1;
|
current_type = $1;
|
||||||
tag_seen = true;
|
tag_seen = true;
|
||||||
@@ -616,14 +577,12 @@ rhs:
|
|||||||
| rhs symbol named_ref.opt
|
| rhs symbol named_ref.opt
|
||||||
{ grammar_current_rule_symbol_append ($2, @2, $3); }
|
{ grammar_current_rule_symbol_append ($2, @2, $3); }
|
||||||
| rhs "{...}" named_ref.opt
|
| rhs "{...}" named_ref.opt
|
||||||
{ grammar_current_rule_action_append ($2, @2, $3, false); }
|
{ grammar_current_rule_action_append ($2, @2, $3); }
|
||||||
| rhs "%?{...}"
|
|
||||||
{ grammar_current_rule_action_append ($2, @2, NULL, true); }
|
|
||||||
| rhs "%prec" symbol
|
| rhs "%prec" symbol
|
||||||
{ grammar_current_rule_prec_set ($3, @3); }
|
{ grammar_current_rule_prec_set ($3, @3); }
|
||||||
| rhs "%dprec" INT
|
| rhs "%dprec" INT
|
||||||
{ grammar_current_rule_dprec_set ($3, @3); }
|
{ grammar_current_rule_dprec_set ($3, @3); }
|
||||||
| rhs "%merge" TAG
|
| rhs "%merge" TYPE
|
||||||
{ grammar_current_rule_merge_set ($3, @3); }
|
{ grammar_current_rule_merge_set ($3, @3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -633,9 +592,10 @@ named_ref.opt:
|
|||||||
BRACKETED_ID { $$ = named_ref_new($1, @1); }
|
BRACKETED_ID { $$ = named_ref_new($1, @1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
/*---------------------------.
|
|
||||||
|
/*----------------------------*
|
||||||
| variable and content.opt. |
|
| variable and content.opt. |
|
||||||
`---------------------------*/
|
*---------------------------*/
|
||||||
|
|
||||||
/* The STRING form of variable is deprecated and is not M4-friendly.
|
/* The STRING form of variable is deprecated and is not M4-friendly.
|
||||||
For example, M4 fails for `%define "[" "value"'. */
|
For example, M4 fails for `%define "[" "value"'. */
|
||||||
@@ -652,9 +612,9 @@ content.opt:
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/*------------.
|
/*-------------*
|
||||||
| braceless. |
|
| braceless. |
|
||||||
`------------*/
|
*-------------*/
|
||||||
|
|
||||||
braceless:
|
braceless:
|
||||||
"{...}"
|
"{...}"
|
||||||
@@ -669,9 +629,9 @@ braceless:
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/*--------------.
|
/*---------------*
|
||||||
| Identifiers. |
|
| Identifiers. |
|
||||||
`--------------*/
|
*---------------*/
|
||||||
|
|
||||||
/* Identifiers are returned as uniqstr values by the scanner.
|
/* Identifiers are returned as uniqstr values by the scanner.
|
||||||
Depending on their use, we may need to make them genuine symbols. */
|
Depending on their use, we may need to make them genuine symbols. */
|
||||||
@@ -721,6 +681,7 @@ epilogue.opt:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|
||||||
/* Return the location of the left-hand side of a rule whose
|
/* Return the location of the left-hand side of a rule whose
|
||||||
right-hand side is RHS[1] ... RHS[N]. Ignore empty nonterminals in
|
right-hand side is RHS[1] ... RHS[N]. Ignore empty nonterminals in
|
||||||
the right-hand side, and return an empty location equal to the end
|
the right-hand side, and return an empty location equal to the end
|
||||||
@@ -751,18 +712,20 @@ lloc_default (YYLTYPE const *rhs, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Add a lex-param or a parse-param (depending on TYPE) with
|
||||||
|
declaration DECL and location LOC. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_param (param_type type, char *decl, location loc)
|
add_param (char const *type, char *decl, location loc)
|
||||||
{
|
{
|
||||||
static char const alphanum[26 + 26 + 1 + 10] =
|
static char const alphanum[26 + 26 + 1 + 10] =
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"_"
|
"_"
|
||||||
"0123456789";
|
"0123456789";
|
||||||
|
|
||||||
char const *name_start = NULL;
|
char const *name_start = NULL;
|
||||||
{
|
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
/* Stop on last actual character. */
|
/* Stop on last actual character. */
|
||||||
for (p = decl; p[1]; p++)
|
for (p = decl; p[1]; p++)
|
||||||
if ((p == decl
|
if ((p == decl
|
||||||
@@ -779,17 +742,13 @@ add_param (param_type type, char *decl, location loc)
|
|||||||
++decl;
|
++decl;
|
||||||
while (c_isspace ((unsigned char) *decl))
|
while (c_isspace ((unsigned char) *decl))
|
||||||
++decl;
|
++decl;
|
||||||
}
|
|
||||||
|
|
||||||
if (! name_start)
|
if (! name_start)
|
||||||
complain (&loc, complaint, _("missing identifier in parameter declaration"));
|
complain_at (loc, _("missing identifier in parameter declaration"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *name = xmemdup0 (name_start, strspn (name_start, alphanum));
|
char *name = xmemdup0 (name_start, strspn (name_start, alphanum));
|
||||||
if (type & param_lex)
|
muscle_pair_list_grow (type, decl, name);
|
||||||
muscle_pair_list_grow ("lex_param", decl, name);
|
|
||||||
if (type & param_parse)
|
|
||||||
muscle_pair_list_grow ("parse_param", decl, name);
|
|
||||||
free (name);
|
free (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,7 +761,7 @@ version_check (location const *loc, char const *version)
|
|||||||
{
|
{
|
||||||
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
||||||
{
|
{
|
||||||
complain (loc, complaint, "require bison %s, but have %s",
|
complain_at (*loc, "require bison %s, but have %s",
|
||||||
version, PACKAGE_VERSION);
|
version, PACKAGE_VERSION);
|
||||||
exit (EX_MISMATCH);
|
exit (EX_MISMATCH);
|
||||||
}
|
}
|
||||||
@@ -811,7 +770,7 @@ version_check (location const *loc, char const *version)
|
|||||||
static void
|
static void
|
||||||
gram_error (location const *loc, char const *msg)
|
gram_error (location const *loc, char const *msg)
|
||||||
{
|
{
|
||||||
complain (loc, complaint, "%s", msg);
|
complain_at (*loc, "%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
char const *
|
char const *
|
||||||
|
|||||||
+3
-3
@@ -334,10 +334,10 @@ print_reductions (FILE *out, state *s)
|
|||||||
if (default_reduction)
|
if (default_reduction)
|
||||||
{
|
{
|
||||||
char *default_reductions =
|
char *default_reductions =
|
||||||
muscle_percent_define_get ("lr.default-reduction");
|
muscle_percent_define_get ("lr.default-reductions");
|
||||||
print_reduction (out, width, _("$default"), default_reduction, true);
|
print_reduction (out, width, _("$default"), default_reduction, true);
|
||||||
aver (STREQ (default_reductions, "most")
|
aver (0 == strcmp (default_reductions, "most")
|
||||||
|| (STREQ (default_reductions, "consistent")
|
|| (0 == strcmp (default_reductions, "consistent")
|
||||||
&& default_reduction_only)
|
&& default_reduction_only)
|
||||||
|| (reds->num == 1 && reds->rules[0]->number == 0));
|
|| (reds->num == 1 && reds->rules[0]->number == 0));
|
||||||
free (default_reductions);
|
free (default_reductions);
|
||||||
|
|||||||
+36
-20
@@ -42,15 +42,32 @@
|
|||||||
/* Print the lhs of a rule in such a manner that there is no vertical
|
/* Print the lhs of a rule in such a manner that there is no vertical
|
||||||
repetition, like in *.output files. */
|
repetition, like in *.output files. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_lhs (struct obstack *oout, rule *previous_rule, rule *r)
|
||||||
|
{
|
||||||
|
if (previous_rule && STREQ (previous_rule->lhs->tag, r->lhs->tag))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < strlen (r->lhs->tag); ++i)
|
||||||
|
obstack_1grow (oout, ' ');
|
||||||
|
obstack_1grow (oout, '|');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
obstack_sgrow (oout, escape (r->lhs->tag));
|
||||||
|
obstack_1grow (oout, ':');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_core (struct obstack *oout, state *s)
|
print_core (struct obstack *oout, state *s)
|
||||||
{
|
{
|
||||||
item_number const *sitems = s->items;
|
item_number *sitems = s->items;
|
||||||
symbol *previous_lhs = NULL;
|
rule *previous_rule = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t snritems = s->nitems;
|
size_t snritems = s->nitems;
|
||||||
|
|
||||||
/* Output all the items of a state, not just its kernel. */
|
/* Output all the items of a state, not only its kernel. */
|
||||||
if (report_flag & report_itemsets)
|
if (report_flag & report_itemsets)
|
||||||
{
|
{
|
||||||
closure (sitems, snritems);
|
closure (sitems, snritems);
|
||||||
@@ -62,27 +79,25 @@ print_core (struct obstack *oout, state *s)
|
|||||||
obstack_sgrow (oout, "\\n\\l");
|
obstack_sgrow (oout, "\\n\\l");
|
||||||
for (i = 0; i < snritems; i++)
|
for (i = 0; i < snritems; i++)
|
||||||
{
|
{
|
||||||
item_number const *sp1 = ritem + sitems[i];
|
item_number *sp;
|
||||||
item_number const *sp = sp1;
|
item_number *sp1;
|
||||||
rule *r;
|
rule_number r;
|
||||||
|
|
||||||
while (0 <= *sp)
|
sp1 = sp = ritem + sitems[i];
|
||||||
|
|
||||||
|
while (*sp >= 0)
|
||||||
sp++;
|
sp++;
|
||||||
|
|
||||||
r = &rules[item_number_as_rule_number (*sp)];
|
r = item_number_as_rule_number (*sp);
|
||||||
|
|
||||||
obstack_printf (oout, "%3d ", r->number);
|
obstack_printf (oout, "%3d ", r);
|
||||||
if (previous_lhs && UNIQSTR_EQ (previous_lhs->tag, r->lhs->tag))
|
print_lhs (oout, previous_rule, &rules[r]);
|
||||||
obstack_printf (oout, "%*s| ",
|
previous_rule = &rules[r];
|
||||||
(int) strlen (previous_lhs->tag), "");
|
|
||||||
else
|
|
||||||
obstack_printf (oout, "%s: ", escape (r->lhs->tag));
|
|
||||||
previous_lhs = r->lhs;
|
|
||||||
|
|
||||||
for (sp = r->rhs; sp < sp1; sp++)
|
for (sp = rules[r].rhs; sp < sp1; sp++)
|
||||||
obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
|
obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
|
||||||
|
|
||||||
obstack_1grow (oout, '.');
|
obstack_sgrow (oout, " .");
|
||||||
|
|
||||||
for (/* Nothing */; *sp >= 0; ++sp)
|
for (/* Nothing */; *sp >= 0; ++sp)
|
||||||
obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
|
obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
|
||||||
@@ -93,7 +108,7 @@ print_core (struct obstack *oout, state *s)
|
|||||||
{
|
{
|
||||||
/* Find the reduction we are handling. */
|
/* Find the reduction we are handling. */
|
||||||
reductions *reds = s->reductions;
|
reductions *reds = s->reductions;
|
||||||
int redno = state_reduction_find (s, r);
|
int redno = state_reduction_find (s, &rules[r]);
|
||||||
|
|
||||||
/* Print them if there are. */
|
/* Print them if there are. */
|
||||||
if (reds->lookahead_tokens && redno != -1)
|
if (reds->lookahead_tokens && redno != -1)
|
||||||
@@ -143,7 +158,7 @@ print_actions (state const *s, FILE *fgraph)
|
|||||||
: "dashed");
|
: "dashed");
|
||||||
|
|
||||||
if (TRANSITION_IS_ERROR (trans, i)
|
if (TRANSITION_IS_ERROR (trans, i)
|
||||||
&& STRNEQ (symbols[sym]->tag, "error"))
|
&& strcmp (symbols[sym]->tag, "error") != 0)
|
||||||
abort ();
|
abort ();
|
||||||
output_edge (s->number, s1->number,
|
output_edge (s->number, s1->number,
|
||||||
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
|
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
|
||||||
@@ -167,7 +182,8 @@ print_state (state *s, FILE *fgraph)
|
|||||||
/* A node's label contains its items. */
|
/* A node's label contains its items. */
|
||||||
obstack_init (&node_obstack);
|
obstack_init (&node_obstack);
|
||||||
print_core (&node_obstack, s);
|
print_core (&node_obstack, s);
|
||||||
output_node (s->number, obstack_finish0 (&node_obstack), fgraph);
|
obstack_1grow (&node_obstack, '\0');
|
||||||
|
output_node (s->number, obstack_finish (&node_obstack), fgraph);
|
||||||
obstack_free (&node_obstack, 0);
|
obstack_free (&node_obstack, 0);
|
||||||
|
|
||||||
/* Output the edges. */
|
/* Output the edges. */
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user