-2012-01-15 Jim Meyering <meyering@redhat.com>
+2012-01-15 Akim Demaille <demaille@gostai.com>
+
+ java: fix reduction traces.
+ * data/lalr1.java (yy_reduce_print): Fix state index.
+ Reported by Tim Landscheidt.
+
+2012-01-12 Jim Meyering <meyering@redhat.com>
+
+ build: avoid warning from coverity about lbitset_elt_find
+ * lib/lbitset.c (lbitset_elt_find): Remove unnecessary test of "elt",
+ at a point where we know it is non-NULL, due to prior dereference.
+
+2012-01-13 Jim Meyering <meyering@redhat.com>
maint: get fdl.texi from gnulib
* bootstrap.conf (gnulib_modules): Add fdl.
* doc/fdl.texi: Remove file.
* doc/.gitignore: Add it here.
-2012-01-15 Jim Meyering <meyering@redhat.com>
-
maint: spell "file system" as two separate words
* doc/Doxyfile.in: Spell it "file system", to avoid a
"make syntax-check" failure.
-2012-01-15 Jim Meyering <meyering@redhat.com>
-
maint: avoid "the the"
* djgpp/README.in: s/the the/the/
* src/parse-gram.c (lloc_default): Likewise.
* src/parse-gram.y (lloc_default): Likewise, and remove a
trailing space.
-2012-01-13 Jim Meyering <meyering@redhat.com>
-
- build: avoid warning from coverity about lbitset_elt_find
- * lib/lbitset.c (lbitset_elt_find): Remove unnecessary test of "elt",
- at a point where we know it is non-NULL, due to prior dereference.
-
2012-01-13 Akim Demaille <akim@lrde.epita.fr>
maint: factor copyright year.
* lib/ebitset.c (ebitset_init): Likewise, for "size".
* lib/lbitset.c (lbitset_not): Likewise, for "elt".
+2011-08-21 Joel E. Denny <joeldenny@joeldenny.org>
+
+ lalr1.cc: remove trailing comma from enumerator list.
+ * data/lalr1.cc (yy::parser): Here. This suppresses a -pedantic
+ warning.
+
2011-08-21 Joel E. Denny <joeldenny@joeldenny.org>
tests: add -pedantic for --enable-gcc-warnings.
* tests/existing.at (GNU Cim Grammar)
(GNU pic (Groff 1.18.1) Grammar.): Remove empty %union.
+2011-07-24 Joel E. Denny <joeldenny@joeldenny.org>
+
+ global: remove unnecessary horizontal tabs.
+ This change was made by applying emacs' untabify function to
+ nearly all files in Bison's repository. Required tabs in make
+ files, ChangeLog, regexps, and test code were manually skipped.
+ Other notable exceptions and changes are listed below.
+ * bootstrap: Skip because we sync this with gnulib.
+ * data/m4sugar/foreach.m4
+ * data/m4sugar/m4sugar.m4: Skip because we sync these with
+ Autoconf.
+ * djgpp: Skip because I don't know how to test djgpp properly, and
+ this code appears to be unmaintained anyway.
+ * README-hacking (Hacking): Specify that tabs should be avoided
+ where not required.
+
2011-07-10 Joel E. Denny <joeldenny@joeldenny.org>
build: avoid YACC typo inherited from Autoconf.
* tests/regression.at (Token number in precedence declaration):
Extend.
-2011-05-01 Joel E. Denny <joeldenny@joeldenny.org>
-
- Prepare for 2.5 release.
- * NEWS (2.5_rc1): Rename back to...
- (2.5): ... this, and unset date.
-
-2011-05-01 Joel E. Denny <joeldenny@joeldenny.org>
-
- Version 2.5_rc1.
- * NEWS (2.5): Rename to...
- (2.5_rc1): ... this, and set date.
-
2011-05-01 Joel E. Denny <joeldenny@joeldenny.org>
Pacify -DGNULIB_POSIXCHECK.
* src/files.c (file_name_split)
* src/getargs.c (getargs)
* src/location.c (boundary_set_from_string)
- * src/output.c (token_definitions_output, output_skeleton)
+ * src/output.c (output_skeleton)
* src/parse-gram.y (prologue_declaration)
* src/scan-gram.l (handle_syncline)
* src/symtab.c (symbol_new): Use mbschr and mbsrchr instead of
* NEWS (2.5): Document fix for -Wno-CATEGORY.
-2008-11-21 Di-an Jan <dianj@freeshell.org>
-
- Implement no-XXX arguments for --warnings, --report, --trace.
- * src/getargs.c (flags_argmatch): Handles no-XXX.
- Fix typo in doxygen comment.
-
2011-03-20 Joel E. Denny <joeldenny@joeldenny.org>
doc: fix confusing citation of LAC publication.
lr.keep-unreachable-states, lr.type, and parse.lac into brief
summaries, and cross-reference the appropriate subsections of
Tuning LR. For parse.lac, mention that it's only implemented for
- deterministic parsers in C.
- (Error Reporting): When mentioning %error-verbose, mention LAC,
+ deterministic parsers in C. In parse.error entry, mention LAC,
and add cross-reference to the LAC section.
+ (Error Reporting): When mentioning parse.error, mention LAC, and
+ add cross-reference to the LAC section.
(Tuning LR): New section with an extended version of the
documentation removed from %define Summary. Change all
cross-references in the manual to point here instead of there.
- (Calc++ Parser): When mentioning %error-verbose, mention LAC, and
- add cross-reference to the LAC section.
- (Table of Symbols): In %error-verbose and YYERROR_VERBOSE entries,
- add cross-references to Error Reporting.
+ (Calc++ Parser): When mentioning parse.error, mention LAC, and add
+ cross-reference to the LAC section.
+ (Table of Symbols): In %error-verbose entry, add cross-reference
+ to Error Reporting.
(Glossary): Capitalize entry titles consistently. Add definitions
for "defaulted state" and "unreachable state". Expand IELR
acronym in IELR's entry.
reversed access to location stack.
* THANKS (Bernd Kiefer): Add.
-2010-05-11 Akim Demaille <demaille@gostai.com>
+2011-02-13 Joel E. Denny <joeldenny@joeldenny.org>
- doc: please Emacs.
- * doc/bison.texinfo (Local Variables): Move this after the
- LocalWords, since the latter are looked for in the whole document,
- while the former are looked for only at its end.
- Require american spell checking.
+ doc: fix some minor inconsistencies.
+ * doc/bison.texinfo (%define Summary): Fix mislabeled entry for
+ lex_symbol.
+ (%code Summary): For consistency with the variable list in the
+ %define Summary, enclose the list of %code qualifiers in a table
+ instead of an itemize.
2011-02-06 Joel E. Denny <joeldenny@joeldenny.org>
is requested.
* tests/conflicts.at (%nonassoc and eof): Extend to check the
effect of each of -Dlr.type=canonical-lr and -Dparse.lac=full.
- (%error-verbose and consistent errors): Likewise.
+ (parse.error=verbose and consistent errors): Likewise.
(LAC: %nonassoc requires splitting canonical LR states): New test
group demonstrating how LAC can fix canonical LR.
* tests/input.at (LAC: Errors for %define): New test group.
* bootstrap.conf (bootstrap_sync): Set to true.
* gnulib: Update to latest so bootstrap is in sync now.
-2010-11-07 Joel E. Denny <joeldenny@joeldenny.org>
-
- yysyntax_error: adjust prior fixes for branch-2.5's lalr1.cc.
- On master, there is no yychar in lalr1.cc, but there is on
- branch-2.5, and the prior cherry-pick of "Fix handling of yychar
- manipulation in user semantic actions" wasn't adjusted for that
- difference.
- * data/lalr1.cc (yy::parser::parse): Translate yychar before
- every use of yytoken, and add comments explaining this approach.
- * tests/conflicts.at (%error-verbose and consistent errors):
- Extend to test yychar manipulation with lalr1.cc.
-
2010-11-07 Joel E. Denny <joeldenny@joeldenny.org>
yysyntax_error: fix for consistent error with lookahead.
* data/glr.c (yyreportSyntaxError): As in yacc.c, don't drop the
unexpected token unless there actually is no lookahead.
* data/lalr1.cc (yy::parser::parse): If there's no lookahead,
- set yytoken to yyempty_ before invoking yysyntax_error_.
+ pass yyempty_ not yyla.type to yysyntax_error_.
(yy::parser::yysyntax_error_): Again, don't drop the unexpected
token unless there actually is no lookahead.
* data/lalr1.java (YYParser::parse): If there's no lookahead,
set yytoken to yyempty_ before invoking yysyntax_error.
(YYParser::yysyntax_error): Again, don't drop the unexpected
token unless there actually is no lookahead.
- * tests/conflicts.at (%error-verbose and consistent
+ * tests/conflicts.at (parse.error=verbose and consistent
errors): Extend test group to further reveal how the previous
use of the simple "syntax error" message was too general. Test
yacc.c, glr.c, lalr1.cc, and lalr1.java. No longer an expected
There are no behavioral changes here.
* data/glr.c (yyreportSyntaxError): Reorganize.
* data/lalr1.cc (yy::parser::yysyntax_error_): Reorganize.
- * tests/conflicts.at (%error-verbose and consistent errors):
+ * tests/conflicts.at (parse.error=verbose and consistent errors):
Reorganize.
2010-11-07 Joel E. Denny <joeldenny@joeldenny.org>
* data/lalr1.java (YYParser::yysyntax_error): Reindent.
* data/yacc.c (yysyntax_error): Reindent.
+2010-10-31 Joel E. Denny <joeldenny@joeldenny.org>
+
+ Fix memory leak.
+ * src/output.c (prepare_rules): Free temporary array.
+
2010-10-31 Joel E. Denny <joeldenny@joeldenny.org>
yysyntax_error: improve invocation readability.
out of storage? If not, we can omit malloc-gnu; but for now I left
it in to be safe.
(vc_ignore): Remove.
+ (gnulib_mk_hook): New function.
* README-hacking: Renamed from HACKING, since gnulib bootstrap now
uses that convention.
+2010-09-09 Paul Hilfinger <hilfinger@cs.berkeley.edu>
+
+ * data/glr.c (yySymbol): Define as int to avoid compiler warnings about
+ possible change of value.
+
+2010-09-08 Paul Hilfinger <hilfinger@cs.berkeley.edu>
+
+ * data/glr.c (yy_reduce_print): Change yyrhsVals to yyvsp to remove
+ compiler errors when using %debug.
+ Add declaration of yylow when locations in use to avoid compilation
+ error.
+ (yyglrReduce): Conditionalize message "Parse ... rejected by rule..."
+ on whether we are in split mode, for consistency with behavior of
+ non-GLR parsing.
+
+2010-09-01 Akim Demaille <demaille@gostai.com>
+
+ Address GCC warnings about shadowed local variables (yyflag).
+ * data/glr.c (YYCHK): Rename yyflag as yychk_flag.
+ (yyprocessOneStack): Reduce the scope of yyaction, yyconflicts,
+ yyrule, and yyflag.
+
2010-08-05 Joel E. Denny <joeldenny@joeldenny.org>
Version 2.4.3.
* po/POTFILES.in: Add remaining gnulib files that have
translatable strings.
+2010-07-25 Joel E. Denny <joeldenny@joeldenny.org>
+
+ build: fix our adjustments for gnulib files in lib.
+ * configure.ac: For prepending lib/ to the values of config
+ variables, fix detection of empty values. Also, due to recent
+ gnulib changes, add LIBUNISTRING_UNITYPES_H and
+ LIBUNISTRING_UNIWIDTH_H to the list of those variables.
+
2010-07-25 Joel E. Denny <joeldenny@joeldenny.org>
maint: use announce-gen's new --mail-headers.
(Output files: -dv >&-): Skip test group if running
maintainer-check-valgrind.
+2010-07-23 Paul Hilfinger <hilfingr@EECS.Berkeley.EDU>
+
+ * NEWS: Describe new semantic-predicate feature.
+ * data/c.m4 (b4_predicate_case): New definition.
+ * data/java.m4 (b4_predicate_case): New definition.
+ * data/glr.c (yyimmediate): Add definition.
+ (yydoAction): Remove comment, now obsolete.
+ Do YY_REDUCE_PRINT here.
+ (yyglrReduce): Alter comment to indicate that semantic values
+ need not be deferred.
+ Remove YY_REDUCE_PRINT from here; done in yydoAction.
+ (yyprocessOneStack): Pass immediate flag.
+ Delete stacks rejected by predicates in newly split-off parsers.
+ Change handling of yyerr so that only current stack gets deleted
+ when semantic predicate fails.
+ (yyfillin): Don't crash if a semantic value is unresolved (as may
+ happen in predicate rules).
+ Copy lr state as well in debugging mode.
+ Update comment on setting of yysval to include yyloc as well.
+ (yy_reduce_print): Add yynormal argument. Perform fillin properly.
+ Report unresolved RHS values.
+ (yyimmediate): New table.
+ * src/gram.h (struct rule): Add is_predicate field.
+ * src/output.c (user_actions_output): Use b4_predicate_case for
+ predicates.
+ (prepare_symbols): Output yyimmediate.
+ * src/scan-gram.l: Add %? token, SC_PREDICATE state.
+ * src/scan-code.l (code_props_rule_action_init): Add is_predicate
+ argument.
+ * src/scan-code.h (struct code_props): Add is_predicate field.
+ (code_props_rule_action_init): New interface.
+ * src/parse-gram.y (%?{...}): New token.
+ (rhs): Add %?{...} rule.
+ * src/parse-gram.c: Regenerate.
+ * src/parse-gram.h: Regenerate.
+ * src/reader.c (grammar_current_rule_action_append): Add
+ immediate argument.
+ (grammar_midrule_action): Use new interface for
+ code_props_rule_action_init.
+ (grammar_current_rule_action_append): Ditto.
+ (packgram): Transfer is_predicate value.
+ * src/reader.h (grammar_current_rule_action_append): New interface.
+ * doc/bison.texinfo: Document semantic predicates (%?).
+
+ * data/glr.c (yylhsNonterm, yyisDefaultedState,yyDefaultAction)
+ (yygetLRActions,yynewGLRStackItem,yyaddDeferredAction,yyinitStateSet)
+ (yyinitGLRStack,yyexpandGLRStack,yyupdateSplit,yymarkStackDeleted)
+ (yyundeleteLastStack,yyglrShift,yyglrShiftDefer,yydoAction,yyglrReduce)
+ (yyidenticalOptions,yymergeOptionSets,yyresolveStates,yyresolveAction)
+ (yyresolveLocations,yyresolveValue,yyreducePrint): Update parameter
+ names in comments and mention all parameters.
+ (struct yyGLRState): Fix description of yyposn field.
+ (yyresolveLocations): Correct comment so as not to imply action when
+ yyn1==0.
+
2010-06-17 Paul Eggert <eggert@cs.ucla.edu>
Update from GFDL GFDL 1.2 to 1.3.
* doc/fdl.texi: Update to version 1.3, taken from:
http://www.gnu.org/licenses/fdl.texi
-2010-06-17 Paul Eggert <eggert@cs.ucla.edu>
-
Do not use date ranges in copyright notices.
See http://www.gnu.org/prep/maintain/maintain.html#Copyright-Notices
* data/README, data/bison.m4, data/c++-skel.m4, data/c++.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/xslt/bison.xsl:
+ * data/lalr1.java, data/local.mk, data/location.cc:
+ * data/stack.hh, data/variant.hh, data/xslt/bison.xsl:
* data/xslt/xml2dot.xsl, data/xslt/xml2text.xsl:
* data/xslt/xml2xhtml.xsl, data/yacc.c, djgpp/Makefile.maint:
* djgpp/README.in, djgpp/config.bat, djgpp/config.sed:
* djgpp/config.site, djgpp/config_h.sed, djgpp/djunpack.bat:
- * djgpp/subpipe.c, djgpp/subpipe.h:
- * djgpp/testsuite.sed, doc/bison.texinfo:
- * doc/refcard.tex, etc/README, etc/bench.pl.in:
+ * djgpp/local.mk, djgpp/subpipe.c, djgpp/subpipe.h:
+ * djgpp/testsuite.sed, doc/bison.texinfo, doc/local.mk:
+ * doc/refcard.tex, etc/README, etc/bench.pl.in, etc/local.mk:
* examples/calc++/Makefile.am, examples/extexi:
- * lib/abitset.c, lib/abitset.h:
+ * examples/local.mk, 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-print.c:
* lib/bitsetv-print.h, lib/bitsetv.c, lib/bitsetv.h:
* lib/ebitset.c, lib/ebitset.h, lib/get-errno.c:
* lib/get-errno.h, lib/lbitset.c, lib/lbitset.h:
- * lib/libiberty.h, lib/main.c, lib/timevar.c:
+ * lib/libiberty.h, lib/local.mk, lib/main.c, lib/timevar.c:
* lib/timevar.def, lib/timevar.h, lib/vbitset.c:
* lib/vbitset.h, lib/yyerror.c, m4/bison-i18n.m4:
* m4/c-working.m4, m4/cxx.m4, m4/subpipe.m4, m4/timevar.m4:
* 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/ielr.c:
- * src/ielr.h, src/lalr.c, src/lalr.h:
+ * src/ielr.h, src/lalr.c, src/lalr.h, src/local.mk:
* 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:
* tests/calc.at, tests/conflicts.at, tests/cxx-type.at:
* tests/existing.at, tests/glr-regression.at:
* tests/headers.at, tests/input.at, tests/java.at:
- * tests/local.at, tests/named-refs.at:
+ * tests/local.at, tests/local.mk, tests/named-refs.at:
* tests/output.at, tests/push.at, tests/reduce.at:
* tests/regression.at, tests/sets.at, tests/skeletons.at:
* tests/synclines.at, tests/testsuite.at, tests/torture.at:
- * data/Makefile.am, data/location.cc, doc/Makefile.am, src/Makefile.am:
- * tests/Makefile.am, lib/Makefile.am, examples/Makefile.am:
- * etc/Makefile.am:
Don't use date ranges in copyright notices.
2010-05-11 Akim Demaille <demaille@gostai.com>
sections.
* NEWS (2.5): Document this.
-2010-05-07 Akim Demaille <demaille@gostai.com>
+2010-05-11 Akim Demaille <demaille@gostai.com>
+
+ doc: please Emacs.
+ * doc/bison.texinfo (Local Variables): Move this after the
+ LocalWords, since the latter are looked for in the whole document,
+ while the former are looked for only at its end.
+ Require american spell checking.
+
+2010-05-10 Akim Demaille <demaille@gostai.com>
+
+ doc: fix lalr1.cc documentation.
+ * doc/bison.texinfo (C++ Scanner Interface): Fix yylex signature.
+ (C++ Bison Interface): Fix lalr1.cc skeleton name.
+ (C++ Parser Interface): Fix semantic_type and location_type names.
+ Document yy::parser::token.
+ Reported by Jerry Quinn.
+
+2010-05-10 Akim Demaille <demaille@gostai.com>
c++: use YYRHSLOC.
* data/lalr1.cc (YYRHSLOC): New.
Check that glr.cc supports user defined location_type.
* NEWS: Document this.
-2010-05-10 Akim Demaille <demaille@gostai.com>
+2010-05-07 Akim Demaille <demaille@gostai.com>
- doc: fix lalr1.cc documentation.
- * doc/bison.texinfo (C++ Scanner Interface): Fix yylex signature.
- (C++ Bison Interface): Fix lalr1.cc skeleton name.
- (C++ Parser Interface): Fix semantic_type and location_type names.
- Document yy::parser::token.
- Reported by Jerry Quinn.
+ doc: fix typo.
+ * tests/synclines.at: here.
+
+2010-05-04 Akim Demaille <demaille@gostai.com>
+
+ tests: enhance AT_SYNCLINES_COMPILE.
+ * tests/synclines.at (AT_SYNCLINES_COMPILE): More distcc patterns.
+ (AT_TEST_SYNCLINE): Remove GCC 4.5 protection which is already
+ taken care of in AT_SYNCLINES_COMPILE.
2010-05-04 Akim Demaille <demaille@gostai.com>
lalr1.cc: don't generate location.hh when location_type is defined
- * data/bison.m4 (b4_percent_define_use): New.
- (b4_percent_define_get): Use it.
- Accept a default value.
+ * data/bison.m4 (b4_percent_define_get): Accept a default value.
* data/c++.m4: Do not provide a default value for the %define
variable location_type, rather, use b4_percent_define_get with a
default argument where its value is needed.
* data/lalr1.cc: Do not load location.cc (which outputs both
location.hh and position.hh) if the user defined location_type.
Do not include location.hh either.
- * data/glr.cc: Likewise.
+
+2010-05-04 Akim Demaille <demaille@gostai.com>
+
+ lalr1.cc: minor refactoring.
+ * data/lalr1.cc: Don't issue empty namespaces.
+
+2010-05-04 Akim Demaille <demaille@gostai.com>
+
+ tests: fix %printer.
+ Currently, there is no check that %printer ... <foo> (nor
+ %destructor) is about an existing <foo> type. This C++ test had
+ it wrong (<::std::string> vs. <std::string>).
+
+ * tests/c++.at (AT_CHECK_VARIANTS): In list.yy, redefine the
+ pretty-printing of lists into something better for parser traces.
+ Update the expected output.
+ Fix correspondance between %type/%token and %printer.
2010-05-04 Akim Demaille <demaille@gostai.com>
* tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Adjust to the
location_type changes.
-2010-05-04 Akim Demaille <demaille@gostai.com>
-
- tests: enhance AT_SYNCLINES_COMPILE.
- * tests/synclines.at (AT_TEST_SYNCLINE): Move GCC 4.5 protection
- into...
- (AT_SYNCLINES_COMPILE): here.
- Add more distcc patterns.
-
2010-05-01 Joel E. Denny <joeldenny@joeldenny.org>
tests: fix maintainer-xml-check.
portability: fix for BSD make.
Reported by Johan van Selst at
<http://lists.gnu.org/archive/html/bug-bison/2010-03/msg00016.html>.
- * tests/Makefile.am ($(TESTSUITE)): Qualify package.m4 in
+ * tests/local.mk ($(TESTSUITE)): Qualify package.m4 in
this dependency list as in package.m4's target rule.
2010-03-23 Joel E. Denny <jdenny@ces.clemson.edu>
<http://lists.gnu.org/archive/html/bug-bison/2010-03/msg00014.html>.
* NEWS (2.4.3): New.
* THANKS (Johan van Selst): Add.
+ * etc/prefix-gnulib-mk (prefix): Adjust regex for makefile
+ targets so that gnulib's new c++defs.h is matched.
* gnulib: Update to latest.
2010-03-20 Joel E. Denny <jdenny@ces.clemson.edu>
* bootstrap.conf (gnulib_modules): Add pipe.
* gnulib: Update to latest to make sure we have all the latest
fixes.
- * lib/Makefile.am (libbison_a_SOURCES): Remove subpipe.h and
+ * lib/local.mk (lib_libbison_a_SOURCES): Remove subpipe.h and
subpipe.c.
* po/POTFILES.in (lib/subpipe.c): Remove.
* src/files.c (compute_output_file_names): Update invocations
* tests/atlocal.in (abs_top_srcdir): Remove shell variable,
which is already defined in atconfig.
+2010-01-22 Joel E. Denny <jdenny@clemson.edu>
+
+ tests: fix missing include caught by g++ 4.4.1.
+ Reported by Tys Lefering.
+ * HACKING (Release checks): Add note about trying a recent GCC.
+ * tests/regression.at (_AT_DATA_DANCER_Y): For C++, include
+ cstdlib for abort.
+ (_AT_DATA_EXPECT2_Y): Likewise.
+
2010-01-21 Joel E. Denny <jdenny@clemson.edu>
* cfg.mk (gnulib_dir): Assume gnulib is a subdirectory.
* HACKING (Release Procedure): Recommend a secure automake.
-2008-12-11 Akim Demaille <demaille@gostai.com>
-
- Propagate i18n changes into glr.c.
- * data/glr.c (yyreportSyntaxError): Use "switch" instead of
- building the error message format dynamically.
- * data/lalr1.java: Formatting changes.
-
-2009-12-22 Joel E. Denny <jdenny@clemson.edu>
-
- Port small part of master's 11707b2b so future ports are easier.
- * data/lalr1.java (YYParser::yysyntax_error): Untabify.
-
-2008-12-11 Akim Demaille <demaille@gostai.com>
-
- Simplify the i18n of the error messages.
- * data/lalr1.cc: Comment changes.
-
-2008-11-11 Akim Demaille <demaille@gostai.com>
-
- Prefer M4 to CPP.
- * data/lalr1.cc: Use b4_error_verbose_if instead of #if
- YYERROR_VERBOSE.
-
-2008-11-11 Akim Demaille <demaille@gostai.com>
-
- Support i18n of the parse error messages.
- * TODO (lalr1.cc/I18n): Remove.
- * data/lalr1.cc (yysyntax_error_): Support the translation of the
- error messages, as done in yacc.c.
- Stay within the yy* pseudo namespace.
-
-2009-12-22 Joel E. Denny <jdenny@clemson.edu>
-
- Port small part of master's 8901f32e so future ports are easier.
- * data/lalr1.cc (yy::parser::yysyntax_error_): Always add second
- argument, but name it in the function definition only when
- verbose error messages are enabled and it'll thus be used.
- (yy::parser::parse): Update use of yysyntax_error_.
-
2009-12-29 Joel E. Denny <jdenny@clemson.edu>
portability: `<' and `>' are not always defined on addresses.
action): New test group checking that translation happens before
lookahead destructor calls at parser return. Previously,
incorrect destructors were called.
- * tests/conflicts.at (%error-verbose and consistent
+ * tests/conflicts.at (parse.error=verbose and consistent
errors): New test group checking that translation happens at
syntax error detection before the associated verbose error
message and the associated lookahead destructor calls. While
documentation.
(LocalWords): Remove YYFAIL.
+2009-12-20 Joel E. Denny <jdenny@clemson.edu>
+
+ tests: cleanup.
+ * tests/c++.at (Syntax error discarding no lookahead): Don't
+ ignore stderr. Instead, eliminate remaining warnings.
+
+2009-12-18 Joel E. Denny <jdenny@clemson.edu>
+
+ lalr1.cc: don't discard non-existent lookahead on syntax error.
+ * data/lalr1.cc (yy::parser::parse): Check yyempty first.
+ * tests/c++.at (Syntax error discarding no lookahead): New test
+ group.
+
2009-12-17 Joel E. Denny <jdenny@clemson.edu>
Code cleanup.
* tests/atlocal.in (LIBS): As for LDADD in src/local.mk, add
lib/libbison.a so gnulib libraries can be linked.
+2009-12-15 Joel E. Denny <jdenny@clemson.edu>
+
+ gnulib: update for fix of fprintf-posix, which we'll use soon.
+ * etc/prefix-gnulib-mk (prefix): Adjust regex for make file
+ targets so that gnulib's new arg-nonnull.h and link-warning.h
+ are matched.
+ * gnulib: Update.
+
2009-12-14 Joel E. Denny <jdenny@clemson.edu>
Enable assertion output and --disable-assert for configure.
* data/bison.m4: Update comments for rename to muscle-tab.h.
-2009-10-08 Joel E. Denny <jdenny@clemson.edu>
-
- Rename muscle_tab.* to muscle-tab.* for consistency with master.
- * src/Makefile.am (bison_SOURCES): Update.
- * src/getargs.c, src/ielr.c, src/lalr.c, src/main.c,
- src/output.c, src/parse-gram.y, src/print.c, src/reader.c,
- src/tables.c: Update include.
- * src/muscle_tab.c, src/muscle_tab.h: Rename to...
- * src/muscle-tab.c, src/muscle-tab.h: ... these and update
- include.
-
2009-10-07 Joel E. Denny <jdenny@clemson.edu>
Minor code cleanup.
- * src/muscle_tab.c (MUSCLE_USER_NAME_CONVERT): Remove macro and
+ * src/muscle-tab.c (MUSCLE_USER_NAME_CONVERT): Remove macro and
replace all uses with UNIQSTR_CONCAT.
* src/uniqstr.c (uniqstr_vsprintf): New function.
* src/uniqstr.h (uniqstr_vsprintf): Add prototype.
(UNIQSTR_CONCAT, UNIQSTR_GEN_FORMAT, UNIQSTR_GEN_FORMAT_): New
macros.
+2009-10-06 Joel E. Denny <jdenny@clemson.edu>
+
+ * TODO (Complaint submessage indentation): New.
+
2009-10-04 Joel E. Denny <jdenny@clemson.edu>
Minor code cleanup.
message buffer, import and clean up memory management code
from...
(yyparse, yypush_parse): ... here.
- * tests/regression.at (%error-verbose overflow): No longer an
- expected failure.
+ * tests/regression.at (parse.error=verbose overflow): No longer
+ an expected failure.
2009-09-23 Joel E. Denny <jdenny@clemson.edu>
yysyntax_error: test memory management more.
* tests/atlocal.in (NO_WERROR_CFLAGS): New cpp macro.
- * tests/regression.at (%error-verbose and YYSTACK_USE_ALLOCA):
- New test group.
- (%error-verbose overflow): New test group that reveals an
+ * tests/regression.at (parse.error=verbose and
+ YYSTACK_USE_ALLOCA): New test group.
+ (parse.error=verbose overflow): New test group that reveals an
obscure bug. Expected fail for now.
-2008-12-11 Akim Demaille <demaille@gostai.com>
-
- Pass the token type to yysyntax_error.
- * data/yacc.c (yysyntax_error): Take the transated token instead
- of the raw number.
- Adjust callers.
-
-2008-12-11 Akim Demaille <demaille@gostai.com>
+2009-10-04 Joel E. Denny <jdenny@clemson.edu>
- Simplify the i18n of the error messages.
- * data/yacc.c (yysyntax_error): Rewrite, using a switch instead
- of building dynamically the format string.
+ benchmarks: use %debug consistently among grammars.
+ * etc/bench.pl.in (generate_grammar_triangular): Do not activate
+ %debug by default. It can affect the timings even if yydebug=0.
+ (generate_grammar_calc): For consistency with other grammars,
+ use YYDEBUG environment variable to set yydebug.
2009-10-03 Joel E. Denny <jdenny@clemson.edu>
* tests/regression.at (parse-gram.y: LALR = IELR): New test
group.
-2009-09-16 Akim Demaille <demaille@gostai.com>
-
- doc: comment changes.
- * doc/bison.texinfo: Comment changes.
-
-2009-09-16 Akim Demaille <demaille@gostai.com>
-
- doc: spell checking.
- * doc/bison.texinfo: here.
-
2009-09-19 Alex Rozenman <rozenman@gmail.com>
Keep sub-messages aligned. Fix strings for translation.
* tests/named-ref.at: Adjust test-cases.
* NEWS (2.5): Add an announcement about named references.
+2009-09-17 Akim Demaille <demaille@gostai.com>
+
+ doc: fixes.
+ * doc/bison.texinfo: here.
+ Reported by Alex Rozenman.
+
+2009-09-16 Akim Demaille <demaille@gostai.com>
+
+ doc: lalr1.cc and variants.
+ * doc/bison.texinfo (Decl Summary): Document the "lex_symbol" and
+ "variant" %define variables.
+ (C++ Semantic Values): Split into...
+ (C++ Unions, C++ Variants): these.
+ The latter is new.
+ (C++ Parser Interface): Fix type names.
+ Document parser::syntax_error.
+ Document the fact that locations are not mandatory.
+ (C++ Scanner Interface): Split into...
+ (Split Symbols, Complete Symbols): these.
+ The later is new.
+ (Calc++ Parsing Driver): Use variants.
+ Add more comments.
+ Adjust style.
+ (Calc++ Parser): Declare all the tokens, no
+ longer accept raw characters.
+ Remove %union.
+ Adjust types and printers.
+ Remove destructors.
+ (Calc++ Scanner): Use make_<SYMBOL> functions.
+ Use strerror in error message.
+
+2009-09-16 Akim Demaille <demaille@gostai.com>
+
+ doc: spell checking.
+ * doc/bison.texinfo: here.
+
+2009-09-16 Akim Demaille <demaille@gostai.com>
+
+ doc: comment changes.
+ * doc/bison.texinfo: Comment changes.
+
+2009-09-16 Akim Demaille <demaille@gostai.com>
+
+ lalr1.cc: factor the yytranslate_ invocation in make_SYMBOLS.
+ * data/c++.m4, data/lalr1.cc (parser::symbol_type): Change the
+ constructor to take a token_type instead of the (internal) symbol
+ number.
+ Call yytranslate_.
+ * data/variant.hh (b4_symbol_constructor_define_): Therefore,
+ don't call yytranslate_ here.
+
+2009-09-16 Akim Demaille <demaille@gostai.com>
+
+ TODO: statistics.
+ * TODO (Figures): New.
+
2009-09-13 Joel E. Denny <jdenny@clemson.edu>
tests: clean up push.at test group titles.
comment, instead of saying "yyparse or yypush_parse", say either
"yyparse" or "yypush_parse" depending on which it actually is.
-2009-09-03 Joel E. Denny <jdenny@clemson.edu>
+2009-09-10 Joel E. Denny <jdenny@clemson.edu>
- Complain about unused %define variables and %code qualifiers.
- * NEWS (2.5): Document.
- * data/bison.m4 (b4_check_user_names): Complain instead of warn.
- * doc/bison.texinfo (Decl Summary): Document complaint, and
- improve %define documentation a little otherwise.
- * tests/input.at (Reject unused %code qualifiers): Update.
- (%define errors): Update.
- (%define, --define, --force-define): Update.
- (%define backward compatibility): Update.
- (Unused %define api.pure): Update.
- * tests/push.at (Push Parsing: Unsupported Skeletons): Update.
+ Fix --enable-gcc-warnings.
+ * src/parse-gram.y (%printer <param>): Handle param_none.
+
+2009-09-09 Akim Demaille <demaille@gostai.com>
+
+ lalr1.cc: syntax_error as exceptions.
+ It is common to use sort of factories in the user actions. These
+ factories may check some "syntactic" constraints that are not
+ enforced by the grammar itself. This is possible using YYERROR
+ within the action itself. Provide the user with a means to throw
+ a syntax_error exception.
+
+ * data/c++.m4 (b4_public_types_declare, b4_public_types_define):
+ Declare and define yy::parser::syntax_error.
+ * data/lalr1.cc: Include stdexcept.
+ (yy::parser::parse): Wrap the user action within a try/catch.
+ * data/glr.cc: Include stdexcept.
+
+2009-09-09 Akim Demaille <demaille@gostai.com>
+
+ lalr1.cc: add missing "inline".
+ * data/c++.m4 (b4_public_types_define): Add missing inline to
+ implementations provided in headers.
+
+2009-09-09 Akim Demaille <demaille@gostai.com>
+
+ %param: documentation.
+ * NEWS (2.6): Document %param, %lex-param, and %parse-param
+ changes.
+ * doc/bison.texinfo: Document that %lex-param and %parse-param
+ are n-ary.
+ Changes some examples to demonstrate it.
+ (Calc++ Parser): Use %param.
+
+2009-09-09 Akim Demaille <demaille@gostai.com>
+
+ Regen.
+
+2009-09-09 Akim Demaille <demaille@gostai.com>
+
+ style changes.
+ * src/parse-gram.y (add_param): Scope changes.
+
+2009-09-09 Akim Demaille <demaille@gostai.com>
+
+ %parse: support several arguments.
+ * src/parse-gram.y (current_param): New.
+ (param_type): Add param_none.
+ (params): New nonterminal.
+ Use it.
+
+2009-09-09 Akim Demaille <demaille@gostai.com>
+
+ Regen.
+
+2009-09-09 Akim Demaille <demaille@gostai.com>
+
+ %param.
+ Provide a means to factor lex-param and parse-param common
+ declarations.
+
+ * src/parse-gram.y (param_type): New.
+ Define a %printer for it.
+ (add_param): Use it.
+ (%parse-param, %lex-param): Merge into...
+ (%parse): this new token.
+ Adjust the grammar to use it.
+ * src/scan-gram.l (RETURN_VALUE): New.
+ (RETURN_PERCENT_FLAG): Use it.
+ (RETURN_PERCENT_PARAM): New.
+ Use it to support %parse-param, %lex-param and %param.
2009-09-03 Joel E. Denny <jdenny@clemson.edu>
rename variable "exact_mode" to "explicit_bracketing".
* tests/named-ref.at: Adjust existing tests and add a new one.
+2009-09-04 Akim Demaille <demaille@gostai.com>
+
+ Adjust synclines in src/parse-gram.[ch].
+ * tests/bison.in: Do some magic (including working around issues
+ with ylwrap) when this wrapper is used to compile
+ src/parse-gram.y.
+
+2009-09-03 Joel E. Denny <jdenny@clemson.edu>
+
+ Complain about unused %define variables and %code qualifiers.
+ * NEWS (2.5): Document.
+ * data/bison.m4 (b4_check_user_names): Complain instead of warn.
+ * doc/bison.texinfo (Decl Summary): Document complaint, and
+ improve %define documentation a little otherwise.
+ * tests/input.at (Reject unused %code qualifiers): Update.
+ (%define errors): Update.
+ (%define, --define, --force-define): Update.
+ (%define backward compatibility): Update.
+ (Unused %define api.pure): Update.
+ * tests/push.at (Push Parsing: Unsupported Skeletons): Update.
+
+2009-09-03 Joel E. Denny <jdenny@clemson.edu>
+
+ Don't suppress warnings about unused parse.error.
+ * data/bison.m4 (b4_error_verbose_flag): Don't examine value of
+ %define variable parse.error unless b4_error_verbose_flag is
+ actually expanded in a skeleton.
+
2009-09-03 Akim Demaille <demaille@gostai.com>
* NEWS (2.4.2): Add "Internationalization" item.
(Table of Symbols): Likewise.
* src/ielr.c (LrType): Update documentation.
* src/parse-gram.y (content.opt): Add production for ID.
- * tests/calc.at: Remove quotes in most tests.
+ * tests/actions.at: Remove quotes in most tests.
+ * tests/calc.at: Likewise.
* tests/existing.at: Likewise.
* tests/input.at: Likewise.
* tests/local.at: Likewise.
2009-08-26 Joel E. Denny <jdenny@clemson.edu>
Actually handle the yytable zero value correctly this time.
- * data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Don't
- mention zero values in the YYTABLE comments.
+ * data/bison.m4 (b4_integral_parser_tables_map): Don't mention
+ zero values in the YYTABLE comments.
* data/glr.c (yytable_value_is_error): Don't check for zero
value.
* data/lalr1.cc (yy_table_value_is_error_): Likewise.
2009-08-25 Joel E. Denny <jdenny@clemson.edu>
More fixes related to last two patches.
+ * data/bison.m4 (b4_integral_parser_tables_map): Fix YYTABLE
+ comments: zero indicates syntax error not default action.
* data/c.m4 (b4_table_value_equals): Comment that YYID must be
defined.
- * data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Fix
- yytable comments: zero indicates syntax error not default
- action.
* data/glr.c (yyis_pact_ninf): Rename to...
(yypact_value_is_default): ... this.
(yyisDefaultedState): Update for rename.
2009-08-19 Akim Demaille <demaille@gostai.com>
- doc: %initial-action to initialize yylloc.
+ tests: distcc compliance.
+ * tests/synclines.at (AT_SYNCLINES_COMPILE): Discard distcc's
+ error messages from the output.
+
+2009-08-19 Akim Demaille <demaille@gostai.com>
+
+ variables: simplify the upgrade of namespace into api.namespace.
+
+ This patch simplifies "variables: rename namespace as
+ api.namespace", commit 67501061076ba46355cfd9f9361c7eed861b389c.
+ Suggested by Joel E. Denny in
+ http://lists.gnu.org/archive/html/bison-patches/2009-07/msg00006.html
+
+ * src/muscle-tab.c (muscle_percent_variable_update): New.
+ (muscle_percent_define_insert): Use it in replacement of the
+ previous tr invocation.
+ Remove variable_tr, no longer needed.
+ * data/bison.m4 (b4_percent_define_copy_, b4_percent_define_copy):
+ Remove.
+ * data/c++.m4: No longer handle namespace -> api.namespace.
+ * tests/input.at (%define backward compatibility): Check that
+ namespace is treated as api.namespace.
+
+2009-08-19 Akim Demaille <demaille@gostai.com>
+
+ doc: %initial-action to initialize yylloc.
Reported by Bill Allombert.
* doc/bison.texinfo: Set fill-column to 76.
(Location Type): Document the use of %initial-action to initialize
yylloc.
+2009-08-19 Akim Demaille <demaille@gostai.com>
+
+ lalr1.cc: use state_type.
+ * data/lalr1.cc (yysyntax_error_): Use state_type.
+ Move argument names into yy*.
+
+2009-08-19 Akim Demaille <demaille@gostai.com>
+
+ lalr1.cc: get rid of yyparse's yystate.
+ yystate and yystack_[0].state are equal, keep only the latter.
+ The former was also used as a temporary variable to compute the
+ post-reduction state. Move this computation into an auxiliary
+ function.
+
+ * data/glr.c (yyLRgotoState): Fuse variable definition and first
+ assignment.
+ * data/lalr1.cc (yy_lr_goto_state_): New.
+ (yyparse): Use it.
+ Replace remaining uses of yystate by yystate_[0].state.
+ Remove the former.
+
+2009-08-19 Akim Demaille <demaille@gostai.com>
+
+ lalr1.cc: destroy $$ when YYERROR is called.
+ * data/lalr1.cc (yyreduce): Compute the resulting state before
+ running the user action so that yylhs is a valid symbol.
+ (yyerrorlab): Since yylhs is complete (it knows its type), we can
+ simply call yy_destroy_ to destroy $$ on YYERROR invocations.
+ * tests/c++.at (AT_CHECK_VARIANTS): Test YYERROR with variants.
+
2009-08-18 Joel E. Denny <jdenny@clemson.edu>
maint: update for gnulib's recent update-copyright changes
* tests/input.at (Numbered tokens): Recombine tests now that the
output should be deterministic across multiple numbers.
+2009-08-12 Akim Demaille <demaille@gostai.com>
+
+ tests: GCC 4.5 compliance.
+ * tests/synclines.at (AT_SYNCLINES_COMPILE): Adjust to GCC 4.5's
+ messages about #error.
+
+2009-08-12 Akim Demaille <demaille@gostai.com>
+
+ build: fix the generation of the documentation.
+ Some of our targets use "bison --help", but they can't depend on
+ "bison" itself (to avoid additional requirements on the user), so
+ they used to call "make src/bison" in the commands. Then
+ concurrent builds may fail: 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.
+
+ This might also be a more convincing explanation for the failure
+ described in the patch "build: fix paths".
+
+ * Makefile.am (SUFFIXES): Initialize.
+ * build-aux/move-if-change: New, symlink to gnulib's.
+ * build-aux/local.mk: Ship it.
+ * doc/common.x: Remove, merged into...
+ * doc/bison.x: here.
+ * doc/local.mk (doc/bison.help): New.
+ ($(CROSS_OPTIONS_TEXI)): Depend on it.
+ Use src/bison.
+ (.x.1): Replace with...
+ (doc/bison.1): this explicit, simpler, target.
+ (common_dep): Remove, inlined where appropriate.
+ (SUFFIXES, PREPATH): Remove, unused.
+
+2009-08-12 Akim Demaille <demaille@gostai.com>
+
+ gnulib: improve prefixing.
+ * configure.ac (gl_PREFIXED_LIBOBJS): Don't rename it, rather,
+ change the value of...
+ (gl_LIBOBJS): this.
+ Adjust more variables.
+ * etc/prefix-gnulib-mk (prefix_assignment): Don't rename
+ gl_LIBOBJS.
+ (prefix): Also transform rules whose targets have slashes.
+ Use $prefix liberally.
+ Map @MKDIR_P@ to $(MKDIR_P).
+ Prefix directories that are mkdir'd.
+
+2009-08-12 Akim Demaille <demaille@gostai.com>
+
+ build: fix paths.
+ When using $(top_builddir) inconsistently, Make (including GNU
+ Make) is sometimes confused. As a result it may want to build
+ lib/libbison.la and $(top_builddir)/lib/libbison.la (the same
+ file, different names) concurrently, which, amusingly enough,
+ might end with:
+
+ ranlib lib/libbison.a
+ ranlib lib/libbison.a
+ make[2]: *** [lib/libbison.a] Segmentation fault
+
+ on OS X.
+
+ * doc/local.mk, src/local.mk: Do not use $(top_builddir) when not
+ needed.
+
2009-08-12 Akim Demaille <demaille@gostai.com>
distcheck: fix.
2009-08-10 Joel E. Denny <jdenny@clemson.edu>
- * tests/Makefile.am (TESTSUITE_AT): Add named-refs.at.
+ * tests/local.mk (TESTSUITE_AT): Add named-refs.at.
2009-08-10 Joel E. Denny <jdenny@clemson.edu>
maint: automate b4_copyright updates.
* Makefile.am (update-b4-copyright): New target rule.
- * build-aux/Makefile.am (EXTRA_DIST): Add update-b4-copyright.
+ * build-aux/local.mk (EXTRA_DIST): Add update-b4-copyright.
* build-aux/update-b4-copyright: New.
* data/yacc.c: Remove stray characters around b4_copyright
invocations.
* src/scan-gram.l (SC_ESCAPED_CHARACTER): Actually use length
variable.
-2009-07-24 Alex Rozenman <rozenman@gmail.com>
-
- Fix some memory leaks.
- * src/named-ref.c: Add a pointer check (named_ref_free).
- * src/scan-code.l: New function (variant_table_free). Called in
- code_scanner_free.
- * src/symlist.c: Call to named_ref_free (symbol_list_free).
-
2009-07-24 Joel E. Denny <jdenny@ces.clemson.edu>
Warn about character literals not of length one.
(SC_ESCAPED_CHARACTER): Warn if length is wrong.
* tests/input.at (Bad character literals): New test group.
+2009-07-24 Alex Rozenman <rozenman@gmail.com>
+
+ Fix some memory leaks.
+ * src/named-ref.c: Add a pointer check (named_ref_free).
+ * src/scan-code.l: New function (variant_table_free). Called in
+ code_scanner_free.
+ * src/symlist.c: Call to named_ref_free (symbol_list_free).
+
2009-07-24 Joel E. Denny <jdenny@ces.clemson.edu>
* src/lalr.c (state_lookahead_tokens_count): Correct comment.
do not distinguish between a missing value and an empty string
value.
-2009-07-21 Joel E. Denny <jdenny@ces.clemson.edu>
-
- * m4/m4.m4: Make it a sym link to submodules/autoconf/m4/m4.m4.
-
2009-07-15 Joel E. Denny <jdenny@ces.clemson.edu>
Revert unnecessary column realignment in --help output.
2009-07-04 Alex Rozenman <rozenman@gmail.com>
- Alphabetical order in src/Makefile.am.
- * src/Makefile.am: Adjust.
+ Alphabetical order in src/local.mk.
+ * src/local.mk: Adjust.
2009-07-04 Alex Rozenman <rozenman@gmail.com>
Not only this is inefficient, this also builds incorrect sources
with several extractions mixed together.
+2009-06-29 Akim Demaille <demaille@gostai.com>
+
+ parse.error: fix.
+ * data/bison.m4: Move code related to specific variables after the
+ definition of the variable-maintaining macros so that we don't
+ "invoke" b4_percent_define_check_values before it is defined.
+
+2009-06-29 Akim Demaille <demaille@gostai.com>
+
+ variables: parse.error
+
+ Implement, document, and test the replacement of %error-verbose
+ by %define parse.error "verbose".
+ * data/bison.m4 (b4_error_verbose_if): Reimplement to track the
+ values of the parse.error variable.
+ Make "simple" its default value.
+ Check the valid values.
+ * src/parse-gram.y: Use %define parse.error.
+ (PERCENT_ERROR_VERBOSE): New token.
+ Support it.
+ * src/scan-gram.l: Support %error-verbose.
+
+ * doc/bison.texinfo (Decl Summary): Replace the documentation of
+ %define error-verbose by that of %define parse.error.
+ * NEWS: Document it.
+
+ * tests/actions.at, tests/calc.at: Use parse.error instead of
+ %error-verbose.
+
2009-06-27 Alex Rozenman <rozenman@gmail.com>
Implement support for named symbol references.
hash: check insertion for memory exhaustion.
* src/uniqstr.c (uniqstr_new): New.
+2009-06-24 Akim Demaille <demaille@gostai.com>
+
+ variables: rename namespace as api.namespace.
+ Discussed in
+ http://lists.gnu.org/archive/html/bison-patches/2009-04/msg00033.html
+
+ * data/bison.m4 (b4_percent_define_copy_, b4_percent_define_copy):
+ New.
+ (b4_percent_define_use): New.
+ Use it where applicable.
+ * data/c++.m4: Replace uses of the variable "namespace" by
+ "api.namespace".
+ Default the latter to the former.
+ * doc/bison.texinfo (Decl Summary): Document "namespace" as
+ obsolete.
+ Document api.namespace.
+ Use @samp to document %define uses, keep @code for identifiers.
+ * NEWS: Likewise.
+ * tests/c++.at, tests/input.at: Test api.namespace instead of
+ namespace. (The tests passed with namespace.)
+
2009-06-11 Akim Demaille <demaille@gostai.com>
style changes.
* src/state.c (state_hash_insert): Check the return value of
hash_insert.
+2009-06-11 Akim Demaille <demaille@gostai.com>
+
+ tests: honor TESTSUITEFLAGS in every check target.
+ * tests/local.mk (RUN_TESTSUITE): New.
+ (check-local, installcheck-local, maintainer-check-g++)
+ (maintainer-check-posix, maintainer-check-valgrind): Use it.
+
2009-06-10 Akim Demaille <demaille@gostai.com>
deterministic test suite.
Use different file names for the three tests to make the
maintenance easier.
+2009-06-10 Akim Demaille <demaille@gostai.com>
+
+ gnulib: update.
+ * gnulib: Update to latest.
+ * lib/.cvsignore, lib/.gitignore, m4/.cvsignore,
+ * m4/.gitignore: Regen.
+ * src/symtab.c (symbol_from_uniqstr, semantic_type_from_uniqstr):
+ Call xalloc_die on hash_insert failures.
+ Requested by the new __warn_unused_result__ attribute of
+ hash_insert.
+
2009-06-10 Akim Demaille <demaille@gostai.com>
deterministic user-token-number redeclaration errors.
2009-05-25 Akim Demaille <demaille@gostai.com>
- gnulib: update.
- * gnulib: Update to latest.
- * lib/.cvsignore, lib/.gitignore, m4/.cvsignore,
- * m4/.gitignore: Regen.
- * src/symtab.c (symbol_from_uniqstr, semantic_type_from_uniqstr):
- Call xalloc_die on hash_insert failures.
- Requested by the new __warn_unused_result__ attribute of
- hash_insert.
+ build: avoid ignored errors.
+ * doc/local.mk ($(CROSS_OPTIONS_TEXI)): Don't generate ignored
+ errors, they pollute the output.
2009-05-22 Joel E. Denny <jdenny@ces.clemson.edu>
* NEWS (2.5): Add a new entry for that change.
* doc/bison.texinfo (Decl Summary): Update %define entry.
(Bison Options): Update -D/--define/-F/--force-define entry.
- * src/muscle_tab.c (muscle_percent_define_insert): Implement.
- * src/muscle_tab.h (muscle_percent_define_insert): Update
+ * src/muscle-tab.c (muscle_percent_define_insert): Implement.
+ * src/muscle-tab.h (muscle_percent_define_insert): Update
comments.
* tests/input.at (`%define errors'): Update.
(`%define, --define, --force-define'): Update.
* src/getargs.c (usage): Document -F/--force-define. Realign
options in output.
(short_options, long_options, getargs): Parse -F/--force-define,
- and update muscle_percent_define_insert invocation.
- * src/muscle_tab.h (muscle_percent_define_how): New enum type.
+ and update muscle_percent_define_insert invocations.
+ * src/muscle-tab.h (muscle_percent_define_how): New enum type.
(muscle_percent_define_insert): Add argument with that type.
- * src/muscle_tab.c (muscle_percent_define_insert): Implement
+ * src/muscle-tab.c (muscle_percent_define_insert): Implement
-F/--force-define behavior and priorities.
+ (muscle_percent_define_ensure): Update
+ muscle_percent_define_insert invocation.
* src/parse-gram.y (prologue_declaration): Update
muscle_percent_define_insert invocations.
* tests/input.at (`%define, --define'): Rename to...
Update some comments to make sense for -D.
* data/bison.m4 (b4_check_user_names): In header comments, say
"user occurrence" instead of "grammar occurrence".
- * src/muscle_tab.h (muscle_percent_define_insert): Likewise.
+ * src/muscle-tab.h (muscle_percent_define_insert): Likewise.
(muscle_percent_code_grow): Likewise just for consistency.
-2009-05-22 Joel E. Denny <jdenny@ces.clemson.edu>
-
- * data/c++.m4: Update copyright year.
-
2009-05-20 Joel E. Denny <jdenny@ces.clemson.edu>
* data/c++.m4 (b4_namespace_close): Simplify slightly.
* src/getargs.c (skeleton_arg): Remove now useless variable.
Should help the compiler see that this printf-like call is sane.
+2009-05-15 Akim Demaille <demaille@gostai.com>
+
+ Rename token.prefix as api.tokens.prefix.
+ Discussed here.
+ http://lists.gnu.org/archive/html/bison-patches/2009-05/msg00024.html.
+
+ * NEWS, data/bison.m4, data/c.m4, data/java.m4, doc/bison.texinfo,
+ * tests/c++.at, tests/calc.at, tests/java.at, tests/local.at
+ (token.prefix): Rename as...
+ (api.tokens.prefix): this.
+
2009-05-11 Akim Demaille <demaille@gostai.com>
doc: use C++ headers.
* doc/bison.texinfo (Calc++ Scanner): Prefer C++ headers to C
headers.
-2009-05-05 Akim Demaille <demaille@gostai.com>
-
- fix hexadecimal token number support.
- * src/scan-gram.l: Catch incorrect ids after hexadecimal numbers.
-
-2009-05-05 Akim Demaille <demaille@gostai.com>
+2009-05-11 Akim Demaille <demaille@gostai.com>
- tests: check token numbers.
- * tests/input.at (Numbered tokens): New.
+ doc: token.prefix
+ * doc/bison.simple (Decl Summary): Document token.prefix.
+ (Calc++ Parser): Various fixes.
+ Formatting changes.
+ Use token.prefix.
+ Introduce a macro TOKEN to shorten the code and make it more
+ readable.
+ (Calc++ Scanner): Adjust.
+ * NEWS (Variable token.prefix): New.
2009-05-04 Akim Demaille <demaille@gostai.com>
* src/scan-gram.l({int}{id}): Report as an invalid identifier.
* tests/input.at: Adjust.
-2009-05-04 Akim Demaille <demaille@gostai.com>
-
- space changes.
- * src/scan-gram.l: Untabify to be robust to zealous editors.
-
2009-05-04 Akim Demaille <demaille@gostai.com>
identifiers: dashes are letters.
* data/c.m4 (b4_identification): Update comment.
* data/yacc.c: Update access.
* doc/bison.texinfo: Update.
- * etc/bench.pl.in (bench_grammar): Update use.
+ * etc/bench.pl.in (bench_push_parser): Update use.
* src/files.c (tr): Move to...
* src/getargs.c, src/getargs.h (tr): ... here because I can't
think of a better place to expose it. My logic is that, for all
Pacify ./configure --enable-gcc-warnings.
* tests/input.at (Symbols): Prototype yyerror and yylex.
-2009-04-21 Akim Demaille <demaille@gostai.com>
-
- tests: check the use of dashes and periods in symbols.
- * tests/input.at (Symbol): New test group.
-
2009-04-29 Joel E. Denny <jdenny@ces.clemson.edu>
Document how `%define "var" "value"' is not M4-friendly.
* src/parse-gram.y (variable): In comments here.
-2009-04-29 Joel E. Denny <jdenny@ces.clemson.edu>
-
- Add copyright updates missed during previous cherry pick.
- * src/output.c: Here.
- * src/parse-gram.y: Here.
- * src/scan-gram.l: Here.
-
-2009-04-20 Akim Demaille <demaille@gostai.com>
-
- variables: accept dashes.
- * src/scan-gram.l ({id}): Also accept dashes after the initial
- letter.
- ({directive}): Use {id}.
- * src/parse-gram.y: Comment and formatting changes.
- * doc/bison.texinfo (Symbols): Adjust the lexical definitions of
- symbols.
- * src/complain.h, src/complain.c (yacc_at): New.
- * src/symtab.c (symbol_new): Use yacc_at to report inappropriate
- symbol names.
- * src/output.c (token_definitions_output): Do not #define token
- names with dashes.
-
2009-04-24 Joel E. Denny <jdenny@ces.clemson.edu>
Clean up recent patches a little.
Suggested by Akim Demaille at
<http://lists.gnu.org/archive/html/bison-patches/2009-04/msg00082.html>.
* data/bison.m4 (_b4_percent_define_check_values): Implement.
- * src/muscle_tab.c (muscle_percent_define_check_values): Implement.
+ * src/muscle-tab.c (muscle_percent_define_check_values): Implement.
* tests/input.at (%define lr.default_reductions invalid values): Merge
into...
(%define enum variables): ... here, and update output.
comments, and renaming %define lr.default_rules to %define
lr.default_reductions.
* NEWS (2.5): Update IELR documentation.
- * data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c:
- Adjust YYDEFACT and yydefact_ documentation.
+ * data/bison.m4 (b4_integral_parser_tables_map): Adjust YYDEFACT
+ documentation.
+ * data/glr.c, data/lalr1.java: Sync copyright dates.
* doc/bison.texinfo (Decl Summary): Adjust lr.default_reductions
and lr.type documentation. Make some other wording
improvements.
* tests/reduce.at (AT_TEST_LR_DEFAULT_RULES): Rename to...
(AT_TEST_LR_DEFAULT_REDUCTIONS): ... this, and update.
+2009-04-21 Akim Demaille <demaille@gostai.com>
+
+ tests: check the use of dashes and periods in symbols.
+ * tests/input.at (Symbol): New test group.
+
2009-04-21 Joel E. Denny <jdenny@ces.clemson.edu>
Document %define lr.type and lr.default_rules.
(`%define lr.default_rules "consistent"'): Likewise.
(`%define lr.default_rules "accepting"'): Likewise.
+2009-04-20 Akim Demaille <demaille@gostai.com>
+
+ Formatting change.
+
+2009-04-20 Akim Demaille <demaille@gostai.com>
+
+ bison: factoring.
+ * src/output.c (token_definitions_output): Use symbol_id_get
+ instead of duplicating its logic.
+ * TODO (YYERRCODE): Extend.
+
+2009-04-20 Akim Demaille <demaille@gostai.com>
+
+ variables: prefer error-verbose to error_verbose.
+ * data/bison.m4 (b4_error_verbose_if): Based on error-verbose
+ instead of error_verbose.
+ * src/scan-gram.l (%error-verbose): Map to the error-verbose
+ variable.
+ * doc/bison.texinfo: Promote %define error-verbose instead of
+ %error-verbose.
+ * tests/actions.at: Prefer %define error-verbose to %error-verbose.
+
+2009-04-15 Akim Demaille <demaille@gostai.com>
+
+ variables: accept dashes.
+ * data/bison.m4 (b4_percent_define_if_define_): Also map dashes to
+ underscores.
+ * src/scan-gram.l ({id}): Also accept dashes after the initial
+ letter.
+ ({directive}): Use {id}.
+ * src/parse-gram.y: Comment and formatting changes.
+ * doc/bison.texinfo (Symbols): Adjust the lexical definitions of
+ symbols.
+ * src/complain.h, src/complain.c (yacc_at): New.
+ * src/symtab.c (symbol_new): Use yacc_at to report inappropriate
+ symbol names.
+ * src/output.c (token_definitions_output): Do not #define token
+ names with dashes.
+
2009-04-20 Akim Demaille <demaille@gostai.com>
Consistently refer to Yacc, not YACC.
Document semicolon warnings.
* NEWS (2.5): Here.
-2008-12-08 Akim Demaille <demaille@gostai.com>
+2009-04-14 Akim Demaille <demaille@gostai.com>
- Fix portability issue in the test suite.
- * tests/local.at (AT_MATCHES_CHECK): New.
- Based on Perl instead of Sed. Sed has too many portability
- pitfalls, not ever Sed is GNU Sed.
- * tests/actions.at (Fix user actions without a trailing semicolon):
- Use it.
+ variables: use `parse.assert' instead of `assert'.
+ * TODO (assert): Remove.
+ * data/bison.m4 (b4_assert_if): Replace with...
+ (b4_parse_assert_if): this.
+ * data/lalr1.cc, data/variant.hh, tests/c++.at: Adjust.
+ * doc/bison.texinfo (Decl Summary): Document parse.assert.
-2008-12-07 Di-an Jan <dianj@freeshell.org>
+2009-04-14 Akim Demaille <demaille@gostai.com>
- Implement the FIXME that ends an user action with a semicolon
- if it seems necessary.
- * src/scan-code.l (flex rules section): Flag cpp directive from
- any `#' to the first unescaped end-of-line. Semicolon is not
- needed after `;', `{', '}', or cpp directives and is needed after
- any other token (whitespaces and comments have no effect).
- * tests/actions.at (Fix user actions without a trailing semicolon):
- New test.
- * tests/input.at (AT_CHECK_UNUSED_VALUES): Add semicolons to
- to make user actions complete statements.
- Adjust column numbers in error messages.
- * tests/regression.at (Fix user actions without a trailing semicolon):
- Remove. Covered by new test.
+ variables: use `parse.trace' instead of `debug'.
+ * src/getargs.c (getargs): Map -t to %define trace.parse.
+ * src/scan-gram.l (%debug): Map to %define trace.parse.
+ * data/bison.m4 (b4_percent_define_if_define): Map `.' in variable
+ names to `_' in macro names.
+ (b4_debug_if): Replace with...
+ (b4_parse_trace_if): this.
+ * data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java,
+ * data/yacc.c: Adjust.
+ * doc/bison.texinfo (Decl Summary): Document %debug as obsoleted.
+ Use @code to label the variable list.
+ Document the variable parse.trace.
+ (Tracing): Promote the parse.trace variable.
+ * TODO: %printer is not documented.
2009-04-14 Akim Demaille <demaille@gostai.com>
2009-04-06 Joel E. Denny <jdenny@ces.clemson.edu>
- * NEWS (2.5): Describe new -D/--define feature.
-
-2008-11-10 Akim Demaille <demaille@gostai.com>
-
- --trace=muscles
- * src/getargs.h, src/getargs.c (trace_muscle): New.
- (trace_types, trace_args): Support it.
- * src/output.c (output_skeleton): Use it.
+ * NEWS (2.5): New section. Describe new -D/--define feature.
-2008-11-10 Akim Demaille <demaille@gostai.com>
+2009-04-06 Akim Demaille <demaille@gostai.com>
- muscles_output.
- * src/output.c (muscles_output): New, extracted from...
- (output_skeleton): here.
- Adjust.
+ Regen.
+ * src/parse-gram.h, src/parse-gram.c: Regen.
-2008-11-21 Akim Demaille <demaille@gostai.com>
+2009-04-06 Akim Demaille <demaille@gostai.com>
- Display the changes in cross-options.texi.
- * build-aux/cross-options.pl ($sep): New, to separate items.
- * doc/Makefile.am ($(srcdir)/cross-options.texi): Use diff to display
- the changes.
+ rename muscle_tab.* as muscle-tab.* for consistency.
+ * src/muscle_tab.h, src/muscle_tab.c: Rename as...
+ * src/muscle-tab.h, src/muscle-tab.c: these.
+ * src/getargs.c, src/local.mk, src/main.c, src/output.c,
+ * src/parse-gram.y, src/reader.c, src/scan-code.l: Adjust.
-2008-11-20 Di-an Jan <dianj@freeshell.org>
+2009-04-06 Akim Demaille <demaille@gostai.com>
- Improves options in the manual.
- * doc/bison.texinfo (-g, -x): Add space before argument.
- (Option Cross Key): Implement FIXME: listing directives also.
- * build-aux/cross-options.pl: Read from <STDIN> rather than <>.
- (Short Option): Special case -d. Put arguments inside @option.
- (Bison Directive): Add column, automatically extracted from
- src/scan-gram.l (actual name passed as the first argument)
- with special case for %define.
- * doc/Makefile.am (doc/cross-options.texi): Pass src/scan-gram.l
- to build-aux/cross-options.pl.
- * src/getargs.c (usage): Document limitations of cross-options.pl.
- * src/scan-gram.l: Likewise.
+ Makefile: introduce $(BISON).
+ * src/local.mk (BISON): New.
+ (YACC): Use it.
-2009-02-25 Akim Demaille <demaille@gostai.com>
+2009-04-06 Akim Demaille <demaille@gostai.com>
- Copyright years.
- * data/glr.c: Add 2007 and 2008 here, consistenly with the comments.
+ parser: handle %locations as %define locations.
+ * src/getargs.h, src/getargs.c (locations_flag): Remove.
+ * src/getargs.c, src/scan-code.l: Use muscle_percent_define_ensure
+ to set "locations" to true.
+ * src/output.c (prepare): Don't output "locations".
+ * src/scan-gram.l (%locations): Handle it as a %<flag>.
+ * src/parse-gram.y: It's no longer a token.
+ Don't handle it.
+ * data/bison.m4 (b4_locations_if): Define it with
+ b4_percent_define_if_define.
+ * data/c.m4, data/glr.cc: Adjust.
-2008-12-08 Akim Demaille <demaille@gostai.com>
+2009-04-06 Akim Demaille <demaille@gostai.com>
- Install autoconf as a submodule to get m4sugar.
- * .gitmodules: Add submodules/autoconf.
- * data/m4sugar/foreach.m4, data/m4sugar/m4sugar.m4: Now links into
- submodules/autoconf.
+ Regen.
+ * src/parse-gram.c: Regen.
-2008-11-17 Joel E. Denny <jdenny@ces.clemson.edu>
+2009-04-06 Akim Demaille <demaille@gostai.com>
- Simplify last patch slightly.
- * src/getargs.c (getargs): Here.
+ muscle: factor the handling of obsolete of obsolete directives.
+ Suggested by Joel E. Denny.
-2008-11-17 Joel E. Denny <jdenny@ces.clemson.edu>
+ * src/muscle_tab.h, src/muscle_tab.c (muscle_percent_define_ensure):
+ New, extracted from...
+ * src/parse-gram.y (prologue_declaration: pure-parser): here.
+ Remove it.
+ (prologue_declaration: "%<flag>"): Use
+ muscle_percent_define_ensure.
+ (%error-verbose, %pure-parser): No longer tokens.
+ * src/scan-gram.l (pure-parser): Return as a %<flag>.
- Fix last warning from --enable-gcc-warnings.
- * src/getargs.c (getargs): Don't assign const address to non-const
- pointer.
+2009-04-06 Joel E. Denny <jdenny@ces.clemson.edu>
-2008-11-17 Di-an Jan <dianj@freeshell.org>
+ Fix options documentation.
+ * build-aux/cross-options.pl: As in --help output, write optional
+ arguments as [=ARG] not =[ARG].
+ * doc/bison.texinfo (Bison Options): Add -W/--warnings argument.
- Handle --enable-gcc-warnings.
- * src/getargs.c (command_line_location): Set parameters to void.
+2009-04-04 Joel E. Denny <jdenny@ces.clemson.edu>
-2008-11-11 Akim Demaille <demaille@gostai.com>
+ Replace BISON_PROG_GNU_M4 with Autoconf's AC_PROG_GNU_M4.
+ If the first m4 in $PATH is wrong, it keeps looking. Moreover, its
+ requirements for a correct m4 are stricter.
+ * m4/m4.m4: Make it a symbolic link to submodules/autoconf/m4/m4.m4.
+ * configure.ac: Update to use AC_PROG_GNU_M4.
+ Reported by Eric Blake.
- AT_FULL_COMPILE.
- * tests/actions.at, tests/regression.at: Use it.
+2009-04-03 Joel E. Denny <jdenny@ces.clemson.edu>
-2008-11-07 Akim Demaille <demaille@gostai.com>
+ Help with updating web manual.
+ * HACKING: Incorporate instructions from gnulib/doc/README.
+ * bootstrap.conf (gnulib_modules): Add gendocs.
- Pass command line location to skeleton_arg and language_argmatch.
- * src/getargs.h, src/getargs.c (skeleton_arg, language_argmatch):
- The location argument is now mandatory.
- Adjust all dependencies.
- (getargs): Use command_line_location.
+2009-04-03 Akim Demaille <demaille@gostai.com>
+
+ Regen.
+ * src/parse-gram.h, src/parse-gram.c: Regen.
+
+2009-04-03 Akim Demaille <demaille@gostai.com>
+
+ Factor %FLAG at scan level.
+ * src/parse-gram.y (PERCENT_DEBUG, PERCENT_ERROR_VERBOSE): Token
+ definitions and associated rules, replaced by....
+ (PERCENT_FLAG): this new token type, and rule.
+ * src/scan-gram.l (RETURN_PERCENT_FLAG): New.
+ Use it for %debug and %error-verbose.
+
+2009-04-03 Akim Demaille <demaille@gostai.com>
+
+ Regen.
+ * src/parse-gram.h, src/parse-gram.c: Regen.
+
+2009-04-03 Akim Demaille <demaille@gostai.com>
+
+ Treat %debug as %define debug.
+ * data/bison.m4 (b4_debug_if): New.
+ * data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c,
+ * data/lalr1.java: Use it instead of b4_debug_flag.
+ * src/getargs.h, src/getargs.c (debug_flag): Remove.
+ * src/output.c (prepare): Don't output it.
+ * src/parse-gram.y: Treat %debug as %define debug.
+
+2009-04-03 Akim Demaille <demaille@gostai.com>
+
+ Treat %error-verbose as %define error_verbose.
+ This allows to pass -Derror_verbose on the command line. Better
+ yet, it allows to pass -Derror_verbose=$(ERROR_VERBOSE), with
+ ERROR_VERBOSE being defined as false or true.
+ * data/bison.m4 (b4_percent_define_if_define): Instead of relying
+ on b4_percent_define_ifdef, for does not check the defined value,
+ but only whether the symbol is defined, rely on
+ b4_percent_define_flag_if, so that a value of "false" is processed
+ as a false.
+ If not defined, define the flag to "false".
+ (b4_error_verbose_if): New.
+ * data/glr.c, data/lalr1.cc, data/yacc.c: Use it instead of
+ b4_error_verbose_flag.
+ * src/getargs.h, src/getargs.c (error_verbose_flag): Remove.
+ * src/output.c (prepare): Don't output it.
+ * src/parse-gram.y (%error-verbose): Treat as %define error_verbose.
-2008-11-07 Akim Demaille <demaille@gostai.com>
-
- -D, --define.
- * src/getargs.c (usage): Document -D.
- Fix help string for --locations.
- (command_line_location): New.
- (short_options, long_options, getargs): Support -D, --define.
- (getargs): Move -d support at the right place.
- * doc/bison.texinfo (Bison Options): Update.
- * tests/input.at (%define, --define): New.
-
-2008-11-07 Akim Demaille <demaille@gostai.com>
-
- Initialize the muscle table before parsing the command line.
- * src/getargs.c (quotearg.h, muscle_tab.h): Include.
- (getargs): Define file_name.
- * src/main.c (main): Initialize muscle_tab before calling
- getargs.
- * src/muscle_tab.c (muscle_init): No longer define file_name, as
- its value is not available yet.
-
-2008-11-09 Akim Demaille <demaille@gostai.com>
-
- Require the generation of parse-gram.output.
- * src/Makefile.am (YACC): Pass --report=all.
-
-2009-04-06 Joel E. Denny <jdenny@ces.clemson.edu>
-
- * NEWS (2.5): New stub.
-
-2009-04-06 Joel E. Denny <jdenny@ces.clemson.edu>
-
- Fix options documentation.
- * build-aux/cross-options.pl: As in --help output, write optional
- arguments as [=ARG] not =[ARG].
- * doc/bison.texinfo (Bison Options): Add -W/--warnings argument.
-
-2008-11-07 Akim Demaille <demaille@gostai.com>
-
- Fix --help.
- * src/getargs.c (usage): Fix help string for -W.
-
-2008-11-07 Akim Demaille <demaille@gostai.com>
-
- Handle more general types of option arguments.
- * build-aux/cross-options.pl: The argument ends at the first
- space, not the first non-symbol character.
- Use @var for each word appearing the argument description.
-
-2009-04-04 Joel E. Denny <jdenny@ces.clemson.edu>
-
- Remove spurious initial empty lines.
- * data/location.cc: End the @output lines with an @.
-
-2008-11-04 Akim Demaille <demaille@gostai.com>
-
- Remove spurious initial empty lines.
- * data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java,
- * data/yacc.c: End the @output lines with an @.
-
-2009-04-04 Joel E. Denny <jdenny@ces.clemson.edu>
-
- Replace BISON_PROG_GNU_M4 with Autoconf's AC_PROG_GNU_M4.
- If the first m4 in $PATH is wrong, it keeps looking. Moreover, its
- requirements for a correct m4 are stricter.
- * m4/m4.m4: Replace with Autoconf 2.63's m4/m4.m4.
- * configure.ac: Update to use AC_PROG_GNU_M4.
- Reported by Eric Blake.
-
-2009-04-03 Joel E. Denny <jdenny@ces.clemson.edu>
-
- Help with updating web manual.
- * HACKING: Incorporate instructions from gnulib/doc/README.
- * bootstrap.conf (gnulib_modules): Add gendocs.
-
-2009-04-03 Joel E. Denny <jdenny@ces.clemson.edu>
+2009-04-03 Joel E. Denny <jdenny@ces.clemson.edu>
Fix strange %define locations for default values.
Reported by Akim Demaille at
* tests/skeletons.at (%define Boolean variables: invalid skeleton
defaults): Update output.
-2008-11-07 Akim Demaille <demaille@gostai.com>
-
- Locations without columns for command line arguments.
- * src/location.c (location_print): Don't display negative columns.
- * src/location.h: Document this.
-
-2009-02-03 Joel E. Denny <jdenny@ces.clemson.edu>
+2009-04-03 Joel E. Denny <jdenny@ces.clemson.edu>
- Add reminder about uploading public key to keys.gnupg.net.
- * HACKING (Release Procedure): Here.
+ Pacify ./configure --enable-gcc-warnings.
+ * Makefile.am (AM_CFLAGS): Remove $(WERROR_CFLAGS) because many files
+ in lib won't compile with it.
+ * src/local.mk (src_bison_CFLAGS): Use $(WERROR_CFLAGS) here only.
2009-03-31 Akim Demaille <demaille@gostai.com>
gnulib: update.
* gnulib: Update to latest.
- * lib/Makefile.am (AM_CPPFLAGS): It is now defined by gnulib, so
- use +=.
+ * src/local.mk (AM_CFLAGS): Move to...
+ * Makefile.am: here.
+ * etc/prefix-gnulib-mk (prefix_assignment): Also transform
+ AM_CFLAGS.
+
+2009-03-02 Akim Demaille <demaille@gostai.com>
+
+ Comment changes.
+
+2009-03-02 Akim Demaille <demaille@gostai.com>
+
+ Share b4_yytranslate_define.
+ * data/lalr1.cc (b4_yytranslate_define): Move to...
+ * data/c++.m4: here.
+
+2009-03-02 Akim Demaille <demaille@gostai.com>
+
+ Use locations in the variant example.
+ Yes, this obfuscates the point of this example, variants only.
+ But glr.cc cannot work (yet?) without locations. This change
+ makes it easier to use this example with glr.cc.
+
+ * examples/variant.yy (assert): %define it.
+ (locations): Request them.
+ (yylex): Bind the location to the stage.
+
+2009-03-02 Akim Demaille <demaille@gostai.com>
+
+ Dub make_TOKEN as a public type interface.
+ * data/c++.m4 (b4_symbol_constructor_declare)
+ (b4_symbol_constructor_define): New empty stubs.
+ (b4_public_types_declare, b4_public_types_define): Use them.
+ * data/lalr1.cc (b4_symbol_constructor_declare)
+ (b4_symbol_constructor_declare_)
+ (b4_symbol_constructor_define_, b4_symbol_constructor_define):
+ Move to...
+ * data/variant.hh: here.
+ Remove the "b4_variant_if" parts, as variant.hh is loaded only if
+ needed.
+ * data/lalr1.cc: No longer invoke b4_symbol_constructor_define and
+ b4_symbol_constructor_declare, as it is now done by
+ b4_public_types_define and b4_public_types_declare.
+
+2009-03-02 Akim Demaille <demaille@gostai.com>
+
+ Coding style changes.
+ * data/lalr1.cc (b4_symbol_constructor_declaration_)
+ (b4_symbol_constructor_declarations)
+ (b4_symbol_constructor_definition_)
+ (b4_symbol_constructor_definitions)
+ (b4_yytranslate_definition): Rename as...
+ (b4_symbol_constructor_declare_)
+ (b4_symbol_constructor_declare)
+ (b4_symbol_constructor_define_)
+ (b4_symbol_constructor_define)
+ (b4_yytranslate_define): these.
+ * data/variant.hh (b4_variant_definition): Rename as...
+ (b4_variant_define): this.
+
+2009-03-02 Akim Demaille <demaille@gostai.com>
+
+ Factor b4_assert_if, b4_lex_symbol_if, and b4_variant_if.
+ * data/bison.m4 (b4_percent_define_if_define): New.
+ * data/c++.m4 (b4_variant_if): Move to...
+ * data/bison.m4: Here, using b4_percent_define_if_define.
+ * data/lalr1.cc (b4_assert_if, b4_lex_symbol_if): Move to...
+ * data/bison.m4: Here, using b4_percent_define_if_define.
+
+2009-03-02 Akim Demaille <demaille@gostai.com>
+
+ Dub symbol_type_base as a public type.
+ * data/c++.m4 (b4_public_types_declare): Now define
+ symbol_type_base and symbol_type.
+ (b4_public_types_define): New.
+ In both cases, the definitions are taken verbatim from lalr1.cc.
+ * data/lalr1.cc: Adjust.
+
+2009-03-02 Akim Demaille <demaille@gostai.com>
+
+ b4_public_types_declare.
+ * data/c++.m4 (b4_public_types_declare): New.
+ * data/glr.cc, data/lalr1.cc: Use it.
+
+2009-03-02 Akim Demaille <demaille@gostai.com>
+
+ b4_semantic_type_declare.
+ * data/c++.m4 (b4_semantic_type_declare): New.
+ Factors and generalizes what was in glr.cc and lalr1.cc.
+ * data/variant.hh (b4_semantic_type_declare): Redefine it for
+ variants.
+ * data/lalr1.cc, data/glr.cc: Use it.
+
+2009-02-26 Akim Demaille <demaille@gostai.com>
+
+ Upgrade gnulib.
+ * gnulib: Upgrade from master.
+ * lib/.cvsignore, lib/.gitignore, m4/.cvsignore, m4/.gitignore:
+ Regen.
+
+2009-02-25 Akim Demaille <demaille@gostai.com>
+
+ Remove useless arguments.
+ * data/glr.c (yy_reduce_print): $$ and @$ are not used and not
+ relevant.
+
+2009-02-25 Akim Demaille <demaille@gostai.com>
+
+ Comment changes.
+ * data/lalr1.cc: here.
+
+2009-02-25 Akim Demaille <demaille@gostai.com>
+
+ Fix glr.cc's debug level handling.
+ * data/glr.cc (yydebug_): Remove, as it is actually yydebug from
+ glr.c which is used.
+ (debug_level, set_debug_level): Adjust.
+
+2009-02-25 Akim Demaille <demaille@gostai.com>
+
+ Copyright years.
+ * data/glr.c: Add 2007 and 2008 here, consistenly with the comments.
+
+2009-02-25 Akim Demaille <demaille@gostai.com>
+
+ Style changes.
+ * etc/bench.pl.in (generate_grammar_list): Consitently use
+ location_type, not yy::location.
+
+2009-02-25 Akim Demaille <demaille@gostai.com>
+
+ Comment change.
+ * data/lalr1.cc: here.
+
+2009-02-19 Akim Demaille <demaille@gostai.com>
+
+ Make yyparser::error public.
+ * data/lalr1.cc: here.
+ There is no good reason to keep it private (and it is convenient
+ to use it from the scanner for instance). It is already public in
+ glr.cc.
+
+2009-02-19 Akim Demaille <demaille@gostai.com>
+
+ Comment changes.
+ * data/glr.cc: here.
+
+2009-02-19 Akim Demaille <demaille@gostai.com>
+
+ Remove trailing blanks.
+ The epilogue has its own ending \n, no need to add another.
+
+ * data/glr.c, data/lalr1.java, data/yacc.c: dnl when outputing the
+ epilogue.
+ * data/glr.cc: dnl when extending the epilogue.
+ Remove stray "private:".
+
+2009-02-19 Akim Demaille <demaille@gostai.com>
+
+ Use b4_c_modern.
+ * data/c.m4 (b4_c_function_decl): Here.
+
+2009-02-19 Akim Demaille <demaille@gostai.com>
+
+ Comment changes.
+ * data/lalr1.cc: here.
+
+2009-02-19 Akim Demaille <demaille@gostai.com>
+
+ Extract variant.hh
+ * data/variant.hh: New, extracted from...
+ * data/lalr1.cc: here.
+ Adjust.
+ * data/local.mk: Adjust.
+
+2009-02-19 Akim Demaille <demaille@gostai.com>
+
+ Extract stack.hh from lalr1.cc.
+ * data/stack.hh: New.
+ * data/lalr1.cc: Extract from here.
+ * data/local.mk: Adjust.
+
+2009-02-03 Joel E. Denny <jdenny@ces.clemson.edu>
+
+ Add reminder about uploading public key to keys.gnupg.net.
+ * HACKING (Release Procedure): Here.
+
+2009-01-28 Akim Demaille <demaille@gostai.com>
+
+ * NEWS: Update information about 2.4.1 and 2.4.2.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Reformat NEWS.
+ * NEWS: Use more outline-mode markup.
+ Suggested by Jim Meyering.
2009-01-08 Akim Demaille <demaille@gostai.com>
* tests/java.at: Use $EGREP instead of egrep.
Use AT_CHECK's ignore instead of grep's -q.
-2008-12-11 Joel E. Denny <jdenny@ces.clemson.edu>
+2008-12-11 Akim Demaille <demaille@gostai.com>
+
+ Pass the token type to yysyntax_error.
+ * data/yacc.c (yysyntax_error): Take the transated token instead
+ of the raw number.
+ Adjust callers.
+ * TODO: Update.
- Version 2.4.1.
- * NEWS: Set version and date.
- * lib/Makefile.am: Update copyright year.
- * tests/atlocal.in: Update copyright year.
+2008-12-11 Akim Demaille <demaille@gostai.com>
-2008-12-11 Joel E. Denny <jdenny@ces.clemson.edu>
+ Formatting changes.
+ * data/glr.c: Formatting changes.
- Semicolon feature removal is not about future language support.
- * NEWS: The semicolon feature is no longer active for newer languages,
- so don't claim that it causes trouble for them.
+2008-12-11 Akim Demaille <demaille@gostai.com>
-2008-12-11 Joel E. Denny <jdenny@ces.clemson.edu>
+ Propagate i18n changes into glr.c.
+ * TODO: Update.
+ * data/glr.c (yyreportSyntaxError): Use "switch" instead of
+ building the error message format dynamically.
+ * data/lalr1.java: Formatting changes.
- * gnulib: Update submodule to HEAD.
+2008-12-11 Akim Demaille <demaille@gostai.com>
-2008-12-09 Akim Demaille <demaille@gostai.com>
+ Use testsuite -C.
+ * tests/local.mk: Replace "cd && testsuite" by "testsuite -C".
+ Solves problems when top_srcdir is an absolute path.
+ Suggested by Eric Blake.
+ * configure.ac: Require Autoconf 2.62.
+
+2008-12-11 Akim Demaille <demaille@gostai.com>
+
+ Simplify the i18n of the error messages.
+ * data/lalr1.cc: Comment changes.
+ * data/yacc.c (yysyntax_error): Rewrite, using a switch as in
+ lalr1.cc instead of building dynamically the format string.
+
+2008-12-08 Akim Demaille <demaille@gostai.com>
+
+ Fix portability issue in the test suite.
+ * tests/local.at (AT_MATCHES_CHECK): New.
+ Based on Perl instead of Sed. Sed has too many portability
+ pitfalls, not ever Sed is GNU Sed.
+ * tests/actions.at (Fix user actions without a trailing semicolon):
+ Use it.
+
+2008-12-08 Akim Demaille <demaille@gostai.com>
Update data/README.
* data/README: Document glr.cc, lalr1.java, m4sugar and xslt.
+2008-12-08 Akim Demaille <demaille@gostai.com>
+
+ Install autoconf as a submodule to get m4sugar.
+ * .gitmodules: Add submodules/autoconf.
+ * data/m4sugar/foreach.m4, data/m4sugar/m4sugar.m4: Now links into
+ submodules/autoconf.
+
+2008-12-08 Akim Demaille <demaille@gostai.com>
+
+ Test token.prefix in all the skeletons.
+ * data/java.m4 (b4_token_enum): Use the token.prefix.
+ * tests/local.at (AT_BISON_OPTION_PUSHDEFS): Define AT_TOKEN_PREFIX.
+ * tests/calc.at (_AT_DATA_CALC_Y): Use it.
+ Add checks for yacc.c, glr.c, lalr1.cc and glr.cc.
+ * tests/java.at: Comment changes.
+ (AT_CHECK_JAVA_MINIMAL): Define the END token.
+ (Java parser class and package names): Add token.prefix check.
+
+2008-12-08 Akim Demaille <demaille@gostai.com>
+
+ Fix regeneration of atconfig.
+ * tests/local.mk (tests/atconfig): The rule was incorrect, but
+ remove it: now that there is no tests/Makefile.am, the top-level
+ Makefile properly updates atconfig when needed.
+
+2008-12-07 Di-an Jan <dianj@freeshell.org>
+
+ Implement the FIXME that ends an user action with a semicolon
+ if it seems necessary.
+ * src/scan-code.l (flex rules section): Flag cpp directive from
+ any `#' to the first unescaped end-of-line. Semicolon is not
+ needed after `;', `{', '}', or cpp directives and is needed after
+ any other token (whitespaces and comments have no effect).
+ * tests/actions.at (Fix user actions without a trailing semicolon):
+ New test.
+ * tests/input.at (AT_CHECK_UNUSED_VALUES): Add semicolons to
+ to make user actions complete statements.
+ Adjust column numbers in error messages.
+ * tests/regression.at (Fix user actions without a trailing semicolon):
+ Remove. Covered by new test.
+
+2008-12-07 Akim Demaille <demaille@gostai.com>
+
+ Update gnulib.
+ * gnulib: Update from master.
+
2008-12-05 Eric Blake <ebb9@byu.net>
+ Avoid compiler warning.
+ * src/output.c (muscle_insert_item_number_table): Delete unused
+ function.
+
+2008-12-02 Eric Blake <ebb9@byu.net>
+
Build testsuite with newer autoconf.
* tests/output.at (m4_expand): Don't override in newer autoconf,
where the underlying implementation changed.
(_AT_VERBOSE_GLR_STDERR): Expand to double-quoted strings,
since some of them contain unbalanced ')'.
-2008-11-19 Joel E. Denny <jdenny@ces.clemson.edu>
+2008-12-01 Akim Demaille <demaille@gostai.com>
- * NEWS: Clarify a little.
+ Use b4_symbol for printers and destructors everywhere.
+ * data/bison.m4 (b4_symbol_action_location): New.
+ * data/c.m4 (b4_symbol_actions): Remove.
+ Adjust all callers to use by b4_symbol_foreach and the corresponding
+ b4_symbol_printer/destructor macro.
+ * data/glr.cc: Adjust.
+ * data/lalr1.java: Adjust the %destructor sanity check.
+ * src/output.c (symbol_code_props_output): Remove, we no longer
+ need the b4_symbol_printers/destructors tables.
-2008-11-19 Joel E. Denny <jdenny@ces.clemson.edu>
+2008-12-01 Akim Demaille <demaille@gostai.com>
- * NEWS: Update for recent changes.
+ Use b4_symbol_case_.
+ * data/lalr1.cc, data/bison.m4 (b4_symbol_action): Use
+ b4_symbol_case_.
-2008-11-18 Joel E. Denny <jdenny@ces.clemson.edu>
+2008-12-01 Akim Demaille <demaille@gostai.com>
- Fix unexpanded macros in GLR defines file.
- Reported by Csaba Raduly at
- <http://lists.gnu.org/archive/html/bug-bison/2008-11/msg00048.html>.
- * THANKS (Csaba Raduly): Add.
- * data/glr.c: Fix overquoting on b4_prefix for yylval and yylloc.
- * tests/calc.at (_AT_DATA_CALC_Y): If %defines is specified, generate
- lexer in a separate module that includes the defines file.
- (AT_CHECK_CALC): Use AT_FULL_COMPILE and request compilation of lexer
- source.
- * tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Push AT_DEFINES_IF.
- Adjust AT_LOC and AT_VAL to use AT_NAME_PREFIX.
- (AT_BISON_OPTION_POPDEFS): Pop AT_DEFINES_IF.
- (AT_DATA_SOURCE_PROLOGUE): New.
- (AT_DATA_GRAMMAR_PROLOGUE): Use AT_DATA_SOURCE_PROLOGUE.
- (AT_DATA_SOURCE): New.
- (AT_FULL_COMPILE): New, copied from master branch and extended to
- support an additional source file.
+ Move b4_symbol based macro to bison.m4.
+ * data/lalr1.cc (b4_symbol_, b4_symbol, b4_symbol_if)
+ (b4_symbol_action, b4_symbol_destructor, b4_symbol_printer)
+ (b4_symbol_case_, b4_symbol_foreach, b4_type_action_)
+ (b4_type_foreach): Move to...
+ * data/bison.m4: Here.
+ * data/lalr1.cc (b4_symbol_action): Specialize for C++: use
+ b4_symbol_value_template instead of b4_symbol_value.
-2008-11-17 Joel E. Denny <jdenny@ces.clemson.edu>
+2008-12-01 Akim Demaille <demaille@gostai.com>
- Don't let maintainer-*-check targets force a version update.
- * cfg.mk (_is-dist-target): Implement. maintainer-check* was already
- handled.
+ b4_symbol/type_foreach.
+ * data/lalr1.cc (b4_symbol_foreach, b4_type_foreach): New.
+ Use them.
-2008-11-17 Di-an Jan <dianj@freeshell.org>
+2008-12-01 Akim Demaille <demaille@gostai.com>
+
+ Use the symbol properties to output the printer/destructor for lalr1.cc.
+ Instead of defining complex list of tuples to define various
+ properties of the symbols, we now prefer to define symbols as
+ "structs" in m4: using the symbol key (its number), and the
+ property name, b4_symbol gives it value. Use this to handle
+ destructors and printers.
+
+ * src/output.c (CODE_PROP): New.
+ (prepare_symbol_definitions): Use it to define the printer and
+ destructor related attributes of the symbols.
+ * data/lalr1.cc (b4_symbol_actions): Rename as...
+ (b4_symbol_action): this.
+ Use b4_symbol instead of 6 arguments.
+ (b4_symbol_printer, b4_symbol_destructor): New.
+ Use them instead of b4_symbol_actions.
+
+2008-12-01 Akim Demaille <demaille@gostai.com>
+
+ Avoid capturing variables too easily.
+ * src/muscle_tab.h (MUSCLE_INSERT_BOOL, MUSCLE_OBSTACK_SGROW): Use
+ v__ and p__ instead of v and p.
+
+2008-12-01 Akim Demaille <demaille@gostai.com>
+
+ Remove spurious empty line before syncline.
+ * data/bison.m4 (b4_syncline): Don't output an empty line before
+ the output.
+
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ Convert lib/Makefile.am into lib/local.mk.
+ The real problem is rather gnulib.mk, which itself is extracted
+ from a Makefile.am that gnulib expects to the "recursive". The
+ tool prefix-gnulib-mk converts such a gnulib.mk to be
+ non-recursive. Also, some AC_SUBST variables need to be adjusted.
+
+ * etc/prefix-gnulib-mk: New.
+ * bootstrap (slurp): Use it to convert further gnulib.mk.
+ No longer try to avoid re-creation of lib/gnulib.mk as the changes
+ are deeper.
+ * lib/Makefile.am: Rename as...
+ * lib/local.mk: this.
+ Adjust to be prefixed.
+ * Makefile.am, configure.ac: Adjust.
+ * src/local.mk (AM_CPPFLAGS): Extend it, don't define it.
+
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ s/_FLAGS/FLAGS/.
+ * tests/local.mk (TESTSUITE_FLAGS, AUTOTEST_FLAGS): Rename as...
+ (TESTSUITEFLAGS, AUTOTESTFLAGS): these to compy with the GCS.
+ Reported by Eric Blake.
- * doc/bison.texinfo: Synchronize ``Detail Node Listing''.
- Align menus. Adjust word wrapping. Use node names for menu names.
- (Examples): Don't abbreviate node names.
- (LocalWords): Remove abbreviations.
- (Copying): Make description a sentence.
- (Java Action Features): Remove period to match the rest of menu.
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ Use b4_parser_tables_define in glr.cc.
+ * data/glr.c: Use b4_parser_tables_define instead of defining the
+ (deterministic integral) tables by hand.
+
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ Use b4_parser_tables_define in Java.
+ * data/java.m4 (b4_typed_parser_table): Rename as...
+ (b4_typed_parser_table_define): this, for consistency.
+ Accept a comment as $4.
+ Move $2 into yy*_.
+ (b4_integral_parser_table): Rename as...
+ (b4_integral_parser_table_define): this.
+ * data/lalr1.java: Adjust all uses.
+ Use b4_parser_tables_define instead of generation by hand.
+
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ Prepare the convergence bw C style and Java table generation.
+ * data/bison.m4 (b4_tables_map, b4_tables_declare)
+ (b4_tables_define): Rename as...
+ (b4_integral_parser_tables_map, b4_parser_tables_declare)
+ (b4_parser_tables_define): these.
+ * data/c.m4 (b4_table_define): Rename as...
+ (b4_integral_parser_table_define): this.
+ * data/lalr1.cc: Adjust.
+ (b4_table_define, b4_table_declare): Rename as...
+ (b4_integral_parser_table_define)
+ (b4_integral_parser_table_declare): these.
+ (yyrline_): Move the comment where it is actually used.
+ * data/yacc.c: Adjust.
+ (yyrline): Use b4_integral_parser_table_define.
+
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ Regen.
+ * src/parse-gram.h, src/parse-gram.c: Regen.
+
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ Factor the generation of the (integral) tables bw yacc.c and lalr1.cc.
+ * data/lalr1.cc (b4_tables_map): Move to...
+ * data/bison.m4: here.
+ Update the comment for yytable during the flight.
+ (b4_tables_declare, b4_tables_define): New.
+ * data/lalr1.cc: Use them.
+ * data/c.m4 (b4_table_define): New.
+ * data/yacc.c: Use b4_tables_define instead of output the tables
+ by hand.
+ * tests/regression.at (Web2c Actions): Adjust the expected output,
+ the order of the tables changed.
+
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ Get rid of (yy)rhs and (yy)prhs.
+ These tables are no longer needed in the parsers, and they don't seem to
+ be useful. They are not documented either.
+
+ * src/output.c (prepare_rules): Get rid of rhs and prhs.
+ Adjust the computation of (yy)r2.
+
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ Rule length is unsigned.
+ * src/gram.h, src/gram.c (rule_rhs_length): Return a size_t.
+
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ Get rid of lalr1-split.cc.
+ It was no longer maintainer.
+
+ * data/lalr1-split.cc: Remove.
+ * etc/bench.pl.in (bench_fusion_parser): Remove.
+ Adjust.
-2008-11-11 Paolo Bonzini <bonzini@gnu.org>
+2008-11-26 Akim Demaille <demaille@gostai.com>
- * bootstrap.conf: Replace m4/warning.m4 with warnings module.
- * configure.ac: Adjust usage.
- * lib/Makefile.am: Replace $(WARNING_CFLAGS) with $(WARN_CFLAGS).
- * src/Makefile.am: Replace $(WARNING_CFLAGS) with $(WARN_CFLAGS).
- * tests/atlocal.in: Replace $(WARNING_*FLAGS) with $(WARN_*FLAGS).
+ Use yy* consistently.
+ * data/glr.c: Now that yyrhs no longer exists as a global
+ variable, rename local "rhs" variables into "yyrhs" for
+ consistency.
-2008-11-07 Joel E. Denny <jdenny@ces.clemson.edu>
+2008-11-25 Akim Demaille <demaille@gostai.com>
- Don't add a semicolon to actions for %skeleton or %language.
- It breaks Java test cases as reported by Akim Demaille.
- * src/scan-code.l: Implement.
+ Get rid of yyrhs and yyprhs in glr.c.
+ * data/glr.c (yyrhs, yyprhs): Remove.
+ Instead, use the state stack and yystos.
-2008-11-07 Joel E. Denny <jdenny@ces.clemson.edu>
+2008-11-25 Akim Demaille <demaille@gostai.com>
- Clean up %skeleton and %language priority implementation.
- * src/getargs.c (skeleton_prio): Use default_prio rather than 2, and
- remove static qualifier because others will soon need to see it.
- (language_prio): Likewise.
+ Flag glr tests.
+ * tests/local.at (_AT_BISON_OPTION_PUSHDEFS): If glr, declare it
+ as an Autotest keyword.
+
+2008-11-25 Akim Demaille <demaille@gostai.com>
+
+ Prefer TESTSUITE_FLAGS.
+ TESTSUITEFLAGS is barely readable.
+
+ * tests/local.mk (TESTSUITE_FLAGS): Default to $(TESTSUITEFLAGS)
+ for backward compatibility.
+ Use the former instead of the latter.
+
+2008-11-25 Akim Demaille <demaille@gostai.com>
+
+ Get rid of yyrhs and yyprhs in larl1.java.
+ * data/lalr1.java (yyrhs_, yyprhs_): Remove.
+ (yy_reduce_print): Rather, use yystos_ and the state stack.
+
+2008-11-25 Akim Demaille <demaille@gostai.com>
+
+ Formatting changes.
+
+2008-11-25 Akim Demaille <demaille@gostai.com>
+
+ Get rid of yyrhs and yyprhs in yacc.c.
+ They were used to get the symbol types, given a rule number, when
+ displaying the top of the stack before a reduction. But the
+ symbol type is available from the state stack. This has two be
+ benefits: two tables less in the parser (making it smaller), and a
+ more consistent use of the three stacks which will help to fuse
+ them.
+
+ * data/yacc.c (yyprhs, yyrhs): Remove.
+ (YY_REDUCE_PRINT): Pass yyssp to yy_reduce_print.
+ (yy_reduce_print): Take yyssp as argument.
+ Use it, together with yystos, to get the symbol type.
+ * tests/regression.at (Web2c Report): Remove these tables from the
+ expected output.
+
+2008-11-25 Akim Demaille <demaille@gostai.com>
+
+ b4_tables_map.
+ The point is to factor the generation of the tables across skeletons.
+ This is language dependant.
+
+ * data/c.m4 (b4_comment_): New.
+ Should be usable to define how to generate tables independently of
+ the language.
+ (b4_c_comment): New.
+ (b4_comment): Bounce to b4_c_comment.
+ Now support $2 = [PREFIX] for indentation.
+ * data/lalr1.cc (b4_table_declare): Don't output a comment if
+ there is no comment.
+ Indent it properly when there is one.
+ Output the ending semicolon.
+ (b4_table_define): Space changes.
+ Output the ending semicolon.
+ (b4_tables_map): New.
+ Use it twice instead of declaring and defining the (integral)
+ tables by hand.
+
+2008-11-25 Akim Demaille <demaille@gostai.com>
+
+ b4_table_declare.
+ * data/lalr1.cc (b4_table_declare): New.
+ Use it to declare the tables defined with b4_table_define.
+ (b4_table_define): Declare a third arg to match b4_table_declare
+ signature.
+ Move all the comments around invocations of b4_table_define into
+ the invocations itselves.
+ Move things around to have the order for declarations and
+ definitions.
+
+2008-11-25 Akim Demaille <demaille@gostai.com>
+
+ Formatting changes.
+ * data/lalr1.java: here.
+
+2008-11-25 Akim Demaille <demaille@gostai.com>
+
+ b4_args is more general than only C++.
+ * data/lalr1.cc (b4_args, _b4_args): Move to...
+ * data/bison.m4: here.
+
+2008-11-21 Di-an Jan <dianj@freeshell.org>
+
+ Implement no-XXX arguments for --warnings, --report, --trace.
+ * src/getargs.c (flags_argmatch): Handles no-XXX.
+ Fix typo in doxygen comment.
+
+2008-11-21 Akim Demaille <demaille@gostai.com>
+
+ Display the changes in cross-options.texi.
+ * build-aux/cross-options.pl ($sep): New, to separate items.
+ * doc/local.mk ($(CROSS_OPTIONS_TEXI)): Use diff to display the
+ changes.
+
+2008-11-20 Di-an Jan <dianj@freeshell.org>
+
+ Improves options in the manual.
+ * doc/bison.texinfo (-g, -x): Add space before argument.
+ (Option Cross Key): Implement FIXME: listing directives also.
+ * build-aux/cross-options.pl: Read from <STDIN> rather than <>.
+ (Short Option): Special case -d. Put arguments inside @option.
+ (Bison Directive): Add column, automatically extracted from
+ src/scan-gram.l (actual name passed as the first argument)
+ with special case for %define.
+ * doc/local.mk (doc/cross-options.texi): Pass src/scan-gram.l
+ to build-aux/cross-options.pl.
+ * src/getargs.c (usage): Document limitations of cross-options.pl.
+ * src/scan-gram.l: Likewise.
+
+2008-11-18 Joel E. Denny <jdenny@ces.clemson.edu>
+
+ Fix unexpanded macros in GLR defines file.
+ Reported by Csaba Raduly at
+ <http://lists.gnu.org/archive/html/bug-bison/2008-11/msg00048.html>.
+ * THANKS (Csaba Raduly): Add.
+ * data/glr.c: Fix overquoting on b4_prefix for yylval and yylloc.
+ * tests/calc.at (_AT_DATA_CALC_Y): If %defines is specified, generate
+ lexer in a separate module that includes the defines file.
+ (AT_CHECK_CALC): From AT_FULL_COMPILE, request compilation of lexer
+ source.
+ * tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Push AT_DEFINES_IF.
+ Adjust AT_LOC and AT_VAL to use AT_NAME_PREFIX.
+ (AT_BISON_OPTION_POPDEFS): Pop AT_DEFINES_IF.
+ (AT_DATA_SOURCE_PROLOGUE): New.
+ (AT_DATA_GRAMMAR_PROLOGUE): Use AT_DATA_SOURCE_PROLOGUE.
+ (AT_DATA_SOURCE): New.
+ (AT_FULL_COMPILE): Extend to support an additional source file.
+
+2008-11-18 Akim Demaille <demaille@gostai.com>
+
+ More TODO.
+ * TODO: More short term issues.
+
+2008-11-18 Akim Demaille <demaille@gostai.com>
+
+ Regen.
+ * src/parse-gram.h, src/parse-gram.c: Regen.
+
+2008-11-18 Akim Demaille <demaille@gostai.com>
+
+ Use b4_subtract where possible.
+ * data/lalr1.cc (b4_subtract): Move to...
+ * data/bison.m4: here.
+ * data/glr.c (b4_rhs_data): Use it.
+ * data/yacc.c (b4_rhs_value, b4_rhs_location): Use it.
+
+2008-11-18 Akim Demaille <demaille@gostai.com>
+
+ Remove incorrect mode specification.
+ * data/glr.cc: Don't pretend it's C code.
+
+2008-11-17 Joel E. Denny <jdenny@ces.clemson.edu>
+
+ Simplify last patch slightly.
+ * src/getargs.c (getargs): Here.
+
+2008-11-17 Joel E. Denny <jdenny@ces.clemson.edu>
+
+ Fix last warning from --enable-gcc-warnings.
+ * src/getargs.c (getargs): Don't assign const address to non-const
+ pointer.
+
+2008-11-17 Joel E. Denny <jdenny@ces.clemson.edu>
+
+ Don't let maintainer-*-check targets force a version update.
+ * cfg.mk (_is-dist-target): Implement. maintainer-check* was already
+ handled.
+
+2008-11-17 Di-an Jan <dianj@freeshell.org>
+
+ * doc/bison.texinfo: Synchronize ``Detail Node Listing''.
+ Align menus. Adjust word wrapping. Use node names for menu names.
+ (Examples): Don't abbreviate node names.
+ (LocalWords): Remove abbreviations.
+ (Copying): Make description a sentence.
+ (Java Action Features): Remove period to match the rest of menu.
+
+2008-11-17 Di-an Jan <dianj@freeshell.org>
+
+ Handles several --enable-gcc-warnings.
+ * src/getargs.c (command_line_location): Set parameters to void.
+ * src/output.c (symbol_type_name_cmp): Make static.
+ (symbols_by_type_name): Set parameters to void.
+ (symbol_definitions_output): Remove unused parameter. Rename as...
+ (prepare_symbol_definitions): this.
+ (muscles_output): Move symbol_definitions_output to...
+ (output): here as prepare_symbol_definitions.
+ * tests/c++.at (AT_CHECK_VARIANTS): Remove unused parameters of main.
+ (AT_CHECK_NAMESPACE): Make unused parameter lloc unnamed.
+
+2008-11-17 Di-an Jan <dianj@freeshell.org>
+
+ * tests/c++.at (AT_CHECK_VARIANTS): Fixes tests 198-202.
+ Use AT_DATA_GRAMMAR instead of AT_DATA for compiled tests.
+
+2008-11-16 Akim Demaille <demaille@gostai.com>
+
+ Add missing $(EXEEXT).
+ * doc/local.mk ($(CROSS_OPTIONS_TEXI)): The target is
+ "src/bison$(EXEEXT)".
+ Reported by Di-an Jan.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ * TODO: Update.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Formatting changes.
+ * tests/input.at: here.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Remove duplicate header inclusion.
+ * src/LR0.c: here.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ * src/parse-gram.h, src/parse-gram.c: Regen.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Support parametric types.
+
+ There are two issues to handle: first scanning nested angle
+ bracket pairs to support types such as std::pair< std::string,
+ std::list<std::string> > >.
+
+ Another issue is to address idiosyncracies of C++: do not glue two
+ closing angle brackets together (otherwise it's operator>>), and
+ avoid sticking blindly a TYPE to the opening <, as it can result
+ in '<:' which is a digraph for '['.
+
+ * src/scan-gram.l (brace_level): Rename as...
+ (nesting): this.
+ (SC_TAG): New.
+ Implement support for complex tags.
+ (tag): Accept
+ , but not <.
+ * data/lalr1.cc (b4_symbol_value, b4_symbol_value_template)
+ (b4_symbol_variant): Leave space around types as parameters.
+ * examples/variant.yy: Use nested template types and leading ::.
+ * src/parse-gram.y (TYPE, TYPE_TAG_ANY, TYPE_TAG_NONE, type.opt):
+ Rename as...
+ (TAG, TAG_ANY, TAG_NONE, tag.opt): these.
+ * tests/c++.at: Test parametric types.
+
+2008-11-15 Akim Demaille <akim@betelgeuse.gostai.ensta.fr>
+
+ Test token.prefix.
+ This is not sufficient, but we test at least that the make_SYMBOL
+ interface is not affected by token.prefix. A more general test
+ will be implemented when the support of token.prefix is generalized
+ to more skeletons.
+
+ * tests/c++.at: One more variant test, using token.prefix.
+
+2008-11-15 Akim Demaille <akim@betelgeuse.gostai.ensta.fr>
+
+ Test the make_TOKEN interface.
+ * tests/c++.at (AT_CHECK_VARIANTS): Require and use locations.
+ Factor the common code in yylex.
+ Use it to test "%define lex_symbol".
+
+2008-11-15 Akim Demaille <akim@betelgeuse.gostai.ensta.fr>
+
+ Formatting change.
+
+2008-11-15 Akim Demaille <akim@betelgeuse.gostai.ensta.fr>
+
+ Simplify code for variants bench marks.
+ * etc/bench.pl.in (&generate_grammar_list): Define and use
+ location_type.
+ Factor the common code in yylex.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Better error message.
+ * bootstrap (find_tool): Fix the error message.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Update variant.yy to newest interface.
+ * examples/variant.yy: Define lex_symbol.
+ Adjust.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Don't use locations in variant.yy.
+ * examples/variant.yy: Adjust to not using locations.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Comment changes.
+ * data/local.mk, etc/local.mk, examples/local.mk: Use Automake
+ comments for the license.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Remove tests/Makefile.am.
+ * tests/Makefile.am: Rename as...
+ * tests/local.mk: this.
+ * Makefile.am, configure.ac: Adjust.
+ * Makefile.am (DISTCLEANFILES): Define.
+ (maintainer-check, maintainer-xml-check, maintainer-push-check):
+ Remove, we no longer need to bounce to the real targets.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Comment changes.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ djgpp/local.mk.
+ * Makefile.am (EXTRA_DIST): Move djgpp related part to...
+ * djgpp/local.mk: this new file.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Remove doc/Makefile.am.
+ * doc/Makefile.am: Rename as...
+ * doc/local.mk: this.
+ Adjust paths
+ * Makefile.am, configure.ac: Adjust.
+ * Makefile.am (MOSTLYCLEANFILES): New.
+ * src/local.mk: Adjust.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Move sc_tight_scope into maint.mk.
+ It does not work, and I don't know how it was supposed to work: it
+ seems to be looking for sources in the build tree. I just moved
+ it at a better place, fixing it is still required.
+
+ * src/local.mk (echo): Remove.
+ (sc_tight_scope): Move to...
+ * maint.mk: here.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Regen.
+ * src/parse-gram.h, src/parse-gram.h: Regen.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Remove src/Makefile.am.
+ * src/Makefile.am: Rename as...
+ * src/local.mk: this.
+ Prefix all the paths with src/.
+ (AUTOMAKE_OPTIONS): Build object files in the sub dirs.
+ (AM_CPPFLAGS): Find find in builddir/src.
+ (YACC): Move the flags into...
+ (AM_YFLAGS): here.
+ * maint.mk (sc_tight_scope): Disable.
+ It used to bounce to the version in src/Makefile.am which is now
+ part of this very Makefile.
+ * Makefile.am, configure.ac: Adjust.
+ * src/scan-code-c.c, src/scan-code.l: We can no longer rely on
+ include "..." to find files "here": we are no longer in src/, so
+ qualify the includes with src/.
+ * doc/Makefile.am (PREPATH): No longer include the top_builddir
+ prefix.
+ (.x.1): Adjust to be able to create src/foo from the top level
+ Makefile, instead of going bounce to src/Makefile the creation of
+ foo.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Remove useless variable.
+ * doc/Makefile.am (srcsrcdir): Remove.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Remove data/Makefile.am.
+ * data/Makefile.am: Rename as...
+ * data/local.mk: this.
+ Adjust paths.
+ * Makefile.am, configure.ac: Adjust.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Remove etc/Makefile.am.
+ * etc/Makefile.am: Rename as...
+ * etc/local.mk: this.
+ Adjust.
+ * Makefile.am, configure.ac: Adjust.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Remove examples/local.mk.
+ examples/calc++/Makefile.am might be interesting to keep as is, since
+ it is an example in itself.
+
+ * examples/Makefile.am: Rename as...
+ * examples/local.mk: this.
+ Adjust.
+ * Makefile.am, configure.ac: Adjust.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Remove build-aux/Makefile.am.
+ Recursive Makefiles are really way too slow, let's get rid of some of
+ them.
+
+ * build-aux/Makefile.am: Rename as...
+ * build-aux/local.mk: this.
+ Adjust paths.
+ * Makefile.am, configure.ac: Adjust.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Provide convenience constructors for locations and positions.
+ * data/location.cc (position::position): Accept file, line and
+ column as arguments with default values.
+ Always qualify initial line and column literals as unsigned.
+ (location::location): Provide convenience constructors.
+
+2008-11-15 Akim Demaille <demaille@gostai.com>
+
+ Instead of using make_symbol<TOK_FOO>, generate make_FOO for each
+ token type.
+ Using template buys us nothing, and makes it uselessly complex to
+ construct a symbol. Besides, it could not be generalized to other
+ languages, while make_FOO would work in C/Java etc.
+
+ * data/lalr1.cc (b4_symbol_): New.
+ (b4_symbol): Use it.
+ (b4_symbol_constructor_declaration_)
+ (b4_symbol_constructor_definition_): Instead of generating
+ specializations of an overloaded template function, just generate
+ several functions whose names are forged from the token names
+ without the token.prefix.
+ (b4_symbol_constructor_declarations): Generate them for all the
+ symbols, not just by class of symbol type, now that instead of
+ specializing a function template by the token, we generate a
+ function named after the token.
+ (b4_symbol_constructor_specialization_)
+ (b4_symbol_constructor_specializations): Remove.
+ * etc/bench.pl.in: Adjust to this new API.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ %define token.prefix.
+ Provide a means to add a prefix to the name of the tokens as
+ output in the generated files. Because of name clashes, it is
+ good to have such a prefix such as TOK_ that protects from names
+ such as EOF, FILE etc. But it clutters the grammar itself.
+
+ * data/bison.m4 (token.prefix): Empty by default.
+ * data/c.m4 (b4_token_enum, b4_token_define): Use it.
+ * data/lalr1.cc (b4_symbol): Ditto.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Compute at M4 time some of the subtractions.
+ * data/lalr1.cc (b4_subtract): New.
+ (b4_rhs_data): Use it.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ symbol::token.
+ This allows the user to get the type of a token returned by yylex.
+
+ * data/lalr1.cc (symbol::token): New.
+ (yytoknum_): Define when %define lex_symbol, independently of
+ %debug.
+ (yytoken_number_): Move into...
+ (symbol::token): here, since that's the only use.
+ The other one is YYPRINT which was not officially supported
+ by lalr1.cc, and anyway it did not work since YYPRINT uses this
+ array under a different name (yytoknum).
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ YYERRCODE.
+ * TODO (YYERRCODE): Mention the case of $undef.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ TODO: YYPRINT.
+ * TODO (YYPRINT): New.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Comment changes.
+ * data/lalr1.cc, data/yacc.c: Fix the description of the
+ yytranslate and yytoknum tables.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Define make_symbol in the header.
+ To reach good performances these functions should be inlined (yet
+ this is to measure precisely). To this end they must be available
+ to the caller.
+
+ * data/lalr1.cc (b4_symbol_constructor_definition_): Qualify
+ location_type with the class name.
+ Since will now be output in the header, declare "inline".
+ No longer use b4_symbol_constructor_specializations, but
+ b4_symbol_constructor_definitions in the header.
+ Don't call it in the *.cc file.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Define yytranslate in the header for lex_symbol.
+ * data/lalr1.cc: Move the invocation of b4_yytranslate_definition
+ into the header file when using %define lex_symbol.
+ (yytranslate_): Declare inline.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Define the constructors of symbol_type in
+ b4_symbol_constructor_definitions.
+ The constructors are called by the make_symbol functions, which a
+ forthcoming patch will move elsewhere. Hence the interest of
+ putting them together.
+
+ The stack_symbol_type does not need to be moved, it is used only
+ by the parser.
+
+ * data/lalr1.cc: Move symbol_type and symbol_base_type
+ constructors into...
+ (b4_symbol_constructor_definitions): here.
+ Adjust.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Make it easier to move the definition of yytranslate_.
+ Forthcoming changes will make it possible to use yytranslate_
+ from outside the parser implementation file.
+
+ * data/lalr1.cc (b4_yytranslate_definition): New.
+ Use it.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Remove useless class specification.
+ * data/lalr1.cc (b4_symbol_constructor_specialization_): No need
+ to refer to the class name to use a type defined by the class for
+ arguments of member functions.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Finer input type for yytranslate.
+ This patch is debatable: the tradition expects yylex to return an int
+ which happens to correspond to token_number (which is an enum). This
+ allows for instance to return characters (such as '*' etc.). But this
+ goes against the stronger typing I am trying to have with the new
+ lex interface which return a symbol_type. So in this case, feed
+ yytranslate_ with a token_type.
+
+ * data/lalr1.cc (yytranslate_): When in %define lex-symbol,
+ expect a token_type.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Honor lex-params in %define lex_symbol mode.
+ * data/lalr1.cc: Use b4_lex_param.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Simplify names.
+ * src/output.c (symbol_definitions_output): Rename symbol
+ attributes type_name and has_type_name as type and has_type.
+ * data/lalr1.cc: Adjust uses.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Use b4_type_names for the union type.
+ The union used to compute the size of the variant used to iterate
+ over the type of all the symbols, with a lot of redundancy. Now
+ iterate over the lists of symbols having the same type-name.
+
+ * data/lalr1.cc (b4_char_sizeof_): New.
+ (b4_char_sizeof): Use it.
+ Adjust to be called with a list of numbers instead of a single
+ number.
+ Adjust its caller for new-line issues.
+
+2008-11-13 Akim Demaille <demaille@gostai.com>
+
+ Define the "identifier" of a symbol.
+ Symbols may have several string representations, for instance if
+ they have an alias. What I call its "id" is a string that can be
+ used as an identifier. May not exist.
+
+ Currently the symbols which have the "tag_is_id" flag set are
+ those that don't have an alias. Look harder for the id.
+
+ * src/output.c (is_identifier): Move to...
+ * src/symtab.c (is_identifier): here.
+ * src/symtab.h, src/symtab.c (symbol_id_get): New.
+ * src/output.c (symbol_definitions_output): Use it to define "id"
+ and "has_id".
+ Remove the definition of "tag_is_id".
+ * data/lalr1.cc: Use the "id" and "has_id" whereever "tag" and
+ "tag_is_id" were used to produce code.
+ We still use "tag" for documentation.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Locations are no longer required by lalr1.cc.
+ * data/lalr1.cc (_b4_args, b4_args): New.
+ Adjust all uses of locations to make them optional.
+ * tests/c++.at (AT_CHECK_VARIANTS): No longer use the locations.
+ (AT_CHECK_NAMESPACE): Check the use of locations.
+ * tests/calc.at (_AT_DATA_CALC_Y): Adjust to be usable with or
+ without locations with lalr1.cc.
+ Test these cases.
+ * tests/output.at: Check lalr1.cc with and without location
+ support.
+ * tests/regression.at (_AT_DATA_EXPECT2_Y, _AT_DATA_DANCER_Y):
+ Don't use locations.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ AT_FULL_COMPILE.
+ * tests/local.at (AT_FULL_COMPILE): New.
+ * tests/actions.at, tests/calc.at, tests/regression.at: Use it.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Support parens in calc++.
+ * doc/bison.texinfo (Calc++ Scanner, Calc++ Parser): Support parens.
+ * examples/calc++/test (run): Check the expected output.
+ Adjust callers.
+ Check parens too.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Simplify lalr1.cc since %defines is mandatory.
+ * data/lalr1.cc: Remove useless calls to b4_defines_if.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ TODO: yyfmt.
+ * TODO (yysyntax_error): New item.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Prefer M4 to CPP.
+ * data/lalr1.cc: Use b4_error_verbose_if instead of #if
+ YYERROR_VERBOSE.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Support i18n of the parse error messages.
+ * TODO (lalr1.cc/I18n): Remove.
+ * data/lalr1.cc (yysyntax_error_): Support the translation of the
+ error messages, as done in yacc.c.
+ Stay within the yy* pseudo namespace.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ More TODO.
+ * TODO (single stack, yysyntax_error): New.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Make it possible to return a symbol_type from yylex.
+ * data/lalr1.cc (b4_lex_symbol_if): New.
+ (parse): When lex_symbol is defined, expected yylex to return the
+ complete lookahead.
+ * etc/bench.pl.in (generate_grammar_list): Extend to support this
+ yylex interface.
+ (bench_variant_parser): Exercise it.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Remove useless bench case.
+ * etc/bench.pl.in (bench_variant_parser): VARIANT_DESTROY is
+ no longer used.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Improve display of directives.
+ * etc/bench.pl.in (parse_term): Don't add useless eol.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Use string_cast in the bench.
+ * etc/bench.pl.in (generate_grammar_list): Define and use
+ string_cast.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Replace yychar with a Boolean.
+ * data/lalr1.cc (parse::yychar): Replace by...
+ (parse::yyempty): this.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Factor the tables.
+ * TODO: New item.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Let yytranslate handle the eof case.
+ * data/lalr1.cc (yytranslate_): Handle the EOF case.
+ Adjust callers.
+ No longer expect yychar to be equal to yyeof_, rather, test the
+ lookahead's (translated) kind.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ yychar cannot be empty in yyerrlab.
+ * TODO (yychar == yyempty_): New.
+ * data/lalr1.cc: Remove the handling of this case.
+ This eases forthcoming changes related to yychar and yytranslate.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Bench: syntactic sugar for %define/#define.
+ * etc/bench.pl.in (parse_dirs): Support %d and #d with arguments.
+ (&bench_push_parser, bench_variant_parser): Use this feature.
+ (&eat): New.
+ Use it.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Less memory pressure on the "list" bench.
+ * etc/bench.pl.in (generate_grammar_list): Do not accumulate all
+ the values, to limit memory pressure.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Introduce make_symbol.
+ make_symbol provides a means to construct a full symbol (kind,
+ value, location) in a single shot. It is meant to be a Symbol
+ constructor, parameterized by the symbol kind so that overloading
+ would prevent incorrect kind/value pairs. Unfortunately
+ parameterized constructors do not work well in C++ (unless the
+ parameter also appears as an argument, which is not acceptable),
+ hence the use of a function instead of a constructor.
+
+ * data/lalr1.cc (b4_symbol_constructor_declaration_)
+ (b4_symbol_constructor_declarations)
+ (b4_symbol_constructor_specialization_)
+ (b4_symbol_constructor_specializations)
+ (b4_symbol_constructor_definition_)
+ (b4_symbol_constructor_definitions): New.
+ Use them where appropriate to generate declaration, declaration of
+ the specializations, and implementations of the templated
+ overloaded function "make_symbol".
+ (variant::variant): Always define a default ctor.
+ Also provide a copy ctor.
+ (symbol_base_type, symbol_type): New ctor overloads for value-less
+ symbols.
+ (symbol_type): Now public, so that functions such as yylex can use
+ it.
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Inform m4 whether a tag is a valid id.
+ * src/output.c (is_identifier): New.
+ (symbol_definitions_output): Use it to define tag_is_id.
+ But maybe this should be done at m4 level?
+
+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Test 214 was failing: it greps with a pattern containing [ ]*
+ which obviously meant to catch spaces and tabs, but contained only
+ spaces. Tabulations in sources are a nuisance, so to simplify the
+ matter, get rid of all the tabulations in the Java sources. The
+ other skeletons will be treated equally later.
+
+ * data/java.m4, data/lalr1.java: Untabify.
+ * tests/java.at: Simplify AT_CHECK_JAVA_GREP invocations:
+ tabulations are no longer generated.
+
+2008-11-11 Paolo Bonzini <bonzini@gnu.org>
+
+ * bootstrap.conf: Replace m4/warning.m4 with warnings module.
+ * configure.ac: Adjust usage.
+ * lib/Makefile.am: Replace $(WARNING_CFLAGS) with $(WARN_CFLAGS).
+ * src/Makefile.am: Replace $(WARNING_CFLAGS) with $(WARN_CFLAGS).
+ * tests/atlocal.in: Replace $(WARNING_*FLAGS) with $(WARN_*FLAGS).
+
+2008-11-10 Di-an Jan <dianj@freeshell.org>
+
+ Workaround Java's ``code too large'' problem for parser tables
+ in most cases, by using one function per initialization.
+ * data/java.m4 (b4_typed_parser_table, b4_integral_parser_table): New.
+ * data/lalr1.java (yypact_, yydefact_, yypgoto_, yydefgoto_,
+ yytable_, yycheck_, yystos_, yytoken_number_, yyr1_, yyr2_, yyrhs_
+ yyprhs_, yyrline_, yytranslate_table_): Use b4_integral_parser_table.
+ (yytname_): Use b4_typed_parser_table.
+ * doc/bison.texinfo (Java Bison Interface): Add note on Java's
+ ``code too large'' error.
+
+2008-11-10 Di-an Jan <dianj@freeshell.org>
+
+ * NEWS: Document them.
+
+ General Java skeleton improvements.
+ * configure.ac (gt_JAVACOMP): Request target of 1.4, which allows
+ using gcj < 4.3 in the testsuite, according to comments in
+ gnulib/m4/javacomp.m4.
+ * data/java.m4 (stype, parser_class_name, lex_throws, throws,
+ location_type, position_type): Remove extraneous brackets from
+ b4_percent_define_default.
+ (b4_lex_param, b4_parse_param): Remove extraneous brackets from
+ m4_define and m4_define_default.
+ * data/lalr1.java (b4_pre_prologue): Change to b4_user_post_prologue,
+ which marks the end of user code with appropriate syncline, like all
+ the other skeletons.
+ (b4_user_post_prologue): Add. Don't silently drop.
+ (yylex): Remove.
+ (parse): Inline yylex.
+ * doc/bison.texinfo (bisonVersion, bisonSkeleton): Document.
+ (%{...%}): Fix typo of %code imports.
+ * tests/java.at (AT_JAVA_COMPILE): Add "java" keyword.
+
+ Support annotations on parser class with %define annotations.
+ * data/lalr1.java (annotations): Add to parser class modifier.
+ * doc/bison.texinfo (Java Parser Interface): Document
+ %define annotations.
+ (Java Declarations Summary): Document %define annotations.
+ * tests/java.at (Java parser class modifiers): Test annotations.
+
+ Do not generate code for %error-verbose unless requested.
+ * data/lalr1.java (errorVerbose): Rename to yyErrorVerbose.
+ Make private. Make conditional on %error-verbose.
+ (getErrorVerbose, setErrorVerbose): New.
+ (yytnamerr_): Make conditional on %error-verbose.
+ (yysyntax_error): Make some code conditional on %error-verbose.
+ * doc/bison.texinfo (Java Bison Interface): Remove the parts
+ about %error-verbose having no effect.
+ (getErrorVerbose, setErrorVerbose): Document.
+
+ Move constants for token names to Lexer interface.
+ * data/lalr1.java (Lexer): Move EOF, b4_token_enums(b4_tokens) here.
+ * data/java.m4 (b4_token_enum): Indent for move to Lexer interface.
+ (parse): Qualify EOF to Lexer.EOF.
+ * doc/bison.texinfo (Java Parser Interface): Move documentation of
+ EOF and token names to Java Lexer Interface.
+ * tests/java.at (_AT_DATA_JAVA_CALC_Y): Remove Calc qualifier.
+
+ Make yyerror public.
+ * data/lalr1.java (Lexer.yyerror): Use longer parameter name.
+ (yyerror): Change to public. Add Javadoc comments. Use longer
+ parameter names. Make the body rather than the declarator
+ conditional on %locations.
+ * doc/bison.texinfo (yyerror): Document. Don't mark as protected.
+
+ Allow user to add code to the constructor with %code init.
+ * data/java.m4 (b4_init_throws): New, for %define init_throws.
+ * data/lalr1.java (YYParser.YYParser): Add b4_init_throws.
+ Add %code init to the front of the constructor body.
+ * doc/bison.texinfo (YYParser.YYParser): Document %code init
+ and %define init_throws.
+ (Java Declarations Summary): Document %code init and
+ %define init_throws.
+ * tests/java.at (Java %parse-param and %lex-param): Adjust grep.
+ (Java constructor init and init_throws): Add tests.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Update TODO.
+ * TODO (-D): is implemented.
+ (associativity): Same precedence must have the same associativity.
+ For instance, how can a * b / c be parsed if * is %left and / is
+ %right?
+ (YYERRORCODE, YYFAIL, YYBACKUP): New.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Formatting changes.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ More information about the symbols.
+ * src/output.c (type_names_output): Document all the symbols,
+ including those that don't have a type-name.
+ (symbol_definitions_output): Define "is_token" and
+ "has_type_name".
+ * data/lalr1.cc (b4_type_action_): Skip symbols that have an empty
+ type-name, now that they are defined too in b4_type_names.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Regen.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Make parser::yytranslate static.
+ Small speedup (1%) on the list grammar. And makes yytranslate_
+ available in non member functions.
+
+ * data/lalr1.cc (yytranslate_): Does not need to be a instance
+ function.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Avoid trailing spaces.
+ * data/c.m4: b4_comment(TEXT): Don't indent empty lines.
+ * data/lalr1.cc: Don't indent before rule and symbol actions, as
+ they can be empty, and anyway this incorrectly indents the first
+ action.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Comment changes.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Use "enum" for integral constants.
+ This is just nicer to read, I observed no speedup.
+
+ * data/lalr1.cc (yyeof_, yylast_, yynnts_, yyempty_, yyfinal_)
+ (yterror_, yyerrcode_, yyntokens_): Define as members of an enum.
+ (yyuser_token_number_max_, yyundef_token_): Move into...
+ (yytranslate_): here.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Shortcuts in bench directives.
+ * etc/bench.pl.in (parse_dirs): New.
+ Use it.
+ (bench_variant_parser, bench_fusion_parser): Use %s and %d.
+ Create the benches in "benches/".
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Formatting changes.
+ * data/lalr1.cc: here.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Adjust verbose message to using emacs.
+ * etc/bench.pl.in: Inform compilation-mode when we change the
+ directory.
+ (generate_grammar_list): Recognize %define "variant" in addition
+ to %define variant.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Classify symbols by type-name.
+ * src/uniqstr.h (UNIQSTR_CMP): New.
+ * src/output.c (symbol_type_name_cmp, symbols_by_type_name)
+ (type_names_output): New.
+ (muscles_output): Use it.
+ * data/lalr1.cc (b4_symbol_action_): Remove.
+ (b4_symbol_case_, b4_type_action_): New.
+ Adjust uses of b4_symbol_action_ to use b4_type_action_.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Change the handling of the symbols in the skeletons.
+ Before we were using tables which lines were the symbols and which
+ columns were things like number, tag, type-name etc. It is was
+ difficult to extend: each time a column was added, all the numbers had
+ to be updated (you asked for colon $2, not for "tag"). Also, it was
+ hard to filter these tables when only a subset of the symbols (say the
+ tokens, or the nterms, or the tokens that have and external number
+ *and* a type-name) was of interest.
+
+ Now instead of monolithic tables, we define one macro per cell. For
+ instance "b4_symbol(0, tag)" is a macro name which contents is
+ self-decriptive. The macro "b4_symbol" provides easier access to
+ these cells.
+
+ * src/output.c (type_names_output): Remove.
+ (symbol_numbers_output, symbol_definitions_output): New.
+ (muscles_output): Call them.
+ (prepare_symbols): Define b4_symbols_number.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ --trace=muscles
+ * src/getargs.h, src/getargs.c (trace_muscle): New.
+ (trace_types, trace_args): Support it.
+ * src/output.c (output_skeleton): Use it.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ muscles_output.
+ * src/output.c (muscles_output): New, extracted from...
+ (output_skeleton): here.
+ Adjust.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Formatting changes.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Update the variant example.
+ * examples/variant.yy: Formatting changes.
+ One stage build.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Support constructor with an argument.
+ This improves the "list" bench by 2%.
+
+ * data/lalr1.cc (variant::build): Add an overloaded version with
+ an argument.
+ * tests/c++.at (AT_CHECK_VARIANT): Check it.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Test variants.
+ * tests/c++.at (AT_CHECK_VARIANTS): New.
+ Use it with and without %define assert.
+
+2008-11-10 Akim Demaille <demaille@gostai.com>
+
+ Add %precedence support.
+ Unfortunately it is not possible to reuse the %prec directive. This
+ is because to please POSIX, we do not require to end the rules with a
+ semicolon. As a result,
+
+ foo: bar %prec baz
+
+ is ambiguous: either a rule which precedence is that of baz, or a rule,
+ and then a declaration of the precedence of the token baz.
+
+ * doc/bison.texinfo: Document %precedence.
+ (Precedence Only): New.
+ * src/assoc.h, src/assoc.c (precedence_assoc): New.
+ * src/conflicts.c (resolve_sr_conflict): Support it.
+ * src/scan-gram.l, src/parse-gram.y (%precedence): New token.
+ Parse it.
+ * tests/calc.at: Use %precedence for NEG.
+ * tests/conflicts.at (%precedence does not suffice)
+ (%precedence suffices): New tests.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Make benches in a sub dirs.
+ * etc/bench.pl.in ($dir): New.
+ Use it.
+ Check the use of constructors with an argument.
+ (bench_variant_parser): Fix.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ fix eof condition
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Fix --help.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Require the generation of parse-gram.output.
+ * src/Makefile.am (YACC): Pass --report=all.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Formatting changes.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Update TODO.
+ * TODO: Remove obsolete items.
+ Update others.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Enhance bench.pl.
+ * etc/bench.pl.in (parse, parse_expr, parse_term, parse_fact)
+ (@token, $grammar, $bench): New.
+ (generate_grammar_variant): Rename as...
+ (generate_grammar_list): this.
+ (generate_grammar): Adjust.
+ (bench_grammar): Rename as...
+ (bench): this.
+ Use it in the various bench-marking routines.
+ (-b, -g): New options.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Use a static hierarchy for symbols in the C++ parser.
+ * data/lalr1.cc (symbol_base_type, symbol_type)
+ (stack_symbol_type): Make it a static hierarchy.
+ Adjust dependencies.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ bench.pl -d, --directive.
+ * etc/bench.pl.in (@directive): New.
+ (&bench_grammar): Use it.
+ (&bench_list_grammar): New, to provide access to the "variant"
+ grammar.
+ Use it.
+ (getopts): Support -d, --directive.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Use inline for small operations.
+ * data/lalr1.cc (symbol_base_type, symbol_type)
+ (stack_symbol_type): Declare constructor and other operations as
+ inline.
+ (yy_destroy_): Inline.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Introduce a hierarchy for symbols.
+ * data/lalr1.cc (symbol_base_type, symbol_type): New.
+ (data_type): Rename as...
+ (stack_symbol_type): this.
+ Derive from symbol_base_type.
+ (yy_symbol_value_print_): Merge into...
+ (yy_symbol_print_): this.
+ Rename as...
+ (yy_print_): this.
+ (yydestruct_): Rename as...
+ (yy_destroy_): this.
+ (b4_symbols_actions, YY_SYMBOL_PRINT): Adjust.
+ (parser::parse): yyla is now of symbol_type.
+ Use its type member instead of yytoken.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Rename data_type and stack_symbol_type.
+ * data/lalr1.cc (data_type): Rename as...
+ (stack_symbol_type): this.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Handle semantic value and location together.
+ * data/lalr1.cc (b4_symbol_actions): Bounce $$ and @$ to
+ yydata.value and yydata.location.
+ (yy_symbol_value_print_, yy_symbol_print_, yydestruct_)
+ (YY_SYMBOL_PRINT): Now take semantic value and location as a
+ single arg.
+ Adjust all callers.
+ (yydestruct_): New overload for a stack symbol.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Push a complete symbol, not connected parts.
+ * data/lalr1.cc (yypush_): Take a data_type&, not disconnected
+ state, value and location.
+ Adjust callers.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Agregate yylval and yylloc.
+ * data/lalr1.cc (parser::yylval, parser::yylloc): Replace by...
+ (parser::yyla): this.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Rely on the state stack to display reduction traces.
+ To display rhs symbols before a reduction, we used information
+ about the rule reduced, which required the tables yyrhs and
+ yyprhs. Now use rely only on the state stack to get the same
+ information.
+
+ * data/lalr1.cc (b4_rhs_data, b4_rhs_state): New.
+ Use them.
+ (parser::yyrhs_, parser::yyprhs_): Remove.
+ (parser::yy_reduce_print_): Use the state stack.
+
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Fuse yyval and yyloc into yylhs.
+ * data/lalr1.cc (b4_lhs_value, b4_lhs_location): Adjust to using
+ yylhs.
+ (parse): Replace yyval and yyloc with yylhs.value and
+ yylhs.location.
+ After a user action, compute yylhs.state earlier.
+ (yyerrlab1): Do not play tricks with yylhs.location, rather, use a
+ fresh error_token.
+
+2008-11-09 Di-an Jan <dianj@freeshell.org>
+
+ Remove unused variable.
+ * src/output.c (type_names_output): Remove unused variable sep.
+
+2008-11-09 Paolo Bonzini <bonzini@gnu.org>
+
+ Change tests/output.at quoting.
+ * tests/output.at (AT_CHECK_OUTPUT): Use conventional m4 quoting when
+ expanding arguments.
+
+2008-11-07 Joel E. Denny <jdenny@ces.clemson.edu>
+
+ Don't add a semicolon to actions for %skeleton or %language.
+ It breaks Java test cases as reported by Akim Demaille.
+ * src/scan-code.l: Implement.
+
+2008-11-07 Joel E. Denny <jdenny@ces.clemson.edu>
+
+ Clean up %skeleton and %language priority implementation.
+ * src/getargs.c (skeleton_prio): Use default_prio rather than 2, and
+ remove static qualifier because others will soon need to see it.
+ (language_prio): Likewise.
(getargs): Use command_line_prio rather than 0.
* src/getargs.h (command_line_prio, grammar_prio, default_prio): New
enum fields.
(language_prio): Extern it.
* src/parse-gram.y: Use grammar_prio rather than 1.
-2008-11-04 Akim Demaille <demaille@gostai.com>
+2008-11-07 Akim Demaille <demaille@gostai.com>
- * NEWS: Mention the trailing semicolon in action.
+ Moving push traces into yypush_.
+ * data/lalr1.cc (yypush_): Now takes a optional trace message.
+ Adjust all uses.
-2008-11-04 Akim Demaille <demaille@gostai.com>
+2008-11-07 Akim Demaille <demaille@gostai.com>
- Reformat NEWS.
- * NEWS: Use more outline-mode markup.
- Suggested by Jim Meyering.
+ The single-stack C++ parser is now the standard one.
+ * data/lalr1.cc: Rename as...
+ * data/lalr1-split.cc: this.
+ * data/lalr1-fusion.cc: Rename as...
+ * data/lalr1.cc: this.
+ * etc/bench.pl.in: Adjust.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ Avoid empty-if warnings.
+ Reported by Quentin Hocquet.
+
+ * data/lalr1-fusion.cc (YY_SYMBOL_PRINT, YY_REDUCE_PRINT)
+ (YY_STACK_PRINT): Provide some contents even when !YYDEBUG.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ Pass command line location to skeleton_arg and language_argmatch.
+ * src/getargs.h, src/getargs.c (skeleton_arg, language_argmatch):
+ The location argument is now mandatory.
+ Adjust all dependencies.
+ (getargs): Use command_line_location.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ -D, --define.
+ * src/getargs.c (usage): Document -D.
+ Fix help string for --locations.
+ (command_line_location): New.
+ (short_options, long_options, getargs): Support -D, --define.
+ (getargs): Move -d support at the right place.
+ * doc/bison.texinfo (Bison Options): Update.
+ * tests/input.at (%define, --define): New.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ Initialize the muscle table before parsing the command line.
+ * src/getargs.c (quotearg.h, muscle_tab.h): Include.
+ (getargs): Define file_name.
+ * src/main.c (main): Initialize muscle_tab before calling
+ getargs.
+ * src/muscle_tab.c (muscle_init): No longer define file_name, as
+ its value is not available yet.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ Locations without columns for command line arguments.
+ * src/location.c (location_print): Don't display negative columns.
+ * src/location.h: Document this.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ Fix --help.
+ * src/getargs.c (usage): Fix help string for -W.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ Handle more general types of option arguments.
+ * build-aux/cross-options.pl: The argument ends at the first
+ space, not the first non-symbol character.
+ Use @var for each word appearing the argument description.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ Destroy the variants that remain on the stack in case of error.
+ * data/lalr1-fusion.cc (yydestruct_): Invoke the variant's
+ destructor.
+ Display the value only if yymsg is nonnull.
+ (yyreduce): Invoke yydestruct_ when popping lhs symbols.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ Add "%define assert" to variants.
+ This is used to help the user catch cases where some value gets
+ ovewritten by a new one. This should not happen, as this will
+ probably leak.
+
+ Unfortunately this uncovered a bug in the C++ parser itself: the
+ lookahead value was not destroyed between two calls to yylex. For
+ instance if the previous lookahead was a std::string, and then an int,
+ then the value of the std::string was correctly taken (i.e., the
+ lookahead was now an empty string), but std::string structure itself
+ was not reclaimed.
+
+ This is now done in variant::build(other&) (which is used to take the
+ value of the lookahead): other is not only stolen from its value, it
+ is also destroyed. This incurs a new performance penalty of a few
+ percent, and union becomes faster again.
+
+ * data/lalr1-fusion.cc (variant::build(other&)): Destroy other.
+ (b4_variant_if): New.
+ (variant::built): New.
+ Use it whereever the status of the variant changes.
+ * etc/bench.pl.in: Check the penalty of %define assert.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ Use "%define variant" in bench.pl.
+ * etc/bench.pl.in: No longer use the pseudo directive %variants,
+ just use %define variants.
+
+2008-11-07 Akim Demaille <demaille@gostai.com>
+
+ Regen.
+ * src/parse-gram.h, src/parse-gram.c: Regen.
2008-11-04 Joel E. Denny <jdenny@ces.clemson.edu>
* tests/regression.at (Fix user actions without a trailing semicolon):
New test case.
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Use b4_copyright_years.
+ * data/yacc.c (b4_copyright_years): New.
+ Fix its value according to the comments in the file.
+ Use it and undefine it.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Formatting changes.
+ * data/lalr1-fusion.cc, src/parse-gram.y: here.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Formatting changes.
+ * data/lalr1-fusion.cc: here.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Use strict on bench.pl.
+ * etc/bench.pl.in (&run, &generate_grammar): New.
+ Rename the grammar generating functions for consistency.
+ Change the interface so that the list of benches to run is passed
+ as (optionless) arguments.
+ (&compile): Use &run.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Remove spurious initial empty lines.
+ * data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java,
+ * data/yacc.c: End the @output lines with an @.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Improve the display of sizes.
+ * etc/bench.p.in: Higher precision.
+ Sort by decreasing size.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Don't memcpy C++ structures.
+ * data/lalr1-fusion.cc (b4_symbol_variant): Adjust additional
+ arguments.
+ (variant::build): New overload for
+ copy-construction-that-destroys.
+ (variant::swap): New.
+ (parser::yypush_): Use it in variant mode.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Better defaults for bench.pl.
+ * etc/bench.pl.in ($verbose, $cflags, $iterations): Change the
+ default values.
+ Adjust &verbose uses.
+ (-q, --quiet): New.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Make variant.yy more complex.
+ std::list cannot be copied via memcpy, they are more demanding than
+ std::string. Use one std::list to strengthen the test.
+
+ * examples/variant.yy: Use lalr1-fusion.cc, not lalr1.cc.
+ Adjust.
+ Create a list of strings, instead of a single large string.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ bench.pl --bench.
+ * etc/bench.pl.in (--bench, $bench): New.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Sort methods.
+ * data/lalr1-fusion.cc (destroy): Use as() in its definition.
+ Define it after as().
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Useless parens.
+ * data/lalr1-fusion.cc (b4_rhs_location): Remove useless parens.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Issue missing synclines after user actions.
+ * data/c.m4 (b4_case): Issue synclines on the output file.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Remove trailing empty line.
+ * data/lalr1-fusion.cc: Don't add an empty line after the user's
+ epilogue.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Fix output of copyright years.
+ * data/bison.m4 (b4_copyright): Fix the indentation of the
+ copyright year paragraph.
+ Use b4_copyright_years when no years are given.
+ * data/lalr1.cc, data/lalr1-fusion.cc, data/location.cc
+ (b4_copyright_years): New.
+ Use it.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Avoid the spurious initial empty line.
+ * data/lalr1-fusion.cc, data/location.cc: Put a trailing "@" at
+ the end of @output request to suppress the empty line that
+ results.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Remove parser::rhs_number_type.
+ * data/lalr1-fusion.cc (rhs_number_type): No longer define it.
+ (yyrhs_): Use b4_table_define.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Fix iteration type.
+ * data/lalr1-fusion.cc: Use an int to iterate up to an int.
+
+2008-11-04 Akim Demaille <demaille@gostai.com>
+
+ Factor the declaration of the integer tables.
+ * data/lalr1-fusion.cc (b4_table_define): New.
+ Use it.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Fix indentation of tables in lalr1.cc
+ * data/lalr1-fusion.cc: Fix the indentation.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Destroy the lhs symbols after reduction.
+ * data/lalr1-fusion.cc (parse): After the user action, when in
+ variant mode, destroy the lhs symbols.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Simplify yysyntax_error_ use.
+ * data/lalr1-fusion.cc (yysyntax_error_): Always pass it the token
+ type, but make it unnamed in the declaration when it is not used.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Let yy::variant::build return an lvalue.
+ * data/lalr1-fusion.cc (variant::build): Return a reference to the
+ object.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Define yy::variant only when needed.
+ * data/lalr1-fusion.cc (yy::variant): Define only if variants are
+ used.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Bench the three-stack lalr1.cc.
+ * etc/bench.pl.in: Bench the three-stack lalr1.cc vs. the
+ one-stack one.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Fail on parse error in calc++.
+ * doc/bison.texinfo (calc++.cc): Propagate failures to the exit
+ status.
+ * examples/calc++/test ($me, $number, $exit, run): New.
+ Use them to propagate errors to the exit status.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Don't specify the skeleton twice in the example.
+ * examples/calc++/Makefile.am: Don't pass -S to Bison, the grammar
+ file does what is needed.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ bench: Improve output.
+ * etc/bench.pl.in (bench_grammar): Tune the printf format.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ bench: check impact of %debug on variants.
+ * etc/bench.pl.in (variant_grammar): Fix the computation of
+ $variant.
+ Generate a grammar file that can work with or without %debug.
+ Do use the @directive.
+ (bench_variant_parser): Check impact of %debug.
+ (@directives): Rename all the occurrences to...
+ (@directive): this, for consistency.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ bench: report the size too.
+ * etc/bench.pl.in ($iterations): Defaults to -3.
+ (&bench_grammar): Require hireswallclock.
+ Compute and display the size of the result.
+ More comments.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ bench: More use of the verbosity level.
+ * etc/bench.pl.in ($verbose, &verbose): New.
+ Use them.
+ More POD documentation.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ bench.pl: a command line interface
+ * etc/bench.pl.in: More doc.
+ Some fixes in the documentation.
+ ($cflags, $iterations, &help, &getopt): New.
+ Use them.
+ (&variant_grammar): Let the number of stages be 10 times what is
+ specified.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Bench the use of Boost.Variants.
+ * etc/bench.pl.in ($cxx, &variant_grammar, &bench_variant_parser):
+ New.
+ (&compile): Be ready to compile C++ parsers.
+ (&bench_push_parser): Move debug information to the outermost
+ level.
+ * THANKS: Add Michiel De Wilde.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ bench.pl: Pass directives as a list instead of as a string.
+ * etc/bench.pl.in (&directives): New.
+ (&triangular_grammar, &calc_grammar): Use it to format the Bison
+ directives.
+ (&triangular_grammar): Do use the directives (were ignored).
+ (&bench_grammar, &bench_push_parser): Adjust to pass lists of
+ directives.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Improve genericity of bench.pl.
+ * etc/bench.pl.in (&bench_grammar): Take the set of benches as
+ argument.
+ (&bench_push_parser): New.
+ Call it.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Add documentation to bench.pl.
+ * etc/bench.pl.in: Comment changes.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Fuse the three stacks into a single one.
+
+ In order to make it easy to perform benchmarks to ensure that
+ there are no performance loss, lalr1.cc is forked into
+ lalr1-fusion.cc. Eventually, lalr1-fusion.cc will replace
+ lalr1.cc.
+
+ Meanwhile, to make sure that lalr1-fusion.cc is correctly
+ exercized by the test suite, the user must install a symbolic link
+ from lalr1.cc to it.
+
+ Instead of having three stacks (state, value, location), use a
+ stack of triples. This considerably simplifies the code (and it
+ will be easier not to require locations as currently does the C++
+ parser), and also gives a 10% speedup according to
+ etc/bench (probably mainly since memory allocation is done once
+ instead of three times).
+
+ Another motivation is to make it easier to destruct properly
+ semantic values: now that they are bound to their state (hence
+ symbol type) it will be easier to call the appropriate destructor.
+
+ These changes should probably benefit the C parser too.
+
+ * data/lalr1.cc: Copy as...
+ * data/lalr1-fusion.cc: this new file.
+ (b4_rhs_value, b4_rhs_location): New definitions overriding those
+ from c++.m4.
+ (state_stack_type, semantic_stack_type, location_stack_type)
+ (yystate_stack_, yysemantic_stack_, yylocation_stack_): Remove.
+ (data_type, stack_type, yystack_): New.
+ (YYLLOC_DEFAULT, yypush_): Adjust.
+ (yyerror_range): Now based on data_type, not location_type.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Push the state, value, and location at the same time.
+ This is needed to prepare a forthcoming patch that fuses the three
+ stacks into one.
+
+ * data/lalr1.cc (parser::yypush_): New.
+ (parser::yynewstate): Change the semantics: instead of arriving to
+ this label when value and location have been pushed, but yystate
+ is to be pushed on the state stack, now the three of them must
+ have been pushed before. yystate still must be the new state.
+ This allows to use yypush_ everywhere instead of individual
+ handling of the stacks.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Prefer references to pointers.
+ * data/lalr1.cc (b4_symbol_actions): New, overrides the default C
+ definition to use references instead of pointers.
+ (yy_symbol_value_print_, yy_symbol_print_, yydestruct_):
+ Take the value and location as references.
+ Adjust callers.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ stack::size instead of stack::height.
+ * data/lalr1.cc (stack::height): Rename as...
+ (stack::size): this.
+ Fix the output type.
+ Comment changes.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Use variants to support objects as semantic values.
+ This patch was inspired by work by Michiel De Wilde. But he used
+ Boost variants which (i) requires Boost on the user side, (ii) is
+ slow, and (iii) has useless overhead (the parser knows the type of
+ the semantic value there is no reason to duplicate this
+ information as Boost.Variants do).
+
+ This implementation reserves a buffer large enough to store the
+ largest objects. yy::variant implements this buffer. It was
+ implemented with Quentin Hocquet.
+
+ * src/output.c (type_names_output): New.
+ (output_skeleton): Invoke it.
+ * data/c++.m4 (b4_variant_if): New.
+ (b4_symbol_value): If needed, provide a definition for variants.
+ * data/lalr1.cc (b4_symbol_value, b4_symbol_action_)
+ (b4_symbol_variant, _b4_char_sizeof_counter, _b4_char_sizeof_dummy)
+ (b4_char_sizeof, yy::variant): New.
+ (parser::parse): If variants are requested, define
+ parser::union_type, parser::variant, change the definition of
+ semantic_type, construct $$ before running the user action instead
+ of performing a default $$ = $1.
+ * examples/variant.yy: New.
+ Based on an example by Michiel De Wilde.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Parameterize the extraction of semantic values.
+ To make future changes easier, no longer rely on ".TYPE" being the
+ way to get a semantic value.
+
+ * data/c.m4 (b4_symbol_value): New.
+ Use it.
+ * data/c++.m4, data/yacc.c: Use it.
+ * data/glr.c: Use b4_symbol_value.
+ (b4_rhs_data): New.
+ Use it.
+
+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ Prepare easier M4 changes.
+ * data/lalr1.cc: Use escaped [] instead of literals to prepare
+ future changes.
+
2008-11-02 Joel E. Denny <jdenny@ces.clemson.edu>
Initiate further development.
-## Process this file with automake to produce Makefile.in -*-Makefile-*-
-
-## Copyright (C) 2001-2012 Free Software Foundation, Inc.
+## Process this file with automake to produce Makefile.in.
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = build-aux po runtime-po lib data src doc examples tests etc
+SUBDIRS = po runtime-po .
# Files installed for use by Automake.
aclocaldir = @aclocaldir@
aclocal_DATA = m4/bison-i18n.m4
EXTRA_DIST = .prev-version .version \
- 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
+ cfg.mk ChangeLog-1998 ChangeLog-2012 PACKAGING
+
+## Running the bison from this tarball. To generate our own parser,
+## but also to run the tests. Of course, you ought to keep a sane
+## version of Bison nearby...
+BISON = $(top_builddir)/tests/bison
+BISON_IN = $(top_srcdir)/tests/bison.in
+YACC = $(BISON) -y
+AM_YFLAGS = -d -v --warnings=all,error --report=all
+
+# 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 =
-MAINTAINER_CHECKS = \
- maintainer-check \
- maintainer-push-check \
- maintainer-xml-check \
- maintainer-release-check
-.PHONY: $(MAINTAINER_CHECKS)
-$(MAINTAINER_CHECKS):
- $(AM_V_GEN)cd tests && $(MAKE) $(AM_MAKEFLAGS) $@
+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
# on configure so that .version and VERSION/PACKAGE_VERSION stay in sync in the
# 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
# pass incorrectly.
-BUILT_SOURCES = $(top_srcdir)/.version
+BUILT_SOURCES += $(top_srcdir)/.version
$(top_srcdir)/.version: configure
- $(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
+ echo $(VERSION) > $@-t && mv $@-t $@
dist-hook: gen-ChangeLog
- $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
+ echo $(VERSION) > $(distdir)/.tarball-version
.PHONY: update-b4-copyright update-package-copyright-year
update-b4-copyright:
- $(AM_V_GEN) find data -type f \
- | grep -v -E '^data/bison.m4$$' \
+ find data -type f \
+ | grep -v -E '^data/bison.m4$$' \
| xargs $(build_aux)/$@
@echo 'warning: src/parse-gram.[hc] may need to be regenerated.'
update-package-copyright-year:
- $(AM_V_GEN)$(build_aux)/$@ configure.ac
+ $(build_aux)/$@ configure.ac
gen_start_date = 2012-01-16
.PHONY: gen-ChangeLog
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Incompatible changes
+
+*** Obsolete features
+
+ Support for YYFAIL is removed (deprecated in Bison 2.4.2).
+ Support for yystype and yyltype (instead of YYSTYPE and YYLTYPE)
+ is removed (deprecated in Bison 1.875).
+ Support for YYPARSE_PARAM is removed (deprecated in Bison 1.875).
+
+** Warnings
+
+*** 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
+
+** 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
+
+ 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).
+
+** 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).
+
+** 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
+
+** 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
+
+ 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.
+
+* Noteworthy changes in release ?.? (????-??-??) [?]
+
+** %language is no longer an experimental feature.
+
+ The introduction of this feature, in 2.4, was four years ago. The --language
+ option and the %language directive are no longer experimental.
+
** Bug fixes
Warnings about uninitialized yylloc in yyparse have been fixed.
* Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
- Bison no longer executes user-specified M4 code when processing a grammar.
+ Bison no longer executes user-specified M4 code when processing a grammar.
** Future Changes
* 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
deprecated features. Please report disagreements to bug-bison@gnu.org.
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
- LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp calc yyo fval Wmaybe
- LocalWords: yyvsp pragmas noreturn java's
+ LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp Wother nterm arg init
+ LocalWords: TOK calc yyo fval Wconflicts
Local Variables:
mode: outline
(comparable to assert/abort), and all the --trace output which is
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
** make check
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
If the test suite shows failures such as the following one
that it does not make sense for glr.c, which should be ANSI, but
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
This section needs to be updated to take into account features from
and Systems (TOPLAS) 4, 4 (October 1982), 615-649. Their
technique is the standard one now.)
- paul rubin
- free software foundation
+ paul rubin
+ free software foundation
[DeRemer-Pennello reference corrected by Paul Eggert <eggert@cs.ucla.edu>,
Matt Rosing rosing@peakfive.com
Michael Hayes m.hayes@elec.canterbury.ac.nz
Michael Raskin 7c6f434c@mail.ru
+Michiel De Wilde mdewilde.agilent@gmail.com
Mickael Labau labau_m@epita.fr
Mike Castle dalgoda@ix.netcom.com
Neil Booth NeilB@earthling.net
Peter Hamorsky hamo@upjs.sk
Peter Simons simons@cryp.to
Piotr Gackiewicz gacek@intertel.com.pl
+Quentin Hocquet hocquet@gostai.com
Quoc Peyrot chojin@lrde.epita.fr
R Blake blakers@mac.com
Raja R Harinath harinath@cs.umn.edu
Also, the underscore in print_graph.[ch] isn't very fitting considering
the dashes in the other filenames.
+** push-parser
+Check it too when checking the different kinds of parsers. And be
+sure to check that the initial-action is performed once per parsing.
+
+** m4 names
+b4_shared_declarations is no longer what it is. Make it
+b4_parser_declaration for instance.
+
+** yychar in lalr1.cc
+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);
+
+
+** $ and others in epilogue
+A stray $ is a warning in the actions, but an error in the epilogue.
+IMHO, it should not even be a warning in the epilogue.
+
+** 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.
+
** Variable names.
What should we name `variant' and `lex_symbol'?
-** Use b4_symbol in all the skeleton
-Move its definition in the more standard places and deploy it in other
-skeletons. Then remove the older system, including the tables
-generated by output.c
-
-** Update the documentation on gnu.org
-
** Get rid of fake #lines [Bison: ...]
Possibly as simple as checking whether the column number is nonnegative.
Enhance bench.pl with %b to run different bisons.
* Various
-** Warnings
-Warnings about type tags that are used in printer and dtors, but not
-for symbols?
-
** YYERRCODE
Defined to 256, but not used, not documented. Probably the token
number for the error token, which POSIX wants to be 256, but which
"\"end of command\"", "error", "$undefined", "\"=\"", "\"break\"",
-** YYFAIL
-It is seems to be *really* obsolete now, shall we remove it?
-
** yychar == yyempty_
The code in yyerrlab reads:
getopt-gnu
gettext git-version-gen gitlog-to-changelog
gpl-3.0 hash inttypes isnan javacomp-script
- javaexec-script ldexpl malloc-gnu mbschr mbsrchr
+ javaexec-script ldexpl malloc-gnu
mbswidth
+ non-recursive-gnulib-prefix-hack
obstack
obstack-printf
perror progname
spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp
unistd unistd-safer unlocked-io update-copyright unsetenv verify
warnings
- xalloc xalloc-die xmemdup0 xstrndup
+ xalloc
+ xalloc-die
+ xconcat-filename
+ xmemdup0
+ xstrndup
fprintf-posix printf-posix snprintf-posix sprintf-posix
vsnprintf-posix vsprintf-posix
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
--from-code=UTF-8\\\
--flag=asprintf:2:c-format\\\
- --flag=complain:1:c-format --flag=complain_at:2: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=complain:3:c-format\\\
+ --flag=complain_indent:4:c-format\\\
--flag=unexpected_end:2:c-format\\\
'
XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
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.
test -f ChangeLog || touch ChangeLog
}
-/Makefile
-/Makefile.in
/announce-gen
/arg-nonnull.h
/c++defs.h
/compile
/config.guess
/config.rpath
+/config.rpath~
/config.sub
/depcomp
/do-release-commit-and-tag
/link-warning.h
/mdate-sh
/missing
+/test-driver
/texinfo.tex
/update-copyright
/useless-if-before-free
/vc-list-files
/warn-on-use.h
/ylwrap
+/prefix-gnulib-mk
+++ /dev/null
-## Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-EXTRA_DIST = \
- cross-options.pl \
- darwin11.4.0.valgrind \
- prev-version.txt \
- update-b4-copyright
\s # Spaces.
/x)
{
- my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
- $short = '' if ! defined $short;
- $short = '-d' if $long eq '--defines' && ! $short;
- my $dir = '%' . substr($long, 2);
- if (index ($scanner, "\"$dir\"") < 0)
- {
- if ($long eq '--force-define') { $dir = '%define'; }
- else { $dir = ''; }
- }
- if ($arg)
- {
+ my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
+ $short = '' if ! defined $short;
+ $short = '-d' if $long eq '--defines' && ! $short;
+ my $dir = '%' . substr($long, 2);
+ if (index ($scanner, "\"$dir\"") < 0)
+ {
+ if ($long eq '--force-define') { $dir = '%define'; }
+ else { $dir = ''; }
+ }
+ if ($arg)
+ {
# if $opt, $arg contains the closing ].
substr ($arg, -1) = ''
if $opt eq '[';
- $arg =~ s/^=//;
+ $arg =~ s/^=//;
$arg = lc ($arg);
- my $dir_arg = $arg;
+ my $dir_arg = $arg;
# If the argument is compite (e.g., for --define[=NAME[=VALUE]]),
# put each word in @var, to build @var{name}[=@var{value}], not
# @var{name[=value]}].
- $arg =~ s/(\w+)/\@var{$1}/g;
- my $long_arg = "=$arg";
- if ($opt eq '[') {
- $long_arg = "[$long_arg]";
- $arg = "[$arg]";
- }
- # For arguments of directives: this only works if all arguments
- # are strings and have the same syntax as on the command line.
- if ($dir_arg eq 'name[=value]')
- {
- $dir_arg = '@var{name} ["@var{value}"]';
- }
- else
- {
- $dir_arg =~ s/(\w+)/\@var{"$1"}/g;
- $dir_arg = '[' . $dir_arg . ']'
- if $opt eq '[';
- }
- $long = "$long$long_arg";
- $short = "$short $arg" if $short && $short ne '-d';
- $dir = "$dir $dir_arg" if $dir;
- }
- $option{$long} = $short;
- $directive{$long} = $dir;
+ $arg =~ s/(\w+)/\@var{$1}/g;
+ my $long_arg = "=$arg";
+ if ($opt eq '[') {
+ $long_arg = "[$long_arg]";
+ $arg = "[$arg]";
+ }
+ # For arguments of directives: this only works if all arguments
+ # are strings and have the same syntax as on the command line.
+ if ($dir_arg eq 'name[=value]')
+ {
+ $dir_arg = '@var{name} ["@var{value}"]';
+ }
+ else
+ {
+ $dir_arg =~ s/(\w+)/\@var{"$1"}/g;
+ $dir_arg = '[' . $dir_arg . ']'
+ if $opt eq '[';
+ }
+ $long = "$long$long_arg";
+ $short = "$short $arg" if $short && $short ne '-d';
+ $dir = "$dir $dir_arg" if $dir;
+ }
+ $option{$long} = $short;
+ $directive{$long} = $dir;
}
}
--- /dev/null
+## Makefile for Bison testsuite.
+
+# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+EXTRA_DIST += \
+ build-aux/cross-options.pl \
+ build-aux/darwin11.4.0.valgrind \
+ build-aux/move-if-change \
+ build-aux/prev-version.txt \
+ build-aux/update-b4-copyright
--- /dev/null
+../gnulib/build-aux/move-if-change
\ No newline at end of file
ftp://$(gnu_rel_host)/gnu/bison
# 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 = \
- changelog-check \
+local-checks-to-skip = \
sc_immutable_NEWS \
- sc_prohibit_always_true_header_tests \
- sc_prohibit_atoi_atof \
- sc_prohibit_strcmp
+ sc_prohibit_atoi_atof
# The local directory containing the checked-out copy of gnulib used in
# this release. Used solely to get a date for the "announcement" target.
prohibit_doubled_word=^tests/named-refs.at$$ \
prohibit_magic_number_exit=^doc/bison.texi$$ \
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
+ prohibit_strcmp=^doc/bison\.texi$$ \
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$$) \
)
# releases, we want to be able run make dist without being required to
# add a bogus NEWS entry. In that case, the version string
# automatically contains a dash, which we also let disable gnits.
-AM_INIT_AUTOMAKE([1.11.1 dist-xz silent-rules]
+AM_INIT_AUTOMAKE([1.11.1 dist-xz nostdinc
+ color-tests parallel-tests
+ silent-rules]
m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
[gnu], [gnits]))
AM_SILENT_RULES([yes])
-Wformat -Wpointer-arith -Wwrite-strings'
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
warn_cxx='-Wnoexcept'
+
AC_LANG_PUSH([C])
# Clang supports many of GCC's -W options, but only issues warnings
# on the ones it does not recognize. In that case, gl_WARN_ADD
# Warnings for the test suite only.
gl_WARN_ADD([-Wundef], [WARN_CXXFLAGS_TEST])
gl_WARN_ADD([-pedantic], [WARN_CXXFLAGS_TEST])
+ # Variants break strict aliasing analysis.
+ gl_WARN_ADD([-fno-strict-aliasing], [NO_STRICT_ALIAS_CXXFLAGS])
CXXFLAGS=$save_CXXFLAGS
AC_LANG_POP([C++])
fi
, [enable_yacc=yes])
case $enable_yacc in
yes)
- YACC_SCRIPT=yacc
- YACC_LIBRARY=liby.a;;
+ YACC_SCRIPT=src/yacc
+ YACC_LIBRARY=lib/liby.a;;
*)
YACC_SCRIPT=
YACC_LIBRARY=;;
# Initialize the test suite.
AC_CONFIG_TESTDIR(tests)
-AC_CONFIG_FILES([tests/Makefile tests/atlocal])
+AC_CONFIG_FILES([tests/atlocal])
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
AC_CHECK_PROGS([VALGRIND], [valgrind])
case $VALGRIND:$host_os in
# Needed by tests/atlocal.in.
AC_SUBST([GCC])
-gt_JAVACOMP([1.3])
+gt_JAVACOMP([1.3], [1.4])
gt_JAVAEXEC
AC_CONFIG_FILES([Makefile
- build-aux/Makefile
- po/Makefile.in
- data/Makefile
- etc/Makefile
- examples/Makefile
- examples/calc++/Makefile
- lib/Makefile src/Makefile
- doc/Makefile
- doc/yacc.1])
+ po/Makefile.in
+ doc/yacc.1])
AC_OUTPUT
+++ /dev/null
-Makefile.in
-Makefile
+++ /dev/null
-/Makefile.in
-/Makefile
+++ /dev/null
-## Copyright (C) 2002, 2005-2012 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-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
## Identification. ##
## ---------------- ##
-# b4_copyright(TITLE, YEARS)
-# --------------------------
+# b4_copyright(TITLE, [YEARS])
+# ----------------------------
+# If YEARS are not defined, use b4_copyright_years.
m4_define([b4_copyright],
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
b4_comment([$1
-m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ])
+]m4_dquote(m4_text_wrap([Copyright (C)
+]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
it under the terms of the GNU General Public License as published by
])dnl
m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])])
-# b4_error(KIND, FORMAT, [ARG1], [ARG2], ...)
-# -------------------------------------------
-# Write @KIND(FORMAT@,ARG1@,ARG2@,...@) to stdout.
+# b4_error(KIND, START, END, FORMAT, [ARG1], [ARG2], ...)
+# -------------------------------------------------------
+# Write @KIND(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.
#
# For example:
#
-# b4_error([[warn]], [[invalid value for '%s': %s]], [[foo]], [[3]])
+# b4_error([[complain]], [[input.y:2.3]], [[input.y:5.4]],
+# [[invalid %s]], [[foo]])
m4_define([b4_error],
-[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
+[b4_cat([[@complain][(]$1[@,]$2[@,]$3[@,]$4[]]dnl
[m4_if([$#], [4], [],
[m4_foreach([b4_arg],
m4_dquote(m4_shift(m4_shift(m4_shift(m4_shift($@))))),
# m4_define([asdf], [ASDF])
# m4_define([fsa], [FSA])
# m4_define([fdsa], [FDSA])
-# b4_warn([[[asdf), asdf]]], [[[fsa), fsa]]], [[[fdsa), fdsa]]])
-# b4_warn([[asdf), asdf]], [[fsa), fsa]], [[fdsa), fdsa]])
-# b4_warn()
-# b4_warn(1)
-# b4_warn(1, 2)
+# b4_warn_at([[[asdf), asdf]]], [[[fsa), fsa]]], [[[fdsa), fdsa]]])
+# b4_warn_at([[asdf), asdf]], [[fsa), fsa]], [[fdsa), fdsa]])
+# b4_warn_at()
+# b4_warn_at(1)
+# b4_warn_at(1, 2)
#
# Should produce this without newlines:
#
-# @warn([asdf), asdf]@,[fsa), fsa]@,[fdsa), fdsa]@)
-# @warn(asdf), asdf@,fsa), fsa@,fdsa), fdsa@)
+# @warn_at([asdf), asdf]@,@,@,[fsa), fsa]@,[fdsa), fdsa]@)
+# @warn(asdf), asdf@,@,@,fsa), fsa@,fdsa), fdsa@)
# @warn(@)
# @warn(1@)
# @warn(1@,2@)
m4_define([b4_warn],
-[b4_error([[warn]], $@)])
+[b4_error([[warn]], [], [], $@)])
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
# ---------------------------------------------------
#
# b4_warn_at([[input.y:2.3]], [[input.y:5.4]], [[invalid %s]], [[foo]])
m4_define([b4_warn_at],
-[b4_error_at([[warn]], $@)])
+[b4_error([[warn]], $@)])
# b4_complain(FORMAT, [ARG1], [ARG2], ...)
# ----------------------------------------
-# Write @complain(FORMAT@,ARG1@,ARG2@,...@) to stdout.
+# Bounce to b4_complain_at.
#
# See b4_warn example.
m4_define([b4_complain],
-[b4_error([[complain]], $@)])
+[b4_error([[complain]], [], [], $@)])
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
# -------------------------------------------------------
#
# See b4_warn_at example.
m4_define([b4_complain_at],
-[b4_error_at([[complain]], $@)])
+[b4_error([[complain]], $@)])
# b4_fatal(FORMAT, [ARG1], [ARG2], ...)
# -------------------------------------
-# Write @fatal(FORMAT@,ARG1@,ARG2@,...@) to stdout and exit.
+# Bounce to b4_fatal_at.
#
# See b4_warn example.
m4_define([b4_fatal],
-[b4_error([[fatal]], $@)dnl
+[b4_error([[fatal]], [], [], $@)dnl
m4_exit(1)])
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
#
# See b4_warn_at example.
m4_define([b4_fatal_at],
-[b4_error_at([[fatal]], $@)dnl
+[b4_error([[fatal]], $@)dnl
m4_exit(1)])
[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[S] -- default reduction number in state S. 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 which
+number is the opposite. If YYTABLE_NINF, syntax error.]])
+
+$1([check], [b4_check])
+
+$1([stos], [b4_stos],
+ [[STOS_[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 composing 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. ##
m4_define([b4_flag_if],
[m4_case(b4_$1_flag,
[0], [$3],
- [1], [$2],
- [m4_fatal([invalid $1 value: ]$1)])])
+ [1], [$2],
+ [m4_fatal([invalid $1 value: ]$1)])])
# b4_define_flag_if(FLAG)
# -----------------------------
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
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([locations]) # Whether locations are tracked.
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([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 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 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_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([$1], [tag])
+])
+
+
+# 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.
+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]))])
-
## --------------------- ##
## b4_percent_define_*. ##
## --------------------- ##
[m4_indir([b4_percent_define(]$1[)])],
[$2])])
-
# b4_percent_define_get_loc(VARIABLE)
# -----------------------------------
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
m4_define([b4_percent_define_ifdef],
[m4_ifdef([b4_percent_define(]$1[)],
- [m4_define([b4_percent_define_bison_variables(]$1[)])$2],
- [$3])])
+ [b4_percent_define_use([$1])$2],
+ [$3])])
+
+
+## --------- ##
+## Options. ##
+## --------- ##
+
# b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE])
# --------------------------------------------------------
[[b4_percent_define_flag_if($1)]])])],
[b4_fatal([[b4_percent_define_flag_if: undefined %%define variable '%s']], [$1])])])
+
# b4_percent_define_default(VARIABLE, DEFAULT)
# --------------------------------------------
# Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is,
[[<skeleton default value>:-1.-1]]]])dnl
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)
# --------------------------------------
# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly
[$1],
m4_dquote(m4_indir([b4_percent_define(]$1[)])))
m4_foreach([b4_value], m4_dquote(m4_shift($@)),
- [b4_complain_at(b4_percent_define_get_loc([$1]),
+ [b4_error([[note]], b4_percent_define_get_loc([$1]), []
[[accepted value: '%s']],
m4_dquote(b4_value))])])dnl
m4_popdef([b4_good_value])],
m4_define([b4_percent_code_ifdef],
[m4_ifdef([b4_percent_code(]$1[)],
[m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2],
- [$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_variant_if([IF-VARIANT-ARE-USED], [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_percent_define_if_define([variant])
+
+
+# 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])])
## ----------------------------------------------------------- ##
## Default values. ##
## ---------------- ##
-# Default parser class name.
b4_percent_define_default([[parser_class_name]], [[parser]])
# Don't do that so that we remember whether we're using a user
# b4_percent_define_default([[api.location.type]], [[location]])
b4_percent_define_default([[filename_type]], [[std::string]])
-b4_percent_define_default([[namespace]], m4_defn([b4_prefix]))
+b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
+
b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
b4_percent_define_default([[define_location_comparison]],
[m4_if(b4_percent_define_get([[filename_type]]),
[std::string], [[true]], [[false]])])
+
## ----------- ##
## Namespace. ##
## ----------- ##
-m4_define([b4_namespace_ref], [b4_percent_define_get([[namespace]])])
+m4_define([b4_namespace_ref], [b4_percent_define_get([[api.namespace]])])
+
# 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.
# include the header, which is always generated. If we ever need to permit
# internal linkage somehow, surely we can find a cleaner approach.
m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
-[b4_complain_at(b4_percent_define_get_loc([[namespace]]),
+[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
[[namespace reference is empty]])])
# Instead of assuming the C++ compiler will do it, Bison should reject any
# Specifically, don't allow empty names as b4_namespace_open would just convert
# those into anonymous namespaces, and that might tempt some users.
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [],
-[b4_complain_at(b4_percent_define_get_loc([[namespace]]),
+[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
[[namespace reference has consecutive "::"]])])
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
-[b4_complain_at(b4_percent_define_get_loc([[namespace]]),
+[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
[[namespace reference has a trailing "::"]])])
m4_define([b4_namespace_open],
-[b4_user_code([b4_percent_define_get_syncline([[namespace]])
+[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
[^\(.\)[ ]*::], [\1])),
[::], [ { namespace ])[ {]])])
m4_define([b4_namespace_close],
-[b4_user_code([b4_percent_define_get_syncline([[namespace]])
+[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
[\1])),
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
-# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
-# -----------------------------------------------------
+# b4_token_enums
+# --------------
# Output the definition of the tokens as enums.
m4_define([b4_token_enums],
-[/* Tokens. */
- enum yytokentype {
-m4_map_sep([ b4_token_enum], [,
-],
- [$@])
- };
+[[enum yytokentype
+ {
+ ]m4_join([,
+ ],
+ b4_symbol_map([b4_token_enum]))[
+ };]dnl
])
## 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[
+ };
+
+ /// Token type.
+ typedef token::yytokentype token_type;
+
+ /// A complete symbol, with its type.
+ template <typename Exact>
+ struct symbol_base_type
+ {
+ /// Default constructor.
+ inline symbol_base_type ();
+
+ /// Constructor.]b4_locations_if([
+ inline symbol_base_type (const location_type& l);])[
+ inline symbol_base_type (]b4_join(
+ [const semantic_type& v],
+ b4_locations_if([const location_type& l]))[);
+
+ /// Return this with its exact type.
+ const Exact& self () const;
+ Exact& self ();
+
+ /// Return the type of this symbol.
+ int type_get () const;
+
+ /// The semantic value.
+ semantic_type value;]b4_locations_if([
+
+ /// The location.
+ location_type location;])[
+ };
+
+ /// External form of a symbol: its type and attributes.
+ struct symbol_type : symbol_base_type<symbol_type>
+ {
+ /// The parent class.
+ typedef symbol_base_type<symbol_type> super_type;
+
+ /// Default constructor.
+ inline symbol_type ();
+
+ /// Constructor for tokens with semantic value.
+ inline symbol_type (]b4_join([token_type t],
+ [const semantic_type& v],
+ b4_locations_if([const location_type& l]))[);
+
+ /// Constructor for valueless tokens.
+ inline symbol_type (]b4_join([token_type t],
+ b4_locations_if([const location_type& l]))[);
+
+ /// The symbol type.
+ int type;
+
+ /// The symbol type.
+ inline int type_get_ () const;
+
+ /// The token.
+ inline token_type token () const;
+ };
+]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)])[
+ {}
+
+ // symbol_base_type.
+ template <typename Exact>
+ inline
+ ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type ()
+ : value()]b4_locations_if([
+ , location()])[
+ {
+ }]b4_locations_if([[
+
+ template <typename Exact>
+ inline
+ ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (const location_type& l)
+ : value()
+ , location(l)
+ {
+ }]])[
+
+ template <typename Exact>
+ inline
+ ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (]b4_join(
+ [const semantic_type& v],
+ b4_locations_if([const location_type& l]))[)
+ : value(v)]b4_locations_if([
+ , location(l)])[
+ {
+ }
+
+ template <typename Exact>
+ inline
+ const Exact&
+ ]b4_parser_class_name[::symbol_base_type<Exact>::self () const
+ {
+ return static_cast<const Exact&>(*this);
+ }
+
+ template <typename Exact>
+ inline
+ Exact&
+ ]b4_parser_class_name[::symbol_base_type<Exact>::self ()
+ {
+ return static_cast<Exact&>(*this);
+ }
+
+ template <typename Exact>
+ inline
+ int
+ ]b4_parser_class_name[::symbol_base_type<Exact>::type_get () const
+ {
+ return self ().type_get_ ();
+ }
+
+ // symbol_type.
+ inline
+ ]b4_parser_class_name[::symbol_type::symbol_type ()
+ : super_type ()
+ , type ()
+ {
+ }
+
+ inline
+ ]b4_parser_class_name[::symbol_type::symbol_type (]b4_join(
+ [token_type t],
+ b4_locations_if([const location_type& l]))[)
+ : super_type (]b4_locations_if([l])[)
+ , type (yytranslate_ (t))
+ {
+ }
+
+ inline
+ ]b4_parser_class_name[::symbol_type::symbol_type (]b4_join(
+ [token_type t],
+ [const semantic_type& v],
+ b4_locations_if([const location_type& l]))[)
+ : super_type (v]b4_locations_if([, l])[)
+ , type (yytranslate_ (t))
+ {
+ }
+
+ inline
+ int
+ ]b4_parser_class_name[::symbol_type::type_get_ () const
+ {
+ return type;
+ }
+]b4_token_ctor_if([[
+ inline
+ ]b4_parser_class_name[::token_type
+ ]b4_parser_class_name[::symbol_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.
+ ]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])
# --------------------
# Expansion of $<TYPE>$.
m4_define([b4_lhs_value],
-[(yyval[]m4_ifval([$1], [.$1]))])
+[b4_symbol_value([yyval], [$1])])
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
m4_define([b4_rhs_value],
-[(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))])
+[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
+
# b4_lhs_location()
# -----------------
# Extra initialisations of the constructor.
m4_define([b4_parse_param_cons],
[m4_ifset([b4_parse_param],
- [
+ [
b4_cc_constructor_calls(b4_parse_param)])])
m4_define([b4_cc_constructor_calls],
- [m4_map_sep([b4_cc_constructor_call], [,
+ [m4_map_sep([b4_cc_constructor_call], [,
], [$@])])
m4_define([b4_cc_constructor_call],
- [$2 ($2_yyarg)])
+ [$2 ($2_yyarg)])
# b4_parse_param_vars
# -------------------
# Extra instance variables.
m4_define([b4_parse_param_vars],
[m4_ifset([b4_parse_param],
- [
+ [
/* User arguments. */
b4_cc_var_decls(b4_parse_param)])])
m4_define([b4_cc_var_decls],
- [m4_map_sep([b4_cc_var_decl], [
+ [m4_map_sep([b4_cc_var_decl], [
], [$@])])
m4_define([b4_cc_var_decl],
- [ $1;])
+ [ $1;])
## ---------##
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
# pointer.
m4_define([b4_dollar_dollar_],
-[m4_if([$2], [[]],
- [m4_ifval([$3], [($1.$3)],
- [$1])],
- [($1.$2)])])
+[b4_symbol_value([$1],
+ m4_if([$2], [[]],
+ [[$3]], [[$2]]))])
# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION)
# b4_dollar_popdef
## Identification. ##
## ---------------- ##
-# b4_comment(TEXT)
-# ----------------
-m4_define([b4_comment], [/* m4_bpatsubst([$1], [
-], [
- ]) */])
+# 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([$1], [
+\(.\)], [
+$3\1])$4])
+
+
+# b4_comment(TEXT, [PREFIX])
+# --------------------------
+# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
+# Avoid adding indentation to the first line, as the indentation comes
+# from "/*". That's why we don't patsubst([$1], [^\(.\)], [ \1]).
+#
+# Prefix all the output lines with PREFIX.
+m4_define([b4_comment],
+[b4_comment_([$1], [$2/* ], [$2 ], [$2 */])])
+
# b4_identification
# -----------------
# b4_user_args
# ------------
m4_define([b4_user_args],
-[m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])])
+[m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])])
# b4_parse_param
m4_popdef([$1])dnl
])])
-# b4_parse_param_use
-# ------------------
-# `YYUSE' all the parse-params.
+# b4_parse_param_use([VAL], [LOC])
+# --------------------------------
+# `YYUSE' VAL, LOC if locations are enabled, and all the parse-params.
m4_define([b4_parse_param_use],
-[b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
+[m4_ifvaln([$1], [ YYUSE([$1]);])dnl
+b4_locations_if([m4_ifvaln([$2], [ YYUSE ([$2]);])])dnl
+b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
])dnl
])
# --------------------------------------------
# Without inducing a comparison warning from the compiler, check if the
# literal value LITERAL equals VALUE from table TABLE, which must have
-# TABLE_min and TABLE_max defined. YYID must be defined as an identity
-# function that suppresses warnings about constant conditions.
+# TABLE_min and TABLE_max defined.
m4_define([b4_table_value_equals],
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|| m4_indir([b4_]$1[_max]) < $3), [1],
- [[YYID (0)]],
+ [[0]],
[(!!(($2) == ($3)))])])
# Return a null pointer constant.
m4_define([b4_null], [YY_NULL])
+# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
+# -------------------------------------------------------------
+# Define "yy<TABLE-NAME>" which 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. ##
## ------------------------- ##
-# b4_token_define(TOKEN-NAME, TOKEN-NUMBER)
-# -----------------------------------------
+# b4_token_define(TOKEN-NUM)
+# --------------------------
# Output the definition of this token as #define.
m4_define([b4_token_define],
-[#define $1 $2
-])
-
+[b4_token_format([#define %s %s], [$1])])
-# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
-# -------------------------------------------------------
-# Output the definition of the tokens (if there are) as #defines.
+# b4_token_defines
+# ----------------
+# Output the definition of the tokens.
m4_define([b4_token_defines],
-[m4_if([$#$1], [1], [],
-[/* Tokens. */
-m4_map([b4_token_define], [$@])])
-])
+[b4_any_token_visible_if([/* Tokens. */
+m4_join([
+], b4_symbol_map([b4_token_define]))
+])])
-# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
-# ---------------------------------------
+# b4_token_enum(TOKEN-NUM)
+# ------------------------
# Output the definition of this token as an enum.
m4_define([b4_token_enum],
-[$1 = $2])
+[b4_token_format([%s = %s], [$1])])
-# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
-# -----------------------------------------------------
+# b4_token_enums
+# --------------
# Output the definition of the tokens (if there are) as enums.
m4_define([b4_token_enums],
-[m4_if([$#$1], [1], [],
-[[/* Tokens. */
+[b4_any_token_visible_if([[/* Tokens. */
#ifndef ]b4_api_PREFIX[TOKENTYPE
# define ]b4_api_PREFIX[TOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum ]b4_api_prefix[tokentype {
-]m4_map_sep([ b4_token_enum], [,
-],
- [$@])[
- };
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum ]b4_api_prefix[tokentype
+ {
+ ]m4_join([,
+ ],
+ b4_symbol_map([b4_token_enum]))[
+ };
#endif
]])])
-# b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
-# -------------------------------------------------------------
-# Output the definition of the tokens (if there are any) as enums and, if POSIX
-# Yacc is enabled, as #defines.
+# b4_token_enums_defines
+# ----------------------
+# Output the definition of the tokens (if there are any) as enums and,
+# if POSIX Yacc is enabled, as #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. ##
+## ----------------- ##
-## --------------------------------------------- ##
-## Defining C functions in both K&R and ANSI-C. ##
-## --------------------------------------------- ##
+# 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]))])
-# 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
-])
+## ---------------------- ##
+## Defining C functions. ##
+## ---------------------- ##
-# b4_c_ansi_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
-# ---------------------------------------------------------------
-# Declare the function NAME in ANSI.
-m4_define([b4_c_ansi_function_def],
+
+# b4_function_define(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
+# -----------------------------------------------------------
+# Declare the function NAME in C.
+m4_define([b4_function_define],
[$2
-$1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl
+$1 (b4_formals(m4_shift2($@)))[]dnl
])
-# b4_c_ansi_formals([DECL1, NAME1], ...)
-# --------------------------------------
-# Output the arguments ANSI-C definition.
-m4_define([b4_c_ansi_formals],
+# b4_formals([DECL1, NAME1], ...)
+# -------------------------------
+# The formal arguments of a C function definition.
+m4_define([b4_formals],
[m4_if([$#], [0], [void],
[$#$1], [1], [void],
- [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
+ [m4_map_sep([b4_formal], [, ], [$@])])])
-m4_define([b4_c_ansi_formal],
+m4_define([b4_formal],
[$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],
-[$2])
-
-
-# b4_c_knr_formal_decls([DECL1, NAME1], ...)
-# ------------------------------------------
-# Output the K&R argument declarations.
-m4_define([b4_c_knr_formal_decls],
-[m4_map_sep([b4_c_knr_formal_decl],
- [
-],
- [$@])])
-m4_define([b4_c_knr_formal_decl],
-[ $1;])
+## ----------------------- ##
+## Declaring C functions. ##
+## ----------------------- ##
-
-## ------------------------------------------------------------ ##
-## 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_function_declare(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
+# ------------------------------------------------------------
+# Declare the function NAME.
+m4_define([b4_function_declare],
+[$2 $1 (b4_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. ##
## --------------------- ##
-# b4_c_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
+# b4_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
# -----------------------------------------------------------
# Call the function NAME with arguments NAME1, NAME2 etc.
-m4_define([b4_c_function_call],
-[$1 (b4_c_args(m4_shift2($@)))[]dnl
+m4_define([b4_function_call],
+[$1 (b4_args(m4_shift2($@)))[]dnl
])
-# b4_c_args([DECL1, NAME1], ...)
-# ------------------------------
+# b4_args([DECL1, NAME1], ...)
+# ----------------------------
# Output the arguments NAME1, NAME2...
-m4_define([b4_c_args],
-[m4_map_sep([b4_c_arg], [, ], [$@])])
+m4_define([b4_args],
+[m4_map_sep([b4_arg], [, ], [$@])])
-m4_define([b4_c_arg],
+m4_define([b4_arg],
[$2])
## ----------- ##
# b4_sync_start(LINE, FILE)
-# -----------------------
+# -------------------------
m4_define([b4_sync_start], [[#]line $1 $2])
m4_define([b4_case],
[ case $1:
$2
+b4_syncline([@oline@], [@ofile@])
break;])
-# b4_symbol_actions(FILENAME, LINENO,
-# SYMBOL-TAG, SYMBOL-NUM,
-# SYMBOL-ACTION, SYMBOL-TYPENAME)
-# -------------------------------------------------
-# Issue the code for a symbol action (e.g., %printer).
-#
-# Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are
-# invoked where $<TYPE-NAME>$ and @$ were specified by the user.
-m4_define([b4_symbol_actions],
-[b4_dollar_pushdef([(*yyvaluep)], [$6], [(*yylocationp)])dnl
- case $4: /* $3 */
-b4_syncline([$2], [$1])
- $5;
+
+# b4_predicate_case(LABEL, CONDITIONS)
+# ------------------------------------
+m4_define([b4_predicate_case],
+[ case $1:
+ if (! ($2)) YYERROR;
b4_syncline([@oline@], [@ofile@])
- break;
-b4_dollar_popdef[]dnl
-])
+ break;])
-# b4_yydestruct_generate(FUNCTION-DECLARATOR)
-# -------------------------------------------
-# Generate the "yydestruct" function, which declaration is issued using
-# 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],
+# b4_yydestruct_define
+# --------------------
+# Define the "yydestruct" function.
+m4_define_default([b4_yydestruct_define],
[[/*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
-/*ARGSUSED*/
-]$1([yydestruct],
+]b4_function_define([yydestruct],
[static void],
[[const char *yymsg], [yymsg]],
[[int yytype], [yytype]],
b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
- YYUSE (yyvaluep);
-]b4_locations_if([ YYUSE (yylocationp);
-])dnl
-b4_parse_param_use[]dnl
-[
- if (!yymsg)
+]b4_parse_param_use([yyvaluep], [yylocationp])dnl
+[ if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
switch (yytype)
{
-]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
- default:
+]b4_symbol_foreach([b4_symbol_destructor])dnl
+[ default:
break;
}
}]dnl
])
-# b4_yy_symbol_print_generate(FUNCTION-DECLARATOR)
-# ------------------------------------------------
-# Generate the "yy_symbol_print" function, which declaration is issued using
-# 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],
+# b4_yy_symbol_print_define
+# -------------------------
+# Define the "yy_symbol_print" function.
+m4_define_default([b4_yy_symbol_print_define],
[[
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
-/*ARGSUSED*/
-]$1([yy_symbol_value_print],
+]b4_function_define([yy_symbol_value_print],
[static void],
[[FILE *yyoutput], [yyoutput]],
[[int yytype], [yytype]],
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
FILE *yyo = yyoutput;
- YYUSE (yyo);
- if (!yyvaluep)
- return;
-]b4_locations_if([ YYUSE (yylocationp);
-])dnl
-b4_parse_param_use[]dnl
-[# ifdef YYPRINT
+]b4_parse_param_use([yyo], [yylocationp])dnl
+[ if (!yyvaluep)
+ return;]
+dnl glr.c does not feature yytoknum.
+m4_if(b4_skeleton, ["yacc.c"],
+[[# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# else
- YYUSE (yyoutput);
# endif
- switch (yytype)
+]])dnl
+[ switch (yytype)
{
-]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
+]b4_symbol_foreach([b4_symbol_printer])dnl
[ default:
break;
}
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
-]$1([yy_symbol_print],
+]b4_function_define([yy_symbol_print],
[static void],
[[FILE *yyoutput], [yyoutput]],
[[int yytype], [yytype]],
[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([[
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]])
[[/* Enabling traces. */
]m4_if(b4_api_prefix, [yy],
[[#ifndef YYDEBUG
-# define YYDEBUG ]b4_debug_flag[
+# define YYDEBUG ]b4_parse_trace_if([1], [0])[
#endif]],
[[#ifndef ]b4_api_PREFIX[DEBUG
# if defined YYDEBUG
-# if YYDEBUG
+#if YYDEBUG
# define ]b4_api_PREFIX[DEBUG 1
# else
# define ]b4_api_PREFIX[DEBUG 0
# endif
# else /* ! defined YYDEBUG */
-# define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[
+# define ]b4_api_PREFIX[DEBUG ]b4_parse_trace_if([1], [0])[
# endif /* ! defined YYDEBUG */
#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
- if (YYID (N)) \
+ if (N) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
- while (YYID (0))
+ while (0)
#endif
]])
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
__attribute__((__unused__))
-]b4_c_function_def([yy_location_print_],
+]b4_function_define([yy_location_print_],
[static unsigned],
[[FILE *yyo], [yyo]],
[[YYLTYPE const * const yylocp], [yylocp]])[
return res;
}
-# define YY_LOCATION_PRINT(File, Loc) \
+# define YY_LOCATION_PRINT(File, Loc) \
yy_location_print_ (File, &(Loc))
# else
# This is not shared with yacc.c in c.m4 because GLR relies on ISO C
# formal argument declarations.
m4_define([b4_user_formals],
-[m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])])
+[m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])])
# b4_lex_param
# a trailing comma.
m4_define([b4_yyerror_args],
[b4_pure_if([b4_locations_if([yylocp, ])])dnl
-m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
+m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
# b4_lyyerror_args
# Same as above, but on the lookahead, hence &yylloc instead of yylocp.
m4_define([b4_lyyerror_args],
[b4_pure_if([b4_locations_if([&yylloc, ])])dnl
-m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
+m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
# b4_pure_args
# --------------------
# Expansion of $<TYPE>$.
m4_define([b4_lhs_value],
-[((*yyvalp)[]m4_ifval([$1], [.$1]))])
+[b4_symbol_value([(*yyvalp)], [$1])])
+
+
+# b4_rhs_data(RULE-LENGTH, NUM)
+# -----------------------------
+# Expand to the semantic stack place that contains value and location
+# of symbol number NUM in a rule of length RULE-LENGTH.
+m4_define([b4_rhs_data],
+[((yyGLRStackItem const *)yyvsp)@{YYFILL (b4_subtract([$2], [$1]))@}.yystate])
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
m4_define([b4_rhs_value],
-[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))])
+[b4_symbol_value([b4_rhs_data([$1], [$2]).yysemantics.yysval], [$3])])
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# on RHS.
m4_define([b4_rhs_location],
-[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)])
+[(b4_rhs_data([$1], [$2]).yyloc)])
## -------------- ##
# 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],
+# or open coded in the parser body. glr.cc has its own definition.
+m4_if(b4_skeleton, ["glr.c"],
+[m4_define([b4_shared_declarations],
[b4_declare_yydebug[
]b4_percent_code_get([[requires]])[
-]b4_token_enums(b4_tokens)[
+]b4_token_enums[
]b4_declare_yylstype[
-]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
+]b4_function_declare(b4_prefix[parse], [int], b4_parse_param)[
]b4_percent_code_get([[provides]])[]dnl
])
-
+])
## -------------- ##
## Output files. ##
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
#define yylloc ]b4_prefix[lloc]])])[
-/* Copy the first part of user declarations. */
+/* First part of user declarations. */
]b4_user_pre_prologue[
]b4_null_define[
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
-# define YYERROR_VERBOSE ]b4_error_verbose_flag[
+# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
#endif
/* Default (constant) value used for initialization for null
#endif
/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
+#ifdef __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
-/* Identity function, used to suppress warnings about constant conditions. */
-#ifndef lint
-# define YYID(N) (N)
-#else
-]b4_c_function_def([YYID], [static int], [[int i], [i]])[
-{
- return i;
-}
-#endif
-
#ifndef YYFREE
# define YYFREE free
#endif
};
#if ]b4_api_PREFIX[DEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- 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[] =
{
};
#endif
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const ]b4_int_type_for([b4_r1])[ yyr1[] =
-{
- ]b4_r1[
-};
+#define YYPACT_NINF ]b4_pact_ninf[
+#define YYTABLE_NINF ]b4_table_ninf[
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const ]b4_int_type_for([b4_r2])[ yyr2[] =
-{
- ]b4_r2[
-};
+]b4_parser_tables_define[
/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
]b4_merger[
};
-/* YYDEFACT[S] -- default reduction number in state S. 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[
-};
-
-/* YYPDEFGOTO[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[
-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[] =
+/* YYIMMEDIATE[RULE-NUM] -- True iff rule #RULE-NUM is not to be deferred, as
+ in the case of predicates. */
+static const yybool yyimmediate[] =
{
- ]b4_table[
+ ]b4_immediate[
};
/* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
]b4_conflicting_rules[
};
-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[
-};
-
/* Error token number */
#define YYTERROR 1
]b4_yy_location_print_define[
/* YYLEX -- calling `yylex' with the right arguments. */
-#define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
+#define YYLEX ]b4_function_call([yylex], [int], b4_lex_param)[
]b4_pure_if(
[
typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
-#define YYCHK(YYE) \
- do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
- while (YYID (0))
+#define YYCHK(YYE) \
+ do { \
+ YYRESULTTAG yychk_flag = YYE; \
+ if (yychk_flag != yyok) \
+ return yychk_flag; \
+ } while (0)
#if ]b4_api_PREFIX[DEBUG
# endif
# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (YYID (0))
-
-]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (YYID (0))
+ do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+ } while (0)
+
+]b4_yy_symbol_print_define[
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+ do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+ } while (0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
#define YYHEADROOM 2
#ifndef YYSTACKEXPANDABLE
-# if (! defined __cplusplus \
- || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
- && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL))
# define YYSTACKEXPANDABLE 1
-# else
-# define YYSTACKEXPANDABLE 0
-# endif
#endif
#if YYSTACKEXPANDABLE
do { \
if (Yystack->yyspaceLeft < YYHEADROOM) \
yyexpandGLRStack (Yystack); \
- } while (YYID (0))
+ } while (0)
#else
# define YY_RESERVE_GLRSTACK(Yystack) \
do { \
if (Yystack->yyspaceLeft < YYHEADROOM) \
yyMemoryExhausted (Yystack); \
- } while (YYID (0))
+ } while (0)
#endif
typedef int yyRuleNum;
/** Grammar symbol */
-typedef short int yySymbol;
+typedef int yySymbol;
/** Item references, as in LALR(1) machine */
typedef short int yyItemNum;
yyStateNum yylrState;
/** Preceding state in this stack */
yyGLRState* yypred;
- /** Source position of the first token produced by my symbol */
+ /** Source position of the last token produced by my symbol */
size_t yyposn;
union {
/** First in a chain of alternative reductions producing the
yyGLRState *s = yyvsp[yylow0].yystate.yypred;
for (i = yylow0-1; i >= yylow1; i -= 1)
{
- YYASSERT (s->yyresolved);
- yyvsp[i].yystate.yyresolved = yytrue;
- yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;]b4_locations_if([[
+#if ]b4_api_PREFIX[DEBUG
+ yyvsp[i].yystate.yylrState = s->yylrState;
+#endif
+ yyvsp[i].yystate.yyresolved = s->yyresolved;
+ if (s->yyresolved)
+ yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;
+ else
+ /* The effect of using yysval or yyloc (in an immediate rule) is
+ * undefined. */
+ yyvsp[i].yystate.yysemantics.yyfirstVal = YY_NULL;]b4_locations_if([[
yyvsp[i].yystate.yyloc = s->yyloc;]])[
s = yyvsp[i].yystate.yypred = s->yypred;
}
* value ($$), and yylocp points to place for location information
* (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
* yyerr for YYERROR, yyabort for YYABORT. */
-/*ARGSUSED*/ static YYRESULTTAG
+static YYRESULTTAG
yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
yyGLRStack* yystackp,
YYSTYPE* yyvalp]b4_locuser_formals[)
yybool yynormal __attribute__ ((__unused__)) =
(yystackp->yysplitPoint == YY_NULL);
int yylow;
-]b4_parse_param_use[]dnl
+]b4_parse_param_use([yyvalp], [yylocp])dnl
[# undef yyerrok
# define yyerrok (yystackp->yyerrState = 0)
# undef YYACCEPT
# undef yyclearin
# undef YYRECOVERING
}
-\f
-/*ARGSUSED*/ static void
+
+static void
yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
{
YYUSE (yy0);
switch (yyn)
{
- ]b4_mergers[
+]b4_mergers[
default: break;
}
}
/* Bison grammar-table manipulation. */
-]b4_yydestruct_generate([b4_c_ansi_function_def])[
+]b4_yydestruct_define[
/** Number of symbols composing the right hand side of rule #RULE. */
static inline int
}
}
-/** Left-hand-side symbol for rule #RULE. */
+/** Left-hand-side symbol for rule #YYRULE. */
static inline yySymbol
yylhsNonterm (yyRuleNum yyrule)
{
#define yypact_value_is_default(Yystate) \
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
-/** True iff LR state STATE has only a default reduction (regardless
+/** True iff LR state YYSTATE has only a default reduction (regardless
* of token). */
static inline yybool
yyisDefaultedState (yyStateNum yystate)
return yypact_value_is_default (yypact[yystate]);
}
-/** The default reduction for STATE, assuming it has one. */
+/** The default reduction for YYSTATE, assuming it has one. */
static inline yyRuleNum
yydefaultAction (yyStateNum yystate)
{
* R < 0: Reduce on rule -R.
* R = 0: Error.
* R > 0: Shift to state R.
- * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
- * conflicting reductions.
+ * Set *YYCONFLICTS to a pointer into yyconfl to a 0-terminated list
+ * of conflicting reductions.
*/
static inline void
yygetLRActions (yyStateNum yystate, int yytoken,
static inline yyStateNum
yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
{
- int yyr;
- yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
+ int yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
return yytable[yyr];
else
/* GLRStates */
-/** Return a fresh GLRStackItem. Callers should call
- * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
- * headroom. */
+/** Return a fresh GLRStackItem in YYSTACKP. The item is an LR state
+ * if YYISSTATE, and otherwise a semantic option. Callers should call
+ * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
+ * headroom. */
static inline yyGLRStackItem*
yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
}
/** Add a new semantic action that will execute the action for rule
- * RULENUM on the semantic values in RHS to the list of
- * alternative actions for STATE. Assumes that RHS comes from
- * stack #K of *STACKP. */
+ * YYRULE on the semantic values in YYRHS to the list of
+ * alternative actions for YYSTATE. Assumes that YYRHS comes from
+ * stack #YYK of *YYSTACKP. */
static void
yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
- yyGLRState* rhs, yyRuleNum yyrule)
+ yyGLRState* yyrhs, yyRuleNum yyrule)
{
yySemanticOption* yynewOption =
&yynewGLRStackItem (yystackp, yyfalse)->yyoption;
- yynewOption->yystate = rhs;
+ yynewOption->yystate = yyrhs;
yynewOption->yyrule = yyrule;
if (yystackp->yytops.yylookaheadNeeds[yyk])
{
/* GLRStacks */
-/** Initialize SET to a singleton set containing an empty stack. */
+/** Initialize YYSET to a singleton set containing an empty stack. */
static yybool
yyinitStateSet (yyGLRStateSet* yyset)
{
YYFREE (yyset->yylookaheadNeeds);
}
-/** Initialize STACK to a single empty stack, with total maximum
- * capacity for all stacks of SIZE. */
+/** Initialize *YYSTACKP to a single empty stack, with total maximum
+ * capacity for all stacks of YYSIZE. */
static yybool
yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
{
# define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
&((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
-/** If STACK is expandable, extend it. WARNING: Pointers into the
+/** If *YYSTACKP is expandable, extend it. WARNING: Pointers into the
stack from outside should be considered invalid after this call.
We always expand when there are 1 or fewer items left AFTER an
allocation, so that we can avoid having external pointers exist
yyfreeStateSet (&yystackp->yytops);
}
-/** Assuming that S is a GLRState somewhere on STACK, update the
- * splitpoint of STACK, if needed, so that it is at least as deep as
- * S. */
+/** Assuming that YYS is a GLRState somewhere on *YYSTACKP, update the
+ * splitpoint of *YYSTACKP, if needed, so that it is at least as deep as
+ * YYS. */
static inline void
yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
{
yystackp->yysplitPoint = yys;
}
-/** Invalidate stack #K in STACK. */
+/** Invalidate stack #YYK in *YYSTACKP. */
static inline void
yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
{
yystackp->yytops.yystates[yyk] = YY_NULL;
}
-/** Undelete the last stack that was marked as deleted. Can only be
- done once after a deletion, and only when all other stacks have
+/** Undelete the last stack in *YYSTACKP that was marked as deleted. Can
+ only be done once after a deletion, and only when all other stacks have
been deleted. */
static void
yyundeleteLastStack (yyGLRStack* yystackp)
}
}
-/** Shift to a new state on stack #K of STACK, corresponding to LR state
- * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
+/** Shift to a new state on stack #YYK of *YYSTACKP, corresponding to LR
+ * state YYLRSTATE, at input position YYPOSN, with (resolved) semantic
+ * value *YYVALP and source location *YYLOCP. */
static inline void
yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
size_t yyposn,
YY_RESERVE_GLRSTACK (yystackp);
}
-/** Shift stack #K of YYSTACK, to a new state corresponding to LR
+/** Shift stack #YYK of *YYSTACKP, to a new state corresponding to LR
* state YYLRSTATE, at input position YYPOSN, with the (unresolved)
* semantic value of YYRHS under the action for YYRULE. */
static inline void
yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
- size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
+ size_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
{
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
yystackp->yytops.yystates[yyk] = yynewState;
/* Invokes YY_RESERVE_GLRSTACK. */
- yyaddDeferredAction (yystackp, yyk, yynewState, rhs, yyrule);
+ yyaddDeferredAction (yystackp, yyk, yynewState, yyrhs, yyrule);
}
-/** Pop the symbols consumed by reduction #RULE from the top of stack
- * #K of STACK, and perform the appropriate semantic action on their
+#if !]b4_api_PREFIX[DEBUG
+# define YY_REDUCE_PRINT(Args)
+#else
+# define YY_REDUCE_PRINT(Args) \
+do { \
+ if (yydebug) \
+ yy_reduce_print Args; \
+} while (0)
+
+/*----------------------------------------------------------------------.
+| Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. |
+`----------------------------------------------------------------------*/
+
+static inline void
+yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
+ yyRuleNum yyrule]b4_user_formals[)
+{
+ int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
+ int yylow = 1;])[
+ int yyi;
+ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
+ (unsigned long int) yyk, yyrule - 1,
+ (unsigned long int) yyrline[yyrule]);
+ if (! yynormal)
+ yyfillin (yyvsp, 1, -yynrhs);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr,
+ yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState],
+ &yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval
+ ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
+ b4_user_args[);
+ if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved)
+ YYFPRINTF (stderr, " (unresolved)");
+ YYFPRINTF (stderr, "\n");
+ }
+}
+#endif
+
+/** Pop the symbols consumed by reduction #YYRULE from the top of stack
+ * #YYK of *YYSTACKP, and perform the appropriate semantic action on their
* semantic values. Assumes that all ambiguities in semantic values
- * have been previously resolved. Set *VALP to the resulting value,
- * and *LOCP to the computed location (if any). Return value is as
+ * have been previously resolved. Set *YYVALP to the resulting value,
+ * and *YYLOCP to the computed location (if any). Return value is as
* for userAction. */
static inline YYRESULTTAG
yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
if (yystackp->yysplitPoint == YY_NULL)
{
/* Standard special case: single stack. */
- yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
+ yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
YYASSERT (yyk == 0);
yystackp->yynextFree -= yynrhs;
yystackp->yyspaceLeft += yynrhs;
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
- return yyuserAction (yyrule, yynrhs, rhs, yystackp,
+ YY_REDUCE_PRINT ((1, yyrhs, yyk, yyrule]b4_user_args[));
+ return yyuserAction (yyrule, yynrhs, yyrhs, yystackp,
yyvalp]b4_locuser_args[);
}
else
{
- /* At present, doAction is never called in nondeterministic
- * mode, so this branch is never taken. It is here in
- * anticipation of a future feature that will allow immediate
- * evaluation of selected actions in nondeterministic mode. */
int yyi;
yyGLRState* yys;
yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
}
yyupdateSplit (yystackp, yys);
yystackp->yytops.yystates[yyk] = yys;
+ YY_REDUCE_PRINT ((0, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
yystackp, yyvalp]b4_locuser_args[);
}
}
-#if !]b4_api_PREFIX[DEBUG
-# define YY_REDUCE_PRINT(Args)
-#else
-# define YY_REDUCE_PRINT(Args) \
-do { \
- if (yydebug) \
- yy_reduce_print Args; \
-} while (YYID (0))
-
-/*----------------------------------------------------------.
-| Report that the RULE is going to be reduced on stack #K. |
-`----------------------------------------------------------*/
-
-/*ARGSUSED*/ static inline void
-yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
- YYSTYPE* yyvalp]b4_locuser_formals[)
-{
- int yynrhs = yyrhsLength (yyrule);
- yybool yynormal __attribute__ ((__unused__)) =
- (yystackp->yysplitPoint == YY_NULL);
- yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
- int yylow = 1;
- int yyi;
- YYUSE (yyvalp);]b4_locations_if([
- YYUSE (yylocp);])[
-]b4_parse_param_use[]dnl
-[ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
- (unsigned long int) yyk, yyrule - 1,
- (unsigned long int) yyrline[yyrule]);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- YYFPRINTF (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
- &]b4_rhs_value(yynrhs, yyi + 1)[
- ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
- b4_user_args[);
- YYFPRINTF (stderr, "\n");
- }
-}
-#endif
-
-/** Pop items off stack #K of STACK according to grammar rule RULE,
+/** Pop items off stack #YYK of *YYSTACKP according to grammar rule YYRULE,
* and push back on the resulting nonterminal symbol. Perform the
- * semantic action associated with RULE and store its value with the
- * newly pushed state, if FORCEEVAL or if STACK is currently
+ * semantic action associated with YYRULE and store its value with the
+ * newly pushed state, if YYFORCEEVAL or if *YYSTACKP is currently
* unambiguous. Otherwise, store the deferred semantic action with
* the new state. If the new state would have an identical input
* position, LR state, and predecessor to an existing state on the stack,
- * it is identified with that existing state, eliminating stack #K from
- * the STACK. In this case, the (necessarily deferred) semantic value is
+ * it is identified with that existing state, eliminating stack #YYK from
+ * *YYSTACKP. In this case, the semantic value is
* added to the options for the existing state's semantic value.
*/
static inline YYRESULTTAG
if (yyforceEval || yystackp->yysplitPoint == YY_NULL)
{
+ YYRESULTTAG yyflag;
YYSTYPE yysval;]b4_locations_if([
YYLTYPE yyloc;])[
- YY_REDUCE_PRINT ((yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[));
- YYCHK (yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[));
+ yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
+ if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULL)
+ {
+ YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n",
+ (unsigned long int) yyk, yyrule - 1));
+ }
+ if (yyflag != yyok)
+ return yyflag;
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
yyglrShift (yystackp, yyk,
yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState,
yyupdateSplit (yystackp, yys);
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
YYDPRINTF ((stderr,
- "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
+ "Reduced stack %lu by rule #%d; action deferred. "
+ "Now in state %d.\n",
(unsigned long int) yyk, yyrule - 1, yynewLRState));
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL)
return yystackp->yytops.yysize-1;
}
-/** True iff Y0 and Y1 represent identical options at the top level.
+/** True iff YYY0 and YYY1 represent identical options at the top level.
* That is, they represent the same rule applied to RHS symbols
* that produce the same terminal symbols. */
static yybool
return yyfalse;
}
-/** Assuming identicalOptions (Y0,Y1), destructively merge the
- * alternative semantic values for the RHS-symbols of Y1 and Y0. */
+/** Assuming identicalOptions (YYY0,YYY1), destructively merge the
+ * alternative semantic values for the RHS-symbols of YYY1 and YYY0. */
static void
yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
{
{
yySemanticOption** yyz0p = &yys0->yysemantics.yyfirstVal;
yySemanticOption* yyz1 = yys1->yysemantics.yyfirstVal;
- while (YYID (yytrue))
+ while (yytrue)
{
if (yyz1 == *yyz0p || yyz1 == YY_NULL)
break;
yyGLRStack* yystackp]b4_user_formals[);
-/** Resolve the previous N states starting at and including state S. If result
- * != yyok, some states may have been left unresolved possibly with empty
- * semantic option chains. Regardless of whether result = yyok, each state
- * has been left with consistent data so that yydestroyGLRState can be invoked
- * if necessary. */
+/** Resolve the previous YYN states starting at and including state YYS
+ * on *YYSTACKP. If result != yyok, some states may have been left
+ * unresolved possibly with empty semantic option chains. Regardless
+ * of whether result = yyok, each state has been left with consistent
+ * data so that yydestroyGLRState can be invoked if necessary. */
static YYRESULTTAG
yyresolveStates (yyGLRState* yys, int yyn,
yyGLRStack* yystackp]b4_user_formals[)
return yyok;
}
-/** Resolve the states for the RHS of OPT, perform its user action, and return
- * the semantic value and location. Regardless of whether result = yyok, all
- * RHS states have been destroyed (assuming the user action destroys all RHS
+/** Resolve the states for the RHS of YYOPT on *YYSTACKP, perform its
+ * user action, and return the semantic value and location in *YYVALP
+ * and *YYLOCP. Regardless of whether result = yyok, all RHS states
+ * have been destroyed (assuming the user action destroys all RHS
* semantic values if invoked). */
static YYRESULTTAG
yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
{
if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
- yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
+ yytokenName (yystos[yystates[yyi]->yylrState]));
else
YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
- yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
- (unsigned long int) (yystates[yyi - 1]->yyposn + 1),
+ yytokenName (yystos[yystates[yyi]->yylrState]),
+ (unsigned long int) (yystates[yyi-1]->yyposn + 1),
(unsigned long int) yystates[yyi]->yyposn);
}
else
}
#endif
-/*ARGSUSED*/ static YYRESULTTAG
+static YYRESULTTAG
yyreportAmbiguity (yySemanticOption* yyx0,
yySemanticOption* yyx1]b4_pure_formals[)
{
return yyabort;
}]b4_locations_if([[
-/** Starting at and including state S1, resolve the location for each of the
- * previous N1 states that is unresolved. The first semantic option of a state
- * is always chosen. */
+/** Resolve the locations for each of the YYN1 states in *YYSTACKP,
+ * ending at YYS1. Has no effect on previously resolved states.
+ * The first semantic option of a state is always chosen. */
static void
yyresolveLocations (yyGLRState* yys1, int yyn1,
yyGLRStack *yystackp]b4_user_formals[)
}
}]])[
-/** Resolve the ambiguity represented in state S, perform the indicated
- * actions, and set the semantic value of S. If result != yyok, the chain of
- * semantic options in S has been cleared instead or it has been left
- * unmodified except that redundant options may have been removed. Regardless
- * of whether result = yyok, S has been left with consistent data so that
+/** Resolve the ambiguity represented in state YYS in *YYSTACKP,
+ * perform the indicated actions, and set the semantic value of YYS.
+ * If result != yyok, the chain of semantic options in YYS has been
+ * cleared instead or it has been left unmodified except that
+ * redundant options may have been removed. Regardless of whether
+ * result = yyok, YYS has been left with consistent data so that
* yydestroyGLRState can be invoked if necessary. */
static YYRESULTTAG
yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
size_t yyposn]b4_pure_formals[)
{
- int yyaction;
- const short int* yyconflicts;
- yyRuleNum yyrule;
-
while (yystackp->yytops.yystates[yyk] != YY_NULL)
{
yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
if (yyisDefaultedState (yystate))
{
- yyrule = yydefaultAction (yystate);
+ YYRESULTTAG yyflag;
+ yyRuleNum yyrule = yydefaultAction (yystate);
if (yyrule == 0)
{
YYDPRINTF ((stderr, "Stack %lu dies.\n",
yymarkStackDeleted (yystackp, yyk);
return yyok;
}
- YYCHK (yyglrReduce (yystackp, yyk, yyrule, yyfalse]b4_user_args[));
+ yyflag = yyglrReduce (yystackp, yyk, yyrule, yyimmediate[yyrule]]b4_user_args[);
+ if (yyflag == yyerr)
+ {
+ YYDPRINTF ((stderr,
+ "Stack %lu dies "
+ "(predicate failure or explicit user error).\n",
+ (unsigned long int) yyk));
+ yymarkStackDeleted (yystackp, yyk);
+ return yyok;
+ }
+ if (yyflag != yyok)
+ return yyflag;
}
else
{
yySymbol yytoken;
+ int yyaction;
+ const short int* yyconflicts;
+
yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
if (yychar == YYEMPTY)
{
while (*yyconflicts != 0)
{
+ YYRESULTTAG yyflag;
size_t yynewStack = yysplitStack (yystackp, yyk);
YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
(unsigned long int) yynewStack,
(unsigned long int) yyk));
- YYCHK (yyglrReduce (yystackp, yynewStack,
- *yyconflicts, yyfalse]b4_user_args[));
- YYCHK (yyprocessOneStack (yystackp, yynewStack,
- yyposn]b4_pure_args[));
+ yyflag = yyglrReduce (yystackp, yynewStack,
+ *yyconflicts,
+ yyimmediate[*yyconflicts]]b4_user_args[);
+ if (yyflag == yyok)
+ YYCHK (yyprocessOneStack (yystackp, yynewStack,
+ yyposn]b4_pure_args[));
+ else if (yyflag == yyerr)
+ {
+ YYDPRINTF ((stderr, "Stack %lu dies.\n",
+ (unsigned long int) yynewStack));
+ yymarkStackDeleted (yystackp, yynewStack);
+ }
+ else
+ return yyflag;
yyconflicts += 1;
}
break;
}
else
- YYCHK (yyglrReduce (yystackp, yyk, -yyaction,
- yyfalse]b4_user_args[));
+ {
+ YYRESULTTAG yyflag = yyglrReduce (yystackp, yyk, -yyaction,
+ yyimmediate[-yyaction]]b4_user_args[);
+ if (yyflag == yyerr)
+ {
+ YYDPRINTF ((stderr,
+ "Stack %lu dies "
+ "(predicate failure or explicit user error).\n",
+ (unsigned long int) yyk));
+ yymarkStackDeleted (yystackp, yyk);
+ break;
+ }
+ else if (yyflag != yyok)
+ return yyflag;
+ }
}
}
return yyok;
}
-/*ARGSUSED*/ static void
+static void
yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
{
if (yystackp->yyerrState != 0)
/* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP,
yylval, and yylloc are the syntactic category, semantic value, and location
of the lookahead. */
-/*ARGSUSED*/ static void
+static void
yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
{
size_t yyk;
if (yystackp->yyerrState == 3)
/* We just shifted the error token and (perhaps) took some
reductions. Skip tokens until we can proceed. */
- while (YYID (yytrue))
+ while (yytrue)
{
yySymbol yytoken;
if (yychar == YYEOF)
default: \
goto yybuglab; \
} \
- } while (YYID (0))
-
+ } while (0)
/*----------.
| yyparse. |
`----------*/
-]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[
+]b4_function_define([yyparse], [int], b4_parse_param)[
{
int yyresult;
yyGLRStack yystack;
yylloc = yyloc_default;])[
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yylval], [], [yylloc])dnl
-/* User initialization code. */
-b4_user_initial_action
+ /* User initialization code. */
+ b4_user_initial_action
b4_dollar_popdef])[]dnl
[
if (! yyinitGLRStack (yystackp, YYINITDEPTH))
yyglrShift (&yystack, 0, 0, 0, &yylval]b4_locations_if([, &yylloc])[);
yyposn = 0;
- while (YYID (yytrue))
+ while (yytrue)
{
/* For efficiency, we have two loops, the first of which is
specialized to deterministic operation (single stack, no
potential ambiguity). */
/* Standard mode */
- while (YYID (yytrue))
+ while (yytrue)
{
yyRuleNum yyrule;
int yyaction;
}
}
- while (YYID (yytrue))
+ while (yytrue)
{
yySymbol yytoken_to_shift;
size_t yys;
yyfreeGLRStack (&yystack);
}
- /* Make sure YYID is used. */
- return YYID (yyresult);
+ return yyresult;
}
/* DEBUGGING ONLY */
- -*- C -*-
-
# C++ GLR skeleton for Bison
# Copyright (C) 2002-2012 Free Software Foundation, Inc.
#
# The additional arguments are stored as members of the parser
# object, yyparser. The C routines need to carry yyparser
-# throughout the C parser; that easy: just let yyparser become an
+# throughout the C parser; that's easy: make yyparser an
# additional parse-param. But because the C++ skeleton needs to
# know the "real" original parse-param, we save them
# (b4_parse_param_orig). Note that b4_parse_param is overquoted
# The locations
#
# We use location.cc just like lalr1.cc, but because glr.c stores
-# the locations in a (C++) union, the position and location classes
+# the locations in a union, the position and location classes
# must not have a constructor. Therefore, contrary to lalr1.cc, we
# must not define "b4_location_constructors". As a consequence the
# user must initialize the first positions (in particular the
# filename member).
-# We require a pure interface using locations.
-m4_define([b4_locations_flag], [1])
+# We require a pure interface.
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])
-b4_percent_define_ifdef([[api.location.type]], [],
- [m4_include(b4_pkgdatadir/[location.cc])])
+b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
+ [m4_include(b4_pkgdatadir/[location.cc])])])
m4_define([b4_parser_class_name],
[b4_percent_define_get([[parser_class_name]])])
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
-# b4_yy_symbol_print_generate
-# ---------------------------
+# b4_yy_symbol_print_define
+# -------------------------
# Bypass the default implementation to generate the "yy_symbol_print"
# and "yy_symbol_value_print" functions.
-m4_define([b4_yy_symbol_print_generate],
+m4_define([b4_yy_symbol_print_define],
[[
/*--------------------.
| Print this symbol. |
`--------------------*/
-]b4_c_ansi_function_def([yy_symbol_print],
+]b4_function_define([yy_symbol_print],
[static void],
- [[FILE *], []],
- [[int yytype], [yytype]],
+ [[FILE *], []],
+ [[int yytype], [yytype]],
[[const ]b4_namespace_ref::b4_parser_class_name[::semantic_type *yyvaluep],
- [yyvaluep]],
+ [yyvaluep]][]dnl
+b4_locations_if([,
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
- [yylocationp]],
+ [yylocationp]]]),
b4_parse_param)[
{
]b4_parse_param_use[]dnl
[b4_syncline([@oline@], [@ofile@])[
]b4_yylloc_default_define[
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
-]b4_c_ansi_function_decl([yyerror],
- [static void],
+]b4_function_declare([yyerror],
+ [static void],b4_locations_if([
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
- [yylocationp]],
+ [yylocationp]],])
b4_parse_param,
[[const char* msg], [msg]])])
| Report an error. |
`------------------*/
-]b4_c_ansi_function_def([yyerror],
- [static void],
+]b4_function_define([yyerror],
+ [static void],b4_locations_if([
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
- [yylocationp]],
+ [yylocationp]],])
b4_parse_param,
[[const char* msg], [msg]])[
{
]b4_parse_param_use[]dnl
-[ yyparser.error (*yylocationp, msg);
+[ yyparser.error (]b4_locations_if([[*yylocationp, ]])[msg);
}
]b4_namespace_open[
-]dnl In this section, the parse param are the original parse_params.
+]dnl In this section, the parse params are the original parse_params.
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
[ /// Build a parser object.
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
:])[
#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[
{
}
inline void
]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
- const semantic_type* yyvaluep,
- const location_type* yylocationp)
- {
- YYUSE (yylocationp);
+ const semantic_type* yyvaluep]b4_locations_if([[,
+ const location_type* yylocationp]])[)
+ {]b4_locations_if([[
+ YYUSE (yylocationp);]])[
YYUSE (yyvaluep);
std::ostream& yyoutput = debug_stream ();
std::ostream& yyo = yyoutput;
YYUSE (yyo);
switch (yytype)
{
- ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
+]b4_symbol_foreach([b4_symbol_printer])dnl
[ default:
break;
}
void
]b4_parser_class_name[::yy_symbol_print_ (int yytype,
- const semantic_type* yyvaluep,
- const location_type* yylocationp)
+ const semantic_type* yyvaluep]b4_locations_if([[,
+ const location_type* yylocationp]])[)
{
*yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
- << ' ' << yytname[yytype] << " ("
- << *yylocationp << ": ";
- yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
+ << ' ' << yytname[yytype] << " ("]b4_locations_if([[
+ << *yylocationp << ": "]])[;
+ yy_symbol_value_print_ (yytype, yyvaluep]b4_locations_if([[, yylocationp]])[);
*yycdebug_ << ')';
}
#endif
]m4_popdef([b4_parse_param])dnl
-b4_namespace_close])
-
-
-# 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]]]])
+b4_namespace_close
])
-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-2012])[
-
-/* C++ GLR parser skeleton written by Akim Demaille. */
-
-]b4_cpp_guard_open([b4_spec_defines_file])[
-
-]b4_percent_code_get([[requires]])[
+# 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],
+[dnl In this section, the parse params are the original parse_params.
+m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
+b4_percent_code_get([[requires]])[
-# include <string>
-# include <iostream>
-]b4_percent_define_ifdef([[api.location.type]], [],
- [[# include "location.hh"]])[
+#include <stdexcept>
+#include <string>
+#include <iostream>]b4_defines_if([
+b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
+ [[#include "location.hh"]])])])[
]b4_YYDEBUG_define[
]b4_namespace_open[
+]b4_defines_if([],
+[b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
+ [b4_position_define
+b4_location_define])])])[
+
/// A Bison parser.
class ]b4_parser_class_name[
{
public:
- /// 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;
+]b4_public_types_declare[
/// Build a parser object.
]b4_parser_class_name[ (]b4_parse_param_decl[);
/// Set the current debugging level.
void set_debug_level (debug_level_type l);
- private:
-
public:
- /// Report a syntax error.
- /// \param loc where the syntax error is found.
+ /// Report a syntax error.]b4_locations_if([[
+ /// \param loc where the syntax error is found.]])[
/// \param msg a description of the syntax error.
- virtual void error (const location_type& loc, const std::string& msg);
- private:
+ virtual void error (]b4_locations_if([[const location_type& loc, ]])[const std::string& msg);
# if ]b4_api_PREFIX[DEBUG
public:
/// \brief Report a symbol value on the debug stream.
/// \param yytype The token type.
- /// \param yyvaluep Its semantic value.
- /// \param yylocationp Its location.
+ /// \param yyvaluep Its semantic value.]b4_locations_if([[
+ /// \param yylocationp Its location.]])[
virtual void yy_symbol_value_print_ (int yytype,
- const semantic_type* yyvaluep,
- const location_type* yylocationp);
+ const semantic_type* yyvaluep]b4_locations_if([[,
+ const location_type* yylocationp]])[);
/// \brief Report a symbol on the debug stream.
/// \param yytype The token type.
- /// \param yyvaluep Its semantic value.
- /// \param yylocationp Its location.
+ /// \param yyvaluep Its semantic value.]b4_locations_if([[
+ /// \param yylocationp Its location.]])[
virtual void yy_symbol_print_ (int yytype,
- const semantic_type* yyvaluep,
- const location_type* yylocationp);
+ const semantic_type* yyvaluep]b4_locations_if([[,
+ const location_type* yylocationp]])[);
private:
/* Debugging. */
std::ostream* yycdebug_;
-# endif
+#endif
]b4_parse_param_vars[
};
]dnl Redirections for glr.c.
b4_percent_define_flag_if([[global_tokens_and_yystype]],
-[b4_token_defines(b4_tokens)])
+[b4_token_defines])
[
#ifndef ]b4_api_PREFIX[STYPE
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
]b4_namespace_close[
]b4_percent_code_get([[provides]])[
+]m4_popdef([b4_parse_param])dnl
+])
+
+b4_defines_if(
+[m4_changecom()dnl
+m4_divert_push(0)dnl
+@output(b4_spec_defines_file@)@
+b4_copyright([Skeleton interface for Bison GLR parsers in C++],
+ [2002-2012])[
+
+/* 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_output_end()
+]b4_output_end()])
+
+# Let glr.c (and b4_shared_declarations) 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])
# --------------------------
# Join two lists with a comma if necessary.
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])
# b4_percent_define_get3(DEF, PRE, POST, NOT)
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
# otherwise NOT.
m4_define([b4_percent_define_get3],
- [m4_ifval(m4_quote(b4_percent_define_get([$1])),
- [$2[]b4_percent_define_get([$1])[]$3], [$4])])
+ [m4_ifval(m4_quote(b4_percent_define_get([$1])),
+ [$2[]b4_percent_define_get([$1])[]$3], [$4])])
m4_define([b4_int_type],
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
b4_ints_in($@, [-32768], [32767]), [1], [short],
- [int])])
+ [int])])
# b4_int_type_for(NAME)
# ---------------------
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. ##
## ------------------------- ##
-# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
-# ---------------------------------------
+# b4_token_enum(TOKEN-NUM)
+# ------------------------
# Output the definition of this token as an enum.
m4_define([b4_token_enum],
-[ /** Token number, to be returned by the scanner. */
- public static final int $1 = $2;
-])
+[b4_token_format([ /** Token number, to be returned by the scanner. */
+ static final int %s = %s;
+], [$1])])
-
-# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
-# -----------------------------------------------------
+# b4_token_enums
+# --------------
# Output the definition of the tokens (if there are) as enums.
m4_define([b4_token_enums],
-[m4_if([$#$1], [1], [],
-[/* Tokens. */
-m4_map([b4_token_enum], [$@])])
-])
+[b4_any_token_visible_if([/* Tokens. */
+b4_symbol_foreach([b4_token_enum])])])
# b4-case(ID, CODE)
# -----------------
break;
])
+# b4_predicate_case(LABEL, CONDITIONS)
+# ------------------------------------
+m4_define([b4_predicate_case], [ case $1:
+ if (! ($2)) YYERROR;
+ break;
+ ])
+
## ---------------- ##
## Default values. ##
b4_percent_define_default([[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])
m4_define([b4_location_type], [b4_percent_define_get([[api.location.type]])])
m4_define([b4_parse_param], b4_parse_param)
# b4_lex_param_decl
-# -------------------
+# -----------------
# Extra formal arguments of the constructor.
m4_define([b4_lex_param_decl],
[m4_ifset([b4_lex_param],
[b4_remove_comma([$1],
- b4_param_decls(b4_lex_param))],
- [$1])])
+ b4_param_decls(b4_lex_param))],
+ [$1])])
m4_define([b4_param_decls],
- [m4_map([b4_param_decl], [$@])])
+ [m4_map([b4_param_decl], [$@])])
m4_define([b4_param_decl], [, $1])
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
m4_define([b4_parse_param_decl],
[m4_ifset([b4_parse_param],
[b4_remove_comma([$1],
- b4_param_decls(b4_parse_param))],
- [$1])])
+ b4_param_decls(b4_parse_param))],
+ [$1])])
# b4_lex_param_call
-# -------------------
+# -----------------
# Delegating the lexer parameters to the lexer constructor.
m4_define([b4_lex_param_call],
[m4_ifset([b4_lex_param],
- [b4_remove_comma([$1],
- b4_param_calls(b4_lex_param))],
- [$1])])
+ [b4_remove_comma([$1],
+ b4_param_calls(b4_lex_param))],
+ [$1])])
m4_define([b4_param_calls],
- [m4_map([b4_param_call], [$@])])
+ [m4_map([b4_param_call], [$@])])
m4_define([b4_param_call], [, $2])
# Extra initialisations of the constructor.
m4_define([b4_parse_param_cons],
[m4_ifset([b4_parse_param],
- [b4_constructor_calls(b4_parse_param)])])
+ [b4_constructor_calls(b4_parse_param)])])
m4_define([b4_constructor_calls],
- [m4_map([b4_constructor_call], [$@])])
+ [m4_map([b4_constructor_call], [$@])])
m4_define([b4_constructor_call],
- [this.$2 = $2;
- ])
+ [this.$2 = $2;
+ ])
# Extra instance variables.
m4_define([b4_parse_param_vars],
[m4_ifset([b4_parse_param],
- [
+ [
/* User arguments. */
b4_var_decls(b4_parse_param)])])
m4_define([b4_var_decls],
- [m4_map_sep([b4_var_decl], [
+ [m4_map_sep([b4_var_decl], [
], [$@])])
m4_define([b4_var_decl],
- [ protected final $1;])
+ [ protected final $1;])
# -----------------------
# Expand to either an empty string or "throws THROWS".
m4_define([b4_maybe_throws],
- [m4_ifval($1, [throws $1])])
+ [m4_ifval($1, [throws $1])])
m4_include(b4_pkgdatadir/[c++.m4])
-m4_define([b4_parser_class_name],
- [b4_percent_define_get([[parser_class_name]])])
-# The header is mandatory.
-b4_defines_if([],
- [b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
+# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
+# --------------------------------------------------------------
+# Declare "parser::yy<TABLE-NAME>_" which contents is CONTENT.
+m4_define([b4_integral_parser_table_declare],
+[m4_ifval([$3], [b4_comment([$3], [ ])
+])dnl
+ static const b4_int_type_for([$2]) yy$1_[[]];dnl
+])
-b4_percent_define_ifdef([[api.location.type]], [],
- [# Backward compatibility.
- m4_define([b4_location_constructors])
- m4_include(b4_pkgdatadir/[location.cc])])
-m4_include(b4_pkgdatadir/[stack.hh])
+# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
+# -------------------------------------------------------------
+# Define "parser::yy<TABLE-NAME>_" which contents is CONTENT.
+m4_define([b4_integral_parser_table_define],
+[ const b4_int_type_for([$2])
+ b4_parser_class_name::yy$1_[[]] =
+ {
+ $2
+ };dnl
+])
-b4_defines_if(
-[b4_output_begin([b4_spec_defines_file])
-b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
- [2002-2012])
-[
-/**
- ** \file ]b4_spec_defines_file[
- ** Define the ]b4_namespace_ref[::parser class.
- */
-/* C++ LALR(1) parser skeleton written by Akim Demaille. */
+# b4_symbol_value_template(VAL, [TYPE])
+# -------------------------------------
+# Same as b4_symbol_value, but used in a template method. It makes
+# a difference when using variants.
+m4_copy([b4_symbol_value], [b4_symbol_value_template])
+
+
+# b4_lhs_value([TYPE])
+# --------------------
+# Expansion of $<TYPE>$.
+m4_define([b4_lhs_value],
+ [b4_symbol_value([yylhs.value], [$1])])
+
+
+# b4_lhs_location()
+# -----------------
+# Expansion of @$.
+m4_define([b4_lhs_location],
+ [yylhs.location])
+
+
+# b4_rhs_data(RULE-LENGTH, NUM)
+# -----------------------------
+# Return the data corresponding to the symbol #NUM, where the current
+# rule has RULE-LENGTH symbols on RHS.
+m4_define([b4_rhs_data],
+ [yystack_@{b4_subtract($@)@}])
+
+
+# b4_rhs_state(RULE-LENGTH, NUM)
+# ------------------------------
+# The state corresponding to the symbol #NUM, where the current
+# rule has RULE-LENGTH symbols on RHS.
+m4_define([b4_rhs_state],
+ [b4_rhs_data([$1], [$2]).state])
+
+
+# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
+# --------------------------------------
+# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
+# symbols on RHS.
+m4_define([b4_rhs_value],
+ [b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3])])
+
+
+# b4_rhs_location(RULE-LENGTH, NUM)
+# ---------------------------------
+# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
+# on RHS.
+m4_define([b4_rhs_location],
+ [b4_rhs_data([$1], [$2]).location])
+
+
+# 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],
+[m4_pushdef([b4_symbol_value], m4_defn([b4_symbol_value_template]))[]dnl
+b4_dollar_pushdef([yysym.value],
+ b4_symbol_if([$1], [has_type],
+ [m4_dquote(b4_symbol([$1], [type]))]),
+ [yysym.location])dnl
+ b4_symbol_case_([$1])
+b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"])
+ b4_symbol([$1], [$2])
+b4_syncline([@oline@], [@ofile@])
+ break;
+
+m4_popdef([b4_symbol_value])[]dnl
+b4_dollar_popdef[]dnl
+])])
-]b4_cpp_guard_open([b4_spec_defines_file])[
-]b4_percent_code_get([[requires]])[
+m4_pushdef([b4_copyright_years],
+ [2002-2012])
-#include <string>
-#include <iostream>
-#include "stack.hh"
-]b4_percent_define_ifdef([[api.location.type]], [],
- [[#include "location.hh"]])[
+m4_define([b4_parser_class_name],
+ [b4_percent_define_get([[parser_class_name]])])
+
+b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
+ [# Backward compatibility.
+ m4_define([b4_location_constructors])
+ m4_include(b4_pkgdatadir/[location.cc])])])
+m4_include(b4_pkgdatadir/[stack.hh])
+b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
+
+# b4_shared_declarations
+# ----------------------
+# Declaration that might either go into the header (if --defines)
+# or open coded in the parser body.
+m4_define([b4_shared_declarations],
+[b4_percent_code_get([[requires]])[
+]b4_parse_assert_if([# include <cassert>])[
+# include <deque>
+# include <iostream>
+# include <stdexcept>
+# include <string>]b4_defines_if([[
+# include "stack.hh"
+]b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
+ [[# include "location.hh"]])])])[
]b4_YYDEBUG_define[
]b4_namespace_open[
+]b4_defines_if([],
+[b4_stack_define
+b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
+ [b4_position_define
+b4_location_define])])])[
+
+]b4_variant_if([b4_variant_define])[
+
/// A Bison parser.
class ]b4_parser_class_name[
{
public:
- /// 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;
-
+]b4_public_types_declare[
/// Build a parser object.
]b4_parser_class_name[ (]b4_parse_param_decl[);
virtual ~]b4_parser_class_name[ ();
void set_debug_level (debug_level_type l);
#endif
- private:
- /// Report a syntax error.
- /// \param loc where the syntax error is found.
+ /// Report a syntax error.]b4_locations_if([[
+ /// \param loc where the syntax error is found.]])[
/// \param msg a description of the syntax error.
- virtual void error (const location_type& loc, const std::string& msg);
-
- /// Generate an error message.
- /// \param state the state where the error occurred.
- /// \param tok the lookahead token.
- virtual std::string yysyntax_error_ (int yystate, int tok);
-
-#if ]b4_api_PREFIX[DEBUG
- /// \brief Report a symbol value on the debug stream.
- /// \param yytype The token type.
- /// \param yyvaluep Its semantic value.
- /// \param yylocationp Its location.
- virtual void yy_symbol_value_print_ (int yytype,
- const semantic_type* yyvaluep,
- const location_type* yylocationp);
- /// \brief Report a symbol on the debug stream.
- /// \param yytype The token type.
- /// \param yyvaluep Its semantic value.
- /// \param yylocationp Its location.
- virtual void yy_symbol_print_ (int yytype,
- const semantic_type* yyvaluep,
- const location_type* yylocationp);
-#endif
+ virtual void error (]b4_locations_if([[const location_type& loc, ]])[const std::string& msg);
+ /// Report a syntax error.
+ void error (const syntax_error& err);
+ private:
/// State numbers.
typedef int state_type;
- /// State stack type.
- typedef stack<state_type> state_stack_type;
- /// Semantic value stack type.
- typedef stack<semantic_type> semantic_stack_type;
- /// location stack type.
- typedef stack<location_type> location_stack_type;
-
- /// The state stack.
- state_stack_type yystate_stack_;
- /// The semantic value stack.
- semantic_stack_type yysemantic_stack_;
- /// The location stack.
- location_stack_type yylocation_stack_;
+
+ /// Generate an error message.
+ /// \param yystate the state where the error occurred.
+ /// \param yytoken the lookahead token.
+ virtual std::string yysyntax_error_ (state_type yystate, int yytoken);
+
+ /// Compute post-reduction state.
+ /// \param yystate the current state
+ /// \param yylhs the nonterminal to push on the stack
+ state_type yy_lr_goto_state_ (state_type yystate, int yylhs);
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
/// Internal symbol numbers.
typedef ]b4_int_type_for([b4_translate])[ token_number_type;
- /* Tables. */
- /// For a state, the index in \a yytable_ of its portion.
- static const ]b4_int_type_for([b4_pact])[ yypact_[];
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
-
- /// For a state, default reduction number.
- /// Unless\a yytable_ specifies something else to do.
- /// Zero means the default is an error.
- static const ]b4_int_type_for([b4_defact])[ yydefact_[];
-
- static const ]b4_int_type_for([b4_pgoto])[ yypgoto_[];
- static const ]b4_int_type_for([b4_defgoto])[ yydefgoto_[];
-
- /// What to do in a state.
- /// \a yytable_[yypact_[s]]: what to do in state \a s.
- /// - if positive, shift that token.
- /// - if negative, reduce the rule which number is the opposite.
- /// - if zero, do what YYDEFACT says.
- static const ]b4_int_type_for([b4_table])[ yytable_[];
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
- static const ]b4_int_type_for([b4_check])[ yycheck_[];
-
- /// For a state, its accessing symbol.
- static const ]b4_int_type_for([b4_stos])[ yystos_[];
-
- /// For a rule, its LHS.
- static const ]b4_int_type_for([b4_r1])[ yyr1_[];
- /// For a rule, its RHS length.
- static const ]b4_int_type_for([b4_r2])[ yyr2_[]; ]b4_error_verbose_if([
+ // Tables.
+]b4_parser_tables_declare[]b4_error_verbose_if([
/// Convert the symbol name \a n to a form suitable for a diagnostic.
static std::string yytnamerr_ (const char *n);])[
/// For a symbol, its name in clear.
static const char* const yytname_[];
]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[
- /// A type to store symbol numbers and -1.
- typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type;
- /// A `-1'-separated list of the rules' RHS.
- static const rhs_number_type yyrhs_[];
- /// For each rule, the index of the first RHS symbol in \a yyrhs_.
- static const ]b4_int_type_for([b4_prhs])[ yyprhs_[];
- /// For each rule, its source line number.
- static const ]b4_int_type_for([b4_rline])[ yyrline_[];
- /// For each scanner token number, its symbol number.
- static const ]b4_int_type_for([b4_toknum])[ yytoken_number_[];
+]b4_integral_parser_table_declare([rline], [b4_rline],
+ [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
/// Report on the debug stream that the rule \a r is going to be reduced.
virtual void yy_reduce_print_ (int r);
/// Print the state stack on the debug stream.
virtual void yystack_print_ ();
- /* Debugging. */
+ // Debugging.
int yydebug_;
std::ostream* yycdebug_;
-#endif
+#endif // ]b4_api_PREFIX[DEBUG
/// Convert a scanner token number \a t to a symbol number.
- token_number_type yytranslate_ (int t);
+ static inline token_number_type yytranslate_ (]b4_token_ctor_if([token_type], [int])[ t);
+
+#if ]b4_api_PREFIX[DEBUG
+ /// \brief Display a symbol type, value and location.
+ /// \param yyo The output stream.
+ /// \param yysym The symbol.
+ template <typename Exact>
+ void yy_print_ (std::ostream& yyo,
+ const symbol_base_type<Exact>& yysym) const;
+#endif
/// \brief Reclaim the memory associated to a symbol.
- /// \param yymsg Why this token is reclaimed.
- /// If null, do not display the symbol, just free it.
- /// \param yytype The symbol type.
- /// \param yyvaluep Its semantic value.
- /// \param yylocationp Its location.
- inline void yydestruct_ (const char* yymsg,
- int yytype,
- semantic_type* yyvaluep,
- location_type* yylocationp);
+ /// \param yymsg Why this token is reclaimed.
+ /// If null, print nothing.
+ /// \param s The symbol.
+ template <typename Exact>
+ inline void yy_destroy_ (const char* yymsg,
+ symbol_base_type<Exact>& yysym) const;
+
+ private:
+ /// Element of the stack: a state and its attributes.
+ struct stack_symbol_type : symbol_base_type<stack_symbol_type>
+ {
+ /// The parent class.
+ typedef symbol_base_type<stack_symbol_type> super_type;
+
+ /// Default constructor.
+ inline stack_symbol_type ();
+
+ /// Constructor.
+ inline stack_symbol_type (]b4_join([state_type s],
+ [const semantic_type& v],
+ b4_locations_if([const location_type& l]))[);
+
+ /// The state.
+ state_type state;
+
+ /// The type (corresponding to \a state).
+ inline int type_get_ () const;
+ };
+
+ /// Stack type.
+ typedef stack<stack_symbol_type> stack_type;
+
+ /// The stack.
+ stack_type yystack_;
+
+ /// Push a new state on the stack.
+ /// \param m a debug message to display
+ /// if null, no trace is output.
+ /// \param s the symbol
+ /// \warning the contents of \a s.value is stolen.
+ inline void yypush_ (const char* m, stack_symbol_type& s);
+
+ /// Push a new look ahead token on the state on the stack.
+ /// \param m a debug message to display
+ /// if null, no trace is output.
+ /// \param s the state
+ /// \param sym the symbol (for its value and location).
+ /// \warning the contents of \a s.value is stolen.
+ inline void yypush_ (const char* m, state_type s, symbol_type& sym);
/// Pop \a n symbols the three stacks.
inline void yypop_ (unsigned int n = 1);
/* Constants. */
- static const int yyeof_;
- /* LAST_ -- Last index in TABLE_. */
- static const int yylast_;
- static const int yynnts_;
- static const int yyempty_;
- static const int yyfinal_;
- static const int yyterror_;
- static const int yyerrcode_;
- static const int yyntokens_;
- static const unsigned int yyuser_token_number_max_;
- static const token_number_type yyundef_token_;
+ enum
+ {
+ yyeof_ = 0,
+ yylast_ = ]b4_last[, //< Last index in yytable_.
+ yynnts_ = ]b4_nterms_number[, //< Number of nonterminal symbols.
+ yyempty_ = -2,
+ yyfinal_ = ]b4_final_state_number[, //< Termination state number.
+ yyterror_ = 1,
+ yyerrcode_ = 256,
+ yyntokens_ = ]b4_tokens_number[ //< Number of tokens.
+ };
+
]b4_parse_param_vars[
};
+
+]b4_token_ctor_if([b4_yytranslate_define
+b4_public_types_define])[
]b4_namespace_close[
]b4_percent_define_flag_if([[global_tokens_and_yystype]],
-[b4_token_defines(b4_tokens)
+[b4_token_defines
#ifndef ]b4_api_PREFIX[STYPE
/* Redirection for backward compatibility. */
#endif
])[
]b4_percent_code_get([[provides]])[
+]])
+
+# We do want M4 expansion after # for CPP macros.
+m4_changecom()
+b4_defines_if(
+[m4_divert_push(0)dnl
+@output(b4_spec_defines_file@)@
+b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
+[
+/**
+ ** \file ]b4_spec_defines_file[
+ ** Define the ]b4_namespace_ref[::parser class.
+ */
+
+/* C++ LALR(1) 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_output_end()
])
b4_output_begin([b4_parser_file_name])
-b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++],
- [2002-2012])
+b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])
b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [],
[
// Take the name prefix into account.
#define yylex b4_prefix[]lex])[
-/* First part of user declarations. */
+// First part of user declarations.
]b4_user_pre_prologue[
-]b4_defines_if([[
-#include "@basename(]b4_spec_defines_file[@)"]])[
+]b4_null_define[
+
+]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
+ [b4_shared_declarations])[
/* User implementation prologue. */
]b4_user_post_prologue[
]b4_percent_code_get[
-]b4_null_define[
-
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# endif
#endif
-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
-]b4_yylloc_default_define[
+]b4_locations_if([dnl
+[#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
+]b4_yylloc_default_define])[
/* Suppress unused-variable warnings by "using" E. */
#define YYUSE(e) ((void) (e))
/* A pseudo ostream that takes yydebug_ into account. */
# define YYCDEBUG if (yydebug_) (*yycdebug_)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug_) \
- { \
- *yycdebug_ << Title << ' '; \
- yy_symbol_print_ ((Type), (Value), (Location)); \
- *yycdebug_ << std::endl; \
- } \
-} while (false)
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug_) \
- yy_reduce_print_ (Rule); \
-} while (false)
-
-# define YY_STACK_PRINT() \
-do { \
- if (yydebug_) \
- yystack_print_ (); \
-} while (false)
+# define YY_SYMBOL_PRINT(Title, Symbol) \
+ do { \
+ if (yydebug_) \
+ { \
+ *yycdebug_ << Title << ' '; \
+ yy_print_ (*yycdebug_, Symbol); \
+ *yycdebug_ << std::endl; \
+ } \
+ } while (false)
+
+# define YY_REDUCE_PRINT(Rule) \
+ do { \
+ if (yydebug_) \
+ yy_reduce_print_ (Rule); \
+ } while (false)
+
+# define YY_STACK_PRINT() \
+ do { \
+ if (yydebug_) \
+ yystack_print_ (); \
+ } while (false)
#else /* !]b4_api_PREFIX[DEBUG */
# define YYCDEBUG if (false) std::cerr
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) YYUSE(Type)
-# define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
-# define YY_STACK_PRINT() static_cast<void>(0)
+# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol)
+# define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
+# define YY_STACK_PRINT() static_cast<void>(0)
#endif /* !]b4_api_PREFIX[DEBUG */
-#define yyerrok (yyerrstatus_ = 0)
-#define yyclearin (yychar = yyempty_)
+#define yyerrok (yyerrstatus_ = 0)
+#define yyclearin (yyempty = true)
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
#define YYRECOVERING() (!!yyerrstatus_)
]b4_namespace_open[]b4_error_verbose_if([[
{
}
-#if ]b4_api_PREFIX[DEBUG
- /*--------------------------------.
- | Print this symbol on YYOUTPUT. |
- `--------------------------------*/
- inline void
- ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
- const semantic_type* yyvaluep, const location_type* yylocationp)
+ /*---------------.
+ | Symbol types. |
+ `---------------*/
+
+]b4_token_ctor_if([], [b4_public_types_define])[
+
+ // stack_symbol_type.
+ ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
+ : super_type ()
+ , state ()
+ {
+ }
+
+ ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (]b4_join(
+ [state_type s],
+ [const semantic_type& v],
+ b4_locations_if([const location_type& l]))[)
+ : super_type (v]b4_locations_if([, l])[)
+ , state (s)
+ {
+ }
+
+ int
+ ]b4_parser_class_name[::stack_symbol_type::type_get_ () const
+ {
+ return yystos_[state];
+ }
+
+
+ template <typename Exact>
+ void
+ ]b4_parser_class_name[::yy_destroy_ (const char* yymsg,
+ symbol_base_type<Exact>& yysym) const
+ {
+ if (yymsg)
+ YY_SYMBOL_PRINT (yymsg, yysym);
+
+ // User destructor.
+ int yytype = yysym.type_get ();
+ switch (yytype)
+ {
+]b4_symbol_foreach([b4_symbol_destructor])dnl
+[ default:
+ break;
+ }]b4_variant_if([
+
+ // Type destructor.
+ b4_symbol_variant([[yytype]], [[yysym.value]], [[template destroy]])])[
+ }
+
+#if ]b4_api_PREFIX[DEBUG
+ template <typename Exact>
+ void
+ ]b4_parser_class_name[::yy_print_ (std::ostream& yyo,
+ const symbol_base_type<Exact>& yysym) const
{
- YYUSE (yylocationp);
- YYUSE (yyvaluep);
- std::ostream& yyo = debug_stream ();
std::ostream& yyoutput = yyo;
YYUSE (yyoutput);
+ int yytype = yysym.type_get ();
+ yyo << (yytype < yyntokens_ ? "token" : "nterm")
+ << ' ' << yytname_[yytype] << " ("]b4_locations_if([
+ << yysym.location << ": "])[;
switch (yytype)
{
- ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
+]b4_symbol_foreach([b4_symbol_printer])dnl
[ default:
- break;
+ break;
}
+ yyo << ')';
}
-
+#endif
void
- ]b4_parser_class_name[::yy_symbol_print_ (int yytype,
- const semantic_type* yyvaluep, const location_type* yylocationp)
+ ]b4_parser_class_name[::yypush_ (const char* m, state_type s,
+ symbol_type& sym)
{
- *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
- << ' ' << yytname_[yytype] << " ("
- << *yylocationp << ": ";
- yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
- *yycdebug_ << ')';
+ if (m)
+ YY_SYMBOL_PRINT (m, sym);
+]b4_variant_if(
+[[ yystack_.push (stack_symbol_type (]b4_join(
+ [s],
+ [semantic_type()],
+ b4_locations_if([sym.location]))[));
+ ]b4_symbol_variant([[yystos_[s]]], [[yystack_[0].value]],
+ [build], [sym.value])],
+[[ yystack_.push (stack_symbol_type (]b4_join(
+ [s],
+ [sym.value],
+ b4_locations_if([sym.location]))[));]])[
}
-#endif
void
- ]b4_parser_class_name[::yydestruct_ (const char* yymsg,
- int yytype, semantic_type* yyvaluep, location_type* yylocationp)
+ ]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s)
{
- YYUSE (yylocationp);
- YYUSE (yymsg);
- YYUSE (yyvaluep);
-
- if (yymsg)
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- switch (yytype)
- {
- ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
- default:
- break;
- }
+ if (m)
+ YY_SYMBOL_PRINT (m, s);
+]b4_variant_if(
+[[ yystack_.push (stack_symbol_type (]b4_join(
+ [s.state],
+ [semantic_type()],
+ b4_locations_if([s.location]))[));
+ ]b4_symbol_variant([[yystos_[s.state]]], [[yystack_[0].value]],
+ [build], [s.value])],
+[ yystack_.push (s);])[
}
void
]b4_parser_class_name[::yypop_ (unsigned int n)
{
- yystate_stack_.pop (n);
- yysemantic_stack_.pop (n);
- yylocation_stack_.pop (n);
+ yystack_.pop (n);
}
#if ]b4_api_PREFIX[DEBUG
{
yydebug_ = l;
}
-#endif
+#endif // ]b4_api_PREFIX[DEBUG
+
+ inline ]b4_parser_class_name[::state_type
+ ]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yylhs)
+ {
+ int yyr = yypgoto_[yylhs - yyntokens_] + yystate;
+ if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
+ return yytable_[yyr];
+ else
+ return yydefgoto_[yylhs - yyntokens_];
+ }
inline bool
]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue)
int
]b4_parser_class_name[::parse ()
{
- /// Lookahead and lookahead in internal form.
- int yychar = yyempty_;
- int yytoken = 0;
+ /// Whether yyla contains a lookahead.
+ bool yyempty = true;
// State.
int yyn;
int yylen = 0;
- int yystate = 0;
// Error handling.
int yynerrs_ = 0;
int yyerrstatus_ = 0;
- /// Semantic value of the lookahead.
- static semantic_type yyval_default;
- semantic_type yylval = yyval_default;
- /// Location of the lookahead.
- location_type yylloc;
+ /// The lookahead symbol.
+ symbol_type yyla;]b4_locations_if([[
+
/// The locations where the error started and ended.
- location_type yyerror_range[3];
+ stack_symbol_type yyerror_range[3];]])[
- /// $$.
- semantic_type yyval;
- /// @@$.
- location_type yyloc;
+ /// $$ and @@$.
+ stack_symbol_type yylhs;
+ /// The return value of parse ().
int yyresult;
// FIXME: This shoud be completely indented. It is not yet to
YYCDEBUG << "Starting parse" << std::endl;
]m4_ifdef([b4_initial_action], [
-b4_dollar_pushdef([yylval], [], [yylloc])dnl
-/* User initialization code. */
-b4_user_initial_action
+b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl
+ /* User initialization code. */
+ b4_user_initial_action
b4_dollar_popdef])[]dnl
- [ /* Initialize the stacks. The initial state will be pushed in
+ [ /* Initialize the stack. The initial state will be set in
yynewstate, since the latter expects the semantical and the
location values to have been already stored, initialize these
stacks with a primary value. */
- yystate_stack_ = state_stack_type (0);
- yysemantic_stack_ = semantic_stack_type (0);
- yylocation_stack_ = location_stack_type (0);
- yysemantic_stack_.push (yylval);
- yylocation_stack_.push (yylloc);
+ yystack_ = stack_type (0);
+ yypush_ (YY_NULL, 0, yyla);
- /* New state. */
+ // A new symbol was pushed on the stack.
yynewstate:
- yystate_stack_.push (yystate);
- YYCDEBUG << "Entering state " << yystate << std::endl;
+ YYCDEBUG << "Entering state " << yystack_[0].state << std::endl;
/* Accept? */
- if (yystate == yyfinal_)
+ if (yystack_[0].state == yyfinal_)
goto yyacceptlab;
goto yybackup;
yybackup:
/* Try to take a decision without lookahead. */
- yyn = yypact_[yystate];
+ yyn = yypact_[yystack_[0].state];
if (yy_pact_value_is_default_ (yyn))
goto yydefault;
/* Read a lookahead token. */
- if (yychar == yyempty_)
+ if (yyempty)
{
YYCDEBUG << "Reading a token: ";
- yychar = ]b4_c_function_call([yylex], [int],
- [b4_api_PREFIX[STYPE*], [&yylval]][]dnl
-b4_locations_if([, [[location*], [&yylloc]]])dnl
-m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
- }
-
- /* Convert token to internal form. */
- if (yychar <= yyeof_)
- {
- yychar = yytoken = yyeof_;
- YYCDEBUG << "Now at end of input." << std::endl;
- }
- else
- {
- yytoken = yytranslate_ (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ try
+ {
+]b4_token_ctor_if(
+[ yyla = b4_function_call([yylex], [symbol_type],
+ m4_ifdef([b4_lex_param], b4_lex_param));],
+[ yyla.type = yytranslate_ (b4_function_call([yylex], [int],
+ [b4_api_PREFIX[STYPE*], [&yyla.value]][]dnl
+b4_locations_if([, [[location*], [&yyla.location]]])dnl
+m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
+ }
+ catch (const syntax_error& yyexc)
+ {
+ error (yyexc);
+ goto yyerrlab1;
+ }
+ yyempty = false;
}
+ YY_SYMBOL_PRINT ("Next token is", yyla);
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
+ /* If the proper action on seeing token YYLA.TYPE is to reduce or
+ to detect an error, take that action. */
+ yyn += yyla.type;
+ if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type)
goto yydefault;
/* Reduce or error. */
yyn = yytable_[yyn];
if (yyn <= 0)
{
- if (yy_table_value_is_error_ (yyn))
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
+ if (yy_table_value_is_error_ (yyn))
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
}
- /* Shift the lookahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
/* Discard the token being shifted. */
- yychar = yyempty_;
-
- yysemantic_stack_.push (yylval);
- yylocation_stack_.push (yylloc);
+ yyempty = true;
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus_)
--yyerrstatus_;
- yystate = yyn;
+ /* Shift the lookahead token. */
+ yypush_ ("Shifting", yyn, yyla);
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
- yyn = yydefact_[yystate];
+ yyn = yydefact_[yystack_[0].state];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
`-----------------------------*/
yyreduce:
yylen = yyr2_[yyn];
+ yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([
+ /* Variants are always initialized to an empty instance of the
+ correct type. The default $$=$1 action is NOT applied when using
+ variants. */
+ b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build])],[
/* If YYLEN is nonzero, implement the default value of the action:
`$$ = $1'. Otherwise, use the top of the stack.
- Otherwise, the following line sets YYVAL to garbage.
+ Otherwise, the following line sets YYLHS.VALUE to garbage.
This behavior is undocumented and Bison
users should not rely upon it. */
if (yylen)
- yyval = yysemantic_stack_[yylen - 1];
+ yylhs.value = yystack_@{yylen - 1@}.value;
else
- yyval = yysemantic_stack_[0];
-
+ yylhs.value = yystack_@{0@}.value;])[
+]b4_locations_if([dnl
+[
// Compute the default @@$.
{
- slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
- YYLLOC_DEFAULT (yyloc, slice, yylen);
- }
+ slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
+ YYLLOC_DEFAULT (yylhs.location, slice, yylen);
+ }]])[
// Perform the reduction.
YY_REDUCE_PRINT (yyn);
- switch (yyn)
+ try
{
- ]b4_user_actions[
- default:
- break;
+ switch (yyn)
+ {
+]b4_user_actions[
+ default:
+ break;
+ }
}
-
- /* 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. */
- YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
+ catch (const syntax_error& yyexc)
+ {
+ error (yyexc);
+ YYERROR;
+ }
+ YY_SYMBOL_PRINT ("-> $$ =", yylhs);
+]b4_variant_if([[
+ // Destroy the rhs symbols.
+ for (int i = 0; i < yylen; ++i)
+ // Destroy a variant which value may have been swapped with
+ // yylhs.value (for instance if the action was "std::swap($$,
+ // $1)"). The value of yylhs.value (hence possibly one of these
+ // rhs symbols) depends on the default construction for this
+ // type. In the case of pointers for instance, no
+ // initialization is done, so the value is junk. Therefore do
+ // not try to report the value of symbols about to be destroyed
+ // in the debug trace, it's possibly junk. Hence yymsg = 0.
+ // Besides, that keeps exactly the same traces as with the other
+ // Bison skeletons.
+ yy_destroy_ (YY_NULL, yystack_[i]);]])[
yypop_ (yylen);
yylen = 0;
YY_STACK_PRINT ();
- yysemantic_stack_.push (yyval);
- yylocation_stack_.push (yyloc);
-
/* Shift the result of the reduction. */
- yyn = yyr1_[yyn];
- yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
- if (0 <= yystate && yystate <= yylast_
- && yycheck_[yystate] == yystate_stack_[0])
- yystate = yytable_[yystate];
- else
- yystate = yydefgoto_[yyn - yyntokens_];
+ yypush_ (YY_NULL, yylhs);
goto yynewstate;
- /*------------------------------------.
- | yyerrlab -- here on detecting error |
- `------------------------------------*/
+ /*--------------------------------------.
+ | yyerrlab -- here on detecting error. |
+ `--------------------------------------*/
yyerrlab:
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = yytranslate_ (yychar);
-
/* If not already recovering from an error, report this error. */
if (!yyerrstatus_)
{
- ++yynerrs_;
- if (yychar == yyempty_)
- yytoken = yyempty_;
- error (yylloc, yysyntax_error_ (yystate, yytoken));
+ ++yynerrs_;
+ error (]b4_join(b4_locations_if([yyla.location]),
+ [[yysyntax_error_ (yystack_[0].state,
+ yyempty ? yyempty_ : yyla.type)]])[);
}
- yyerror_range[1] = yylloc;
+]b4_locations_if([[
+ yyerror_range[1].location = yyla.location;]])[
if (yyerrstatus_ == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
- if (yychar <= yyeof_)
- {
- /* Return failure if at end of input. */
- if (yychar == yyeof_)
- YYABORT;
- }
- else
+
+ /* Return failure if at end of input. */
+ if (yyla.type == yyeof_)
+ YYABORT;
+ else if (!yyempty)
{
- yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
- yychar = yyempty_;
+ yy_destroy_ ("Error: discarding", yyla);
+ yyempty = true;
}
}
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (false)
- goto yyerrorlab;
-
- yyerror_range[1] = yylocation_stack_[yylen - 1];
+ goto yyerrorlab;]b4_locations_if([[
+ yyerror_range[1].location = yystack_[yylen - 1].location;]])b4_variant_if([[
+ /* $$ was initialized before running the user action. */
+ yy_destroy_ ("Error: discarding", yylhs);]])[
/* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */
yypop_ (yylen);
yylen = 0;
- yystate = yystate_stack_[0];
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
- yyerrstatus_ = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact_[yystate];
- if (!yy_pact_value_is_default_ (yyn))
- {
- yyn += yyterror_;
- if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
- {
- yyn = yytable_[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yystate_stack_.height () == 1)
- YYABORT;
-
- yyerror_range[1] = yylocation_stack_[0];
- yydestruct_ ("Error: popping",
- yystos_[yystate],
- &yysemantic_stack_[0], &yylocation_stack_[0]);
- yypop_ ();
- yystate = yystate_stack_[0];
- YY_STACK_PRINT ();
- }
-
- yyerror_range[2] = yylloc;
- // Using YYLLOC is tempting, but would change the location of
- // the lookahead. YYLOC is available though.
- YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
- yysemantic_stack_.push (yylval);
- yylocation_stack_.push (yyloc);
+ yyerrstatus_ = 3; /* Each real token shifted decrements this. */
+ {
+ stack_symbol_type error_token;
+ for (;;)
+ {
+ yyn = yypact_[yystack_[0].state];
+ if (!yy_pact_value_is_default_ (yyn))
+ {
+ yyn += yyterror_;
+ if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
+ {
+ yyn = yytable_[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
- &yysemantic_stack_[0], &yylocation_stack_[0]);
+ // Pop the current state because it cannot handle the error token.
+ if (yystack_.size () == 1)
+ YYABORT;
+]b4_locations_if([[
+ yyerror_range[1].location = yystack_[0].location;]])[
+ yy_destroy_ ("Error: popping", yystack_[0]);
+ yypop_ ();
+ YY_STACK_PRINT ();
+ }
+]b4_locations_if([[
+ yyerror_range[2].location = yyla.location;
+ YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);]])[
- yystate = yyn;
+ /* Shift the error token. */
+ error_token.state = yyn;
+ yypush_ ("Shifting", error_token);
+ }
goto yynewstate;
/* Accept. */
goto yyreturn;
yyreturn:
- if (yychar != yyempty_)
- {
- /* Make sure we have latest lookahead translation. See comments
- at user semantic actions for why this is necessary. */
- yytoken = yytranslate_ (yychar);
- yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval,
- &yylloc);
- }
+ if (!yyempty)
+ yy_destroy_ ("Cleanup: discarding lookahead", yyla);
/* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */
yypop_ (yylen);
- while (1 < yystate_stack_.height ())
+ while (1 < yystack_.size ())
{
- yydestruct_ ("Cleanup: popping",
- yystos_[yystate_stack_[0]],
- &yysemantic_stack_[0],
- &yylocation_stack_[0]);
+ yy_destroy_ ("Cleanup: popping", yystack_[0]);
yypop_ ();
}
return yyresult;
- }
+ }
catch (...)
{
YYCDEBUG << "Exception caught: cleaning lookahead and stack"
<< std::endl;
// Do not try to display the values of the reclaimed symbols,
// as their printer might throw an exception.
- if (yychar != yyempty_)
- {
- /* Make sure we have latest lookahead translation. See
- comments at user semantic actions for why this is
- necessary. */
- yytoken = yytranslate_ (yychar);
- yydestruct_ (YY_NULL, yytoken, &yylval, &yylloc);
- }
+ if (!yyempty)
+ yy_destroy_ (YY_NULL, yyla);
- while (1 < yystate_stack_.height ())
+ while (1 < yystack_.size ())
{
- yydestruct_ (YY_NULL,
- yystos_[yystate_stack_[0]],
- &yysemantic_stack_[0],
- &yylocation_stack_[0]);
+ yy_destroy_ (YY_NULL, yystack_[0]);
yypop_ ();
}
throw;
}
}
+ void
+ ]b4_parser_class_name[::error (const syntax_error& yyexc)
+ {
+ error (]b4_join(b4_locations_if([yyexc.location]),
+ [[yyexc.what()]])[);
+ }
+
// Generate an error message.
std::string
]b4_parser_class_name[::yysyntax_error_ (]dnl
-b4_error_verbose_if([int yystate, int yytoken],
+b4_error_verbose_if([state_type yystate, int yytoken],
[int, int])[)
{]b4_error_verbose_if([[
std::string yyres;
a consistent state with a default action. There might have
been a previous inconsistent state, consistent state with a
non-default action, or user semantic action that manipulated
- yychar.
+ yyla. (However, yyla is currently not documented for users.)
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
}
- /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[;
- const ]b4_int_type_for([b4_pact])[
- ]b4_parser_class_name[::yypact_[] =
- {
- ]b4_pact[
- };
-
- /* YYDEFACT[S] -- default reduction number in state S. Performed when
- YYTABLE doesn't specify something else to do. Zero means the
- default is an error. */
- const ]b4_int_type_for([b4_defact])[
- ]b4_parser_class_name[::yydefact_[] =
- {
- ]b4_defact[
- };
- /* YYPGOTO[NTERM-NUM]. */
- const ]b4_int_type_for([b4_pgoto])[
- ]b4_parser_class_name[::yypgoto_[] =
- {
- ]b4_pgoto[
- };
-
- /* YYDEFGOTO[NTERM-NUM]. */
- const ]b4_int_type_for([b4_defgoto])[
- ]b4_parser_class_name[::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. */
const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[;
- const ]b4_int_type_for([b4_table])[
- ]b4_parser_class_name[::yytable_[] =
- {
- ]b4_table[
- };
-
- /* YYCHECK. */
- const ]b4_int_type_for([b4_check])[
- ]b4_parser_class_name[::yycheck_[] =
- {
- ]b4_check[
- };
-
- /* STOS_[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
- const ]b4_int_type_for([b4_stos])[
- ]b4_parser_class_name[::yystos_[] =
- {
- ]b4_stos[
- };
-#if ]b4_api_PREFIX[DEBUG
- /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
- to YYLEX-NUM. */
- const ]b4_int_type_for([b4_toknum])[
- ]b4_parser_class_name[::yytoken_number_[] =
- {
- ]b4_toknum[
- };
-#endif
-
- /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
- const ]b4_int_type_for([b4_r1])[
- ]b4_parser_class_name[::yyr1_[] =
- {
- ]b4_r1[
- };
-
- /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
- const ]b4_int_type_for([b4_r2])[
- ]b4_parser_class_name[::yyr2_[] =
- {
- ]b4_r2[
- };
+]b4_parser_tables_define[
]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
const char*
const ]b4_parser_class_name[::yytname_[] =
{
- ]b4_tname[
+ ]b4_tname[
};
]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[
- /* YYRHS -- A `-1'-separated list of the rules' RHS. */
- const ]b4_parser_class_name[::rhs_number_type
- ]b4_parser_class_name[::yyrhs_[] =
- {
- ]b4_rhs[
- };
-
- /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- YYRHS. */
- const ]b4_int_type_for([b4_prhs])[
- ]b4_parser_class_name[::yyprhs_[] =
- {
- ]b4_prhs[
- };
-
- /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
- const ]b4_int_type_for([b4_rline])[
- ]b4_parser_class_name[::yyrline_[] =
- {
- ]b4_rline[
- };
+]b4_integral_parser_table_define([rline], [b4_rline])[
// Print the state stack on the debug stream.
void
]b4_parser_class_name[::yystack_print_ ()
{
*yycdebug_ << "Stack now";
- for (state_stack_type::const_iterator i = yystate_stack_.begin ();
- i != yystate_stack_.end (); ++i)
- *yycdebug_ << ' ' << *i;
+ for (stack_type::const_iterator
+ i = yystack_.begin (),
+ i_end = yystack_.end ();
+ i != i_end; ++i)
+ *yycdebug_ << ' ' << i->state;
*yycdebug_ << std::endl;
}
int yynrhs = yyr2_[yyrule];
/* Print the symbols being reduced, and their result. */
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
- << " (line " << yylno << "):" << std::endl;
+ << " (line " << yylno << "):" << std::endl;
/* The symbols being reduced. */
for (int yyi = 0; yyi < yynrhs; yyi++)
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
- yyrhs_[yyprhs_[yyrule] + yyi],
- &]b4_rhs_value(yynrhs, yyi + 1)[,
- &]b4_rhs_location(yynrhs, yyi + 1)[);
+ ]b4_rhs_data(yynrhs, yyi + 1)[);
}
#endif // ]b4_api_PREFIX[DEBUG
- /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
- ]b4_parser_class_name[::token_number_type
- ]b4_parser_class_name[::yytranslate_ (int t)
- {
- static
- const token_number_type
- translate_table[] =
- {
- ]b4_translate[
- };
- if ((unsigned int) t <= yyuser_token_number_max_)
- return translate_table[t];
- else
- return yyundef_token_;
- }
-
- const int ]b4_parser_class_name[::yyeof_ = 0;
- const int ]b4_parser_class_name[::yylast_ = ]b4_last[;
- const int ]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[;
- const int ]b4_parser_class_name[::yyempty_ = -2;
- const int ]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[;
- const int ]b4_parser_class_name[::yyterror_ = 1;
- const int ]b4_parser_class_name[::yyerrcode_ = 256;
- const int ]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[;
-
- const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[;
- const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
-
+]b4_token_ctor_if([], [b4_yytranslate_define])[
]b4_namespace_close[
]b4_epilogue[]dnl
b4_output_end()
+
+
+m4_popdef([b4_copyright_years])dnl
m4_include(b4_pkgdatadir/[java.m4])
-b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], [b4_skeleton])])
-m4_ifval(m4_defn([b4_symbol_destructors]),
- [b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])],
- [])
+b4_defines_if([b4_fatal([%s: %%defines 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_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
])[/* First part of user declarations. */
-]b4_pre_prologue
+]b4_user_pre_prologue
+b4_user_post_prologue
b4_percent_code_get([[imports]])
[/**
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
*
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
*/
-]b4_public_if([public ])dnl
+]b4_percent_define_get3([annotations], [], [ ])dnl
+b4_public_if([public ])dnl
b4_abstract_if([abstract ])dnl
b4_final_if([final ])dnl
b4_strictfp_if([strictfp ])dnl
b4_percent_define_get3([implements], [ implements ])[
{
]b4_identification[
-
+]b4_error_verbose_if([[
/** True if verbose error messages are enabled. */
- public boolean errorVerbose = ]b4_flag_value([error_verbose]);
+ private boolean yyErrorVerbose = true;
+
+ /**
+ * 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([[
/**
]])
-[ /** 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([[
private ]b4_location_type[ yylloc (YYStack rhs, int n)
{
* parser <tt>]b4_parser_class_name[</tt>.
*/
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([[/**
* Method to retrieve the beginning position of the last scanned token.
* @@return the position at which the last scanned token starts. */
*
* ]b4_locations_if([[@@param loc The location of the element to which the
* error message is related]])[
- * @@param s The string for the error message. */
- void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s);]
+ * @@param msg The string for the error message. */
+ void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String msg);]
}
b4_lexer_if([[private class YYLexer implements Lexer {
/**
* Instantiates the Bison-generated parser.
*/
- public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) {
+ public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) ]b4_maybe_throws([b4_init_throws])[
+ {
+ ]b4_percent_code_get([[init]])[
this.yylexer = new YYLexer(]b4_lex_param_call[);
]b4_parse_param_cons[
}
* Instantiates the Bison-generated 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_lexer_if([[protected]], [[public]]) b4_parser_class_name[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
+ {
+ ]b4_percent_code_get([[init]])[
this.yylexer = yylexer;
]b4_parse_param_cons[
}
*/
public final void setDebugLevel(int level) { yydebug = level; }
- private final int yylex () ]b4_maybe_throws([b4_lex_throws]) [{
- return yylexer.yylex ();
+ /**
+ * Print an error message via the lexer.
+ *]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);
}
- protected final void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s) {
- yylexer.yyerror (]b4_locations_if([loc, ])[s);
+]b4_locations_if([[
+ /**
+ * 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([
- protected final void yyerror (String s) {
- yylexer.yyerror ((]b4_location_type[)null, s);
- }
- protected final void yyerror (]b4_position_type[ loc, String s) {
- yylexer.yyerror (new ]b4_location_type[ (loc), s);
- }])
+ /**
+ * Print an error message via the lexer.
+ * @@param pos The position associated with the message.
+ * @@param msg The error message.
+ */
+ public final void yyerror (]b4_position_type[ pos, String msg)
+ {
+ yylexer.yyerror (new ]b4_location_type[ (pos), msg);
+ }]])
[protected final void yycdebug (String s) {
if (yydebug > 0)
public int height = -1;
public final void push (int state, ]b4_yystype[ value]dnl
- b4_locations_if([, ]b4_location_type[ loc])[) {
+ b4_locations_if([, ]b4_location_type[ loc])[) {
height++;
if (size == height)
{
- int[] newStateStack = new int[size * 2];
- System.arraycopy (stateStack, 0, newStateStack, 0, height);
- stateStack = newStateStack;
- ]b4_locations_if([[
- ]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];
- System.arraycopy (locStack, 0, newLocStack, 0, height);
- locStack = newLocStack;]])
-
- b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2];
- System.arraycopy (valueStack, 0, newValueStack, 0, height);
- valueStack = newValueStack;
-
- size *= 2;
- }
+ int[] newStateStack = new int[size * 2];
+ System.arraycopy (stateStack, 0, newStateStack, 0, height);
+ stateStack = newStateStack;
+ ]b4_locations_if([[
+ ]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];
+ System.arraycopy (locStack, 0, newLocStack, 0, height);
+ locStack = newLocStack;]])
+
+ b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2];
+ System.arraycopy (valueStack, 0, newValueStack, 0, height);
+ valueStack = newValueStack;
+
+ size *= 2;
+ }
stateStack[height] = state;
]b4_locations_if([[locStack[height] = loc;]])[
public final void pop (int num) {
// Avoid memory leaks... garbage collection is a white lie!
if (num > 0) {
- java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null);
+ java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null);
]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[
}
height -= num;
for (int i = 0; i <= height; i++)
{
- out.print (' ');
- out.print (stateStack[i]);
+ out.print (' ');
+ out.print (stateStack[i]);
}
out.println ();
}
switch (yyn)
{
- ]b4_user_actions[
- default: break;
+ ]b4_user_actions[
+ default: break;
}
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
yyn = yyr1_[yyn];
int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0);
if (0 <= yystate && yystate <= yylast_
- && yycheck_[yystate] == yystack.stateAt (0))
+ && yycheck_[yystate] == yystack.stateAt (0))
yystate = yytable_[yystate];
else
yystate = yydefgoto_[yyn - yyntokens_];
return YYNEWSTATE;
}
+]b4_error_verbose_if([[
/* Return YYSTR after stripping away unnecessary quotes and
backslashes, so that it's suitable for yyerror. The heuristic is
that double-quoting is unnecessary unless the string contains an
break strip_quotes;
case '\\':
- if (yystr.charAt(++i) != '\\')
+ if (yystr.charAt(++i) != '\\')
break strip_quotes;
/* Fall through. */
default:
return yystr;
}
+]])[
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
private void yy_symbol_print (String s, int yytype,
- ]b4_yystype[ yyvaluep]dnl
- b4_locations_if([, Object yylocationp])[)
+ ]b4_yystype[ yyvaluep]dnl
+ b4_locations_if([, Object yylocationp])[)
{
if (yydebug > 0)
yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ")
- + yytname_[yytype] + " ("]b4_locations_if([
- + yylocationp + ": "])[
- + (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
+ + yytname_[yytype] + " ("]b4_locations_if([
+ + yylocationp + ": "])[
+ + (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
}
/**
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yylval], [], [yylloc])dnl
-/* User initialization code. */
-b4_user_initial_action
+ /* User initialization code. */
+ b4_user_initial_action
b4_dollar_popdef])[]dnl
[ /* Initialize the stack. */
switch (label)
{
/* New state. Unlike in the C/C++ skeletons, the state is already
- pushed when we come here. */
+ pushed when we come here. */
case YYNEWSTATE:
yycdebug ("Entering state " + yystate + "\n");
if (yydebug > 0)
if (yy_pact_value_is_default_ (yyn))
{
label = YYDEFAULT;
- break;
+ break;
}
/* Read a lookahead token. */
if (yychar == yyempty_)
{
- yycdebug ("Reading a token: ");
- yychar = yylex ();]
+ yycdebug ("Reading a token: ");
+ yychar = yylexer.yylex ();]
b4_locations_if([[
- yylloc = new ]b4_location_type[(yylexer.getStartPos (),
- yylexer.getEndPos ());]])
+ yylloc = new ]b4_location_type[(yylexer.getStartPos (),
+ yylexer.getEndPos ());]])
yylval = yylexer.getLVal ();[
}
/* Convert token to internal form. */
- if (yychar <= EOF)
+ if (yychar <= Lexer.EOF)
{
- yychar = yytoken = EOF;
- yycdebug ("Now at end of input.\n");
+ yychar = yytoken = Lexer.EOF;
+ yycdebug ("Now at end of input.\n");
}
else
{
- yytoken = yytranslate_ (yychar);
- yy_symbol_print ("Next token is", yytoken,
- yylval]b4_locations_if([, yylloc])[);
+ yytoken = yytranslate_ (yychar);
+ yy_symbol_print ("Next token is", yytoken,
+ yylval]b4_locations_if([, yylloc])[);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
/* <= 0 means reduce or error. */
else if ((yyn = yytable_[yyn]) <= 0)
{
- if (yy_table_value_is_error_ (yyn))
- label = YYERRLAB;
- else
- {
- yyn = -yyn;
- label = YYREDUCE;
- }
+ if (yy_table_value_is_error_ (yyn))
+ label = YYERRLAB;
+ else
+ {
+ yyn = -yyn;
+ label = YYREDUCE;
+ }
}
else
{
/* Shift the lookahead token. */
- yy_symbol_print ("Shifting", yytoken,
- yylval]b4_locations_if([, yylloc])[);
+ yy_symbol_print ("Shifting", yytoken,
+ yylval]b4_locations_if([, yylloc])[);
/* Discard the token being shifted. */
yychar = yyempty_;
case YYREDUCE:
yylen = yyr2_[yyn];
label = yyaction (yyn, yystack, yylen);
- yystate = yystack.stateAt (0);
+ yystate = yystack.stateAt (0);
break;
/*------------------------------------.
]b4_locations_if([yyerrloc = yylloc;])[
if (yyerrstatus_ == 3)
{
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
-
- if (yychar <= EOF)
- {
- /* Return failure if at end of input. */
- if (yychar == EOF)
- return false;
- }
- else
- yychar = yyempty_;
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= Lexer.EOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == Lexer.EOF)
+ return false;
+ }
+ else
+ yychar = yyempty_;
}
/* Else will try to reuse lookahead token after shifting the error
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
case YYERRLAB1:
- yyerrstatus_ = 3; /* Each real token shifted decrements this. */
+ yyerrstatus_ = 3; /* Each real token shifted decrements this. */
for (;;)
{
- yyn = yypact_[yystate];
- if (!yy_pact_value_is_default_ (yyn))
- {
- yyn += yyterror_;
- if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
- {
- yyn = yytable_[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yystack.height == 0)
- return false;
-
- ]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
- yystack.pop ();
- yystate = yystack.stateAt (0);
- if (yydebug > 0)
- yystack.print (yyDebugStream);
+ yyn = yypact_[yystate];
+ if (!yy_pact_value_is_default_ (yyn))
+ {
+ yyn += yyterror_;
+ if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
+ {
+ yyn = yytable_[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yystack.height == 0)
+ return false;
+
+ ]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
+ yystack.pop ();
+ yystate = yystack.stateAt (0);
+ if (yydebug > 0)
+ yystack.print (yyDebugStream);
}
- ]b4_locations_if([
- /* Muck with the stack to setup for yylloc. */
- yystack.push (0, null, yylloc);
- yystack.push (0, null, yyerrloc);
+ ]b4_locations_if([
+ /* Muck with the stack to setup for yylloc. */
+ yystack.push (0, null, yylloc);
+ yystack.push (0, null, yyerrloc);
yyloc = yylloc (yystack, 2);
- yystack.pop (2);])[
+ yystack.pop (2);])[
/* Shift the error token. */
yy_symbol_print ("Shifting", yystos_[yyn],
- yylval]b4_locations_if([, yyloc])[);
+ yylval]b4_locations_if([, yyloc])[);
yystate = yyn;
- yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
+ yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
label = YYNEWSTATE;
break;
// Generate an error message.
private String yysyntax_error (int yystate, int tok)
- {
- if (errorVerbose)
+ {]b4_error_verbose_if([[
+ if (yyErrorVerbose)
{
/* 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 the only way this function was invoked is if the
default action is an error action. In that case, don't
return res.toString ();
}
}
-
+]])[
return "syntax error";
}
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_[] =
- {
- ]b4_pact[
- };
-
- /* YYDEFACT[S] -- default reduction number in state S. Performed when
- YYTABLE doesn't specify something else to do. Zero means the
- default is an error. */
- 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[
- };
+ ]b4_parser_tables_define[
+ ]b4_integral_parser_table_define([token_number], [b4_toknum],
+ [TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
+ to YYLEX-NUM.])[
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
- private static final String yytname_[] =
- {
- ]b4_tname[
- };
-
- /* YYRHS -- A `-1'-separated list of the rules' RHS. */
- private static final ]b4_int_type_for([b4_rhs])[ yyrhs_[] =
- {
- ]b4_rhs[
- };
+ ]b4_typed_parser_table_define([String], [tname], [b4_tname])[
- /* 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[
- };
+ ]b4_integral_parser_table_define([rline], [b4_rline],
+ [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
// Report on the debug stream that the rule yyrule is going to be reduced.
private void yy_reduce_print (int yyrule, YYStack yystack)
int yynrhs = yyr2_[yyrule];
/* Print the symbols being reduced, and their result. */
yycdebug ("Reducing stack by rule " + (yyrule - 1)
- + " (line " + yylno + "), ");
+ + " (line " + yylno + "), ");
/* The symbols being reduced. */
for (int yyi = 0; yyi < yynrhs; yyi++)
yy_symbol_print (" $" + (yyi + 1) + " =",
- yyrhs_[yyprhs_[yyrule] + yyi],
- ]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
- b4_rhs_location(yynrhs, yyi + 1)])[);
+ yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
+ ]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
+ b4_rhs_location(yynrhs, yyi + 1)])[);
}
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
- private static final ]b4_int_type_for([b4_translate])[ yytranslate_table_[] =
- {
- ]b4_translate[
- };
+ ]b4_integral_parser_table_define([translate_table], [b4_translate])[
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
{
}
-b4_epilogue
+b4_epilogue[]dnl
b4_output_end()
--- /dev/null
+## Copyright (C) 2002, 2005-2012 Free Software Foundation, Inc.
+
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+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
# C++ skeleton for Bison
-# Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+m4_pushdef([b4_copyright_years],
+ [2002-2012])
-b4_output_begin([b4_dir_prefix[]position.hh])
-b4_copyright([Positions for Bison parsers in C++],
- [2002-2007, 2009-2012])[
-
-/**
- ** \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.
+# b4_position_define
+# ------------------
+# Define class position.
+m4_define([b4_position_define],
+[[ /// Abstract a position.
class position
{
public:
ostr << *pos.filename << ':';
return ostr << pos.line << '.' << pos.column;
}
+]])
-]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++],
- [2002-2007, 2009-2012])[
-/**
- ** \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.
+# b4_location_define
+# ------------------
+m4_define([b4_location_define],
+[[ /// Abstract a location.
class location
{
public:
position last = loc.end - 1;
ostr << loc.begin;
if (last.filename
- && (!loc.begin.filename
- || *loc.begin.filename != *last.filename))
+ && (!loc.begin.filename
+ || *loc.begin.filename != *last.filename))
ostr << '-' << last;
else if (loc.begin.line != last.line)
ostr << '-' << last.line << '.' << last.column;
ostr << '-' << last.column;
return ostr;
}
+]])
+
+# We do want M4 expansion after # for CPP macros.
+m4_changecom()
+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_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_output_end()
+])
+
+
+m4_popdef([b4_copyright_years])
m4_pushdef([b4_copyright_years],
[2002-2012])
-b4_output_begin([b4_dir_prefix[]stack.hh])
-b4_copyright([Stack handling for Bison parsers in C++],
- [2002-2012])[
-
-/**
- ** \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> >
+# b4_stack_define
+# ---------------
+m4_define([b4_stack_define],
+[[ template <class T, class S = std::deque<T> >
class stack
{
public:
typedef typename S::reverse_iterator iterator;
typedef typename S::const_reverse_iterator const_iterator;
- stack () : seq_ ()
+ stack ()
+ : seq_ ()
{
}
- stack (unsigned int n) : seq_ (n)
+ stack (unsigned int n)
+ : seq_ (n)
{
}
}
inline
- unsigned int
- height () const
+ typename S::size_type
+ size () const
{
return seq_.size ();
}
- inline const_iterator begin () const { return seq_.rbegin (); }
- inline const_iterator end () const { return seq_.rend (); }
+ inline
+ const_iterator
+ begin () const
+ {
+ return seq_.rbegin ();
+ }
+
+ inline
+ const_iterator
+ end () const
+ {
+ return seq_.rend ();
+ }
private:
+ /// The wrapped container.
S seq_;
};
const S& stack_;
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 <deque>
+
+]b4_namespace_open[
+]b4_stack_define[
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
b4_output_end()
+])
m4_popdef([b4_copyright_years])
--- /dev/null
+# C++ skeleton for Bison
+
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+## --------- ##
+## 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-NUM)
+# ---------------------------
+# A comment describing this symbol.
+m4_define([b4_char_sizeof_],
+[ // b4_symbol([$1], [tag])
+])
+
+# 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_char_sizeof_], [$@])dnl
+ char _b4_char_sizeof_dummy@{sizeof([b4_symbol([$1], [type])])@};
+])])
+
+
+# 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
+ {]b4_parse_assert_if([
+ /// Whether something is contained.
+ bool built;
+])[
+ /// Empty construction.
+ inline
+ variant ()]b4_parse_assert_if([
+ : built (false)])[
+ {}
+
+ /// Instantiate a \a T in here.
+ template <typename T>
+ inline T&
+ build ()
+ {]b4_parse_assert_if([
+ assert (!built);
+ built = true;])[
+ return *new (buffer.raw) T;
+ }
+
+ /// Instantiate a \a T in here from \a t.
+ template <typename T>
+ inline T&
+ build (const T& t)
+ {]b4_parse_assert_if([
+ assert(!built);
+ built = true;])[
+ return *new (buffer.raw) T(t);
+ }
+
+ /// Construct and fill.
+ template <typename T>
+ inline
+ variant (const T& t)]b4_parse_assert_if([
+ : built (true)])[
+ {
+ new (buffer.raw) T(t);
+ }
+
+ /// Accessor to a built \a T.
+ template <typename T>
+ inline T&
+ as ()
+ {]b4_parse_assert_if([
+ assert (built);])[
+ return reinterpret_cast<T&>(buffer.raw);
+ }
+
+ /// Const accessor to a built \a T (for %printer).
+ template <typename T>
+ inline const T&
+ as () const
+ {]b4_parse_assert_if([
+ assert(built);])[
+ return reinterpret_cast<const T&>(buffer.raw);
+ }
+
+ /// Swap the content with \a other.
+ template <typename T>
+ inline void
+ swap (variant<S>& other)
+ {
+ std::swap (as<T>(), other.as<T>());
+ }
+
+ /// Assign the content of \a other to this.
+ /// Destroys \a other.
+ template <typename T>
+ inline void
+ build (variant<S>& other)
+ {
+ build<T>();
+ swap<T>(other);
+ other.destroy<T>();
+ }
+
+ /// Destroy the stored \a T.
+ template <typename T>
+ inline void
+ destroy ()
+ {
+ as<T>().~T();]b4_parse_assert_if([
+ built = false;])[
+ }
+
+ /// 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;
+ };
+]])
+
+
+## -------------------------- ##
+## 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;])
+
+
+# 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_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_])])
<xsl:import href="bison.xsl"/>
<xsl:output method="xml" encoding="UTF-8"
- doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
- doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
- indent="yes"/>
+ doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+ indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>
- <xsl:value-of select="bison-xml-report/filename"/>
- <xsl:text> - GNU Bison XML Automaton Report</xsl:text>
+ <xsl:value-of select="bison-xml-report/filename"/>
+ <xsl:text> - GNU Bison XML Automaton Report</xsl:text>
</title>
<style type="text/css"><![CDATA[
body {
font-family: "Nimbus Sans L", Arial, sans-serif;
- font-size: 9pt;
+ font-size: 9pt;
}
a:link {
- color: #1f00ff;
- text-decoration: none;
+ color: #1f00ff;
+ text-decoration: none;
}
a:visited {
- color: #1f00ff;
- text-decoration: none;
+ color: #1f00ff;
+ text-decoration: none;
}
a:hover {
- color: red;
+ color: red;
}
#menu a {
text-decoration: underline;
<li>
<a href="#reductions">Reductions</a>
<ul class="lower-alpha">
- <li><a href="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>
- <li><a href="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>
- <li><a href="#rules_useless_in_grammar">Rules useless in grammar</a></li>
- <xsl:if test="grammar/rules/rule[@usefulness='useless-in-parser']">
- <li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>
- </xsl:if>
+ <li><a href="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>
+ <li><a href="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>
+ <li><a href="#rules_useless_in_grammar">Rules useless in grammar</a></li>
+ <xsl:if test="grammar/rules/rule[@usefulness='useless-in-parser']">
+ <li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>
+ </xsl:if>
</ul>
</li>
<li><a href="#conflicts">Conflicts</a></li>
<li>
<a href="#grammar">Grammar</a>
<ul class="lower-alpha">
- <li><a href="#grammar">Itemset</a></li>
- <li><a href="#terminals">Terminal symbols</a></li>
- <li><a href="#nonterminals">Nonterminal symbols</a></li>
+ <li><a href="#grammar">Itemset</a></li>
+ <li><a href="#terminals">Terminal symbols</a></li>
+ <li><a href="#nonterminals">Nonterminal symbols</a></li>
</ul>
</li>
<li><a href="#automaton">Automaton</a></li>
<xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
<p class="pre">
<xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
- <xsl:text> </xsl:text>
- <xsl:value-of select="@name"/>
- <xsl:text> </xsl:text>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="@name"/>
+ <xsl:text> </xsl:text>
</xsl:for-each>
<xsl:text> </xsl:text>
</p>
<p class="pre">
<xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
<xsl:sort select="@symbol-number" data-type="number"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="@name"/>
- <xsl:text> </xsl:text>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="@name"/>
+ <xsl:text> </xsl:text>
</xsl:for-each>
<xsl:text> </xsl:text>
</p>
<h3>
<a>
<xsl:attribute name="name">
- <xsl:value-of select="concat('state_', @number)"/>
+ <xsl:value-of select="concat('state_', @number)"/>
</xsl:attribute>
</a>
<xsl:text>state </xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates select="transition[@type = $type]">
<xsl:with-param name="pad">
- <xsl:call-template name="max-width-symbol">
- <xsl:with-param name="node" select="transition[@type = $type]"/>
- </xsl:call-template>
+ <xsl:call-template name="max-width-symbol">
+ <xsl:with-param name="node" select="transition[@type = $type]"/>
+ </xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:apply-templates select="error">
<xsl:with-param name="pad">
- <xsl:call-template name="max-width-symbol">
- <xsl:with-param name="node" select="error"/>
- </xsl:call-template>
+ <xsl:call-template name="max-width-symbol">
+ <xsl:with-param name="node" select="error"/>
+ </xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:apply-templates select="reduction">
<xsl:with-param name="pad">
- <xsl:call-template name="max-width-symbol">
- <xsl:with-param name="node" select="reduction"/>
- </xsl:call-template>
+ <xsl:call-template name="max-width-symbol">
+ <xsl:with-param name="node" select="reduction"/>
+ </xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
<xsl:template match="item">
<xsl:param name="pad"/>
<xsl:param name="prev-rule-number"
- select="preceding-sibling::item[1]/@rule-number"/>
+ select="preceding-sibling::item[1]/@rule-number"/>
<xsl:apply-templates
select="key('bison:ruleByNumber', current()/@rule-number)"
>
<xsl:if test="$itemset != 'true'">
<a>
<xsl:attribute name="name">
- <xsl:value-of select="concat('rule_', @number)"/>
+ <xsl:value-of select="concat('rule_', @number)"/>
</xsl:attribute>
</a>
</xsl:if>
<xsl:choose>
<xsl:when test="$itemset = 'true'">
<a>
- <xsl:attribute name="href">
- <xsl:value-of select="concat('#rule_', @number)"/>
- </xsl:attribute>
- <xsl:call-template name="lpad">
- <xsl:with-param name="str" select="string(@number)"/>
- <xsl:with-param name="pad" select="number($pad)"/>
- </xsl:call-template>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat('#rule_', @number)"/>
+ </xsl:attribute>
+ <xsl:call-template name="lpad">
+ <xsl:with-param name="str" select="string(@number)"/>
+ <xsl:with-param name="pad" select="number($pad)"/>
+ </xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="lpad">
- <xsl:with-param name="str" select="string(@number)"/>
- <xsl:with-param name="pad" select="number($pad)"/>
+ <xsl:with-param name="str" select="string(@number)"/>
+ <xsl:with-param name="pad" select="number($pad)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
<xsl:call-template name="lpad">
- <xsl:with-param name="str" select="'|'"/>
- <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
+ <xsl:with-param name="str" select="'|'"/>
+ <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
<xsl:call-template name="lpad">
- <xsl:with-param name="str" select="'|'"/>
- <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
+ <xsl:with-param name="str" select="'|'"/>
+ <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<span class="i">
- <xsl:value-of select="lhs"/>
+ <xsl:value-of select="lhs"/>
</span>
<xsl:text> →</xsl:text>
</xsl:otherwise>
<xsl:choose>
<xsl:when test="@type = 'shift'">
<a>
- <xsl:attribute name="href">
- <xsl:value-of select="concat('#state_', @state)"/>
- </xsl:attribute>
- <xsl:value-of select="concat('shift, and go to state ', @state)"/>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat('#state_', @state)"/>
+ </xsl:attribute>
+ <xsl:value-of select="concat('shift, and go to state ', @state)"/>
</a>
</xsl:when>
<xsl:when test="@type = 'goto'">
<a>
- <xsl:attribute name="href">
- <xsl:value-of select="concat('#state_', @state)"/>
- </xsl:attribute>
- <xsl:value-of select="concat('go to state ', @state)"/>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat('#state_', @state)"/>
+ </xsl:attribute>
+ <xsl:value-of select="concat('go to state ', @state)"/>
</a>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<a>
- <xsl:attribute name="href">
- <xsl:value-of select="concat('#rule_', @rule)"/>
- </xsl:attribute>
- <xsl:value-of select="concat('reduce using rule ', @rule)"/>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat('#rule_', @rule)"/>
+ </xsl:attribute>
+ <xsl:value-of select="concat('reduce using rule ', @rule)"/>
</a>
<xsl:text> (</xsl:text>
<xsl:value-of
<xsl:variable name="longest">
<xsl:for-each select="$node">
<xsl:sort data-type="number" select="string-length(@symbol)"
- order="descending"/>
+ order="descending"/>
<xsl:if test="position() = 1">
- <xsl:value-of select="string-length(@symbol)"/>
+ <xsl:value-of select="string-length(@symbol)"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="space">
- <xsl:with-param name="repeat" select="$diff"/>
+ <xsl:with-param name="repeat" select="$diff"/>
</xsl:call-template>
<xsl:value-of select="$str"/>
</xsl:otherwise>
<xsl:otherwise>
<xsl:value-of select="$str"/>
<xsl:call-template name="space">
- <xsl:with-param name="repeat" select="$diff"/>
+ <xsl:with-param name="repeat" select="$diff"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
-*- C -*-
-
# Yacc compatible skeleton for Bison
# Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation,
# Inc.
+m4_pushdef([b4_copyright_years],
+ [1984, 1989-1990, 2000-2012])
+
# 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
# Arguments passed to yyerror: user args plus yylloc.
m4_define([b4_yyerror_args],
[b4_yyerror_arg_loc_if([&yylloc, ])dnl
-m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
+m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
# b4_lex_param
m4_eval([0 <= $1]), [1], [unsigned int],
- [int])])
+ [int])])
## ----------------- ##
# --------------------
# Expansion of $<TYPE>$.
m4_define([b4_lhs_value],
-[(yyval[]m4_ifval([$1], [.$1]))])
+[b4_symbol_value(yyval, [$1])])
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
m4_define([b4_rhs_value],
-[(yyvsp@{($2) - ($1)@}m4_ifval([$3], [.$3]))])
+ [b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3])])
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# on RHS.
m4_define([b4_rhs_location],
-[(yylsp@{($2) - ($1)@})])
+ [(yylsp@{b4_subtract([$2], [$1])@})])
## -------------- ##
typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
-]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
-])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
+]b4_pull_if([b4_function_declare([b4_prefix[parse]], [[int]], b4_parse_param)
+])b4_function_declare([b4_prefix[push_parse]], [[int]],
[[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([,
[[[int pushed_char]], [[pushed_char]]],
[[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([,
[[b4_api_PREFIX[LTYPE *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [,
b4_parse_param]))
-b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
+b4_pull_if([b4_function_declare([b4_prefix[pull_parse]], [[int]],
[[b4_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [,
b4_parse_param]))])
-b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
+b4_function_declare([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
[[[void]], []])
-b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
+b4_function_declare([b4_prefix[pstate_delete]], [[void]],
[[b4_prefix[pstate *ps]], [[ps]]])dnl
])
# -------------------
# When not the push parser.
m4_define([b4_declare_yyparse_],
-[[#ifdef YYPARSE_PARAM
-]b4_c_function_decl(b4_prefix[parse], [int],
- [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
-#else /* ! YYPARSE_PARAM */
-]b4_c_function_decl(b4_prefix[parse], [int], b4_parse_param)[
-#endif /* ! YYPARSE_PARAM */]dnl
-])
+[b4_function_declare(b4_prefix[parse], [int], b4_parse_param)])
# b4_declare_yyparse
[b4_cpp_guard_open([b4_spec_defines_file])[
]b4_declare_yydebug[
]b4_percent_code_get([[requires]])[
-]b4_token_enums_defines(b4_tokens)[
+]b4_token_enums_defines[
]b4_declare_yylstype[
]b4_declare_yyparse[
]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
])
-
## -------------- ##
## Output files. ##
## -------------- ##
b4_output_begin([b4_parser_file_name])
-b4_copyright([Bison implementation for Yacc-like parsers in C],
- [1984, 1989-1990, 2000-2012])[
+b4_copyright([Bison implementation for Yacc-like parsers in C])[
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
-# define YYERROR_VERBOSE ]b4_error_verbose_flag[
+# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
#endif
]m4_ifval(m4_quote(b4_spec_defines_file),
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
-#elif ]b4_c_modern[
-typedef signed char yytype_int8;
#else
-typedef short int yytype_int8;
+typedef signed char yytype_int8;
#endif
#ifdef YYTYPE_UINT16
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T && ]b4_c_modern[
+# elif ! defined YYSIZE_T
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
#endif
/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
+#ifdef __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
-/* Identity function, used to suppress warnings about constant conditions. */
-#ifndef lint
-# define YYID(N) (N)
-#else
-]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[
-{
- return yyi;
-}
-#endif
-
#if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[
/* The parser invokes alloca or malloc; define the necessary symbols. */]dnl
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && ]b4_c_modern[
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS
# ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# ifndef YYSTACK_ALLOC_MAXIMUM
/* 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
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
+ && (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
-# if ! defined malloc && ! defined EXIT_SUCCESS && ]b4_c_modern[
+# if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
-# if ! defined free && ! defined EXIT_SUCCESS && ]b4_c_modern[
+# if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
#if (! defined yyoverflow \
&& (! defined __cplusplus \
- || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
- && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
+ || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
+ && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
-# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
- Stack = &yyptr->Stack_alloc; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (YYID (0))
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (0)
#endif
for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \
} \
- while (YYID (0))
+ while (0)
# endif
# endif
#endif /* !YYCOPY_NEEDED */
#define YYNNTS ]b4_nterms_number[
/* YYNRULES -- Number of rules. */
#define YYNRULES ]b4_rules_number[
-/* YYNRULES -- Number of states. */
+/* YYNSTATES -- Number of states. */
#define YYNSTATES ]b4_states_number[
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
+ by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK ]b4_undef_token_number[
#define YYMAXUTOK ]b4_user_token_number_max[
-#define YYTRANSLATE(YYX) \
+#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, without out-of-bounds checking. */
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
{
]b4_translate[
};
#if ]b4_api_PREFIX[DEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- 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[
-};
+]b4_integral_parser_table_define([rline], [b4_rline],
+ [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
#endif
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
#endif
# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
- token YYLEX-NUM. */
+/* 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])[ yytoknum[] =
{
]b4_toknum[
};
# 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[
-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) \
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
+#define YYTABLE_NINF ]b4_table_ninf[
+
#define yytable_value_is_error(Yytable_value) \
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
-static const ]b4_int_type_for([b4_check])[ yycheck[] =
-{
- ]b4_check[
-};
+]b4_parser_tables_define[
-/* 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 yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#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)
else \
{ \
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (YYID (0))
+ YYERROR; \
+ } \
+while (0)
/* Error token number */
-#define YYTERROR 1
-#define YYERRCODE 256
+#define YYTERROR 1
+#define YYERRCODE 256
]b4_locations_if([[
]b4_yylloc_default_define[
#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)[
+# define YYLEX ]b4_function_call([yylex], [int], b4_lex_param)[
#endif
/* Enable debugging if requested. */
# define YYFPRINTF fprintf
# endif
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (YYID (0))
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (YYID (0))
-
-]b4_yy_symbol_print_generate([b4_c_function_def])[
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (0)
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (0)
+
+]b4_yy_symbol_print_define[
/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included). |
`------------------------------------------------------------------*/
-]b4_c_function_def([yy_stack_print], [static void],
- [[yytype_int16 *yybottom], [yybottom]],
- [[yytype_int16 *yytop], [yytop]])[
+]b4_function_define([yy_stack_print], [static void],
+ [[yytype_int16 *yybottom], [yybottom]],
+ [[yytype_int16 *yytop], [yytop]])[
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
YYFPRINTF (stderr, "\n");
}
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (YYID (0))
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (0)
/*------------------------------------------------.
| Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/
-]b4_c_function_def([yy_reduce_print], [static void],
- [[YYSTYPE *yyvsp], [yyvsp]],
+]b4_function_define([yy_reduce_print], [static void],
+ [[yytype_int16 *yyssp], [yyssp]],
+ [[YYSTYPE *yyvsp], [yyvsp]],
b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
- ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
- b4_parse_param]))[
+ ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
+ b4_parse_param]))[
{
+ unsigned long int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
- unsigned long int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
+ yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
- &]b4_rhs_value(yynrhs, yyi + 1)[
- ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
- b4_user_args[);
+ yy_symbol_print (stderr,
+ yystos[yyssp[yyi + 1 - yynrhs]],
+ &]b4_rhs_value(yynrhs, yyi + 1)[
+ ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
+ b4_user_args[);
YYFPRINTF (stderr, "\n");
}
}
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
-} while (YYID (0))
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
+} while (0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
+#ifndef YYINITDEPTH
# define YYINITDEPTH ]b4_stack_depth_init[
#endif
goto yyerrlab; \
} \
} \
-} while (YYID (0))
+} while (0)
/* Discard any previous initial lookahead context because of Event,
which may be a lookahead change or an invalidation of the currently
Event "\n"); \
yy_lac_established = 0; \
} \
-} while (YYID (0))
+} while (0)
#else
# define YY_LAC_DISCARD(Event) yy_lac_established = 0
#endif
# define yystrlen strlen
# else
/* Return the length of YYSTR. */
-]b4_c_function_def([yystrlen], [static YYSIZE_T],
+]b4_function_define([yystrlen], [static YYSIZE_T],
[[const char *yystr], [yystr]])[
{
YYSIZE_T yylen;
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
-]b4_c_function_def([yystpcpy], [static char *],
+]b4_function_define([yystpcpy], [static char *],
[[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[
{
char *yyd = yydest;
char const *yyp = yystr;
for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
do_not_strip_quotes: ;
}
int yycount = 0;
/* 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
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
}
#endif /* YYERROR_VERBOSE */
-]b4_yydestruct_generate([b4_c_function_def])[
+]b4_yydestruct_define[
]b4_pure_if([], [
static char yypstate_allocated = 0;]])b4_pull_if([
-b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
+b4_function_define([[yyparse]], [[int]], b4_parse_param)[
{
return yypull_parse (YY_NULL]m4_ifset([b4_parse_param],
- [[, ]b4_c_args(b4_parse_param)])[);
+ [[, ]b4_args(b4_parse_param)])[);
}
-]b4_c_function_def([[yypull_parse]], [[int]],
+]b4_function_define([[yypull_parse]], [[int]],
[[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
b4_parse_param]))[
{
do {
yychar = YYLEX;
yystatus =
- yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])[);
+ yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[);
} while (yystatus == YYPUSH_MORE);
if (!yyps)
yypstate_delete (yyps_local);
}]])[
/* Initialize the parser data structure. */
-]b4_c_function_def([[yypstate_new]], [[yypstate *]])[
+]b4_function_define([[yypstate_new]], [[yypstate *]])[
{
yypstate *yyps;]b4_pure_if([], [[
if (yypstate_allocated)
return yyps;
}
-]b4_c_function_def([[yypstate_delete]], [[void]],
+]b4_function_define([[yypstate_delete]], [[void]],
[[[yypstate *yyps]], [[yyps]]])[
{
#ifndef yyoverflow
| yypush_parse. |
`---------------*/
-]b4_c_function_def([[yypush_parse]], [[int]],
+]b4_function_define([[yypush_parse]], [[int]],
[[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
[[[int yypushed_char]], [[yypushed_char]]],
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
| yyparse. |
`----------*/
-#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_function_define([yyparse], [int], b4_parse_param)])[
{]b4_pure_if([b4_declare_scanner_communication_variables
])b4_push_if([b4_pure_if([], [[
int yypushed_char = yychar;
#ifdef yyoverflow
{
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;]b4_locations_if([
- YYLTYPE *yyls1 = yyls;])[
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
- &yyls1, yysize * sizeof (*yylsp),])[
- &yystacksize);
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;]b4_locations_if([
+ YYLTYPE *yyls1 = yyls;])[
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
+ &yyls1, yysize * sizeof (*yylsp),])[
+ &yystacksize);
]b4_locations_if([
- yyls = yyls1;])[
- yyss = yyss1;
- yyvs = yyvs1;
+ yyls = yyls1;])[
+ yyss = yyss1;
+ yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
+ goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
+ yystacksize = YYMAXDEPTH;
{
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss_alloc, yyss);
- YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
- YYSTACK_RELOCATE (yyls_alloc, yyls);])[
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
+ YYSTACK_RELOCATE (yyls_alloc, yyls);])[
# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yylsp = yyls + yysize - 1;])[
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
+ (unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
+ YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
goto yynewstate;
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
+/*--------------------------------------.
+| yyerrlab -- here on detecting error. |
+`--------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
- error, discard it. */
+ error, discard it. */
if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
- yychar = YYEMPTY;
- }
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
+ yychar = YYEMPTY;
+ }
}
/* Else will try to reuse lookahead token after shifting the error
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
- YYABORT;
+ YYABORT;
]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[
yydestruct ("Error: popping",
- yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
+ yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
+ yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
- /* Make sure YYID is used. */
- return YYID (yyresult);
+ return yyresult;
}
-
-
]b4_epilogue[]dnl
b4_output_end()
b4_defines_if(
[b4_output_begin([b4_spec_defines_file])[
-]b4_copyright([Bison interface for Yacc-like parsers in C],
- [1984, 1989-1990, 2000-2012])[
+]b4_copyright([Bison interface for Yacc-like parsers in C])[
]b4_shared_declarations[
]b4_output_end()
-])
+])# b4_defines_if
--- /dev/null
+## Copyright (C) 2008-2012 Free Software Foundation, Inc.
+
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+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
/*~
/.dirstamp
-/Makefile
-/Makefile.in
/bison.1
/bison.aux
/bison.cp
/bison.cps
/bison.dvi
/bison.fn
+/bison.help
/bison.html
/bison.info
/bison.ky
-# Doxyfile 1.3.4 -*- Makefile -*-
+# Doxyfile 1.8.0
# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
+# doxygen (www.doxygen.org) for a project.
#
-# All text after a hash (#) is considered a comment and will be ignored
+# All text after a hash (#) is considered a comment and will be ignored.
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
+# Values that contain spaces should be placed between quotes (" ").
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or sequence of words) that should
+# identify the project. Note that if you do not use Doxywizard you need
+# to put quotes around the project name if it contains spaces.
PROJECT_NAME = "@PACKAGE_NAME@"
PROJECT_NUMBER = "@PACKAGE_VERSION@"
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF =
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is
+# included in the documentation. The maximum height of the logo should not
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO =
+
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
-OUTPUT_DIRECTORY = .
+OUTPUT_DIRECTORY = @top_builddir@/doc
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
-# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch,
-# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en
-# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese,
-# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
OUTPUT_LANGUAGE = English
-# This tag can be used to specify the encoding used in the generated output.
-# The encoding is not always determined by the language that is chosen,
-# but also whether or not the output is meant for Windows or non-Windows users.
-# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
-# forces the Windows encoding (this is the default for the Windows binary),
-# whereas setting the tag to NO uses a Unix-style encoding (the default for
-# all platforms other than Windows).
-
-USE_WINDOWS_ENCODING = NO
-
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
REPEAT_BRIEF = YES
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# Doxygen will generate a detailed section even if there is only a brief
# description.
ALWAYS_DETAILED_SEC = YES
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
-# members of a class in the documentation of that class as if those members were
-# ordinary class members. Constructors, destructors and assignment operators of
-# the base classes will not be shown.
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
INLINE_INHERITED_MEMB = YES
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user-defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
-# the path. It is allowed to use relative paths in the argument list.
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
STRIP_FROM_PATH =
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
+# (but less readable) file names. This can be useful if your file system
# doesn't support long names like on DOS, Mac, or CD-ROM.
SHORT_NAMES = NO
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like the Qt-style comments (thus requiring an
-# explict @brief command for a brief description.
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
JAVADOC_AUTOBRIEF = NO
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
# treat a multi-line C++ special comment block (i.e. a block of //! or ///
# comments) as a brief description. This used to be the default behaviour.
MULTILINE_CPP_IS_BRIEF = NO
-# If the DETAILS_AT_TOP tag is set to YES then Doxygen
-# will output the detailed description near the top, like JavaDoc.
-# If set to NO, the detailed description appears after the member
-# documentation.
-
-DETAILS_AT_TOP = NO
-
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
-# reimplements.
+# re-implements.
INHERIT_DOCS = YES
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
-DISTRIBUTE_GROUP_DOC = NO
+SEPARATE_MEMBER_PAGES = NO
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
ALIASES =
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
-# only. Doxygen will then generate output that is more tailored for C.
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding
+# "class=itcl::class" will allow you to use the command class in the
+# itcl::class meaning.
+
+TCL_SUBST =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
# For instance, some of the names that are used will be different. The list
# of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = NO
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
-# only. Doxygen will then generate output that is more tailored for Java.
-# For instance, namespaces will be presented as packages, qualified scopes
-# will look different, etc.
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
OPTIMIZE_OUTPUT_JAVA = NO
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this
+# tag. The format is ext=language, where ext is a file extension, and language
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all
+# comments according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you
+# can mix doxygen, HTML, and XML commands with Markdown formatting.
+# Disable only in case of backward compatibilities issues.
+
+MARKDOWN_SUPPORT = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also makes the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
# the same type (for instance a group of public functions) to be put as a
# subgroup of that type (e.g. under the Public Functions section). Set it to
SUBGROUPING = YES
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
+# unions are shown inside the group in which they are included (e.g. using
+# @ingroup) instead of on a separate page (for HTML and Man pages) or
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
+# unions with only public data fields will be shown inline in the documentation
+# of the scope in which they are defined (i.e. file, namespace, or group
+# documentation), provided this scope is documented. If set to NO (the default),
+# structs, classes, and unions are shown on a separate page (for HTML and Man
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penalty.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will roughly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+SYMBOL_CACHE_SIZE = 0
+
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
+# their name and scope. Since this can be an expensive process and often the
+# same symbol appear multiple times in the code, doxygen keeps a cache of
+# pre-resolved symbols. If the cache is too small doxygen will become slower.
+# If the cache is too large, memory is wasted. The cache size is given by this
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+LOOKUP_CACHE_SIZE = 0
+
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_PRIVATE = YES
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation.
+
+EXTRACT_PACKAGE = NO
+
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_LOCAL_CLASSES = YES
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# file names in lower-case letters. If set to YES upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
-# users are advised to set this option to NO.
+# and Mac users are advised to set this option to NO.
CASE_SENSE_NAMES = YES
SHOW_INCLUDE_FILES = YES
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES = NO
+
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
SORT_MEMBER_DOCS = YES
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
+# do proper type resolution of all parameters of a function it will reject a
+# match between the prototype and the implementation of a member function even
+# if there is only one candidate or it is obvious which candidate to choose
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING = NO
+
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
ENABLED_SECTIONS =
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
+# the initial value of a variable or macro consists of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
+# The appearance of the initializer of individual variables and macros in the
# documentation can be controlled using \showinitializer or \hideinitializer
# command in the documentation regardless of this setting.
SHOW_USED_FILES = YES
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. The create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files
+# containing the references data. This must be a list of .bib files. The
+# .bib extension is automatically appended if omitted. Using this command
+# requires the bibtex tool to be installed. See also
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
+# feature you need bibtex and perl available in the search path.
+
+CITE_BIB_FILES =
+
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
WARN_IF_DOC_ERROR = YES
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text.
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
WARN_FORMAT = "$file:$line: $text"
# with spaces.
INPUT = @top_srcdir@/src \
- @top_builddir@/src
+ @top_builddir@/src
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
-# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
+# *.f90 *.f *.for *.vhd *.vhdl
FILE_PATTERNS = *.c \
*.h \
- *.l \
- *.y
+ *.l \
+ *.y
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
RECURSIVE = YES
-# The EXCLUDE tag can be used to specify files and/or directories that should
+# The EXCLUDE tag can be used to specify files and/or directories that should be
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
EXCLUDE = @top_srcdir@/src/scan-gram.c \
- @top_srcdir@/src/scan-skel.c \
- @top_builddir@/src/parse-*.[ch]
+ @top_srcdir@/src/scan-skel.c \
+ @top_builddir@/src/parse-*.[ch]
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
-# directories that are symbolic links (a Unix file system feature) are
-# excluded from the input.
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
EXCLUDE_SYMLINKS = YES
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories.
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
EXCLUDE_PATTERNS =
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
# input file. Doxygen will then use the output that the filter program writes
# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
INPUT_FILTER =
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty or if
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS =
+
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse (i.e. when SOURCE_BROWSER is set to YES).
FILTER_SOURCE_FILES = NO
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
+# and it is also possible to disable source filtering for a specific pattern
+# using *.ext= (so without naming a filter). This option only has effect when
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS =
+
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
SOURCE_BROWSER = NO
STRIP_CODE_COMMENTS = YES
-# If the REFERENCED_BY_RELATION tag is set to YES (the default)
+# If the REFERENCED_BY_RELATION tag is set to YES
# then for each documented function all documented
# functions referencing it will be listed.
REFERENCED_BY_RELATION = YES
-# If the REFERENCES_RELATION tag is set to YES (the default)
+# If the REFERENCES_RELATION tag is set to YES
# then for each documented function all documented entities
# called/used by that function will be listed.
REFERENCES_RELATION = YES
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
+# standard header. Note that when using a custom header you are responsible
+# for the proper inclusion of any scripts and style sheets that doxygen
+# needs, which is dependent on the configuration options used.
+# It is advised to generate a default header using "doxygen -w html
+# header.html footer.html stylesheet.css YourConfigFile" and then modify
+# that header. Note that the header is subject to change so you typically
+# have to redo this when upgrading to a newer version of doxygen or when
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
HTML_HEADER =
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
-# will generate a default style sheet
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# style sheet in the HTML output directory as well, or it will be erased!
HTML_STYLESHEET =
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the style sheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP = YES
+
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
HTML_ALIGN_MEMBERS = YES
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME = Publisher
+
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
# of the generated HTML documentation.
GENERATE_HTMLHELP = NO
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
# be used to specify the file name of the resulting .chm file. You
# can add a path in front of the file if the result should not be
-# written to the html output dir.
+# written to the html output directory.
CHM_FILE =
GENERATE_CHI = NO
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
# controls whether a binary table of contents is generated (YES) or a
# normal table of contents (NO) in the .chm file.
TOC_EXPAND = NO
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
-DISABLE_INDEX = NO
+GENERATE_QHP = NO
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
-ENUM_VALUES_PER_LINE = 4
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">
+# Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">
+# Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS =
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+# will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
+# at top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it. Since the tabs have the same information as the
+# navigation tree you can set this option to NO if you already set
+# GENERATE_TREEVIEW to YES.
+
+DISABLE_INDEX = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
-# probably better off using the HTML help feature.
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+# Since the tree basically has the same information as the tab index you
+# could consider to set DISABLE_INDEX to NO when enabling this option.
GENERATE_TREEVIEW = YES
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML
+# documentation. Note that a value of 0 will completely suppress the enum
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE = 4
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES = NO
+
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree
# is shown.
TREEVIEW_WIDTH = 250
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW = NO
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
+# (see http://www.mathjax.org) which uses client side Javascript for the
+# rendering instead of using prerendered bitmaps. Use this if you do not
+# have LaTeX installed or if you want to formulas look prettier in the HTML
+# output. When enabled you may also need to install MathJax separately and
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX = NO
+
+# When MathJax is enabled you need to specify the location relative to the
+# HTML output directory using the MATHJAX_RELPATH option. The destination
+# directory should contain the MathJax.js script. For instance, if the mathjax
+# directory is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to
+# the MathJax Content Delivery Network so you can quickly see the result without
+# installing MathJax.
+# However, it is strongly recommended to install a local
+# copy of MathJax from http://www.mathjax.org before deployment.
+
+MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE = NO
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a PHP enabled web server instead of at the web client
+# using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server
+# based approach is that it scales better to large projects and allows
+# full text search. The disadvantages are that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH = NO
+
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
LATEX_CMD_NAME = latex
COMPACT_LATEX = NO
# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
+# by the printer. Possible values are: a4, letter, legal and
# executive. If left blank a4wide will be used.
PAPER_TYPE = a4wide
LATEX_HEADER =
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
+# the generated latex document. The footer should contain everything after
+# the last chapter. If it is left blank doxygen will generate a
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER =
+
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
LATEX_HIDE_INDICES = NO
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE = plain
+
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimised for Word 97 and may not look very pretty with
+# The RTF output is optimized for Word 97 and may not look very pretty with
# other RTF readers or editors.
GENERATE_RTF = NO
RTF_HYPERLINKS = NO
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assigments. You only have to provide
+# Load style sheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
# replacements, missing definitions are set to their default value.
RTF_STYLESHEET_FILE =
# If the GENERATE_XML tag is set to YES Doxygen will
# generate an XML file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
+# the code including all documentation.
GENERATE_XML = NO
XML_DTD =
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
PERLMOD_LATEX = NO
# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader. This is useful
-# if you want to understand what is going on. On the other hand, if this
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
# tag is set to NO the size of the Perl module output will be much smaller
# and Perl will parse it just the same.
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+# PREDEFINED and EXPAND_AS_DEFINED tags.
EXPAND_ONLY_PREDEF = NO
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
SEARCH_INCLUDES = YES
# contain include files that are not input files but should be processed by
# the preprocessor.
-INCLUDE_PATH =
+INCLUDE_PATH = @top_srcdir@
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# are defined before the preprocessor is started (similar to the -D option of
# gcc). The argument of the tag is a list of macros of the form: name
# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed.
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
PREDEFINED =
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
+# Use the PREDEFINED tag if you want to use a different macro definition that
+# overrules the definition found in the source code.
EXPAND_AS_DEFINED =
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse the
-# parser if not removed.
+# doxygen's preprocessor will remove all references to function-like macros
+# that are alone on a line, have an all uppercase name, and do not end with a
+# semicolon, because these will confuse the parser if not removed.
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
-# Configuration::addtions related to external references
+# Configuration::additions related to external references
#---------------------------------------------------------------------------
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
-# TAGFILES = file1 file2 ...
+# The TAGFILES option can be used to specify one or more tagfiles. For each
+# tag file the location of the external documentation should be added. The
+# format of a tag file without this location is as follows:
+#
+# TAGFILES = file1 file2 ...
# Adding location for the tag files is done as follows:
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths
+# or URLs. Note that each tag file must have a unique name (where the name does
+# NOT include the path). If a tag file is not located in the directory in which
+# doxygen is run, you must also specify the path to the tagfile here.
TAGFILES =
#---------------------------------------------------------------------------
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or
-# super classes. Setting the tag to NO turns the diagrams off. Note that this
-# option is superceded by the HAVE_DOT option below. This is only a fallback. It is
-# recommended to install and use dot, since it yields more powerful graphs.
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option also works with HAVE_DOT disabled, but it is recommended to
+# install and use dot, since it yields more powerful graphs.
CLASS_DIAGRAMS = YES
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
# If set to YES, the inheritance and collaboration graphs will hide
# inheritance and usage relations if the target is undocumented
# or is not a class.
HAVE_DOT = YES
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
+# allowed to run in parallel. When set to 0 (the default) doxygen will
+# base this on the number of processors available in the system. You can set it
+# explicitly to a value larger than 0 to get control over the balance
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS = 0
+
+# By default doxygen will use the Helvetica font for all dot files that
+# doxygen generates. When you want a differently looking font you can specify
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find
+# the font, which can be done by putting it in a standard location or by setting
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
+# directory containing the font.
+
+DOT_FONTNAME = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the Helvetica font.
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
+# set the path where dot can find it.
+
+DOT_FONTPATH =
+
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
+# CLASS_DIAGRAMS tag to NO.
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
UML_LOOK = NO
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside
+# the class node. If there are many fields or methods and many nodes the
+# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
+# threshold limits the number of items for each type to make the size more
+# managable. Set this to 0 for no limit. Note that the threshold may be
+# exceeded by 50% before the limit is enforced.
+
+UML_LIMIT_NUM_FIELDS = 10
+
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
INCLUDED_BY_GRAPH = YES
-# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
-# generate a call dependency graph for every global function or class method.
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable call graphs for selected
-# functions only using the \callgraph command.
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
CALL_GRAPH = NO
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
+# will generate a graphical hierarchy of all classes instead of a textual one.
GRAPHICAL_HIERARCHY = YES
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
+# generated by dot. Possible values are svg, png, jpg, or gif.
+# If left blank png will be used. If you choose svg you need to set
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible in IE 9+ (other browsers do not have this requirement).
DOT_IMAGE_FORMAT = png
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+# Note that this requires a modern browser other than Internet Explorer.
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible. Older versions of IE do not have SVG support.
+
+INTERACTIVE_SVG = NO
+
# The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found on the path.
+# found. If left blank, it is assumed the dot tool can be found in the path.
DOT_PATH =
DOTFILE_DIRS =
-# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than
-# this value, doxygen will try to truncate the graph, so that it fits within
-# the specified constraint. Beware that most browsers cannot cope with very
-# large images.
-
-MAX_DOT_GRAPH_WIDTH = 1024
-
-# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than
-# this value, doxygen will try to truncate the graph, so that it fits within
-# the specified constraint. Beware that most browsers cannot cope with very
-# large images.
-
-MAX_DOT_GRAPH_HEIGHT = 1024
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of
-# the graphs generated by dot. A depth value of 3 means that only
-# nodes reachable from the root by following a path via at most 3
-# edges will be shown. Nodes that lay further from the root node will
-# be omitted. Note that setting this option to 1 or 2 may greatly
-# reduce the computation time needed for large code bases. Also note
-# that a graph may be further truncated if the graph's image
-# dimensions are not sufficient to fit the graph (see
-# MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the
-# depth value (the default), the graph is not depth-constrained.
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the
+# \mscfile command).
+
+MSCFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
MAX_DOT_GRAPH_DEPTH = 0
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
# the various graphs.
DOT_CLEANUP = YES
-
-#---------------------------------------------------------------------------
-# Configuration::addtions related to the search engine
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE = NO
+++ /dev/null
-## Process this file with automake to produce Makefile.in -*-Makefile-*-
-
-## Copyright (C) 2001-2003, 2005-2012 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-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
* Simple GLR Parsers:: Using GLR parsers on unambiguous grammars.
* Merging GLR Parses:: Using GLR parsers to resolve ambiguities.
-* GLR Semantic Actions:: Deferred semantic actions have special concerns.
+* GLR Semantic Actions:: Considerations for semantic values and deferred actions.
+* Semantic Predicates:: Controlling a parse with arbitrary computations.
* Compiler Requirements:: GLR parsers require a modern C compiler.
Examples
Grammar Rules for @code{rpcalc}
-* Rpcalc Input::
-* Rpcalc Line::
-* Rpcalc Expr::
+* Rpcalc Input:: Explanation of the @code{input} nonterminal
+* Rpcalc Line:: Explanation of the @code{line} nonterminal
+* Rpcalc Expr:: Explanation of the @code{expr} nonterminal
Location Tracking Calculator: @code{ltcalc}
* Mfcalc Declarations:: Bison declarations for multi-function calculator.
* Mfcalc Rules:: Grammar rules for the calculator.
* Mfcalc Symbol Table:: Symbol table management subroutines.
+* Mfcalc Lexer:: The lexical analyzer.
+* Mfcalc Main:: The controlling function.
Bison Grammar Files
Operator Precedence
* Why Precedence:: An example showing why precedence is needed.
-* Using Precedence:: How to specify precedence in Bison grammars.
+* Using Precedence:: How to specify precedence and associativity.
+* Precedence Only:: How to specify precedence only.
* Precedence Examples:: How these features are used in the previous example.
* How Precedence:: How they work.
* Non Operators:: Using precedence for general conflicts.
@menu
* Simple GLR Parsers:: Using GLR parsers on unambiguous grammars.
* Merging GLR Parses:: Using GLR parsers to resolve ambiguities.
-* GLR Semantic Actions:: Deferred semantic actions have special concerns.
+* GLR Semantic Actions:: Considerations for semantic values and deferred actions.
+* Semantic Predicates:: Controlling a parse with arbitrary computations.
* Compiler Requirements:: GLR parsers require a modern C compiler.
@end menu
@end group
%%
-
-@group
type_decl: TYPE ID '=' type ';' ;
-@end group
@group
type:
@node GLR Semantic Actions
@subsection GLR Semantic Actions
+The nature of GLR parsing and the structure of the generated
+parsers give rise to certain restrictions on semantic values and actions.
+
+@subsubsection Deferred semantic actions
@cindex deferred semantic actions
By definition, a deferred semantic action is not performed at the same time as
the associated reduction.
to invoke @code{yyclearin} (@pxref{Action Features}) or to attempt to free
memory referenced by @code{yylval}.
+@subsubsection YYERROR
@findex YYERROR
@cindex GLR parsers and @code{YYERROR}
Another Bison feature requiring special consideration is @code{YYERROR}
initiate error recovery.
During deterministic GLR operation, the effect of @code{YYERROR} is
the same as its effect in a deterministic parser.
-In a deferred semantic action, its effect is undefined.
-@c The effect is probably a syntax error at the split point.
+The effect in a deferred action is similar, but the precise point of the
+error is undefined; instead, the parser reverts to deterministic operation,
+selecting an unspecified stack on which to continue with a syntax error.
+In a semantic predicate (see @ref{Semantic Predicates}) during nondeterministic
+parsing, @code{YYERROR} silently prunes
+the parse that invoked the test.
+
+@subsubsection Restrictions on semantic values and locations
+GLR parsers require that you use POD (Plain Old Data) types for
+semantic values and location types when using the generated parsers as
+C++ code.
+
+@node Semantic Predicates
+@subsection Controlling a Parse with Arbitrary Predicates
+@findex %?
+@cindex Semantic predicates in GLR parsers
+
+In addition to the @code{%dprec} and @code{%merge} directives,
+GLR parsers
+allow you to reject parses on the basis of arbitrary computations executed
+in user code, without having Bison treat this rejection as an error
+if there are alternative parses. (This feature is experimental and may
+evolve. We welcome user feedback.) For example,
+
+@example
+widget:
+ %?@{ new_syntax @} "widget" id new_args @{ $$ = f($3, $4); @}
+| %?@{ !new_syntax @} "widget" id old_args @{ $$ = f($3, $4); @}
+;
+@end example
+
+@noindent
+is one way to allow the same parser to handle two different syntaxes for
+widgets. The clause preceded by @code{%?} is treated like an ordinary
+action, except that its text is treated as an expression and is always
+evaluated immediately (even when in nondeterministic mode). If the
+expression yields 0 (false), the clause is treated as a syntax error,
+which, in a nondeterministic parser, causes the stack in which it is reduced
+to die. In a deterministic parser, it acts like YYERROR.
+
+As the example shows, predicates otherwise look like semantic actions, and
+therefore you must be take them into account when determining the numbers
+to use for denoting the semantic values of right-hand side symbols.
+Predicate actions, however, have no defined value, and may not be given
+labels.
+
+There is a subtle difference between semantic predicates and ordinary
+actions in nondeterministic mode, since the latter are deferred.
+For example, we could try to rewrite the previous example as
+
+@example
+widget:
+ @{ if (!new_syntax) YYERROR; @}
+ "widget" id new_args @{ $$ = f($3, $4); @}
+| @{ if (new_syntax) YYERROR; @}
+ "widget" id old_args @{ $$ = f($3, $4); @}
+;
+@end example
+
+@noindent
+(reversing the sense of the predicate tests to cause an error when they are
+false). However, this
+does @emph{not} have the same effect if @code{new_args} and @code{old_args}
+have overlapping syntax.
+Since the mid-rule actions testing @code{new_syntax} are deferred,
+a GLR parser first encounters the unresolved ambiguous reduction
+for cases where @code{new_args} and @code{old_args} recognize the same string
+@emph{before} performing the tests of @code{new_syntax}. It therefore
+reports an error.
-Also, see @ref{Location Default Action, ,Default Action for Locations}, which
-describes a special usage of @code{YYLLOC_DEFAULT} in GLR parsers.
+Finally, be careful in writing predicates: deferred actions have not been
+evaluated, so that using them in a predicate will have undefined effects.
@node Compiler Requirements
@subsection Considerations when Compiling GLR Parsers
Here are the C and Bison declarations for the reverse polish notation
calculator. As in C, comments are placed between @samp{/*@dots{}*/}.
+@comment file: rpcalc.y
@example
/* Reverse polish notation calculator. */
%@{
#define YYSTYPE double
+ #include <stdio.h>
#include <math.h>
int yylex (void);
void yyerror (char const *);
Here are the grammar rules for the reverse polish notation calculator.
+@comment file: rpcalc.y
@example
@group
input:
rule are referred to as @code{$1}, @code{$2}, and so on.
@menu
-* Rpcalc Input::
-* Rpcalc Line::
-* Rpcalc Expr::
+* Rpcalc Input:: Explanation of the @code{input} nonterminal
+* Rpcalc Line:: Explanation of the @code{line} nonterminal
+* Rpcalc Expr:: Explanation of the @code{expr} nonterminal
@end menu
@node Rpcalc Input
Here is the code for the lexical analyzer:
+@comment file: rpcalc.y
@example
@group
/* The lexical analyzer returns a double floating point
kept to the bare minimum. The only requirement is that it call
@code{yyparse} to start the process of parsing.
+@comment file: rpcalc.y
@example
@group
int
@code{yyerror} (@pxref{Interface, ,Parser C-Language Interface}), so
here is the definition we will use:
+@comment file: rpcalc.y
@example
-@group
#include <stdio.h>
-@end group
@group
/* Called by yyparse on error. */
@example
$ @kbd{rpcalc}
@kbd{4 9 +}
-13
+@result{} 13
@kbd{3 7 + 3 4 5 *+-}
--13
+@result{} -13
@kbd{3 7 + 3 4 5 * + - n} @r{Note the unary minus, @samp{n}}
-13
+@result{} 13
@kbd{5 6 / 4 n +}
--3.166666667
+@result{} -3.166666667
@kbd{3 4 ^} @r{Exponentiation}
-81
+@result{} 81
@kbd{^D} @r{End-of-file indicator}
$
@end example
%token NUM
%left '-' '+'
%left '*' '/'
-%left NEG /* negation--unary minus */
-%right '^' /* exponentiation */
+%precedence NEG /* negation--unary minus */
+%right '^' /* exponentiation */
@end group
%% /* The grammar follows. */
types and says they are left-associative operators. The declarations
@code{%left} and @code{%right} (right associativity) take the place of
@code{%token} which is used to declare a token type name without
-associativity. (These tokens are single-character literals, which
+associativity/precedence. (These tokens are single-character literals, which
ordinarily don't need to be declared. We declare them here to specify
-the associativity.)
+the associativity/precedence.)
Operator precedence is determined by the line ordering of the
declarations; the higher the line number of the declaration (lower on
the page or screen), the higher the precedence. Hence, exponentiation
has the highest precedence, unary minus (@code{NEG}) is next, followed
-by @samp{*} and @samp{/}, and so on. @xref{Precedence, ,Operator
+by @samp{*} and @samp{/}, and so on. Unary minus is not associative,
+only precedence matters (@code{%precedence}. @xref{Precedence, ,Operator
Precedence}.
The other important new feature is the @code{%prec} in the grammar
%left '-' '+'
%left '*' '/'
-%left NEG
+%precedence NEG
%right '^'
%% /* The grammar follows. */
Here is a sample session with the multi-function calculator:
@example
+@group
$ @kbd{mfcalc}
@kbd{pi = 3.141592653589}
-3.1415926536
+@result{} 3.1415926536
+@end group
+@group
@kbd{sin(pi)}
-0.0000000000
+@result{} 0.0000000000
+@end group
@kbd{alpha = beta1 = 2.3}
-2.3000000000
+@result{} 2.3000000000
@kbd{alpha}
-2.3000000000
+@result{} 2.3000000000
@kbd{ln(alpha)}
-0.8329091229
+@result{} 0.8329091229
@kbd{exp(ln(beta1))}
-2.3000000000
+@result{} 2.3000000000
$
@end example
* Mfcalc Declarations:: Bison declarations for multi-function calculator.
* Mfcalc Rules:: Grammar rules for the calculator.
* Mfcalc Symbol Table:: Symbol table management subroutines.
+* Mfcalc Lexer:: The lexical analyzer.
+* Mfcalc Main:: The controlling function.
@end menu
@node Mfcalc Declarations
@example
@group
%@{
- #include <math.h> /* For math functions, cos(), sin(), etc. */
- #include "calc.h" /* Contains definition of `symrec'. */
+ #include <stdio.h> /* For printf, etc. */
+ #include <math.h> /* For pow, used in the grammar. */
+ #include "calc.h" /* Contains definition of `symrec'. */
int yylex (void);
void yyerror (char const *);
%@}
%right '='
%left '-' '+'
%left '*' '/'
-%left NEG /* negation--unary minus */
-%right '^' /* exponentiation */
+%precedence NEG /* negation--unary minus */
+%right '^' /* exponentiation */
@end group
@end example
@end group
@end example
-The new version of @code{main} includes a call to @code{init_table}, a
-function that initializes the symbol table. Here it is, and
-@code{init_table} as well:
+The new version of @code{main} will call @code{init_table} to initialize
+the symbol table:
@comment file: mfcalc.y: 3
@example
-#include <stdio.h>
-
-@group
-/* Called by yyparse on error. */
-void
-yyerror (char const *s)
-@{
- fprintf (stderr, "%s\n", s);
-@}
-@end group
-
@group
struct init
@{
@group
struct init const arith_fncts[] =
@{
- "sin", sin,
- "cos", cos,
- "atan", atan,
- "ln", log,
- "exp", exp,
- "sqrt", sqrt,
- 0, 0
+ @{ "atan", atan @},
+ @{ "cos", cos @},
+ @{ "exp", exp @},
+ @{ "ln", log @},
+ @{ "sin", sin @},
+ @{ "sqrt", sqrt @},
+ @{ 0, 0 @},
@};
@end group
@group
/* Put arithmetic functions in table. */
+static
void
init_table (void)
@{
@}
@}
@end group
-
-@group
-int
-main (void)
-@{
- init_table ();
- return yyparse ();
-@}
-@end group
@end example
By simply editing the initialization list and adding the necessary include
symrec *ptr;
for (ptr = sym_table; ptr != (symrec *) 0;
ptr = (symrec *)ptr->next)
- if (strcmp (ptr->name,sym_name) == 0)
+ if (strcmp (ptr->name, sym_name) == 0)
return ptr;
return 0;
@}
@end group
@end example
+@node Mfcalc Lexer
+@subsection The @code{mfcalc} Lexer
+
The function @code{yylex} must now recognize variables, numeric values, and
the single-character arithmetic operators. Strings of alphanumeric
characters with a leading letter are recognized as either variables or
@comment file: mfcalc.y: 3
@example
-@group
#include <ctype.h>
-@end group
@group
int
symrec *s;
int i;
@end group
-
if (!symbuf)
symbuf = (char *) malloc (length + 1);
@end group
@end example
+@node Mfcalc Main
+@subsection The @code{mfcalc} Main
+
The error reporting function is unchanged, and the new version of
@code{main} includes a call to @code{init_table} and sets the @code{yydebug}
on user demand (@xref{Tracing, , Tracing Your Parser}, for details):
A Bison grammar rule has the following general form:
@example
-@group
@var{result}: @var{components}@dots{};
-@end group
@end example
@noindent
For example,
@example
-@group
exp: exp '+' exp;
-@end group
@end example
@noindent
following example, the action is triggered only when @samp{b} is found:
@example
-@group
a-or-b: 'a'|'b' @{ a_or_b_found = 1; @};
-@end group
@end example
@cindex default action
the parser, so that the function @code{yylex} (if it is in this file)
can use the name @var{name} to stand for this token type's code.
-Alternatively, you can use @code{%left}, @code{%right}, or
+Alternatively, you can use @code{%left}, @code{%right},
+@code{%precedence}, or
@code{%nonassoc} instead of @code{%token}, if you wish to specify
associativity and precedence. @xref{Precedence Decl, ,Operator
Precedence}.
@cindex declaring operator precedence
@cindex operator precedence, declaring
-Use the @code{%left}, @code{%right} or @code{%nonassoc} declaration to
+Use the @code{%left}, @code{%right}, @code{%nonassoc}, or
+@code{%precedence} declaration to
declare a token and specify its precedence and associativity, all at
once. These are called @dfn{precedence declarations}.
@xref{Precedence, ,Operator Precedence}, for general information on
means that @samp{@var{x} @var{op} @var{y} @var{op} @var{z}} is
considered a syntax error.
+@code{%precedence} gives only precedence to the @var{symbols}, and
+defines no associativity at all. Use this to define precedence only,
+and leave any potential conflict due to associativity enabled.
+
@item
The precedence of an operator determines how it nests with other operators.
All the tokens declared in a single precedence declaration have equal
including @code{yylval} and @code{yylloc}.)
Alternatively, you can generate a pure, reentrant parser. The Bison
-declaration @code{%define api.pure} says that you want the parser to be
+declaration @samp{%define api.pure} says that you want the parser to be
reentrant. It looks like this:
@example
Bison also supports both the push parser interface along with the pull parser
interface in the same generated parser. In order to get this functionality,
-you should replace the @code{%define api.push-pull push} declaration with the
-@code{%define api.push-pull both} declaration. Doing this will create all of
+you should replace the @samp{%define api.push-pull push} declaration with the
+@samp{%define api.push-pull both} declaration. Doing this will create all of
the symbols mentioned earlier along with the two extra symbols, @code{yyparse}
and @code{yypull_parse}. @code{yyparse} can be used exactly as it normally
would be used. However, the user should note that it is implemented in the
generated parser by calling @code{yypull_parse}.
This makes the @code{yyparse} function that is generated with the
-@code{%define api.push-pull both} declaration slower than the normal
+@samp{%define api.push-pull both} declaration slower than the normal
@code{yyparse} function. If the user
calls the @code{yypull_parse} function it will parse the rest of the input
stream. It is possible to @code{yypush_parse} tokens to select a subgrammar
yypstate_delete (ps);
@end example
-Adding the @code{%define api.pure full} declaration does exactly the same thing
-to the generated parser with @code{%define api.push-pull both} as it did for
-@code{%define api.push-pull push}.
+Adding the @samp{%define api.pure} declaration does exactly the same thing to
+the generated parser with @samp{%define api.push-pull both} as it did for
+@samp{%define api.push-pull push}.
@node Decl Summary
@subsection Bison Declaration Summary
@end deffn
@deffn {Directive} %debug
-In the parser implementation file, define the macro @code{YYDEBUG} (or
-@code{@var{prefix}DEBUG} with @samp{%define api.prefix @var{prefix}}, see
-@ref{Multiple Parsers, ,Multiple Parsers in the Same Program}) to 1 if it is
-not already defined, so that the debugging facilities are compiled.
+Instrument the parser for traces. Obsoleted by @samp{%define
+parse.trace}.
@xref{Tracing, ,Tracing Your Parser}.
@end deffn
accurate syntax error messages.
@end deffn
+@deffn {Directive} %name-prefix "@var{prefix}"
+Rename the external symbols used in the parser so that they start with
+@var{prefix} instead of @samp{yy}. The precise list of symbols renamed
+in C parsers
+is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
+@code{yylval}, @code{yychar}, @code{yydebug}, and
+(if locations are used) @code{yylloc}. If you use a push parser,
+@code{yypush_parse}, @code{yypull_parse}, @code{yypstate},
+@code{yypstate_new} and @code{yypstate_delete} will
+also be renamed. For example, if you use @samp{%name-prefix "c_"}, the
+names become @code{c_parse}, @code{c_lex}, and so on.
+For C++ parsers, see the @samp{%define api.namespace} documentation in this
+section.
+@xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
+@end deffn
+
@ifset defaultprec
@deffn {Directive} %no-default-prec
Do not assign a precedence to rules lacking an explicit @code{%prec}
@end deffn
@deffn {Directive} %pure-parser
-Deprecated version of @code{%define api.pure} (@pxref{%define
+Deprecated version of @samp{%define api.pure} (@pxref{%define
Summary,,api.pure}), for which Bison is more careful to warn about
unreasonable usage.
@end deffn
Unaccepted @var{variable}s produce an error.
Some of the accepted @var{variable}s are:
-@itemize @bullet
+@table @code
+@c ================================================== api.namespace
+@item api.namespace
+@findex %define api.namespace
+@itemize
+@item Languages(s): C++
+
+@item Purpose: Specify the namespace for the parser class.
+For example, if you specify:
+
+@example
+%define api.namespace "foo::bar"
+@end example
+
+Bison uses @code{foo::bar} verbatim in references such as:
+
+@example
+foo::bar::parser::semantic_type
+@end example
+
+However, to open a namespace, Bison removes any leading @code{::} and then
+splits on any remaining occurrences:
+
+@example
+namespace foo @{ namespace bar @{
+ class position;
+ class location;
+@} @}
+@end example
+
+@item Accepted Values:
+Any absolute or relative C++ namespace reference without a trailing
+@code{"::"}. For example, @code{"foo"} or @code{"::foo::bar"}.
+
+@item Default Value:
+The value specified by @code{%name-prefix}, which defaults to @code{yy}.
+This usage of @code{%name-prefix} is for backward compatibility and can
+be confusing since @code{%name-prefix} also specifies the textual prefix
+for the lexical analyzer function. Thus, if you specify
+@code{%name-prefix}, it is best to also specify @samp{%define
+api.namespace} so that @code{%name-prefix} @emph{only} affects the
+lexical analyzer function. For example, if you specify:
+
+@example
+%define api.namespace "foo"
+%name-prefix "bar::"
+@end example
+
+The parser namespace is @code{foo} and @code{yylex} is referenced as
+@code{bar::lex}.
+@end itemize
+@c namespace
+
@c ================================================== api.location.type
@item @code{api.location.type}
@findex %define api.location.type
@end itemize
@c ================================================== api.prefix
-@item @code{api.prefix}
+@item api.prefix
@findex %define api.prefix
@itemize @bullet
@end itemize
@c ================================================== api.pure
-@item @code{api.pure}
+@item api.pure
@findex %define api.pure
@itemize @bullet
@item History: the @code{full} value was introduced in Bison 2.7
@end itemize
+@c api.pure
-@c ================================================== api.push-pull
-@item @code{api.push-pull}
+
+@c ================================================== api.push-pull
+@item api.push-pull
@findex %define api.push-pull
@itemize @bullet
@item Default Value: @code{pull}
@end itemize
+@c api.push-pull
+
-@c ================================================== lr.default-reductions
-@item @code{lr.default-reductions}
-@findex %define lr.default-reductions
+@c ================================================== api.token.constructor
+@item api.token.constructor
+@findex %define api.token.constructor
+
+@itemize @bullet
+@item Language(s):
+C++
+
+@item Purpose:
+When variant-based semantic values are enabled (@pxref{C++ Variants}),
+request that symbols be handled as a whole (type, value, and possibly
+location) in the scanner. @xref{Complete Symbols}, for details.
+
+@item Accepted Values:
+Boolean.
+
+@item Default Value:
+@code{false}
+@item History:
+introduced in Bison 2.8
+@end itemize
+@c api.token.constructor
+
+
+@c ================================================== api.token.prefix
+@item api.token.prefix
+@findex %define api.token.prefix
+
+@itemize
+@item Languages(s): all
+
+@item Purpose:
+Add a prefix to the token names when generating their definition in the
+target language. For instance
+
+@example
+%token FILE for ERROR
+%define api.token.prefix "TOK_"
+%%
+start: FILE for ERROR;
+@end example
+
+@noindent
+generates the definition of the symbols @code{TOK_FILE}, @code{TOK_for},
+and @code{TOK_ERROR} in the generated source files. In particular, the
+scanner must use these prefixed token names, while the grammar itself
+may still use the short names (as in the sample rule given above). The
+generated informational files (@file{*.output}, @file{*.xml},
+@file{*.dot}) are not modified by this prefix. See @ref{Calc++ Parser}
+and @ref{Calc++ Scanner}, for a complete example.
+
+@item Accepted Values:
+Any string. Should be a valid identifier prefix in the target language,
+in other words, it should typically be an identifier itself (sequence of
+letters, underscores, and ---not at the beginning--- digits).
+
+@item Default Value:
+empty
+@item History:
+introduced in Bison 2.8
+@end itemize
+@c api.token.prefix
+
+
+@c ================================================== lr.default-reduction
+
+@item lr.default-reduction
+@findex %define lr.default-reduction
@itemize @bullet
@item Language(s): all
@item @code{accepting} if @code{lr.type} is @code{canonical-lr}.
@item @code{most} otherwise.
@end itemize
+@item History:
+introduced as @code{lr.default-reduction} in 2.5, renamed as
+@code{lr.default-reduction} in 2.8.
@end itemize
-@c ============================================ lr.keep-unreachable-states
+@c ============================================ lr.keep-unreachable-state
-@item @code{lr.keep-unreachable-states}
-@findex %define lr.keep-unreachable-states
+@item lr.keep-unreachable-state
+@findex %define lr.keep-unreachable-state
@itemize @bullet
@item Language(s): all
@item Accepted Values: Boolean
@item Default Value: @code{false}
@end itemize
+introduced as @code{lr.keep_unreachable_states} in 2.3b, renamed as
+@code{lr.keep-unreachable-states} in 2.5, and as
+@code{lr.keep-unreachable-state} in 2.8.
+@c lr.keep-unreachable-state
@c ================================================== lr.type
-@item @code{lr.type}
+@item lr.type
@findex %define lr.type
@itemize @bullet
@item Default Value: @code{lalr}
@end itemize
-@c ================================================== namespace
-@item @code{namespace}
+@c ================================================== namespace
+@item namespace
@findex %define namespace
+Obsoleted by @code{api.namespace}
+@c namespace
-@itemize
-@item Languages(s): C++
-@item Purpose: Specify the namespace for the parser class.
-For example, if you specify:
+@c ================================================== parse.assert
+@item parse.assert
+@findex %define parse.assert
-@smallexample
-%define namespace "foo::bar"
-@end smallexample
+@itemize
+@item Languages(s): C++
-Bison uses @code{foo::bar} verbatim in references such as:
+@item Purpose: Issue runtime assertions to catch invalid uses.
+In C++, when variants are used (@pxref{C++ Variants}), symbols must be
+constructed and
+destroyed properly. This option checks these constraints.
-@smallexample
-foo::bar::parser::semantic_type
-@end smallexample
+@item Accepted Values: Boolean
-However, to open a namespace, Bison removes any leading @code{::} and then
-splits on any remaining occurrences:
+@item Default Value: @code{false}
+@end itemize
+@c parse.assert
-@smallexample
-namespace foo @{ namespace bar @{
- class position;
- class location;
-@} @}
-@end smallexample
-
-@item Accepted Values: Any absolute or relative C++ namespace reference without
-a trailing @code{"::"}.
-For example, @code{"foo"} or @code{"::foo::bar"}.
-
-@item Default Value: The value specified by @code{%name-prefix}, which defaults
-to @code{yy}.
-This usage of @code{%name-prefix} is for backward compatibility and can be
-confusing since @code{%name-prefix} also specifies the textual prefix for the
-lexical analyzer function.
-Thus, if you specify @code{%name-prefix}, it is best to also specify
-@code{%define namespace} so that @code{%name-prefix} @emph{only} affects the
-lexical analyzer function.
-For example, if you specify:
-@smallexample
-%define namespace "foo"
-%name-prefix "bar::"
-@end smallexample
+@c ================================================== parse.error
+@item parse.error
+@findex %define parse.error
+@itemize
+@item Languages(s):
+all
+@item Purpose:
+Control the kind of error messages passed to the error reporting
+function. @xref{Error Reporting, ,The Error Reporting Function
+@code{yyerror}}.
+@item Accepted Values:
+@itemize
+@item @code{simple}
+Error messages passed to @code{yyerror} are simply @w{@code{"syntax
+error"}}.
+@item @code{verbose}
+Error messages report the unexpected token, and possibly the expected ones.
+However, this report can often be incorrect when LAC is not enabled
+(@pxref{LAC}).
+@end itemize
-The parser namespace is @code{foo} and @code{yylex} is referenced as
-@code{bar::lex}.
+@item Default Value:
+@code{simple}
@end itemize
+@c parse.error
+
@c ================================================== parse.lac
-@item @code{parse.lac}
+@item parse.lac
@findex %define parse.lac
@itemize
@item Accepted Values: @code{none}, @code{full}
@item Default Value: @code{none}
@end itemize
+@c parse.lac
+
+@c ================================================== parse.trace
+@item parse.trace
+@findex %define parse.trace
+
+@itemize
+@item Languages(s): C, C++, Java
+
+@item Purpose: Require parser instrumentation for tracing.
+@xref{Tracing, ,Tracing Your Parser}.
+
+In C/C++, define the macro @code{YYDEBUG} (or @code{@var{prefix}DEBUG} with
+@samp{%define api.prefix @var{prefix}}), see @ref{Multiple Parsers,
+,Multiple Parsers in the Same Program}) to 1 in the parser implementation
+file if it is not already defined, so that the debugging facilities are
+compiled.
+
+@item Accepted Values: Boolean
+
+@item Default Value: @code{false}
+@end itemize
+@c parse.trace
+
+@c ================================================== variant
+@item variant
+@findex %define variant
+
+@itemize @bullet
+@item Language(s):
+C++
+
+@item Purpose:
+Request variant-based semantic values.
+@xref{C++ Variants}.
+
+@item Accepted Values:
+Boolean.
+
+@item Default Value:
+@code{false}
@end itemize
+@c variant
+@end table
@node %code Summary
Not all qualifiers are accepted for all target languages. Unaccepted
qualifiers produce an error. Some of the accepted qualifiers are:
-@itemize @bullet
+@table @code
@item requires
@findex %code requires
@item Location(s): The parser Java file after any Java package directive and
before any class definitions.
@end itemize
-@end itemize
+@end table
Though we say the insertion locations are language-dependent, they are
technically skeleton-dependent. Writers of non-standard skeletons
parameter information to it in a reentrant way. To do so, use the
declaration @code{%parse-param}:
-@deffn {Directive} %parse-param @{@var{argument-declaration}@}
+@deffn {Directive} %parse-param @{@var{argument-declaration}@} @dots{}
@findex %parse-param
-Declare that an argument declared by the braced-code
-@var{argument-declaration} is an additional @code{yyparse} argument.
+Declare that one or more
+@var{argument-declaration} are additional @code{yyparse} arguments.
The @var{argument-declaration} is used when declaring
functions or prototypes. The last identifier in
@var{argument-declaration} must be the argument name.
Here's an example. Write this in the parser:
@example
-%parse-param @{int *nastiness@}
-%parse-param @{int *randomness@}
+%parse-param @{int *nastiness@} @{int *randomness@}
@end example
@noindent
More user feedback will help to stabilize it.)
You call the function @code{yypush_parse} to parse a single token. This
-function is available if either the @code{%define api.push-pull push} or
-@code{%define api.push-pull both} declaration is used.
+function is available if either the @samp{%define api.push-pull push} or
+@samp{%define api.push-pull both} declaration is used.
@xref{Push Decl, ,A Push Parser}.
@deftypefun int yypush_parse (yypstate *yyps)
More user feedback will help to stabilize it.)
You call the function @code{yypull_parse} to parse the rest of the input
-stream. This function is available if the @code{%define api.push-pull both}
+stream. This function is available if the @samp{%define api.push-pull both}
declaration is used.
@xref{Push Decl, ,A Push Parser}.
More user feedback will help to stabilize it.)
You call the function @code{yypstate_new} to create a new parser instance.
-This function is available if either the @code{%define api.push-pull push} or
-@code{%define api.push-pull both} declaration is used.
+This function is available if either the @samp{%define api.push-pull push} or
+@samp{%define api.push-pull both} declaration is used.
@xref{Push Decl, ,A Push Parser}.
@deftypefun {yypstate*} yypstate_new (void)
More user feedback will help to stabilize it.)
You call the function @code{yypstate_delete} to delete a parser instance.
-function is available if either the @code{%define api.push-pull push} or
-@code{%define api.push-pull both} declaration is used.
+function is available if either the @samp{%define api.push-pull push} or
+@samp{%define api.push-pull both} declaration is used.
@xref{Push Decl, ,A Push Parser}.
@deftypefun void yypstate_delete (yypstate *yyps)
this case, omit the second argument; @code{yylex} will be called with
only one argument.
-
-If you wish to pass the additional parameter data to @code{yylex}, use
+If you wish to pass additional arguments to @code{yylex}, use
@code{%lex-param} just like @code{%parse-param} (@pxref{Parser
-Function}).
+Function}). To pass additional arguments to both @code{yylex} and
+@code{yyparse}, use @code{%param}.
-@deffn {Directive} lex-param @{@var{argument-declaration}@}
+@deffn {Directive} %lex-param @{@var{argument-declaration}@} @dots{}
@findex %lex-param
-Declare that the braced-code @var{argument-declaration} is an
-additional @code{yylex} argument declaration.
+Specify that @var{argument-declaration} are additional @code{yylex} argument
+declarations. You may pass one or more such declarations, which is
+equivalent to repeating @code{%lex-param}.
+@end deffn
+
+@deffn {Directive} %param @{@var{argument-declaration}@} @dots{}
+@findex %param
+Specify that @var{argument-declaration} are additional
+@code{yylex}/@code{yyparse} argument declaration. This is equivalent to
+@samp{%lex-param @{@var{argument-declaration}@} @dots{} %parse-param
+@{@var{argument-declaration}@} @dots{}}. You may pass one or more
+declarations, which is equivalent to repeating @code{%param}.
@end deffn
@noindent
For instance:
@example
-%lex-param @{int *nastiness@}
+%lex-param @{scanner_mode *mode@}
+%parse-param @{parser_mode *mode@}
+%param @{environment_type *env@}
@end example
@noindent
-results in the following signature:
+results in the following signatures:
@example
-int yylex (int *nastiness);
+int yylex (scanner_mode *mode, environment_type *env);
+int yyparse (parser_mode *mode, environment_type *env);
+@end example
+
+If @samp{%define api.pure full} is added:
+
+@example
+int yylex (YYSTYPE *lvalp, scanner_mode *mode, environment_type *env);
+int yyparse (parser_mode *mode, environment_type *env);
@end example
@noindent
-If @code{%define api.pure full} (or just @code{%define api.pure}) is added:
+and finally, if both @samp{%define api.pure full} and @code{%locations} are
+used:
@example
-int yylex (YYSTYPE *lvalp, int *nastiness);
+int yylex (YYSTYPE *lvalp, YYLTYPE *llocp,
+ scanner_mode *mode, environment_type *env);
+int yyparse (parser_mode *mode, environment_type *env);
@end example
@node Error Reporting
@cindex parse error
@cindex syntax error
-The Bison parser detects a @dfn{syntax error} or @dfn{parse error}
+The Bison parser detects a @dfn{syntax error} (or @dfn{parse error})
whenever it reads a token which cannot satisfy any syntax rule. An
action in the grammar can also explicitly proclaim an error, using the
macro @code{YYERROR} (@pxref{Action Features, ,Special Features for Use
receives one argument. For a syntax error, the string is normally
@w{@code{"syntax error"}}.
-@findex %error-verbose
-If you invoke the directive @code{%error-verbose} in the Bison declarations
+@findex %define parse.error
+If you invoke @samp{%define parse.error verbose} in the Bison declarations
section (@pxref{Bison Declarations, ,The Bison Declarations Section}), then
Bison provides a more verbose and specific error message string instead of
just plain @w{@code{"syntax error"}}. However, that message sometimes
the conflict:
@example
-@group
%%
-@end group
@group
stmt:
expr
@menu
* Why Precedence:: An example showing why precedence is needed.
-* Using Precedence:: How to specify precedence in Bison grammars.
+* Using Precedence:: How to specify precedence and associativity.
+* Precedence Only:: How to specify precedence only.
* Precedence Examples:: How these features are used in the previous example.
* How Precedence:: How they work.
* Non Operators:: Using precedence for general conflicts.
@node Using Precedence
@subsection Specifying Operator Precedence
@findex %left
-@findex %right
@findex %nonassoc
+@findex %precedence
+@findex %right
Bison allows you to specify these choices with the operator precedence
declarations @code{%left} and @code{%right}. Each such declaration
them right-associative. A third alternative is @code{%nonassoc}, which
declares that it is a syntax error to find the same operator twice ``in a
row''.
+The last alternative, @code{%precedence}, allows to define only
+precedence and no associativity at all. As a result, any
+associativity-related conflict that remains will be reported as an
+compile-time error. The directive @code{%nonassoc} creates run-time
+error: using the operator in a associative way is a syntax error. The
+directive @code{%precedence} creates compile-time errors: an operator
+@emph{can} be involved in an associativity-related conflict, contrary to
+what expected the grammar author.
The relative precedence of different operators is controlled by the
-order in which they are declared. The first @code{%left} or
-@code{%right} declaration in the file declares the operators whose
+order in which they are declared. The first precedence/associativity
+declaration in the file declares the operators whose
precedence is lowest, the next such declaration declares the operators
whose precedence is a little higher, and so on.
+@node Precedence Only
+@subsection Specifying Precedence Only
+@findex %precedence
+
+Since POSIX Yacc defines only @code{%left}, @code{%right}, and
+@code{%nonassoc}, which all defines precedence and associativity, little
+attention is paid to the fact that precedence cannot be defined without
+defining associativity. Yet, sometimes, when trying to solve a
+conflict, precedence suffices. In such a case, using @code{%left},
+@code{%right}, or @code{%nonassoc} might hide future (associativity
+related) conflicts that would remain hidden.
+
+The dangling @code{else} ambiguity (@pxref{Shift/Reduce, , Shift/Reduce
+Conflicts}) can be solved explicitly. This shift/reduce conflicts occurs
+in the following situation, where the period denotes the current parsing
+state:
+
+@example
+if @var{e1} then if @var{e2} then @var{s1} . else @var{s2}
+@end example
+
+The conflict involves the reduction of the rule @samp{IF expr THEN
+stmt}, which precedence is by default that of its last token
+(@code{THEN}), and the shifting of the token @code{ELSE}. The usual
+disambiguation (attach the @code{else} to the closest @code{if}),
+shifting must be preferred, i.e., the precedence of @code{ELSE} must be
+higher than that of @code{THEN}. But neither is expected to be involved
+in an associativity related conflict, which can be specified as follows.
+
+@example
+%precedence THEN
+%precedence ELSE
+@end example
+
+The unary-minus is another typical example where associativity is
+usually over-specified, see @ref{Infix Calc, , Infix Notation
+Calculator: @code{calc}}. The @code{%left} directive is traditionally
+used to declare the precedence of @code{NEG}, which is more than needed
+since it also defines its associativity. While this is harmless in the
+traditional example, who knows how @code{NEG} might be used in future
+evolutions of the grammar@dots{}
+
@node Precedence Examples
@subsection Precedence Examples
@example
@group
-%nonassoc "then"
-%nonassoc "else"
+%precedence "then"
+%precedence "else"
@end group
@end example
@end example
Neither solution is perfect however. Since Bison does not provide, so far,
-support for ``scoped'' precedence, both force you to declare the precedence
+``scoped'' precedence, both force you to declare the precedence
of these keywords with respect to the other operators your grammar.
Therefore, instead of being warned about new conflicts you would be unaware
of (e.g., a shift/reduce conflict due to @samp{if test then 1 else 2 + 3}
sign typically has a very high precedence as a unary operator, and a
somewhat lower precedence (lower than multiplication) as a binary operator.
-The Bison precedence declarations, @code{%left}, @code{%right} and
-@code{%nonassoc}, can only be used once for a given token; so a token has
+The Bison precedence declarations
+can only be used once for a given token; so a token has
only one precedence declared in this way. For context-dependent
precedence, you need to use an additional mechanism: the @code{%prec}
modifier for rules.
Here is another common error that yields a reduce/reduce conflict:
@example
-sequence:
@group
+sequence:
/* empty */
| sequence words
| sequence redirects
rule:
@example
-%nonassoc "word"
-%nonassoc "sequence"
+%precedence "word"
+%precedence "sequence"
%%
@group
sequence:
| name_list ':' type
;
@end group
+
@group
return_spec:
type
| name ':' type
;
@end group
-@group
+
type: "id";
-@end group
+
@group
name: "id";
name_list:
rather than the one for @code{name}.
@example
+@group
param_spec:
type
| name_list ':' type
;
+@end group
+
+@group
return_spec:
type
| "id" ':' type
;
+@end group
@end example
For a more detailed exposition of LALR(1) parsers and parser
historical reasons, but that behavior is often not robust. For example, in
the previous section, we discussed the mysterious conflicts that can be
produced by LALR(1), Bison's default parser table construction algorithm.
-Another example is Bison's @code{%error-verbose} directive, which instructs
-the generated parser to produce verbose syntax error messages, which can
-sometimes contain incorrect information.
+Another example is Bison's @code{%define parse.error verbose} directive,
+which instructs the generated parser to produce verbose syntax error
+messages, which can sometimes contain incorrect information.
In this section, we explore several modern features of Bison that allow you
to tune fundamental aspects of the generated LR-based parsers. Some of
@cindex GLR with LALR
When employing GLR parsers (@pxref{GLR Parsers}), if you do not resolve any
-conflicts statically (for example, with @code{%left} or @code{%prec}), then
+conflicts statically (for example, with @code{%left} or @code{%precedence}),
+then
the parser explores all potential parses of any given input. In this case,
the choice of parser table construction algorithm is guaranteed not to alter
the language accepted by the parser. LALR parser tables are the smallest
@node Default Reductions
@subsection Default Reductions
@cindex default reductions
-@findex %define lr.default-reductions
+@findex %define lr.default-reduction
@findex %nonassoc
After parser table construction, Bison identifies the reduction with the
split the parse instead.
To adjust which states have default reductions enabled, use the
-@code{%define lr.default-reductions} directive.
+@code{%define lr.default-reduction} directive.
-@deffn {Directive} {%define lr.default-reductions} @var{where}
+@deffn {Directive} {%define lr.default-reduction} @var{where}
Specify the kind of states that are permitted to contain default reductions.
The accepted values of @var{where} are:
@itemize
@node Unreachable States
@subsection Unreachable States
-@findex %define lr.keep-unreachable-states
+@findex %define lr.keep-unreachable-state
@cindex unreachable states
If there exists no sequence of transitions from the parser's start state to
keeping unreachable states is sometimes useful when trying to understand the
relationship between the parser and the grammar.
-@deffn {Directive} {%define lr.keep-unreachable-states} @var{value}
+@deffn {Directive} {%define lr.keep-unreachable-state} @var{value}
Request that Bison allow unreachable states to remain in the parser tables.
@var{value} must be a Boolean. The default is @code{false}.
@end deffn
Do not allow @code{YYINITDEPTH} to be greater than @code{YYMAXDEPTH}.
-@c FIXME: C++ output.
-Because of semantic differences between C and C++, the deterministic
-parsers in C produced by Bison cannot grow when compiled
-by C++ compilers. In this precise case (compiling a C parser as C++) you are
-suggested to grow @code{YYINITDEPTH}. The Bison maintainers hope to fix
-this deficiency in a future release.
+You can generate a deterministic parser containing C++ user code from
+the default (C) skeleton, as well as from the C++ skeleton
+(@pxref{C++ Parsers}). However, if you do use the default skeleton
+and want to allow the parsing stack to grow,
+be careful not to use semantic types or location types that require
+non-trivial copy constructors.
+The C skeleton bypasses these constructors when copying data to
+new, larger stacks.
@node Error Recovery
@chapter Error Recovery
@item the directive @samp{%debug}
@findex %debug
Add the @code{%debug} directive (@pxref{Decl Summary, ,Bison Declaration
-Summary}). This is a Bison extension, especially useful for languages that
-don't use a preprocessor. Unless POSIX and Yacc portability matter to you,
-this is the preferred solution.
+Summary}). This Bison extension is maintained for backward
+compatibility with previous versions of Bison.
+
+@item the variable @samp{parse.trace}
+@findex %define parse.trace
+Add the @samp{%define parse.trace} directive (@pxref{%define
+Summary,,parse.trace}), or pass the @option{-Dparse.trace} option
+(@pxref{Bison Options}). This is a Bison extension, which is especially
+useful for languages that don't use a preprocessor. Unless POSIX and Yacc
+portability matter to you, this is the preferred solution.
@end table
-We suggest that you always enable the debug option so that debugging is
+We suggest that you always enable the trace option so that debugging is
always possible.
@findex YYFPRINTF
conflicts is not reported, so @option{-W} and @option{--warning} then have
no effect on the conflict report.
+@item deprecated
+Deprecated constructs whose support will be removed in future versions of
+Bison.
+
@item other
All warnings not categorized above. These warnings are enabled by default.
@item none
Turn off all the warnings.
@item error
-Treat warnings as errors.
+See @option{-Werror}, below.
@end table
A category can be turned off by prefixing its name with @samp{no-}. For
instance, @option{-Wno-yacc} will hide the warnings about
POSIX Yacc incompatibilities.
+@item -Werror[=@var{category}]
+@itemx -Wno-error[=@var{category}]
+Enable warnings falling in @var{category}, and treat them as errors. If no
+@var{category} is given, it defaults to making all enabled warnings into errors.
+
+@var{category} is the same as for @option{--warnings}, with the exception that
+it may not be prefixed with @samp{no-} (see above).
+
+Prefixed with @samp{no}, it deactivates the error treatment for this
+@var{category}. However, the warning itself won't be disabled, or enabled, by
+this option.
+
+Note that the precedence of the @samp{=} and @samp{,} operators is such that
+the following commands are @emph{not} equivalent, as the first will not treat
+S/R conflicts as errors.
+
+@example
+$ bison -Werror=yacc,conflicts-sr input.y
+$ bison -Werror=yacc,error=conflicts-sr input.y
+@end example
+
@item -f [@var{feature}]
@itemx --feature[=@var{feature}]
Activate miscellaneous @var{feature}. @var{feature} can be one of:
When run, @command{bison} will create several entities in the @samp{yy}
namespace.
-@findex %define namespace
-Use the @samp{%define namespace} directive to change the namespace
-name, see @ref{%define Summary,,namespace}. The various classes are
-generated in the following files:
+@findex %define api.namespace
+Use the @samp{%define api.namespace} directive to change the namespace name,
+see @ref{%define Summary,,api.namespace}. The various classes are generated
+in the following files:
@table @file
@item position.hh
@itemx location.hh
The definition of the classes @code{position} and @code{location}, used for
-location tracking. These files are not generated if the @code{%define}
-variable @code{api.location.type} is defined. @xref{C++ Location Values}.
+location tracking when enabled. These files are not generated if the
+@code{%define} variable @code{api.location.type} is defined. @xref{C++
+Location Values}.
@item stack.hh
An auxiliary class @code{stack} used by the parser.
@c - YYSTYPE
@c - Printer and destructor
+Bison supports two different means to handle semantic values in C++. One is
+alike the C interface, and relies on unions (@pxref{C++ Unions}). As C++
+practitioners know, unions are inconvenient in C++, therefore another
+approach is provided, based on variants (@pxref{C++ Variants}).
+
+@menu
+* C++ Unions:: Semantic values cannot be objects
+* C++ Variants:: Using objects as semantic values
+@end menu
+
+@node C++ Unions
+@subsubsection C++ Unions
+
The @code{%union} directive works as for C, see @ref{Union Decl, ,The
Collection of Value Types}. In particular it produces a genuine
-@code{union}@footnote{In the future techniques to allow complex types
-within pseudo-unions (similar to Boost variants) might be implemented to
-alleviate these issues.}, which have a few specific features in C++.
+@code{union}, which have a few specific features in C++.
@itemize @minus
@item
The type @code{YYSTYPE} is defined but its use is discouraged: rather
only means to avoid leaks. @xref{Destructor Decl, , Freeing Discarded
Symbols}.
+@node C++ Variants
+@subsubsection C++ Variants
+
+Starting with version 2.6, Bison provides a @emph{variant} based
+implementation of semantic values for C++. This alleviates all the
+limitations reported in the previous section, and in particular, object
+types can be used without pointers.
+
+To enable variant-based semantic values, set @code{%define} variable
+@code{variant} (@pxref{%define Summary,, variant}). Once this defined,
+@code{%union} is ignored, and instead of using the name of the fields of the
+@code{%union} to ``type'' the symbols, use genuine types.
+
+For instance, instead of
+
+@example
+%union
+@{
+ int ival;
+ std::string* sval;
+@}
+%token <ival> NUMBER;
+%token <sval> STRING;
+@end example
+
+@noindent
+write
+
+@example
+%token <int> NUMBER;
+%token <std::string> STRING;
+@end example
+
+@code{STRING} is no longer a pointer, which should fairly simplify the user
+actions in the grammar and in the scanner (in particular the memory
+management).
+
+Since C++ features destructors, and since it is customary to specialize
+@code{operator<<} to support uniform printing of values, variants also
+typically simplify Bison printers and destructors.
+
+Variants are stricter than unions. When based on unions, you may play any
+dirty game with @code{yylval}, say storing an @code{int}, reading a
+@code{char*}, and then storing a @code{double} in it. This is no longer
+possible with variants: they must be initialized, then assigned to, and
+eventually, destroyed.
+
+@deftypemethod {semantic_type} {T&} build<T> ()
+Initialize, but leave empty. Returns the address where the actual value may
+be stored. Requires that the variant was not initialized yet.
+@end deftypemethod
+
+@deftypemethod {semantic_type} {T&} build<T> (const T& @var{t})
+Initialize, and copy-construct from @var{t}.
+@end deftypemethod
+
+
+@strong{Warning}: We do not use Boost.Variant, for two reasons. First, it
+appeared unacceptable to require Boost on the user's machine (i.e., the
+machine on which the generated parser will be compiled, not the machine on
+which @command{bison} was run). Second, for each possible semantic value,
+Boost.Variant not only stores the value, but also a tag specifying its
+type. But the parser already ``knows'' the type of the semantic value, so
+that would be duplicating the information.
+
+Therefore we developed light-weight variants whose type tag is external (so
+they are really like @code{unions} for C++ actually). But our code is much
+less mature that Boost.Variant. So there is a number of limitations in
+(the current implementation of) variants:
+@itemize
+@item
+Alignment must be enforced: values should be aligned in memory according to
+the most demanding type. Computing the smallest alignment possible requires
+meta-programming techniques that are not currently implemented in Bison, and
+therefore, since, as far as we know, @code{double} is the most demanding
+type on all platforms, alignments are enforced for @code{double} whatever
+types are actually used. This may waste space in some cases.
+
+@item
+Our implementation is not conforming with strict aliasing rules. Alias
+analysis is a technique used in optimizing compilers to detect when two
+pointers are disjoint (they cannot ``meet''). Our implementation breaks
+some of the rules that G++ 4.4 uses in its alias analysis, so @emph{strict
+alias analysis must be disabled}. Use the option
+@option{-fno-strict-aliasing} to compile the generated parser.
+
+@item
+There might be portability issues we are not aware of.
+@end itemize
+
+As far as we know, these limitations @emph{can} be alleviated. All it takes
+is some time and/or some talented C++ hacker willing to contribute to Bison.
@node C++ Location Values
@subsection C++ Location Values
genuine code only the latter is used.
@menu
-* C++ position:: One point in the source file
-* C++ location:: Two points in the source file
+* C++ position:: One point in the source file
+* C++ location:: Two points in the source file
* User Defined Location Type:: Required interface for locations
@end menu
@defcv {Type} {parser} {semantic_type}
@defcvx {Type} {parser} {location_type}
-The types for semantics value and locations.
+The types for semantic values and locations (if enabled).
@end defcv
@defcv {Type} {parser} {token}
(@pxref{Calc++ Scanner}).
@end defcv
+@defcv {Type} {parser} {syntax_error}
+This class derives from @code{std::runtime_error}. Throw instances of it
+from the scanner or from the user actions to raise parse errors. This is
+equivalent with first
+invoking @code{error} to report the location and message of the syntax
+error, and then to invoke @code{YYERROR} to enter the error-recovery mode.
+But contrary to @code{YYERROR} which can only be invoked from user actions
+(i.e., written in the action itself), the exception can be thrown from
+function invoked from the user action.
+@end defcv
+
@deftypemethod {parser} {} parser (@var{type1} @var{arg1}, ...)
Build a new parser object. There are no arguments by default, unless
@samp{%parse-param @{@var{type1} @var{arg1}@}} was used.
@end deftypemethod
+@deftypemethod {syntax_error} {} syntax_error (const location_type& @var{l}, const std::string& @var{m})
+@deftypemethodx {syntax_error} {} syntax_error (const std::string& @var{m})
+Instantiate a syntax-error exception.
+@end deftypemethod
+
@deftypemethod {parser} {int} parse ()
Run the syntactic analysis, and return 0 on success, 1 otherwise.
@end deftypemethod
@deftypemethod {parser} {void} error (const location_type& @var{l}, const std::string& @var{m})
+@deftypemethodx {parser} {void} error (const std::string& @var{m})
The definition for this member function must be supplied by the user:
the parser uses it to report a parser error occurring at @var{l},
-described by @var{m}.
+described by @var{m}. If location tracking is not enabled, the second
+signature is used.
@end deftypemethod
The parser invokes the scanner by calling @code{yylex}. Contrary to C
parsers, C++ parsers are always pure: there is no point in using the
-@code{%define api.pure full} directive. Therefore the interface is as follows.
+@samp{%define api.pure} directive. The actual interface with @code{yylex}
+depends whether you use unions, or variants.
+
+@menu
+* Split Symbols:: Passing symbols as two/three components
+* Complete Symbols:: Making symbols a whole
+@end menu
+
+@node Split Symbols
+@subsubsection Split Symbols
+
+The interface is as follows.
@deftypemethod {parser} {int} yylex (semantic_type* @var{yylval}, location_type* @var{yylloc}, @var{type1} @var{arg1}, ...)
-Return the next token. Its type is the return value, its semantic
-value and location being @var{yylval} and @var{yylloc}. Invocations of
+@deftypemethodx {parser} {int} yylex (semantic_type* @var{yylval}, @var{type1} @var{arg1}, ...)
+Return the next token. Its type is the return value, its semantic value and
+location (if enabled) being @var{yylval} and @var{yylloc}. Invocations of
@samp{%lex-param @{@var{type1} @var{arg1}@}} yield additional arguments.
@end deftypemethod
+Note that when using variants, the interface for @code{yylex} is the same,
+but @code{yylval} is handled differently.
+
+Regular union-based code in Lex scanner typically look like:
+
+@example
+[0-9]+ @{
+ yylval.ival = text_to_int (yytext);
+ return yy::parser::INTEGER;
+ @}
+[a-z]+ @{
+ yylval.sval = new std::string (yytext);
+ return yy::parser::IDENTIFIER;
+ @}
+@end example
+
+Using variants, @code{yylval} is already constructed, but it is not
+initialized. So the code would look like:
+
+@example
+[0-9]+ @{
+ yylval.build<int>() = text_to_int (yytext);
+ return yy::parser::INTEGER;
+ @}
+[a-z]+ @{
+ yylval.build<std::string> = yytext;
+ return yy::parser::IDENTIFIER;
+ @}
+@end example
+
+@noindent
+or
+
+@example
+[0-9]+ @{
+ yylval.build(text_to_int (yytext));
+ return yy::parser::INTEGER;
+ @}
+[a-z]+ @{
+ yylval.build(yytext);
+ return yy::parser::IDENTIFIER;
+ @}
+@end example
+
+
+@node Complete Symbols
+@subsubsection Complete Symbols
+
+If you specified both @code{%define variant} and
+@code{%define api.token.constructor},
+the @code{parser} class also defines the class @code{parser::symbol_type}
+which defines a @emph{complete} symbol, aggregating its type (i.e., the
+traditional value returned by @code{yylex}), its semantic value (i.e., the
+value passed in @code{yylval}, and possibly its location (@code{yylloc}).
+
+@deftypemethod {symbol_type} {} symbol_type (token_type @var{type}, const semantic_type& @var{value}, const location_type& @var{location})
+Build a complete terminal symbol which token type is @var{type}, and which
+semantic value is @var{value}. If location tracking is enabled, also pass
+the @var{location}.
+@end deftypemethod
+
+This interface is low-level and should not be used for two reasons. First,
+it is inconvenient, as you still have to build the semantic value, which is
+a variant, and second, because consistency is not enforced: as with unions,
+it is still possible to give an integer as semantic value for a string.
+
+So for each token type, Bison generates named constructors as follows.
+
+@deftypemethod {symbol_type} {} make_@var{token} (const @var{value_type}& @var{value}, const location_type& @var{location})
+@deftypemethodx {symbol_type} {} make_@var{token} (const location_type& @var{location})
+Build a complete terminal symbol for the token type @var{token} (not
+including the @code{api.token.prefix}) whose possible semantic value is
+@var{value} of adequate @var{value_type}. If location tracking is enabled,
+also pass the @var{location}.
+@end deftypemethod
+
+For instance, given the following declarations:
+
+@example
+%define api.token.prefix "TOK_"
+%token <std::string> IDENTIFIER;
+%token <int> INTEGER;
+%token COLON;
+@end example
+
+@noindent
+Bison generates the following functions:
+
+@example
+symbol_type make_IDENTIFIER(const std::string& v,
+ const location_type& l);
+symbol_type make_INTEGER(const int& v,
+ const location_type& loc);
+symbol_type make_COLON(const location_type& loc);
+@end example
+
+@noindent
+which should be used in a Lex-scanner as follows.
+
+@example
+[0-9]+ return yy::parser::make_INTEGER(text_to_int (yytext), loc);
+[a-z]+ return yy::parser::make_IDENTIFIER(yytext, loc);
+":" return yy::parser::make_COLON(loc);
+@end example
+
+Tokens that do not have an identifier are not accessible: you cannot simply
+use characters such as @code{':'}, they must be declared with @code{%token}.
@node A Complete C++ Example
@subsection A Complete C++ Example
This section demonstrates the use of a C++ parser with a simple but
complete example. This example should be available on your system,
-ready to compile, in the directory @dfn{../bison/examples/calc++}. It
+ready to compile, in the directory @dfn{.../bison/examples/calc++}. It
focuses on the use of Bison, therefore the design of the various C++
classes is very naive: no accessors, no encapsulation of members etc.
We will use a Lex scanner, and more precisely, a Flex scanner, to
-demonstrate the various interaction. A hand written scanner is
+demonstrate the various interactions. A hand-written scanner is
actually easier to interface with.
@menu
@comment file: calc++-driver.hh
@example
// Tell Flex the lexer's prototype ...
-# define YY_DECL \
- yy::calcxx_parser::token_type \
- yylex (yy::calcxx_parser::semantic_type* yylval, \
- yy::calcxx_parser::location_type* yylloc, \
- calcxx_driver& driver)
+# define YY_DECL \
+ yy::calcxx_parser::symbol_type yylex (calcxx_driver& driver)
// ... and declare it for the parser's sake.
YY_DECL;
@end example
@end example
@noindent
-To encapsulate the coordination with the Flex scanner, it is useful to
-have two members function to open and close the scanning phase.
+To encapsulate the coordination with the Flex scanner, it is useful to have
+member functions to open and close the scanning phase.
@comment file: calc++-driver.hh
@example
@comment file: calc++-driver.hh
@example
- // Run the parser. Return 0 on success.
+ // Run the parser on file F.
+ // Return 0 on success.
int parse (const std::string& f);
+ // The name of the file being parsed.
+ // Used later to pass the file name to the location tracker.
std::string file;
+ // Whether parser traces should be generated.
bool trace_parsing;
@end example
%define parser_class_name "calcxx_parser"
@end example
+@noindent
+@findex %define api.token.constructor
+@findex %define variant
+This example will use genuine C++ objects as semantic values, therefore, we
+require the variant-based interface. To make sure we properly use it, we
+enable assertions. To fully benefit from type-safety and more natural
+definition of ``symbol'', we enable @code{api.token.constructor}.
+
+@comment file: calc++-parser.yy
+@example
+%define api.token.constructor
+%define parse.assert
+%define variant
+@end example
+
@noindent
@findex %code requires
-Then come the declarations/inclusions needed to define the
-@code{%union}. Because the parser uses the parsing driver and
-reciprocally, both cannot include the header of the other. Because the
+Then come the declarations/inclusions needed by the semantic values.
+Because the parser uses the parsing driver and reciprocally, both would like
+to include the header of the other, which is, of course, insane. This
+mutual dependency will be broken using forward declarations. Because the
driver's header needs detailed knowledge about the parser class (in
-particular its inner types), it is the parser's header which will simply
-use a forward declaration of the driver.
-@xref{%code Summary}.
+particular its inner types), it is the parser's header which will use a
+forward declaration of the driver. @xref{%code Summary}.
@comment file: calc++-parser.yy
@example
-%code requires @{
+%code requires
+@{
# include <string>
class calcxx_driver;
@}
@comment file: calc++-parser.yy
@example
// The parsing context.
-%parse-param @{ calcxx_driver& driver @}
-%lex-param @{ calcxx_driver& driver @}
+%param @{ calcxx_driver& driver @}
@end example
@noindent
-Then we request the location tracking feature, and initialize the
+Then we request location tracking, and initialize the
first location's file name. Afterward new locations are computed
relatively to the previous locations: the file name will be
-automatically propagated.
+propagated.
@comment file: calc++-parser.yy
@example
@end example
@noindent
-Use the two following directives to enable parser tracing and verbose error
+Use the following two directives to enable parser tracing and verbose error
messages. However, verbose error messages can contain incorrect information
(@pxref{LAC}).
@comment file: calc++-parser.yy
@example
-%debug
-%error-verbose
-@end example
-
-@noindent
-Semantic values cannot use ``real'' objects, but only pointers to
-them.
-
-@comment file: calc++-parser.yy
-@example
-// Symbols.
-%union
-@{
- int ival;
- std::string *sval;
-@};
+%define parse.trace
+%define parse.error verbose
@end example
@noindent
@comment file: calc++-parser.yy
@example
-%code @{
+%code
+@{
# include "calc++-driver.hh"
@}
@end example
@noindent
The token numbered as 0 corresponds to end of file; the following line
-allows for nicer error messages referring to ``end of file'' instead
-of ``$end''. Similarly user friendly named are provided for each
-symbol. Note that the tokens names are prefixed by @code{TOKEN_} to
-avoid name clashes.
+allows for nicer error messages referring to ``end of file'' instead of
+``$end''. Similarly user friendly names are provided for each symbol. To
+avoid name clashes in the generated files (@pxref{Calc++ Scanner}), prefix
+tokens with @code{TOK_} (@pxref{%define Summary,,api.token.prefix}).
@comment file: calc++-parser.yy
@example
-%token END 0 "end of file"
-%token ASSIGN ":="
-%token <sval> IDENTIFIER "identifier"
-%token <ival> NUMBER "number"
-%type <ival> exp
+%define api.token.prefix "TOK_"
+%token
+ END 0 "end of file"
+ ASSIGN ":="
+ MINUS "-"
+ PLUS "+"
+ STAR "*"
+ SLASH "/"
+ LPAREN "("
+ RPAREN ")"
+;
@end example
@noindent
-To enable memory deallocation during error recovery, use
-@code{%destructor}.
+Since we use variant-based semantic values, @code{%union} is not used, and
+both @code{%type} and @code{%token} expect genuine types, as opposed to type
+tags.
-@c FIXME: Document %printer, and mention that it takes a braced-code operand.
@comment file: calc++-parser.yy
@example
-%printer @{ yyoutput << *$$; @} "identifier"
-%destructor @{ delete $$; @} "identifier"
+%token <std::string> IDENTIFIER "identifier"
+%token <int> NUMBER "number"
+%type <int> exp
+@end example
+
+@noindent
+No @code{%destructor} is needed to enable memory deallocation during error
+recovery; the memory, for strings for instance, will be reclaimed by the
+regular destructors. All the values are printed using their
+@code{operator<<} (@pxref{Printer Decl, , Printing Semantic Values}).
-%printer @{ yyoutput << $$; @} <ival>
+@comment file: calc++-parser.yy
+@example
+%printer @{ yyoutput << $$; @} <*>;
@end example
@noindent
-The grammar itself is straightforward.
+The grammar itself is straightforward (@pxref{Location Tracking Calc, ,
+Location Tracking Calculator: @code{ltcalc}}).
@comment file: calc++-parser.yy
@example
| assignments assignment @{@};
assignment:
- "identifier" ":=" exp
- @{ driver.variables[*$1] = $3; delete $1; @};
-
-%left '+' '-';
-%left '*' '/';
-exp: exp '+' exp @{ $$ = $1 + $3; @}
- | exp '-' exp @{ $$ = $1 - $3; @}
- | exp '*' exp @{ $$ = $1 * $3; @}
- | exp '/' exp @{ $$ = $1 / $3; @}
- | "identifier" @{ $$ = driver.variables[*$1]; delete $1; @}
- | "number" @{ $$ = $1; @};
+ "identifier" ":=" exp @{ driver.variables[$1] = $3; @};
+
+%left "+" "-";
+%left "*" "/";
+exp:
+ exp "+" exp @{ $$ = $1 + $3; @}
+| exp "-" exp @{ $$ = $1 - $3; @}
+| exp "*" exp @{ $$ = $1 * $3; @}
+| exp "/" exp @{ $$ = $1 / $3; @}
+| "(" exp ")" @{ std::swap ($$, $2); @}
+| "identifier" @{ $$ = driver.variables[$1]; @}
+| "number" @{ std::swap ($$, $1); @};
%%
@end example
@comment file: calc++-parser.yy
@example
void
-yy::calcxx_parser::error (const yy::calcxx_parser::location_type& l,
+yy::calcxx_parser::error (const location_type& l,
const std::string& m)
@{
driver.error (l, m);
@comment file: calc++-scanner.ll
@example
%@{ /* -*- C++ -*- */
-# include <cstdlib>
# include <cerrno>
# include <climits>
+# include <cstdlib>
# include <string>
# include "calc++-driver.hh"
# include "calc++-parser.hh"
-/* Work around an incompatibility in flex (at least versions
- 2.5.31 through 2.5.33): it generates code that does
- not conform to C89. See Debian bug 333231
- <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */
+// Work around an incompatibility in flex (at least versions
+// 2.5.31 through 2.5.33): it generates code that does
+// not conform to C89. See Debian bug 333231
+// <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>.
# undef yywrap
# define yywrap() 1
-/* By default yylex returns int, we use token_type.
- Unfortunately yyterminate by default returns 0, which is
- not of token_type. */
-#define yyterminate() return token::END
+// The location of the current token.
+static yy::location loc;
%@}
@end example
Because there is no @code{#include}-like feature we don't need
@code{yywrap}, we don't need @code{unput} either, and we parse an
actual file, this is not an interactive session with the user.
-Finally we enable the scanner tracing features.
+Finally, we enable scanner tracing.
@comment file: calc++-scanner.ll
@example
@noindent
The following paragraph suffices to track locations accurately. Each
time @code{yylex} is invoked, the begin position is moved onto the end
-position. Then when a pattern is matched, the end position is
-advanced of its width. In case it matched ends of lines, the end
+position. Then when a pattern is matched, its width is added to the end
+column. When matching ends of lines, the end
cursor is adjusted, and each time blanks are matched, the begin cursor
is moved onto the end cursor to effectively ignore the blanks
preceding tokens. Comments would be treated equally.
@example
@group
%@{
-# define YY_USER_ACTION yylloc->columns (yyleng);
+ // Code run each time a pattern is matched.
+ # define YY_USER_ACTION loc.columns (yyleng);
%@}
@end group
%%
+@group
%@{
- yylloc->step ();
+ // Code run each time yylex is called.
+ loc.step ();
%@}
-@{blank@}+ yylloc->step ();
-[\n]+ yylloc->lines (yyleng); yylloc->step ();
+@end group
+@{blank@}+ loc.step ();
+[\n]+ loc.lines (yyleng); loc.step ();
@end example
@noindent
-The rules are simple, just note the use of the driver to report errors.
-It is convenient to use a typedef to shorten
-@code{yy::calcxx_parser::token::identifier} into
-@code{token::identifier} for instance.
+The rules are simple. The driver is used to report errors.
@comment file: calc++-scanner.ll
@example
-%@{
- typedef yy::calcxx_parser::token token;
-%@}
- /* Convert ints to the actual type of tokens. */
-[-+*/] return yy::calcxx_parser::token_type (yytext[0]);
-
-":=" return token::ASSIGN;
-
-@group
-@{int@} @{
- errno = 0;
- long n = strtol (yytext, NULL, 10);
- if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
- driver.error (*yylloc, "integer is out of range");
- yylval->ival = n;
- return token::NUMBER;
- @}
-@end group
-
-@group
-@{id@} @{
- yylval->sval = new std::string (yytext);
- return token::IDENTIFIER;
- @}
+"-" return yy::calcxx_parser::make_MINUS(loc);
+"+" return yy::calcxx_parser::make_PLUS(loc);
+"*" return yy::calcxx_parser::make_STAR(loc);
+"/" return yy::calcxx_parser::make_SLASH(loc);
+"(" return yy::calcxx_parser::make_LPAREN(loc);
+")" return yy::calcxx_parser::make_RPAREN(loc);
+":=" return yy::calcxx_parser::make_ASSIGN(loc);
+
+@group
+@{int@} @{
+ errno = 0;
+ long n = strtol (yytext, NULL, 10);
+ if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
+ driver.error (loc, "integer is out of range");
+ return yy::calcxx_parser::make_NUMBER(n, loc);
+@}
@end group
-
-. driver.error (*yylloc, "invalid character");
+@{id@} return yy::calcxx_parser::make_IDENTIFIER(yytext, loc);
+. driver.error (loc, "invalid character");
+<<EOF>> return yy::calcxx_parser::make_END(loc);
%%
@end example
@noindent
-Finally, because the scanner related driver's member function depend
+Finally, because the scanner-related driver's member-functions depend
on the scanner's data, it is simpler to implement them in this file.
@comment file: calc++-scanner.ll
int
main (int argc, char *argv[])
@{
+ int res = 0;
calcxx_driver driver;
for (int i = 1; i < argc; ++i)
if (argv[i] == std::string ("-p"))
driver.trace_scanning = true;
else if (!driver.parse (argv[i]))
std::cout << driver.result << std::endl;
+ else
+ res = 1;
+ return res;
@}
@end group
@end example
Contrary to C parsers, Java parsers do not use global variables; the
state of the parser is always local to an instance of the parser class.
Therefore, all Java parsers are ``pure'', and the @code{%pure-parser}
-and @code{%define api.pure full} directives does not do anything when used in
-Java.
+and @code{%define api.pure} directives do nothing when used in Java.
Push parsers are currently unsupported in Java and @code{%define
api.push-pull} have no effect.
@code{%defines} directive or the @option{-d}/@option{--defines} options.
@c FIXME: Possible code change.
-Currently, support for debugging and verbose errors are always compiled
-in. Thus the @code{%debug} and @code{%token-table} directives and the
+Currently, support for tracing is always compiled
+in. Thus the @samp{%define parse.trace} and @samp{%token-table}
+directives and the
@option{-t}/@option{--debug} and @option{-k}/@option{--token-table}
options have no effect. This may change in the future to eliminate
-unused code in the generated parser, so use @code{%debug} and
-@code{%verbose-error} explicitly if needed. Also, in the future the
+unused code in the generated parser, so use @samp{%define parse.trace}
+explicitly
+if needed. Also, in the future the
@code{%token-table} directive might enable a public interface to
access the token names and codes.
+Getting a ``code too large'' error from the Java compiler means the code
+hit the 64KB bytecode per method limitation of the Java class file.
+Try reducing the amount of code in actions and static initializers;
+otherwise, report a bug so that the parser skeleton will be improved.
+
+
@node Java Semantic Values
@subsection Java Semantic Values
@c - No %union, specify type in %type/%token.
By default, the semantic stack is declared to have @code{Object} members,
which means that the class types you specify can be of any class.
To improve the type safety of the parser, you can declare the common
-superclass of all the semantic values using the @code{%define stype}
+superclass of all the semantic values using the @samp{%define stype}
directive. For example, after the following declaration:
@example
The name of the generated parser class defaults to @code{YYParser}. The
@code{YY} prefix may be changed using the @code{%name-prefix} directive
or the @option{-p}/@option{--name-prefix} option. Alternatively, use
-@code{%define parser_class_name "@var{name}"} to give a custom name to
+@samp{%define parser_class_name "@var{name}"} to give a custom name to
the class. The interface of this class is detailed below.
By default, the parser class has package visibility. A declaration
-@code{%define public} will change to public visibility. Remember that,
+@samp{%define public} will change to public visibility. Remember that,
according to the Java language specification, the name of the @file{.java}
file should match the name of the class in this case. Similarly, you can
use @code{abstract}, @code{final} and @code{strictfp} with the
@code{%define} declaration to add other modifiers to the parser class.
+A single @samp{%define annotations "@var{annotations}"} directive can
+be used to add any number of annotations to the parser class.
The Java package name of the parser class can be specified using the
-@code{%define package} directive. The superclass and the implemented
+@samp{%define package} directive. The superclass and the implemented
interfaces of the parser class can be specified with the @code{%define
-extends} and @code{%define implements} directives.
+extends} and @samp{%define implements} directives.
The parser class defines an inner class, @code{Location}, that is used
for location tracking (see @ref{Java Location Values}), and a inner
below, all the other members and fields are preceded with a @code{yy} or
@code{YY} prefix to avoid clashes with user code.
-@c FIXME: The following constants and variables are still undocumented:
-@c @code{bisonVersion}, @code{bisonSkeleton} and @code{errorVerbose}.
-
The parser class can be extended using the @code{%parse-param}
directive. Each occurrence of the directive will add a @code{protected
final} field to the parser class, and an argument to its constructor,
which initialize them automatically.
-Token names defined by @code{%token} and the predefined @code{EOF} token
-name are added as constant fields to the parser class.
-
@deftypeop {Constructor} {YYParser} {} YYParser (@var{lex_param}, @dots{}, @var{parse_param}, @dots{})
Build a new parser object with embedded @code{%code lexer}. There are
-no parameters, unless @code{%parse-param}s and/or @code{%lex-param}s are
-used.
+no parameters, unless @code{%param}s and/or @code{%parse-param}s and/or
+@code{%lex-param}s are used.
+
+Use @code{%code init} for code added to the start of the constructor
+body. This is especially useful to initialize superclasses. Use
+@samp{%define init_throws} to specify any uncaught exceptions.
@end deftypeop
@deftypeop {Constructor} {YYParser} {} YYParser (Lexer @var{lexer}, @var{parse_param}, @dots{})
Build a new parser object using the specified scanner. There are no
-additional parameters unless @code{%parse-param}s are used.
+additional parameters unless @code{%param}s and/or @code{%parse-param}s are
+used.
If the scanner is defined by @code{%code lexer}, this constructor is
declared @code{protected} and is called automatically with a scanner
-created with the correct @code{%lex-param}s.
+created with the correct @code{%param}s and/or @code{%lex-param}s.
+
+Use @code{%code init} for code added to the start of the constructor
+body. This is especially useful to initialize superclasses. Use
+@samp{%define init_throws} to specify any uncaught exceptions.
@end deftypeop
@deftypemethod {YYParser} {boolean} parse ()
@code{false} otherwise.
@end deftypemethod
+@deftypemethod {YYParser} {boolean} getErrorVerbose ()
+@deftypemethodx {YYParser} {void} setErrorVerbose (boolean @var{verbose})
+Get or set the option to produce verbose error messages. These are only
+available with @samp{%define parse.error verbose}, which also turns on
+verbose error messages.
+@end deftypemethod
+
+@deftypemethod {YYParser} {void} yyerror (String @var{msg})
+@deftypemethodx {YYParser} {void} yyerror (Position @var{pos}, String @var{msg})
+@deftypemethodx {YYParser} {void} yyerror (Location @var{loc}, String @var{msg})
+Print an error message using the @code{yyerror} method of the scanner
+instance in use. The @code{Location} and @code{Position} parameters are
+available only if location tracking is active.
+@end deftypemethod
+
@deftypemethod {YYParser} {boolean} recovering ()
During the syntactic analysis, return @code{true} if recovering
from a syntax error.
or nonzero, full tracing.
@end deftypemethod
+@deftypecv {Constant} {YYParser} {String} {bisonVersion}
+@deftypecvx {Constant} {YYParser} {String} {bisonSkeleton}
+Identify the Bison version and skeleton used to generate this parser.
+@end deftypecv
+
@node Java Scanner Interface
@subsection Java Scanner Interface
There are two possible ways to interface a Bison-generated Java parser
with a scanner: the scanner may be defined by @code{%code lexer}, or
defined elsewhere. In either case, the scanner has to implement the
-@code{Lexer} inner interface of the parser class.
+@code{Lexer} inner interface of the parser class. This interface also
+contain constants for all user-defined token names and the predefined
+@code{EOF} token.
In the first case, the body of the scanner class is placed in
@code{%code lexer} blocks. If you want to pass parameters from the
value and location are saved and returned by the their methods in the
interface.
-Use @code{%define lex_throws} to specify any uncaught exceptions.
+Use @samp{%define lex_throws} to specify any uncaught exceptions.
Default is @code{java.io.IOException}.
@end deftypemethod
@deftypemethod {Lexer} {Object} getLVal ()
Return the semantic value of the last token that yylex returned.
-The return type can be changed using @code{%define stype
+The return type can be changed using @samp{%define stype
"@var{class-name}".}
@end deftypemethod
The following special constructs can be uses in Java actions.
Other analogous C action features are currently unavailable for Java.
-Use @code{%define throws} to specify any uncaught exceptions from parser
+Use @samp{%define throws} to specify any uncaught exceptions from parser
actions, and initial actions specified by @code{%initial-action}.
@defvar $@var{n}
@defvar $$
The semantic value for the grouping made by the current rule. As a
value, this is in the base type (@code{Object} or as specified by
-@code{%define stype}) as in not cast to the declared subtype because
+@samp{%define stype}) as in not cast to the declared subtype because
casts are not allowed on the left-hand side of Java assignments.
Use an explicit Java cast if the correct subtype is needed.
@xref{Java Semantic Values}.
@xref{Error Recovery}.
@end deftypefn
-@deftypefn {Function} {protected void} yyerror (String msg)
-@deftypefnx {Function} {protected void} yyerror (Position pos, String msg)
-@deftypefnx {Function} {protected void} yyerror (Location loc, String msg)
+@deftypefn {Function} {void} yyerror (String @var{msg})
+@deftypefnx {Function} {void} yyerror (Position @var{loc}, String @var{msg})
+@deftypefnx {Function} {void} yyerror (Location @var{loc}, String @var{msg})
Print an error message using the @code{yyerror} method of the scanner
-instance in use.
+instance in use. The @code{Location} and @code{Position} parameters are
+available only if location tracking is active.
@end deftypefn
@item @code{%code imports}
blocks are placed at the beginning of the Java source code. They may
include copyright notices. For a @code{package} declarations, it is
-suggested to use @code{%define package} instead.
+suggested to use @samp{%define package} instead.
@item unqualified @code{%code}
blocks are placed inside the parser class.
@deffn {Directive} %name-prefix "@var{prefix}"
The prefix of the parser class name @code{@var{prefix}Parser} if
-@code{%define parser_class_name} is not used. Default is @code{YY}.
+@samp{%define parser_class_name} is not used. Default is @code{YY}.
@xref{Java Bison Interface}.
@end deffn
@xref{Java Differences}.
@end deffn
+@deffn {Directive} {%code init} @{ @var{code} @dots{} @}
+Code inserted at the beginning of the parser constructor body.
+@xref{Java Parser Interface}.
+@end deffn
+
@deffn {Directive} {%code lexer} @{ @var{code} @dots{} @}
Code added to the body of a inner lexer class within the parser class.
@xref{Java Scanner Interface}.
@end deffn
@deffn {Directive} %@{ @var{code} @dots{} %@}
-Not supported. Use @code{%code import} instead.
+Not supported. Use @code{%code imports} instead.
@xref{Java Differences}.
@end deffn
@xref{Java Bison Interface}.
@end deffn
+@deffn {Directive} {%define annotations} "@var{annotations}"
+The Java annotations for the parser class. Default is none.
+@xref{Java Bison Interface}.
+@end deffn
+
@deffn {Directive} {%define extends} "@var{superclass}"
The superclass of the parser class. Default is none.
@xref{Java Bison Interface}.
@xref{Java Bison Interface}.
@end deffn
+@deffn {Directive} {%define init_throws} "@var{exceptions}"
+The exceptions thrown by @code{%code init} from the parser class
+constructor. Default is none.
+@xref{Java Parser Interface}.
+@end deffn
+
@deffn {Directive} {%define lex_throws} "@var{exceptions}"
The exceptions thrown by the @code{yylex} method of the lexer, a
comma-separated list. Default is @code{java.io.IOException}.
Grammar}.
@end deffn
+@deffn {Directive} %?@{@var{expression}@}
+Predicate actions. This is a type of action clause that may appear in
+rules. The expression is evaluated, and if false, causes a syntax error. In
+GLR parsers during nondeterministic operation,
+this silently causes an alternative parse to die. During deterministic
+operation, it is the same as the effect of YYERROR.
+@xref{Semantic Predicates}.
+
+This feature is experimental.
+More user feedback will help to determine whether it should become a permanent
+feature.
+@end deffn
+
@deffn {Construct} /* @dots{} */
@deffnx {Construct} // @dots{}
Comments, as in C/C++.
@end deffn
@deffn {Directive} %error-verbose
-Bison declaration to request verbose, specific error message strings
-when @code{yyerror} is called. @xref{Error Reporting}.
+An obsolete directive standing for @samp{%define parse.error verbose}
+(@pxref{Error Reporting, ,The Error Reporting Function @code{yyerror}}).
@end deffn
@deffn {Directive} %file-prefix "@var{prefix}"
@end deffn
@deffn {Directive} %left
-Bison declaration to assign left associativity to token(s).
+Bison declaration to assign precedence and left associativity to token(s).
@xref{Precedence Decl, ,Operator Precedence}.
@end deffn
-@deffn {Directive} %lex-param @{@var{argument-declaration}@}
-Bison declaration to specifying an additional parameter that
+@deffn {Directive} %lex-param @{@var{argument-declaration}@} @dots{}
+Bison declaration to specifying additional arguments that
@code{yylex} should accept. @xref{Pure Calling,, Calling Conventions
for Pure Parsers}.
@end deffn
@end deffn
@deffn {Directive} %nonassoc
-Bison declaration to assign nonassociativity to token(s).
+Bison declaration to assign precedence and nonassociativity to token(s).
@xref{Precedence Decl, ,Operator Precedence}.
@end deffn
@xref{Decl Summary}.
@end deffn
-@deffn {Directive} %parse-param @{@var{argument-declaration}@}
-Bison declaration to specifying an additional parameter that
-@code{yyparse} should accept. @xref{Parser Function,, The Parser
-Function @code{yyparse}}.
+@deffn {Directive} %param @{@var{argument-declaration}@} @dots{}
+Bison declaration to specify additional arguments that both
+@code{yylex} and @code{yyparse} should accept. @xref{Parser Function,, The
+Parser Function @code{yyparse}}.
+@end deffn
+
+@deffn {Directive} %parse-param @{@var{argument-declaration}@} @dots{}
+Bison declaration to specify additional arguments that @code{yyparse}
+should accept. @xref{Parser Function,, The Parser Function @code{yyparse}}.
@end deffn
@deffn {Directive} %prec
@xref{Contextual Precedence, ,Context-Dependent Precedence}.
@end deffn
+@deffn {Directive} %precedence
+Bison declaration to assign precedence to token(s), but no associativity
+@xref{Precedence Decl, ,Operator Precedence}.
+@end deffn
+
@deffn {Directive} %pure-parser
-Deprecated version of @code{%define api.pure} (@pxref{%define
+Deprecated version of @samp{%define api.pure} (@pxref{%define
Summary,,api.pure}), for which Bison is more careful to warn about
unreasonable usage.
@end deffn
@end deffn
@deffn {Directive} %right
-Bison declaration to assign right associativity to token(s).
+Bison declaration to assign precedence and right associativity to token(s).
@xref{Precedence Decl, ,Operator Precedence}.
@end deffn
@deffn {Function} yyerror
User-supplied function to be called by @code{yyparse} on error.
-@xref{Error Reporting, ,The Error
-Reporting Function @code{yyerror}}.
+@xref{Error Reporting, ,The Error Reporting Function @code{yyerror}}.
@end deffn
@deffn {Macro} YYERROR_VERBOSE
-An obsolete macro that you define with @code{#define} in the prologue
-to request verbose, specific error message strings
-when @code{yyerror} is called. It doesn't matter what definition you
-use for @code{YYERROR_VERBOSE}, just whether you define it.
-Supported by the C skeletons only; using
-@code{%error-verbose} is preferred. @xref{Error Reporting}.
+An obsolete macro used in the @file{yacc.c} skeleton, that you define
+with @code{#define} in the prologue to request verbose, specific error
+message strings when @code{yyerror} is called. It doesn't matter what
+definition you use for @code{YYERROR_VERBOSE}, just whether you define
+it. Using @samp{%define parse.error verbose} is preferred
+(@pxref{Error Reporting, ,The Error Reporting Function @code{yyerror}}).
@end deffn
@deffn {Macro} YYFPRINTF
More user feedback will help to stabilize it.)
@end deffn
-@deffn {Macro} YYPARSE_PARAM
-An obsolete macro for specifying the name of a parameter that
-@code{yyparse} should accept. The use of this macro is deprecated, and
-is supported only for Yacc like parsers. @xref{Pure Calling,, Calling
-Conventions for Pure Parsers}.
-@end deffn
-
@deffn {Macro} YYRECOVERING
The expression @code{YYRECOVERING ()} yields 1 when the parser
is recovering from a syntax error, and 0 otherwise.
is adapted from the node
.B Invocation
in the
-.B bison.texinfo
+.B bison.texi
manual, which should be taken as authoritative.
.PP
.I Bison
.BR \-\-file-prefix ,
connect the option name and the argument with
.BR = .
+
+[see also]
+.BR lex (1),
+.BR flex (1),
+.BR yacc (1).
+++ /dev/null
-[see also]
-.BR lex (1),
-.BR flex (1),
-.BR yacc (1).
--- /dev/null
+## Copyright (C) 2001-2003, 2005-2012 Free Software Foundation, Inc.
+
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AM_MAKEINFOFLAGS = --no-split
+info_TEXINFOS = doc/bison.texi
+doc_bison_TEXINFOS = \
+ $(CROSS_OPTIONS_TEXI) \
+ doc/fdl.texi \
+ doc/gpl-3.0.texi
+
+TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d
+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-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
+
+doc/bison.dvi: $(FIGS_DOT:.dot=.eps)
+doc/bison.html: $(FIGS_DOT:.dot=.png)
+doc/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: 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
-/Makefile
-/Makefile.in
/bench.pl
+++ /dev/null
-## Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-nodist_noinst_SCRIPTS = bench.pl
# You should have received a copy of the GNU General Public License
# 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
+ | #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 Benchmark qw (:all);
+##################################################################
+
+=head1 VARIABLES
+
+=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) = @_;
+ print STDERR $message
+ if $level <= $verbose;
+}
+
+
+######################################################################
+
+=item C<directives($bench, @directive)>
+
+Format the list of directives for Bison for bench named C<$bench>.
-sub triangular_grammar ($$$)
+=cut
+
+sub directives($@)
{
- my ($base, $max, $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"
or die;
print $out <<EOF;
%error-verbose
-%debug
%{
#include <stdio.h>
#include <stdlib.h>
static int yylex (void);
static void yyerror (const char *msg);
%}
+$directives
%union
{
int val;
{
use Text::Wrap;
print $out wrap ("| ", " ",
- (map { "\"$_\"" } (1 .. $size)),
- " END \n"),
+ (map { "\"$_\"" } (1 .. $size)),
+ " END \n"),
" { \$\$ = $size; }\n";
};
print $out ";\n";
int
main (void)
{
+#if YYDEBUG
yydebug = !!getenv ("YYDEBUG");
+#endif
return yyparse ();
}
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 ($$)
{
my ($base, $max) = @_;
##################################################################
-sub calc_grammar ($$$)
+=item C<generate_grammar_calc ($base, $max, @directive)>
+
+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, $directives) = @_;
+ my ($base, $max, @directive) = @_;
+ 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"
or die;
static int global_count = 0;
%}
-/* Exercise %union. */
$directives
%error-verbose
+/* Exercise %union. */
%union
{
semantic_value ival;
%token <ival> NUM "number"
%type <ival> exp
-%nonassoc '=' /* comparison */
+%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
int count = 0;
int status;
+#if YYDEBUG
+ yydebug = !!getenv ("YYDEBUG");
+#endif
+
input = fopen ("calc.input", "r");
if (!input)
{
##################################################################
-sub compile ($)
+=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) = @_;
- system ("$bison $base.y -o $base.c") == 0
- or die;
- system ("$cc -o $base $base.c") == 0
+ 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>
}
-sub bench_grammar ($)
+%code // *.c
{
- my ($gram) = @_;
- my %test =
+#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* yylval,
+ yy::parser::location_type* yylloc);
+#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* yylval,
+ yy::parser::location_type* yylloc)
+#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
+ *yylloc = 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
+ yylval->build(stage);
+# elif USE_VARIANTS
+ yylval->build<int>() = stage;
+# else
+ yylval->ival = stage;
+# endif
+ *yylloc = 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
+ yylval->build(std::string("A string."));
+# elif USE_VARIANTS
+ yylval->build<std::string>() = std::string("A string.");
+# else
+ yylval->sval = new std::string("A string.");
+# endif
+ *yylloc = 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 =
(
- "pull-impure" => '',
- "pull-pure" => '%define api.pure',
- "push-impure" => '%define api.push-pull "both"',
- "push-pure" => '%define api.push-pull "both" %define api.pure',
+ "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 ($)
+{
+ my ($base) = @_;
+ my $language = `sed -ne '/%language "\\(.*\\)"/{s//\\1/;p;q;}' $base.y`;
+ chomp $language;
+
+ my $compiler = $language eq 'C++' ? $cxx : $cc;
+
+ run "$bison $base.y -o $base.c";
+ run "$compiler -o $base $cflags $base.c";
+}
+
+######################################################################
+
+=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) = @_;
+ use Benchmark qw (:all :hireswallclock);
+
+ my @directive = parse (@token);
+
+ # Set up the benches as expected by timethese.
my %bench;
- while (my ($name, $directives) = each %test)
+ # A counter of directive sets.
+ my $count = 1;
+ for my $d (@directive)
+ {
+ $bench{$count} = $d;
+ printf " %2d. %s\n", $count, join (' ', split ("\n", $d));
+ $count++;
+ };
+
+ # For each bench, capture the size.
+ my %size;
+
+ while (my ($name, $directives) = each %bench)
{
- print STDERR "$name\n";
- my $generator = "$gram" . "_grammar";
- &$generator ($name, 200, $directives);
+ generate_grammar ($grammar, $name, $directives);
+ # Compile the executable.
compile ($name);
$bench{$name} = "system ('./$name');";
+ chop($size{$name} = `wc -c <$name`);
}
- print "$gram:\n";
- my $res = timethese (50, \%bench, 'nop');
+ # Run the benches.
+ #
+ # 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');
+
+ # 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);
-bench_grammar ('calc');
+######################################################################
+
+=item C<bench_push_parser ()>
+
+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;
+ }
+ 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.
## Local Variables:
--- /dev/null
+## Copyright (C) 2006, 2008-2012 Free Software Foundation, Inc.
+
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+nodist_noinst_SCRIPTS = etc/bench.pl
+++ /dev/null
-Makefile
-Makefile.in
+++ /dev/null
-/Makefile
-/Makefile.in
+++ /dev/null
-## Process this file with automake to produce Makefile.in -*-Makefile-*-
-## Copyright (C) 2005, 2009-2012 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-if BISON_CXX_WORKS
-SUBDIRS = calc++
-endif
-
-dist_noinst_SCRIPTS = extexi
-/*.cc
-/*.hh
-/*.ll
/*.o
-/*.output
-/*.stamp
/*.tmp
-/*.yy
/.deps
-/Makefile
-/Makefile.in
/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.stamp
+/location.hh
+/position.hh
+/stack.hh
+++ /dev/null
-## Process this file with automake to produce Makefile.in -*-Makefile-*-
-## Copyright (C) 2005-2006, 2009-2012 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-## ------------------------------------- ##
-## 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)
--- /dev/null
+#! /bin/sh
+
+# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+cat >input <<EOF
+toto := 1
+toto
+EOF
+run 0 1 -s
+
+
+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 ''
--- /dev/null
+# Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+## ------------------- ##
+## 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++
+dist_TESTS += examples/calc++/calc++.test
+endif
+++ /dev/null
-#! /bin/sh
-
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-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
-toto := 1
-toto
-EOF
-./calc++ -s input
-
-rm input
--- /dev/null
+// 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"
-# Extract all examples from the manual source. -*- AWK -*-
+#! /usr/bin/perl -w
+# Extract all examples from the manual source.
# This file is part of GNU Bison
# You should have received a copy of the GNU General Public License
# 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]
-BEGIN {
- if (!output_dir)
- output_dir = ".";
- for (argc = 1; argc < ARGC; ++argc)
- if (ARGV[argc] == "--")
- break;
- for (i = argc + 1; i < ARGC; ++i)
- file_wanted[ARGV[i]] = 1;
- ARGC = argc;
-}
-
-/^@node / {
- if (seq > 0)
- print "AT_CLEANUP";
- split ($0, tmp, ",");
- node = substr(tmp[1], 7);
- seq = 0;
+# Look for @example environments preceded with lines such as:
+#
+# @comment file calc.y
+# or
+# @comment file calc.y: 3
+#
+# and output their content in that file (calc.y). When numbers are
+# provided, use them to decide the output order (block numbered 1 is
+# 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.*//;
+ $_;
}
-/^@comment file: / {
- if (!file_wanted[$3])
- message("ignoring " $3);
- else
+# Print messages only once.
+my %msg;
+sub message($)
+{
+ my ($msg) = @_;
+ if (! $msg{$msg})
{
- message("extracting " $3);
- file = $3;
+ print STDERR "extexi: $msg\n";
+ $msg{$msg} = 1;
}
}
-/^@example$/, /^@end example$/ {
- if (!file)
- next;
-
- if ($0 ~ /^@example$/)
+# basename => full file name for files we should extract.
+my %file_wanted;
+
+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>)
{
- input = files_output[file] ? "\n" : "";
-
- # FNR is starting at 0 instead of 1, and
- # #line report the line number of the *next* line.
- # => + 2.
- # Note that recent Bison support it, but not Flex.
- if (file ~ /\.[chy]*$/)
- input = "#line " (FNR + 1) " \"" FILENAME "\"\n";
- next;
+ if (/^\@comment file: ([^:\n]+)(?::\s*(\d+))?$/)
+ {
+ my $f = $1;
+ $block = $2 || 1;
+ if ($file_wanted{$f})
+ {
+ $file = $file_wanted{$f};
+ message(" GEN $file");
+ }
+ else
+ {
+ message("SKIP $f");
+ }
+ }
+ elsif ($file && /^\@(small)?example$/ .. /^\@end (small)?example$/)
+ {
+ if (/^\@(small)?example$/)
+ {
+ # Bison supports synclines, but not Flex.
+ $input .= sprintf ("#line %s \"$in\"\n", $. + 1)
+ if $file =~ /\.[chy]*$/;
+ next;
+ }
+ elsif (/^\@end (small)?example$/)
+ {
+ die "no contents: $file"
+ if $input eq "";
+
+ $file{$file}{$block} .= normalize($input);
+ $file = $input = undef;
+ ++$block;
+ }
+ else
+ {
+ $input .= $_;
+ }
+ }
}
- if ($0 ~ /^@end example$/)
+ # Output the files.
+ for my $file (keys %file)
{
- if (input == "")
- fatal("no contents: " file);
-
- input = normalize(input);
# No spurious end of line: use printf.
- if (files_output[file])
- # The parens around the output file seem to be required
- # by awk on Mac OS X Tiger (darwin 8.4.6).
- printf ("%s", input) >> (output_dir "/" file);
- else
- printf ("%s", input) > (output_dir "/" file);
- close (output_dir "/" file);
- files_output[file] = 1;
-
- file = input = "";
- next;
+ my $o = new IO::File(">$file")
+ or die "$file: cannot create: $?";
+ print $o $file{$file}{$_}
+ for sort keys %{$file{$file}};
}
-
- 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)
+my @input;
+my $seen_dash = 0;
+for my $arg (@ARGV)
+{
+ if ($arg eq '--')
{
- 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";
+ $seen_dash = 1;
}
- return res;
-}
-
-
-function message(msg) {
- if (! message_printed[msg])
+ elsif ($seen_dash)
{
- print "extexi: " msg > "/dev/stderr";
- message_printed[msg] = 1;
+ use File::Basename;
+ $file_wanted{basename($arg)} = $arg;
+ }
+ else
+ {
+ push @input, $arg;
}
}
-
-function fatal(msg) {
- message(msg);
- exit 1
-}
+process $_
+ foreach @input;
+
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
--- /dev/null
+# Copyright (C) 2005, 2008-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+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
--- /dev/null
+/*.o
+/*.tmp
+/.deps
+/calc.h
+/mfcalc
+/mfcalc.c
+/mfcalc.exe
+/mfcalc.h
+/mfcalc.output
+/mfcalc.stamp
+/mfcalc.y
--- /dev/null
+# Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+## -------------------- ##
+## 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
--- /dev/null
+#! /bin/sh
+
+# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+cat >input <<EOF
+1+2*3
+EOF
+run 0 7
+
+cat >input <<EOF
+(1+2) * 3
+EOF
+run 0 9
+run 0 9 -p
--- /dev/null
+/calc.h
+/rpcalc.c
+/rpcalc.h
+/rpcalc.output
+/rpcalc.stamp
+/rpcalc.y
--- /dev/null
+# Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+## -------------------- ##
+## 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
--- /dev/null
+#! /bin/sh
+
+# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+cat >input <<EOF
+1 2 3 * +
+EOF
+run 0 7
+
+cat >input <<EOF
+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
--- /dev/null
+#! /bin/sh
+
+# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+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
+ $prog "$@" - <input >out_eff
+ # Effective exit status.
+ local 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
--- /dev/null
+/*
+ Copyright (C) 2008-2012 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+%debug
+%skeleton "lalr1.cc"
+%defines
+%define api.token.constructor
+%define parse.assert
+%define variant
+%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 { debug_stream () << $$; }
+ <int> <::std::string> <::std::list<std::string>>;
+%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:
-Subproject commit c457e702babb79026dd57036e0652e141f58f72d
+Subproject commit daf7f8c02242c535d596231e2f655109b97fa2bc
/close.c
/closeout.c
/closeout.h
+/concat-filename.c
+/concat-filename.h
/config.charset
/config.h
/config.in.h
/fd-hook.h
/fd-safer-flag.c
/fd-safer.c
+/filename.h
/float+.h
/float.c
/float.h
/isnanf.c
/isnanl-nolibm.h
/isnanl.c
-/iswblank.c
/itold.c
/ldexpl.c
/localcharset.c
/malloc.c
/math.h
/math.in.h
-/mbchar.c
-/mbchar.h
/mbrtowc.c
-/mbschr.c
/mbsinit.c
-/mbsrchr.c
/mbswidth.c
/mbswidth.h
-/mbuiter.h
/memchr.c
/memchr.valgrind
/msvc-inval.c
/nonblocking.h
/obstack.c
/obstack.h
+/obstack_printf.c
/open.c
/pathmax.h
/perror.c
/stripslash.c
/strndup.c
/strnlen.c
-/strnlen1.c
-/strnlen1.h
/strtol.c
/strtoul.c
/strverscmp.c
/sys_socket.in.h
/sys_stat.h
/sys_stat.in.h
+/sys_types.in.h
/sys_wait.h
/sys_wait.in.h
/sysexits.in.h
/xalloc-die.c
/xalloc-oversized.h
/xalloc.h
+/xconcat-filename.c
/xmalloc.c
+/xmemdup0.c
+/xmemdup0.h
/xsize.h
/xstrndup.c
/xstrndup.h
-/xmemdup0.c
-/xmemdup0.h
-/sys_types.in.h
-/obstack_printf.c
/binary-io.c
-/mbuiter.c
/xsize.c
-/bitrotate.c
-/math.c
-/sig-handler.c
-/stdio.c
-/unistd.c
-/wctype-h.c
/getdelim.c
/getline.c
+++ /dev/null
-# Make bison/lib.
-
-# Copyright (C) 2001-2004, 2006, 2008-2012 Free Software Foundation,
-# Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-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
found and with *NEXT indicating where search stopped. */
static bitset_bindex
abitset_small_list (bitset src, bitset_bindex *list,
- bitset_bindex num, bitset_bindex *next)
+ bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex count;
if (num >= BITSET_WORD_BITS)
{
for (count = 0; word; bitno++)
- {
- if (word & 1)
- list[count++] = bitno;
- word >>= 1;
- }
+ {
+ if (word & 1)
+ list[count++] = bitno;
+ word >>= 1;
+ }
}
else
{
for (count = 0; word; bitno++)
- {
- if (word & 1)
- {
- list[count++] = bitno;
- if (count >= num)
- {
- bitno++;
- break;
- }
- }
- word >>= 1;
- }
+ {
+ if (word & 1)
+ {
+ list[count++] = bitno;
+ if (count >= num)
+ {
+ bitno++;
+ break;
+ }
+ }
+ word >>= 1;
+ }
}
*next = bitno;
/* Reset bit BITNO in bitset DST. */
static void
abitset_reset (bitset dst ATTRIBUTE_UNUSED,
- bitset_bindex bitno ATTRIBUTE_UNUSED)
+ bitset_bindex bitno ATTRIBUTE_UNUSED)
{
/* This should never occur for abitsets since we should always hit
the cache. It is likely someone is trying to access outside the
/* Test bit BITNO in bitset SRC. */
static bool
abitset_test (bitset src ATTRIBUTE_UNUSED,
- bitset_bindex bitno ATTRIBUTE_UNUSED)
+ bitset_bindex bitno ATTRIBUTE_UNUSED)
{
/* This should never occur for abitsets since we should always
hit the cache. */
stopped. */
static bitset_bindex
abitset_list_reverse (bitset src, bitset_bindex *list,
- bitset_bindex num, bitset_bindex *next)
+ bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex rbitno;
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
for (; word; bitcnt--)
- {
- if (word & BITSET_MSB)
- {
- list[count++] = bitoff + bitcnt;
- if (count >= num)
- {
- *next = n_bits - (bitoff + bitcnt);
- return count;
- }
- }
- word <<= 1;
- }
+ {
+ if (word & BITSET_MSB)
+ {
+ list[count++] = bitoff + bitcnt;
+ if (count >= num)
+ {
+ *next = n_bits - (bitoff + bitcnt);
+ return count;
+ }
+ }
+ word <<= 1;
+ }
bitoff -= BITSET_WORD_BITS;
bitcnt = BITSET_WORD_BITS - 1;
}
found and with *NEXT indicating where search stopped. */
static bitset_bindex
abitset_list (bitset src, bitset_bindex *list,
- bitset_bindex num, bitset_bindex *next)
+ bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex count;
{
/* Many bitsets are zero, so make this common case fast. */
for (windex = 0; windex < size && !srcp[windex]; windex++)
- continue;
+ continue;
if (windex >= size)
- return 0;
+ return 0;
/* If num is 1, we could speed things up with a binary search
- of the current word. */
+ of the current word. */
bitoff = windex * BITSET_WORD_BITS;
}
else
{
if (bitno >= BITSET_SIZE_ (src))
- return 0;
+ return 0;
windex = bitno / BITSET_WORD_BITS;
bitno = bitno % BITSET_WORD_BITS;
if (bitno)
- {
- /* Handle the case where we start within a word.
- Most often, this is executed with large bitsets
- with many set bits where we filled the array
- on the previous call to this function. */
-
- bitoff = windex * BITSET_WORD_BITS;
- word = srcp[windex] >> bitno;
- for (bitno = bitoff + bitno; word; bitno++)
- {
- if (word & 1)
- {
- list[count++] = bitno;
- if (count >= num)
- {
- *next = bitno + 1;
- return count;
- }
- }
- word >>= 1;
- }
- windex++;
- }
+ {
+ /* Handle the case where we start within a word.
+ Most often, this is executed with large bitsets
+ with many set bits where we filled the array
+ on the previous call to this function. */
+
+ bitoff = windex * BITSET_WORD_BITS;
+ word = srcp[windex] >> bitno;
+ for (bitno = bitoff + bitno; word; bitno++)
+ {
+ if (word & 1)
+ {
+ list[count++] = bitno;
+ if (count >= num)
+ {
+ *next = bitno + 1;
+ return count;
+ }
+ }
+ word >>= 1;
+ }
+ windex++;
+ }
bitoff = windex * BITSET_WORD_BITS;
}
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
{
if (!(word = srcp[windex]))
- continue;
+ continue;
if ((count + BITSET_WORD_BITS) < num)
- {
- for (bitno = bitoff; word; bitno++)
- {
- if (word & 1)
- list[count++] = bitno;
- word >>= 1;
- }
- }
+ {
+ for (bitno = bitoff; word; bitno++)
+ {
+ if (word & 1)
+ list[count++] = bitno;
+ word >>= 1;
+ }
+ }
else
- {
- for (bitno = bitoff; word; bitno++)
- {
- if (word & 1)
- {
- list[count++] = bitno;
- if (count >= num)
- {
- *next = bitno + 1;
- return count;
- }
- }
- word >>= 1;
- }
- }
+ {
+ for (bitno = bitoff; word; bitno++)
+ {
+ if (word & 1)
+ {
+ list[count++] = bitno;
+ if (count >= num)
+ {
+ *next = bitno + 1;
+ return count;
+ }
+ }
+ word >>= 1;
+ }
+ }
}
*next = bitoff;
for (i = 0; i < size; i++)
if (*srcp++ != *dstp++)
- return false;
+ return false;
return true;
}
for (i = 0; i < size; i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
- return false;
+ return false;
return true;
}
for (i = 0; i < size; i++)
if (*srcp++ & *dstp++)
- return false;
+ return false;
return true;
}
bitset_word tmp = *src1p++ & *src2p++;
if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
+ {
+ changed = true;
+ *dstp = tmp;
+ }
}
return changed;
}
bitset_word tmp = *src1p++ & ~(*src2p++);
if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
+ {
+ changed = true;
+ *dstp = tmp;
+ }
}
return changed;
}
bitset_word tmp = *src1p++ | *src2p++;
if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
+ {
+ changed = true;
+ *dstp = tmp;
+ }
}
return changed;
}
bitset_word tmp = *src1p++ ^ *src2p++;
if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
+ {
+ changed = true;
+ *dstp = tmp;
+ }
}
return changed;
}
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
+ {
+ changed = true;
+ *dstp = tmp;
+ }
}
return changed;
}
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
+ {
+ changed = true;
+ *dstp = tmp;
+ }
}
return changed;
}
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
+ {
+ changed = true;
+ *dstp = tmp;
+ }
}
return changed;
}
Memory for bit array and bitset structure allocated
contiguously.
BITSET_LIST: Linked list of arrays of bits (variable size, least storage
- for large very sparse sets).
+ for large very sparse sets).
BITSET_TABLE: Expandable table of pointers to arrays of bits
- (variable size, less storage for large sparse sets).
+ (variable size, less storage for large sparse sets).
Faster than BITSET_LIST for random access.
BITSET_VARRAY: Variable array of bits (variable size, fast for
dense bitsets).
statistics and/or better run-time checking.
*/
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VARRAY,
- BITSET_TYPE_NUM, BITSET_STATS};
+ BITSET_TYPE_NUM, BITSET_STATS};
#define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset", "vbitset"}
extern const char * const bitset_type_names[];
#define BITSET_LIST_SIZE 1024
enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
- BITSET_OP_COPY, BITSET_OP_NOT,
- BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P,
- BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P,
- BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
- BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR};
+ BITSET_OP_COPY, BITSET_OP_NOT,
+ BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P,
+ BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P,
+ BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
+ BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR};
struct bbitset_struct
{
const struct bitset_vtable *vtable;
- bitset_windex cindex; /* Cache word index. */
- bitset_windex csize; /* Cache size in words. */
- bitset_word *cdata; /* Cache data pointer. */
- bitset_bindex n_bits; /* Number of bits. */
+ bitset_windex cindex; /* Cache word index. */
+ bitset_windex csize; /* Cache size in words. */
+ bitset_word *cdata; /* Cache data pointer. */
+ bitset_bindex n_bits; /* Number of bits. */
/* Perhaps we could sacrifice another word to indicate
that the bitset is known to be zero, that a bit has been set
in the cache, and that a bit has been cleared in the cache.
bool (*or_and_cmp) (bitset, bitset, bitset, bitset);
bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex,
- bitset_bindex *);
+ bitset_bindex *);
bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex,
- bitset_bindex *);
+ bitset_bindex *);
void (*free) (bitset);
enum bitset_type type;
};
/* Create a bitset of N_BITS of type TYPE. */
bitset
bitset_obstack_alloc (struct obstack *bobstack,
- bitset_bindex n_bits, enum bitset_type type)
+ bitset_bindex n_bits, enum bitset_type type)
{
size_t bytes;
bitset bset;
if (verbose)
fprintf (file, "n_bits = %lu, set = {",
- (unsigned long int) bitset_size (bset));
+ (unsigned long int) bitset_size (bset));
pos = 30;
BITSET_FOR_EACH (iter, bset, i, 0)
{
if (pos > 70)
{
- fprintf (file, "\n");
- pos = 0;
+ fprintf (file, "\n");
+ pos = 0;
}
fprintf (file, "%lu ", (unsigned long int) i);
four operand operations. */
static inline bool
bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
- enum bitset_ops op)
+ enum bitset_ops op)
{
bool changed = false;
bool stats_enabled_save;
/* Attributes used to select a bitset implementation. */
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
- BITSET_VARIABLE = 2, /* Bitset size variable. */
- BITSET_DENSE = 4, /* Bitset dense. */
- BITSET_SPARSE = 8, /* Bitset sparse. */
- BITSET_FRUGAL = 16, /* Prefer most compact. */
- BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
+ BITSET_VARIABLE = 2, /* Bitset size variable. */
+ BITSET_DENSE = 4, /* Bitset dense. */
+ BITSET_SPARSE = 8, /* Bitset sparse. */
+ BITSET_FRUGAL = 16, /* Prefer most compact. */
+ BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
typedef unsigned int bitset_attrs;
{
/* This must be the first member of every other structure that is a
member of this union. */
- struct bbitset_struct b; /* Base bitset data. */
+ struct bbitset_struct b; /* Base bitset data. */
struct abitset_struct
{
struct bbitset_struct b;
- bitset_word words[1]; /* The array of bits. */
+ bitset_word words[1]; /* The array of bits. */
} a;
struct ebitset_struct
{
struct bbitset_struct b;
- bitset_windex size; /* Number of elements. */
- struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
+ bitset_windex size; /* Number of elements. */
+ struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
} e;
struct lbitset_struct
{
struct bbitset_struct b;
- struct lbitset_elt_struct *head; /* First element in linked list. */
- struct lbitset_elt_struct *tail; /* Last element in linked list. */
+ struct lbitset_elt_struct *head; /* First element in linked list. */
+ struct lbitset_elt_struct *tail; /* Last element in linked list. */
} l;
struct bitset_stats_struct
struct vbitset_struct
{
struct bbitset_struct b;
- bitset_windex size; /* Allocated size of array. */
+ bitset_windex size; /* Allocated size of array. */
} v;
};
/* Create a bitset of desired type and size using an obstack. The
bitset is zeroed. */
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
- bitset_bindex, enum bitset_type);
+ bitset_bindex, enum bitset_type);
/* Free bitset allocated on obstack. */
extern void bitset_obstack_free (bitset);
printf ("%lu ", (unsigned long int) i);
};
*/
-#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
- for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
- (ITER.num == BITSET_LIST_SIZE) \
- && (ITER.num = bitset_list (BSET, ITER.list, \
- BITSET_LIST_SIZE, &ITER.next));) \
- for (ITER.i = 0; \
- ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
- ITER.i++)
+#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
+ for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
+ (ITER.num == BITSET_LIST_SIZE) \
+ && (ITER.num = bitset_list (BSET, ITER.list, \
+ BITSET_LIST_SIZE, &ITER.next));) \
+ for (ITER.i = 0; \
+ ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
+ ITER.i++)
/* Loop over all elements of BSET, in reverse order starting with
printf ("%lu ", (unsigned long int) i);
};
*/
-#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
- for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
- (ITER.num == BITSET_LIST_SIZE) \
- && (ITER.num = bitset_list_reverse (BSET, ITER.list, \
- BITSET_LIST_SIZE, &ITER.next));) \
- for (ITER.i = 0; \
- ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
- ITER.i++)
+#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
+ for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
+ (ITER.num == BITSET_LIST_SIZE) \
+ && (ITER.num = bitset_list_reverse (BSET, ITER.list, \
+ BITSET_LIST_SIZE, &ITER.next));) \
+ for (ITER.i = 0; \
+ ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
+ ITER.i++)
/* Define set operations in terms of logical operations. */
/* Accessor macros. */
-#define BITSET_STATS_ALLOCS_INC(TYPE) \
+#define BITSET_STATS_ALLOCS_INC(TYPE) \
bitset_stats_info->types[(TYPE)].allocs++
-#define BITSET_STATS_FREES_INC(BSET) \
+#define BITSET_STATS_FREES_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].frees++
-#define BITSET_STATS_SETS_INC(BSET) \
+#define BITSET_STATS_SETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].sets++
-#define BITSET_STATS_CACHE_SETS_INC(BSET) \
+#define BITSET_STATS_CACHE_SETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_sets++
-#define BITSET_STATS_RESETS_INC(BSET) \
+#define BITSET_STATS_RESETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].resets++
-#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
+#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_resets++
-#define BITSET_STATS_TESTS_INC(BSET) \
+#define BITSET_STATS_TESTS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].tests++
-#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
+#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_tests++
-#define BITSET_STATS_LISTS_INC(BSET) \
+#define BITSET_STATS_LISTS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].lists++
-#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
+#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_counts[(I)]++
-#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
+#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_sizes[(I)]++
-#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
+#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_density[(I)]++
/* Print a percentage histogram with message MSG to FILE. */
static void
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
- unsigned int n_bins, unsigned int *bins)
+ unsigned int n_bins, unsigned int *bins)
{
unsigned int i;
unsigned int total;
fprintf (file, "%s %s", name, msg);
for (i = 0; i < n_bins; i++)
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
- i * 100.0 / n_bins,
- (i + 1) * 100.0 / n_bins, bins[i],
- (100.0 * bins[i]) / total);
+ i * 100.0 / n_bins,
+ (i + 1) * 100.0 / n_bins, bins[i],
+ (100.0 * bins[i]) / total);
}
/* Print a log histogram with message MSG to FILE. */
static void
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
- unsigned int n_bins, unsigned int *bins)
+ unsigned int n_bins, unsigned int *bins)
{
unsigned int i;
unsigned int total;
fprintf (file, "%s %s", name, msg);
for (i = 0; i < 2; i++)
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
- max_width, i, bins[i], 100.0 * bins[i] / total);
+ max_width, i, bins[i], 100.0 * bins[i] / total);
for (; i < n_bins; i++)
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
- max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
- 1UL << (i - 1),
- (1UL << i) - 1,
- bins[i],
- (100.0 * bins[i]) / total);
+ max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
+ 1UL << (i - 1),
+ (1UL << i) - 1,
+ bins[i],
+ (100.0 * bins[i]) / total);
}
/* Print bitset statistics to FILE. */
static void
bitset_stats_print_1 (FILE *file, const char *name,
- struct bitset_type_info_struct *stats)
+ struct bitset_type_info_struct *stats)
{
if (!stats)
return;
fprintf (file, "%s:\n", name);
fprintf (file, _("%u bitset_allocs, %u freed (%.2f%%).\n"),
- stats->allocs, stats->frees,
- stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
+ stats->allocs, stats->frees,
+ stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
fprintf (file, _("%u bitset_sets, %u cached (%.2f%%)\n"),
- stats->sets, stats->cache_sets,
- stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
+ stats->sets, stats->cache_sets,
+ stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
fprintf (file, _("%u bitset_resets, %u cached (%.2f%%)\n"),
- stats->resets, stats->cache_resets,
- stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
+ stats->resets, stats->cache_resets,
+ stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
fprintf (file, _("%u bitset_tests, %u cached (%.2f%%)\n"),
- stats->tests, stats->cache_tests,
- stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
+ stats->tests, stats->cache_tests,
+ stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
fprintf (file, _("%u bitset_lists\n"), stats->lists);
bitset_log_histogram_print (file, name, _("count log histogram\n"),
- BITSET_LOG_COUNT_BINS, stats->list_counts);
+ BITSET_LOG_COUNT_BINS, stats->list_counts);
bitset_log_histogram_print (file, name, _("size log histogram\n"),
- BITSET_LOG_SIZE_BINS, stats->list_sizes);
+ BITSET_LOG_SIZE_BINS, stats->list_sizes);
bitset_percent_histogram_print (file, name, _("density histogram\n"),
- BITSET_DENSITY_BINS, stats->list_density);
+ BITSET_DENSITY_BINS, stats->list_density);
}
for (i = 0; i < BITSET_TYPE_NUM; i++)
bitset_stats_print_1 (file, bitset_type_names[i],
- &bitset_stats_info->types[i]);
+ &bitset_stats_info->types[i]);
}
if (offset < bset->b.csize)
{
bset->b.cdata[offset] &=
- ~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
+ ~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
BITSET_STATS_CACHE_RESETS_INC (bset);
}
else
static bitset_bindex
bitset_stats_list (bitset bset, bitset_bindex *list,
- bitset_bindex num, bitset_bindex *next)
+ bitset_bindex num, bitset_bindex *next)
{
bitset_bindex count;
bitset_bindex tmp;
static bitset_bindex
bitset_stats_list_reverse (bitset bset, bitset_bindex *list,
- bitset_bindex num, bitset_bindex *next)
+ bitset_bindex num, bitset_bindex *next)
{
return BITSET_LIST_REVERSE_ (bset->s.bset, list, num, next);
}
{
fprintf (out, "%2lu|", (unsigned long int) i);
for (j = 0; j < hsize; ++j)
- fputs (bitset_test (bset[i], j) ? "1" : " ", out);
+ fputs (bitset_test (bset[i], j) ? "1" : " ", out);
fputs ("|\n", out);
}
type TYPE. */
bitset *
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
- enum bitset_type type)
+ enum bitset_type type)
{
size_t vector_bytes;
size_t bytes;
for (i = 0; bsetv[i]; i++)
for (j = 0; bsetv[j]; j++)
if (bitset_test (bsetv[j], i))
- bitset_or (bsetv[j], bsetv[j], bsetv[i]);
+ bitset_or (bsetv[j], bsetv[j], bsetv[i]);
}
FILE. */
void
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
- bitsetv bsetv)
+ bitsetv bsetv)
{
bitset_windex i;
{
union
{
- bitset_word words[EBITSET_ELT_WORDS]; /* Bits that are set. */
+ bitset_word words[EBITSET_ELT_WORDS]; /* Bits that are set. */
struct ebitset_elt_struct *next;
}
u;
/* Obstack to allocate bitset elements from. */
static struct obstack ebitset_obstack;
static bool ebitset_obstack_init = false;
-static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
+static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
#define EBITSET_N_ELTS(N) (((N) + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS)
#define EBITSET_ELTS(BSET) ((BSET)->e.elts)
/* Disable bitset cache and mark BSET as being zero. */
#define EBITSET_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX, \
- (BSET)->b.cdata = 0)
+ (BSET)->b.cdata = 0)
#define EBITSET_CACHE_DISABLE(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX)
bitset_windex size;
/* The bitset needs to grow. If we already have enough memory
- allocated, then just zero what we need. */
+ allocated, then just zero what we need. */
if (newsize > EBITSET_ASIZE (src))
- {
- /* We need to allocate more memory. When oldsize is
- non-zero this means that we are changing the size, so
- grow the bitset 25% larger than requested to reduce
- number of reallocations. */
-
- if (oldsize == 0)
- size = newsize;
- else
- size = newsize + newsize / 4;
-
- EBITSET_ELTS (src)
- = realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
- EBITSET_ASIZE (src) = size;
- }
+ {
+ /* We need to allocate more memory. When oldsize is
+ non-zero this means that we are changing the size, so
+ grow the bitset 25% larger than requested to reduce
+ number of reallocations. */
+
+ if (oldsize == 0)
+ size = newsize;
+ else
+ size = newsize + newsize / 4;
+
+ EBITSET_ELTS (src)
+ = realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
+ EBITSET_ASIZE (src) = size;
+ }
memset (EBITSET_ELTS (src) + oldsize, 0,
- (newsize - oldsize) * sizeof (ebitset_elt *));
+ (newsize - oldsize) * sizeof (ebitset_elt *));
}
else
{
/* The bitset needs to shrink. There's no point deallocating
- the memory unless it is shrinking by a reasonable amount. */
+ the memory unless it is shrinking by a reasonable amount. */
if ((oldsize - newsize) >= oldsize / 2)
- {
- EBITSET_ELTS (src)
- = realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
- EBITSET_ASIZE (src) = newsize;
- }
+ {
+ EBITSET_ELTS (src)
+ = realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
+ EBITSET_ASIZE (src) = newsize;
+ }
/* Need to prune any excess bits. FIXME. */
}
else
{
if (!ebitset_obstack_init)
- {
- ebitset_obstack_init = true;
+ {
+ ebitset_obstack_init = true;
- /* Let particular systems override the size of a chunk. */
+ /* Let particular systems override the size of a chunk. */
#ifndef OBSTACK_CHUNK_SIZE
#define OBSTACK_CHUNK_SIZE 0
#endif
- /* Let them override the alloc and free routines too. */
+ /* Let them override the alloc and free routines too. */
#ifndef OBSTACK_CHUNK_ALLOC
#define OBSTACK_CHUNK_ALLOC xmalloc
#define __alignof__(type) 0
#endif
- obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
- __alignof__ (ebitset_elt),
- OBSTACK_CHUNK_ALLOC,
- OBSTACK_CHUNK_FREE);
- }
+ obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
+ __alignof__ (ebitset_elt),
+ OBSTACK_CHUNK_ALLOC,
+ OBSTACK_CHUNK_FREE);
+ }
/* Perhaps we should add a number of new elements to the free
- list. */
+ list. */
elt = (ebitset_elt *) obstack_alloc (&ebitset_obstack,
- sizeof (ebitset_elt));
+ sizeof (ebitset_elt));
}
return elt;
static ebitset_elt *
ebitset_elt_find (bitset bset, bitset_bindex bindex,
- enum ebitset_find_mode mode)
+ enum ebitset_find_mode mode)
{
ebitset_elt *elt;
bitset_windex size;
if (eindex < size)
{
if ((elt = elts[eindex]))
- {
- if (EBITSET_WORDS (elt) == bset->b.cdata)
- return elt;
+ {
+ if (EBITSET_WORDS (elt) == bset->b.cdata)
+ return elt;
- EBITSET_CACHE_SET (bset, eindex);
- return elt;
- }
+ EBITSET_CACHE_SET (bset, eindex);
+ return elt;
+ }
}
/* The element could not be found. */
case EBITSET_CREATE:
if (eindex >= size)
- ebitset_resize (bset, bindex);
+ ebitset_resize (bset, bindex);
/* Create a new element. */
elt = ebitset_elt_calloc ();
ebitset_elt *elt = elts[j];
if (elt)
- {
- if (ebitset_elt_zero_p (elt))
- {
- ebitset_elt_remove (bset, j);
- count++;
- }
- }
+ {
+ if (ebitset_elt_zero_p (elt))
+ {
+ ebitset_elt_remove (bset, j);
+ count++;
+ }
+ }
else
- count++;
+ count++;
}
count = j - count;
if (!count)
{
/* All the bits are zero. We could shrink the elts.
- For now just mark BSET as known to be zero. */
+ For now just mark BSET as known to be zero. */
EBITSET_ZERO_SET (bset);
}
else
ebitset_elt *elt = elts[j];
if (elt)
- ebitset_elt_remove (bset, j);
+ ebitset_elt_remove (bset, j);
}
/* All the bits are zero. We could shrink the elts.
ebitset_elt *delt = delts[j];
if (!selt && !delt)
- continue;
+ continue;
if ((selt && !delt) || (!selt && delt))
- return false;
+ return false;
for (i = 0; i < EBITSET_ELT_WORDS; i++)
- if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
- return false;
+ if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
+ return false;
}
return true;
}
ebitset_elt *selt = selts[j];
if (selt)
- {
- ebitset_elt *tmp;
-
- tmp = ebitset_elt_alloc ();
- delts[j] = tmp;
- memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
- sizeof (EBITSET_WORDS (selt)));
- }
+ {
+ ebitset_elt *tmp;
+
+ tmp = ebitset_elt_alloc ();
+ delts[j] = tmp;
+ memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
+ sizeof (EBITSET_WORDS (selt)));
+ }
}
EBITSET_NONZERO_SET (dst);
}
bitset_windex windex = bitno / BITSET_WORD_BITS;
return (ebitset_elt_find (src, bitno, EBITSET_FIND)
- && ((src->b.cdata[windex - src->b.cindex]
- >> (bitno % BITSET_WORD_BITS))
- & 1));
+ && ((src->b.cdata[windex - src->b.cindex]
+ >> (bitno % BITSET_WORD_BITS))
+ & 1));
}
found and with *NEXT indicating where search stopped. */
static bitset_bindex
ebitset_list_reverse (bitset bset, bitset_bindex *list,
- bitset_bindex num, bitset_bindex *next)
+ bitset_bindex num, bitset_bindex *next)
{
bitset_bindex n_bits;
bitset_bindex bitno;
elt = elts[eindex];
if (elt)
- {
- srcp = EBITSET_WORDS (elt);
-
- do
- {
- bitset_word word;
-
- word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
-
- for (; word; bcount--)
- {
- if (word & BITSET_MSB)
- {
- list[count++] = boffset + bcount;
- if (count >= num)
- {
- *next = n_bits - (boffset + bcount);
- return count;
- }
- }
- word <<= 1;
- }
- boffset -= BITSET_WORD_BITS;
- bcount = BITSET_WORD_BITS - 1;
- }
- while (woffset--);
- }
+ {
+ srcp = EBITSET_WORDS (elt);
+
+ do
+ {
+ bitset_word word;
+
+ word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
+
+ for (; word; bcount--)
+ {
+ if (word & BITSET_MSB)
+ {
+ list[count++] = boffset + bcount;
+ if (count >= num)
+ {
+ *next = n_bits - (boffset + bcount);
+ return count;
+ }
+ }
+ word <<= 1;
+ }
+ boffset -= BITSET_WORD_BITS;
+ bcount = BITSET_WORD_BITS - 1;
+ }
+ while (woffset--);
+ }
woffset = EBITSET_ELT_WORDS - 1;
boffset = eindex * EBITSET_ELT_BITS - BITSET_WORD_BITS;
found and with *NEXT indicating where search stopped. */
static bitset_bindex
ebitset_list (bitset bset, bitset_bindex *list,
- bitset_bindex num, bitset_bindex *next)
+ bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_windex windex;
elt = elts[eindex];
if (elt)
- {
- bitset_windex woffset;
- bitset_word *srcp = EBITSET_WORDS (elt);
-
- windex = bitno / BITSET_WORD_BITS;
- woffset = eindex * EBITSET_ELT_WORDS;
-
- for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
- {
- word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
-
- for (; word; bitno++)
- {
- if (word & 1)
- {
- list[count++] = bitno;
- if (count >= num)
- {
- *next = bitno + 1;
- return count;
- }
- }
- word >>= 1;
- }
- bitno = (windex + 1) * BITSET_WORD_BITS;
- }
- }
+ {
+ bitset_windex woffset;
+ bitset_word *srcp = EBITSET_WORDS (elt);
+
+ windex = bitno / BITSET_WORD_BITS;
+ woffset = eindex * EBITSET_ELT_WORDS;
+
+ for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
+ {
+ word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
+
+ for (; word; bitno++)
+ {
+ if (word & 1)
+ {
+ list[count++] = bitno;
+ if (count >= num)
+ {
+ *next = bitno + 1;
+ return count;
+ }
+ }
+ word >>= 1;
+ }
+ bitno = (windex + 1) * BITSET_WORD_BITS;
+ }
+ }
/* Skip to next element. */
eindex++;
elt = elts[eindex];
if (!elt)
- continue;
+ continue;
srcp = EBITSET_WORDS (elt);
windex = eindex * EBITSET_ELT_WORDS;
if ((count + EBITSET_ELT_BITS) < num)
- {
- /* The coast is clear, plant boot! */
+ {
+ /* The coast is clear, plant boot! */
#if EBITSET_ELT_WORDS == 2
- word = srcp[0];
- if (word)
- {
- if (!(word & 0xffff))
- {
- word >>= 16;
- bitno += 16;
- }
- if (!(word & 0xff))
- {
- word >>= 8;
- bitno += 8;
- }
- for (; word; bitno++)
- {
- if (word & 1)
- list[count++] = bitno;
- word >>= 1;
- }
- }
- windex++;
- bitno = windex * BITSET_WORD_BITS;
-
- word = srcp[1];
- if (word)
- {
- if (!(word & 0xffff))
- {
- word >>= 16;
- bitno += 16;
- }
- for (; word; bitno++)
- {
- if (word & 1)
- list[count++] = bitno;
- word >>= 1;
- }
- }
- windex++;
- bitno = windex * BITSET_WORD_BITS;
+ word = srcp[0];
+ if (word)
+ {
+ if (!(word & 0xffff))
+ {
+ word >>= 16;
+ bitno += 16;
+ }
+ if (!(word & 0xff))
+ {
+ word >>= 8;
+ bitno += 8;
+ }
+ for (; word; bitno++)
+ {
+ if (word & 1)
+ list[count++] = bitno;
+ word >>= 1;
+ }
+ }
+ windex++;
+ bitno = windex * BITSET_WORD_BITS;
+
+ word = srcp[1];
+ if (word)
+ {
+ if (!(word & 0xffff))
+ {
+ word >>= 16;
+ bitno += 16;
+ }
+ for (; word; bitno++)
+ {
+ if (word & 1)
+ list[count++] = bitno;
+ word >>= 1;
+ }
+ }
+ windex++;
+ bitno = windex * BITSET_WORD_BITS;
#else
- for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
- {
- bitno = windex * BITSET_WORD_BITS;
-
- word = srcp[i];
- if (word)
- {
- if (!(word & 0xffff))
- {
- word >>= 16;
- bitno += 16;
- }
- if (!(word & 0xff))
- {
- word >>= 8;
- bitno += 8;
- }
- for (; word; bitno++)
- {
- if (word & 1)
- list[count++] = bitno;
- word >>= 1;
- }
- }
- }
+ for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
+ {
+ bitno = windex * BITSET_WORD_BITS;
+
+ word = srcp[i];
+ if (word)
+ {
+ if (!(word & 0xffff))
+ {
+ word >>= 16;
+ bitno += 16;
+ }
+ if (!(word & 0xff))
+ {
+ word >>= 8;
+ bitno += 8;
+ }
+ for (; word; bitno++)
+ {
+ if (word & 1)
+ list[count++] = bitno;
+ word >>= 1;
+ }
+ }
+ }
#endif
- }
+ }
else
- {
- /* Tread more carefully since we need to check
- if array overflows. */
-
- for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
- {
- bitno = windex * BITSET_WORD_BITS;
-
- for (word = srcp[i]; word; bitno++)
- {
- if (word & 1)
- {
- list[count++] = bitno;
- if (count >= num)
- {
- *next = bitno + 1;
- return count;
- }
- }
- word >>= 1;
- }
- }
- }
+ {
+ /* Tread more carefully since we need to check
+ if array overflows. */
+
+ for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
+ {
+ bitno = windex * BITSET_WORD_BITS;
+
+ for (word = srcp[i]; word; bitno++)
+ {
+ if (word & 1)
+ {
+ list[count++] = bitno;
+ if (count >= num)
+ {
+ *next = bitno + 1;
+ return count;
+ }
+ }
+ word >>= 1;
+ }
+ }
+ }
}
*next = bitno;
elt = elts[eindex];
if (elt)
- {
- bitset_windex windex;
- bitset_windex woffset;
- bitset_word *srcp = EBITSET_WORDS (elt);
-
- windex = n_bits / BITSET_WORD_BITS;
- woffset = eindex * EBITSET_ELT_WORDS;
-
- srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
- windex++;
- for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
- srcp[windex - woffset] = 0;
- }
+ {
+ bitset_windex windex;
+ bitset_windex woffset;
+ bitset_word *srcp = EBITSET_WORDS (elt);
+
+ windex = n_bits / BITSET_WORD_BITS;
+ woffset = eindex * EBITSET_ELT_WORDS;
+
+ srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
+ windex++;
+ for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
+ srcp[windex - woffset] = 0;
+ }
}
}
for (j = 0; j < EBITSET_SIZE (dst); j++)
{
/* Create new elements if they cannot be found. Perhaps
- we should just add pointers to a ones element? */
+ we should just add pointers to a ones element? */
elt =
- ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
+ ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
}
EBITSET_NONZERO_SET (dst);
ebitset_elt *elt = elts[j];
if (elt)
- {
- if (!ebitset_elt_zero_p (elt))
- return 0;
- /* Do some weeding as we go. */
- ebitset_elt_remove (dst, j);
- }
+ {
+ if (!ebitset_elt_zero_p (elt))
+ return 0;
+ /* Do some weeding as we go. */
+ ebitset_elt_remove (dst, j);
+ }
}
/* All the bits are zero. We could shrink the elts.
for (j = 0; j < EBITSET_SIZE (src); j++)
{
/* Create new elements for dst if they cannot be found
- or substitute zero elements if src elements not found. */
+ or substitute zero elements if src elements not found. */
selt =
- ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
+ ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
delt =
- ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
+ ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
for (i = 0; i < EBITSET_ELT_WORDS; i++)
- EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
+ EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
}
EBITSET_NONZERO_SET (dst);
ebitset_unused_clear (dst);
delt = j < dsize ? delts[j] : 0;
if (!selt && !delt)
- continue;
+ continue;
if (!selt)
- selt = &ebitset_zero_elts[0];
+ selt = &ebitset_zero_elts[0];
if (!delt)
- delt = &ebitset_zero_elts[0];
+ delt = &ebitset_zero_elts[0];
for (i = 0; i < EBITSET_ELT_WORDS; i++)
- if (EBITSET_WORDS (delt)[i]
- != (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
- return false;
+ if (EBITSET_WORDS (delt)[i]
+ != (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
+ return false;
}
return true;
}
delt = j < dsize ? delts[j] : 0;
if (!selt || !delt)
- continue;
+ continue;
for (i = 0; i < EBITSET_ELT_WORDS; i++)
- if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
- return false;
+ if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
+ return false;
}
return true;
}
delt = j < dsize ? delts[j] : 0;
if (!selt1 && !selt2)
- {
- if (delt)
- {
- changed = true;
- ebitset_elt_remove (dst, j);
- }
- continue;
- }
+ {
+ if (delt)
+ {
+ changed = true;
+ ebitset_elt_remove (dst, j);
+ }
+ continue;
+ }
if (!selt1)
- selt1 = &ebitset_zero_elts[0];
+ selt1 = &ebitset_zero_elts[0];
if (!selt2)
- selt2 = &ebitset_zero_elts[0];
+ selt2 = &ebitset_zero_elts[0];
if (!delt)
- delt = ebitset_elt_calloc ();
+ delt = ebitset_elt_calloc ();
else
- delts[j] = 0;
+ delts[j] = 0;
srcp1 = EBITSET_WORDS (selt1);
srcp2 = EBITSET_WORDS (selt2);
dstp = EBITSET_WORDS (delt);
switch (op)
- {
- default:
- abort ();
-
- case BITSET_OP_OR:
- for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
- {
- bitset_word tmp = *srcp1++ | *srcp2++;
-
- if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
- }
- break;
-
- case BITSET_OP_AND:
- for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
- {
- bitset_word tmp = *srcp1++ & *srcp2++;
-
- if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
- }
- break;
-
- case BITSET_OP_XOR:
- for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
- {
- bitset_word tmp = *srcp1++ ^ *srcp2++;
-
- if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
- }
- break;
-
- case BITSET_OP_ANDN:
- for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
- {
- bitset_word tmp = *srcp1++ & ~(*srcp2++);
-
- if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
- }
- break;
- }
+ {
+ default:
+ abort ();
+
+ case BITSET_OP_OR:
+ for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
+ {
+ bitset_word tmp = *srcp1++ | *srcp2++;
+
+ if (*dstp != tmp)
+ {
+ changed = true;
+ *dstp = tmp;
+ }
+ }
+ break;
+
+ case BITSET_OP_AND:
+ for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
+ {
+ bitset_word tmp = *srcp1++ & *srcp2++;
+
+ if (*dstp != tmp)
+ {
+ changed = true;
+ *dstp = tmp;
+ }
+ }
+ break;
+
+ case BITSET_OP_XOR:
+ for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
+ {
+ bitset_word tmp = *srcp1++ ^ *srcp2++;
+
+ if (*dstp != tmp)
+ {
+ changed = true;
+ *dstp = tmp;
+ }
+ }
+ break;
+
+ case BITSET_OP_ANDN:
+ for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
+ {
+ bitset_word tmp = *srcp1++ & ~(*srcp2++);
+
+ if (*dstp != tmp)
+ {
+ changed = true;
+ *dstp = tmp;
+ }
+ }
+ break;
+ }
if (!ebitset_elt_zero_p (delt))
- {
- ebitset_elt_add (dst, delt, j);
- }
+ {
+ ebitset_elt_add (dst, delt, j);
+ }
else
- {
- ebitset_elt_free (delt);
- }
+ {
+ ebitset_elt_free (delt);
+ }
}
/* If we have elements of DST left over, free them all. */
delt = delts[j];
if (delt)
- ebitset_elt_remove (dst, j);
+ ebitset_elt_remove (dst, j);
}
EBITSET_NONZERO_SET (dst);
/* Functions to support link list bitsets.
- Copyright (C) 2002-2004, 2006, 2009-2012 Free Software Foundation,
- Inc.
+ Copyright (C) 2002-2004, 2006, 2009-2012 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
These are linked together in a doubly-linked list. */
typedef struct lbitset_elt_struct
{
- struct lbitset_elt_struct *next; /* Next element. */
- struct lbitset_elt_struct *prev; /* Previous element. */
- bitset_windex index; /* bitno / BITSET_WORD_BITS. */
- bitset_word words[LBITSET_ELT_WORDS]; /* Bits that are set. */
+ struct lbitset_elt_struct *next; /* Next element. */
+ struct lbitset_elt_struct *prev; /* Previous element. */
+ bitset_windex index; /* bitno / BITSET_WORD_BITS. */
+ bitset_word words[LBITSET_ELT_WORDS]; /* Bits that are set. */
}
lbitset_elt;
/* Obstack to allocate bitset elements from. */
static struct obstack lbitset_obstack;
static bool lbitset_obstack_init = false;
-static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
+static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
extern void debug_lbitset (bitset);
else
{
if (!lbitset_obstack_init)
- {
- lbitset_obstack_init = true;
+ {
+ lbitset_obstack_init = true;
- /* Let particular systems override the size of a chunk. */
+ /* Let particular systems override the size of a chunk. */
#ifndef OBSTACK_CHUNK_SIZE
#define OBSTACK_CHUNK_SIZE 0
#endif
- /* Let them override the alloc and free routines too. */
+ /* Let them override the alloc and free routines too. */
#ifndef OBSTACK_CHUNK_ALLOC
#define OBSTACK_CHUNK_ALLOC xmalloc
#define __alignof__(type) 0
#endif
- obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
- __alignof__ (lbitset_elt),
- OBSTACK_CHUNK_ALLOC,
- OBSTACK_CHUNK_FREE);
- }
+ obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
+ __alignof__ (lbitset_elt),
+ OBSTACK_CHUNK_ALLOC,
+ OBSTACK_CHUNK_FREE);
+ }
/* Perhaps we should add a number of new elements to the free
- list. */
+ list. */
elt = (lbitset_elt *) obstack_alloc (&lbitset_obstack,
- sizeof (lbitset_elt));
+ sizeof (lbitset_elt));
}
return elt;
if (LBITSET_CURRENT (bset) == elt)
{
if (next)
- {
- bset->b.cdata = next->words;
- bset->b.cindex = next->index;
- }
+ {
+ bset->b.cdata = next->words;
+ bset->b.cindex = next->index;
+ }
else if (prev)
- {
- bset->b.cdata = prev->words;
- bset->b.cindex = prev->index;
- }
+ {
+ bset->b.cdata = prev->words;
+ bset->b.cindex = prev->index;
+ }
else
- {
- bset->b.csize = 0;
- bset->b.cdata = 0;
- }
+ {
+ bset->b.csize = 0;
+ bset->b.cdata = 0;
+ }
}
lbitset_elt_free (elt);
else if (windex < bset->b.cindex)
{
for (ptr = current;
- ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
- continue;
+ ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
+ continue;
if (ptr->prev)
- ptr->prev->next = elt;
+ ptr->prev->next = elt;
else
- LBITSET_HEAD (bset) = elt;
+ LBITSET_HEAD (bset) = elt;
elt->prev = ptr->prev;
elt->next = ptr;
else
{
for (ptr = current;
- ptr->next && ptr->next->index < windex; ptr = ptr->next)
- continue;
+ ptr->next && ptr->next->index < windex; ptr = ptr->next)
+ continue;
if (ptr->next)
- ptr->next->prev = elt;
+ ptr->next->prev = elt;
else
- LBITSET_TAIL (bset) = elt;
+ LBITSET_TAIL (bset) = elt;
elt->next = ptr->next;
elt->prev = ptr;
static lbitset_elt *
lbitset_elt_find (bitset bset, bitset_windex windex,
- enum lbitset_find_mode mode)
+ enum lbitset_find_mode mode)
{
lbitset_elt *elt;
lbitset_elt *current;
current = LBITSET_CURRENT (bset);
/* Check if element is the cached element. */
if ((windex - bset->b.cindex) < bset->b.csize)
- return current;
+ return current;
}
else
{
if (current)
{
if (windex < bset->b.cindex)
- {
- for (elt = current;
- elt->prev && elt->index > windex; elt = elt->prev)
- continue;
- }
+ {
+ for (elt = current;
+ elt->prev && elt->index > windex; elt = elt->prev)
+ continue;
+ }
else
- {
- for (elt = current;
- elt->next && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
- elt = elt->next)
- continue;
- }
+ {
+ for (elt = current;
+ elt->next && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
+ elt = elt->next)
+ continue;
+ }
/* ELT is the nearest to the one we want. If it's not the one
- we want, the one we want does not exist. */
+ we want, the one we want does not exist. */
if (windex - elt->index < LBITSET_ELT_WORDS)
- {
- bset->b.cindex = elt->index;
- bset->b.csize = LBITSET_ELT_WORDS;
- bset->b.cdata = elt->words;
- return elt;
- }
+ {
+ bset->b.cindex = elt->index;
+ bset->b.csize = LBITSET_ELT_WORDS;
+ bset->b.cdata = elt->words;
+ return elt;
+ }
}
switch (mode)
{
next = elt->next;
if (lbitset_elt_zero_p (elt))
- lbitset_elt_unlink (bset, elt);
+ lbitset_elt_unlink (bset, elt);
}
}
selt && delt; selt = selt->next, delt = delt->next)
{
if (selt->index != delt->index)
- return false;
+ return false;
for (j = 0; j < LBITSET_ELT_WORDS; j++)
- if (delt->words[j] != selt->words[j])
- return false;
+ if (delt->words[j] != selt->words[j])
+ return false;
}
return !selt && !delt;
}
tmp->prev = prev;
tmp->next = 0;
if (prev)
- prev->next = tmp;
+ prev->next = tmp;
else
- LBITSET_HEAD (dst) = tmp;
+ LBITSET_HEAD (dst) = tmp;
prev = tmp;
memcpy (tmp->words, elt->words, sizeof (elt->words));
bitset_windex windex = bitno / BITSET_WORD_BITS;
return (lbitset_elt_find (src, windex, LBITSET_FIND)
- && ((src->b.cdata[windex - src->b.cindex]
- >> (bitno % BITSET_WORD_BITS))
- & 1));
+ && ((src->b.cdata[windex - src->b.cindex]
+ >> (bitno % BITSET_WORD_BITS))
+ & 1));
}
found and with *NEXT indicating where search stopped. */
static bitset_bindex
lbitset_list_reverse (bitset bset, bitset_bindex *list,
- bitset_bindex num, bitset_bindex *next)
+ bitset_bindex num, bitset_bindex *next)
{
bitset_bindex rbitno;
bitset_bindex bitno;
if (windex >= elt->index + LBITSET_ELT_WORDS)
{
/* We are trying to start in no-mans land so start
- at end of current elt. */
+ at end of current elt. */
bcount = BITSET_WORD_BITS - 1;
windex = elt->index + LBITSET_ELT_WORDS - 1;
}
bitset_word *srcp = elt->words;
for (; (windex - elt->index) < LBITSET_ELT_WORDS;
- windex--, boffset -= BITSET_WORD_BITS,
- bcount = BITSET_WORD_BITS - 1)
- {
- word =
- srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
-
- for (; word; bcount--)
- {
- if (word & BITSET_MSB)
- {
- list[count++] = boffset + bcount;
- if (count >= num)
- {
- *next = n_bits - (boffset + bcount);
- return count;
- }
- }
- word <<= 1;
- }
- }
+ windex--, boffset -= BITSET_WORD_BITS,
+ bcount = BITSET_WORD_BITS - 1)
+ {
+ word =
+ srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
+
+ for (; word; bcount--)
+ {
+ if (word & BITSET_MSB)
+ {
+ list[count++] = boffset + bcount;
+ if (count >= num)
+ {
+ *next = n_bits - (boffset + bcount);
+ return count;
+ }
+ }
+ word <<= 1;
+ }
+ }
elt = elt->prev;
if (elt)
- {
- windex = elt->index + LBITSET_ELT_WORDS - 1;
- boffset = windex * BITSET_WORD_BITS;
- }
+ {
+ windex = elt->index + LBITSET_ELT_WORDS - 1;
+ boffset = windex * BITSET_WORD_BITS;
+ }
}
*next = n_bits - (boffset + 1);
found and with *NEXT indicating where search stopped. */
static bitset_bindex
lbitset_list (bitset bset, bitset_bindex *list,
- bitset_bindex num, bitset_bindex *next)
+ bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_windex windex;
/* Skip to starting element. */
for (elt = head;
- elt && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
- elt = elt->next)
- continue;
+ elt && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
+ elt = elt->next)
+ continue;
if (!elt)
- return 0;
+ return 0;
if (windex < elt->index)
- {
- windex = elt->index;
- bitno = windex * BITSET_WORD_BITS;
- }
+ {
+ windex = elt->index;
+ bitno = windex * BITSET_WORD_BITS;
+ }
else
- {
- bitset_word *srcp = elt->words;
-
- /* We are starting within an element. */
-
- for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
- {
- word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
-
- for (; word; bitno++)
- {
- if (word & 1)
- {
- list[count++] = bitno;
- if (count >= num)
- {
- *next = bitno + 1;
- return count;
- }
- }
- word >>= 1;
- }
- bitno = (windex + 1) * BITSET_WORD_BITS;
- }
-
- elt = elt->next;
- if (elt)
- {
- windex = elt->index;
- bitno = windex * BITSET_WORD_BITS;
- }
- }
+ {
+ bitset_word *srcp = elt->words;
+
+ /* We are starting within an element. */
+
+ for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
+ {
+ word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
+
+ for (; word; bitno++)
+ {
+ if (word & 1)
+ {
+ list[count++] = bitno;
+ if (count >= num)
+ {
+ *next = bitno + 1;
+ return count;
+ }
+ }
+ word >>= 1;
+ }
+ bitno = (windex + 1) * BITSET_WORD_BITS;
+ }
+
+ elt = elt->next;
+ if (elt)
+ {
+ windex = elt->index;
+ bitno = windex * BITSET_WORD_BITS;
+ }
+ }
}
bitset_word *srcp = elt->words;
if ((count + LBITSET_ELT_BITS) < num)
- {
- /* The coast is clear, plant boot! */
+ {
+ /* The coast is clear, plant boot! */
#if LBITSET_ELT_WORDS == 2
- word = srcp[0];
- if (word)
- {
- if (!(word & 0xffff))
- {
- word >>= 16;
- bitno += 16;
- }
- if (!(word & 0xff))
- {
- word >>= 8;
- bitno += 8;
- }
- for (; word; bitno++)
- {
- if (word & 1)
- list[count++] = bitno;
- word >>= 1;
- }
- }
- windex++;
- bitno = windex * BITSET_WORD_BITS;
-
- word = srcp[1];
- if (word)
- {
- if (!(word & 0xffff))
- {
- word >>= 16;
- bitno += 16;
- }
- for (; word; bitno++)
- {
- if (word & 1)
- list[count++] = bitno;
- word >>= 1;
- }
- }
- windex++;
- bitno = windex * BITSET_WORD_BITS;
+ word = srcp[0];
+ if (word)
+ {
+ if (!(word & 0xffff))
+ {
+ word >>= 16;
+ bitno += 16;
+ }
+ if (!(word & 0xff))
+ {
+ word >>= 8;
+ bitno += 8;
+ }
+ for (; word; bitno++)
+ {
+ if (word & 1)
+ list[count++] = bitno;
+ word >>= 1;
+ }
+ }
+ windex++;
+ bitno = windex * BITSET_WORD_BITS;
+
+ word = srcp[1];
+ if (word)
+ {
+ if (!(word & 0xffff))
+ {
+ word >>= 16;
+ bitno += 16;
+ }
+ for (; word; bitno++)
+ {
+ if (word & 1)
+ list[count++] = bitno;
+ word >>= 1;
+ }
+ }
+ windex++;
+ bitno = windex * BITSET_WORD_BITS;
#else
- for (i = 0; i < LBITSET_ELT_WORDS; i++)
- {
- word = srcp[i];
- if (word)
- {
- if (!(word & 0xffff))
- {
- word >>= 16;
- bitno += 16;
- }
- if (!(word & 0xff))
- {
- word >>= 8;
- bitno += 8;
- }
- for (; word; bitno++)
- {
- if (word & 1)
- list[count++] = bitno;
- word >>= 1;
- }
- }
- windex++;
- bitno = windex * BITSET_WORD_BITS;
- }
+ for (i = 0; i < LBITSET_ELT_WORDS; i++)
+ {
+ word = srcp[i];
+ if (word)
+ {
+ if (!(word & 0xffff))
+ {
+ word >>= 16;
+ bitno += 16;
+ }
+ if (!(word & 0xff))
+ {
+ word >>= 8;
+ bitno += 8;
+ }
+ for (; word; bitno++)
+ {
+ if (word & 1)
+ list[count++] = bitno;
+ word >>= 1;
+ }
+ }
+ windex++;
+ bitno = windex * BITSET_WORD_BITS;
+ }
#endif
- }
+ }
else
- {
- /* Tread more carefully since we need to check
- if array overflows. */
-
- for (i = 0; i < LBITSET_ELT_WORDS; i++)
- {
- for (word = srcp[i]; word; bitno++)
- {
- if (word & 1)
- {
- list[count++] = bitno;
- if (count >= num)
- {
- *next = bitno + 1;
- return count;
- }
- }
- word >>= 1;
- }
- windex++;
- bitno = windex * BITSET_WORD_BITS;
- }
- }
+ {
+ /* Tread more carefully since we need to check
+ if array overflows. */
+
+ for (i = 0; i < LBITSET_ELT_WORDS; i++)
+ {
+ for (word = srcp[i]; word; bitno++)
+ {
+ if (word & 1)
+ {
+ list[count++] = bitno;
+ if (count >= num)
+ {
+ *next = bitno + 1;
+ return count;
+ }
+ }
+ word >>= 1;
+ }
+ windex++;
+ bitno = windex * BITSET_WORD_BITS;
+ }
+ }
elt = elt->next;
if (elt)
- {
- windex = elt->index;
- bitno = windex * BITSET_WORD_BITS;
- }
+ {
+ windex = elt->index;
+ bitno = windex * BITSET_WORD_BITS;
+ }
}
*next = bitno;
{
next = elt->next;
if (!lbitset_elt_zero_p (elt))
- return 0;
+ return 0;
/* Weed as we go. */
lbitset_elt_unlink (dst, elt);
}
windex++;
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
- srcp[windex - elt->index] = 0;
+ srcp[windex - elt->index] = 0;
}
}
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
{
/* Create new elements for dst if they cannot be found
- or substitute zero elements if src elements not found. */
+ or substitute zero elements if src elements not found. */
selt = lbitset_elt_find (src, i, LBITSET_SUBST);
delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
for (j = 0; j < LBITSET_ELT_WORDS; j++)
- delt->words[j] = ~selt->words[j];
+ delt->words[j] = ~selt->words[j];
}
lbitset_unused_clear (dst);
lbitset_weed (dst);
selt || delt; selt = selt->next, delt = delt->next)
{
if (!selt)
- selt = &lbitset_zero_elts[0];
+ selt = &lbitset_zero_elts[0];
else if (!delt)
- delt = &lbitset_zero_elts[0];
+ delt = &lbitset_zero_elts[0];
else if (selt->index != delt->index)
- {
- if (selt->index < delt->index)
- {
- lbitset_zero_elts[2].next = delt;
- delt = &lbitset_zero_elts[2];
- }
- else
- {
- lbitset_zero_elts[1].next = selt;
- selt = &lbitset_zero_elts[1];
- }
- }
+ {
+ if (selt->index < delt->index)
+ {
+ lbitset_zero_elts[2].next = delt;
+ delt = &lbitset_zero_elts[2];
+ }
+ else
+ {
+ lbitset_zero_elts[1].next = selt;
+ selt = &lbitset_zero_elts[1];
+ }
+ }
for (j = 0; j < LBITSET_ELT_WORDS; j++)
- if (delt->words[j] != (selt->words[j] | delt->words[j]))
- return false;
+ if (delt->words[j] != (selt->words[j] | delt->words[j]))
+ return false;
}
return true;
}
selt && delt; selt = selt->next, delt = delt->next)
{
if (selt->index != delt->index)
- {
- if (selt->index < delt->index)
- {
- lbitset_zero_elts[2].next = delt;
- delt = &lbitset_zero_elts[2];
- }
- else
- {
- lbitset_zero_elts[1].next = selt;
- selt = &lbitset_zero_elts[1];
- }
- /* Since the elements are different, there is no
- intersection of these elements. */
- continue;
- }
+ {
+ if (selt->index < delt->index)
+ {
+ lbitset_zero_elts[2].next = delt;
+ delt = &lbitset_zero_elts[2];
+ }
+ else
+ {
+ lbitset_zero_elts[1].next = selt;
+ selt = &lbitset_zero_elts[1];
+ }
+ /* Since the elements are different, there is no
+ intersection of these elements. */
+ continue;
+ }
for (j = 0; j < LBITSET_ELT_WORDS; j++)
- if (selt->words[j] & delt->words[j])
- return false;
+ if (selt->words[j] & delt->words[j])
+ return false;
}
return true;
}
while (selt1 || selt2)
{
/* Figure out whether we need to substitute zero elements for
- missing links. */
+ missing links. */
if (windex1 == windex2)
- {
- windex = windex1;
- stmp1 = selt1;
- stmp2 = selt2;
- selt1 = selt1->next;
- windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
- selt2 = selt2->next;
- windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
- }
+ {
+ windex = windex1;
+ stmp1 = selt1;
+ stmp2 = selt2;
+ selt1 = selt1->next;
+ windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
+ selt2 = selt2->next;
+ windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
+ }
else if (windex1 < windex2)
- {
- windex = windex1;
- stmp1 = selt1;
- stmp2 = &lbitset_zero_elts[0];
- selt1 = selt1->next;
- windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
- }
+ {
+ windex = windex1;
+ stmp1 = selt1;
+ stmp2 = &lbitset_zero_elts[0];
+ selt1 = selt1->next;
+ windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
+ }
else
- {
- windex = windex2;
- stmp1 = &lbitset_zero_elts[0];
- stmp2 = selt2;
- selt2 = selt2->next;
- windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
- }
+ {
+ windex = windex2;
+ stmp1 = &lbitset_zero_elts[0];
+ stmp2 = selt2;
+ selt2 = selt2->next;
+ windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
+ }
/* Find the appropriate element from DST. Begin by discarding
- elements that we've skipped. */
+ elements that we've skipped. */
while (delt && delt->index < windex)
- {
- changed = true;
- dtmp = delt;
- delt = delt->next;
- lbitset_elt_free (dtmp);
- }
+ {
+ changed = true;
+ dtmp = delt;
+ delt = delt->next;
+ lbitset_elt_free (dtmp);
+ }
if (delt && delt->index == windex)
- {
- dtmp = delt;
- delt = delt->next;
- }
+ {
+ dtmp = delt;
+ delt = delt->next;
+ }
else
- dtmp = lbitset_elt_calloc ();
+ dtmp = lbitset_elt_calloc ();
/* Do the operation, and if any bits are set, link it into the
- linked list. */
+ linked list. */
srcp1 = stmp1->words;
srcp2 = stmp2->words;
dstp = dtmp->words;
switch (op)
- {
- default:
- abort ();
-
- case BITSET_OP_OR:
- for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
- {
- bitset_word tmp = *srcp1++ | *srcp2++;
-
- if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
- }
- break;
-
- case BITSET_OP_AND:
- for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
- {
- bitset_word tmp = *srcp1++ & *srcp2++;
-
- if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
- }
- break;
-
- case BITSET_OP_XOR:
- for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
- {
- bitset_word tmp = *srcp1++ ^ *srcp2++;
-
- if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
- }
- break;
-
- case BITSET_OP_ANDN:
- for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
- {
- bitset_word tmp = *srcp1++ & ~(*srcp2++);
-
- if (*dstp != tmp)
- {
- changed = true;
- *dstp = tmp;
- }
- }
- break;
- }
+ {
+ default:
+ abort ();
+
+ case BITSET_OP_OR:
+ for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
+ {
+ bitset_word tmp = *srcp1++ | *srcp2++;
+
+ if (*dstp != tmp)
+ {
+ changed = true;
+ *dstp = tmp;
+ }
+ }
+ break;
+
+ case BITSET_OP_AND:
+ for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
+ {
+ bitset_word tmp = *srcp1++ & *srcp2++;
+
+ if (*dstp != tmp)
+ {
+ changed = true;
+ *dstp = tmp;
+ }
+ }
+ break;
+
+ case BITSET_OP_XOR:
+ for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
+ {
+ bitset_word tmp = *srcp1++ ^ *srcp2++;
+
+ if (*dstp != tmp)
+ {
+ changed = true;
+ *dstp = tmp;
+ }
+ }
+ break;
+
+ case BITSET_OP_ANDN:
+ for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
+ {
+ bitset_word tmp = *srcp1++ & ~(*srcp2++);
+
+ if (*dstp != tmp)
+ {
+ changed = true;
+ *dstp = tmp;
+ }
+ }
+ break;
+ }
if (!lbitset_elt_zero_p (dtmp))
- {
- dtmp->index = windex;
- /* Perhaps this could be optimised... */
- lbitset_elt_link (dst, dtmp);
- }
+ {
+ dtmp->index = windex;
+ /* Perhaps this could be optimised... */
+ lbitset_elt_link (dst, dtmp);
+ }
else
- {
- lbitset_elt_free (dtmp);
- }
+ {
+ lbitset_elt_free (dtmp);
+ }
}
/* If we have elements of DST left over, free them all. */
{
fprintf (stderr, "Elt %lu\n", (unsigned long int) elt->index);
for (i = 0; i < LBITSET_ELT_WORDS; i++)
- {
- unsigned int j;
- bitset_word word;
-
- word = elt->words[i];
-
- fprintf (stderr, " Word %u:", i);
- for (j = 0; j < LBITSET_WORD_BITS; j++)
- if ((word & ((bitset_word) 1 << j)))
- fprintf (stderr, " %u", j);
- fprintf (stderr, "\n");
- }
+ {
+ unsigned int j;
+ bitset_word word;
+
+ word = elt->words[i];
+
+ fprintf (stderr, " Word %u:", i);
+ for (j = 0; j < LBITSET_WORD_BITS; j++)
+ if ((word & ((bitset_word) 1 << j)))
+ fprintf (stderr, " %u", j);
+ fprintf (stderr, "\n");
+ }
}
}
--- /dev/null
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+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
static void get_time (struct timevar_time_def *);
static void timevar_accumulate (struct timevar_time_def *,
- struct timevar_time_def *,
- struct timevar_time_def *);
+ struct timevar_time_def *,
+ struct timevar_time_def *);
/* Fill the current times into TIME. The definition of this function
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
const float tiny = 5e-3;
/* Don't print the total execution time here; that goes at the
- end. */
+ end. */
if ((timevar_id_t) id == TV_TOTAL)
- continue;
+ continue;
/* Don't print timing variables that were never used. */
if (!tv->used)
- continue;
+ continue;
/* Don't print timing variables if we're going to get a row of
- zeroes. */
+ zeroes. */
if (tv->elapsed.user < tiny
- && tv->elapsed.sys < tiny
- && tv->elapsed.wall < tiny)
- continue;
+ && tv->elapsed.sys < tiny
+ && tv->elapsed.wall < tiny)
+ continue;
/* The timing variable name. */
fprintf (fp, " %-22s:", tv->name);
#ifdef HAVE_USER_TIME
/* Print user-mode time for this process. */
fprintf (fp, "%7.2f (%2.0f%%) usr",
- tv->elapsed.user,
- (total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
+ tv->elapsed.user,
+ (total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
#endif /* HAVE_USER_TIME */
#ifdef HAVE_SYS_TIME
/* Print system-mode time for this process. */
fprintf (fp, "%7.2f (%2.0f%%) sys",
- tv->elapsed.sys,
- (total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
+ tv->elapsed.sys,
+ (total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
#endif /* HAVE_SYS_TIME */
#ifdef HAVE_WALL_TIME
/* Print wall clock time elapsed. */
fprintf (fp, "%7.2f (%2.0f%%) wall",
- tv->elapsed.wall,
- (total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
+ tv->elapsed.wall,
+ (total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
#endif /* HAVE_WALL_TIME */
putc ('\n', fp);
#endif
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
- || defined (HAVE_WALL_TIME) */
+ || defined (HAVE_WALL_TIME) */
}
/* Returns time (user + system) used so far by the compiler process,
{
long all_time = get_run_time ();
fprintf (stderr,
- _("time in %s: %ld.%06ld (%ld%%)\n"),
- str, total / 1000000, total % 1000000,
- all_time == 0 ? 0
- : (long) (((100.0 * (double) total) / (double) all_time) + .5));
+ _("time in %s: %ld.%06ld (%ld%%)\n"),
+ str, total / 1000000, total % 1000000,
+ all_time == 0 ? 0
+ : (long) (((100.0 * (double) total) / (double) all_time) + .5));
}
static void vbitset_reset (bitset, bitset_bindex);
static bool vbitset_test (bitset, bitset_bindex);
static bitset_bindex vbitset_list (bitset, bitset_bindex *,
- bitset_bindex, bitset_bindex *);
+ bitset_bindex, bitset_bindex *);
static bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *,
- bitset_bindex, bitset_bindex *);
+ bitset_bindex, bitset_bindex *);
#define VBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
#define VBITSET_WORDS(X) ((X)->b.cdata)
bitset_windex size;
/* The bitset needs to grow. If we already have enough memory
- allocated, then just zero what we need. */
+ allocated, then just zero what we need. */
if (newsize > VBITSET_ASIZE (src))
- {
- /* We need to allocate more memory. When oldsize is
- non-zero this means that we are changing the size, so
- grow the bitset 25% larger than requested to reduce
- number of reallocations. */
-
- if (oldsize == 0)
- size = newsize;
- else
- size = newsize + newsize / 4;
-
- VBITSET_WORDS (src)
- = realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
- VBITSET_ASIZE (src) = size;
- }
+ {
+ /* We need to allocate more memory. When oldsize is
+ non-zero this means that we are changing the size, so
+ grow the bitset 25% larger than requested to reduce
+ number of reallocations. */
+
+ if (oldsize == 0)
+ size = newsize;
+ else
+ size = newsize + newsize / 4;
+
+ VBITSET_WORDS (src)
+ = realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
+ VBITSET_ASIZE (src) = size;
+ }
memset (VBITSET_WORDS (src) + oldsize, 0,
- (newsize - oldsize) * sizeof (bitset_word));
+ (newsize - oldsize) * sizeof (bitset_word));
VBITSET_SIZE (src) = newsize;
}
else
{
/* The bitset needs to shrink. There's no point deallocating
- the memory unless it is shrinking by a reasonable amount. */
+ the memory unless it is shrinking by a reasonable amount. */
if ((oldsize - newsize) >= oldsize / 2)
- {
- VBITSET_WORDS (src)
- = realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word));
- VBITSET_ASIZE (src) = newsize;
- }
+ {
+ VBITSET_WORDS (src)
+ = realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word));
+ VBITSET_ASIZE (src) = newsize;
+ }
/* Need to prune any excess bits. FIXME. */
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
for (; word; bitcnt--)
- {
- if (word & BITSET_MSB)
- {
- list[count++] = bitoff + bitcnt;
- if (count >= num)
- {
- *next = n_bits - (bitoff + bitcnt);
- return count;
- }
- }
- word <<= 1;
- }
+ {
+ if (word & BITSET_MSB)
+ {
+ list[count++] = bitoff + bitcnt;
+ if (count >= num)
+ {
+ *next = n_bits - (bitoff + bitcnt);
+ return count;
+ }
+ }
+ word <<= 1;
+ }
bitoff -= BITSET_WORD_BITS;
bitcnt = BITSET_WORD_BITS - 1;
}
{
/* Many bitsets are zero, so make this common case fast. */
for (windex = 0; windex < size && !srcp[windex]; windex++)
- continue;
+ continue;
if (windex >= size)
- return 0;
+ return 0;
/* If num is 1, we could speed things up with a binary search
- of the current word. */
+ of the current word. */
bitoff = windex * BITSET_WORD_BITS;
}
else
{
if (bitno >= BITSET_SIZE_ (src))
- return 0;
+ return 0;
windex = bitno / BITSET_WORD_BITS;
bitno = bitno % BITSET_WORD_BITS;
if (bitno)
- {
- /* Handle the case where we start within a word.
- Most often, this is executed with large bitsets
- with many set bits where we filled the array
- on the previous call to this function. */
-
- bitoff = windex * BITSET_WORD_BITS;
- word = srcp[windex] >> bitno;
- for (bitno = bitoff + bitno; word; bitno++)
- {
- if (word & 1)
- {
- list[count++] = bitno;
- if (count >= num)
- {
- *next = bitno + 1;
- return count;
- }
- }
- word >>= 1;
- }
- windex++;
- }
+ {
+ /* Handle the case where we start within a word.
+ Most often, this is executed with large bitsets
+ with many set bits where we filled the array
+ on the previous call to this function. */
+
+ bitoff = windex * BITSET_WORD_BITS;
+ word = srcp[windex] >> bitno;
+ for (bitno = bitoff + bitno; word; bitno++)
+ {
+ if (word & 1)
+ {
+ list[count++] = bitno;
+ if (count >= num)
+ {
+ *next = bitno + 1;
+ return count;
+ }
+ }
+ word >>= 1;
+ }
+ windex++;
+ }
bitoff = windex * BITSET_WORD_BITS;
}
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
{
if (!(word = srcp[windex]))
- continue;
+ continue;
if ((count + BITSET_WORD_BITS) < num)
- {
- for (bitno = bitoff; word; bitno++)
- {
- if (word & 1)
- list[count++] = bitno;
- word >>= 1;
- }
- }
+ {
+ for (bitno = bitoff; word; bitno++)
+ {
+ if (word & 1)
+ list[count++] = bitno;
+ word >>= 1;
+ }
+ }
else
- {
- for (bitno = bitoff; word; bitno++)
- {
- if (word & 1)
- {
- list[count++] = bitno;
- if (count >= num)
- {
- *next = bitno + 1;
- return count;
- }
- }
- word >>= 1;
- }
- }
+ {
+ for (bitno = bitoff; word; bitno++)
+ {
+ if (word & 1)
+ {
+ list[count++] = bitno;
+ if (count >= num)
+ {
+ *next = bitno + 1;
+ return count;
+ }
+ }
+ word >>= 1;
+ }
+ }
}
*next = bitoff;
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
memset (dstp + sizeof (bitset_word) * ssize, 0,
- sizeof (bitset_word) * (dsize - ssize));
+ sizeof (bitset_word) * (dsize - ssize));
}
vbitset_unused_clear (dst);
memset (dstp + sizeof (bitset_word) * ssize, 0,
- sizeof (bitset_word) * (dsize - ssize));
+ sizeof (bitset_word) * (dsize - ssize));
}
for (i = 0; i < min (ssize, dsize); i++)
if (*srcp++ != *dstp++)
- return 0;
+ return 0;
if (ssize > dsize)
{
for (; i < ssize; i++)
- if (*srcp++)
- return 0;
+ if (*srcp++)
+ return 0;
}
else
{
for (; i < dsize; i++)
- if (*dstp++)
- return 0;
+ if (*dstp++)
+ return 0;
}
return 1;
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
- return 0;
+ return 0;
if (ssize > dsize)
{
for (; i < ssize; i++)
- if (*srcp++)
- return 0;
+ if (*srcp++)
+ return 0;
}
return 1;
for (i = 0; i < min (ssize, dsize); i++)
if (*srcp++ & *dstp++)
- return 0;
+ return 0;
return 1;
}
bitset_word tmp = *src1p++ & *src2p++;
if (*dstp != tmp)
- {
- changed = 1;
- *dstp = tmp;
- }
+ {
+ changed = 1;
+ *dstp = tmp;
+ }
}
if (ssize2 > ssize1)
for (; i < ssize1; i++, dstp++)
{
if (*dstp != 0)
- {
- changed = 1;
- *dstp = 0;
- }
+ {
+ changed = 1;
+ *dstp = 0;
+ }
}
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
if (ssize2 > ssize1)
{
for (; i < ssize2; i++)
- *dstp++ = 0;
+ *dstp++ = 0;
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
}
else
{
for (; i < ssize1; i++)
- *dstp++ = *src1p++;
+ *dstp++ = *src1p++;
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
}
bitset_word tmp = *src1p++ & ~(*src2p++);
if (*dstp != tmp)
- {
- changed = 1;
- *dstp = tmp;
- }
+ {
+ changed = 1;
+ *dstp = tmp;
+ }
}
if (ssize2 > ssize1)
{
for (; i < ssize2; i++, dstp++)
- {
- if (*dstp != 0)
- {
- changed = 1;
- *dstp = 0;
- }
- }
+ {
+ if (*dstp != 0)
+ {
+ changed = 1;
+ *dstp = 0;
+ }
+ }
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
}
else
{
for (; i < ssize1; i++, dstp++)
- {
- bitset_word tmp = *src1p++;
+ {
+ bitset_word tmp = *src1p++;
- if (*dstp != tmp)
- {
- changed = 1;
- *dstp = tmp;
- }
- }
+ if (*dstp != tmp)
+ {
+ changed = 1;
+ *dstp = tmp;
+ }
+ }
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
}
bitset_word tmp = *src1p++ | *src2p++;
if (*dstp != tmp)
- {
- changed = 1;
- *dstp = tmp;
- }
+ {
+ changed = 1;
+ *dstp = tmp;
+ }
}
if (ssize2 > ssize1)
bitset_word tmp = *src1p++;
if (*dstp != tmp)
- {
- changed = 1;
- *dstp = tmp;
- }
+ {
+ changed = 1;
+ *dstp = tmp;
+ }
}
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
bitset_word tmp = *src1p++ ^ *src2p++;
if (*dstp != tmp)
- {
- changed = 1;
- *dstp = tmp;
- }
+ {
+ changed = 1;
+ *dstp = tmp;
+ }
}
if (ssize2 > ssize1)
bitset_word tmp = *src1p++;
if (*dstp != tmp)
- {
- changed = 1;
- *dstp = tmp;
- }
+ {
+ changed = 1;
+ *dstp = tmp;
+ }
}
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
if (*dstp != tmp)
- {
- changed = 1;
- *dstp = tmp;
- }
+ {
+ changed = 1;
+ *dstp = tmp;
+ }
}
return changed;
}
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
if (*dstp != tmp)
- {
- changed = 1;
- *dstp = tmp;
- }
+ {
+ changed = 1;
+ *dstp = tmp;
+ }
}
return changed;
}
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
if (*dstp != tmp)
- {
- changed = 1;
- *dstp = tmp;
- }
+ {
+ changed = 1;
+ *dstp = tmp;
+ }
}
return changed;
}
/include_next.m4
/intdiv0.m4
/intl.m4
+/intl.m4~
/intldir.m4
/intlmacosx.m4
/intmax.m4
/isnand.m4
/isnanf.m4
/isnanl.m4
-/iswblank.m4
/javacomp.m4
/javaexec.m4
/largefile.m4
/longlong.m4
/malloc.m4
/math_h.m4
-/mbchar.m4
-/mbiter.m4
/mbrtowc.m4
/mbsinit.m4
/mbstate_t.m4
/perror.m4
/pipe2.m4
/po.m4
+/po.m4~
/posix_spawn.m4
/printf-frexp.m4
/printf-frexpl.m4
/xstrndup.m4
/obstack-printf.m4
/extern-inline.m4
+/non-recursive-gnulib-prefix-hack.m4
/getdelim.m4
/getline.m4
+/inline.m4
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <limits.h>
- int test_array[CHAR_BIT];]])],
+ int test_array[CHAR_BIT];]])],
[],
[AC_MSG_FAILURE([cannot compile a simple C program])])
AC_SUBST([BISON_C_WORKS], [:])
bison_cv_cxx_works=no
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
- [#include <cstdlib>
- #include <iostream>
- #include <map>
- #include <string>
- using namespace std;],
+ [#include <cstdlib>
+ #include <iostream>
+ #include <map>
+ #include <string>
+ using namespace std;],
[std::cerr << "";
cout << "";
- typedef std::pair<unsigned int, int> uipair;
- std::map<unsigned int, int> m;
- std::map<unsigned int, int>::iterator i;
- m.insert (uipair (4, -4));
- for (i = m.begin (); i != m.end (); ++i)
- if (i->first != 4)
- return 1;])],
+ typedef std::pair<unsigned int, int> uipair;
+ std::map<unsigned int, int> m;
+ std::map<unsigned int, int>::iterator i;
+ m.insert (uipair (4, -4));
+ for (i = m.begin (); i != m.end (); ++i)
+ if (i->first != 4)
+ return 1;])],
[AS_IF([AC_TRY_COMMAND([$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD])],
- [AS_IF([test "$cross_compiling" = yes],
- [bison_cv_cxx_works=cross],
- [AS_IF([AC_TRY_COMMAND(./conftest$ac_exeext)],
- [bison_cv_cxx_works=yes])])])
+ [AS_IF([test "$cross_compiling" = yes],
+ [bison_cv_cxx_works=cross],
+ [AS_IF([AC_TRY_COMMAND(./conftest$ac_exeext)],
+ [bison_cv_cxx_works=yes])])])
rm -f conftest$ac_exeext])
AC_LANG_POP([C++])])
/Makefile
/Makefile.in
/Makefile.in.in
+/Makefile.in.in~
/Makevars
/Makevars.template
/POTFILES
/Makefile
/Makefile.in
/Makefile.in.in
+/Makefile.in.in~
/Makevars
/Makevars.template
/POTFILES
/*.output
/.deps
/.dirstamp
-/Makefile
-/Makefile.in
/bison
/bison.exe
/scan-code.c
* <tt>manifesting_state->reductions->num + 1</tt>.
* - If the set of all \c InadequacyList nodes with which the new
* \c InadequacyList node might be compared is currently empty, then
- * it is best if <tt>*node_count</t> is zero so that the node count
+ * it is best if <tt>*node_count</tt> is zero so that the node count
* does not eventually overflow. However, if that set is not
* currently empty, then <tt>*node_count</tt> has not been modified
* by any function except \c InadequacyList__new_conflict since the
/* Generate the LR(0) parser states for Bison.
- Copyright (C) 1984, 1986, 1989, 2000-2002, 2004-2007, 2009-2012 Free
- Software Foundation, Inc.
+ Copyright (C) 1984, 1986, 1989, 2000-2002, 2004-2012 Free Software
+ Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
#include "complain.h"
#include "getargs.h"
#include "gram.h"
-#include "gram.h"
#include "lalr.h"
#include "reader.h"
#include "reduce.h"
if (trace_flag & trace_automaton)
fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
- nstates, sym, symbols[sym]->tag);
+ nstates, sym, symbols[sym]->tag);
node->next = NULL;
node->state = s;
symbols. */
size_t count = 0;
size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
- sizeof *symbol_count);
+ sizeof *symbol_count);
for (r = 0; r < nrules; ++r)
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
{
- count++;
- symbol_count[*rhsp]++;
+ count++;
+ symbol_count[*rhsp]++;
}
/* See comments before new_itemsets. All the vectors of items
for (i = 0; i < nitemset; ++i)
if (item_number_is_symbol_number (ritem[itemset[i]]))
{
- symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
- if (!kernel_size[sym])
- {
- shift_symbol[nshifts] = sym;
- nshifts++;
- }
-
- kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
- kernel_size[sym]++;
+ symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
+ if (!kernel_size[sym])
+ {
+ shift_symbol[nshifts] = sym;
+ nshifts++;
+ }
+
+ kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
+ kernel_size[sym]++;
}
}
if (trace_flag & trace_automaton)
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
- sym, symbols[sym]->tag);
+ sym, symbols[sym]->tag);
s = state_hash_lookup (core_size, core);
if (!s)
/*---------------------------------------------------------------.
| Use the information computed by new_itemsets to find the state |
-| numbers reached by each shift transition from S. |
+| numbers reached by each shift transition from S. |
| |
| SHIFTSET is set up as a vector of those states. |
`---------------------------------------------------------------*/
symbol_number sym = shift_symbol[i];
int j;
for (j = i; 0 < j && sym < shift_symbol[j - 1]; j--)
- shift_symbol[j] = shift_symbol[j - 1];
+ shift_symbol[j] = shift_symbol[j - 1];
shift_symbol[j] = sym;
}
{
item_number item = ritem[itemset[i]];
if (item_number_is_rule_number (item))
- {
- rule_number r = item_number_as_rule_number (item);
- redset[count++] = &rules[r];
- if (r == 0)
- {
- /* This is "reduce 0", i.e., accept. */
- aver (!final_state);
- final_state = s;
- }
- }
+ {
+ rule_number r = item_number_as_rule_number (item);
+ redset[count++] = &rules[r];
+ if (r == 0)
+ {
+ /* This is "reduce 0", i.e., accept. */
+ aver (!final_state);
+ final_state = s;
+ }
+ }
}
/* Make a reductions structure and copy the data into it. */
state_list *this = first_state;
/* Pessimization, but simplification of the code: make sure all
- the states have valid transitions and reductions members,
- even if reduced to 0. It is too soon for errs, which are
- computed later, but set_conflicts. */
+ the states have valid transitions and reductions members,
+ even if reduced to 0. It is too soon for errs, which are
+ computed later, but set_conflicts. */
state *s = this->state;
if (!s->transitions)
- state_transitions_set (s, 0, 0);
+ state_transitions_set (s, 0, 0);
if (!s->reductions)
- state_reductions_set (s, 0, 0);
+ state_reductions_set (s, 0, 0);
states[s->number] = s;
{
state *s = list->state;
if (trace_flag & trace_automaton)
- fprintf (stderr, "Processing state %d (reached by %s)\n",
- s->number,
- symbols[s->accessing_symbol]->tag);
+ fprintf (stderr, "Processing state %d (reached by %s)\n",
+ s->number,
+ symbols[s->accessing_symbol]->tag);
/* Set up itemset for the transitions out of this state. itemset gets a
vector of all the items that could be accepted next. */
closure (s->items, s->nitems);
append_states (s);
/* Create the shifts structures for the shifts to those states,
- now that the state numbers transitioning to are known. */
+ now that the state numbers transitioning to are known. */
state_transitions_set (s, nshifts, shiftset);
}
+++ /dev/null
-# Make bison/src.
-
-# Copyright (C) 2001-2012 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-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
/* Associativity information.
- Copyright (C) 2002, 2005-2006, 2009-2012 Free Software Foundation,
+ Copyright (C) 2002, 2005-2006, 2008-2012 Free Software Foundation,
Inc.
This file is part of Bison, the GNU Compiler Compiler.
case non_assoc:
return "%nonassoc";
+
+ case precedence_assoc:
+ return "%precedence";
}
}
/* Associativity information.
- Copyright (C) 2002, 2006, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, 2008-2012 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
/* Associativity values for tokens and rules. */
typedef enum
{
- undef_assoc,
- right_assoc,
- left_assoc,
- non_assoc
+ undef_assoc, /** Not defined. */
+ right_assoc, /** %right */
+ left_assoc, /** %left */
+ non_assoc, /** %nonassoc */
+ precedence_assoc /** %precedence */
} assoc;
char const *assoc_to_string (assoc a);
item_number *rp;
fprintf (stderr, " %2d: .", array[i]);
for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
- fprintf (stderr, " %s", symbols[*rp]->tag);
+ fprintf (stderr, " %s", symbols[*rp]->tag);
fprintf (stderr, " (rule %d)\n", -*rp - 1);
}
fputs ("\n\n", stderr);
bitset_iterator iter;
fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
- {
- fprintf (stderr, "\t\t%s\n",
- symbols[j + ntokens]->tag);
- }
+ {
+ fprintf (stderr, "\t\t%s\n",
+ symbols[j + ntokens]->tag);
+ }
}
fprintf (stderr, "\n\n");
}
bitset_iterator iter;
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
- {
- fprintf (stderr, "\t\t%3d ", r);
- rule_rhs_print (&rules[r], stderr);
- }
+ {
+ fprintf (stderr, "\t\t%3d ", r);
+ rule_rhs_print (&rules[r], stderr);
+ fprintf (stderr, "\n");
+ }
}
fprintf (stderr, "\n\n");
}
for (i = ntokens; i < nsyms; i++)
for (j = 0; derives[i - ntokens][j]; ++j)
{
- item_number sym = derives[i - ntokens][j]->rhs[0];
- if (ISVAR (sym))
- bitset_set (FIRSTS (i), sym - ntokens);
+ item_number sym = derives[i - ntokens][j]->rhs[0];
+ if (ISVAR (sym))
+ bitset_set (FIRSTS (i), sym - ntokens);
}
if (trace_flag & trace_sets)
for (i = ntokens; i < nsyms; ++i)
for (j = ntokens; j < nsyms; ++j)
if (bitset_test (FIRSTS (i), j - ntokens))
- for (k = 0; derives[j - ntokens][k]; ++k)
- bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
+ for (k = 0; derives[j - ntokens][k]; ++k)
+ bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
if (trace_flag & trace_sets)
print_fderives ();
{
item_number itemno = rules[ruleno].rhs - ritem;
while (c < n && core[c] < itemno)
- {
- itemset[nitemset] = core[c];
- nitemset++;
- c++;
- }
+ {
+ itemset[nitemset] = core[c];
+ nitemset++;
+ c++;
+ }
itemset[nitemset] = itemno;
nitemset++;
};
#include "files.h"
#include "getargs.h"
-bool complaint_issued;
+warnings warnings_flag =
+ Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
+
+warnings errors_flag;
+
+err_status complaint_status = status_none;
static unsigned *indent_ptr = 0;
-\f
+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.
*
* \param loc the location, defaulting to the current file,
* or the program name.
+ * \param flags the category for this message.
* \param prefix put before the message (e.g., "warning").
* \param message the error message, a printf format string. Iff it
* ends with ": ", then no trailing newline is printed,
*/
static
void
-error_message (location *loc,
- const char *prefix,
- const char *message, va_list args)
+error_message (const location *loc, warnings flags, const char *prefix,
+ const char *message, va_list args)
{
unsigned pos = 0;
if (loc)
pos += location_print (stderr, *loc);
else
- pos += fprintf(stderr, "%s", current_file ? current_file : program_name);
- pos += fprintf(stderr, ": ");
+ pos += fprintf (stderr, "%s", current_file ? current_file : program_name);
+ pos += fprintf (stderr, ": ");
if (indent_ptr)
{
+ if (*indent_ptr)
+ prefix = NULL;
if (!*indent_ptr)
*indent_ptr = pos;
else if (*indent_ptr > pos)
fprintf (stderr, "%s: ", prefix);
vfprintf (stderr, message, args);
+ warnings_print_categories (flags);
{
size_t l = strlen (message);
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')
fflush (stderr);
}
-/** Wrap error_message() with varargs handling. */
-#define ERROR_MESSAGE(Loc, Prefix, Message) \
-{ \
- va_list args; \
- va_start (args, Message); \
- error_message (Loc, Prefix, Message, args); \
- va_end (args); \
-}
-
-
-/*--------------------------------.
-| Report a warning, and proceed. |
-`--------------------------------*/
-
-void
-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, ...)
+/** Raise a complaint. That can be a fatal error, a complaint or just a
+ warning. */
+static inline void
+complains (const location *loc, warnings flags, const char *message,
+ va_list args)
{
- if (!(warnings_flag & warnings_other))
- return;
- set_warning_issued ();
- ERROR_MESSAGE (NULL, _("warning"), message);
+ const char* prefix =
+ 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)
+ complaint_status = status_warning_as_error;
+ if (flags & (warnings_flag | fatal | complaint))
+ error_message (loc, flags, prefix, message, args);
+ if (flags & fatal)
+ exit (EXIT_FAILURE);
}
-
-/*-----------------------------------------------------------.
-| An error has occurred, but we can proceed, and die later. |
-`-----------------------------------------------------------*/
-
void
-complain_at (location loc, const char *message, ...)
+complain (location const *loc, warnings flags, const char *message, ...)
{
- ERROR_MESSAGE (&loc, _("error"), message);
- complaint_issued = true;
+ va_list args;
+ va_start (args, message);
+ complains (loc, flags, message, args);
+ va_end (args);
}
void
-complain_at_indent (location loc, unsigned *indent,
- const char *message, ...)
+complain_indent (location const *loc, warnings flags, unsigned *indent,
+ const char *message, ...)
{
+ va_list args;
indent_ptr = indent;
- ERROR_MESSAGE (&loc, *indent ? NULL : _("error"), message);
- complaint_issued = true;
+ va_start (args, message);
+ complains (loc, flags, message, args);
+ va_end (args);
}
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, ...)
+complain_args (location const *loc, warnings w, unsigned *indent,
+ int argc, char *argv[])
{
- 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);
-}
-
-void
-fatal (const char *message, ...)
-{
- ERROR_MESSAGE (NULL, _("fatal error"), message);
- exit (EXIT_FAILURE);
+ 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;
+ }
}
# include "location.h"
-# ifdef __cplusplus
-extern "C" {
-# endif
-
/* Sub-messages indent. */
#define SUB_INDENT (4)
-/** Record that a warning is about to be issued, and treat it as an
- 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);
+/*-------------.
+| --warnings. |
+`-------------*/
-/** Informative messages, but we proceed. Report iff
- <tt>warnings_flag & warnings_other</tt>. */
+typedef enum
+ {
+ 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. */
-void warn (char const *format, ...)
- __attribute__ ((__format__ (__printf__, 1, 2)));
+ Werror = 1 << 10, /** This bit is no longer used. */
-void warn_at (location loc, char const *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+ complaint = 1 << 11, /**< All complaints. */
+ fatal = 1 << 12, /**< All fatal errors. */
+ silent = 1 << 13, /**< Do not display the warning type. */
-/* Generate a message aligned by an indent.
- When *indent == 0, assign message's indent to *indent,
- When *indent > 0, align the message by *indent value. */
-void warn_at_indent (location loc, unsigned *indent,
- char const *format, ...)
- __attribute__ ((__format__ (__printf__, 3, 4)));
+ /**< All above warnings. */
+ Wall = ~complaint & ~fatal & ~silent
+ } warnings;
-/** An error, but we continue and die later. */
+/** What warnings are issued. */
+extern warnings warnings_flag;
-void complain (char const *format, ...)
- __attribute__ ((__format__ (__printf__, 1, 2)));
+/** What warnings are made errors. */
+extern warnings errors_flag;
-void complain_at (location loc, char const *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+/** Display a "[-Wyacc]" like message on stderr. */
+void warnings_print_categories (warnings warn_flags);
-/* Generate a message aligned by an indent.
- When *indent == 0, assign message's indent to *indent,
- When *indent > 0, align the message by *indent value. */
-void complain_at_indent (location loc, unsigned *indent,
- char const *format, ...)
+/** Make a complaint, with maybe a location. */
+void complain (location const *loc, warnings flags, char const *message, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
-/** An incompatibility with POSIX Yacc: mapped either to warn* or
- complain* depending on yacc_flag. */
-
-void yacc_at (location loc, char const *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
+/** Likewise, but with an \a argc/argv interface. */
+void complain_args (location const *loc, warnings w, unsigned *indent,
+ int argc, char *arg[]);
-/** A midrule-value warning. Report iff
- <tt>warnings_flag & warnings_midrule_values</tt>. */
+/** Make a complaint with location and some indentation. */
+void complain_indent (location const *loc, warnings flags, unsigned *indent,
+ char const *message, ...)
+ __attribute__ ((__format__ (__printf__, 4, 5)));
-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)));
+/** Warnings treated as errors shouldn't stop the execution as regular errors
+ should (because due to their nature, it is safe to go on). Thus, there are
+ three possible execution statuses. */
+typedef enum
+ {
+ status_none,
+ status_warning_as_error,
+ status_complaint
+ } err_status;
/** Whether an error was reported. */
-extern bool complaint_issued;
-
-# ifdef __cplusplus
-}
-# endif
+extern err_status complaint_status;
#endif /* !COMPLAIN_H_ */
/* Find and resolve or report lookahead conflicts for bison,
- Copyright (C) 1984, 1989, 1992, 2000-2007, 2009-2012 Free Software
- Foundation, Inc.
+ Copyright (C) 1984, 1989, 1992, 2000-2012 Free Software Foundation,
+ Inc.
This file is part of Bison, the GNU Compiler Compiler.
static inline void
log_resolution (rule *r, symbol_number token,
- enum conflict_resolution resolution)
+ enum conflict_resolution resolution)
{
if (report_flag & report_solved_conflicts)
{
/* The description of the resolution. */
switch (resolution)
- {
- case shift_resolution:
- case right_resolution:
- obstack_printf (&solved_conflicts_obstack,
- _(" Conflict between rule %d and token %s"
- " resolved as shift"),
- r->number,
- symbols[token]->tag);
- break;
-
- case reduce_resolution:
- case left_resolution:
- obstack_printf (&solved_conflicts_obstack,
- _(" Conflict between rule %d and token %s"
- " resolved as reduce"),
- r->number,
- symbols[token]->tag);
- break;
-
- case nonassoc_resolution:
- obstack_printf (&solved_conflicts_obstack,
- _(" Conflict between rule %d and token %s"
- " resolved as an error"),
- r->number,
- symbols[token]->tag);
- break;
- }
+ {
+ case shift_resolution:
+ case right_resolution:
+ obstack_printf (&solved_conflicts_obstack,
+ _(" Conflict between rule %d and token %s"
+ " resolved as shift"),
+ r->number,
+ symbols[token]->tag);
+ break;
+
+ case reduce_resolution:
+ case left_resolution:
+ obstack_printf (&solved_conflicts_obstack,
+ _(" Conflict between rule %d and token %s"
+ " resolved as reduce"),
+ r->number,
+ symbols[token]->tag);
+ break;
+
+ case nonassoc_resolution:
+ obstack_printf (&solved_conflicts_obstack,
+ _(" Conflict between rule %d and token %s"
+ " resolved as an error"),
+ r->number,
+ symbols[token]->tag);
+ break;
+ }
/* The reason. */
switch (resolution)
- {
- case shift_resolution:
- obstack_printf (&solved_conflicts_obstack,
- " (%s < %s)",
- r->prec->tag,
- symbols[token]->tag);
- break;
-
- case reduce_resolution:
- obstack_printf (&solved_conflicts_obstack,
- " (%s < %s)",
- symbols[token]->tag,
- r->prec->tag);
- break;
-
- case left_resolution:
- obstack_printf (&solved_conflicts_obstack,
- " (%%left %s)",
- symbols[token]->tag);
- break;
-
- case right_resolution:
- obstack_printf (&solved_conflicts_obstack,
- " (%%right %s)",
- symbols[token]->tag);
- break;
-
- case nonassoc_resolution:
- obstack_printf (&solved_conflicts_obstack,
- " (%%nonassoc %s)",
- symbols[token]->tag);
- break;
- }
+ {
+ case shift_resolution:
+ obstack_printf (&solved_conflicts_obstack,
+ " (%s < %s)",
+ r->prec->tag,
+ symbols[token]->tag);
+ break;
+
+ case reduce_resolution:
+ obstack_printf (&solved_conflicts_obstack,
+ " (%s < %s)",
+ symbols[token]->tag,
+ r->prec->tag);
+ break;
+
+ case left_resolution:
+ obstack_printf (&solved_conflicts_obstack,
+ " (%%left %s)",
+ symbols[token]->tag);
+ break;
+
+ case right_resolution:
+ obstack_printf (&solved_conflicts_obstack,
+ " (%%right %s)",
+ symbols[token]->tag);
+ break;
+
+ case nonassoc_resolution:
+ obstack_printf (&solved_conflicts_obstack,
+ " (%%nonassoc %s)",
+ symbols[token]->tag);
+ break;
+ }
obstack_sgrow (&solved_conflicts_obstack, ".\n");
}
bitset_reset (lookahead_set, token);
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
- && TRANSITION_SYMBOL (trans, i) == token)
+ && TRANSITION_SYMBOL (trans, i) == token)
TRANSITION_DISABLE (trans, i);
}
for (i = 0; i < ntokens; i++)
if (bitset_test (lookahead_tokens, i)
- && bitset_test (lookahead_set, i)
- && symbols[i]->prec)
+ && bitset_test (lookahead_set, i)
+ && symbols[i]->prec)
{
- /* Shift-reduce conflict occurs for token number i
- and it has a precedence.
- The precedence of shifting is that of token i. */
- if (symbols[i]->prec < redprec)
- {
- log_resolution (redrule, i, reduce_resolution);
- flush_shift (s, i);
- }
- else if (symbols[i]->prec > redprec)
- {
- log_resolution (redrule, i, shift_resolution);
- flush_reduce (lookahead_tokens, i);
- }
- else
- /* Matching precedence levels.
- For left association, keep only the reduction.
- For right association, keep only the shift.
- For nonassociation, keep neither. */
-
- switch (symbols[i]->assoc)
- {
- default:
- abort ();
-
- case right_assoc:
- log_resolution (redrule, i, right_resolution);
- flush_reduce (lookahead_tokens, i);
- break;
-
- case left_assoc:
- log_resolution (redrule, i, left_resolution);
- flush_shift (s, i);
- break;
-
- case non_assoc:
- log_resolution (redrule, i, nonassoc_resolution);
- flush_shift (s, i);
- flush_reduce (lookahead_tokens, i);
- /* Record an explicit error for this token. */
- errors[(*nerrs)++] = symbols[i];
- break;
- }
+ /* Shift-reduce conflict occurs for token number i
+ and it has a precedence.
+ The precedence of shifting is that of token i. */
+ if (symbols[i]->prec < redprec)
+ {
+ log_resolution (redrule, i, reduce_resolution);
+ flush_shift (s, i);
+ }
+ else if (symbols[i]->prec > redprec)
+ {
+ log_resolution (redrule, i, shift_resolution);
+ flush_reduce (lookahead_tokens, i);
+ }
+ else
+ /* Matching precedence levels.
+ For non-defined associativity, keep both: unexpected
+ associativity conflict.
+ For left associativity, keep only the reduction.
+ For right associativity, keep only the shift.
+ For nonassociativity, keep neither. */
+
+ switch (symbols[i]->assoc)
+ {
+ case undef_assoc:
+ abort ();
+
+ case precedence_assoc:
+ break;
+
+ case right_assoc:
+ log_resolution (redrule, i, right_resolution);
+ flush_reduce (lookahead_tokens, i);
+ break;
+
+ case left_assoc:
+ log_resolution (redrule, i, left_resolution);
+ flush_shift (s, i);
+ break;
+
+ case non_assoc:
+ log_resolution (redrule, i, nonassoc_resolution);
+ flush_shift (s, i);
+ flush_reduce (lookahead_tokens, i);
+ /* Record an explicit error for this token. */
+ errors[(*nerrs)++] = symbols[i];
+ break;
+ }
}
}
precedence. */
for (i = 0; i < reds->num; ++i)
if (reds->rules[i]->prec && reds->rules[i]->prec->prec
- && !bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
+ && !bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
resolve_sr_conflict (s, i, errors, &nerrs);
if (nerrs)
state_errs_set (s, nerrs, errors);
}
if (obstack_object_size (&solved_conflicts_obstack))
- {
- obstack_1grow (&solved_conflicts_obstack, '\0');
- s->solved_conflicts = obstack_finish (&solved_conflicts_obstack);
- }
+ s->solved_conflicts = obstack_finish0 (&solved_conflicts_obstack);
if (obstack_object_size (&solved_conflicts_xml_obstack))
- {
- obstack_1grow (&solved_conflicts_xml_obstack, '\0');
- s->solved_conflicts_xml = obstack_finish (&solved_conflicts_xml_obstack);
- }
+ s->solved_conflicts_xml = obstack_finish0 (&solved_conflicts_xml_obstack);
/* Loop over all rules which require lookahead in this state. Check
for conflicts not resolved above. */
for (i = 0; i < reds->num; ++i)
{
if (!bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
- conflicts[s->number] = 1;
+ conflicts[s->number] = 1;
bitset_or (lookahead_set, lookahead_set, reds->lookahead_tokens[i]);
}
}
set_conflicts (states[i], errors);
/* For uniformity of the code, make sure all the states have a valid
- `errs' member. */
+ `errs' member. */
if (!states[i]->errs)
- states[i]->errs = errs_new (0, 0);
+ states[i]->errs = errs_new (0, 0);
}
free (errors);
| Count the number of shift/reduce conflicts. |
`---------------------------------------------*/
-static int
-count_sr_conflicts (state *s)
+static size_t
+count_state_sr_conflicts (state *s)
{
int i;
- int src_count = 0;
transitions *trans = s->transitions;
reductions *reds = s->reductions;
bitset_and (lookahead_set, lookahead_set, shift_set);
- src_count = bitset_count (lookahead_set);
+ return bitset_count (lookahead_set);
+}
+
+/*---------------------------------------------.
+| The total number of shift/reduce conflicts. |
+`---------------------------------------------*/
- return src_count;
+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 one conflict for each token that has any reduce/reduce |
| conflicts. Otherwise, count one conflict for each pair of |
| conflicting reductions. |
-+`----------------------------------------------------------------*/
+`----------------------------------------------------------------*/
-static int
-count_rr_conflicts (state *s, bool one_per_token)
+static size_t
+count_state_rr_conflicts (state *s, bool one_per_token)
{
int i;
reductions *reds = s->reductions;
- int rrc_count = 0;
+ size_t res = 0;
for (i = 0; i < ntokens; i++)
{
int count = 0;
int j;
for (j = 0; j < reds->num; ++j)
- if (bitset_test (reds->lookahead_tokens[j], i))
- count++;
-
+ count += bitset_test (reds->lookahead_tokens[j], i);
if (count >= 2)
- rrc_count += one_per_token ? 1 : count-1;
+ res += one_per_token ? 1 : count-1;
}
- return rrc_count;
+ return res;
}
-
-/*--------------------------------------------------------.
-| Report the number of conflicts, using the Yacc format. |
-`--------------------------------------------------------*/
-
-static void
-conflict_report (FILE *out, int src_num, int rrc_num)
+static size_t
+count_rr_conflicts (bool one_per_token)
{
- if (src_num && rrc_num)
- fprintf (out, _("conflicts: %d shift/reduce, %d reduce/reduce\n"),
- src_num, rrc_num);
- else if (src_num)
- fprintf (out, _("conflicts: %d shift/reduce\n"), src_num);
- else if (rrc_num)
- fprintf (out, _("conflicts: %d reduce/reduce\n"), rrc_num);
+ size_t res = 0;
+ state_number i;
+
+ /* Conflicts by state. */
+ for (i = 0; i < nstates; i++)
+ if (conflicts[i])
+ res += count_state_rr_conflicts (states[i], one_per_token);
+ return res;
}
{
state *s = states[i];
if (conflicts[i])
- {
- fprintf (out, _("State %d "), i);
- conflict_report (out, count_sr_conflicts (s),
- count_rr_conflicts (s, true));
- printed_sth = true;
- }
+ {
+ int src = count_state_sr_conflicts (s);
+ int rrc = count_state_rr_conflicts (s, true);
+ fprintf (out, _("State %d "), i);
+ if (src && rrc)
+ fprintf (out,
+ _("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;
+ }
}
if (printed_sth)
fputs ("\n\n", out);
| Total the number of S/R and R/R conflicts. Unlike the |
| code in conflicts_output, however, count EACH pair of |
| reductions for the same state and lookahead as one |
-| conflict. |
+| conflict. |
`--------------------------------------------------------*/
int
conflicts_total_count (void)
{
- 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;
+ return count_sr_conflicts () + count_rr_conflicts (false);
}
void
conflicts_print (void)
{
- /* 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. */
- {
- 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)
+ if (! glr_parser && expected_rr_conflicts != -1)
{
- warn (_("%%expect-rr applies only to GLR parsers"));
+ complain (NULL, Wother, _("%%expect-rr applies only to GLR parsers"));
expected_rr_conflicts = -1;
}
- src_expected = expected_sr_conflicts == -1 ? 0 : expected_sr_conflicts;
- 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)
- {
- if (!(warnings_flag & warnings_conflicts_sr))
- src_total = 0;
- if (!(warnings_flag & warnings_conflicts_rr))
- rrc_total = 0;
- }
- if (src_total | rrc_total)
- {
- if (expected_sr_conflicts == -1 && expected_rr_conflicts == -1)
- set_warning_issued ();
- if (! yacc_flag)
- fprintf (stderr, "%s: ", current_file);
- conflict_report (stderr, src_total, rrc_total);
- }
+ /* Screams for factoring, but almost useless because of the
+ different strings to translate. */
+ {
+ int total = count_sr_conflicts ();
+ // If %expect is not used, but %expect-rr is, then expect 0 sr.
+ int expected =
+ (expected_sr_conflicts == -1 && expected_rr_conflicts != -1)
+ ? 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)
+ complain (NULL, Wconflicts_sr,
+ ngettext ("%d shift/reduce conflict",
+ "%d shift/reduce conflicts",
+ total),
+ total);
+ }
- if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1)
- {
- if (! src_ok)
- complain (ngettext ("expected %d shift/reduce conflict",
- "expected %d shift/reduce conflicts",
- src_expected),
- src_expected);
- if (! rrc_ok)
- complain (ngettext ("expected %d reduce/reduce conflict",
- "expected %d reduce/reduce conflicts",
- rrc_expected),
- rrc_expected);
- }
+ {
+ int total = count_rr_conflicts (true);
+ // If %expect-rr is not used, but %expect is, then expect 0 rr.
+ int expected =
+ (expected_rr_conflicts == -1 && expected_sr_conflicts != -1)
+ ? 0
+ : expected_rr_conflicts;
+ if (expected != -1)
+ {
+ if (expected != total)
+ complain (NULL, complaint,
+ _("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);
+ }
}
rule **rp;
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
for (rp = derives[i - ntokens]; *rp; ++rp)
- {
- fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
- rule_rhs_print (*rp, stderr);
- }
+ {
+ fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
+ rule_rhs_print (*rp, stderr);
+ fprintf (stderr, "\n");
+ }
}
fputs ("\n\n", stderr);
rule_list *p = dset[i - ntokens];
derives[i - ntokens] = q;
while (p)
- {
- *q++ = p->value;
- p = p->next;
- }
+ {
+ *q++ = p->value;
+ p = p->next;
+ }
*q++ = NULL;
}
}
\f
+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. |
`------------------------------------------------------------------*/
static void
compute_exts_from_gf (const char *ext)
{
- if (strcmp (ext, ".y") == 0)
+ if (STREQ (ext, ".y"))
{
src_extension = xstrdup (language->src_extension);
header_extension = xstrdup (language->header_extension);
static void
file_name_split (const char *file_name,
- const char **base, const char **tab, const char **ext)
+ const char **base, const char **tab, const char **ext)
{
*base = last_component (file_name);
/* Look for the extension, i.e., look for the last dot. */
- *ext = mbsrchr (*base, '.');
+ *ext = strrchr (*base, '.');
*tab = NULL;
/* If there is an extension, check if there is a `.tab' part right
if (*ext)
{
size_t baselen = *ext - *base;
- size_t dottablen = 4;
+ size_t dottablen = sizeof (TAB_EXT) - 1;
if (dottablen < baselen
- && (strncmp (*ext - dottablen, ".tab", dottablen) == 0
- || strncmp (*ext - dottablen, "_tab", dottablen) == 0))
- *tab = *ext - dottablen;
+ && STRPREFIX_LIT (TAB_EXT, *ext - dottablen))
+ *tab = *ext - dottablen;
}
}
/* ALL_BUT_EXT goes up the EXT, excluding it. */
all_but_ext =
- xstrndup (spec_outfile,
- (strlen (spec_outfile) - (ext ? strlen (ext) : 0)));
+ xstrndup (spec_outfile,
+ (strlen (spec_outfile) - (ext ? strlen (ext) : 0)));
/* ALL_BUT_TAB_EXT goes up to TAB, excluding it. */
all_but_tab_ext =
- xstrndup (spec_outfile,
- (strlen (spec_outfile)
- - (tab ? strlen (tab) : (ext ? strlen (ext) : 0))));
+ xstrndup (spec_outfile,
+ (strlen (spec_outfile)
+ - (tab ? strlen (tab) : (ext ? strlen (ext) : 0))));
if (ext)
- compute_exts_from_src (ext);
+ compute_exts_from_src (ext);
}
else
{
file_name_split (grammar_file, &base, &tab, &ext);
if (spec_file_prefix)
- {
- /* If --file-prefix=foo was specified, ALL_BUT_TAB_EXT = `foo'. */
- dir_prefix =
+ {
+ /* If --file-prefix=foo was specified, ALL_BUT_TAB_EXT = `foo'. */
+ dir_prefix =
xstrndup (spec_file_prefix,
last_component (spec_file_prefix) - spec_file_prefix);
- all_but_tab_ext = xstrdup (spec_file_prefix);
- }
+ all_but_tab_ext = xstrdup (spec_file_prefix);
+ }
else if (yacc_flag)
- {
- /* If --yacc, then the output is `y.tab.c'. */
- dir_prefix = xstrdup ("");
- all_but_tab_ext = xstrdup ("y");
- }
+ {
+ /* If --yacc, then the output is `y.tab.c'. */
+ dir_prefix = xstrdup ("");
+ all_but_tab_ext = xstrdup ("y");
+ }
else
- {
- /* Otherwise, ALL_BUT_TAB_EXT is computed from the input
- grammar: `foo/bar.yy' => `bar'. */
- dir_prefix = xstrdup ("");
- all_but_tab_ext =
- xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0)));
- }
+ {
+ /* Otherwise, ALL_BUT_TAB_EXT is computed from the input
+ grammar: `foo/bar.yy' => `bar'. */
+ dir_prefix = xstrdup ("");
+ all_but_tab_ext =
+ xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0)));
+ }
if (language->add_tab)
all_but_ext = concat2 (all_but_tab_ext, TAB_EXT);
/* Compute the extensions from the grammar file name. */
if (ext && !yacc_flag)
- compute_exts_from_gf (ext);
+ compute_exts_from_gf (ext);
}
}
if (defines_flag)
{
if (! spec_defines_file)
- spec_defines_file = concat2 (all_but_ext, header_extension);
+ spec_defines_file = concat2 (all_but_ext, header_extension);
}
if (graph_flag)
{
if (! spec_graph_file)
- spec_graph_file = concat2 (all_but_tab_ext, ".dot");
+ spec_graph_file = concat2 (all_but_tab_ext, ".dot");
output_file_name_check (&spec_graph_file);
}
if (xml_flag)
{
if (! spec_xml_file)
- spec_xml_file = concat2 (all_but_tab_ext, ".xml");
+ spec_xml_file = concat2 (all_but_tab_ext, ".xml");
output_file_name_check (&spec_xml_file);
}
output_file_name_check (char **file_name)
{
bool conflict = false;
- if (0 == strcmp (*file_name, grammar_file))
+ if (STREQ (*file_name, grammar_file))
{
- complain (_("refusing to overwrite the input file %s"),
+ complain (NULL, complaint, _("refusing to overwrite the input file %s"),
quote (*file_name));
conflict = true;
}
{
int i;
for (i = 0; i < file_names_count; i++)
- if (0 == strcmp (file_names[i], *file_name))
+ if (STREQ (file_names[i], *file_name))
{
- warn (_("conflicting outputs to file %s"),
- quote (*file_name));
+ complain (NULL, Wother, _("conflicting outputs to file %s"),
+ quote (*file_name));
conflict = true;
}
}
void output_file_names_free (void);
void output_file_name_check (char **file_name);
-FILE *xfopen (const char *name, const char *mode);
+FILE *xfopen (const char *name, char const *mode);
void xfclose (FILE *ptr);
+FILE *xfdopen (int fd, char const *mode);
#endif /* !FILES_H_ */
static struct obstack obstack_for_string;
-# define STRING_GROW \
+# define STRING_GROW \
obstack_grow (&obstack_for_string, yytext, yyleng)
-# define STRING_FINISH \
- do { \
- obstack_1grow (&obstack_for_string, '\0'); \
- last_string = obstack_finish (&obstack_for_string); \
- } while (0)
+# define STRING_FINISH \
+ (last_string = obstack_finish0 (&obstack_for_string))
-# define STRING_FREE \
+# define STRING_FREE \
obstack_free (&obstack_for_string, last_string)
#endif
#include <c-strcase.h>
#include <configmake.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>
-
-#ifdef HACK_FOR___GNU_LIBRARY___PROTOTYPE
-# undef __GNU_LIBRARY__
-# undef HACK_FOR___GNU_LIBRARY___PROTOTYPE
-#endif
-
#include <progname.h>
#include "complain.h"
#include "quote.h"
#include "uniqstr.h"
-bool debug;
bool defines_flag;
bool graph_flag;
bool xml_flag;
-bool locations_flag;
bool no_lines_flag;
bool token_table_flag;
-bool yacc_flag; /* for -y */
-
-bool error_verbose = false;
+bool yacc_flag; /* for -y */
bool nondeterministic_parser = false;
bool glr_parser = false;
int feature_flag = feature_none;
int report_flag = report_none;
int trace_flag = trace_none;
-int warnings_flag = warnings_conflicts_sr | warnings_conflicts_rr
- | warnings_other;
static struct bison_language const valid_languages[] = {
{ "c", "c-skel.m4", ".c", ".h", true },
struct bison_language const *language = &valid_languages[0];
const char *include = NULL;
-
-/** Decode an option's set of keys.
+/** 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 args comma separated list of effective subarguments to decode.
- * If 0, then activate all the flags.
+ * \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
-flags_argmatch (const char *option,
- const char * const keys[], const int values[],
- int all, int *flags, char *args)
+flag_argmatch (const char *option,
+ const char * const keys[], const int values[],
+ int all, int *flags, char *arg, size_t no, size_t err)
{
- if (args)
+ int value = 0;
+ if (!err || arg[no + err++] != '\0')
+ value = XARGMATCH (option, arg + no + err, keys, values);
+
+ if (value)
{
- args = strtok (args, ",");
- while (args)
- {
- int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
- int value = XARGMATCH (option, args + no, keys, values);
- if (value == 0)
- {
- if (no)
- *flags |= all;
- else
- *flags &= ~all;
- }
- else
- {
- if (no)
- *flags &= ~value;
- else
- *flags |= value;
- }
- args = strtok (NULL, ",");
- }
+ 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.
+ *
+ * \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 args comma separated list of effective subarguments to decode.
+ * If 0, then activate all the flags.
+ */
+static void
+flags_argmatch (const char *option,
+ const char * const keys[], const int values[],
+ int all, int *flags, char *args)
+{
+ if (args)
+ for (args = strtok (args, ","); args; args = strtok (NULL, ","))
+ {
+ size_t no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
+ size_t err = STRPREFIX_LIT ("error", args + no) ? 5 : 0;
+
+ flag_argmatch (option, keys,
+ values, all, err ? &errors_flag : flags,
+ args, no, err);
+ }
else
*flags |= all;
}
*
* \param FlagName the flag familly to update.
* \param Args the effective sub arguments to decode.
+ * \param All the "all" value.
*
* \arg FlagName_args the list of keys.
* \arg FlagName_types the list of values.
- * \arg FlagName_all the all value.
* \arg FlagName_flag the flag to update.
*/
-#define FLAGS_ARGMATCH(FlagName, Args) \
+#define FLAGS_ARGMATCH(FlagName, Args, All) \
flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \
- FlagName ## _all, &FlagName ## _flag, Args)
+ All, &FlagName ## _flag, Args)
/*----------------------.
"yacc - incompatibilities with POSIX Yacc",
"conflicts-sr - S/R conflicts",
"conflicts-rr - R/R conflicts",
+ "deprecated - obsolete constructs",
"other - all other warnings",
"all - all of the above",
"error - warnings are errors",
static const int warnings_types[] =
{
- warnings_none,
- warnings_midrule_values,
- warnings_yacc,
- warnings_conflicts_sr,
- warnings_conflicts_rr,
- warnings_other,
- warnings_all,
- warnings_error
+ Wnone,
+ Wmidrule_values,
+ Wyacc,
+ Wconflicts_sr,
+ Wconflicts_rr,
+ Wdeprecated,
+ Wother,
+ Wall,
+ Werror
};
ARGMATCH_VERIFY (warnings_args, warnings_types);
{
if (status != 0)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
- program_name);
+ program_name);
else
{
/* For ../build-aux/cross-options.pl to work, use the format:
- ^ -S, --long[=ARGS] (whitespace)
- A --long option is required.
- Otherwise, add exceptions to ../build-aux/cross-options.pl. */
+ ^ -S, --long[=ARGS] (whitespace)
+ A --long option is required.
+ Otherwise, add exceptions to ../build-aux/cross-options.pl. */
printf (_("Usage: %s [OPTION]... FILE\n"), program_name);
fputs (_("\
Parser:\n\
-L, --language=LANGUAGE specify the output programming language\n\
-S, --skeleton=FILE specify the skeleton to use\n\
- -t, --debug instrument the parser for debugging\n\
+ -t, --debug instrument the parser for tracing\n\
+ same as `-Dparse.trace'\n\
--locations enable location support\n\
-D, --define=NAME[=VALUE] similar to '%define NAME \"VALUE\"'\n\
-F, --force-define=NAME[=VALUE] override '%define NAME \"VALUE\"'\n\
fputs (_("\
Warning categories include:\n\
- `midrule-values' unset or unused midrule values\n\
- `yacc' incompatibilities with POSIX Yacc\n\
- `conflicts-sr' S/R conflicts (enabled by default)\n\
- `conflicts-rr' R/R conflicts (enabled by default)\n\
- `deprecated' obsolete constructs\n\
- `other' all other warnings (enabled by default)\n\
- `all' all the warnings\n\
- `no-CATEGORY' turn off warnings in CATEGORY\n\
- `none' turn off all the warnings\n\
- `error' treat warnings as errors\n\
+ `midrule-values' unset or unused midrule values\n\
+ `yacc' incompatibilities with POSIX Yacc\n\
+ `conflicts-sr' S/R conflicts (enabled by default)\n\
+ `conflicts-rr' R/R conflicts (enabled by default)\n\
+ `deprecated' obsolete constructs\n\
+ `other' all other warnings (enabled by default)\n\
+ `all' all the warnings\n\
+ `no-CATEGORY' turn off warnings in CATEGORY\n\
+ `none' turn off all the warnings\n\
+ `error[=CATEGORY]' treat warnings as errors\n\
"), stdout);
putc ('\n', stdout);
Note we still output for 'C' so that it gets included in the
man page. */
const char *lc_messages = setlocale (LC_MESSAGES, NULL);
- if (lc_messages && strcmp (lc_messages, "en_"))
+ if (lc_messages && !STREQ (lc_messages, "en_"))
/* TRANSLATORS: Replace LANG_CODE in this URL with your language
code <http://translationproject.org/team/LANG_CODE.html> to
form one of the URLs at http://translationproject.org/team/.
putc ('\n', stdout);
fprintf (stdout,
- _("Copyright (C) %d Free Software Foundation, Inc.\n"),
- PACKAGE_COPYRIGHT_YEAR);
+ _("Copyright (C) %d Free Software Foundation, Inc.\n"),
+ PACKAGE_COPYRIGHT_YEAR);
fputs (_("\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"),
- stdout);
+ stdout);
}
skeleton = arg;
}
else if (prio == skeleton_prio)
- complain_at (loc, _("multiple skeleton declarations are invalid"));
+ complain (&loc, complaint,
+ _("multiple skeleton declarations are invalid"));
}
void
else
return;
- complain_at (loc, msg, quotearg_colon (arg));
+ complain (&loc, complaint, msg, quotearg_colon (arg));
}
/*----------------------.
static struct option const long_options[] =
{
/* Operation modes. */
- { "help", no_argument, 0, 'h' },
- { "version", no_argument, 0, 'V' },
- { "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
- { "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
+ { "help", no_argument, 0, 'h' },
+ { "version", no_argument, 0, 'V' },
+ { "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
+ { "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
{ "warnings", optional_argument, 0, 'W' },
/* Parser. */
- { "name-prefix", required_argument, 0, 'p' },
+ { "name-prefix", required_argument, 0, 'p' },
{ "include", required_argument, 0, 'I' },
/* Output. */
- { "file-prefix", required_argument, 0, 'b' },
- { "output", required_argument, 0, 'o' },
- { "output-file", required_argument, 0, 'o' },
- { "graph", optional_argument, 0, 'g' },
+ { "file-prefix", required_argument, 0, 'b' },
+ { "output", required_argument, 0, 'o' },
+ { "output-file", required_argument, 0, 'o' },
+ { "graph", optional_argument, 0, 'g' },
{ "xml", optional_argument, 0, 'x' },
- { "report", required_argument, 0, 'r' },
+ { "report", required_argument, 0, 'r' },
{ "report-file", required_argument, 0, REPORT_FILE_OPTION },
- { "verbose", no_argument, 0, 'v' },
+ { "verbose", no_argument, 0, 'v' },
/* Hidden. */
{ "trace", optional_argument, 0, 'T' },
/* Operation modes. */
{ "fixed-output-files", no_argument, 0, 'y' },
- { "yacc", no_argument, 0, 'y' },
+ { "yacc", no_argument, 0, 'y' },
/* Parser. */
- { "debug", no_argument, 0, 't' },
- { "define", required_argument, 0, 'D' },
+ { "debug", no_argument, 0, 't' },
+ { "define", required_argument, 0, 'D' },
{ "force-define", required_argument, 0, 'F' },
- { "locations", no_argument, 0, LOCATIONS_OPTION },
+ { "locations", no_argument, 0, LOCATIONS_OPTION },
{ "no-lines", no_argument, 0, 'l' },
{ "raw", no_argument, 0, 0 },
{ "skeleton", required_argument, 0, 'S' },
int c;
while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
- != -1)
+ != -1)
switch (c)
{
/* ASCII Sorting for short options (i.e., upper case then
lower case), and then long-only options. */
case 0:
- /* Certain long options cause getopt_long to return 0. */
- break;
+ /* Certain long options cause getopt_long to return 0. */
+ break;
case 'D': /* -DNAME[=VALUE]. */
case 'F': /* -FNAME[=VALUE]. */
{
char* name = optarg;
- char* value = mbschr (optarg, '=');
+ char* value = strchr (optarg, '=');
if (value)
*value++ = 0;
muscle_percent_define_insert (name, command_line_location (),
c == 'D' ? MUSCLE_PERCENT_DEFINE_D
: MUSCLE_PERCENT_DEFINE_F);
}
- break;
+ break;
case 'I':
- include = AS_FILE_NAME (optarg);
- break;
+ include = AS_FILE_NAME (optarg);
+ break;
case 'L':
- language_argmatch (optarg, command_line_prio,
- command_line_location ());
- break;
+ language_argmatch (optarg, command_line_prio,
+ command_line_location ());
+ break;
case 'S':
- skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
- command_line_location ());
- break;
+ skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
+ command_line_location ());
+ break;
case 'T':
- FLAGS_ARGMATCH (trace, optarg);
- break;
+ FLAGS_ARGMATCH (trace, optarg, trace_all);
+ break;
case 'V':
- version ();
- exit (EXIT_SUCCESS);
+ version ();
+ exit (EXIT_SUCCESS);
case 'f':
- FLAGS_ARGMATCH (feature, optarg);
+ FLAGS_ARGMATCH (feature, optarg, feature_all);
break;
case 'W':
- FLAGS_ARGMATCH (warnings, optarg);
- break;
+ FLAGS_ARGMATCH (warnings, optarg, Wall);
+ break;
case 'b':
- spec_file_prefix = AS_FILE_NAME (optarg);
- break;
+ spec_file_prefix = AS_FILE_NAME (optarg);
+ break;
case 'd':
/* Here, the -d and --defines options are differentiated. */
break;
case 'g':
- graph_flag = true;
- if (optarg)
+ graph_flag = true;
+ if (optarg)
{
free (spec_graph_file);
spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
}
- break;
+ break;
case 'h':
- usage (EXIT_SUCCESS);
+ usage (EXIT_SUCCESS);
case 'k':
- token_table_flag = true;
- break;
+ token_table_flag = true;
+ break;
case 'l':
- no_lines_flag = true;
- break;
+ no_lines_flag = true;
+ break;
case 'o':
- spec_outfile = AS_FILE_NAME (optarg);
- break;
+ spec_outfile = AS_FILE_NAME (optarg);
+ break;
case 'p':
- spec_name_prefix = optarg;
- break;
+ spec_name_prefix = optarg;
+ break;
case 'r':
- FLAGS_ARGMATCH (report, optarg);
- break;
+ FLAGS_ARGMATCH (report, optarg, report_all);
+ break;
case 't':
- debug = true;
- break;
+ muscle_percent_define_insert ("parse.trace",
+ command_line_location (), "",
+ MUSCLE_PERCENT_DEFINE_D);
+ break;
case 'v':
- report_flag |= report_states;
- break;
+ report_flag |= report_states;
+ break;
case 'x':
- xml_flag = true;
- if (optarg)
+ xml_flag = true;
+ if (optarg)
{
free (spec_xml_file);
spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
}
- break;
+ break;
case 'y':
- yacc_flag = true;
- break;
+ warnings_flag |= Wyacc;
+ errors_flag |= Wyacc;
+ yacc_flag = true;
+ break;
case LOCATIONS_OPTION:
- locations_flag = true;
- break;
+ muscle_percent_define_ensure ("locations",
+ command_line_location (), true);
+ break;
case PRINT_LOCALEDIR_OPTION:
- printf ("%s\n", LOCALEDIR);
- exit (EXIT_SUCCESS);
+ printf ("%s\n", LOCALEDIR);
+ exit (EXIT_SUCCESS);
case PRINT_DATADIR_OPTION:
- printf ("%s\n", compute_pkgdatadir ());
- exit (EXIT_SUCCESS);
+ printf ("%s\n", pkgdatadir ());
+ exit (EXIT_SUCCESS);
case REPORT_FILE_OPTION:
free (spec_verbose_file);
- spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
- break;
+ spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
+ break;
default:
- usage (EXIT_FAILURE);
+ usage (EXIT_FAILURE);
}
if (argc - optind != 1)
/* for -I */
extern char const *include;
-extern bool debug; /* for -t */
-extern bool defines_flag; /* for -d */
-extern bool graph_flag; /* for -g */
-extern bool xml_flag; /* for -x */
-extern bool locations_flag;
-extern bool no_lines_flag; /* for -l */
-extern bool token_table_flag; /* for -k */
-extern bool yacc_flag; /* for -y */
-
-extern bool error_verbose;
+extern bool defines_flag; /* for -d */
+extern bool graph_flag; /* for -g */
+extern bool xml_flag; /* for -x */
+extern bool no_lines_flag; /* for -l */
+extern bool token_table_flag; /* for -k */
+extern bool yacc_flag; /* for -y */
/* GLR_PARSER is true if the input file says to use the GLR
/** What debug items bison displays during its run. */
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. |
`-------------*/
{
int n;
for (n = strlen (previous_lhs->tag); n > 0; --n)
- fputc (' ', out);
+ fputc (' ', out);
fputc ('|', out);
}
}
xml_printf (out, level, "<lhs>%s</lhs>", r->lhs->tag);
}
-int
+size_t
rule_rhs_length (rule *r)
{
- int res = 0;
+ size_t res = 0;
item_number *rhsp;
for (rhsp = r->rhs; *rhsp >= 0; ++rhsp)
++res;
{
item_number *rp;
for (rp = r->rhs; *rp >= 0; rp++)
- fprintf (out, " %s", symbols[*rp]->tag);
- fputc ('\n', out);
+ fprintf (out, " %s", symbols[*rp]->tag);
}
else
{
- fprintf (out, " /* %s */\n", _("empty"));
+ fprintf (out, " /* %s */", _("empty"));
}
}
item_number *rp;
xml_puts (out, level, "<rhs>");
for (rp = r->rhs; *rp >= 0; rp++)
- xml_printf (out, level + 1, "<symbol>%s</symbol>",
- xml_escape (symbols[*rp]->tag));
+ xml_printf (out, level + 1, "<symbol>%s</symbol>",
+ xml_escape (symbols[*rp]->tag));
xml_puts (out, level, "</rhs>");
}
else
}
}
-void
+static void
rule_print (rule *r, FILE *out)
{
fprintf (out, "%s:", r->lhs->tag);
{
int length = rule_rhs_length (&rules[r]);
if (length > max)
- max = length;
+ max = length;
}
return max;
void
grammar_rules_partial_print (FILE *out, const char *title,
- rule_filter filter)
+ rule_filter filter)
{
rule_number r;
bool first = true;
for (r = 0; r < nrules + nuseless_productions; r++)
{
if (filter && !filter (&rules[r]))
- continue;
+ continue;
if (first)
- fprintf (out, "%s\n\n", title);
+ fprintf (out, "%s\n\n", title);
else if (previous_lhs && previous_lhs != rules[r].lhs)
- fputc ('\n', out);
+ fputc ('\n', out);
first = false;
rule_lhs_print (&rules[r], previous_lhs, out);
rule_rhs_print (&rules[r], out);
+ fprintf (out, "\n");
previous_lhs = rules[r].lhs;
}
if (!first)
for (r = 0; r < nrules + nuseless_productions; r++)
{
if (first)
- xml_puts (out, level + 1, "<rules>");
+ xml_puts (out, level + 1, "<rules>");
first = false;
{
char const *usefulness;
{
fprintf (out, "%s\n\n", title);
fprintf (out,
- "ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
- ntokens, nvars, nsyms, nrules, nritems);
+ "ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
+ ntokens, nvars, nsyms, nrules, nritems);
fprintf (out, "Variables\n---------\n\n");
for (i = ntokens; i < nsyms; i++)
fprintf (out, "%5d %5d %5d %s\n",
- i,
- symbols[i]->prec, symbols[i]->assoc,
- symbols[i]->tag);
+ i,
+ symbols[i]->prec, symbols[i]->assoc,
+ symbols[i]->tag);
fprintf (out, "\n\n");
}
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
for (i = 0; i < nrules + nuseless_productions; i++)
{
- rule *rule_i = &rules[i];
- item_number *rp = NULL;
- unsigned int rhs_itemno = rule_i->rhs - ritem;
- unsigned int rhs_count = 0;
- /* Find the last RHS index in ritems. */
- for (rp = rule_i->rhs; *rp >= 0; ++rp)
- ++rhs_count;
- fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
- i,
- rule_i->prec ? rule_i->prec->prec : 0,
- rule_i->prec ? rule_i->prec->assoc : 0,
- rule_i->useful,
- rhs_itemno,
- rhs_itemno + rhs_count - 1,
- rule_i->lhs->number);
- /* Dumped the RHS. */
- for (rp = rule_i->rhs; *rp >= 0; rp++)
- fprintf (out, " %3d", *rp);
- fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
+ rule *rule_i = &rules[i];
+ item_number *rp = NULL;
+ unsigned int rhs_itemno = rule_i->rhs - ritem;
+ unsigned int rhs_count = 0;
+ /* Find the last RHS index in ritems. */
+ for (rp = rule_i->rhs; *rp >= 0; ++rp)
+ ++rhs_count;
+ fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
+ i,
+ rule_i->prec ? rule_i->prec->prec : 0,
+ rule_i->prec ? rule_i->prec->assoc : 0,
+ rule_i->useful,
+ rhs_itemno,
+ rhs_itemno + rhs_count - 1,
+ rule_i->lhs->number);
+ /* Dumped the RHS. */
+ for (rp = rule_i->rhs; *rp >= 0; rp++)
+ fprintf (out, " %3d", *rp);
+ fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
}
}
fprintf (out, "\n\n");
rule_number r;
for (r = 0; r < nrules + nuseless_productions; r++)
{
- fprintf (out, "%-5d ", r);
- rule_print (&rules[r], out);
+ fprintf (out, "%-5d ", r);
+ rule_print (&rules[r], out);
+ fprintf (out, "\n");
}
}
fprintf (out, "\n\n");
void
grammar_rules_useless_report (const char *message)
{
- rule_number r;
- for (r = 0; r < nrules ; ++r)
- if (!rules[r].useful)
- {
- if (feature_flag & feature_caret)
- warn_at (rules[r].location, "%s", message);
- else
+ warnings w = Wother;
+ if (warnings_flag & w)
+ {
+ rule_number r;
+ for (r = 0; r < nrules ; ++r)
+ if (!rules[r].useful)
{
- warn_at (rules[r].location, "%s: ", message);
- if (warnings_flag & warnings_other)
+ if (feature_flag & feature_caret)
+ complain (&rules[r].location, w, "%s", message);
+ else
{
+ complain (&rules[r].location, w | silent, "%s: ", message);
rule_print (&rules[r], stderr);
- fflush (stderr);
+ warnings_print_categories (w);
+ fprintf (stderr, "\n");
}
}
- }
+ }
}
void
# include "location.h"
# include "symtab.h"
-# define ISTOKEN(i) ((i) < ntokens)
-# define ISVAR(i) ((i) >= ntokens)
+# define ISTOKEN(i) ((i) < ntokens)
+# define ISVAR(i) ((i) >= ntokens)
extern int nsyms;
extern int ntokens;
location location;
bool useful;
+ bool is_predicate;
const char *action;
location action_location;
void rule_lhs_print_xml (rule *r, FILE *out, int level);
/* Return the length of the RHS. */
-int rule_rhs_length (rule *r);
+size_t rule_rhs_length (rule *r);
/* Print this rule's RHS on OUT. */
void rule_rhs_print (rule *r, FILE *out);
-/* Print this rule on OUT. */
-void rule_print (rule *r, FILE *out);
-
/* Print the grammar's rules that match FILTER on OUT under TITLE. */
void grammar_rules_partial_print (FILE *out, const char *title,
- rule_filter filter);
+ rule_filter filter);
/* Print the grammar's useful rules on OUT. */
void grammar_rules_print (FILE *out);
/* Examine user options. */
{
char *type = muscle_percent_define_get ("lr.type");
- if (0 == strcmp (type, "lalr"))
+ if (STREQ (type, "lalr"))
lr_type = LR_TYPE__LALR;
- else if (0 == strcmp (type, "ielr"))
+ else if (STREQ (type, "ielr"))
lr_type = LR_TYPE__IELR;
- else if (0 == strcmp (type, "canonical-lr"))
+ else if (STREQ (type, "canonical-lr"))
lr_type = LR_TYPE__CANONICAL_LR;
else
aver (false);
transitions *sp = states[s]->transitions;
int i;
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
- {
- ngotos++;
+ {
+ ngotos++;
- /* Abort if (ngotos + 1) would overflow. */
- aver (ngotos != GOTO_NUMBER_MAXIMUM);
+ /* Abort if (ngotos + 1) would overflow. */
+ aver (ngotos != GOTO_NUMBER_MAXIMUM);
- goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
- }
+ goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
+ }
}
{
int i;
for (i = ntokens; i < nsyms; i++)
{
- temp_map[i - ntokens] = k;
- k += goto_map[i - ntokens];
+ temp_map[i - ntokens] = k;
+ k += goto_map[i - ntokens];
}
for (i = ntokens; i < nsyms; i++)
transitions *sp = states[s]->transitions;
int i;
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
- {
- goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
- from_state[k] = s;
- to_state[k] = sp->states[i]->number;
- }
+ {
+ goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
+ from_state[k] = s;
+ to_state[k] = sp->states[i]->number;
+ }
}
free (temp_map);
middle = (low + high) / 2;
s = from_state[middle];
if (s == s0)
- return middle;
+ return middle;
else if (s < s0)
- low = middle + 1;
+ low = middle + 1;
else
- high = middle - 1;
+ high = middle - 1;
}
}
int j;
FOR_EACH_SHIFT (sp, j)
- bitset_set (goto_follows[i], TRANSITION_SYMBOL (sp, j));
+ bitset_set (goto_follows[i], TRANSITION_SYMBOL (sp, j));
for (; j < sp->num; j++)
- {
- symbol_number sym = TRANSITION_SYMBOL (sp, j);
- if (nullable[sym - ntokens])
- edge[nedges++] = map_goto (stateno, sym);
- }
+ {
+ symbol_number sym = TRANSITION_SYMBOL (sp, j);
+ if (nullable[sym - ntokens])
+ edge[nedges++] = map_goto (stateno, sym);
+ }
if (nedges == 0)
- reads[i] = NULL;
+ reads[i] = NULL;
else
- {
- reads[i] = xnmalloc (nedges + 1, sizeof reads[i][0]);
- memcpy (reads[i], edge, nedges * sizeof edge[0]);
- reads[i][nedges] = END_NODE;
- nedges = 0;
- }
+ {
+ reads[i] = xnmalloc (nedges + 1, sizeof reads[i][0]);
+ memcpy (reads[i], edge, nedges * sizeof edge[0]);
+ reads[i][nedges] = END_NODE;
+ nedges = 0;
+ }
}
relation_digraph (reads, ngotos, &goto_follows);
rule **rulep;
for (rulep = derives[symbol1 - ntokens]; *rulep; rulep++)
- {
- bool done;
- int length = 1;
- item_number const *rp;
- state *s = states[from_state[i]];
- states1[0] = s->number;
-
- for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++)
- {
- s = transitions_to (s->transitions,
- item_number_as_symbol_number (*rp));
- states1[length++] = s->number;
- }
-
- if (!s->consistent)
- add_lookback_edge (s, *rulep, i);
-
- length--;
- done = false;
- while (!done)
- {
- done = true;
- /* Each rhs ends in a rule number, and there is a
- sentinel (ritem[-1]=0) before the first rhs, so it is safe to
- decrement RP here. */
- rp--;
- if (ISVAR (*rp))
- {
- /* Downcasting from item_number to symbol_number. */
- edge[nedges++] = map_goto (states1[--length],
- item_number_as_symbol_number (*rp));
- if (nullable[*rp - ntokens])
- done = false;
- }
- }
- }
+ {
+ bool done;
+ int length = 1;
+ item_number const *rp;
+ state *s = states[from_state[i]];
+ states1[0] = s->number;
+
+ for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++)
+ {
+ s = transitions_to (s->transitions,
+ item_number_as_symbol_number (*rp));
+ states1[length++] = s->number;
+ }
+
+ if (!s->consistent)
+ add_lookback_edge (s, *rulep, i);
+
+ length--;
+ done = false;
+ while (!done)
+ {
+ done = true;
+ /* Each rhs ends in a rule number, and there is a
+ sentinel (ritem[-1]=0) before the first rhs, so it is safe to
+ decrement RP here. */
+ rp--;
+ if (ISVAR (*rp))
+ {
+ /* Downcasting from item_number to symbol_number. */
+ edge[nedges++] = map_goto (states1[--length],
+ item_number_as_symbol_number (*rp));
+ if (nullable[*rp - ntokens])
+ done = false;
+ }
+ }
+ }
if (nedges == 0)
- includes[i] = NULL;
+ includes[i] = NULL;
else
- {
- int j;
- includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
- for (j = 0; j < nedges; j++)
- includes[i][j] = edge[j];
- includes[i][nedges] = END_NODE;
- }
+ {
+ int j;
+ includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
+ for (j = 0; j < nedges; j++)
+ includes[i][j] = edge[j];
+ includes[i][nedges] = END_NODE;
+ }
}
free (edge);
bool default_reduction_only_for_accept;
{
char *default_reductions =
- muscle_percent_define_get ("lr.default-reductions");
- default_reduction_only_for_accept =
- 0 == strcmp (default_reductions, "accepting");
+ muscle_percent_define_get ("lr.default-reduction");
+ default_reduction_only_for_accept = STREQ (default_reductions, "accepting");
free (default_reductions);
}
state_lookahead_tokens_count (states[i],
default_reduction_only_for_accept);
if (count)
- {
- states[i]->reductions->lookahead_tokens = pLA;
- pLA += count;
- }
+ {
+ states[i]->reductions->lookahead_tokens = pLA;
+ pLA += count;
+ }
}
}
int n_lookahead_tokens = 0;
if (reds->lookahead_tokens)
- for (k = 0; k < reds->num; ++k)
- if (reds->lookahead_tokens[k])
- ++n_lookahead_tokens;
+ for (k = 0; k < reds->num; ++k)
+ if (reds->lookahead_tokens[k])
+ ++n_lookahead_tokens;
fprintf (out, "State %d: %d lookahead tokens\n",
- i, n_lookahead_tokens);
+ i, n_lookahead_tokens);
if (reds->lookahead_tokens)
- for (j = 0; j < reds->num; ++j)
- BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0)
- {
- fprintf (out, " on %d (%s) -> rule %d\n",
- k, symbols[k]->tag,
- reds->rules[j]->number);
- };
+ for (j = 0; j < reds->num; ++j)
+ BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0)
+ {
+ fprintf (out, " on %d (%s) -> rule %d\n",
+ k, symbols[k]->tag,
+ reds->rules[j]->number);
+ };
}
fprintf (out, "Lookahead tokens: END\n");
}
--- /dev/null
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+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 $@
if (buf)
{
if (INT_MAX / 2 <= bufsize)
- return INT_MAX;
+ return INT_MAX;
width = mbsnwidth (buf, bufsize, 0);
}
else
switch (*p)
{
case '\n':
- line += line < INT_MAX;
- column = 1;
- p0 = p + 1;
- break;
+ line += line < INT_MAX;
+ column = 1;
+ p0 = p + 1;
+ break;
case '\t':
- column = add_column_width (column, p0, p - p0);
- column = add_column_width (column, NULL, 8 - ((column - 1) & 7));
- p0 = p + 1;
- break;
+ column = add_column_width (column, p0, p - p0);
+ column = add_column_width (column, NULL, 8 - ((column - 1) & 7));
+ p0 = p + 1;
+ break;
default:
- break;
+ break;
}
cur->line = line;
loc->end = *cur;
if (line == INT_MAX && loc->start.line != INT_MAX)
- warn_at (*loc, _("line number overflow"));
+ complain (loc, Wother, _("line number overflow"));
if (column == INT_MAX && loc->start.column != INT_MAX)
- warn_at (*loc, _("column number overflow"));
+ complain (loc, Wother, _("column number overflow"));
}
{
/* Must search in reverse since the file name field may
* contain `.' or `:'. */
- char *delim = mbsrchr (loc_str, '.');
+ char *delim = strrchr (loc_str, '.');
aver (delim);
*delim = '\0';
bound->column = atoi (delim+1);
- delim = mbsrchr (loc_str, ':');
+ delim = strrchr (loc_str, ':');
aver (delim);
*delim = '\0';
bound->line = atoi (delim+1);
equal_boundaries (boundary a, boundary b)
{
return (a.column == b.column
- && a.line == b.line
- && UNIQSTR_EQ (a.file, b.file));
+ && a.line == b.line
+ && UNIQSTR_EQ (a.file, b.file));
}
/* A location, that is, a region of source code. */
/* Set *LOC and adjust scanner cursor to account for token TOKEN of
size SIZE. */
void location_compute (location *loc,
- boundary *cur, char const *token, size_t size);
+ boundary *cur, char const *token, size_t size);
/* Print location to file. Return number of actually printed
characters. */
{
char const *cp = getenv ("LC_CTYPE");
- if (cp && !strcmp (cp, "C"))
+ if (cp && STREQ (cp, "C"))
set_custom_quoting ("e_quoting_options, "'", "'");
else
set_quoting_style ("e_quoting_options, locale_quoting_style);
reader ();
timevar_pop (TV_READER);
- if (complaint_issued)
+ if (complaint_status == status_complaint)
goto finish;
/* Find useless nonterminals and productions and reduce the grammar. */
declarations. */
timevar_push (TV_CONFLICTS);
conflicts_solve ();
- if (!muscle_percent_define_flag_if ("lr.keep-unreachable-states"))
+ if (!muscle_percent_define_flag_if ("lr.keep-unreachable-state"))
{
state_number *old_to_new = xnmalloc (nstates, sizeof *old_to_new);
state_number nstates_old = nstates;
tables_generate ();
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"));
/* Output file names. */
compute_output_file_names ();
/* Stop if there were errors, to avoid trashing previous output
files. */
- if (complaint_issued)
+ if (complaint_status == status_complaint)
goto finish;
/* Lookahead tokens are no longer needed. */
cleanup_caret ();
- return complaint_issued ? EXIT_FAILURE : EXIT_SUCCESS;
+ return complaint_status ? EXIT_FAILURE : EXIT_SUCCESS;
}
{
muscle_entry const *m1 = x;
muscle_entry const *m2 = y;
- return strcmp (m1->key, m2->key) == 0;
+ return STREQ (m1->key, m2->key);
}
static size_t
obstack_init (&muscle_obstack);
muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
- hash_compare_muscles, muscle_entry_free);
+ hash_compare_muscles, muscle_entry_free);
/* Version and input file. */
MUSCLE_INSERT_STRING ("version", VERSION);
{
/* Grow the current value. */
char *new_val;
- obstack_sgrow (&muscle_obstack, entry->value);
+ obstack_printf (&muscle_obstack, "%s%s%s", entry->value, separator, val);
free (entry->storage);
- obstack_sgrow (&muscle_obstack, separator);
- obstack_sgrow (&muscle_obstack, val);
- obstack_1grow (&muscle_obstack, 0);
- new_val = obstack_finish (&muscle_obstack);
+ new_val = obstack_finish0 (&muscle_obstack);
entry->value = entry->storage = xstrdup (new_val);
obstack_free (&muscle_obstack, new_val);
}
obstack_quote (&muscle_obstack,
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, ")[");
- obstack_1grow (&muscle_obstack, 0);
- extension = obstack_finish (&muscle_obstack);
+ extension = obstack_finish0 (&muscle_obstack);
muscle_grow (key, extension, "");
obstack_free (&muscle_obstack, extension);
}
void muscle_pair_list_grow (const char *muscle,
- const char *a1, const char *a2)
+ const char *a1, const char *a2)
{
char *pair;
obstack_sgrow (&muscle_obstack, "[");
obstack_sgrow (&muscle_obstack, ", ");
obstack_quote (&muscle_obstack, a2);
obstack_sgrow (&muscle_obstack, "]");
- obstack_1grow (&muscle_obstack, 0);
- pair = obstack_finish (&muscle_obstack);
+ pair = obstack_finish0 (&muscle_obstack);
muscle_grow (muscle, pair, ",\n");
obstack_free (&muscle_obstack, pair);
}
char *extension;
obstack_sgrow (&muscle_obstack, "[[");
obstack_escape (&muscle_obstack, bound.file);
- obstack_1grow (&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);
+ obstack_printf (&muscle_obstack, ":%d.%d]]", bound.line, bound.column);
+ extension = obstack_finish0 (&muscle_obstack);
muscle_grow (key, extension, "");
obstack_free (&muscle_obstack, extension);
}
static char *
string_decode (char const *key)
{
- char const *value;
+ char const *value = muscle_find_const (key);
char *value_decoded;
char *result;
- value = muscle_find_const (key);
if (!value)
return NULL;
do {
{
char *boundary_str;
aver (*++value == ']');
- obstack_1grow (&muscle_obstack, '\0');
- boundary_str = obstack_finish (&muscle_obstack);
+ boundary_str = obstack_finish0 (&muscle_obstack);
switch (*++value)
{
case ',':
* otherwise \a variable. */
static
char const *
-muscle_percent_variable_update (char const *variable)
+muscle_percent_variable_update (char const *variable, location variable_loc)
{
typedef struct
{
const conversion_type conversion[] =
{
{ "api.push_pull", "api.push-pull", },
+ { "api.tokens.prefix", "api.token.prefix", },
{ "location_type", "api.location.type", },
- { "lr.keep_unreachable_states", "lr.keep-unreachable-states", },
+ { "lr.default-reductions", "lr.default-reduction", },
+ { "lr.keep-unreachable-states", "lr.keep-unreachable-state", },
+ { "lr.keep_unreachable_states", "lr.keep-unreachable-state", },
+ { "namespace", "api.namespace", },
};
char const *res = variable;
int i;
if (STREQ (conversion[i].obsolete, variable))
{
res = conversion[i].updated;
+ complain (&variable_loc, Wdeprecated,
+ _("deprecated %%define variable name: %s, use %s"),
+ quote (variable), quote_n (1, res));
break;
}
return res;
muscle_percent_define_how how)
{
/* Backward compatibility. */
- char const *variable = muscle_percent_variable_update (var);
+ char const *variable = muscle_percent_variable_update (var, variable_loc);
char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
char const *syncline_name =
if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
&& muscle_find_const (name))
{
+ muscle_percent_define_how how_old = atoi (muscle_find_const (how_name));
unsigned i = 0;
- muscle_percent_define_how how_old =
- atoi (muscle_find_const (how_name));
if (how_old == MUSCLE_PERCENT_DEFINE_F)
return;
- complain_at_indent (variable_loc, &i,
- _("%%define variable %s redefined"), quote (variable));
+ complain_indent (&variable_loc, complaint, &i,
+ _("%%define variable %s redefined"),
+ quote (variable));
i += SUB_INDENT;
- complain_at_indent (muscle_percent_define_get_loc (variable), &i,
- _("previous definition"));
+ location loc = muscle_percent_define_get_loc (variable);
+ complain_indent (&loc, complaint, &i, _("previous definition"));
}
MUSCLE_INSERT_STRING (name, value);
MUSCLE_INSERT_INT (how_name, how);
}
-char *
-muscle_percent_define_get (char const *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 *name;
- char const *usage_name;
- char *value;
+ char const *val = value ? "" : "false";
+ char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
- name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
- usage_name = UNIQSTR_CONCAT ("percent_define_bison_variables(",
- 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);
+}
- muscle_insert (usage_name, "");
- value = string_decode (name);
+char *
+muscle_percent_define_get (char const *variable)
+{
+ char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
+ char const *usage_name =
+ UNIQSTR_CONCAT ("percent_define_bison_variables(", variable, ")");
+ char *value = string_decode (name);
if (!value)
value = xstrdup ("");
+
+ muscle_insert (usage_name, "");
return value;
}
location
muscle_percent_define_get_loc (char const *variable)
{
- char const *loc_name;
- loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
+ char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
if (!muscle_find_const (loc_name))
- fatal(_("%s: undefined %%define variable %s"),
- "muscle_percent_define_get_loc", quote (variable));
+ complain (NULL, fatal, _("%s: undefined %%define variable %s"),
+ "muscle_percent_define_get_loc", quote (variable));
return location_decode (loc_name);
}
char const *
muscle_percent_define_get_syncline (char const *variable)
{
- char const *syncline_name;
- char const *syncline;
- syncline_name =
+ char const *syncline_name =
UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
- syncline = muscle_find_const (syncline_name);
+ char const *syncline = muscle_find_const (syncline_name);
if (!syncline)
- fatal(_("%s: undefined %%define variable %s"),
- "muscle_percent_define_get_syncline", quote (variable));
+ complain (NULL, fatal, _("%s: undefined %%define variable %s"),
+ "muscle_percent_define_get_syncline", quote (variable));
return syncline;
}
bool
muscle_percent_define_ifdef (char const *variable)
{
- char const *name;
- char const *usage_name;
- char const *value;
-
- name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
- usage_name =
+ char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
+ char const *usage_name =
UNIQSTR_CONCAT ("percent_define_bison_variables(", variable, ")");
-
- value = muscle_find_const (name);
+ char const *value = muscle_find_const (name);
if (value)
{
muscle_insert (usage_name, "");
bool
muscle_percent_define_flag_if (char const *variable)
{
- char const *invalid_boolean_name;
- bool result = false;
-
- invalid_boolean_name =
+ char const *invalid_boolean_name =
UNIQSTR_CONCAT ("percent_define_invalid_boolean(", variable, ")");
+ bool result = false;
if (muscle_percent_define_ifdef (variable))
{
char *value = muscle_percent_define_get (variable);
- if (value[0] == '\0' || 0 == strcmp (value, "true"))
+ if (value[0] == '\0' || STREQ (value, "true"))
result = true;
- else if (0 == strcmp (value, "false"))
+ else if (STREQ (value, "false"))
result = false;
else if (!muscle_find_const (invalid_boolean_name))
{
muscle_insert (invalid_boolean_name, "");
- complain_at(muscle_percent_define_get_loc (variable),
- _("invalid value for %%define Boolean variable %s"),
- quote (variable));
+ location loc = muscle_percent_define_get_loc (variable);
+ complain (&loc, complaint,
+ _("invalid value for %%define Boolean variable %s"),
+ quote (variable));
}
free (value);
}
else
- fatal(_("%s: undefined %%define variable %s"),
- "muscle_percent_define_flag", quote (variable));
+ complain (NULL, fatal, _("%s: undefined %%define variable %s"),
+ "muscle_percent_define_flag", quote (variable));
return result;
}
void
muscle_percent_define_default (char const *variable, char const *value)
{
- char const *name;
- char const *loc_name;
- char const *syncline_name;
- name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
- loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
- syncline_name =
+ char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
+ char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
+ char const *syncline_name =
UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
if (!muscle_find_const (name))
{
for (; *values; ++values)
{
char const * const *variablep = values;
- char const *name;
- char *value;
-
- name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
-
- value = string_decode (name);
+ char const *name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
+ char *value = string_decode (name);
if (value)
{
for (++values; *values; ++values)
{
- if (0 == strcmp (value, *values))
+ if (STREQ (value, *values))
break;
}
if (!*values)
{
unsigned i = 0;
location loc = muscle_percent_define_get_loc (*variablep);
- complain_at_indent (loc, &i,
- _("invalid value for %%define variable %s: %s"),
- quote (*variablep), quote_n (1, value));
+ complain_indent (&loc, complaint, &i,
+ _("invalid value for %%define variable %s: %s"),
+ quote (*variablep), quote_n (1, value));
i += SUB_INDENT;
for (values = variablep + 1; *values; ++values)
- complain_at_indent (loc, &i, _("accepted value: %s"),
- quote (*values));
+ complain_indent (&loc, complaint, &i, _("accepted value: %s"),
+ quote (*values));
}
else
{
free (value);
}
else
- fatal (_("%s: undefined %%define variable %s"),
- "muscle_percent_define_check_values", quote (*variablep));
+ complain (NULL, fatal, _("%s: undefined %%define variable %s"),
+ "muscle_percent_define_check_values", quote (*variablep));
}
}
muscle_percent_code_grow (char const *qualifier, location qualifier_loc,
char const *code, location code_loc)
{
- char const *name;
- name = UNIQSTR_CONCAT ("percent_code(", qualifier, ")");
+ char const *name = UNIQSTR_CONCAT ("percent_code(", qualifier, ")");
muscle_code_grow (name, code, code_loc);
muscle_user_name_list_grow ("percent_code_user_qualifiers", qualifier,
qualifier_loc);
static inline bool
muscle_m4_output (muscle_entry *entry, FILE *out)
{
- fprintf (out, "m4_define([b4_%s],\n", entry->key);
- fprintf (out, "[[%s]])\n\n\n", entry->value);
+ fprintf (out,
+ "m4_define([b4_%s],\n"
+ "[[%s]])\n\n\n", entry->key, entry->value);
return true;
}
/* Muscle table manager for Bison,
- Copyright (C) 2001-2003, 2006-2007, 2009-2012 Free Software
- Foundation, Inc.
+ Copyright (C) 2001-2003, 2006-2012 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
#define MUSCLE_INSERT_BOOL(Key, Value) \
do { \
- int v = Value; \
- MUSCLE_INSERT_INT (Key, v); \
+ int v__ = Value; \
+ MUSCLE_INSERT_INT (Key, v__); \
} while (0)
-#define MUSCLE_INSERT_INT(Key, Value) \
+#define MUSCLE_INSERTF(Key, Format, Value) \
do { \
- obstack_printf (&muscle_obstack, "%d", Value); \
- obstack_1grow (&muscle_obstack, 0); \
- muscle_insert (Key, obstack_finish (&muscle_obstack)); \
+ obstack_printf (&muscle_obstack, Format, Value); \
+ muscle_insert (Key, obstack_finish0 (&muscle_obstack)); \
} while (0)
+#define MUSCLE_INSERT_INT(Key, Value) \
+ MUSCLE_INSERTF(Key, "%d", Value)
+
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
- do { \
- obstack_printf (&muscle_obstack, "%ld", Value); \
- obstack_1grow (&muscle_obstack, 0); \
- muscle_insert (Key, obstack_finish (&muscle_obstack)); \
- } while (0)
+ MUSCLE_INSERTF(Key, "%ld", Value)
+/* Key -> Value, but don't apply escaping to Value. */
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
- do { \
- obstack_sgrow (&muscle_obstack, Value); \
- obstack_1grow (&muscle_obstack, 0); \
- muscle_insert (Key, obstack_finish (&muscle_obstack)); \
- } while (0)
+ MUSCLE_INSERTF(Key, "%s", Value)
+/* Key -> Value, applying M4 escaping to Value. */
#define MUSCLE_INSERT_STRING(Key, Value) \
do { \
obstack_escape (&muscle_obstack, Value); \
- obstack_1grow (&muscle_obstack, 0); \
- muscle_insert (Key, obstack_finish (&muscle_obstack)); \
+ muscle_insert (Key, obstack_finish0 (&muscle_obstack)); \
} while (0)
#define MUSCLE_INSERT_C_STRING(Key, Value) \
do { \
obstack_escape (&muscle_obstack, \
quotearg_style (c_quoting_style, Value)); \
- obstack_1grow (&muscle_obstack, 0); \
- muscle_insert (Key, obstack_finish (&muscle_obstack)); \
+ muscle_insert (Key, obstack_finish0 (&muscle_obstack)); \
} while (0)
/* Append VALUE to the current value of KEY. If KEY did not already
char const *value,
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
%define variable VARIABLE is defined, return its value. Otherwise, return
the empty string. Also, record Bison's usage of VARIABLE by defining
fputs ("NULLABLE\n", out);
for (i = ntokens; i < nsyms; i++)
fprintf (out, "\t%s: %s\n", symbols[i]->tag,
- nullable[i - ntokens] ? "yes" : "no");
+ nullable[i - ntokens] ? "yes" : "no");
fputs ("\n\n", out);
}
for (ruleno = 0; ruleno < nrules; ++ruleno)
if (rules[ruleno].useful)
{
- rule *rules_ruleno = &rules[ruleno];
- if (rules_ruleno->rhs[0] >= 0)
- {
- /* This rule has a non empty RHS. */
- item_number *rp = NULL;
- bool any_tokens = false;
- for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
- if (ISTOKEN (*rp))
- any_tokens = true;
-
- /* This rule has only nonterminals: schedule it for the second
- pass. */
- if (!any_tokens)
- for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
- {
- rcount[ruleno]++;
- p->next = rsets[*rp - ntokens];
- p->value = rules_ruleno;
- rsets[*rp - ntokens] = p;
- p++;
- }
- }
- else
- {
- /* This rule has an empty RHS. */
- aver (item_number_as_rule_number (rules_ruleno->rhs[0])
- == ruleno);
- if (rules_ruleno->useful
- && ! nullable[rules_ruleno->lhs->number - ntokens])
- {
- nullable[rules_ruleno->lhs->number - ntokens] = true;
- *s2++ = rules_ruleno->lhs->number;
- }
- }
+ rule *rules_ruleno = &rules[ruleno];
+ if (rules_ruleno->rhs[0] >= 0)
+ {
+ /* This rule has a non empty RHS. */
+ item_number *rp = NULL;
+ bool any_tokens = false;
+ for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
+ if (ISTOKEN (*rp))
+ any_tokens = true;
+
+ /* This rule has only nonterminals: schedule it for the second
+ pass. */
+ if (!any_tokens)
+ for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
+ {
+ rcount[ruleno]++;
+ p->next = rsets[*rp - ntokens];
+ p->value = rules_ruleno;
+ rsets[*rp - ntokens] = p;
+ p++;
+ }
+ }
+ else
+ {
+ /* This rule has an empty RHS. */
+ aver (item_number_as_rule_number (rules_ruleno->rhs[0])
+ == ruleno);
+ if (rules_ruleno->useful
+ && ! nullable[rules_ruleno->lhs->number - ntokens])
+ {
+ nullable[rules_ruleno->lhs->number - ntokens] = true;
+ *s2++ = rules_ruleno->lhs->number;
+ }
+ }
}
while (s1 < s2)
for (p = rsets[*s1++ - ntokens]; p; p = p->next)
{
- rule *r = p->value;
- if (--rcount[r->number] == 0)
- if (r->useful && ! nullable[r->lhs->number - ntokens])
- {
- nullable[r->lhs->number - ntokens] = true;
- *s2++ = r->lhs->number;
- }
+ rule *r = p->value;
+ if (--rcount[r->number] == 0)
+ if (r->useful && ! nullable[r->lhs->number - ntokens])
+ {
+ nullable[r->lhs->number - ntokens] = true;
+ *s2++ = r->lhs->number;
+ }
}
free (squeue);
#include <config.h>
#include "system.h"
+#include <concat-filename.h>
#include <configmake.h>
-#include <error.h>
+#include <filename.h>
#include <get-errno.h>
#include <quotearg.h>
#include <spawn-pipe.h>
`-------------------------------------------------------------------*/
-#define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \
- \
-static void \
-Name (char const *name, \
- Type *table_data, \
- Type first, \
- int begin, \
- int end) \
-{ \
- Type min = first; \
- Type max = first; \
- long int lmin; \
- long int lmax; \
- int i; \
- int j = 1; \
- \
- obstack_printf (&format_obstack, "%6d", first); \
- for (i = begin; i < end; ++i) \
- { \
- obstack_1grow (&format_obstack, ','); \
- if (j >= 10) \
- { \
- obstack_sgrow (&format_obstack, "\n "); \
- j = 1; \
- } \
- else \
- ++j; \
- obstack_printf (&format_obstack, "%6d", table_data[i]); \
- if (table_data[i] < min) \
- min = table_data[i]; \
- if (max < table_data[i]) \
- max = table_data[i]; \
- } \
- obstack_1grow (&format_obstack, 0); \
- muscle_insert (name, obstack_finish (&format_obstack)); \
- \
- lmin = min; \
- lmax = max; \
- /* Build `NAME_min' and `NAME_max' in the obstack. */ \
- obstack_printf (&format_obstack, "%s_min", name); \
- obstack_1grow (&format_obstack, 0); \
- MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
- obstack_printf (&format_obstack, "%s_max", name); \
- obstack_1grow (&format_obstack, 0); \
- MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
+#define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \
+ \
+static void \
+Name (char const *name, \
+ Type *table_data, \
+ Type first, \
+ int begin, \
+ int end) \
+{ \
+ Type min = first; \
+ Type max = first; \
+ long int lmin; \
+ long int lmax; \
+ int i; \
+ int j = 1; \
+ \
+ obstack_printf (&format_obstack, "%6d", first); \
+ for (i = begin; i < end; ++i) \
+ { \
+ obstack_1grow (&format_obstack, ','); \
+ if (j >= 10) \
+ { \
+ obstack_sgrow (&format_obstack, "\n "); \
+ j = 1; \
+ } \
+ else \
+ ++j; \
+ obstack_printf (&format_obstack, "%6d", table_data[i]); \
+ if (table_data[i] < min) \
+ min = table_data[i]; \
+ if (max < table_data[i]) \
+ max = table_data[i]; \
+ } \
+ muscle_insert (name, obstack_finish0 (&format_obstack)); \
+ \
+ lmin = min; \
+ lmax = max; \
+ /* Build `NAME_min' and `NAME_max' in the obstack. */ \
+ obstack_printf (&format_obstack, "%s_min", name); \
+ MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmin); \
+ obstack_printf (&format_obstack, "%s_max", name); \
+ MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmax); \
}
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int)
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_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)
{
MUSCLE_INSERT_INT ("tokens_number", ntokens);
MUSCLE_INSERT_INT ("nterms_number", nvars);
+ MUSCLE_INSERT_INT ("symbols_number", nsyms);
MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);
muscle_insert_symbol_number_table ("translate",
- token_translations,
- token_translations[0],
- 1, max_user_token_number + 1);
+ token_translations,
+ token_translations[0],
+ 1, max_user_token_number + 1);
/* tname -- token names. */
{
set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS);
for (i = 0; i < nsyms; i++)
{
- char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);
- /* Width of the next token, including the two quotes, the
- comma and the space. */
- int width = strlen (cp) + 2;
-
- if (j + width > 75)
- {
- obstack_sgrow (&format_obstack, "\n ");
- j = 1;
- }
-
- if (i)
- obstack_1grow (&format_obstack, ' ');
- obstack_escape (&format_obstack, cp);
+ char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);
+ /* Width of the next token, including the two quotes, the
+ comma and the space. */
+ int width = strlen (cp) + 2;
+
+ if (j + width > 75)
+ {
+ obstack_sgrow (&format_obstack, "\n ");
+ j = 1;
+ }
+
+ if (i)
+ obstack_1grow (&format_obstack, ' ');
+ obstack_escape (&format_obstack, cp);
free (cp);
- obstack_1grow (&format_obstack, ',');
- j += width;
+ obstack_1grow (&format_obstack, ',');
+ j += width;
}
free (qo);
obstack_sgrow (&format_obstack, " ]b4_null[");
/* Finish table and store. */
- obstack_1grow (&format_obstack, 0);
- muscle_insert ("tname", obstack_finish (&format_obstack));
+ muscle_insert ("tname", obstack_finish0 (&format_obstack));
}
/* Output YYTOKNUM. */
for (i = 0; i < ntokens; ++i)
values[i] = symbols[i]->user_token_number;
muscle_insert_int_table ("toknum", values,
- values[0], 1, ntokens);
+ values[0], 1, ntokens);
free (values);
}
}
-/*-------------------------------------------------------------.
-| Prepare the muscles related to the rules: rhs, prhs, r1, r2, |
-| rline, dprec, merger. |
-`-------------------------------------------------------------*/
+/*----------------------------------------------------------------.
+| Prepare the muscles related to the rules: r1, r2, rline, dprec, |
+| merger, immediate. |
+`----------------------------------------------------------------*/
static 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);
symbol_number *r1 = xnmalloc (nrules, sizeof *r1);
unsigned int *r2 = xnmalloc (nrules, sizeof *r2);
int *dprec = xnmalloc (nrules, sizeof *dprec);
int *merger = xnmalloc (nrules, sizeof *merger);
+ int *immediate = xnmalloc (nrules, sizeof *immediate);
+ rule_number 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. */
r1[r] = rules[r].lhs->number;
/* Length of rule R's RHS. */
- r2[r] = i - prhs[r];
- /* Separator in RHS. */
- rhs[i++] = -1;
+ r2[r] = rule_rhs_length(&rules[r]);
/* Line where rule was defined. */
rline[r] = rules[r].location.start.line;
/* Dynamic precedence (GLR). */
dprec[r] = rules[r].dprec;
/* Merger-function index (GLR). */
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_symbol_number_table ("r1", r1, 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 ("merger", merger, 0, 0, nrules);
+ muscle_insert_int_table ("immediate", immediate, 0, 0, nrules);
MUSCLE_INSERT_INT ("rules_number", nrules);
MUSCLE_INSERT_INT ("max_left_semantic_context", max_left_semantic_context);
- free (rhs);
- free (prhs);
free (rline);
free (r1);
free (r2);
free (dprec);
free (merger);
+ free (immediate);
}
/*--------------------------------------------.
for (i = 0; i < nstates; ++i)
values[i] = states[i]->accessing_symbol;
muscle_insert_symbol_number_table ("stos", values,
- 0, 1, nstates);
+ 0, 1, nstates);
free (values);
MUSCLE_INSERT_INT ("last", high);
}
+/*-------------------------------------------------------.
+| 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)
+ return res;
+ return (*lhs)->number - (*rhs)->number;
+}
+
+
+/*----------------------------------------------------------------.
+| 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. |
for (r = 0; r < nrules; ++r)
if (rules[r].action)
{
- fprintf (out, "b4_case(%d, [b4_syncline(%d, ", r + 1,
- rules[r].action_location.start.line);
- string_output (out, rules[r].action_location.start.file);
- fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
+ fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
+ rules[r].is_predicate ? "predicate_" : "",
+ r + 1, rules[r].action_location.start.line);
+ string_output (out, rules[r].action_location.start.file);
+ fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
}
fputs ("])\n\n", out);
}
-/*--------------------------------------.
-| Output the merge functions to OUT. |
-`--------------------------------------*/
+/*------------------------------------.
+| Output the merge functions to OUT. |
+`------------------------------------*/
static void
merger_output (FILE *out)
for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next)
{
if (p->type[0] == '\0')
- fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
- n, p->name);
+ fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
+ n, p->name);
else
- fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
- n, p->type, p->name);
+ fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
+ n, p->type, p->name);
}
fputs ("]])\n\n", out);
}
-/*--------------------------------------.
-| Output the tokens definition to OUT. |
-`--------------------------------------*/
+
+/*---------------------------------------------.
+| Prepare the muscles for symbol definitions. |
+`---------------------------------------------*/
static void
-token_definitions_output (FILE *out)
+prepare_symbol_definitions (void)
{
int i;
- char const *sep = "";
-
- fputs ("m4_define([b4_tokens], \n[", out);
- for (i = 0; i < ntokens; ++i)
+ for (i = 0; i < nsyms; ++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);
-}
+ const char *key;
+ const char *value;
+#define SET_KEY(Entry) \
+ obstack_printf (&format_obstack, "symbol(%d, %s)", \
+ i, Entry); \
+ key = obstack_finish0 (&format_obstack);
-/*---------------------------------------------------.
-| Output the symbol destructors or printers to OUT. |
-`---------------------------------------------------*/
+#define SET_KEY2(Entry, Suffix) \
+ obstack_printf (&format_obstack, "symbol(%d, %s_%s)", \
+ i, Entry, Suffix); \
+ key = obstack_finish0 (&format_obstack);
-static void
-symbol_code_props_output (FILE *out, char const *what,
- code_props const *(*get)(symbol const *))
-{
- int i;
- char const *sep = "";
+ // Whether the symbol has an identifier.
+ value = symbol_id_get (sym);
+ SET_KEY("has_id");
+ MUSCLE_INSERT_INT (key, !!value);
- fputs ("m4_define([b4_symbol_", out);
- fputs (what, out);
- fputs ("], \n[", out);
- for (i = 0; i < nsyms; ++i)
- {
- symbol *sym = symbols[i];
- char const *code = (*get) (sym)->code;
- if (code)
- {
- location loc = (*get) (sym)->location;
- /* 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)
- {
- fputs (", ", out);
- quoted_output (out, sym->type_name);
- }
- fputc (']', out);
- }
+ // 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;
+ for (j = 0; j < CODE_PROPS_SIZE; ++j)
+ {
+ /* "printer", not "%printer". */
+ char const *pname = code_props_type_string (j) + 1;
+ code_props const *p = symbol_code_props_get (sym, j);
+ SET_KEY2("has", pname);
+ 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);
+ }
+ }
+ }
+#undef SET_KEY2
+#undef SET_KEY
}
- fputs ("])\n\n", out);
}
lookahead token type. */
muscle_insert_rule_number_table ("defact", yydefact,
- yydefact[0], 1, nstates);
+ yydefact[0], 1, nstates);
/* Figure out what to do after reducing with each rule, depending on
the saved state from before the beginning of parsing the data
that matched this rule. */
muscle_insert_state_number_table ("defgoto", yydefgoto,
- yydefgoto[0], 1, nsyms - ntokens);
+ yydefgoto[0], 1, nsyms - ntokens);
/* Output PACT. */
muscle_insert_base_table ("pact", base,
- base[0], 1, nstates);
+ base[0], 1, nstates);
MUSCLE_INSERT_INT ("pact_ninf", base_ninf);
/* Output PGOTO. */
muscle_insert_base_table ("pgoto", base,
- base[nstates], nstates + 1, nvectors);
+ base[nstates], nstates + 1, nvectors);
muscle_insert_base_table ("table", table,
- table[0], 1, high + 1);
+ table[0], 1, high + 1);
MUSCLE_INSERT_INT ("table_ninf", table_ninf);
muscle_insert_base_table ("check", check,
- check[0], 1, high + 1);
+ check[0], 1, high + 1);
/* GLR parsing slightly modifies YYTABLE and YYCHECK (and thus
YYPACT) so that in states with unresolved conflicts, the default
that case. Nevertheless, it seems even better to be able to use
the GLR skeletons even without the non-deterministic tables. */
muscle_insert_unsigned_int_table ("conflict_list_heads", conflict_table,
- conflict_table[0], 1, high + 1);
+ conflict_table[0], 1, high + 1);
muscle_insert_unsigned_int_table ("conflicting_rules", conflict_list,
- 0, 1, conflict_list_cnt);
+ 0, 1, conflict_list_cnt);
}
+
/*--------------------------------------------.
| Output the definitions of all the muscles. |
`--------------------------------------------*/
muscles_output (FILE *out)
{
fputs ("m4_init()\n", out);
-
- user_actions_output (out);
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);
-
+ symbol_numbers_output (out);
+ type_names_output (out);
+ user_actions_output (out);
+ // Must be last.
muscles_m4_output (out);
}
\f
static void
output_skeleton (void)
{
- FILE *in;
int filter_fd[2];
- char const *argv[10];
pid_t pid;
/* Compute the names of the package data dir and skeleton files. */
- char const m4sugar[] = "m4sugar/m4sugar.m4";
- char const m4bison[] = "bison.m4";
- char *full_m4sugar;
- char *full_m4bison;
- char *full_skeleton;
- char const *p;
- 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);
+ char const *m4 = (m4 = getenv ("M4")) ? m4 : M4;
+ char const *datadir = pkgdatadir ();
+ char *m4sugar = xconcatenated_filename (datadir, "m4sugar/m4sugar.m4", NULL);
+ char *m4bison = xconcatenated_filename (datadir, "bison.m4", NULL);
+ char *skel = (IS_PATH_WITH_DIR (skeleton)
+ ? xstrdup (skeleton)
+ : xconcatenated_filename (datadir, skeleton, NULL));
/* Test whether m4sugar.m4 is readable, to check for proper
installation. A faulty installation can cause deadlock, so a
cheap sanity check is worthwhile. */
- xfclose (xfopen (full_m4sugar, "r"));
+ xfclose (xfopen (m4sugar, "r"));
/* Create an m4 subprocess connected to us via two pipes. */
if (trace_flag & trace_tools)
fprintf (stderr, "running: %s %s - %s %s\n",
- m4, full_m4sugar, full_m4bison, full_skeleton);
+ m4, m4sugar, m4bison, skel);
/* 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
<http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
for details. */
{
+ char const *argv[10];
int i = 0;
argv[i++] = m4;
argv[i++] = M4_GNU_OPTION;
argv[i++] = "-I";
- argv[i++] = pkgdatadir;
+ argv[i++] = datadir;
if (trace_flag & trace_m4)
argv[i++] = "-dV";
- argv[i++] = full_m4sugar;
+ argv[i++] = m4sugar;
argv[i++] = "-";
- argv[i++] = full_m4bison;
- argv[i++] = full_skeleton;
+ argv[i++] = m4bison;
+ argv[i++] = skel;
argv[i++] = NULL;
aver (i <= ARRAY_CARDINALITY (argv));
+
+ /* The ugly cast is because gnulib gets the const-ness wrong. */
+ pid = create_pipe_bidi ("m4", m4, (char **)(void*)argv, false, true,
+ true, filter_fd);
}
- /* The ugly cast is because gnulib gets the const-ness wrong. */
- pid = create_pipe_bidi ("m4", m4, (char **)(void*)argv, false, true,
- true, filter_fd);
- free (full_m4sugar);
- free (full_m4bison);
- free (full_skeleton);
+ free (m4sugar);
+ free (m4bison);
+ free (skel);
if (trace_flag & trace_muscles)
muscles_output (stderr);
{
- FILE *out = fdopen (filter_fd[1], "w");
- if (! out)
- error (EXIT_FAILURE, get_errno (),
- "fdopen");
+ FILE *out = xfdopen (filter_fd[1], "w");
muscles_output (out);
xfclose (out);
}
/* Read and process m4's output. */
timevar_push (TV_M4);
- in = fdopen (filter_fd[0], "r");
- if (! in)
- error (EXIT_FAILURE, get_errno (),
- "fdopen");
- scan_skel (in);
- /* 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
- Bison user. */
- aver (feof (in));
- xfclose (in);
+ {
+ FILE *in = xfdopen (filter_fd[0], "r");
+ scan_skel (in);
+ /* 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
+ Bison user. */
+ aver (feof (in));
+ xfclose (in);
+ }
wait_subprocess (pid, "m4", false, false, true, true, NULL);
timevar_pop (TV_M4);
}
static void
prepare (void)
{
- /* BISON_USE_PUSH_FOR_PULL is for the test suite and should not be documented
- for the user. */
- char const *use_push_for_pull_env = getenv ("BISON_USE_PUSH_FOR_PULL");
- 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;
+ /* BISON_USE_PUSH_FOR_PULL is for the test suite and should not be
+ documented for the user. */
+ char const *cp = getenv ("BISON_USE_PUSH_FOR_PULL");
+ bool use_push_for_pull_flag = cp && *cp && strtol (cp, 0, 10);
/* Flags. */
- MUSCLE_INSERT_BOOL ("debug_flag", debug);
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 ("locations_flag", locations_flag);
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
/* b4_pkgdatadir is used inside m4_include in the skeletons, so digraphs
would never be expanded. Hopefully no one has M4-special characters in
his Bison installation path. */
- MUSCLE_INSERT_STRING_RAW ("pkgdatadir", compute_pkgdatadir ());
+ MUSCLE_INSERT_STRING_RAW ("pkgdatadir", pkgdatadir ());
}
}
prepare_rules ();
prepare_states ();
prepare_actions ();
+ prepare_symbol_definitions ();
prepare ();
}
char const *
-compute_pkgdatadir (void)
+pkgdatadir (void)
{
- char const *pkgdatadir = getenv ("BISON_PKGDATADIR");
- return pkgdatadir ? pkgdatadir : PKGDATADIR;
+ char const *cp = getenv ("BISON_PKGDATADIR");
+ return cp ? cp : PKGDATADIR;
}
/* Output the parsing tables and the parser code to FTABLE. */
void output (void);
-char const *compute_pkgdatadir (void);
+
+/* Where our data files are installed. */
+char const *pkgdatadir (void);
#endif /* !OUTPUT_H_ */
-/* A Bison parser, made by GNU Bison 2.6.5.63-3ada. */
+/* A Bison parser, made by GNU Bison 2.6.5.977-6d58-dirty. */
/* Bison implementation for Yacc-like parsers in C
-
- Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
-
+
+ Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.6.5.63-3ada"
+#define YYBISON_VERSION "2.6.5.977-6d58-dirty"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
#define yylloc gram_lloc
/* Copy the first part of user declarations. */
-/* Line 360 of yacc.c */
-#line 1 "parse-gram.y"
+/* Line 355 of yacc.c */
+#line 1 "src/parse-gram.y"
/* Bison Grammar Parser -*- C -*-
Copyright (C) 2002-2012 Free Software Foundation, Inc.
#include "quotearg.h"
#include "reader.h"
#include "symlist.h"
+#include "symtab.h"
#include "scan-gram.h"
#include "scan-code.h"
#include "xmemdup0.h"
static YYLTYPE lloc_default (YYLTYPE const *, int);
#define YY_LOCATION_PRINT(File, Loc) \
- location_print (File, Loc)
+ location_print (File, Loc)
static void version_check (location const *loc, char const *version);
FIXME: depends on the undocumented availability of YYLLOC. */
#undef yyerror
#define yyerror(Msg) \
- gram_error (&yylloc, Msg)
+ gram_error (&yylloc, Msg)
static void gram_error (location const *, char const *);
static char const *char_name (char);
-/** Add a lex-param or a parse-param.
- *
- * \param type \a lex_param or \a parse_param
- * \param decl the formal argument
- * \param loc the location in the source.
- */
-static void add_param (char const *type, char *decl, location loc);
-
-
-static symbol_class current_class = unknown_sym;
-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
- * to several right-hand side parts of rule.
- */
-static
-void
-current_lhs(symbol *sym, location loc, named_ref *ref)
-{
- current_lhs_symbol = sym;
- current_lhs_location = loc;
- /* In order to simplify memory management, named references for lhs
- are always assigned by deep copy into the current symbol_list
- node. This is because a single named-ref in the grammar may
- result in several uses when the user factors lhs between several
- rules using "|". Therefore free the parser's original copy. */
- free (current_lhs_named_ref);
- current_lhs_named_ref = ref;
-}
-
-
-#define YYTYPE_INT16 int_fast16_t
-#define YYTYPE_INT8 int_fast8_t
-#define YYTYPE_UINT16 uint_fast16_t
-#define YYTYPE_UINT8 uint_fast8_t
-
-/* Line 360 of yacc.c */
-#line 173 "parse-gram.c"
+/* Line 355 of yacc.c */
+#line 134 "src/parse-gram.c"
# ifndef YY_NULL
# if defined __cplusplus && 201103L <= __cplusplus
#endif
/* In a future release of Bison, this section will be replaced
- by #include "parse-gram.h". */
-#ifndef YY_GRAM_Y_TAB_H_INCLUDED
-# define YY_GRAM_Y_TAB_H_INCLUDED
+ by #include "src/parse-gram.h". */
+#ifndef YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED
+# define YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED
/* Enabling traces. */
#ifndef GRAM_DEBUG
# if defined YYDEBUG
-# if YYDEBUG
+#if YYDEBUG
# define GRAM_DEBUG 1
# else
# define GRAM_DEBUG 0
#if GRAM_DEBUG
extern int gram_debug;
#endif
+/* "%code requires" blocks. */
+/* Line 371 of yacc.c */
+#line 223 "src/parse-gram.y"
+
+# 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
+
+
+/* Line 371 of yacc.c */
+#line 188 "src/parse-gram.c"
/* Tokens. */
#ifndef GRAM_TOKENTYPE
# define GRAM_TOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum gram_tokentype {
- GRAM_EOF = 0,
- STRING = 258,
- INT = 259,
- PERCENT_TOKEN = 260,
- PERCENT_NTERM = 261,
- PERCENT_TYPE = 262,
- PERCENT_DESTRUCTOR = 263,
- PERCENT_PRINTER = 264,
- PERCENT_LEFT = 265,
- PERCENT_RIGHT = 266,
- PERCENT_NONASSOC = 267,
- PERCENT_PREC = 268,
- PERCENT_DPREC = 269,
- PERCENT_MERGE = 270,
- PERCENT_CODE = 271,
- PERCENT_DEBUG = 272,
- PERCENT_DEFAULT_PREC = 273,
- PERCENT_DEFINE = 274,
- PERCENT_DEFINES = 275,
- PERCENT_ERROR_VERBOSE = 276,
- PERCENT_EXPECT = 277,
- PERCENT_EXPECT_RR = 278,
- PERCENT_FILE_PREFIX = 279,
- PERCENT_GLR_PARSER = 280,
- PERCENT_INITIAL_ACTION = 281,
- PERCENT_LANGUAGE = 282,
- PERCENT_LEX_PARAM = 283,
- PERCENT_LOCATIONS = 284,
- PERCENT_NAME_PREFIX = 285,
- PERCENT_NO_DEFAULT_PREC = 286,
- PERCENT_NO_LINES = 287,
- PERCENT_NONDETERMINISTIC_PARSER = 288,
- PERCENT_OUTPUT = 289,
- PERCENT_PARSE_PARAM = 290,
- PERCENT_PURE_PARSER = 291,
- PERCENT_REQUIRE = 292,
- PERCENT_SKELETON = 293,
- PERCENT_START = 294,
- PERCENT_TOKEN_TABLE = 295,
- PERCENT_VERBOSE = 296,
- PERCENT_YACC = 297,
- BRACED_CODE = 298,
- BRACKETED_ID = 299,
- CHAR = 300,
- EPILOGUE = 301,
- EQUAL = 302,
- ID = 303,
- ID_COLON = 304,
- PERCENT_PERCENT = 305,
- PIPE = 306,
- PROLOGUE = 307,
- SEMICOLON = 308,
- TYPE = 309,
- TYPE_TAG_ANY = 310,
- TYPE_TAG_NONE = 311,
- PERCENT_UNION = 312
- };
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum gram_tokentype
+ {
+ GRAM_EOF = 0,
+ STRING = 258,
+ INT = 259,
+ PERCENT_TOKEN = 260,
+ PERCENT_NTERM = 261,
+ PERCENT_TYPE = 262,
+ PERCENT_DESTRUCTOR = 263,
+ PERCENT_PRINTER = 264,
+ PERCENT_LEFT = 265,
+ PERCENT_RIGHT = 266,
+ PERCENT_NONASSOC = 267,
+ PERCENT_PRECEDENCE = 268,
+ PERCENT_PREC = 269,
+ PERCENT_DPREC = 270,
+ PERCENT_MERGE = 271,
+ PERCENT_CODE = 272,
+ PERCENT_DEFAULT_PREC = 273,
+ PERCENT_DEFINE = 274,
+ PERCENT_DEFINES = 275,
+ PERCENT_ERROR_VERBOSE = 276,
+ PERCENT_EXPECT = 277,
+ PERCENT_EXPECT_RR = 278,
+ PERCENT_FLAG = 279,
+ PERCENT_FILE_PREFIX = 280,
+ PERCENT_GLR_PARSER = 281,
+ PERCENT_INITIAL_ACTION = 282,
+ PERCENT_LANGUAGE = 283,
+ PERCENT_NAME_PREFIX = 284,
+ PERCENT_NO_DEFAULT_PREC = 285,
+ PERCENT_NO_LINES = 286,
+ PERCENT_NONDETERMINISTIC_PARSER = 287,
+ PERCENT_OUTPUT = 288,
+ PERCENT_REQUIRE = 289,
+ PERCENT_SKELETON = 290,
+ PERCENT_START = 291,
+ PERCENT_TOKEN_TABLE = 292,
+ PERCENT_VERBOSE = 293,
+ PERCENT_YACC = 294,
+ BRACED_CODE = 295,
+ BRACED_PREDICATE = 296,
+ BRACKETED_ID = 297,
+ CHAR = 298,
+ EPILOGUE = 299,
+ EQUAL = 300,
+ ID = 301,
+ ID_COLON = 302,
+ PERCENT_PERCENT = 303,
+ PIPE = 304,
+ PROLOGUE = 305,
+ SEMICOLON = 306,
+ TAG = 307,
+ TAG_ANY = 308,
+ TAG_NONE = 309,
+ PERCENT_PARAM = 310,
+ PERCENT_UNION = 311
+ };
#endif
/* Tokens. */
#define GRAM_EOF 0
#define PERCENT_LEFT 265
#define PERCENT_RIGHT 266
#define PERCENT_NONASSOC 267
-#define PERCENT_PREC 268
-#define PERCENT_DPREC 269
-#define PERCENT_MERGE 270
-#define PERCENT_CODE 271
-#define PERCENT_DEBUG 272
+#define PERCENT_PRECEDENCE 268
+#define PERCENT_PREC 269
+#define PERCENT_DPREC 270
+#define PERCENT_MERGE 271
+#define PERCENT_CODE 272
#define PERCENT_DEFAULT_PREC 273
#define PERCENT_DEFINE 274
#define PERCENT_DEFINES 275
#define PERCENT_ERROR_VERBOSE 276
#define PERCENT_EXPECT 277
#define PERCENT_EXPECT_RR 278
-#define PERCENT_FILE_PREFIX 279
-#define PERCENT_GLR_PARSER 280
-#define PERCENT_INITIAL_ACTION 281
-#define PERCENT_LANGUAGE 282
-#define PERCENT_LEX_PARAM 283
-#define PERCENT_LOCATIONS 284
-#define PERCENT_NAME_PREFIX 285
-#define PERCENT_NO_DEFAULT_PREC 286
-#define PERCENT_NO_LINES 287
-#define PERCENT_NONDETERMINISTIC_PARSER 288
-#define PERCENT_OUTPUT 289
-#define PERCENT_PARSE_PARAM 290
-#define PERCENT_PURE_PARSER 291
-#define PERCENT_REQUIRE 292
-#define PERCENT_SKELETON 293
-#define PERCENT_START 294
-#define PERCENT_TOKEN_TABLE 295
-#define PERCENT_VERBOSE 296
-#define PERCENT_YACC 297
-#define BRACED_CODE 298
-#define BRACKETED_ID 299
-#define CHAR 300
-#define EPILOGUE 301
-#define EQUAL 302
-#define ID 303
-#define ID_COLON 304
-#define PERCENT_PERCENT 305
-#define PIPE 306
-#define PROLOGUE 307
-#define SEMICOLON 308
-#define TYPE 309
-#define TYPE_TAG_ANY 310
-#define TYPE_TAG_NONE 311
-#define PERCENT_UNION 312
-
-
+#define PERCENT_FLAG 279
+#define PERCENT_FILE_PREFIX 280
+#define PERCENT_GLR_PARSER 281
+#define PERCENT_INITIAL_ACTION 282
+#define PERCENT_LANGUAGE 283
+#define PERCENT_NAME_PREFIX 284
+#define PERCENT_NO_DEFAULT_PREC 285
+#define PERCENT_NO_LINES 286
+#define PERCENT_NONDETERMINISTIC_PARSER 287
+#define PERCENT_OUTPUT 288
+#define PERCENT_REQUIRE 289
+#define PERCENT_SKELETON 290
+#define PERCENT_START 291
+#define PERCENT_TOKEN_TABLE 292
+#define PERCENT_VERBOSE 293
+#define PERCENT_YACC 294
+#define BRACED_CODE 295
+#define BRACED_PREDICATE 296
+#define BRACKETED_ID 297
+#define CHAR 298
+#define EPILOGUE 299
+#define EQUAL 300
+#define ID 301
+#define ID_COLON 302
+#define PERCENT_PERCENT 303
+#define PIPE 304
+#define PROLOGUE 305
+#define SEMICOLON 306
+#define TAG 307
+#define TAG_ANY 308
+#define TAG_NONE 309
+#define PERCENT_PARAM 310
+#define PERCENT_UNION 311
#if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED
typedef union GRAM_STYPE
{
-/* Line 376 of yacc.c */
-#line 115 "parse-gram.y"
+/* Line 371 of yacc.c */
+#line 109 "src/parse-gram.y"
+ assoc assoc;
+ char *code;
+ char const *chars;
+ int integer;
+ named_ref *named_ref;
symbol *symbol;
symbol_list *list;
- int integer;
- char const *chars;
- char *code;
- assoc assoc;
uniqstr uniqstr;
unsigned char character;
- named_ref *named_ref;
+/* Line 371 of yacc.c */
+#line 247 "src/parse-gram.y"
+
+ param_type param;
-/* Line 376 of yacc.c */
-#line 353 "parse-gram.c"
+/* Line 371 of yacc.c */
+#line 423 "src/parse-gram.y"
+code_props_type code_type;
+
+/* Line 371 of yacc.c */
+#line 337 "src/parse-gram.c"
} GRAM_STYPE;
# define GRAM_STYPE_IS_TRIVIAL 1
-# define gram_stype GRAM_STYPE /* obsolescent; will be withdrawn */
# define GRAM_STYPE_IS_DECLARED 1
#endif
int last_line;
int last_column;
} GRAM_LTYPE;
-# define gram_ltype GRAM_LTYPE /* obsolescent; will be withdrawn */
# define GRAM_LTYPE_IS_DECLARED 1
# define GRAM_LTYPE_IS_TRIVIAL 1
#endif
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int gram_parse (void *YYPARSE_PARAM);
-#else
-int gram_parse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
int gram_parse (void);
-#else
-int gram_parse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-#endif /* !YY_GRAM_Y_TAB_H_INCLUDED */
+#endif /* !YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED */
/* Copy the second part of user declarations. */
-/* Line 379 of yacc.c */
-#line 393 "parse-gram.c"
+/* Line 374 of yacc.c */
+#line 363 "src/parse-gram.c"
+/* Unqualified %code blocks. */
+/* Line 375 of yacc.c */
+#line 58 "src/parse-gram.y"
+
+ static int current_prec = 0;
+ static location current_lhs_location;
+ static named_ref *current_lhs_named_ref;
+ static symbol *current_lhs_symbol;
+ static symbol_class current_class = unknown_sym;
+ static uniqstr current_type = NULL;
+
+ /** Set the new current left-hand side symbol, possibly common
+ * to several right-hand side parts of rule.
+ */
+ static
+ void
+ current_lhs(symbol *sym, location loc, named_ref *ref)
+ {
+ current_lhs_symbol = sym;
+ current_lhs_location = loc;
+ /* In order to simplify memory management, named references for lhs
+ are always assigned by deep copy into the current symbol_list
+ node. This is because a single named-ref in the grammar may
+ result in several uses when the user factors lhs between several
+ rules using "|". Therefore free the parser's original copy. */
+ free (current_lhs_named_ref);
+ current_lhs_named_ref = ref;
+ }
+
+ #define YYTYPE_INT16 int_fast16_t
+ #define YYTYPE_INT8 int_fast8_t
+ #define YYTYPE_UINT16 uint_fast16_t
+ #define YYTYPE_UINT8 uint_fast8_t
+
+/* Line 375 of yacc.c */
+#line 236 "src/parse-gram.y"
+
+ /** 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;
+
+
+/* Line 375 of yacc.c */
+#line 412 "src/parse-gram.c"
#ifdef short
# undef short
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
-#elif (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-typedef signed char yytype_int8;
#else
-typedef short int yytype_int8;
+typedef signed char yytype_int8;
#endif
#ifdef YYTYPE_UINT16
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
+# elif ! defined YYSIZE_T
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
#endif
/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
+#ifdef __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
-/* Identity function, used to suppress warnings about constant conditions. */
-#ifndef lint
-# define YYID(N) (N)
-#else
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static int
-YYID (int yyi)
-#else
-static int
-YYID (yyi)
- int yyi;
-#endif
-{
- return yyi;
-}
-#endif
-
#if 1
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# ifndef YYSTACK_ALLOC_MAXIMUM
/* 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
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
+ && (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
-# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
+# if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
-# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
+# if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
#if (! defined yyoverflow \
&& (! defined __cplusplus \
- || (defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL \
- && defined GRAM_STYPE_IS_TRIVIAL && GRAM_STYPE_IS_TRIVIAL)))
+ || (defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL \
+ && defined GRAM_STYPE_IS_TRIVIAL && GRAM_STYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
-# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
- Stack = &yyptr->Stack_alloc; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (YYID (0))
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (0)
#endif
for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \
} \
- while (YYID (0))
+ while (0)
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 3
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 160
+#define YYLAST 157
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 58
+#define YYNTOKENS 57
/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 34
+#define YYNNTS 38
/* YYNRULES -- Number of rules. */
-#define YYNRULES 108
-/* YYNRULES -- Number of states. */
-#define YYNSTATES 148
+#define YYNRULES 109
+/* YYNSTATES -- Number of states. */
+#define YYNSTATES 143
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
+ by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
-#define YYMAXUTOK 312
+#define YYMAXUTOK 311
-#define YYTRANSLATE(YYX) \
+#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, without out-of-bounds checking. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57
+ 55, 56
};
#if GRAM_DEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- YYRHS. */
-static const yytype_uint16 yyprhs[] =
-{
- 0, 0, 3, 8, 9, 12, 14, 16, 18, 22,
- 24, 27, 29, 32, 35, 38, 42, 44, 47, 50,
- 53, 55, 58, 62, 64, 66, 69, 73, 76, 78,
- 81, 84, 86, 88, 90, 92, 94, 96, 99, 103,
- 107, 109, 111, 114, 118, 119, 121, 125, 126, 130,
- 131, 135, 139, 143, 145, 147, 149, 150, 152, 154,
- 157, 159, 162, 164, 167, 169, 172, 174, 176, 178,
- 180, 182, 184, 187, 190, 194, 196, 199, 201, 204,
- 206, 209, 212, 213, 218, 220, 224, 227, 228, 232,
- 236, 240, 244, 248, 249, 251, 253, 255, 256, 258,
- 260, 262, 264, 266, 268, 270, 272, 274, 275
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yytype_int8 yyrhs[] =
-{
- 59, 0, -1, 60, 50, 77, 91, -1, -1, 60,
- 61, -1, 62, -1, 52, -1, 17, -1, 19, 84,
- 85, -1, 20, -1, 20, 3, -1, 21, -1, 22,
- 4, -1, 23, 4, -1, 24, 3, -1, 24, 47,
- 3, -1, 25, -1, 26, 43, -1, 27, 3, -1,
- 28, 43, -1, 29, -1, 30, 3, -1, 30, 47,
- 3, -1, 32, -1, 33, -1, 34, 3, -1, 34,
- 47, 3, -1, 35, 43, -1, 36, -1, 37, 3,
- -1, 38, 3, -1, 40, -1, 41, -1, 42, -1,
- 53, -1, 67, -1, 64, -1, 39, 89, -1, 8,
- 43, 73, -1, 9, 43, 73, -1, 18, -1, 31,
- -1, 16, 86, -1, 16, 48, 86, -1, -1, 48,
- -1, 57, 63, 86, -1, -1, 6, 65, 76, -1,
- -1, 5, 66, 76, -1, 7, 54, 72, -1, 68,
- 69, 70, -1, 10, -1, 11, -1, 12, -1, -1,
- 54, -1, 71, -1, 70, 71, -1, 89, -1, 89,
- 4, -1, 89, -1, 72, 89, -1, 74, -1, 73,
- 74, -1, 89, -1, 54, -1, 55, -1, 56, -1,
- 54, -1, 87, -1, 87, 4, -1, 87, 90, -1,
- 87, 4, 90, -1, 75, -1, 76, 75, -1, 78,
- -1, 77, 78, -1, 79, -1, 62, 53, -1, 1,
- 53, -1, -1, 88, 83, 80, 81, -1, 82, -1,
- 81, 51, 82, -1, 81, 53, -1, -1, 82, 89,
- 83, -1, 82, 43, 83, -1, 82, 13, 89, -1,
- 82, 14, 4, -1, 82, 15, 54, -1, -1, 44,
- -1, 48, -1, 3, -1, -1, 48, -1, 3, -1,
- 43, -1, 48, -1, 45, -1, 49, -1, 87, -1,
- 90, -1, 3, -1, -1, 50, 46, -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+ /* YYRLINEYYN -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 230, 230, 238, 240, 244, 245, 255, 256, 261,
- 262, 267, 268, 269, 270, 271, 272, 277, 286, 287,
- 288, 289, 290, 291, 292, 293, 294, 295, 296, 311,
- 312, 336, 337, 338, 339, 343, 344, 345, 349, 361,
- 373, 377, 381, 388, 403, 404, 408, 420, 420, 425,
- 425, 430, 441, 456, 457, 458, 462, 463, 468, 470,
- 475, 476, 481, 483, 488, 489, 493, 494, 495, 496,
- 501, 506, 511, 517, 523, 534, 535, 544, 545, 551,
- 552, 553, 560, 560, 568, 569, 570, 575, 577, 579,
- 581, 583, 585, 590, 592, 603, 604, 609, 610, 611,
- 620, 640, 642, 651, 656, 657, 662, 669, 671
+ 0, 272, 272, 280, 282, 286, 287, 297, 301, 306,
+ 307, 312, 317, 318, 319, 320, 325, 334, 335, 336,
+ 337, 338, 339, 339, 340, 341, 365, 366, 367, 368,
+ 372, 373, 382, 383, 384, 388, 400, 404, 408, 415,
+ 426, 427, 437, 438, 442, 454, 454, 459, 459, 464,
+ 475, 490, 491, 492, 493, 497, 498, 503, 505, 510,
+ 511, 516, 518, 523, 524, 528, 529, 533, 534, 535,
+ 540, 545, 550, 556, 562, 573, 574, 583, 584, 590,
+ 591, 592, 599, 599, 607, 608, 609, 614, 616, 618,
+ 620, 622, 624, 626, 631, 633, 643, 644, 649, 650,
+ 651, 660, 680, 682, 691, 696, 697, 702, 709, 711
};
#endif
{
"\"end of file\"", "error", "$undefined", "\"string\"", "\"integer\"",
"\"%token\"", "\"%nterm\"", "\"%type\"", "\"%destructor\"",
- "\"%printer\"", "\"%left\"", "\"%right\"", "\"%nonassoc\"", "\"%prec\"",
- "\"%dprec\"", "\"%merge\"", "\"%code\"", "\"%debug\"",
+ "\"%printer\"", "\"%left\"", "\"%right\"", "\"%nonassoc\"",
+ "\"%precedence\"", "\"%prec\"", "\"%dprec\"", "\"%merge\"", "\"%code\"",
"\"%default-prec\"", "\"%define\"", "\"%defines\"", "\"%error-verbose\"",
- "\"%expect\"", "\"%expect-rr\"", "\"%file-prefix\"", "\"%glr-parser\"",
- "\"%initial-action\"", "\"%language\"", "\"%lex-param\"",
- "\"%locations\"", "\"%name-prefix\"", "\"%no-default-prec\"",
- "\"%no-lines\"", "\"%nondeterministic-parser\"", "\"%output\"",
- "\"%parse-param\"", "\"%pure-parser\"", "\"%require\"", "\"%skeleton\"",
- "\"%start\"", "\"%token-table\"", "\"%verbose\"", "\"%yacc\"",
- "\"{...}\"", "\"[identifier]\"", "\"char\"", "\"epilogue\"", "\"=\"",
- "\"identifier\"", "\"identifier:\"", "\"%%\"", "\"|\"", "\"%{...%}\"",
- "\";\"", "\"type\"", "\"<*>\"", "\"<>\"", "\"%union\"", "$accept",
- "input", "prologue_declarations", "prologue_declaration",
- "grammar_declaration", "union_name", "symbol_declaration", "$@1", "$@2",
- "precedence_declaration", "precedence_declarator", "type.opt",
+ "\"%expect\"", "\"%expect-rr\"", "\"%<flag>\"", "\"%file-prefix\"",
+ "\"%glr-parser\"", "\"%initial-action\"", "\"%language\"",
+ "\"%name-prefix\"", "\"%no-default-prec\"", "\"%no-lines\"",
+ "\"%nondeterministic-parser\"", "\"%output\"", "\"%require\"",
+ "\"%skeleton\"", "\"%start\"", "\"%token-table\"", "\"%verbose\"",
+ "\"%yacc\"", "\"{...}\"", "\"%?{...}\"", "\"[identifier]\"", "\"char\"",
+ "\"epilogue\"", "\"=\"", "\"identifier\"", "\"identifier:\"", "\"%%\"",
+ "\"|\"", "\"%{...%}\"", "\";\"", "\"<tag>\"", "\"<*>\"", "\"<>\"",
+ "\"%param\"", "\"%union\"", "$accept", "input", "prologue_declarations",
+ "prologue_declaration", "$@1", "params", "grammar_declaration",
+ "code_props_type", "union_name", "symbol_declaration", "$@2", "$@3",
+ "precedence_declaration", "precedence_declarator", "tag.opt",
"symbols.prec", "symbol.prec", "symbols.1", "generic_symlist",
- "generic_symlist_item", "symbol_def", "symbol_defs.1", "grammar",
- "rules_or_grammar_declaration", "rules", "$@3", "rhses.1", "rhs",
+ "generic_symlist_item", "tag", "symbol_def", "symbol_defs.1", "grammar",
+ "rules_or_grammar_declaration", "rules", "$@4", "rhses.1", "rhs",
"named_ref.opt", "variable", "content.opt", "braceless", "id",
"id_colon", "symbol", "string_as_id", "epilogue.opt", YY_NULL
};
#endif
# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
- token YYLEX-NUM. */
+/* YYTOKNUM[NUM] -- (External) token number corresponding to the
+ (internal) symbol number NUM (which must be that of a token). */
static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
- 305, 306, 307, 308, 309, 310, 311, 312
+ 305, 306, 307, 308, 309, 310, 311
};
# endif
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
+#define YYPACT_NINF -74
+
+#define yypact_value_is_default(Yystate) \
+ (!!((Yystate) == (-74)))
+
+#define YYTABLE_NINF -109
+
+#define yytable_value_is_error(Yytable_value) \
+ 0
+
+ /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+static const yytype_int16 yypact[] =
{
- 0, 58, 59, 60, 60, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 63, 63, 62, 65, 64, 66,
- 64, 64, 67, 68, 68, 68, 69, 69, 70, 70,
- 71, 71, 72, 72, 73, 73, 74, 74, 74, 74,
- 75, 75, 75, 75, 75, 76, 76, 77, 77, 78,
- 78, 78, 80, 79, 81, 81, 81, 82, 82, 82,
- 82, 82, 82, 83, 83, 84, 84, 85, 85, 85,
- 86, 87, 87, 88, 89, 89, 90, 91, 91
+ -74, 40, 101, -74, -74, -74, -48, -74, -74, -74,
+ -74, -74, -74, 19, -74, 0, 52, -74, 56, 79,
+ -74, 81, -74, 45, 83, 84, -74, -74, -74, 85,
+ 86, 87, 31, -74, -74, -74, 15, -74, -74, -74,
+ 46, -74, -74, 51, -74, -74, 42, 4, 4, 31,
+ -74, 57, -74, -74, -74, 36, -74, -74, -74, -74,
+ -74, -74, -74, -74, -74, -74, -74, -74, -74, -74,
+ -74, -74, 47, -74, 49, 1, -74, -74, 59, 62,
+ -74, 57, 26, -74, 31, -74, -74, 4, 72, 4,
+ 31, -74, -74, -74, -74, -74, -74, -74, 60, -74,
+ -74, -74, -74, -74, 63, -74, -74, -74, -74, 26,
+ -74, -74, -74, 31, -74, 111, -74, 113, -74, -74,
+ -74, -74, -74, -74, -74, -74, -74, -13, 27, -74,
+ -74, 31, 137, 65, 59, -74, 59, 27, -74, -74,
+ -74, -74, -74
};
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
+ /* YYDEFACT[S] -- default reduction number in state S. Performed when
+ YYTABLE does not specify something else to do. Zero means the default
+ is an error. */
+static const yytype_uint8 yydefact[] =
{
- 0, 2, 4, 0, 2, 1, 1, 1, 3, 1,
- 2, 1, 2, 2, 2, 3, 1, 2, 2, 2,
- 1, 2, 3, 1, 1, 2, 3, 2, 1, 2,
- 2, 1, 1, 1, 1, 1, 1, 2, 3, 3,
- 1, 1, 2, 3, 0, 1, 3, 0, 3, 0,
- 3, 3, 3, 1, 1, 1, 0, 1, 1, 2,
- 1, 2, 1, 2, 1, 2, 1, 1, 1, 1,
- 1, 1, 2, 2, 3, 1, 2, 1, 2, 1,
- 2, 2, 0, 4, 1, 3, 2, 0, 3, 3,
- 3, 3, 3, 0, 1, 1, 1, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 0, 2
+ 3, 0, 0, 1, 47, 45, 0, 40, 41, 51,
+ 52, 53, 54, 0, 36, 0, 9, 11, 0, 0,
+ 7, 0, 15, 0, 0, 0, 37, 19, 20, 0,
+ 0, 0, 0, 26, 27, 28, 0, 6, 29, 22,
+ 42, 4, 5, 0, 33, 32, 55, 0, 0, 0,
+ 101, 0, 38, 97, 96, 98, 10, 12, 13, 14,
+ 16, 17, 18, 21, 24, 25, 107, 103, 102, 105,
+ 34, 106, 0, 104, 0, 0, 77, 79, 94, 0,
+ 43, 0, 0, 56, 0, 70, 75, 48, 71, 46,
+ 49, 61, 39, 100, 99, 8, 81, 80, 0, 78,
+ 2, 95, 82, 31, 23, 44, 67, 68, 69, 35,
+ 63, 66, 65, 50, 57, 59, 76, 72, 73, 62,
+ 109, 87, 30, 64, 58, 60, 74, 83, 84, 87,
+ 86, 0, 0, 0, 94, 90, 94, 85, 91, 92,
+ 93, 89, 88
};
-/* 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 yytype_uint8 yydefact[] =
+ /* YYPGOTO[NTERM-NUM]. */
+static const yytype_int16 yypgoto[] =
{
- 3, 0, 0, 1, 49, 47, 0, 0, 0, 53,
- 54, 55, 0, 7, 40, 0, 9, 11, 0, 0,
- 0, 16, 0, 0, 0, 20, 0, 41, 23, 24,
- 0, 0, 28, 0, 0, 0, 31, 32, 33, 0,
- 6, 34, 44, 4, 5, 36, 35, 56, 0, 0,
- 0, 0, 0, 100, 0, 42, 96, 95, 97, 10,
- 12, 13, 14, 0, 17, 18, 19, 21, 0, 25,
- 0, 27, 29, 30, 106, 102, 101, 104, 37, 105,
- 0, 103, 0, 0, 77, 79, 93, 45, 0, 57,
- 0, 70, 75, 50, 71, 48, 51, 62, 67, 68,
- 69, 38, 64, 66, 39, 43, 99, 98, 8, 15,
- 22, 26, 81, 80, 0, 78, 2, 94, 82, 46,
- 52, 58, 60, 76, 72, 73, 63, 65, 108, 87,
- 59, 61, 74, 83, 84, 87, 86, 0, 0, 0,
- 93, 93, 85, 90, 91, 92, 89, 88
+ -74, -74, -74, -74, -74, -74, 140, -74, -74, -74,
+ -74, -74, -74, -74, -74, -74, 30, -74, -74, 35,
+ -74, -26, 97, -74, 71, -74, -74, -74, 18, -70,
+ -74, -74, -46, 6, -74, -32, -73, -74
};
-/* YYDEFGOTO[NTERM-NUM]. */
+ /* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
- -1, 1, 2, 43, 82, 88, 45, 49, 48, 46,
- 47, 90, 120, 121, 96, 101, 102, 92, 93, 83,
- 84, 85, 129, 133, 134, 118, 58, 108, 55, 77,
- 86, 103, 79, 116
+ -1, 1, 2, 41, 79, 104, 74, 43, 81, 44,
+ 48, 47, 45, 46, 84, 113, 114, 90, 109, 110,
+ 111, 86, 87, 75, 76, 77, 121, 127, 128, 102,
+ 55, 95, 52, 69, 78, 112, 71, 100
};
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-#define YYPACT_NINF -91
-static const yytype_int16 yypact[] =
+ /* 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. */
+static const yytype_int16 yytable[] =
{
- -91, 3, 103, -91, -91, -91, -36, 2, 10, -91,
- -91, -91, 9, -91, -91, 32, 60, -91, 65, 67,
- 27, -91, 41, 73, 51, -91, 39, -91, -91, -91,
- 40, 52, -91, 93, 95, 33, -91, -91, -91, 15,
- -91, -91, 53, -91, -91, -91, -91, 46, 43, 43,
- 33, 11, 11, -91, 61, -91, -91, -91, 35, -91,
- -91, -91, -91, 100, -91, -91, -91, -91, 102, -91,
- 113, -91, -91, -91, -91, -91, -91, -91, -91, -91,
- 64, -91, 94, 1, -91, -91, 62, -91, 61, -91,
- 33, -91, -91, 43, 86, 43, 33, -91, -91, -91,
- -91, 11, -91, -91, 11, -91, -91, -91, -91, -91,
- -91, -91, -91, -91, 72, -91, -91, -91, -91, -91,
- 33, -91, 142, -91, 145, -91, -91, -91, -91, -91,
- -91, -91, -91, 17, 34, -91, -91, 33, 146, 97,
- 62, 62, 34, -91, -91, -91, -91, -91
+ 70, -108, 72, 53, 49, 92, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 118, 72, 91, 13, 14,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 66,
+ 66, 26, 13, 14, 66, 105, 129, 32, 130, 93,
+ 3, 131, 132, 133, 126, 26, 54, 67, 73, 98,
+ 68, 32, 115, 88, 88, 56, 85, 40, 119, 50,
+ 57, 116, 73, 116, 141, 51, 142, 134, 135, 67,
+ 67, 40, 68, 68, 67, 66, 117, 68, 106, 107,
+ 108, 115, 94, 58, 59, 60, 61, 62, 63, 64,
+ 65, 82, 80, 88, 83, 88, 136, 50, 96, 138,
+ 97, 101, 103, 122, 120, 136, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 125, 66, 140, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35, 139, 42, 124, 123, 89, 99, 137, 0, 36,
+ 0, 37, 38, 0, 0, 0, 39, 40
};
-/* YYPGOTO[NTERM-NUM]. */
-static const yytype_int16 yypgoto[] =
+static const yytype_int16 yycheck[] =
{
- -91, -91, -91, -91, 147, -91, -91, -91, -91, -91,
- -91, -91, -91, 37, -91, 106, -60, -33, 105, -91,
- 69, -91, -91, -91, 24, -48, -91, -91, -49, -20,
- -91, -35, -90, -91
+ 32, 0, 1, 3, 52, 51, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 88, 1, 49, 17, 18,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 3,
+ 3, 30, 17, 18, 3, 81, 49, 36, 51, 3,
+ 0, 14, 15, 16, 117, 30, 46, 43, 47, 48,
+ 46, 36, 84, 47, 48, 3, 52, 56, 90, 40,
+ 4, 87, 47, 89, 134, 46, 136, 40, 41, 43,
+ 43, 56, 46, 46, 43, 3, 4, 46, 52, 53,
+ 54, 113, 46, 4, 3, 40, 3, 3, 3, 3,
+ 3, 40, 46, 87, 52, 89, 128, 40, 51, 131,
+ 51, 42, 40, 40, 44, 137, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 4, 3, 52, 17, 18,
+ 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
+ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+ 39, 4, 2, 113, 109, 48, 75, 129, -1, 48,
+ -1, 50, 51, -1, -1, -1, 55, 56
};
-/* 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 -108
-static const yytype_int16 yytable[] =
+ /* STOS_[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
{
- 78, -107, 80, 3, 125, 105, 4, 5, 6, 7,
- 8, 9, 10, 11, 74, 97, 80, 12, 50, 14,
- 4, 5, 6, 7, 8, 9, 10, 11, 94, 94,
- 62, 12, 27, 14, 132, 56, 74, 74, 106, 119,
- 35, 127, 67, 69, 127, 51, 27, 137, 138, 139,
- 81, 114, 53, 52, 35, 122, 75, 54, 42, 76,
- 123, 126, 123, 59, 81, 98, 99, 100, 135, 60,
- 136, 61, 42, 94, 63, 94, 65, 140, 75, 75,
- 57, 76, 76, 107, 64, 122, 68, 70, 75, 74,
- 124, 76, 146, 147, 66, 71, 72, 91, 73, 141,
- 89, 87, 143, 109, 53, 110, 117, 141, 4, 5,
- 6, 7, 8, 9, 10, 11, 111, 112, 128, 12,
- 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 131, 113, 74, 44,
- 144, 145, 115, 39, 95, 40, 41, 130, 104, 142,
- 42
+ 0, 58, 59, 0, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
+ 34, 35, 36, 37, 38, 39, 48, 50, 51, 55,
+ 56, 60, 63, 64, 66, 69, 70, 68, 67, 52,
+ 40, 46, 89, 3, 46, 87, 3, 4, 4, 3,
+ 40, 3, 3, 3, 3, 3, 3, 43, 46, 90,
+ 92, 93, 1, 47, 63, 80, 81, 82, 91, 61,
+ 46, 65, 40, 52, 71, 52, 78, 79, 90, 79,
+ 74, 92, 89, 3, 46, 88, 51, 51, 48, 81,
+ 94, 42, 86, 40, 62, 89, 52, 53, 54, 75,
+ 76, 77, 92, 72, 73, 92, 78, 4, 93, 92,
+ 44, 83, 40, 76, 73, 4, 93, 84, 85, 49,
+ 51, 14, 15, 16, 40, 41, 92, 85, 92, 4,
+ 52, 86, 86
};
-#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-91)))
-
-#define yytable_value_is_error(Yytable_value) \
- YYID (0)
-
-static const yytype_uint8 yycheck[] =
+ /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
{
- 35, 0, 1, 0, 94, 54, 5, 6, 7, 8,
- 9, 10, 11, 12, 3, 50, 1, 16, 54, 18,
- 5, 6, 7, 8, 9, 10, 11, 12, 48, 49,
- 3, 16, 31, 18, 124, 3, 3, 3, 3, 88,
- 39, 101, 3, 3, 104, 43, 31, 13, 14, 15,
- 49, 50, 43, 43, 39, 90, 45, 48, 57, 48,
- 93, 96, 95, 3, 49, 54, 55, 56, 51, 4,
- 53, 4, 57, 93, 47, 95, 3, 43, 45, 45,
- 48, 48, 48, 48, 43, 120, 47, 47, 45, 3,
- 4, 48, 140, 141, 43, 43, 3, 54, 3, 134,
- 54, 48, 137, 3, 43, 3, 44, 142, 5, 6,
- 7, 8, 9, 10, 11, 12, 3, 53, 46, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
- 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
- 37, 38, 39, 40, 41, 42, 4, 53, 3, 2,
- 4, 54, 83, 50, 49, 52, 53, 120, 52, 135,
- 57
+ 0, 57, 58, 59, 59, 60, 60, 60, 60, 60,
+ 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
+ 60, 60, 61, 60, 60, 60, 60, 60, 60, 60,
+ 62, 62, 63, 63, 63, 63, 63, 63, 63, 63,
+ 64, 64, 65, 65, 63, 67, 66, 68, 66, 66,
+ 69, 70, 70, 70, 70, 71, 71, 72, 72, 73,
+ 73, 74, 74, 75, 75, 76, 76, 77, 77, 77,
+ 78, 78, 78, 78, 78, 79, 79, 80, 80, 81,
+ 81, 81, 83, 82, 84, 84, 84, 85, 85, 85,
+ 85, 85, 85, 85, 86, 86, 87, 87, 88, 88,
+ 88, 89, 90, 90, 91, 92, 92, 93, 94, 94
};
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
+ /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
{
- 0, 59, 60, 0, 5, 6, 7, 8, 9, 10,
- 11, 12, 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
- 34, 35, 36, 37, 38, 39, 40, 41, 42, 50,
- 52, 53, 57, 61, 62, 64, 67, 68, 66, 65,
- 54, 43, 43, 43, 48, 86, 3, 48, 84, 3,
- 4, 4, 3, 47, 43, 3, 43, 3, 47, 3,
- 47, 43, 3, 3, 3, 45, 48, 87, 89, 90,
- 1, 49, 62, 77, 78, 79, 88, 48, 63, 54,
- 69, 54, 75, 76, 87, 76, 72, 89, 54, 55,
- 56, 73, 74, 89, 73, 86, 3, 48, 85, 3,
- 3, 3, 53, 53, 50, 78, 91, 44, 83, 86,
- 70, 71, 89, 75, 4, 90, 89, 74, 46, 80,
- 71, 4, 90, 81, 82, 51, 53, 13, 14, 15,
- 43, 89, 82, 89, 4, 54, 83, 83
+ 0, 2, 4, 0, 2, 1, 1, 1, 3, 1,
+ 2, 1, 2, 2, 2, 1, 2, 2, 2, 1,
+ 1, 2, 0, 3, 2, 2, 1, 1, 1, 1,
+ 2, 1, 1, 1, 2, 3, 1, 1, 2, 3,
+ 1, 1, 0, 1, 3, 0, 3, 0, 3, 3,
+ 3, 1, 1, 1, 1, 0, 1, 1, 2, 1,
+ 2, 1, 2, 1, 2, 1, 1, 1, 1, 1,
+ 1, 1, 2, 2, 3, 1, 2, 1, 2, 1,
+ 2, 2, 0, 4, 1, 3, 2, 0, 3, 3,
+ 2, 3, 3, 3, 0, 1, 1, 1, 0, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2
};
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#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 yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
#define YYRECOVERING() (!!yyerrstatus)
else \
{ \
yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (YYID (0))
+ YYERROR; \
+ } \
+while (0)
/* Error token number */
-#define YYTERROR 1
-#define YYERRCODE 256
+#define YYTERROR 1
+#define YYERRCODE 256
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
- if (YYID (N)) \
+ if (N) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
- while (YYID (0))
+ while (0)
#endif
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
# define YYFPRINTF fprintf
# endif
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (YYID (0))
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (0)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value, Location); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (YYID (0))
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value, Location); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (0)
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
-#else
-static void
-yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
- YYLTYPE const * const yylocationp;
-#endif
{
FILE *yyo = yyoutput;
- YYUSE (yyo);
+ YYUSE(yyo);
+ YYUSE (yylocationp);
if (!yyvaluep)
return;
- YYUSE (yylocationp);
# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# else
- YYUSE (yyoutput);
# endif
switch (yytype)
{
- case 3: /* "string" */
-/* Line 812 of yacc.c */
-#line 205 "parse-gram.y"
- { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).chars)), stderr); };
-/* Line 812 of yacc.c */
-#line 1091 "parse-gram.c"
- break;
- case 4: /* "integer" */
-/* Line 812 of yacc.c */
-#line 217 "parse-gram.y"
- { fprintf (stderr, "%d", ((*yyvaluep).integer)); };
-/* Line 812 of yacc.c */
-#line 1098 "parse-gram.c"
- break;
- case 43: /* "{...}" */
-/* Line 812 of yacc.c */
-#line 207 "parse-gram.y"
- { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).code)); };
-/* Line 812 of yacc.c */
-#line 1105 "parse-gram.c"
- break;
- case 44: /* "[identifier]" */
-/* Line 812 of yacc.c */
-#line 212 "parse-gram.y"
- { fprintf (stderr, "[%s]", ((*yyvaluep).uniqstr)); };
-/* Line 812 of yacc.c */
-#line 1112 "parse-gram.c"
- break;
- case 45: /* "char" */
-/* Line 812 of yacc.c */
-#line 199 "parse-gram.y"
- { fputs (char_name (((*yyvaluep).character)), stderr); };
-/* Line 812 of yacc.c */
-#line 1119 "parse-gram.c"
- break;
- case 46: /* "epilogue" */
-/* Line 812 of yacc.c */
-#line 207 "parse-gram.y"
- { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); };
-/* Line 812 of yacc.c */
-#line 1126 "parse-gram.c"
- break;
- case 48: /* "identifier" */
-/* Line 812 of yacc.c */
-#line 211 "parse-gram.y"
- { fputs (((*yyvaluep).uniqstr), stderr); };
-/* Line 812 of yacc.c */
-#line 1133 "parse-gram.c"
- break;
- case 49: /* "identifier:" */
-/* Line 812 of yacc.c */
-#line 213 "parse-gram.y"
- { fprintf (stderr, "%s:", ((*yyvaluep).uniqstr)); };
-/* Line 812 of yacc.c */
-#line 1140 "parse-gram.c"
- break;
- case 52: /* "%{...%}" */
-/* Line 812 of yacc.c */
-#line 207 "parse-gram.y"
- { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); };
-/* Line 812 of yacc.c */
-#line 1147 "parse-gram.c"
- break;
- case 54: /* "type" */
-/* Line 812 of yacc.c */
-#line 214 "parse-gram.y"
- { fprintf (stderr, "<%s>", ((*yyvaluep).uniqstr)); };
-/* Line 812 of yacc.c */
-#line 1154 "parse-gram.c"
- break;
- case 71: /* symbol.prec */
-/* Line 812 of yacc.c */
-#line 220 "parse-gram.y"
- { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); };
-/* Line 812 of yacc.c */
-#line 1161 "parse-gram.c"
- break;
- case 84: /* variable */
-/* Line 812 of yacc.c */
-#line 211 "parse-gram.y"
- { fputs (((*yyvaluep).uniqstr), stderr); };
-/* Line 812 of yacc.c */
-#line 1168 "parse-gram.c"
- break;
- case 85: /* content.opt */
-/* Line 812 of yacc.c */
-#line 207 "parse-gram.y"
- { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); };
-/* Line 812 of yacc.c */
-#line 1175 "parse-gram.c"
- break;
- case 86: /* braceless */
-/* Line 812 of yacc.c */
-#line 207 "parse-gram.y"
- { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); };
-/* Line 812 of yacc.c */
-#line 1182 "parse-gram.c"
- break;
- case 87: /* id */
-/* Line 812 of yacc.c */
-#line 220 "parse-gram.y"
- { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); };
-/* Line 812 of yacc.c */
-#line 1189 "parse-gram.c"
- break;
- case 88: /* id_colon */
-/* Line 812 of yacc.c */
-#line 221 "parse-gram.y"
- { fprintf (stderr, "%s:", ((*yyvaluep).symbol)->tag); };
-/* Line 812 of yacc.c */
-#line 1196 "parse-gram.c"
- break;
- case 89: /* symbol */
-/* Line 812 of yacc.c */
-#line 220 "parse-gram.y"
- { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); };
-/* Line 812 of yacc.c */
-#line 1203 "parse-gram.c"
- break;
- case 90: /* string_as_id */
-/* Line 812 of yacc.c */
-#line 220 "parse-gram.y"
- { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); };
-/* Line 812 of yacc.c */
-#line 1210 "parse-gram.c"
- break;
+ case 3: // "string"
+/* Line 711 of yacc.c */
+#line 196 "src/parse-gram.y"
+ { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).chars)), yyo); }
+/* Line 711 of yacc.c */
+#line 1011 "src/parse-gram.c"
+ break;
+
+ case 4: // "integer"
+/* Line 711 of yacc.c */
+#line 209 "src/parse-gram.y"
+ { fprintf (yyo, "%d", ((*yyvaluep).integer)); }
+/* Line 711 of yacc.c */
+#line 1019 "src/parse-gram.c"
+ break;
+
+ case 24: // "%<flag>"
+/* Line 711 of yacc.c */
+#line 205 "src/parse-gram.y"
+ { fprintf (yyo, "%%%s", ((*yyvaluep).uniqstr)); }
+/* Line 711 of yacc.c */
+#line 1027 "src/parse-gram.c"
+ break;
+
+ case 40: // "{...}"
+/* Line 711 of yacc.c */
+#line 198 "src/parse-gram.y"
+ { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).code)); }
+/* Line 711 of yacc.c */
+#line 1035 "src/parse-gram.c"
+ break;
+
+ case 42: // "[identifier]"
+/* Line 711 of yacc.c */
+#line 203 "src/parse-gram.y"
+ { fprintf (yyo, "[%s]", ((*yyvaluep).uniqstr)); }
+/* Line 711 of yacc.c */
+#line 1043 "src/parse-gram.c"
+ break;
+
+ case 43: // "char"
+/* Line 711 of yacc.c */
+#line 190 "src/parse-gram.y"
+ { fputs (char_name (((*yyvaluep).character)), yyo); }
+/* Line 711 of yacc.c */
+#line 1051 "src/parse-gram.c"
+ break;
+
+ case 44: // "epilogue"
+/* Line 711 of yacc.c */
+#line 198 "src/parse-gram.y"
+ { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).chars)); }
+/* Line 711 of yacc.c */
+#line 1059 "src/parse-gram.c"
+ break;
+
+ case 46: // "identifier"
+/* Line 711 of yacc.c */
+#line 202 "src/parse-gram.y"
+ { fputs (((*yyvaluep).uniqstr), yyo); }
+/* Line 711 of yacc.c */
+#line 1067 "src/parse-gram.c"
+ break;
+
+ case 47: // "identifier:"
+/* Line 711 of yacc.c */
+#line 204 "src/parse-gram.y"
+ { fprintf (yyo, "%s:", ((*yyvaluep).uniqstr)); }
+/* Line 711 of yacc.c */
+#line 1075 "src/parse-gram.c"
+ break;
+
+ case 50: // "%{...%}"
+/* Line 711 of yacc.c */
+#line 198 "src/parse-gram.y"
+ { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).chars)); }
+/* Line 711 of yacc.c */
+#line 1083 "src/parse-gram.c"
+ break;
+
+ case 52: // "<tag>"
+/* Line 711 of yacc.c */
+#line 206 "src/parse-gram.y"
+ { fprintf (yyo, "<%s>", ((*yyvaluep).uniqstr)); }
+/* Line 711 of yacc.c */
+#line 1091 "src/parse-gram.c"
+ break;
+
+ case 55: // "%param"
+/* Line 711 of yacc.c */
+#line 252 "src/parse-gram.y"
+ {
+ switch (((*yyvaluep).param))
+ {
+#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;
+ }
+}
+/* Line 711 of yacc.c */
+#line 1110 "src/parse-gram.c"
+ break;
+
+ case 64: // code_props_type
+/* Line 711 of yacc.c */
+#line 424 "src/parse-gram.y"
+ { fprintf (yyo, "%s", code_props_type_string (((*yyvaluep).code_type))); }
+/* Line 711 of yacc.c */
+#line 1118 "src/parse-gram.c"
+ break;
+
+ case 73: // symbol.prec
+/* Line 711 of yacc.c */
+#line 212 "src/parse-gram.y"
+ { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); }
+/* Line 711 of yacc.c */
+#line 1126 "src/parse-gram.c"
+ break;
+
+ case 77: // tag
+/* Line 711 of yacc.c */
+#line 206 "src/parse-gram.y"
+ { fprintf (yyo, "<%s>", ((*yyvaluep).uniqstr)); }
+/* Line 711 of yacc.c */
+#line 1134 "src/parse-gram.c"
+ break;
+
+ case 87: // variable
+/* Line 711 of yacc.c */
+#line 202 "src/parse-gram.y"
+ { fputs (((*yyvaluep).uniqstr), yyo); }
+/* Line 711 of yacc.c */
+#line 1142 "src/parse-gram.c"
+ break;
+
+ case 88: // content.opt
+/* Line 711 of yacc.c */
+#line 198 "src/parse-gram.y"
+ { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).chars)); }
+/* Line 711 of yacc.c */
+#line 1150 "src/parse-gram.c"
+ break;
+
+ case 89: // braceless
+/* Line 711 of yacc.c */
+#line 198 "src/parse-gram.y"
+ { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).chars)); }
+/* Line 711 of yacc.c */
+#line 1158 "src/parse-gram.c"
+ break;
+
+ case 90: // id
+/* Line 711 of yacc.c */
+#line 212 "src/parse-gram.y"
+ { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); }
+/* Line 711 of yacc.c */
+#line 1166 "src/parse-gram.c"
+ break;
+
+ case 91: // id_colon
+/* Line 711 of yacc.c */
+#line 213 "src/parse-gram.y"
+ { fprintf (yyo, "%s:", ((*yyvaluep).symbol)->tag); }
+/* Line 711 of yacc.c */
+#line 1174 "src/parse-gram.c"
+ break;
+
+ case 92: // symbol
+/* Line 711 of yacc.c */
+#line 212 "src/parse-gram.y"
+ { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); }
+/* Line 711 of yacc.c */
+#line 1182 "src/parse-gram.c"
+ break;
+
+ case 93: // string_as_id
+/* Line 711 of yacc.c */
+#line 212 "src/parse-gram.y"
+ { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); }
+/* Line 711 of yacc.c */
+#line 1190 "src/parse-gram.c"
+ break;
+
default:
- break;
+ break;
}
}
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
-#else
-static void
-yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
- YYLTYPE const * const yylocationp;
-#endif
{
if (yytype < YYNTOKENS)
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
| TOP (included). |
`------------------------------------------------------------------*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
-#else
-static void
-yy_stack_print (yybottom, yytop)
- yytype_int16 *yybottom;
- yytype_int16 *yytop;
-#endif
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
YYFPRINTF (stderr, "\n");
}
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (YYID (0))
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (0)
/*------------------------------------------------.
| Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
-#else
static void
-yy_reduce_print (yyvsp, yylsp, yyrule)
- YYSTYPE *yyvsp;
- YYLTYPE *yylsp;
- int yyrule;
-#endif
+yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
{
+ unsigned long int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
- unsigned long int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
+ yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- , &(yylsp[(yyi + 1) - (yynrhs)]) );
+ yy_symbol_print (stderr,
+ yystos[yyssp[yyi + 1 - yynrhs]],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ , &(yylsp[(yyi + 1) - (yynrhs)]) );
YYFPRINTF (stderr, "\n");
}
}
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyvsp, yylsp, Rule); \
-} while (YYID (0))
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
+} while (0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
+#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
goto yyerrlab; \
} \
} \
-} while (YYID (0))
+} while (0)
/* Discard any previous initial lookahead context because of Event,
which may be a lookahead change or an invalidation of the currently
Event "\n"); \
yy_lac_established = 0; \
} \
-} while (YYID (0))
+} while (0)
#else
# define YY_LAC_DISCARD(Event) yy_lac_established = 0
#endif
# define yystrlen strlen
# else
/* Return the length of YYSTR. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
static YYSIZE_T
yystrlen (const char *yystr)
-#else
-static YYSIZE_T
-yystrlen (yystr)
- const char *yystr;
-#endif
{
YYSIZE_T yylen;
for (yylen = 0; yystr[yylen]; yylen++)
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
static char *
yystpcpy (char *yydest, const char *yysrc)
-#else
-static char *
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-#endif
{
char *yyd = yydest;
const char *yys = yysrc;
char const *yyp = yystr;
for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
do_not_strip_quotes: ;
}
int yycount = 0;
/* 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
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
-#else
-static void
-yydestruct (yymsg, yytype, yyvaluep, yylocationp)
- const char *yymsg;
- int yytype;
- YYSTYPE *yyvaluep;
- YYLTYPE *yylocationp;
-#endif
{
- YYUSE (yyvaluep);
+ YYUSE(yyvaluep);
YYUSE (yylocationp);
-
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
switch (yytype)
{
-
default:
- break;
+ break;
}
}
| yyparse. |
`----------*/
-#ifdef YYPARSE_PARAM
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void *YYPARSE_PARAM)
-#else
-int
-yyparse (YYPARSE_PARAM)
- void *YYPARSE_PARAM;
-#endif
-#else /* ! YYPARSE_PARAM */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
int
yyparse (void)
-#else
-int
-yyparse ()
-
-#endif
-#endif
{
/* The lookahead symbol. */
int yychar;
yychar = YYEMPTY; /* Cause a token to be read. */
/* User initialization code. */
-/* Line 1560 of yacc.c */
-#line 107 "parse-gram.y"
+/* Line 1452 of yacc.c */
+#line 101 "src/parse-gram.y"
{
/* Bison's grammar can initial empty locations, hence a default
location is needed. */
boundary_set (&yylloc.start, current_file, 1, 1);
boundary_set (&yylloc.end, current_file, 1, 1);
}
-/* Line 1560 of yacc.c */
-#line 2008 "parse-gram.c"
+/* Line 1452 of yacc.c */
+#line 1912 "src/parse-gram.c"
yylsp[0] = yylloc;
goto yysetstate;
#ifdef yyoverflow
{
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
- YYLTYPE *yyls1 = yyls;
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
- &yyls1, yysize * sizeof (*yylsp),
- &yystacksize);
-
- yyls = yyls1;
- yyss = yyss1;
- yyvs = yyvs1;
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+ YYLTYPE *yyls1 = yyls;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yyls1, yysize * sizeof (*yylsp),
+ &yystacksize);
+
+ yyls = yyls1;
+ yyss = yyss1;
+ yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
+ goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
+ yystacksize = YYMAXDEPTH;
{
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss_alloc, yyss);
- YYSTACK_RELOCATE (yyvs_alloc, yyvs);
- YYSTACK_RELOCATE (yyls_alloc, yyls);
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+ YYSTACK_RELOCATE (yyls_alloc, yyls);
# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yylsp = yyls + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
+ (unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
+ YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
switch (yyn)
{
case 6:
-/* Line 1778 of yacc.c */
-#line 246 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 288 "src/parse-gram.y"
{
code_props plain_code;
- code_props_plain_init (&plain_code, (yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)]));
+ code_props_plain_init (&plain_code, (yyvsp[0].chars), (yylsp[0]));
code_props_translate_code (&plain_code);
gram_scanner_last_string_free ();
muscle_code_grow (union_seen ? "post_prologue" : "pre_prologue",
- plain_code.code, (yylsp[(1) - (1)]));
+ plain_code.code, (yylsp[0]));
code_scanner_last_string_free ();
}
+/* Line 1670 of yacc.c */
+#line 2118 "src/parse-gram.c"
break;
case 7:
-/* Line 1778 of yacc.c */
-#line 255 "parse-gram.y"
- { debug = true; }
+/* Line 1670 of yacc.c */
+#line 298 "src/parse-gram.y"
+ {
+ muscle_percent_define_ensure ((yyvsp[0].uniqstr), (yylsp[0]), true);
+ }
+/* Line 1670 of yacc.c */
+#line 2128 "src/parse-gram.c"
break;
case 8:
-/* Line 1778 of yacc.c */
-#line 257 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 302 "src/parse-gram.y"
{
- muscle_percent_define_insert ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars),
+ muscle_percent_define_insert ((yyvsp[-1].uniqstr), (yylsp[-1]), (yyvsp[0].chars),
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
}
+/* Line 1670 of yacc.c */
+#line 2139 "src/parse-gram.c"
break;
case 9:
-/* Line 1778 of yacc.c */
-#line 261 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 306 "src/parse-gram.y"
{ defines_flag = true; }
+/* Line 1670 of yacc.c */
+#line 2147 "src/parse-gram.c"
break;
case 10:
-/* Line 1778 of yacc.c */
-#line 263 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 308 "src/parse-gram.y"
{
defines_flag = true;
- spec_defines_file = xstrdup ((yyvsp[(2) - (2)].chars));
+ spec_defines_file = xstrdup ((yyvsp[0].chars));
}
+/* Line 1670 of yacc.c */
+#line 2158 "src/parse-gram.c"
break;
case 11:
-/* Line 1778 of yacc.c */
-#line 267 "parse-gram.y"
- { error_verbose = true; }
+/* Line 1670 of yacc.c */
+#line 313 "src/parse-gram.y"
+ {
+ muscle_percent_define_insert ("parse.error", (yylsp[0]), "verbose",
+ MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
+ }
+/* Line 1670 of yacc.c */
+#line 2169 "src/parse-gram.c"
break;
case 12:
-/* Line 1778 of yacc.c */
-#line 268 "parse-gram.y"
- { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); }
+/* Line 1670 of yacc.c */
+#line 317 "src/parse-gram.y"
+ { expected_sr_conflicts = (yyvsp[0].integer); }
+/* Line 1670 of yacc.c */
+#line 2177 "src/parse-gram.c"
break;
case 13:
-/* Line 1778 of yacc.c */
-#line 269 "parse-gram.y"
- { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); }
+/* Line 1670 of yacc.c */
+#line 318 "src/parse-gram.y"
+ { expected_rr_conflicts = (yyvsp[0].integer); }
+/* Line 1670 of yacc.c */
+#line 2185 "src/parse-gram.c"
break;
case 14:
-/* Line 1778 of yacc.c */
-#line 270 "parse-gram.y"
- { spec_file_prefix = (yyvsp[(2) - (2)].chars); }
+/* Line 1670 of yacc.c */
+#line 319 "src/parse-gram.y"
+ { spec_file_prefix = (yyvsp[0].chars); }
+/* Line 1670 of yacc.c */
+#line 2193 "src/parse-gram.c"
break;
case 15:
-/* Line 1778 of yacc.c */
-#line 271 "parse-gram.y"
- { spec_file_prefix = (yyvsp[(3) - (3)].chars); }
- break;
-
- case 16:
-/* Line 1778 of yacc.c */
-#line 273 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 321 "src/parse-gram.y"
{
nondeterministic_parser = true;
glr_parser = true;
}
+/* Line 1670 of yacc.c */
+#line 2204 "src/parse-gram.c"
break;
- case 17:
-/* Line 1778 of yacc.c */
-#line 278 "parse-gram.y"
+ case 16:
+/* Line 1670 of yacc.c */
+#line 326 "src/parse-gram.y"
{
code_props action;
- code_props_symbol_action_init (&action, (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)]));
+ code_props_symbol_action_init (&action, (yyvsp[0].code), (yylsp[0]));
code_props_translate_code (&action);
gram_scanner_last_string_free ();
- muscle_code_grow ("initial_action", action.code, (yylsp[(2) - (2)]));
+ muscle_code_grow ("initial_action", action.code, (yylsp[0]));
code_scanner_last_string_free ();
}
+/* Line 1670 of yacc.c */
+#line 2219 "src/parse-gram.c"
+ break;
+
+ case 17:
+/* Line 1670 of yacc.c */
+#line 334 "src/parse-gram.y"
+ { language_argmatch ((yyvsp[0].chars), grammar_prio, (yylsp[-1])); }
+/* Line 1670 of yacc.c */
+#line 2227 "src/parse-gram.c"
break;
case 18:
-/* Line 1778 of yacc.c */
-#line 286 "parse-gram.y"
- { language_argmatch ((yyvsp[(2) - (2)].chars), grammar_prio, (yylsp[(1) - (2)])); }
+/* Line 1670 of yacc.c */
+#line 335 "src/parse-gram.y"
+ { spec_name_prefix = (yyvsp[0].chars); }
+/* Line 1670 of yacc.c */
+#line 2235 "src/parse-gram.c"
break;
case 19:
-/* Line 1778 of yacc.c */
-#line 287 "parse-gram.y"
- { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
+/* Line 1670 of yacc.c */
+#line 336 "src/parse-gram.y"
+ { no_lines_flag = true; }
+/* Line 1670 of yacc.c */
+#line 2243 "src/parse-gram.c"
break;
case 20:
-/* Line 1778 of yacc.c */
-#line 288 "parse-gram.y"
- { locations_flag = true; }
+/* Line 1670 of yacc.c */
+#line 337 "src/parse-gram.y"
+ { nondeterministic_parser = true; }
+/* Line 1670 of yacc.c */
+#line 2251 "src/parse-gram.c"
break;
case 21:
-/* Line 1778 of yacc.c */
-#line 289 "parse-gram.y"
- { spec_name_prefix = (yyvsp[(2) - (2)].chars); }
+/* Line 1670 of yacc.c */
+#line 338 "src/parse-gram.y"
+ { spec_outfile = (yyvsp[0].chars); }
+/* Line 1670 of yacc.c */
+#line 2259 "src/parse-gram.c"
break;
case 22:
-/* Line 1778 of yacc.c */
-#line 290 "parse-gram.y"
- { spec_name_prefix = (yyvsp[(3) - (3)].chars); }
+/* Line 1670 of yacc.c */
+#line 339 "src/parse-gram.y"
+ { current_param = (yyvsp[0].param); }
+/* Line 1670 of yacc.c */
+#line 2267 "src/parse-gram.c"
break;
case 23:
-/* Line 1778 of yacc.c */
-#line 291 "parse-gram.y"
- { no_lines_flag = true; }
+/* Line 1670 of yacc.c */
+#line 339 "src/parse-gram.y"
+ { current_param = param_none; }
+/* Line 1670 of yacc.c */
+#line 2275 "src/parse-gram.c"
break;
case 24:
-/* Line 1778 of yacc.c */
-#line 292 "parse-gram.y"
- { nondeterministic_parser = true; }
+/* Line 1670 of yacc.c */
+#line 340 "src/parse-gram.y"
+ { version_check (&(yylsp[0]), (yyvsp[0].chars)); }
+/* Line 1670 of yacc.c */
+#line 2283 "src/parse-gram.c"
break;
case 25:
-/* Line 1778 of yacc.c */
-#line 293 "parse-gram.y"
- { spec_outfile = (yyvsp[(2) - (2)].chars); }
- break;
-
- case 26:
-/* Line 1778 of yacc.c */
-#line 294 "parse-gram.y"
- { spec_outfile = (yyvsp[(3) - (3)].chars); }
- break;
-
- case 27:
-/* Line 1778 of yacc.c */
-#line 295 "parse-gram.y"
- { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
- break;
-
- case 28:
-/* Line 1778 of yacc.c */
-#line 297 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 342 "src/parse-gram.y"
{
- /* %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", (yylsp[(1) - (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", (yylsp[(1) - (1)]), "",
- MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
- }
- break;
-
- case 29:
-/* Line 1778 of yacc.c */
-#line 311 "parse-gram.y"
- { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); }
- break;
-
- case 30:
-/* Line 1778 of yacc.c */
-#line 313 "parse-gram.y"
- {
- char const *skeleton_user = (yyvsp[(2) - (2)].chars);
- if (mbschr (skeleton_user, '/'))
+ char const *skeleton_user = (yyvsp[0].chars);
+ if (strchr (skeleton_user, '/'))
{
size_t dir_length = strlen (current_file);
char *skeleton_build;
skeleton_user = uniqstr_new (skeleton_build);
free (skeleton_build);
}
- skeleton_arg (skeleton_user, grammar_prio, (yylsp[(1) - (2)]));
+ skeleton_arg (skeleton_user, grammar_prio, (yylsp[-1]));
}
+/* Line 1670 of yacc.c */
+#line 2313 "src/parse-gram.c"
break;
- case 31:
-/* Line 1778 of yacc.c */
-#line 336 "parse-gram.y"
+ case 26:
+/* Line 1670 of yacc.c */
+#line 365 "src/parse-gram.y"
{ token_table_flag = true; }
+/* Line 1670 of yacc.c */
+#line 2321 "src/parse-gram.c"
break;
- case 32:
-/* Line 1778 of yacc.c */
-#line 337 "parse-gram.y"
+ case 27:
+/* Line 1670 of yacc.c */
+#line 366 "src/parse-gram.y"
{ report_flag |= report_states; }
+/* Line 1670 of yacc.c */
+#line 2329 "src/parse-gram.c"
break;
- case 33:
-/* Line 1778 of yacc.c */
-#line 338 "parse-gram.y"
+ case 28:
+/* Line 1670 of yacc.c */
+#line 367 "src/parse-gram.y"
{ yacc_flag = true; }
+/* Line 1670 of yacc.c */
+#line 2337 "src/parse-gram.c"
break;
- case 37:
-/* Line 1778 of yacc.c */
-#line 346 "parse-gram.y"
- {
- grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]));
- }
+ case 30:
+/* Line 1670 of yacc.c */
+#line 372 "src/parse-gram.y"
+ { add_param (current_param, (yyvsp[0].code), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2345 "src/parse-gram.c"
break;
- case 38:
-/* Line 1778 of yacc.c */
-#line 350 "parse-gram.y"
+ case 31:
+/* Line 1670 of yacc.c */
+#line 373 "src/parse-gram.y"
+ { add_param (current_param, (yyvsp[0].code), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2353 "src/parse-gram.c"
+ break;
+
+ case 34:
+/* Line 1670 of yacc.c */
+#line 385 "src/parse-gram.y"
{
- code_props code;
- code_props_symbol_action_init (&code, (yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]));
- code_props_translate_code (&code);
- {
- symbol_list *list;
- for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
- symbol_list_destructor_set (list, &code);
- symbol_list_free ((yyvsp[(3) - (3)].list));
- }
+ grammar_start_symbol_set ((yyvsp[0].symbol), (yylsp[0]));
}
+/* Line 1670 of yacc.c */
+#line 2363 "src/parse-gram.c"
break;
- case 39:
-/* Line 1778 of yacc.c */
-#line 362 "parse-gram.y"
+ case 35:
+/* Line 1670 of yacc.c */
+#line 389 "src/parse-gram.y"
{
code_props code;
- code_props_symbol_action_init (&code, (yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]));
+ code_props_symbol_action_init (&code, (yyvsp[-1].code), (yylsp[-1]));
code_props_translate_code (&code);
{
symbol_list *list;
- for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
- symbol_list_printer_set (list, &code);
- symbol_list_free ((yyvsp[(3) - (3)].list));
+ for (list = (yyvsp[0].list); list; list = list->next)
+ symbol_list_code_props_set (list, (yyvsp[-2].code_type), &code);
+ symbol_list_free ((yyvsp[0].list));
}
}
+/* Line 1670 of yacc.c */
+#line 2381 "src/parse-gram.c"
break;
- case 40:
-/* Line 1778 of yacc.c */
-#line 374 "parse-gram.y"
+ case 36:
+/* Line 1670 of yacc.c */
+#line 401 "src/parse-gram.y"
{
default_prec = true;
}
+/* Line 1670 of yacc.c */
+#line 2391 "src/parse-gram.c"
break;
- case 41:
-/* Line 1778 of yacc.c */
-#line 378 "parse-gram.y"
+ case 37:
+/* Line 1670 of yacc.c */
+#line 405 "src/parse-gram.y"
{
default_prec = false;
}
+/* Line 1670 of yacc.c */
+#line 2401 "src/parse-gram.c"
break;
- case 42:
-/* Line 1778 of yacc.c */
-#line 382 "parse-gram.y"
+ case 38:
+/* Line 1670 of yacc.c */
+#line 409 "src/parse-gram.y"
{
/* Do not invoke muscle_percent_code_grow here since it invokes
muscle_user_name_list_grow. */
- muscle_code_grow ("percent_code()", (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)]));
+ muscle_code_grow ("percent_code()", (yyvsp[0].chars), (yylsp[0]));
code_scanner_last_string_free ();
}
+/* Line 1670 of yacc.c */
+#line 2414 "src/parse-gram.c"
break;
- case 43:
-/* Line 1778 of yacc.c */
-#line 389 "parse-gram.y"
+ case 39:
+/* Line 1670 of yacc.c */
+#line 416 "src/parse-gram.y"
{
- muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)]));
+ muscle_percent_code_grow ((yyvsp[-1].uniqstr), (yylsp[-1]), (yyvsp[0].chars), (yylsp[0]));
code_scanner_last_string_free ();
}
+/* Line 1670 of yacc.c */
+#line 2425 "src/parse-gram.c"
break;
- case 44:
-/* Line 1778 of yacc.c */
-#line 403 "parse-gram.y"
+ case 40:
+/* Line 1670 of yacc.c */
+#line 426 "src/parse-gram.y"
+ { (yyval.code_type) = destructor; }
+/* Line 1670 of yacc.c */
+#line 2433 "src/parse-gram.c"
+ break;
+
+ case 41:
+/* Line 1670 of yacc.c */
+#line 427 "src/parse-gram.y"
+ { (yyval.code_type) = printer; }
+/* Line 1670 of yacc.c */
+#line 2441 "src/parse-gram.c"
+ break;
+
+ case 42:
+/* Line 1670 of yacc.c */
+#line 437 "src/parse-gram.y"
{}
+/* Line 1670 of yacc.c */
+#line 2449 "src/parse-gram.c"
break;
- case 45:
-/* Line 1778 of yacc.c */
-#line 404 "parse-gram.y"
- { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
+ case 43:
+/* Line 1670 of yacc.c */
+#line 438 "src/parse-gram.y"
+ { muscle_code_grow ("union_name", (yyvsp[0].uniqstr), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2457 "src/parse-gram.c"
break;
- case 46:
-/* Line 1778 of yacc.c */
-#line 409 "parse-gram.y"
+ case 44:
+/* Line 1670 of yacc.c */
+#line 443 "src/parse-gram.y"
{
union_seen = true;
- muscle_code_grow ("stype", (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)]));
+ muscle_code_grow ("stype", (yyvsp[0].chars), (yylsp[0]));
code_scanner_last_string_free ();
}
+/* Line 1670 of yacc.c */
+#line 2469 "src/parse-gram.c"
break;
- case 47:
-/* Line 1778 of yacc.c */
-#line 420 "parse-gram.y"
+ case 45:
+/* Line 1670 of yacc.c */
+#line 454 "src/parse-gram.y"
{ current_class = nterm_sym; }
+/* Line 1670 of yacc.c */
+#line 2477 "src/parse-gram.c"
break;
- case 48:
-/* Line 1778 of yacc.c */
-#line 421 "parse-gram.y"
+ case 46:
+/* Line 1670 of yacc.c */
+#line 455 "src/parse-gram.y"
{
current_class = unknown_sym;
current_type = NULL;
}
+/* Line 1670 of yacc.c */
+#line 2488 "src/parse-gram.c"
break;
- case 49:
-/* Line 1778 of yacc.c */
-#line 425 "parse-gram.y"
+ case 47:
+/* Line 1670 of yacc.c */
+#line 459 "src/parse-gram.y"
{ current_class = token_sym; }
+/* Line 1670 of yacc.c */
+#line 2496 "src/parse-gram.c"
break;
- case 50:
-/* Line 1778 of yacc.c */
-#line 426 "parse-gram.y"
+ case 48:
+/* Line 1670 of yacc.c */
+#line 460 "src/parse-gram.y"
{
current_class = unknown_sym;
current_type = NULL;
}
+/* Line 1670 of yacc.c */
+#line 2507 "src/parse-gram.c"
break;
- case 51:
-/* Line 1778 of yacc.c */
-#line 431 "parse-gram.y"
+ case 49:
+/* Line 1670 of yacc.c */
+#line 465 "src/parse-gram.y"
{
symbol_list *list;
tag_seen = true;
- for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
- symbol_type_set (list->content.sym, (yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]));
- symbol_list_free ((yyvsp[(3) - (3)].list));
+ for (list = (yyvsp[0].list); list; list = list->next)
+ symbol_type_set (list->content.sym, (yyvsp[-1].uniqstr), (yylsp[-1]));
+ symbol_list_free ((yyvsp[0].list));
}
+/* Line 1670 of yacc.c */
+#line 2521 "src/parse-gram.c"
break;
- case 52:
-/* Line 1778 of yacc.c */
-#line 442 "parse-gram.y"
+ case 50:
+/* Line 1670 of yacc.c */
+#line 476 "src/parse-gram.y"
{
symbol_list *list;
++current_prec;
- for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
- {
- symbol_type_set (list->content.sym, current_type, (yylsp[(2) - (3)]));
- symbol_precedence_set (list->content.sym, current_prec, (yyvsp[(1) - (3)].assoc), (yylsp[(1) - (3)]));
- }
- symbol_list_free ((yyvsp[(3) - (3)].list));
+ for (list = (yyvsp[0].list); list; list = list->next)
+ {
+ symbol_type_set (list->content.sym, current_type, (yylsp[-1]));
+ symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2]));
+ }
+ symbol_list_free ((yyvsp[0].list));
current_type = NULL;
}
+/* Line 1670 of yacc.c */
+#line 2539 "src/parse-gram.c"
break;
- case 53:
-/* Line 1778 of yacc.c */
-#line 456 "parse-gram.y"
+ case 51:
+/* Line 1670 of yacc.c */
+#line 490 "src/parse-gram.y"
{ (yyval.assoc) = left_assoc; }
+/* Line 1670 of yacc.c */
+#line 2547 "src/parse-gram.c"
break;
- case 54:
-/* Line 1778 of yacc.c */
-#line 457 "parse-gram.y"
+ case 52:
+/* Line 1670 of yacc.c */
+#line 491 "src/parse-gram.y"
{ (yyval.assoc) = right_assoc; }
+/* Line 1670 of yacc.c */
+#line 2555 "src/parse-gram.c"
break;
- case 55:
-/* Line 1778 of yacc.c */
-#line 458 "parse-gram.y"
+ case 53:
+/* Line 1670 of yacc.c */
+#line 492 "src/parse-gram.y"
{ (yyval.assoc) = non_assoc; }
+/* Line 1670 of yacc.c */
+#line 2563 "src/parse-gram.c"
break;
- case 56:
-/* Line 1778 of yacc.c */
-#line 462 "parse-gram.y"
+ case 54:
+/* Line 1670 of yacc.c */
+#line 493 "src/parse-gram.y"
+ { (yyval.assoc) = precedence_assoc; }
+/* Line 1670 of yacc.c */
+#line 2571 "src/parse-gram.c"
+ break;
+
+ case 55:
+/* Line 1670 of yacc.c */
+#line 497 "src/parse-gram.y"
{ current_type = NULL; }
+/* Line 1670 of yacc.c */
+#line 2579 "src/parse-gram.c"
+ break;
+
+ case 56:
+/* Line 1670 of yacc.c */
+#line 498 "src/parse-gram.y"
+ { current_type = (yyvsp[0].uniqstr); tag_seen = true; }
+/* Line 1670 of yacc.c */
+#line 2587 "src/parse-gram.c"
break;
case 57:
-/* Line 1778 of yacc.c */
-#line 463 "parse-gram.y"
- { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; }
+/* Line 1670 of yacc.c */
+#line 504 "src/parse-gram.y"
+ { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2595 "src/parse-gram.c"
break;
case 58:
-/* Line 1778 of yacc.c */
-#line 469 "parse-gram.y"
- { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
+/* Line 1670 of yacc.c */
+#line 506 "src/parse-gram.y"
+ { (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); }
+/* Line 1670 of yacc.c */
+#line 2603 "src/parse-gram.c"
break;
case 59:
-/* Line 1778 of yacc.c */
-#line 471 "parse-gram.y"
- { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); }
+/* Line 1670 of yacc.c */
+#line 510 "src/parse-gram.y"
+ { (yyval.symbol) = (yyvsp[0].symbol); }
+/* Line 1670 of yacc.c */
+#line 2611 "src/parse-gram.c"
break;
case 60:
-/* Line 1778 of yacc.c */
-#line 475 "parse-gram.y"
- { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); }
+/* Line 1670 of yacc.c */
+#line 511 "src/parse-gram.y"
+ { (yyval.symbol) = (yyvsp[-1].symbol); symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2619 "src/parse-gram.c"
break;
case 61:
-/* Line 1778 of yacc.c */
-#line 476 "parse-gram.y"
- { (yyval.symbol) = (yyvsp[(1) - (2)].symbol); symbol_user_token_number_set ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].integer), (yylsp[(2) - (2)])); }
+/* Line 1670 of yacc.c */
+#line 517 "src/parse-gram.y"
+ { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2627 "src/parse-gram.c"
break;
case 62:
-/* Line 1778 of yacc.c */
-#line 482 "parse-gram.y"
- { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
+/* Line 1670 of yacc.c */
+#line 519 "src/parse-gram.y"
+ { (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); }
+/* Line 1670 of yacc.c */
+#line 2635 "src/parse-gram.c"
break;
case 63:
-/* Line 1778 of yacc.c */
-#line 484 "parse-gram.y"
- { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); }
+/* Line 1670 of yacc.c */
+#line 523 "src/parse-gram.y"
+ { (yyval.list) = (yyvsp[0].list); }
+/* Line 1670 of yacc.c */
+#line 2643 "src/parse-gram.c"
break;
case 64:
-/* Line 1778 of yacc.c */
-#line 488 "parse-gram.y"
- { (yyval.list) = (yyvsp[(1) - (1)].list); }
+/* Line 1670 of yacc.c */
+#line 524 "src/parse-gram.y"
+ { (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), (yyvsp[0].list)); }
+/* Line 1670 of yacc.c */
+#line 2651 "src/parse-gram.c"
break;
case 65:
-/* Line 1778 of yacc.c */
-#line 489 "parse-gram.y"
- { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); }
+/* Line 1670 of yacc.c */
+#line 528 "src/parse-gram.y"
+ { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2659 "src/parse-gram.c"
break;
case 66:
-/* Line 1778 of yacc.c */
-#line 493 "parse-gram.y"
- { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
- break;
-
- case 67:
-/* Line 1778 of yacc.c */
-#line 494 "parse-gram.y"
- { (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
+/* Line 1670 of yacc.c */
+#line 529 "src/parse-gram.y"
+ { (yyval.list) = symbol_list_type_new ((yyvsp[0].uniqstr), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2667 "src/parse-gram.c"
break;
case 68:
-/* Line 1778 of yacc.c */
-#line 495 "parse-gram.y"
- { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); }
+/* Line 1670 of yacc.c */
+#line 534 "src/parse-gram.y"
+ { (yyval.uniqstr) = uniqstr_new ("*"); }
+/* Line 1670 of yacc.c */
+#line 2675 "src/parse-gram.c"
break;
case 69:
-/* Line 1778 of yacc.c */
-#line 496 "parse-gram.y"
- { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); }
+/* Line 1670 of yacc.c */
+#line 535 "src/parse-gram.y"
+ { (yyval.uniqstr) = uniqstr_new (""); }
+/* Line 1670 of yacc.c */
+#line 2683 "src/parse-gram.c"
break;
case 70:
-/* Line 1778 of yacc.c */
-#line 502 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 541 "src/parse-gram.y"
{
- current_type = (yyvsp[(1) - (1)].uniqstr);
+ current_type = (yyvsp[0].uniqstr);
tag_seen = true;
}
+/* Line 1670 of yacc.c */
+#line 2694 "src/parse-gram.c"
break;
case 71:
-/* Line 1778 of yacc.c */
-#line 507 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 546 "src/parse-gram.y"
{
- symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true);
- symbol_type_set ((yyvsp[(1) - (1)].symbol), current_type, (yylsp[(1) - (1)]));
+ symbol_class_set ((yyvsp[0].symbol), current_class, (yylsp[0]), true);
+ symbol_type_set ((yyvsp[0].symbol), current_type, (yylsp[0]));
}
+/* Line 1670 of yacc.c */
+#line 2705 "src/parse-gram.c"
break;
case 72:
-/* Line 1778 of yacc.c */
-#line 512 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 551 "src/parse-gram.y"
{
- symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
- symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)]));
- symbol_user_token_number_set ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].integer), (yylsp[(2) - (2)]));
+ symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1]), true);
+ symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1]));
+ symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0]));
}
+/* Line 1670 of yacc.c */
+#line 2717 "src/parse-gram.c"
break;
case 73:
-/* Line 1778 of yacc.c */
-#line 518 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 557 "src/parse-gram.y"
{
- symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
- symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)]));
- symbol_make_alias ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].symbol), (yyloc));
+ symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1]), true);
+ symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1]));
+ symbol_make_alias ((yyvsp[-1].symbol), (yyvsp[0].symbol), (yyloc));
}
+/* Line 1670 of yacc.c */
+#line 2729 "src/parse-gram.c"
break;
case 74:
-/* Line 1778 of yacc.c */
-#line 524 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 563 "src/parse-gram.y"
{
- symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true);
- symbol_type_set ((yyvsp[(1) - (3)].symbol), current_type, (yylsp[(1) - (3)]));
- symbol_user_token_number_set ((yyvsp[(1) - (3)].symbol), (yyvsp[(2) - (3)].integer), (yylsp[(2) - (3)]));
- symbol_make_alias ((yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol), (yyloc));
+ symbol_class_set ((yyvsp[-2].symbol), current_class, (yylsp[-2]), true);
+ symbol_type_set ((yyvsp[-2].symbol), current_type, (yylsp[-2]));
+ symbol_user_token_number_set ((yyvsp[-2].symbol), (yyvsp[-1].integer), (yylsp[-1]));
+ symbol_make_alias ((yyvsp[-2].symbol), (yyvsp[0].symbol), (yyloc));
}
+/* Line 1670 of yacc.c */
+#line 2742 "src/parse-gram.c"
break;
case 81:
-/* Line 1778 of yacc.c */
-#line 554 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 593 "src/parse-gram.y"
{
yyerrok;
}
+/* Line 1670 of yacc.c */
+#line 2752 "src/parse-gram.c"
break;
case 82:
-/* Line 1778 of yacc.c */
-#line 560 "parse-gram.y"
- { current_lhs ((yyvsp[(1) - (2)].symbol), (yylsp[(1) - (2)]), (yyvsp[(2) - (2)].named_ref)); }
+/* Line 1670 of yacc.c */
+#line 599 "src/parse-gram.y"
+ { current_lhs ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].named_ref)); }
+/* Line 1670 of yacc.c */
+#line 2760 "src/parse-gram.c"
break;
case 83:
-/* Line 1778 of yacc.c */
-#line 561 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 600 "src/parse-gram.y"
{
/* Free the current lhs. */
- current_lhs (0, (yylsp[(1) - (4)]), 0);
+ current_lhs (0, (yylsp[-3]), 0);
}
+/* Line 1670 of yacc.c */
+#line 2771 "src/parse-gram.c"
break;
case 84:
-/* Line 1778 of yacc.c */
-#line 568 "parse-gram.y"
- { grammar_current_rule_end ((yylsp[(1) - (1)])); }
+/* Line 1670 of yacc.c */
+#line 607 "src/parse-gram.y"
+ { grammar_current_rule_end ((yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2779 "src/parse-gram.c"
break;
case 85:
-/* Line 1778 of yacc.c */
-#line 569 "parse-gram.y"
- { grammar_current_rule_end ((yylsp[(3) - (3)])); }
+/* Line 1670 of yacc.c */
+#line 608 "src/parse-gram.y"
+ { grammar_current_rule_end ((yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2787 "src/parse-gram.c"
break;
case 87:
-/* Line 1778 of yacc.c */
-#line 575 "parse-gram.y"
+/* Line 1670 of yacc.c */
+#line 614 "src/parse-gram.y"
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
- current_lhs_named_ref); }
+ current_lhs_named_ref); }
+/* Line 1670 of yacc.c */
+#line 2796 "src/parse-gram.c"
break;
case 88:
-/* Line 1778 of yacc.c */
-#line 578 "parse-gram.y"
- { grammar_current_rule_symbol_append ((yyvsp[(2) - (3)].symbol), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); }
+/* Line 1670 of yacc.c */
+#line 617 "src/parse-gram.y"
+ { grammar_current_rule_symbol_append ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].named_ref)); }
+/* Line 1670 of yacc.c */
+#line 2804 "src/parse-gram.c"
break;
case 89:
-/* Line 1778 of yacc.c */
-#line 580 "parse-gram.y"
- { grammar_current_rule_action_append ((yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); }
+/* Line 1670 of yacc.c */
+#line 619 "src/parse-gram.y"
+ { grammar_current_rule_action_append ((yyvsp[-1].code), (yylsp[-1]), (yyvsp[0].named_ref), false); }
+/* Line 1670 of yacc.c */
+#line 2812 "src/parse-gram.c"
break;
case 90:
-/* Line 1778 of yacc.c */
-#line 582 "parse-gram.y"
- { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); }
+/* Line 1670 of yacc.c */
+#line 621 "src/parse-gram.y"
+ { grammar_current_rule_action_append ((yyvsp[0].code), (yylsp[0]), NULL, true); }
+/* Line 1670 of yacc.c */
+#line 2820 "src/parse-gram.c"
break;
case 91:
-/* Line 1778 of yacc.c */
-#line 584 "parse-gram.y"
- { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); }
+/* Line 1670 of yacc.c */
+#line 623 "src/parse-gram.y"
+ { grammar_current_rule_prec_set ((yyvsp[0].symbol), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2828 "src/parse-gram.c"
break;
case 92:
-/* Line 1778 of yacc.c */
-#line 586 "parse-gram.y"
- { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); }
+/* Line 1670 of yacc.c */
+#line 625 "src/parse-gram.y"
+ { grammar_current_rule_dprec_set ((yyvsp[0].integer), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2836 "src/parse-gram.c"
break;
case 93:
-/* Line 1778 of yacc.c */
-#line 590 "parse-gram.y"
- { (yyval.named_ref) = 0; }
+/* Line 1670 of yacc.c */
+#line 627 "src/parse-gram.y"
+ { grammar_current_rule_merge_set ((yyvsp[0].uniqstr), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2844 "src/parse-gram.c"
break;
case 94:
-/* Line 1778 of yacc.c */
-#line 592 "parse-gram.y"
- { (yyval.named_ref) = named_ref_new((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
+/* Line 1670 of yacc.c */
+#line 631 "src/parse-gram.y"
+ { (yyval.named_ref) = 0; }
+/* Line 1670 of yacc.c */
+#line 2852 "src/parse-gram.c"
break;
- case 96:
-/* Line 1778 of yacc.c */
-#line 604 "parse-gram.y"
- { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); }
+ case 95:
+/* Line 1670 of yacc.c */
+#line 633 "src/parse-gram.y"
+ { (yyval.named_ref) = named_ref_new((yyvsp[0].uniqstr), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2860 "src/parse-gram.c"
break;
case 97:
-/* Line 1778 of yacc.c */
-#line 609 "parse-gram.y"
- { (yyval.chars) = ""; }
+/* Line 1670 of yacc.c */
+#line 644 "src/parse-gram.y"
+ { (yyval.uniqstr) = uniqstr_new ((yyvsp[0].chars)); }
+/* Line 1670 of yacc.c */
+#line 2868 "src/parse-gram.c"
break;
case 98:
-/* Line 1778 of yacc.c */
-#line 610 "parse-gram.y"
- { (yyval.chars) = (yyvsp[(1) - (1)].uniqstr); }
+/* Line 1670 of yacc.c */
+#line 649 "src/parse-gram.y"
+ { (yyval.chars) = ""; }
+/* Line 1670 of yacc.c */
+#line 2876 "src/parse-gram.c"
+ break;
+
+ case 99:
+/* Line 1670 of yacc.c */
+#line 650 "src/parse-gram.y"
+ { (yyval.chars) = (yyvsp[0].uniqstr); }
+/* Line 1670 of yacc.c */
+#line 2884 "src/parse-gram.c"
break;
- case 100:
-/* Line 1778 of yacc.c */
-#line 621 "parse-gram.y"
+ case 101:
+/* Line 1670 of yacc.c */
+#line 661 "src/parse-gram.y"
{
code_props plain_code;
- (yyvsp[(1) - (1)].code)[strlen ((yyvsp[(1) - (1)].code)) - 1] = '\n';
- code_props_plain_init (&plain_code, (yyvsp[(1) - (1)].code)+1, (yylsp[(1) - (1)]));
+ (yyvsp[0].code)[strlen ((yyvsp[0].code)) - 1] = '\n';
+ code_props_plain_init (&plain_code, (yyvsp[0].code)+1, (yylsp[0]));
code_props_translate_code (&plain_code);
gram_scanner_last_string_free ();
(yyval.chars) = plain_code.code;
}
+/* Line 1670 of yacc.c */
+#line 2899 "src/parse-gram.c"
break;
- case 101:
-/* Line 1778 of yacc.c */
-#line 641 "parse-gram.y"
- { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
+ case 102:
+/* Line 1670 of yacc.c */
+#line 681 "src/parse-gram.y"
+ { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[0].uniqstr), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2907 "src/parse-gram.c"
break;
- case 102:
-/* Line 1778 of yacc.c */
-#line 643 "parse-gram.y"
+ case 103:
+/* Line 1670 of yacc.c */
+#line 683 "src/parse-gram.y"
{
- (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)]));
- symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false);
- symbol_user_token_number_set ((yyval.symbol), (yyvsp[(1) - (1)].character), (yylsp[(1) - (1)]));
+ (yyval.symbol) = symbol_get (char_name ((yyvsp[0].character)), (yylsp[0]));
+ symbol_class_set ((yyval.symbol), token_sym, (yylsp[0]), false);
+ symbol_user_token_number_set ((yyval.symbol), (yyvsp[0].character), (yylsp[0]));
}
+/* Line 1670 of yacc.c */
+#line 2919 "src/parse-gram.c"
break;
- case 103:
-/* Line 1778 of yacc.c */
-#line 651 "parse-gram.y"
- { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
+ case 104:
+/* Line 1670 of yacc.c */
+#line 691 "src/parse-gram.y"
+ { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[0].uniqstr), (yylsp[0])); }
+/* Line 1670 of yacc.c */
+#line 2927 "src/parse-gram.c"
break;
- case 106:
-/* Line 1778 of yacc.c */
-#line 663 "parse-gram.y"
+ case 107:
+/* Line 1670 of yacc.c */
+#line 703 "src/parse-gram.y"
{
- (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)]));
- symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false);
+ (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[0].chars)), (yylsp[0]));
+ symbol_class_set ((yyval.symbol), token_sym, (yylsp[0]), false);
}
+/* Line 1670 of yacc.c */
+#line 2938 "src/parse-gram.c"
break;
- case 108:
-/* Line 1778 of yacc.c */
-#line 672 "parse-gram.y"
+ case 109:
+/* Line 1670 of yacc.c */
+#line 712 "src/parse-gram.y"
{
code_props plain_code;
- code_props_plain_init (&plain_code, (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)]));
+ code_props_plain_init (&plain_code, (yyvsp[0].chars), (yylsp[0]));
code_props_translate_code (&plain_code);
gram_scanner_last_string_free ();
- muscle_code_grow ("epilogue", plain_code.code, (yylsp[(2) - (2)]));
+ muscle_code_grow ("epilogue", plain_code.code, (yylsp[0]));
code_scanner_last_string_free ();
}
+/* Line 1670 of yacc.c */
+#line 2953 "src/parse-gram.c"
break;
-/* Line 1778 of yacc.c */
-#line 2896 "parse-gram.c"
+/* Line 1670 of yacc.c */
+#line 2958 "src/parse-gram.c"
default: break;
}
if (yychar_backup != yychar)
goto yynewstate;
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
+/*--------------------------------------.
+| yyerrlab -- here on detecting error. |
+`--------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
- error, discard it. */
+ error, discard it. */
if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval, &yylloc);
- yychar = YYEMPTY;
- }
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval, &yylloc);
+ yychar = YYEMPTY;
+ }
}
/* Else will try to reuse lookahead token after shifting the error
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
- YYABORT;
+ YYABORT;
yyerror_range[1] = *yylsp;
yydestruct ("Error: popping",
- yystos[yystate], yyvsp, yylsp);
+ yystos[yystate], yyvsp, yylsp);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp, yylsp);
+ yystos[*yyssp], yyvsp, yylsp);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
- /* Make sure YYID is used. */
- return YYID (yyresult);
+ return yyresult;
}
-
-
-/* Line 2041 of yacc.c */
-#line 682 "parse-gram.y"
-
+/* Line 1930 of yacc.c */
+#line 722 "src/parse-gram.y"
/* Return the location of the left-hand side of a rule whose
for (i = 1; i <= n; i++)
if (! equal_boundaries (rhs[i].start, rhs[i].end))
{
- loc.start = rhs[i].start;
- break;
+ loc.start = rhs[i].start;
+ break;
}
return loc;
}
-/* Add a lex-param or a parse-param (depending on TYPE) with
- declaration DECL and location LOC. */
-
static void
-add_param (char const *type, char *decl, location loc)
+add_param (param_type type, char *decl, location loc)
{
static char const alphanum[26 + 26 + 1 + 10] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"_"
"0123456789";
+
char const *name_start = NULL;
- char *p;
-
- /* Stop on last actual character. */
- for (p = decl; p[1]; p++)
- if ((p == decl
- || ! memchr (alphanum, p[-1], sizeof alphanum))
- && memchr (alphanum, p[0], sizeof alphanum - 10))
- name_start = p;
-
- /* Strip the surrounding '{' and '}', and any blanks just inside
- the braces. */
- --p;
- while (c_isspace ((unsigned char) *p))
+ {
+ char *p;
+ /* Stop on last actual character. */
+ for (p = decl; p[1]; p++)
+ if ((p == decl
+ || ! memchr (alphanum, p[-1], sizeof alphanum))
+ && memchr (alphanum, p[0], sizeof alphanum - 10))
+ name_start = p;
+
+ /* Strip the surrounding '{' and '}', and any blanks just inside
+ the braces. */
--p;
- p[1] = '\0';
- ++decl;
- while (c_isspace ((unsigned char) *decl))
+ while (c_isspace ((unsigned char) *p))
+ --p;
+ p[1] = '\0';
++decl;
+ while (c_isspace ((unsigned char) *decl))
+ ++decl;
+ }
if (! name_start)
- complain_at (loc, _("missing identifier in parameter declaration"));
+ complain (&loc, complaint, _("missing identifier in parameter declaration"));
else
{
char *name = xmemdup0 (name_start, strspn (name_start, alphanum));
- muscle_pair_list_grow (type, decl, name);
+ if (type & param_lex)
+ muscle_pair_list_grow ("lex_param", decl, name);
+ if (type & param_parse)
+ muscle_pair_list_grow ("parse_param", decl, name);
free (name);
}
{
if (strverscmp (version, PACKAGE_VERSION) > 0)
{
- complain_at (*loc, "require bison %s, but have %s",
- version, PACKAGE_VERSION);
+ complain (loc, complaint, "require bison %s, but have %s",
+ version, PACKAGE_VERSION);
exit (EX_MISMATCH);
}
}
static void
gram_error (location const *loc, char const *msg)
{
- complain_at (*loc, "%s", msg);
+ complain (loc, complaint, "%s", msg);
}
char const *
-/* A Bison parser, made by GNU Bison 2.6.5.63-3ada. */
+/* A Bison parser, made by GNU Bison 2.6.5.977-6d58-dirty. */
/* Bison interface for Yacc-like parsers in C
-
- Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
-
+
+ Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
-#ifndef YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED
-# define YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED
+#ifndef YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED
+# define YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED
/* Enabling traces. */
#ifndef GRAM_DEBUG
# if defined YYDEBUG
-# if YYDEBUG
+#if YYDEBUG
# define GRAM_DEBUG 1
# else
# define GRAM_DEBUG 0
#if GRAM_DEBUG
extern int gram_debug;
#endif
+/* "%code requires" blocks. */
+/* Line 1931 of yacc.c */
+#line 223 "src/parse-gram.y"
+
+# 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
+
+
+/* Line 1931 of yacc.c */
+#line 68 "src/parse-gram.h"
/* Tokens. */
#ifndef GRAM_TOKENTYPE
# define GRAM_TOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum gram_tokentype {
- GRAM_EOF = 0,
- STRING = 258,
- INT = 259,
- PERCENT_TOKEN = 260,
- PERCENT_NTERM = 261,
- PERCENT_TYPE = 262,
- PERCENT_DESTRUCTOR = 263,
- PERCENT_PRINTER = 264,
- PERCENT_LEFT = 265,
- PERCENT_RIGHT = 266,
- PERCENT_NONASSOC = 267,
- PERCENT_PREC = 268,
- PERCENT_DPREC = 269,
- PERCENT_MERGE = 270,
- PERCENT_CODE = 271,
- PERCENT_DEBUG = 272,
- PERCENT_DEFAULT_PREC = 273,
- PERCENT_DEFINE = 274,
- PERCENT_DEFINES = 275,
- PERCENT_ERROR_VERBOSE = 276,
- PERCENT_EXPECT = 277,
- PERCENT_EXPECT_RR = 278,
- PERCENT_FILE_PREFIX = 279,
- PERCENT_GLR_PARSER = 280,
- PERCENT_INITIAL_ACTION = 281,
- PERCENT_LANGUAGE = 282,
- PERCENT_LEX_PARAM = 283,
- PERCENT_LOCATIONS = 284,
- PERCENT_NAME_PREFIX = 285,
- PERCENT_NO_DEFAULT_PREC = 286,
- PERCENT_NO_LINES = 287,
- PERCENT_NONDETERMINISTIC_PARSER = 288,
- PERCENT_OUTPUT = 289,
- PERCENT_PARSE_PARAM = 290,
- PERCENT_PURE_PARSER = 291,
- PERCENT_REQUIRE = 292,
- PERCENT_SKELETON = 293,
- PERCENT_START = 294,
- PERCENT_TOKEN_TABLE = 295,
- PERCENT_VERBOSE = 296,
- PERCENT_YACC = 297,
- BRACED_CODE = 298,
- BRACKETED_ID = 299,
- CHAR = 300,
- EPILOGUE = 301,
- EQUAL = 302,
- ID = 303,
- ID_COLON = 304,
- PERCENT_PERCENT = 305,
- PIPE = 306,
- PROLOGUE = 307,
- SEMICOLON = 308,
- TYPE = 309,
- TYPE_TAG_ANY = 310,
- TYPE_TAG_NONE = 311,
- PERCENT_UNION = 312
- };
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum gram_tokentype
+ {
+ GRAM_EOF = 0,
+ STRING = 258,
+ INT = 259,
+ PERCENT_TOKEN = 260,
+ PERCENT_NTERM = 261,
+ PERCENT_TYPE = 262,
+ PERCENT_DESTRUCTOR = 263,
+ PERCENT_PRINTER = 264,
+ PERCENT_LEFT = 265,
+ PERCENT_RIGHT = 266,
+ PERCENT_NONASSOC = 267,
+ PERCENT_PRECEDENCE = 268,
+ PERCENT_PREC = 269,
+ PERCENT_DPREC = 270,
+ PERCENT_MERGE = 271,
+ PERCENT_CODE = 272,
+ PERCENT_DEFAULT_PREC = 273,
+ PERCENT_DEFINE = 274,
+ PERCENT_DEFINES = 275,
+ PERCENT_ERROR_VERBOSE = 276,
+ PERCENT_EXPECT = 277,
+ PERCENT_EXPECT_RR = 278,
+ PERCENT_FLAG = 279,
+ PERCENT_FILE_PREFIX = 280,
+ PERCENT_GLR_PARSER = 281,
+ PERCENT_INITIAL_ACTION = 282,
+ PERCENT_LANGUAGE = 283,
+ PERCENT_NAME_PREFIX = 284,
+ PERCENT_NO_DEFAULT_PREC = 285,
+ PERCENT_NO_LINES = 286,
+ PERCENT_NONDETERMINISTIC_PARSER = 287,
+ PERCENT_OUTPUT = 288,
+ PERCENT_REQUIRE = 289,
+ PERCENT_SKELETON = 290,
+ PERCENT_START = 291,
+ PERCENT_TOKEN_TABLE = 292,
+ PERCENT_VERBOSE = 293,
+ PERCENT_YACC = 294,
+ BRACED_CODE = 295,
+ BRACED_PREDICATE = 296,
+ BRACKETED_ID = 297,
+ CHAR = 298,
+ EPILOGUE = 299,
+ EQUAL = 300,
+ ID = 301,
+ ID_COLON = 302,
+ PERCENT_PERCENT = 303,
+ PIPE = 304,
+ PROLOGUE = 305,
+ SEMICOLON = 306,
+ TAG = 307,
+ TAG_ANY = 308,
+ TAG_NONE = 309,
+ PERCENT_PARAM = 310,
+ PERCENT_UNION = 311
+ };
#endif
/* Tokens. */
#define GRAM_EOF 0
#define PERCENT_LEFT 265
#define PERCENT_RIGHT 266
#define PERCENT_NONASSOC 267
-#define PERCENT_PREC 268
-#define PERCENT_DPREC 269
-#define PERCENT_MERGE 270
-#define PERCENT_CODE 271
-#define PERCENT_DEBUG 272
+#define PERCENT_PRECEDENCE 268
+#define PERCENT_PREC 269
+#define PERCENT_DPREC 270
+#define PERCENT_MERGE 271
+#define PERCENT_CODE 272
#define PERCENT_DEFAULT_PREC 273
#define PERCENT_DEFINE 274
#define PERCENT_DEFINES 275
#define PERCENT_ERROR_VERBOSE 276
#define PERCENT_EXPECT 277
#define PERCENT_EXPECT_RR 278
-#define PERCENT_FILE_PREFIX 279
-#define PERCENT_GLR_PARSER 280
-#define PERCENT_INITIAL_ACTION 281
-#define PERCENT_LANGUAGE 282
-#define PERCENT_LEX_PARAM 283
-#define PERCENT_LOCATIONS 284
-#define PERCENT_NAME_PREFIX 285
-#define PERCENT_NO_DEFAULT_PREC 286
-#define PERCENT_NO_LINES 287
-#define PERCENT_NONDETERMINISTIC_PARSER 288
-#define PERCENT_OUTPUT 289
-#define PERCENT_PARSE_PARAM 290
-#define PERCENT_PURE_PARSER 291
-#define PERCENT_REQUIRE 292
-#define PERCENT_SKELETON 293
-#define PERCENT_START 294
-#define PERCENT_TOKEN_TABLE 295
-#define PERCENT_VERBOSE 296
-#define PERCENT_YACC 297
-#define BRACED_CODE 298
-#define BRACKETED_ID 299
-#define CHAR 300
-#define EPILOGUE 301
-#define EQUAL 302
-#define ID 303
-#define ID_COLON 304
-#define PERCENT_PERCENT 305
-#define PIPE 306
-#define PROLOGUE 307
-#define SEMICOLON 308
-#define TYPE 309
-#define TYPE_TAG_ANY 310
-#define TYPE_TAG_NONE 311
-#define PERCENT_UNION 312
-
-
+#define PERCENT_FLAG 279
+#define PERCENT_FILE_PREFIX 280
+#define PERCENT_GLR_PARSER 281
+#define PERCENT_INITIAL_ACTION 282
+#define PERCENT_LANGUAGE 283
+#define PERCENT_NAME_PREFIX 284
+#define PERCENT_NO_DEFAULT_PREC 285
+#define PERCENT_NO_LINES 286
+#define PERCENT_NONDETERMINISTIC_PARSER 287
+#define PERCENT_OUTPUT 288
+#define PERCENT_REQUIRE 289
+#define PERCENT_SKELETON 290
+#define PERCENT_START 291
+#define PERCENT_TOKEN_TABLE 292
+#define PERCENT_VERBOSE 293
+#define PERCENT_YACC 294
+#define BRACED_CODE 295
+#define BRACED_PREDICATE 296
+#define BRACKETED_ID 297
+#define CHAR 298
+#define EPILOGUE 299
+#define EQUAL 300
+#define ID 301
+#define ID_COLON 302
+#define PERCENT_PERCENT 303
+#define PIPE 304
+#define PROLOGUE 305
+#define SEMICOLON 306
+#define TAG 307
+#define TAG_ANY 308
+#define TAG_NONE 309
+#define PERCENT_PARAM 310
+#define PERCENT_UNION 311
#if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED
typedef union GRAM_STYPE
{
-/* Line 2042 of yacc.c */
-#line 115 "parse-gram.y"
+/* Line 1931 of yacc.c */
+#line 109 "src/parse-gram.y"
+ assoc assoc;
+ char *code;
+ char const *chars;
+ int integer;
+ named_ref *named_ref;
symbol *symbol;
symbol_list *list;
- int integer;
- char const *chars;
- char *code;
- assoc assoc;
uniqstr uniqstr;
unsigned char character;
- named_ref *named_ref;
+/* Line 1931 of yacc.c */
+#line 247 "src/parse-gram.y"
+
+ param_type param;
-/* Line 2042 of yacc.c */
-#line 194 "parse-gram.h"
+/* Line 1931 of yacc.c */
+#line 423 "src/parse-gram.y"
+code_props_type code_type;
+
+/* Line 1931 of yacc.c */
+#line 217 "src/parse-gram.h"
} GRAM_STYPE;
# define GRAM_STYPE_IS_TRIVIAL 1
-# define gram_stype GRAM_STYPE /* obsolescent; will be withdrawn */
# define GRAM_STYPE_IS_DECLARED 1
#endif
int last_line;
int last_column;
} GRAM_LTYPE;
-# define gram_ltype GRAM_LTYPE /* obsolescent; will be withdrawn */
# define GRAM_LTYPE_IS_DECLARED 1
# define GRAM_LTYPE_IS_TRIVIAL 1
#endif
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int gram_parse (void *YYPARSE_PARAM);
-#else
-int gram_parse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
int gram_parse (void);
-#else
-int gram_parse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-#endif /* !YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED */
+#endif /* !YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED */
#include "quotearg.h"
#include "reader.h"
#include "symlist.h"
+#include "symtab.h"
#include "scan-gram.h"
#include "scan-code.h"
#include "xmemdup0.h"
static YYLTYPE lloc_default (YYLTYPE const *, int);
#define YY_LOCATION_PRINT(File, Loc) \
- location_print (File, Loc)
+ location_print (File, Loc)
static void version_check (location const *loc, char const *version);
FIXME: depends on the undocumented availability of YYLLOC. */
#undef yyerror
#define yyerror(Msg) \
- gram_error (&yylloc, Msg)
+ gram_error (&yylloc, Msg)
static void gram_error (location const *, char const *);
static char const *char_name (char);
+%}
-/** Add a lex-param or a parse-param.
- *
- * \param type \a lex_param or \a parse_param
- * \param decl the formal argument
- * \param loc the location in the source.
- */
-static void add_param (char const *type, char *decl, location loc);
-
-
-static symbol_class current_class = unknown_sym;
-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
- * to several right-hand side parts of rule.
- */
-static
-void
-current_lhs(symbol *sym, location loc, named_ref *ref)
+%code
{
- current_lhs_symbol = sym;
- current_lhs_location = loc;
- /* In order to simplify memory management, named references for lhs
- are always assigned by deep copy into the current symbol_list
- node. This is because a single named-ref in the grammar may
- result in several uses when the user factors lhs between several
- rules using "|". Therefore free the parser's original copy. */
- free (current_lhs_named_ref);
- current_lhs_named_ref = ref;
-}
-
+ static int current_prec = 0;
+ static location current_lhs_location;
+ static named_ref *current_lhs_named_ref;
+ static symbol *current_lhs_symbol;
+ static symbol_class current_class = unknown_sym;
+ static uniqstr current_type = NULL;
+
+ /** Set the new current left-hand side symbol, possibly common
+ * to several right-hand side parts of rule.
+ */
+ static
+ void
+ current_lhs(symbol *sym, location loc, named_ref *ref)
+ {
+ current_lhs_symbol = sym;
+ current_lhs_location = loc;
+ /* In order to simplify memory management, named references for lhs
+ are always assigned by deep copy into the current symbol_list
+ node. This is because a single named-ref in the grammar may
+ result in several uses when the user factors lhs between several
+ rules using "|". Therefore free the parser's original copy. */
+ free (current_lhs_named_ref);
+ current_lhs_named_ref = ref;
+ }
-#define YYTYPE_INT16 int_fast16_t
-#define YYTYPE_INT8 int_fast8_t
-#define YYTYPE_UINT16 uint_fast16_t
-#define YYTYPE_UINT8 uint_fast8_t
-%}
+ #define YYTYPE_INT16 int_fast16_t
+ #define YYTYPE_INT8 int_fast8_t
+ #define YYTYPE_UINT16 uint_fast16_t
+ #define YYTYPE_UINT8 uint_fast8_t
+}
-%debug
%define api.prefix "gram_"
%define api.pure
+%define locations
+%define parse.error verbose
%define parse.lac full
+%define parse.trace
%defines
-%error-verbose
%expect 0
-%locations
%verbose
%initial-action
%union
{
+ assoc assoc;
+ char *code;
+ char const *chars;
+ int integer;
+ named_ref *named_ref;
symbol *symbol;
symbol_list *list;
- int integer;
- char const *chars;
- char *code;
- assoc assoc;
uniqstr uniqstr;
unsigned char character;
- named_ref *named_ref;
};
/* Define the tokens together with their human representation. */
%token PERCENT_LEFT "%left"
%token PERCENT_RIGHT "%right"
%token PERCENT_NONASSOC "%nonassoc"
+%token PERCENT_PRECEDENCE "%precedence"
%token PERCENT_PREC "%prec"
%token PERCENT_DPREC "%dprec"
%token PERCENT_MERGE "%merge"
-
/*----------------------.
| Global Declarations. |
`----------------------*/
%token
PERCENT_CODE "%code"
- PERCENT_DEBUG "%debug"
PERCENT_DEFAULT_PREC "%default-prec"
PERCENT_DEFINE "%define"
PERCENT_DEFINES "%defines"
PERCENT_ERROR_VERBOSE "%error-verbose"
PERCENT_EXPECT "%expect"
- PERCENT_EXPECT_RR "%expect-rr"
+ PERCENT_EXPECT_RR "%expect-rr"
+ PERCENT_FLAG "%<flag>"
PERCENT_FILE_PREFIX "%file-prefix"
PERCENT_GLR_PARSER "%glr-parser"
PERCENT_INITIAL_ACTION "%initial-action"
PERCENT_LANGUAGE "%language"
- PERCENT_LEX_PARAM "%lex-param"
- PERCENT_LOCATIONS "%locations"
PERCENT_NAME_PREFIX "%name-prefix"
PERCENT_NO_DEFAULT_PREC "%no-default-prec"
PERCENT_NO_LINES "%no-lines"
PERCENT_NONDETERMINISTIC_PARSER
- "%nondeterministic-parser"
+ "%nondeterministic-parser"
PERCENT_OUTPUT "%output"
- PERCENT_PARSE_PARAM "%parse-param"
- PERCENT_PURE_PARSER "%pure-parser"
- PERCENT_REQUIRE "%require"
+ PERCENT_REQUIRE "%require"
PERCENT_SKELETON "%skeleton"
PERCENT_START "%start"
PERCENT_TOKEN_TABLE "%token-table"
;
%token BRACED_CODE "{...}"
+%token BRACED_PREDICATE "%?{...}"
%token BRACKETED_ID "[identifier]"
%token CHAR "char"
%token EPILOGUE "epilogue"
%token PIPE "|"
%token PROLOGUE "%{...%}"
%token SEMICOLON ";"
-%token TYPE "type"
-%token TYPE_TAG_ANY "<*>"
-%token TYPE_TAG_NONE "<>"
+%token TAG "<tag>"
+%token TAG_ANY "<*>"
+%token TAG_NONE "<>"
%type <character> CHAR
-%printer { fputs (char_name ($$), stderr); } CHAR
+%printer { fputs (char_name ($$), yyo); } CHAR
/* braceless is not to be used for rule or symbol actions, as it
calls code_props_plain_init. */
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
-%type <code> "{...}"
-%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
- STRING
-%printer { fprintf (stderr, "{\n%s\n}", $$); }
- braceless content.opt "{...}" "%{...%}" EPILOGUE
-
-%type <uniqstr> BRACKETED_ID ID ID_COLON TYPE variable
-%printer { fputs ($$, stderr); } <uniqstr>
-%printer { fprintf (stderr, "[%s]", $$); } BRACKETED_ID
-%printer { fprintf (stderr, "%s:", $$); } ID_COLON
-%printer { fprintf (stderr, "<%s>", $$); } TYPE
+%type <code> "{...}" "%?{...}"
+%printer { fputs (quotearg_style (c_quoting_style, $$), yyo); }
+ STRING
+%printer { fprintf (yyo, "{\n%s\n}", $$); }
+ braceless content.opt "{...}" "%{...%}" EPILOGUE
+
+%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG tag variable
+%printer { fputs ($$, yyo); } <uniqstr>
+%printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
+%printer { fprintf (yyo, "%s:", $$); } ID_COLON
+%printer { fprintf (yyo, "%%%s", $$); } PERCENT_FLAG
+%printer { fprintf (yyo, "<%s>", $$); } TAG tag
%type <integer> INT
-%printer { fprintf (stderr, "%d", $$); } <integer>
+%printer { fprintf (yyo, "%d", $$); } <integer>
%type <symbol> id id_colon string_as_id symbol symbol.prec
-%printer { fprintf (stderr, "%s", $$->tag); } <symbol>
-%printer { fprintf (stderr, "%s:", $$->tag); } id_colon
+%printer { fprintf (yyo, "%s", $$->tag); } <symbol>
+%printer { fprintf (yyo, "%s:", $$->tag); } id_colon
%type <assoc> precedence_declarator
%type <list> symbols.1 symbols.prec generic_symlist generic_symlist_item
%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:
;
- /*------------------------------------.
- | Declarations: before the first %%. |
- `------------------------------------*/
+ /*------------------------------------.
+ | Declarations: before the first %%. |
+ `------------------------------------*/
prologue_declarations:
/* Nothing */
plain_code.code, @1);
code_scanner_last_string_free ();
}
-| "%debug" { debug = true; }
+| "%<flag>"
+ {
+ muscle_percent_define_ensure ($1, @1, true);
+ }
| "%define" variable content.opt
{
muscle_percent_define_insert ($2, @2, $3,
defines_flag = true;
spec_defines_file = xstrdup ($2);
}
-| "%error-verbose" { error_verbose = true; }
+| "%error-verbose"
+ {
+ muscle_percent_define_insert ("parse.error", @1, "verbose",
+ MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
+ }
| "%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 = $3; } /* deprecated */
| "%glr-parser"
{
nondeterministic_parser = true;
muscle_code_grow ("initial_action", action.code, @2);
code_scanner_last_string_free ();
}
-| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
-| "%lex-param" "{...}" { add_param ("lex_param", $2, @2); }
-| "%locations" { locations_flag = true; }
+| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
| "%name-prefix" STRING { spec_name_prefix = $2; }
-| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */
| "%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 = $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);
- }
+| "%param" { current_param = $1; } params { current_param = param_none; }
| "%require" STRING { version_check (&@2, $2); }
| "%skeleton" STRING
{
char const *skeleton_user = $2;
- if (mbschr (skeleton_user, '/'))
+ if (strchr (skeleton_user, '/'))
{
size_t dir_length = strlen (current_file);
char *skeleton_build;
| /*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:
precedence_declaration
| symbol_declaration
{
grammar_start_symbol_set ($2, @2);
}
-| "%destructor" "{...}" generic_symlist
+| code_props_type "{...}" generic_symlist
{
code_props code;
code_props_symbol_action_init (&code, $2, @2);
{
symbol_list *list;
for (list = $3; list; list = list->next)
- 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_code_props_set (list, $1, &code);
symbol_list_free ($3);
}
}
}
;
+%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";
current_class = unknown_sym;
current_type = NULL;
}
-| "%type" TYPE symbols.1
+| "%type" TAG symbols.1
{
symbol_list *list;
tag_seen = true;
for (list = $3; list; list = list->next)
- symbol_type_set (list->content.sym, $2, @2);
+ symbol_type_set (list->content.sym, $2, @2);
symbol_list_free ($3);
}
;
precedence_declaration:
- precedence_declarator type.opt symbols.prec
+ precedence_declarator tag.opt symbols.prec
{
symbol_list *list;
++current_prec;
for (list = $3; list; list = list->next)
- {
- symbol_type_set (list->content.sym, current_type, @2);
- symbol_precedence_set (list->content.sym, current_prec, $1, @1);
- }
+ {
+ symbol_type_set (list->content.sym, current_type, @2);
+ symbol_precedence_set (list->content.sym, current_prec, $1, @1);
+ }
symbol_list_free ($3);
current_type = NULL;
}
;
precedence_declarator:
- "%left" { $$ = left_assoc; }
-| "%right" { $$ = right_assoc; }
-| "%nonassoc" { $$ = non_assoc; }
+ "%left" { $$ = left_assoc; }
+| "%right" { $$ = right_assoc; }
+| "%nonassoc" { $$ = non_assoc; }
+| "%precedence" { $$ = precedence_assoc; }
;
-type.opt:
+tag.opt:
/* Nothing. */ { current_type = NULL; }
-| TYPE { current_type = $1; tag_seen = true; }
+| TAG { current_type = $1; tag_seen = true; }
;
/* Just like symbols.1 but accept INT for the sake of POSIX. */
;
symbol.prec:
- symbol { $$ = $1; }
- | symbol INT { $$ = $1; symbol_user_token_number_set ($1, $2, @2); }
- ;
+ symbol { $$ = $1; }
+| symbol INT { $$ = $1; symbol_user_token_number_set ($1, $2, @2); }
+;
/* One or more symbols to be %typed. */
symbols.1:
;
generic_symlist_item:
- symbol { $$ = symbol_list_sym_new ($1, @1); }
-| TYPE { $$ = symbol_list_type_new ($1, @1); }
-| "<*>" { $$ = symbol_list_default_tagged_new (@1); }
-| "<>" { $$ = symbol_list_default_tagless_new (@1); }
+ symbol { $$ = symbol_list_sym_new ($1, @1); }
+| tag { $$ = symbol_list_type_new ($1, @1); }
+;
+
+tag:
+ TAG
+| "<*>" { $$ = uniqstr_new ("*"); }
+| "<>" { $$ = uniqstr_new (""); }
;
/* One token definition. */
symbol_def:
- TYPE
+ TAG
{
current_type = $1;
tag_seen = true;
;
- /*------------------------------------------.
- | The grammar section: between the two %%. |
- `------------------------------------------*/
+ /*------------------------------------------.
+ | The grammar section: between the two %%. |
+ `------------------------------------------*/
grammar:
rules_or_grammar_declaration
rhs:
/* Nothing. */
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
- current_lhs_named_ref); }
+ current_lhs_named_ref); }
| rhs symbol named_ref.opt
{ grammar_current_rule_symbol_append ($2, @2, $3); }
| rhs "{...}" named_ref.opt
- { grammar_current_rule_action_append ($2, @2, $3); }
+ { grammar_current_rule_action_append ($2, @2, $3, false); }
+| rhs "%?{...}"
+ { grammar_current_rule_action_append ($2, @2, NULL, true); }
| rhs "%prec" symbol
{ grammar_current_rule_prec_set ($3, @3); }
| rhs "%dprec" INT
{ grammar_current_rule_dprec_set ($3, @3); }
-| rhs "%merge" TYPE
+| rhs "%merge" TAG
{ grammar_current_rule_merge_set ($3, @3); }
;
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.
For example, M4 fails for `%define "[" "value"'. */
;
-/*-------------*
- | braceless. |
- *-------------*/
+/*------------.
+| braceless. |
+`------------*/
braceless:
"{...}"
;
-/*---------------*
- | Identifiers. |
- *---------------*/
+/*--------------.
+| Identifiers. |
+`--------------*/
/* Identifiers are returned as uniqstr values by the scanner.
Depending on their use, we may need to make them genuine symbols. */
%%
-
/* Return the location of the left-hand side of a rule whose
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
for (i = 1; i <= n; i++)
if (! equal_boundaries (rhs[i].start, rhs[i].end))
{
- loc.start = rhs[i].start;
- break;
+ loc.start = rhs[i].start;
+ break;
}
return loc;
}
-/* Add a lex-param or a parse-param (depending on TYPE) with
- declaration DECL and location LOC. */
-
static void
-add_param (char const *type, char *decl, location loc)
+add_param (param_type type, char *decl, location loc)
{
static char const alphanum[26 + 26 + 1 + 10] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"_"
"0123456789";
+
char const *name_start = NULL;
- char *p;
-
- /* Stop on last actual character. */
- for (p = decl; p[1]; p++)
- if ((p == decl
- || ! memchr (alphanum, p[-1], sizeof alphanum))
- && memchr (alphanum, p[0], sizeof alphanum - 10))
- name_start = p;
-
- /* Strip the surrounding '{' and '}', and any blanks just inside
- the braces. */
- --p;
- while (c_isspace ((unsigned char) *p))
+ {
+ char *p;
+ /* Stop on last actual character. */
+ for (p = decl; p[1]; p++)
+ if ((p == decl
+ || ! memchr (alphanum, p[-1], sizeof alphanum))
+ && memchr (alphanum, p[0], sizeof alphanum - 10))
+ name_start = p;
+
+ /* Strip the surrounding '{' and '}', and any blanks just inside
+ the braces. */
--p;
- p[1] = '\0';
- ++decl;
- while (c_isspace ((unsigned char) *decl))
+ while (c_isspace ((unsigned char) *p))
+ --p;
+ p[1] = '\0';
++decl;
+ while (c_isspace ((unsigned char) *decl))
+ ++decl;
+ }
if (! name_start)
- complain_at (loc, _("missing identifier in parameter declaration"));
+ complain (&loc, complaint, _("missing identifier in parameter declaration"));
else
{
char *name = xmemdup0 (name_start, strspn (name_start, alphanum));
- muscle_pair_list_grow (type, decl, name);
+ if (type & param_lex)
+ muscle_pair_list_grow ("lex_param", decl, name);
+ if (type & param_parse)
+ muscle_pair_list_grow ("parse_param", decl, name);
free (name);
}
{
if (strverscmp (version, PACKAGE_VERSION) > 0)
{
- complain_at (*loc, "require bison %s, but have %s",
- version, PACKAGE_VERSION);
+ complain (loc, complaint, "require bison %s, but have %s",
+ version, PACKAGE_VERSION);
exit (EX_MISMATCH);
}
}
static void
gram_error (location const *loc, char const *msg)
{
- complain_at (*loc, "%s", msg);
+ complain (loc, complaint, "%s", msg);
}
char const *
sp1 = sp = ritem + sitems[i];
while (*sp >= 0)
- sp++;
+ sp++;
r = item_number_as_rule_number (*sp);
sp = rules[r].rhs;
/* Display the lookahead tokens? */
if (item_number_is_rule_number (*sp1))
- {
- reductions *reds = s->reductions;
- int red = state_reduction_find (s, &rules[r]);
- /* Print item with lookaheads if there are. */
- if (reds->lookahead_tokens && red != -1)
- {
- xml_printf (out, level + 1,
- "<item rule-number=\"%d\" point=\"%d\">",
- rules[r].number, sp1 - sp);
- state_rule_lookahead_tokens_print_xml (s, &rules[r],
- out, level + 2);
- xml_puts (out, level + 1, "</item>");
- printed = true;
- }
- }
+ {
+ reductions *reds = s->reductions;
+ int red = state_reduction_find (s, &rules[r]);
+ /* Print item with lookaheads if there are. */
+ if (reds->lookahead_tokens && red != -1)
+ {
+ xml_printf (out, level + 1,
+ "<item rule-number=\"%d\" point=\"%d\">",
+ rules[r].number, sp1 - sp);
+ state_rule_lookahead_tokens_print_xml (s, &rules[r],
+ out, level + 2);
+ xml_puts (out, level + 1, "</item>");
+ printed = true;
+ }
+ }
if (!printed)
- {
- xml_printf (out, level + 1,
- "<item rule-number=\"%d\" point=\"%d\"/>",
- rules[r].number,
- sp1 - sp);
- }
+ {
+ xml_printf (out, level + 1,
+ "<item rule-number=\"%d\" point=\"%d\"/>",
+ rules[r].number,
+ sp1 - sp);
+ }
}
xml_puts (out, level, "</itemset>");
}
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i))
{
- n++;
+ n++;
}
/* Nothing to report. */
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
- && TRANSITION_IS_SHIFT (trans, i))
+ && TRANSITION_IS_SHIFT (trans, i))
{
- symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
- char const *tag = sym->tag;
- state *s1 = trans->states[i];
+ symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
+ char const *tag = sym->tag;
+ state *s1 = trans->states[i];
- xml_printf (out, level + 1,
- "<transition type=\"shift\" symbol=\"%s\" state=\"%d\"/>",
- xml_escape (tag), s1->number);
+ xml_printf (out, level + 1,
+ "<transition type=\"shift\" symbol=\"%s\" state=\"%d\"/>",
+ xml_escape (tag), s1->number);
}
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
- && !TRANSITION_IS_SHIFT (trans, i))
+ && !TRANSITION_IS_SHIFT (trans, i))
{
- symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
- char const *tag = sym->tag;
- state *s1 = trans->states[i];
+ symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
+ char const *tag = sym->tag;
+ state *s1 = trans->states[i];
- xml_printf (out, level + 1,
- "<transition type=\"goto\" symbol=\"%s\" state=\"%d\"/>",
- xml_escape (tag), s1->number);
+ xml_printf (out, level + 1,
+ "<transition type=\"goto\" symbol=\"%s\" state=\"%d\"/>",
+ xml_escape (tag), s1->number);
}
xml_puts (out, level, "</transitions>");
for (i = 0; i < errp->num; ++i)
if (errp->symbols[i])
{
- char const *tag = errp->symbols[i]->tag;
- xml_printf (out, level + 1,
- "<error symbol=\"%s\">nonassociative</error>",
- xml_escape (tag));
+ char const *tag = errp->symbols[i]->tag;
+ xml_printf (out, level + 1,
+ "<error symbol=\"%s\">nonassociative</error>",
+ xml_escape (tag));
}
xml_puts (out, level, "</errors>");
}
static void
print_reduction (FILE *out, int level, char const *lookahead_token,
- rule *r, bool enabled)
+ rule *r, bool enabled)
{
if (r->number)
xml_printf (out, level,
- "<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
- xml_escape (lookahead_token),
- r->number,
- enabled ? "true" : "false");
+ "<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
+ xml_escape (lookahead_token),
+ r->number,
+ enabled ? "true" : "false");
else
xml_printf (out, level,
- "<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
- xml_escape (lookahead_token),
- enabled ? "true" : "false");
+ "<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
+ xml_escape (lookahead_token),
+ enabled ? "true" : "false");
}
if (reds->lookahead_tokens)
for (i = 0; i < ntokens; i++)
{
- bool count = bitset_test (no_reduce_set, i);
-
- for (j = 0; j < reds->num; ++j)
- if (bitset_test (reds->lookahead_tokens[j], i))
- {
- if (! count)
- {
- if (reds->rules[j] != default_reduction)
- report = true;
- count = true;
- }
- else
- {
- report = true;
- }
- }
+ bool count = bitset_test (no_reduce_set, i);
+
+ for (j = 0; j < reds->num; ++j)
+ if (bitset_test (reds->lookahead_tokens[j], i))
+ {
+ if (! count)
+ {
+ if (reds->rules[j] != default_reduction)
+ report = true;
+ count = true;
+ }
+ else
+ {
+ report = true;
+ }
+ }
}
/* Nothing to report. */
if (reds->lookahead_tokens)
for (i = 0; i < ntokens; i++)
{
- bool defaulted = false;
- bool count = bitset_test (no_reduce_set, i);
-
- for (j = 0; j < reds->num; ++j)
- if (bitset_test (reds->lookahead_tokens[j], i))
- {
- if (! count)
- {
- if (reds->rules[j] != default_reduction)
- print_reduction (out, level + 1, symbols[i]->tag,
- reds->rules[j], true);
- else
- defaulted = true;
- count = true;
- }
- else
- {
- if (defaulted)
- print_reduction (out, level + 1, symbols[i]->tag,
- default_reduction, true);
- defaulted = false;
- print_reduction (out, level + 1, symbols[i]->tag,
- reds->rules[j], false);
- }
- }
+ bool defaulted = false;
+ bool count = bitset_test (no_reduce_set, i);
+
+ for (j = 0; j < reds->num; ++j)
+ if (bitset_test (reds->lookahead_tokens[j], i))
+ {
+ if (! count)
+ {
+ if (reds->rules[j] != default_reduction)
+ print_reduction (out, level + 1, symbols[i]->tag,
+ reds->rules[j], true);
+ else
+ defaulted = true;
+ count = true;
+ }
+ else
+ {
+ if (defaulted)
+ print_reduction (out, level + 1, symbols[i]->tag,
+ default_reduction, true);
+ defaulted = false;
+ print_reduction (out, level + 1, symbols[i]->tag,
+ reds->rules[j], false);
+ }
+ }
}
if (default_reduction)
print_reduction (out, level + 1,
- "$default", default_reduction, true);
+ "$default", default_reduction, true);
xml_puts (out, level, "</reductions>");
}
for (i = 0; i < max_user_token_number + 1; i++)
if (token_translations[i] != undeftoken->number)
{
- char const *tag = symbols[token_translations[i]]->tag;
+ char const *tag = symbols[token_translations[i]]->tag;
int precedence = symbols[token_translations[i]]->prec;
assoc associativity = symbols[token_translations[i]]->assoc;
xml_indent (out, level + 2);
{
char const *tag = symbols[i]->tag;
xml_printf (out, level + 2,
- "<nonterminal symbol-number=\"%d\" name=\"%s\""
+ "<nonterminal symbol-number=\"%d\" name=\"%s\""
" usefulness=\"%s\"/>",
- i, xml_escape (tag),
+ i, xml_escape (tag),
reduce_nonterminal_useless_in_grammar (i)
? "useless-in-grammar" : "useful");
}
fputc ('\n', out);
xml_printf (out, level + 1, "<filename>%s</filename>",
- xml_escape (grammar_file));
+ xml_escape (grammar_file));
/* print grammar */
print_grammar (out, level + 1);
sp1 = sp = ritem + sitems[i];
while (*sp >= 0)
- sp++;
+ sp++;
r = item_number_as_rule_number (*sp);
previous_lhs = rules[r].lhs;
for (sp = rules[r].rhs; sp < sp1; sp++)
- fprintf (out, " %s", symbols[*sp]->tag);
+ fprintf (out, " %s", symbols[*sp]->tag);
fputs (" .", out);
for (/* Nothing */; *sp >= 0; ++sp)
- fprintf (out, " %s", symbols[*sp]->tag);
+ fprintf (out, " %s", symbols[*sp]->tag);
/* Display the lookahead tokens? */
if (report_flag & report_lookahead_tokens
&& item_number_is_rule_number (*sp1))
- state_rule_lookahead_tokens_print (s, &rules[r], out);
+ state_rule_lookahead_tokens_print (s, &rules[r], out);
fputc ('\n', out);
}
/* Compute the width of the lookahead token column. */
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
- && TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
+ && TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
{
- symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
- max_length (&width, sym->tag);
+ symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
+ max_length (&width, sym->tag);
}
/* Nothing to report. */
/* Report lookahead tokens and shifts. */
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
- && TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
+ && TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
{
- symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
- const char *tag = sym->tag;
- state *s1 = trans->states[i];
- int j;
-
- fprintf (out, " %s", tag);
- for (j = width - strlen (tag); j > 0; --j)
- fputc (' ', out);
- if (display_transitions_p)
- fprintf (out, _("shift, and go to state %d\n"), s1->number);
- else
- fprintf (out, _("go to state %d\n"), s1->number);
+ symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
+ const char *tag = sym->tag;
+ state *s1 = trans->states[i];
+ int j;
+
+ fprintf (out, " %s", tag);
+ for (j = width - strlen (tag); j > 0; --j)
+ fputc (' ', out);
+ if (display_transitions_p)
+ fprintf (out, _("shift, and go to state %d\n"), s1->number);
+ else
+ fprintf (out, _("go to state %d\n"), s1->number);
}
}
for (i = 0; i < errp->num; ++i)
if (errp->symbols[i])
{
- const char *tag = errp->symbols[i]->tag;
- int j;
- fprintf (out, " %s", tag);
- for (j = width - strlen (tag); j > 0; --j)
- fputc (' ', out);
- fputs (_("error (nonassociative)\n"), out);
+ const char *tag = errp->symbols[i]->tag;
+ int j;
+ fprintf (out, " %s", tag);
+ for (j = width - strlen (tag); j > 0; --j)
+ fputc (' ', out);
+ fputs (_("error (nonassociative)\n"), out);
}
}
static void
print_reduction (FILE *out, size_t width,
- const char *lookahead_token,
- rule *r, bool enabled)
+ const char *lookahead_token,
+ rule *r, bool enabled)
{
int j;
fprintf (out, " %s", lookahead_token);
if (reds->lookahead_tokens)
for (i = 0; i < ntokens; i++)
{
- bool count = bitset_test (no_reduce_set, i);
-
- for (j = 0; j < reds->num; ++j)
- if (bitset_test (reds->lookahead_tokens[j], i))
- {
- if (! count)
- {
- if (reds->rules[j] != default_reduction)
- max_length (&width, symbols[i]->tag);
- count = true;
- }
- else
- {
- max_length (&width, symbols[i]->tag);
- }
- }
+ bool count = bitset_test (no_reduce_set, i);
+
+ for (j = 0; j < reds->num; ++j)
+ if (bitset_test (reds->lookahead_tokens[j], i))
+ {
+ if (! count)
+ {
+ if (reds->rules[j] != default_reduction)
+ max_length (&width, symbols[i]->tag);
+ count = true;
+ }
+ else
+ {
+ max_length (&width, symbols[i]->tag);
+ }
+ }
}
/* Nothing to report. */
if (reds->lookahead_tokens)
for (i = 0; i < ntokens; i++)
{
- bool defaulted = false;
- bool count = bitset_test (no_reduce_set, i);
+ bool defaulted = false;
+ bool count = bitset_test (no_reduce_set, i);
if (count)
default_reduction_only = false;
- for (j = 0; j < reds->num; ++j)
- if (bitset_test (reds->lookahead_tokens[j], i))
- {
- if (! count)
- {
- if (reds->rules[j] != default_reduction)
+ for (j = 0; j < reds->num; ++j)
+ if (bitset_test (reds->lookahead_tokens[j], i))
+ {
+ if (! count)
+ {
+ if (reds->rules[j] != default_reduction)
{
default_reduction_only = false;
print_reduction (out, width,
symbols[i]->tag,
reds->rules[j], true);
}
- else
- defaulted = true;
- count = true;
- }
- else
- {
+ else
+ defaulted = true;
+ count = true;
+ }
+ else
+ {
default_reduction_only = false;
- if (defaulted)
- print_reduction (out, width,
- symbols[i]->tag,
- default_reduction, true);
- defaulted = false;
- print_reduction (out, width,
- symbols[i]->tag,
- reds->rules[j], false);
- }
- }
+ if (defaulted)
+ print_reduction (out, width,
+ symbols[i]->tag,
+ default_reduction, true);
+ defaulted = false;
+ print_reduction (out, width,
+ symbols[i]->tag,
+ reds->rules[j], false);
+ }
+ }
}
if (default_reduction)
{
char *default_reductions =
- muscle_percent_define_get ("lr.default-reductions");
+ muscle_percent_define_get ("lr.default-reduction");
print_reduction (out, width, _("$default"), default_reduction, true);
- aver (0 == strcmp (default_reductions, "most")
- || (0 == strcmp (default_reductions, "consistent")
+ aver (STREQ (default_reductions, "most")
+ || (STREQ (default_reductions, "consistent")
&& default_reduction_only)
|| (reds->num == 1 && reds->rules[0]->number == 0));
free (default_reductions);
| Print information on the whole grammar. |
`-----------------------------------------*/
-#define END_TEST(End) \
-do { \
- if (column + strlen(buffer) > (End)) \
- { \
- fprintf (out, "%s\n ", buffer); \
- column = 3; \
- buffer[0] = 0; \
- } \
-} while (0)
+#define END_TEST(End) \
+ do { \
+ if (column + strlen (buffer) > (End)) \
+ { \
+ fprintf (out, "%s\n ", buffer); \
+ column = 3; \
+ buffer[0] = 0; \
+ } \
+ } while (0)
static void
for (i = 0; i < max_user_token_number + 1; i++)
if (token_translations[i] != undeftoken->number)
{
- const char *tag = symbols[token_translations[i]]->tag;
- rule_number r;
- item_number *rhsp;
-
- buffer[0] = 0;
- column = strlen (tag);
- fputs (tag, out);
- END_TEST (65);
- sprintf (buffer, " (%d)", i);
-
- for (r = 0; r < nrules; r++)
- for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
- if (item_number_as_symbol_number (*rhsp) == token_translations[i])
- {
- END_TEST (65);
- sprintf (buffer + strlen (buffer), " %d", r);
- break;
- }
- fprintf (out, "%s\n", buffer);
+ const char *tag = symbols[token_translations[i]]->tag;
+ rule_number r;
+ item_number *rhsp;
+
+ buffer[0] = 0;
+ column = strlen (tag);
+ fputs (tag, out);
+ END_TEST (65);
+ sprintf (buffer, " (%d)", i);
+
+ for (r = 0; r < nrules; r++)
+ for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+ if (item_number_as_symbol_number (*rhsp) == token_translations[i])
+ {
+ END_TEST (65);
+ sprintf (buffer + strlen (buffer), " %d", r);
+ break;
+ }
+ fprintf (out, "%s\n", buffer);
}
fputs ("\n\n", out);
const char *tag = symbols[i]->tag;
for (r = 0; r < nrules; r++)
- {
- item_number *rhsp;
- if (rules[r].lhs->number == i)
- left_count++;
- for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
- if (item_number_as_symbol_number (*rhsp) == i)
- {
- right_count++;
- break;
- }
- }
+ {
+ item_number *rhsp;
+ if (rules[r].lhs->number == i)
+ left_count++;
+ for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+ if (item_number_as_symbol_number (*rhsp) == i)
+ {
+ right_count++;
+ break;
+ }
+ }
buffer[0] = 0;
fputs (tag, out);
END_TEST (0);
if (left_count > 0)
- {
- END_TEST (65);
- sprintf (buffer + strlen (buffer), _(" on left:"));
-
- for (r = 0; r < nrules; r++)
- {
- if (rules[r].lhs->number == i)
- {
- END_TEST (65);
- sprintf (buffer + strlen (buffer), " %d", r);
- }
- }
- }
+ {
+ END_TEST (65);
+ sprintf (buffer + strlen (buffer), _(" on left:"));
+
+ for (r = 0; r < nrules; r++)
+ {
+ if (rules[r].lhs->number == i)
+ {
+ END_TEST (65);
+ sprintf (buffer + strlen (buffer), " %d", r);
+ }
+ }
+ }
if (right_count > 0)
- {
- if (left_count > 0)
- sprintf (buffer + strlen (buffer), ",");
- END_TEST (65);
- sprintf (buffer + strlen (buffer), _(" on right:"));
- for (r = 0; r < nrules; r++)
- {
- item_number *rhsp;
- for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
- if (item_number_as_symbol_number (*rhsp) == i)
- {
- END_TEST (65);
- sprintf (buffer + strlen (buffer), " %d", r);
- break;
- }
- }
- }
+ {
+ if (left_count > 0)
+ sprintf (buffer + strlen (buffer), ",");
+ END_TEST (65);
+ sprintf (buffer + strlen (buffer), _(" on right:"));
+ for (r = 0; r < nrules; r++)
+ {
+ item_number *rhsp;
+ for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+ if (item_number_as_symbol_number (*rhsp) == i)
+ {
+ END_TEST (65);
+ sprintf (buffer + strlen (buffer), " %d", r);
+ break;
+ }
+ }
+ }
fprintf (out, "%s\n", buffer);
}
}
reduce_output (out);
grammar_rules_partial_print (out,
- _("Rules useless in parser due to conflicts"),
+ _("Rules useless in parser due to conflicts"),
rule_useless_in_parser_p);
conflicts_output (out);
obstack_sgrow (oout, escape (r->lhs->tag));
obstack_1grow (oout, ':');
}
+ obstack_1grow (oout, ' ');
}
static void
previous_rule = &rules[r];
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_sgrow (oout, " .");
+ obstack_1grow (oout, '.');
for (/* Nothing */; *sp >= 0; ++sp)
obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i))
{
- state *s1 = trans->states[i];
- symbol_number sym = s1->accessing_symbol;
-
- /* Shifts are solid, gotos are dashed, and error is dotted. */
- char const *style =
- (TRANSITION_IS_ERROR (trans, i) ? "dotted"
- : TRANSITION_IS_SHIFT (trans, i) ? "solid"
- : "dashed");
-
- if (TRANSITION_IS_ERROR (trans, i)
- && strcmp (symbols[sym]->tag, "error") != 0)
- abort ();
- output_edge (s->number, s1->number,
- TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
- style, fgraph);
+ state *s1 = trans->states[i];
+ symbol_number sym = s1->accessing_symbol;
+
+ /* Shifts are solid, gotos are dashed, and error is dotted. */
+ char const *style =
+ (TRANSITION_IS_ERROR (trans, i) ? "dotted"
+ : TRANSITION_IS_SHIFT (trans, i) ? "solid"
+ : "dashed");
+
+ if (TRANSITION_IS_ERROR (trans, i)
+ && STRNEQ (symbols[sym]->tag, "error"))
+ abort ();
+ output_edge (s->number, s1->number,
+ TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
+ style, fgraph);
}
/* Display reductions. */
output_red (s, s->reductions, fgraph);
/* A node's label contains its items. */
obstack_init (&node_obstack);
print_core (&node_obstack, s);
- obstack_1grow (&node_obstack, '\0');
- output_node (s->number, obstack_finish (&node_obstack), fgraph);
+ output_node (s->number, obstack_finish0 (&node_obstack), fgraph);
obstack_free (&node_obstack, 0);
/* Output the edges. */
grammar_start_symbol_set (symbol *sym, location loc)
{
if (start_flag)
- complain_at (loc, _("multiple %s declarations"), "%start");
+ complain (&loc, complaint, _("multiple %s declarations"), "%start");
else
{
start_flag = true;
syms->next = xmalloc (sizeof syms->next[0]);
syms->next->name = uniqstr_new (name);
/* After all symbol type declarations have been parsed, packgram invokes
- record_merge_function_type to set the type. */
+ record_merge_function_type to set the type. */
syms->next->type = NULL;
syms->next->next = NULL;
merge_functions = head.next;
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
{
unsigned indent = 0;
- complain_at_indent (declaration_loc, &indent,
- _("result type clash on merge function %s: "
- "<%s> != <%s>"),
- quote (merge_function->name), type,
- merge_function->type);
+ complain_indent (&declaration_loc, complaint, &indent,
+ _("result type clash on merge function %s: "
+ "<%s> != <%s>"),
+ quote (merge_function->name), type,
+ merge_function->type);
indent += SUB_INDENT;
- complain_at_indent (merge_function->type_declaration_location, &indent,
- _("previous declaration"));
- }
+ complain_indent (&merge_function->type_declaration_location, complaint,
+ &indent,
+ _("previous declaration"));
+ }
merge_function->type = uniqstr_new (type);
merge_function->type_declaration_location = declaration_loc;
}
/*--------------------------------------.
-| Free all merge-function definitions. |
+| Free all merge-function definitions. |
`--------------------------------------*/
void
if (name->id == sym->tag)
{
- warn_at (name->loc,
- _("duplicated symbol name for %s ignored"),
- quote (sym->tag));
+ complain (&name->loc, Wother,
+ _("duplicated symbol name for %s ignored"),
+ quote (sym->tag));
named_ref_free (name);
}
else
void
grammar_current_rule_begin (symbol *lhs, location loc,
- named_ref *lhs_name)
+ named_ref *lhs_name)
{
symbol_list* p;
++nvars;
}
else if (lhs->class == token_sym)
- complain_at (loc, _("rule given for %s, which is a token"), lhs->tag);
+ complain (&loc, complaint, _("rule given for %s, which is a token"),
+ lhs->tag);
}
static bool
symbol_should_be_used (symbol_list const *s, bool *midrule_warning)
{
- if (symbol_destructor_get (s->content.sym)->code)
+ if (symbol_code_props_get (s->content.sym, destructor)->code)
return true;
if ((s->midrule && s->midrule->action_props.is_value_used)
|| (s->midrule_parent_rule
symbol *first_rhs = r->next->content.sym;
/* If $$ is being set in default way, report if any type mismatch. */
if (first_rhs)
- {
- char const *lhs_type = r->content.sym->type_name;
- const char *rhs_type =
- first_rhs->type_name ? first_rhs->type_name : "";
- if (!UNIQSTR_EQ (lhs_type, rhs_type))
- warn_at (r->location,
- _("type clash on default action: <%s> != <%s>"),
- lhs_type, rhs_type);
- }
+ {
+ char const *lhs_type = r->content.sym->type_name;
+ const char *rhs_type =
+ first_rhs->type_name ? first_rhs->type_name : "";
+ if (!UNIQSTR_EQ (lhs_type, rhs_type))
+ complain (&r->location, Wother,
+ _("type clash on default action: <%s> != <%s>"),
+ lhs_type, rhs_type);
+ }
/* Warn if there is no default for $$ but we need one. */
else
- warn_at (r->location,
- _("empty rule for typed nonterminal, and no action"));
+ complain (&r->location, Wother,
+ _("empty rule for typed nonterminal, and no action"));
}
/* Check that symbol values that should be used are in fact used. */
/* The default action, $$ = $1, `uses' both. */
&& (r->action_props.code || (n != 0 && n != 1)))
{
- void (*warn_at_ptr)(location, char const*, ...) =
- midrule_warning ? midrule_value_at : warn_at;
+ warnings warn_flag = midrule_warning ? Wmidrule_values : Wother;
if (n)
- warn_at_ptr (l->location, _("unused value: $%d"), n);
+ complain (&l->location, warn_flag, _("unused value: $%d"), n);
else
- warn_at_ptr (l->location, _("unset value: $$"));
+ complain (&l->location, warn_flag, _("unset value: $$"));
}
}
}
it for char literals and strings, which are always tokens. */
if (r->ruleprec
&& r->ruleprec->tag[0] != '\'' && r->ruleprec->tag[0] != '"'
- && !r->ruleprec->declared && !r->ruleprec->prec)
- warn_at (r->location, _("token for %%prec is not defined: %s"),
- r->ruleprec->tag);
+ && r->ruleprec->status != declared && !r->ruleprec->prec)
+ complain (&r->location, Wother,
+ _("token for %%prec is not defined: %s"), r->ruleprec->tag);
}
code_props_rule_action_init (&midrule->action_props,
current_rule->action_props.code,
current_rule->action_props.location,
- midrule, 0);
+ midrule, 0,
+ current_rule->action_props.is_predicate);
code_props_none_init (¤t_rule->action_props);
if (previous_rule_end)
token. */
symbol_class_set (precsym, token_sym, loc, false);
if (current_rule->ruleprec)
- complain_at (loc, _("only one %s allowed per rule"), "%prec");
+ complain (&loc, complaint, _("only one %s allowed per rule"), "%prec");
current_rule->ruleprec = precsym;
}
grammar_current_rule_dprec_set (int dprec, location loc)
{
if (! glr_parser)
- warn_at (loc, _("%s affects only GLR parsers"), "%dprec");
+ complain (&loc, Wother, _("%s affects only GLR parsers"),
+ "%dprec");
if (dprec <= 0)
- complain_at (loc, _("%s must be followed by positive number"), "%dprec");
+ complain (&loc, complaint, _("%s must be followed by positive number"),
+ "%dprec");
else if (current_rule->dprec != 0)
- complain_at (loc, _("only one %s allowed per rule"), "%dprec");
+ complain (&loc, complaint, _("only one %s allowed per rule"), "%dprec");
current_rule->dprec = dprec;
}
grammar_current_rule_merge_set (uniqstr name, location loc)
{
if (! glr_parser)
- warn_at (loc, _("%s affects only GLR parsers"), "%merge");
+ complain (&loc, Wother, _("%s affects only GLR parsers"),
+ "%merge");
if (current_rule->merger != 0)
- complain_at (loc, _("only one %s allowed per rule"), "%merge");
+ complain (&loc, complaint, _("only one %s allowed per rule"), "%merge");
current_rule->merger = get_merge_function (name);
current_rule->merger_declaration_location = loc;
}
void
grammar_current_rule_symbol_append (symbol *sym, location loc,
- named_ref *name)
+ named_ref *name)
{
symbol_list *p;
if (current_rule->action_props.code)
p = grammar_symbol_append (sym, loc);
if (name)
assign_named_ref(p, name);
+ if (sym->status == undeclared || sym->status == used)
+ sym->status = needed;
}
/* Attach an ACTION to the current rule. */
void
grammar_current_rule_action_append (const char *action, location loc,
- named_ref *name)
+ named_ref *name, bool is_predicate)
{
if (current_rule->action_props.code)
grammar_midrule_action ();
/* After all symbol declarations have been parsed, packgram invokes
code_props_translate_code. */
code_props_rule_action_init (¤t_rule->action_props, action, loc,
- current_rule, name);
+ current_rule, name, is_predicate);
}
\f
int rule_length = 0;
symbol *ruleprec = p->ruleprec;
record_merge_function_type (p->merger, p->content.sym->type_name,
- p->merger_declaration_location);
+ p->merger_declaration_location);
rules[ruleno].user_number = ruleno;
rules[ruleno].number = ruleno;
rules[ruleno].lhs = p->content.sym;
rules[ruleno].useful = true;
rules[ruleno].action = p->action_props.code;
rules[ruleno].action_location = p->action_props.location;
+ rules[ruleno].is_predicate = p->action_props.is_predicate;
/* If the midrule's $$ is set or its $n is used, remove the `$' from the
- symbol name so that it's a user-defined symbol so that the default
- %destructor and %printer apply. */
+ symbol name so that it's a user-defined symbol so that the default
+ %destructor and %printer apply. */
if (p->midrule_parent_rule
&& (p->action_props.is_value_used
- || symbol_list_n_get (p->midrule_parent_rule,
- p->midrule_parent_rhs_index)
+ || symbol_list_n_get (p->midrule_parent_rule,
+ p->midrule_parent_rhs_index)
->action_props.is_value_used))
- p->content.sym->tag += 1;
+ p->content.sym->tag += 1;
/* Don't check the generated rule 0. It has no action, so some rhs
- symbols may appear unused, but the parsing algorithm ensures that
- %destructor's are invoked appropriately. */
+ symbols may appear unused, but the parsing algorithm ensures that
+ %destructor's are invoked appropriately. */
if (p != grammar)
- grammar_rule_check (p);
+ grammar_rule_check (p);
for (p = p->next; p && p->content.sym; p = p->next)
- {
- ++rule_length;
+ {
+ ++rule_length;
- /* Don't allow rule_length == INT_MAX, since that might
- cause confusion with strtol if INT_MAX == LONG_MAX. */
- if (rule_length == INT_MAX)
- fatal_at (rules[ruleno].location, _("rule is too long"));
+ /* Don't allow rule_length == INT_MAX, since that might
+ cause confusion with strtol if INT_MAX == LONG_MAX. */
+ if (rule_length == INT_MAX)
+ complain (&rules[ruleno].location, fatal, _("rule is too long"));
- /* item_number = symbol_number.
- But the former needs to contain more: negative rule numbers. */
- ritem[itemno++] =
+ /* item_number = symbol_number.
+ But the former needs to contain more: negative rule numbers. */
+ ritem[itemno++] =
symbol_number_as_item_number (p->content.sym->number);
- /* A rule gets by default the precedence and associativity
- of its last token. */
- if (p->content.sym->class == token_sym && default_prec)
- rules[ruleno].prec = p->content.sym;
- }
+ /* A rule gets by default the precedence and associativity
+ of its last token. */
+ if (p->content.sym->class == token_sym && default_prec)
+ rules[ruleno].prec = p->content.sym;
+ }
/* If this rule has a %prec,
the specified symbol's precedence replaces the default. */
if (ruleprec)
- {
- rules[ruleno].precsym = ruleprec;
- rules[ruleno].prec = ruleprec;
- }
+ {
+ rules[ruleno].precsym = ruleprec;
+ rules[ruleno].prec = ruleprec;
+ }
/* An item ends by the rule number (negated). */
ritem[itemno++] = rule_number_as_item_number (ruleno);
aver (itemno < ITEM_NUMBER_MAX);
aver (ruleno < RULE_NUMBER_MAX);
if (p)
- p = p->next;
+ p = p->next;
}
aver (itemno == nritems);
gram_parse ();
prepare_percent_define_front_end_variables ();
- if (! complaint_issued)
+ if (complaint_status < status_complaint)
check_and_convert_grammar ();
xfclose (gram_in);
prepare_percent_define_front_end_variables (void)
{
/* Set %define front-end variable defaults. */
- muscle_percent_define_default ("lr.keep-unreachable-states", "false");
+ muscle_percent_define_default ("lr.keep-unreachable-state", "false");
{
char *lr_type;
/* IELR would be a better default, but LALR is historically the
default. */
muscle_percent_define_default ("lr.type", "lalr");
lr_type = muscle_percent_define_get ("lr.type");
- if (0 != strcmp (lr_type, "canonical-lr"))
- muscle_percent_define_default ("lr.default-reductions", "most");
+ if (STRNEQ (lr_type, "canonical-lr"))
+ muscle_percent_define_default ("lr.default-reduction", "most");
else
- muscle_percent_define_default ("lr.default-reductions", "accepting");
+ muscle_percent_define_default ("lr.default-reduction", "accepting");
free (lr_type);
}
{
static char const * const values[] = {
"lr.type", "lalr", "ielr", "canonical-lr", NULL,
- "lr.default-reductions", "most", "consistent", "accepting", NULL,
+ "lr.default-reduction", "most", "consistent", "accepting", NULL,
NULL
};
muscle_percent_define_check_values (values);
/*-------------------------------------------------------------.
| Check the grammar that has just been read, and convert it to |
-| internal form. |
+| internal form. |
`-------------------------------------------------------------*/
static void
{
/* Grammar has been read. Do some checking. */
if (nrules == 0)
- fatal (_("no rules in the input grammar"));
+ complain (NULL, fatal, _("no rules in the input grammar"));
/* If the user did not define her ENDTOKEN, do it now. */
if (!endtoken)
/* From reader.c. */
void grammar_start_symbol_set (symbol *sym, location loc);
void grammar_current_rule_begin (symbol *lhs, location loc,
- named_ref *lhs_named_ref);
+ named_ref *lhs_named_ref);
void grammar_current_rule_end (location loc);
void grammar_midrule_action (void);
void grammar_current_rule_prec_set (symbol *precsym, location loc);
void grammar_current_rule_dprec_set (int dprec, location loc);
void grammar_current_rule_merge_set (uniqstr name, location loc);
void grammar_current_rule_symbol_append (symbol *sym, location loc,
- named_ref *nref);
+ named_ref *nref);
void grammar_current_rule_action_append (const char *action, location loc,
- named_ref *nref);
+ named_ref *nref, bool);
void reader (void);
void free_merger_functions (void);
{
bitset_copy (Np, N);
for (r = 0; r < nrules; r++)
- if (!bitset_test (P, r)
- && useful_production (r, N))
- {
- bitset_set (Np, rules[r].lhs->number - ntokens);
- bitset_set (P, r);
- }
+ if (!bitset_test (P, r)
+ && useful_production (r, N))
+ {
+ bitset_set (Np, rules[r].lhs->number - ntokens);
+ bitset_set (P, r);
+ }
if (bitset_equal_p (N, Np))
- break;
+ break;
Ns = Np;
Np = N;
N = Ns;
bitset_set (V, accept->number);
while (1)
- {
- rule_number r;
- bitset_copy (Vp, V);
- for (r = 0; r < nrules; r++)
- {
- if (!bitset_test (Pp, r)
- && bitset_test (P, r)
- && bitset_test (V, rules[r].lhs->number))
- {
- item_number *rhsp;
- for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
- if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
- bitset_set (Vp, *rhsp);
- bitset_set (Pp, r);
- }
- }
- if (bitset_equal_p (V, Vp))
- break;
- Vs = Vp;
- Vp = V;
- V = Vs;
- }
+ {
+ rule_number r;
+ bitset_copy (Vp, V);
+ for (r = 0; r < nrules; r++)
+ {
+ if (!bitset_test (Pp, r)
+ && bitset_test (P, r)
+ && bitset_test (V, rules[r].lhs->number))
+ {
+ item_number *rhsp;
+ for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+ if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
+ bitset_set (Vp, *rhsp);
+ bitset_set (Pp, r);
+ }
+ }
+ if (bitset_equal_p (V, Vp))
+ break;
+ Vs = Vp;
+ Vp = V;
+ V = Vs;
+ }
}
bitset_free (V);
V = Vp;
/* Tokens 0, 1, and 2 are internal to Bison. Consider them useful. */
- bitset_set (V, endtoken->number); /* end-of-input token */
- bitset_set (V, errtoken->number); /* error token */
- bitset_set (V, undeftoken->number); /* some undefined token */
+ bitset_set (V, endtoken->number); /* end-of-input token */
+ bitset_set (V, errtoken->number); /* error token */
+ bitset_set (V, undeftoken->number); /* some undefined token */
bitset_free (P);
P = Pp;
symbol_number i;
for (i = ntokens; i < nsyms; i++)
if (bitset_test (V, i))
- nuseful_nonterminals++;
+ nuseful_nonterminals++;
}
nuseless_nonterminals = nvars - nuseful_nonterminals;
rule_number r;
for (r = 0; r < nrules; ++r)
if (rules[r].precsym != 0)
- bitset_set (V1, rules[r].precsym->number);
+ bitset_set (V1, rules[r].precsym->number);
}
}
/* Renumber the rules markers in RITEMS. */
for (r = 0; r < nrules; ++r)
{
- item_number *rhsp = rules[r].rhs;
- for (/* Nothing. */; *rhsp >= 0; ++rhsp)
- /* Nothing. */;
- *rhsp = rule_number_as_item_number (r);
- rules[r].number = r;
+ item_number *rhsp = rules[r].rhs;
+ for (/* Nothing. */; *rhsp >= 0; ++rhsp)
+ /* Nothing. */;
+ *rhsp = rule_number_as_item_number (r);
+ rules[r].number = r;
}
nrules -= nuseless_productions;
}
int length;
for (r = nrules; r < nrules + nuseless_productions; ++r)
{
- length = rule_rhs_length (&rules[r]);
- nritems -= length + 1;
+ length = rule_rhs_length (&rules[r]);
+ nritems -= length + 1;
}
}
}
static void
nonterminals_reduce (void)
{
- symbol_number i, n;
-
/* Map the nonterminals to their new index: useful first, useless
afterwards. Kept for later report. */
symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap);
- n = ntokens;
+ symbol_number n = ntokens;
+ symbol_number i;
for (i = ntokens; i < nsyms; i++)
if (bitset_test (V, i))
nontermmap[i - ntokens] = n++;
for (i = ntokens; i < nsyms; i++)
if (!bitset_test (V, i))
{
- nontermmap[i - ntokens] = n++;
- warn_at (symbols[i]->location, _("nonterminal useless in grammar: %s"),
- symbols[i]->tag);
+ nontermmap[i - ntokens] = n++;
+ if (symbols[i]->status != used)
+ complain (&symbols[i]->location, Wother,
+ _("nonterminal useless in grammar: %s"),
+ symbols[i]->tag);
}
rule_number r;
for (r = 0; r < nrules; ++r)
{
- item_number *rhsp;
- for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
- if (ISVAR (*rhsp))
- *rhsp = symbol_number_as_item_number (nontermmap[*rhsp
- - ntokens]);
+ item_number *rhsp;
+ for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
+ if (ISVAR (*rhsp))
+ *rhsp = symbol_number_as_item_number (nontermmap[*rhsp
+ - ntokens]);
}
accept->number = nontermmap[accept->number - ntokens];
}
int i;
fprintf (out, "%s\n\n", _("Nonterminals useless in grammar"));
for (i = 0; i < nuseless_nonterminals; ++i)
- fprintf (out, " %s\n", symbols[nsyms + i]->tag);
+ fprintf (out, " %s\n", symbols[nsyms + i]->tag);
fputs ("\n\n", out);
}
int i;
for (i = 0; i < ntokens; i++)
if (reduce_token_unused_in_grammar (i))
- {
- if (!b)
- fprintf (out, "%s\n\n", _("Terminals unused in grammar"));
- b = true;
- fprintf (out, " %s\n", symbols[i]->tag);
- }
+ {
+ if (!b)
+ fprintf (out, "%s\n\n", _("Terminals unused in grammar"));
+ b = true;
+ fprintf (out, " %s\n", symbols[i]->tag);
+ }
if (b)
fputs ("\n\n", out);
}
if (nuseless_productions > 0)
grammar_rules_partial_print (out, _("Rules useless in grammar"),
- rule_useless_in_grammar_p);
+ rule_useless_in_grammar_p);
}
\f
reduce_print (void)
{
if (nuseless_nonterminals > 0)
- warn (ngettext ("%d nonterminal useless in grammar",
- "%d nonterminals useless in grammar",
- nuseless_nonterminals),
- nuseless_nonterminals);
+ complain (NULL, Wother, ngettext ("%d nonterminal useless in grammar",
+ "%d nonterminals useless in grammar",
+ nuseless_nonterminals),
+ nuseless_nonterminals);
if (nuseless_productions > 0)
- warn (ngettext ("%d rule useless in grammar",
- "%d rules useless in grammar",
- nuseless_productions),
- nuseless_productions);
+ complain (NULL, Wother, ngettext ("%d rule useless in grammar",
+ "%d rules useless in grammar",
+ nuseless_productions),
+ nuseless_productions);
}
\f
void
reduce_print ();
if (!bitset_test (N, accept->number - ntokens))
- fatal_at (startsymbol_location,
- _("start symbol %s does not derive any sentence"),
- startsymbol->tag);
+ complain (&startsymbol_location, fatal,
+ _("start symbol %s does not derive any sentence"),
+ startsymbol->tag);
/* First reduce the nonterminals, as they renumber themselves in the
whole grammar. If you change the order, nonterms would be
{
grammar_dump (stderr, "Reduced Grammar");
- fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals\
-, and %d productions.\n",
- grammar_file, ntokens, nvars, nrules);
+ fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals"
+ ", and %d productions.\n",
+ grammar_file, ntokens, nvars, nrules);
}
}
{
fprintf (out, "%3lu: ", (unsigned long int) i);
if (r[i])
- for (j = 0; r[i][j] != END_NODE; ++j)
- fprintf (out, "%3lu ", (unsigned long int) r[i][j]);
+ for (j = 0; r[i][j] != END_NODE; ++j)
+ fprintf (out, "%3lu ", (unsigned long int) r[i][j]);
fputc ('\n', out);
}
fputc ('\n', out);
if (R[i])
for (j = 0; R[i][j] != END_NODE; ++j)
{
- if (INDEX[R[i][j]] == 0)
- traverse (R[i][j]);
+ if (INDEX[R[i][j]] == 0)
+ traverse (R[i][j]);
- if (INDEX[i] > INDEX[R[i][j]])
- INDEX[i] = INDEX[R[i][j]];
+ if (INDEX[i] > INDEX[R[i][j]])
+ INDEX[i] = INDEX[R[i][j]];
- bitset_or (F[i], F[i], F[R[i][j]]);
+ bitset_or (F[i], F[i], F[R[i][j]]);
}
if (INDEX[i] == height)
for (;;)
{
- j = VERTICES[top--];
- INDEX[j] = infinity;
+ j = VERTICES[top--];
+ INDEX[j] = infinity;
- if (i == j)
- break;
+ if (i == j)
+ break;
- bitset_copy (F[j], F[i]);
+ bitset_copy (F[j], F[i]);
}
}
for (i = 0; i < n; i++)
if (r[i])
for (j = 0; r[i][j] != END_NODE; ++j)
- ++nedges[r[i][j]];
+ ++nedges[r[i][j]];
/* Allocate. */
for (i = 0; i < n; i++)
{
relation_node *sp = NULL;
if (nedges[i] > 0)
- {
- sp = xnmalloc (nedges[i] + 1, sizeof *sp);
- sp[nedges[i]] = END_NODE;
- }
+ {
+ sp = xnmalloc (nedges[i] + 1, sizeof *sp);
+ sp[nedges[i]] = END_NODE;
+ }
new_R[i] = sp;
end_R[i] = sp;
}
for (i = 0; i < n; i++)
if (r[i])
for (j = 0; r[i][j] != END_NODE; ++j)
- *end_R[r[i][j]]++ = i;
+ *end_R[r[i][j]]++ = i;
free (nedges);
free (end_R);
#include <config.h>
#include "system.h"
-#include "scan-code.c"
+#include "src/scan-code.c"
*/
bool is_value_used;
+ /**
+ * \c true iff this code is an action that is not to be deferred in
+ * a non-deterministic parser.
+ */
+ bool is_predicate;
+
+ /**
+ * Whether this is actually used (i.e., not completely masked by
+ * other code props). */
+ bool is_used;
+
/** \c NULL iff \c code_props::kind is not \c CODE_PROPS_RULE_ACTION. */
struct symbol_list *rule;
void code_props_none_init (code_props *self);
/** Equivalent to \c code_props_none_init. */
-#define CODE_PROPS_NONE_INIT \
- {CODE_PROPS_NONE, NULL, EMPTY_LOCATION_INIT, false, NULL, NULL}
+#define CODE_PROPS_NONE_INIT \
+ { \
+ /* .kind = */ CODE_PROPS_NONE, \
+ /* .code = */ NULL, \
+ /* .location = */ EMPTY_LOCATION_INIT, \
+ /* .is_value_used = */ false, \
+ /* .is_predicate = */ false, \
+ /* .is_used = */ false, \
+ /* .rule = */ NULL, \
+ /* .named_ref = */ NULL \
+ }
/** Initialized by \c CODE_PROPS_NONE_INIT with no further modification. */
-extern code_props const code_props_none;
+extern code_props code_props_none;
/**
* \pre
*/
void code_props_rule_action_init (code_props *self, char const *code,
location code_loc, struct symbol_list *rule,
- named_ref *name);
+ named_ref *name, bool is_predicate);
/**
* \pre
#define code_wrap() 1
#define FLEX_PREFIX(Id) code_ ## Id
-#include "flex-scanner.h"
+#include <src/flex-scanner.h>
-#include "complain.h"
-#include "reader.h"
-#include "getargs.h"
-#include "scan-code.h"
-#include "symlist.h"
+#include <src/complain.h>
+#include <src/reader.h>
+#include <src/getargs.h>
+#include <src/muscle-tab.h>
+#include <src/scan-code.h>
+#include <src/symlist.h>
#include <c-ctype.h>
#include <get-errno.h>
location dollar_loc);
static void handle_action_dollar (symbol_list *rule, char *cp,
- location dollar_loc);
+ location dollar_loc);
static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
/* A string to be pushed to obstack after dollar/at has been handled. */
/* POSIX says that a tag must be both an id and a C union member, but
historically almost any character is allowed in a tag. We disallow
NUL and newline, as this simplifies our implementation. */
-tag [^\0\n>]+
+tag [^\0\n>]+
/* Zero or more instances of backslash-newline. Following GCC, allow
white space between the backslash and the newline. */
-splice (\\[ \f\t\v]*\n)*
+splice (\\[ \f\t\v]*\n)*
/* C style identifier. Must start with letter. Will be used for
named symbol references. Shall be kept synchronized with
scan-gram.l "letter" and "id". */
-letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
-id {letter}({letter}|[-0-9])*
+letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
+id {letter}({letter}|[-0-9])*
ref -?[0-9]+|{id}|"["{id}"]"|"$"
%%
is expected to return only once. This initialization is
therefore done once per action to translate. */
aver (sc_context == SC_SYMBOL_ACTION
- || sc_context == SC_RULE_ACTION
- || sc_context == INITIAL);
+ || sc_context == SC_RULE_ACTION
+ || sc_context == INITIAL);
BEGIN sc_context;
%}
<SC_LINE_COMMENT>
{
- "\n" STRING_GROW; BEGIN sc_context;
- {splice} STRING_GROW;
+ "\n" STRING_GROW; BEGIN sc_context;
+ {splice} STRING_GROW;
}
<SC_CHARACTER,SC_STRING>
{
- {splice}|\\{splice}. STRING_GROW;
+ {splice}|\\{splice}. STRING_GROW;
}
<SC_CHARACTER>
{
- "'" STRING_GROW; BEGIN sc_context;
+ "'" STRING_GROW; BEGIN sc_context;
}
<SC_STRING>
{
- "\"" STRING_GROW; BEGIN sc_context;
+ "\"" STRING_GROW; BEGIN sc_context;
}
BEGIN SC_LINE_COMMENT;
}
[$@] {
- warn_at (*loc, _("stray '%s'"), yytext);
+ complain (loc, Wother, _("stray '%s'"), yytext);
obstack_escape (&obstack_for_string, yytext);
need_semicolon = true;
}
&& skeleton_prio == default_prio && need_semicolon && ! in_cpp)
{
unsigned int indent = 0;
- warn_at_indent (*loc, &indent,
- _("a ';' might be needed at the end of action code"));
+ complain_indent (loc, Wdeprecated, &indent,
+ _("a ';' might be needed at the end of action code"));
indent += SUB_INDENT;
- warn_at_indent (*loc, &indent,
- _("future versions of Bison will not add the ';'"));
+ complain_indent (loc, Wdeprecated | silent, &indent,
+ _("future versions of Bison will not add the ';'"));
obstack_1grow (&obstack_for_string, ';');
}
{splice} STRING_GROW;
[\n\r] STRING_GROW; if (in_cpp) in_cpp = need_semicolon = false;
[ \t\f] STRING_GROW;
-
- /* YYFAIL is undocumented and was formally deprecated in Bison
- 2.4.2. */
- YYFAIL {
- STRING_GROW; need_semicolon = true;
- warn_at (*loc, _("use of YYFAIL, which is deprecated and will be"
- " removed"));
- }
-
- /* The sole purpose of this is to make sure identifiers that merely
- contain YYFAIL don't produce the above warning. */
- [A-Za-z_][0-9A-Za-z_]* STRING_GROW; need_semicolon = true;
-
- . STRING_GROW; need_semicolon = true;
+ . STRING_GROW; need_semicolon = true;
}
<SC_SYMBOL_ACTION>
}
"@$" {
obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
- locations_flag = true;
+ muscle_percent_define_ensure("locations", the_location, true);
}
}
/* By default, grow the string obstack with the input. */
.|\n STRING_GROW;
- /* End of processing. */
+ /* End of processing. */
<<EOF>> STRING_FINISH; return last_string;
}
if (variant_count > variant_table_size)
{
while (variant_count > variant_table_size)
- variant_table_size = 2 * variant_table_size + 3;
+ variant_table_size = 2 * variant_table_size + 3;
variant_table = xnrealloc (variant_table, variant_table_size,
- sizeof *variant_table);
+ sizeof *variant_table);
}
return &variant_table[variant_count - 1];
}
static variant *
variant_add (uniqstr id, location id_loc, unsigned symbol_index,
- char *cp, char *cp_end, bool explicit_bracketing)
+ char *cp, char *cp_end, bool explicit_bracketing)
{
char *prefix_end;
}
static const char *
-get_at_spec (unsigned symbol_index)
+get_at_spec(unsigned symbol_index)
{
static char at_buf[20];
if (symbol_index == 0)
}
static void
-show_sub_messages (const char* cp, bool explicit_bracketing,
- int midrule_rhs_index, char dollar_or_at,
- bool is_warning, unsigned indent)
+show_sub_message (warnings warning,
+ const char* cp, bool explicit_bracketing,
+ int midrule_rhs_index, char dollar_or_at,
+ unsigned indent, const variant *var)
{
- unsigned i;
+ const char *at_spec = get_at_spec (var->symbol_index);
- for (i = 0; i < variant_count; ++i)
+ if (var->err == 0)
+ complain_indent (&var->loc, warning, &indent,
+ _("refers to: %c%s at %s"), dollar_or_at,
+ var->id, at_spec);
+ else
{
- const variant *var = &variant_table[i];
- const char *at_spec = get_at_spec (var->symbol_index);
+ static struct obstack msg_buf;
+ const char *tail = explicit_bracketing ? "" : cp + strlen (var->id);
+ const char *id = var->hidden_by ? var->hidden_by->id : var->id;
+ location id_loc = var->hidden_by ? var->hidden_by->loc : var->loc;
+
+ /* Create the explanation message. */
+ obstack_init (&msg_buf);
- if (var->err == 0)
+ obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at);
+ if (contains_dot_or_dash (id))
+ obstack_printf (&msg_buf, "[%s]", id);
+ else
+ obstack_sgrow (&msg_buf, id);
+ obstack_sgrow (&msg_buf, tail);
+
+ if (var->err & VARIANT_HIDDEN)
{
- if (is_warning)
- warn_at_indent (var->loc, &indent, _("refers to: %c%s at %s"),
- dollar_or_at, var->id, at_spec);
+ obstack_printf (&msg_buf, _(", hiding %c"), dollar_or_at);
+ if (contains_dot_or_dash (var->id))
+ obstack_printf (&msg_buf, "[%s]", var->id);
else
- complain_at_indent (var->loc, &indent, _("refers to: %c%s at %s"),
- dollar_or_at, var->id, at_spec);
+ obstack_sgrow (&msg_buf, var->id);
+ obstack_sgrow (&msg_buf, tail);
}
- else
- {
- static struct obstack msg_buf;
- const char *tail = explicit_bracketing ? "" :
- cp + strlen (var->id);
- const char *id = var->hidden_by ? var->hidden_by->id :
- var->id;
- location id_loc = var->hidden_by ? var->hidden_by->loc :
- var->loc;
-
- /* Create the explanation message. */
- obstack_init (&msg_buf);
-
- obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at);
- if (contains_dot_or_dash (id))
- obstack_printf (&msg_buf, "[%s]", id);
- else
- obstack_sgrow (&msg_buf, id);
- obstack_sgrow (&msg_buf, tail);
-
- if (var->err & VARIANT_HIDDEN)
- {
- obstack_printf (&msg_buf, _(", hiding %c"), dollar_or_at);
- if (contains_dot_or_dash (var->id))
- obstack_printf (&msg_buf, "[%s]", var->id);
- else
- obstack_sgrow (&msg_buf, var->id);
- obstack_sgrow (&msg_buf, tail);
- }
-
- obstack_printf (&msg_buf, _(" at %s"), at_spec);
-
- if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
- {
- const char *format =
- _(", cannot be accessed from mid-rule action at $%d");
- obstack_printf (&msg_buf, format, midrule_rhs_index);
- }
- obstack_1grow (&msg_buf, '\0');
- if (is_warning)
- warn_at_indent (id_loc, &indent, "%s",
- (char *) obstack_finish (&msg_buf));
- else
- complain_at_indent (id_loc, &indent, "%s",
- (char *) obstack_finish (&msg_buf));
- obstack_free (&msg_buf, 0);
- }
+ obstack_printf (&msg_buf, _(" at %s"), at_spec);
+
+ if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
+ obstack_printf (&msg_buf,
+ _(", cannot be accessed from mid-rule action at $%d"),
+ midrule_rhs_index);
+
+ complain_indent (&id_loc, warning, &indent, "%s",
+ obstack_finish0 (&msg_buf));
+ obstack_free (&msg_buf, 0);
}
}
+static void
+show_sub_messages (warnings warning,
+ const char* cp, bool explicit_bracketing,
+ int midrule_rhs_index, char dollar_or_at,
+ unsigned indent)
+{
+ unsigned i;
+
+ for (i = 0; i < variant_count; ++i)
+ show_sub_message (warning | silent,
+ cp, explicit_bracketing,
+ midrule_rhs_index, dollar_or_at,
+ indent, &variant_table[i]);
+}
+
/* Returned from "parse_ref" when the reference
is inappropriate. */
#define INVALID_REF (INT_MIN)
accesses. */
static long int
parse_ref (char *cp, symbol_list *rule, int rule_length,
- int midrule_rhs_index, char *text, location text_loc,
- char dollar_or_at)
+ int midrule_rhs_index, char *text, location text_loc,
+ char dollar_or_at)
{
symbol_list *l;
char *cp_end;
{
long int num = strtol (cp, &cp, 10);
if (1 - INT_MAX + rule_length <= num && num <= rule_length)
- return num;
+ return num;
else
- {
- complain_at (text_loc, _("integer out of range: %s"),
- quote (text));
- return INVALID_REF;
- }
+ {
+ complain (&text_loc, complaint, _("integer out of range: %s"),
+ quote (text));
+ return INVALID_REF;
+ }
}
if ('[' == *cp)
/* Ignore the brackets. */
char *p;
for (p = ++cp; *p != ']'; ++p)
- continue;
+ continue;
cp_end = p;
explicit_bracketing = true;
/* Take all characters of the name. */
char* p;
for (p = cp; *p; ++p)
- if (is_dot_or_dash (*p))
- {
- ref_tail_fields = p;
- break;
- }
+ if (is_dot_or_dash (*p))
+ {
+ ref_tail_fields = p;
+ break;
+ }
for (p = cp; *p; ++p)
- continue;
+ continue;
cp_end = p;
explicit_bracketing = false;
for (symbol_index = 0, l = rule; !symbol_list_null (l);
++symbol_index, l = l->next)
{
- variant *var;
- if (l->content_type != SYMLIST_SYMBOL)
- continue;
+ variant *var;
+ if (l->content_type != SYMLIST_SYMBOL)
+ continue;
- var = variant_add (l->content.sym->tag, l->sym_loc,
+ var = variant_add (l->content.sym->tag, l->sym_loc,
symbol_index, cp, cp_end, explicit_bracketing);
- if (var && l->named_ref)
- var->hidden_by = l->named_ref;
+ if (var && l->named_ref)
+ var->hidden_by = l->named_ref;
- if (l->named_ref)
- variant_add (l->named_ref->id, l->named_ref->loc,
+ if (l->named_ref)
+ variant_add (l->named_ref->id, l->named_ref->loc,
symbol_index, cp, cp_end, explicit_bracketing);
}
}
/* Check visibility from mid-rule actions. */
if (midrule_rhs_index != 0
- && (symbol_index == 0 || midrule_rhs_index < symbol_index))
+ && (symbol_index == 0 || midrule_rhs_index < symbol_index))
var->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE;
/* Check correct bracketing. */
cp_end - cp : ref_tail_fields - cp;
unsigned indent = 0;
- complain_at_indent (text_loc, &indent, _("invalid reference: %s"),
- quote (text));
+ complain_indent (&text_loc, complaint, &indent,
+ _("invalid reference: %s"), quote (text));
indent += SUB_INDENT;
if (len == 0)
{
location sym_loc = text_loc;
sym_loc.start.column += 1;
sym_loc.end = sym_loc.start;
- const char *format =
- _("syntax error after '%c', expecting integer, letter,"
- " '_', '[', or '$'");
- complain_at_indent (sym_loc, &indent, format, dollar_or_at);
+ complain_indent (&sym_loc, complaint, &indent,
+ _("syntax error after '%c', expecting integer, "
+ "letter, '_', '[', or '$'"),
+ dollar_or_at);
}
else if (midrule_rhs_index)
- {
- const char *format =
- _("symbol not found in production before $%d: %.*s");
- complain_at_indent (rule->location, &indent, format,
- midrule_rhs_index, len, cp);
- }
+ complain_indent (&rule->location, complaint, &indent,
+ _("symbol not found in production before $%d: "
+ "%.*s"),
+ midrule_rhs_index, len, cp);
else
- {
- const char *format =
- _("symbol not found in production: %.*s");
- complain_at_indent (rule->location, &indent, format,
- len, cp);
- }
+ complain_indent (&rule->location, complaint, &indent,
+ _("symbol not found in production: %.*s"),
+ len, cp);
if (variant_count > 0)
- show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
- dollar_or_at, false, indent);
+ show_sub_messages (complaint,
+ cp, explicit_bracketing, midrule_rhs_index,
+ dollar_or_at, indent);
return INVALID_REF;
}
case 1:
unsigned indent = 0;
if (variant_count > 1)
{
- warn_at_indent (text_loc, &indent, _("misleading reference: %s"),
- quote (text));
- show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
- dollar_or_at, true, indent + SUB_INDENT);
+ complain_indent (&text_loc, Wother, &indent,
+ _("misleading reference: %s"), quote (text));
+ show_sub_messages (Wother,
+ cp, explicit_bracketing, midrule_rhs_index,
+ dollar_or_at, indent + SUB_INDENT);
}
{
unsigned symbol_index =
default:
{
unsigned indent = 0;
- complain_at_indent (text_loc, &indent, _("ambiguous reference: %s"),
- quote (text));
- show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
- dollar_or_at, false, indent + SUB_INDENT);
+ complain_indent (&text_loc, complaint, &indent,
+ _("ambiguous reference: %s"), quote (text));
+ show_sub_messages (complaint,
+ cp, explicit_bracketing, midrule_rhs_index,
+ dollar_or_at, indent + SUB_INDENT);
return INVALID_REF;
}
}
{
*type_name = ++cp;
while (*cp != '>')
- ++cp;
+ ++cp;
/* The '>' symbol will be later replaced by '\0'. Original
- 'text' is needed for error messages. */
+ 'text' is needed for error messages. */
++cp;
if (untyped_var_seen)
- complain_at (dollar_loc, _("explicit type given in untyped grammar"));
+ complain (&dollar_loc, complaint,
+ _("explicit type given in untyped grammar"));
tag_seen = true;
}
return cp;
cp = fetch_type_name (cp, &type_name, dollar_loc);
n = parse_ref (cp, effective_rule, effective_rule_length,
- rule->midrule_parent_rhs_index, text, dollar_loc, '$');
+ rule->midrule_parent_rhs_index, text, dollar_loc, '$');
/* End type_name. */
if (type_name)
case LHS_REF:
if (!type_name)
- type_name = symbol_list_n_type_name_get (rule, dollar_loc, 0);
+ type_name = symbol_list_n_type_name_get (rule, dollar_loc, 0);
if (!type_name)
{
if (union_seen | tag_seen)
{
if (rule->midrule_parent_rule)
- complain_at (dollar_loc,
+ complain (&dollar_loc, complaint,
_("$$ for the midrule at $%d of %s"
" has no declared type"),
rule->midrule_parent_rhs_index,
quote (effective_rule->content.sym->tag));
else
- complain_at (dollar_loc, _("$$ of %s has no declared type"),
- quote (rule->content.sym->tag));
+ complain (&dollar_loc, complaint,
+ _("$$ of %s has no declared type"),
+ quote (rule->content.sym->tag));
}
else
untyped_var_seen = true;
default:
if (max_left_semantic_context < 1 - n)
- max_left_semantic_context = 1 - n;
+ max_left_semantic_context = 1 - n;
if (!type_name && 0 < n)
- type_name =
- symbol_list_n_type_name_get (effective_rule, dollar_loc, n);
+ type_name =
+ symbol_list_n_type_name_get (effective_rule, dollar_loc, n);
if (!type_name)
{
if (union_seen | tag_seen)
- complain_at (dollar_loc, _("$%s of %s has no declared type"),
- cp, quote (effective_rule->content.sym->tag));
+ complain (&dollar_loc, complaint,
+ _("$%s of %s has no declared type"), cp,
+ quote (effective_rule->content.sym->tag));
else
untyped_var_seen = true;
}
obstack_printf (&obstack_for_string,
- "]b4_rhs_value(%d, %d, ", effective_rule_length, n);
+ "]b4_rhs_value(%d, %d, ", effective_rule_length, n);
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
if (n > 0)
- symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
- true;
+ symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
+ true;
break;
}
}
effective_rule_length = symbol_list_length (rule->next);
}
- locations_flag = true;
+ muscle_percent_define_ensure("locations", at_loc, true);
n = parse_ref (cp, effective_rule, effective_rule_length,
- rule->midrule_parent_rhs_index, text, at_loc, '@');
+ rule->midrule_parent_rhs_index, text, at_loc, '@');
switch (n)
{
case INVALID_REF:
default:
obstack_printf (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
- effective_rule_length, n);
+ effective_rule_length, n);
break;
}
}
*self = code_props_none;
}
-code_props const code_props_none = CODE_PROPS_NONE_INIT;
+code_props code_props_none = CODE_PROPS_NONE_INIT;
void
code_props_plain_init (code_props *self, char const *code,
- location code_loc)
+ location code_loc)
{
+ code_props_none_init (self);
self->kind = CODE_PROPS_PLAIN;
self->code = code;
self->location = code_loc;
- self->is_value_used = false;
- self->rule = NULL;
- self->named_ref = NULL;
}
void
code_props_symbol_action_init (code_props *self, char const *code,
location code_loc)
{
+ code_props_none_init (self);
self->kind = CODE_PROPS_SYMBOL_ACTION;
self->code = code;
self->location = code_loc;
- self->is_value_used = false;
- self->rule = NULL;
- self->named_ref = NULL;
}
void
code_props_rule_action_init (code_props *self, char const *code,
location code_loc, symbol_list *rule,
- named_ref *name)
+ named_ref *name, bool is_predicate)
{
+ code_props_none_init (self);
self->kind = CODE_PROPS_RULE_ACTION;
self->code = code;
self->location = code_loc;
- self->is_value_used = false;
self->rule = rule;
self->named_ref = name;
+ self->is_predicate = is_predicate;
}
void
#include <config.h>
#include "system.h"
-#include "scan-gram.c"
+#include "src/scan-gram.c"
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-%option debug nodefault noinput nounput noyywrap never-interactive
+%option debug nodefault noinput noyywrap never-interactive
%option prefix="gram_" outfile="lex.yy.c"
%{
#define gram_wrap() 1
#define FLEX_PREFIX(Id) gram_ ## Id
-#include "flex-scanner.h"
+#include <src/flex-scanner.h>
-#include "complain.h"
-#include "files.h"
-#include "gram.h"
-#include "quotearg.h"
-#include "reader.h"
-#include "uniqstr.h"
+#include <src/complain.h>
+#include <src/files.h>
+#include <src/getargs.h>
+#include <src/gram.h>
+#include <quotearg.h>
+#include <src/reader.h>
+#include <src/uniqstr.h>
#include <c-ctype.h>
#include <mbswidth.h>
#include <quote.h>
-#include "scan-gram.h"
+#include <src/scan-gram.h>
#define YY_DECL GRAM_LEX_DECL
-#define YY_USER_INIT \
- code_start = scanner_cursor = loc->start; \
+#define YY_USER_INIT \
+ code_start = scanner_cursor = loc->start; \
/* Location of scanner cursor. */
static boundary scanner_cursor;
static size_t no_cr_read (FILE *, char *, size_t);
#define YY_INPUT(buf, result, size) ((result) = no_cr_read (yyin, buf, size))
+#define RETURN_PERCENT_PARAM(Value) \
+ RETURN_VALUE(PERCENT_PARAM, param, param_ ## Value)
+
+#define RETURN_PERCENT_FLAG(Value) \
+ RETURN_VALUE(PERCENT_FLAG, uniqstr, uniqstr_new (Value))
+
+#define RETURN_VALUE(Token, Field, Value) \
+ do { \
+ val->Field = Value; \
+ return Token; \
+ } while (0)
+
#define ROLLBACK_CURRENT_TOKEN \
do { \
- scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0); \
+ scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0); \
yyless (0); \
} while (0)
+#define DEPRECATED(Msg) \
+ do { \
+ size_t i; \
+ complain (loc, Wdeprecated, \
+ _("deprecated directive: %s, use %s"), \
+ quote (yytext), quote_n (1, Msg)); \
+ scanner_cursor.column -= mbsnwidth (Msg, strlen (Msg), 0); \
+ for (i = strlen (Msg); i != 0; --i) \
+ unput (Msg[i - 1]); \
+ } while (0)
+
/* A string representing the most recently saved token. */
static char *last_string;
/* A identifier was just read in directives/rules. Special state
to capture the sequence 'identifier :'. */
%x SC_AFTER_IDENTIFIER
+ /* A complex tag, with nested angles brackets. */
+%x SC_TAG
- /* Three types of user code:
+ /* Four types of user code:
- prologue (code between '%{' '%}' in the first section, before %%);
- actions, printers, union, etc, (between braced in the middle section);
- - epilogue (everything after the second %%). */
-%x SC_PROLOGUE SC_BRACED_CODE SC_EPILOGUE
+ - epilogue (everything after the second %%).
+ - predicate (code between '%?{' and '{' in middle section); */
+%x SC_PROLOGUE SC_BRACED_CODE SC_EPILOGUE SC_PREDICATE
/* C and C++ comments in code. */
%x SC_COMMENT SC_LINE_COMMENT
/* Strings and characters in code. */
/* Bracketed identifiers support. */
%x SC_BRACKETED_ID SC_RETURN_BRACKETED_ID
-letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
+letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
notletter [^.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]{-}[%\{]
-id {letter}({letter}|[-0-9])*
-int [0-9]+
+id {letter}({letter}|[-0-9])*
+int [0-9]+
/* POSIX says that a tag must be both an id and a C union member, but
historically almost any character is allowed in a tag. We disallow
- NUL and newline, as this simplifies our implementation. */
-tag [^\0\n>]+
+ NUL, as this simplifies our implementation. We disallow angle
+ bracket to match them in nested pairs: several languages use them
+ for generics/template types. */
+tag [^\0<>]+
/* Zero or more instances of backslash-newline. Following GCC, allow
white space between the backslash and the newline. */
-splice (\\[ \f\t\v]*\n)*
+splice (\\[ \f\t\v]*\n)*
+
+/* An equal sign, with optional leading whitespaces. This is used in some
+ deprecated constructs. */
+eqopt ([[:space:]]*=)?
%%
%{
- /* Nesting level of the current code in braces. */
- int braces_level PACIFY_CC (= 0);
+ /* Nesting level. Either for nested braces, or nested angle brackets
+ (but not mixed). */
+ int nesting PACIFY_CC (= 0);
/* Parent context state, when applicable. */
int context_state PACIFY_CC (= 0);
<INITIAL,SC_AFTER_IDENTIFIER,SC_BRACKETED_ID,SC_RETURN_BRACKETED_ID>
{
/* Comments and white space. */
- "," warn_at (*loc, _("stray ',' treated as white space"));
+ "," {
+ complain (loc, Wother, _("stray ',' treated as white space"));
+ }
[ \f\n\t\v] |
"//".* continue;
"/*" {
`----------------------------*/
/* For directives that are also command line options, the regex must be
- "%..."
+ "%..."
after "[-_]"s are removed, and the directive must match the --long
option name, with a single string argument. Otherwise, add exceptions
to ../build-aux/cross-options.pl. */
{
"%binary" return PERCENT_NONASSOC;
"%code" return PERCENT_CODE;
- "%debug" return PERCENT_DEBUG;
- "%default"[-_]"prec" return PERCENT_DEFAULT_PREC;
+ "%debug" RETURN_PERCENT_FLAG("parse.trace");
+ "%default-prec" return PERCENT_DEFAULT_PREC;
"%define" return PERCENT_DEFINE;
"%defines" return PERCENT_DEFINES;
"%destructor" return PERCENT_DESTRUCTOR;
"%dprec" return PERCENT_DPREC;
- "%error"[-_]"verbose" return PERCENT_ERROR_VERBOSE;
+ "%error-verbose" return PERCENT_ERROR_VERBOSE;
"%expect" return PERCENT_EXPECT;
- "%expect"[-_]"rr" return PERCENT_EXPECT_RR;
+ "%expect-rr" return PERCENT_EXPECT_RR;
"%file-prefix" return PERCENT_FILE_PREFIX;
- "%fixed"[-_]"output"[-_]"files" return PERCENT_YACC;
+ "%fixed-output-files" return PERCENT_YACC;
"%initial-action" return PERCENT_INITIAL_ACTION;
"%glr-parser" return PERCENT_GLR_PARSER;
"%language" return PERCENT_LANGUAGE;
"%left" return PERCENT_LEFT;
- "%lex-param" return PERCENT_LEX_PARAM;
- "%locations" return PERCENT_LOCATIONS;
+ "%lex-param" RETURN_PERCENT_PARAM(lex);
+ "%locations" RETURN_PERCENT_FLAG("locations");
"%merge" return PERCENT_MERGE;
- "%name"[-_]"prefix" return PERCENT_NAME_PREFIX;
- "%no"[-_]"default"[-_]"prec" return PERCENT_NO_DEFAULT_PREC;
- "%no"[-_]"lines" return PERCENT_NO_LINES;
+ "%name-prefix" return PERCENT_NAME_PREFIX;
+ "%no-default-prec" return PERCENT_NO_DEFAULT_PREC;
+ "%no-lines" return PERCENT_NO_LINES;
"%nonassoc" return PERCENT_NONASSOC;
"%nondeterministic-parser" return PERCENT_NONDETERMINISTIC_PARSER;
"%nterm" return PERCENT_NTERM;
"%output" return PERCENT_OUTPUT;
- "%parse-param" return PERCENT_PARSE_PARAM;
+ "%param" RETURN_PERCENT_PARAM(both);
+ "%parse-param" RETURN_PERCENT_PARAM(parse);
"%prec" return PERCENT_PREC;
+ "%precedence" return PERCENT_PRECEDENCE;
"%printer" return PERCENT_PRINTER;
- "%pure"[-_]"parser" return PERCENT_PURE_PARSER;
+ "%pure-parser" RETURN_PERCENT_FLAG("api.pure");
"%require" return PERCENT_REQUIRE;
"%right" return PERCENT_RIGHT;
"%skeleton" return PERCENT_SKELETON;
"%start" return PERCENT_START;
"%term" return PERCENT_TOKEN;
"%token" return PERCENT_TOKEN;
- "%token"[-_]"table" return PERCENT_TOKEN_TABLE;
+ "%token-table" return PERCENT_TOKEN_TABLE;
"%type" return PERCENT_TYPE;
"%union" return PERCENT_UNION;
"%verbose" return PERCENT_VERBOSE;
"%yacc" return PERCENT_YACC;
+ /* deprecated */
+ "%default"[-_]"prec" DEPRECATED("%default-prec");
+ "%error"[-_]"verbose" DEPRECATED("%define parse.error verbose");
+ "%expect"[-_]"rr" DEPRECATED("%expect-rr");
+ "%file-prefix"{eqopt} DEPRECATED("%file-prefix");
+ "%fixed"[-_]"output"[-_]"files" DEPRECATED("%fixed-output-files");
+ "%name"[-_]"prefix"{eqopt} DEPRECATED("%name-prefix");
+ "%no"[-_]"default"[-_]"prec" DEPRECATED("%no-default-prec");
+ "%no"[-_]"lines" DEPRECATED("%no-lines");
+ "%output"{eqopt} DEPRECATED("%output");
+ "%pure"[-_]"parser" DEPRECATED("%pure-parser");
+ "%token"[-_]"table" DEPRECATED("%token-table");
+
"%"{id}|"%"{notletter}([[:graph:]])+ {
- complain_at (*loc, _("invalid directive: %s"), quote (yytext));
+ complain (loc, complaint, _("invalid directive: %s"), quote (yytext));
}
"=" return EQUAL;
"|" return PIPE;
";" return SEMICOLON;
- "<*>" return TYPE_TAG_ANY;
- "<>" return TYPE_TAG_NONE;
{id} {
val->uniqstr = uniqstr_new (yytext);
/* Identifiers may not start with a digit. Yet, don't silently
accept "1FOO" as "1 FOO". */
{int}{id} {
- complain_at (*loc, _("invalid identifier: %s"), quote (yytext));
+ complain (loc, complaint, _("invalid identifier: %s"), quote (yytext));
}
/* Characters. */
- "'" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
+ "'" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
/* Strings. */
- "\"" token_start = loc->start; BEGIN SC_ESCAPED_STRING;
+ "\"" token_start = loc->start; BEGIN SC_ESCAPED_STRING;
/* Prologue. */
"%{" code_start = loc->start; BEGIN SC_PROLOGUE;
/* Code in between braces. */
"{" {
STRING_GROW;
- braces_level = 0;
+ nesting = 0;
code_start = loc->start;
BEGIN SC_BRACED_CODE;
}
+ /* Semantic predicate. */
+ "%?"[ \f\n\t\v]*"{" {
+ nesting = 0;
+ code_start = loc->start;
+ BEGIN SC_PREDICATE;
+ }
+
/* A type. */
+ "<*>" return TAG_ANY;
+ "<>" return TAG_NONE;
"<"{tag}">" {
obstack_grow (&obstack_for_string, yytext + 1, yyleng - 2);
STRING_FINISH;
val->uniqstr = uniqstr_new (last_string);
STRING_FREE;
- return TYPE;
+ return TAG;
+ }
+ "<" {
+ nesting = 0;
+ token_start = loc->start;
+ BEGIN SC_TAG;
}
"%%" {
}
[^\[%A-Za-z0-9_<>{}\"\'*;|=/, \f\n\t\v]+|. {
- complain_at (*loc, "%s: %s",
- ngettext ("invalid character", "invalid characters", yyleng),
- quote_mem (yytext, yyleng));
+ complain (loc, complaint, "%s: %s",
+ ngettext ("invalid character", "invalid characters", yyleng),
+ quote_mem (yytext, yyleng));
}
<<EOF>> {
}
+ /*--------------------------------------------------------------.
+ | Supporting \0 complexifies our implementation for no expected |
+ | added value. |
+ `--------------------------------------------------------------*/
+
+<SC_ESCAPED_CHARACTER,SC_ESCAPED_STRING,SC_TAG>
+{
+ \0 complain (loc, complaint, _("invalid null character"));
+}
+
+
/*-----------------------------------------------------------------.
| Scanning after an identifier, checking whether a colon is next. |
`-----------------------------------------------------------------*/
"[" {
if (bracketed_id_str)
{
- ROLLBACK_CURRENT_TOKEN;
- BEGIN SC_RETURN_BRACKETED_ID;
- *loc = id_loc;
- return ID;
+ ROLLBACK_CURRENT_TOKEN;
+ BEGIN SC_RETURN_BRACKETED_ID;
+ *loc = id_loc;
+ return ID;
}
else
{
- bracketed_id_start = loc->start;
- bracketed_id_context_state = YY_START;
- BEGIN SC_BRACKETED_ID;
+ bracketed_id_start = loc->start;
+ bracketed_id_context_state = YY_START;
+ BEGIN SC_BRACKETED_ID;
}
}
":" {
{id} {
if (bracketed_id_str)
{
- complain_at (*loc, _("unexpected identifier in bracketed name: %s"),
- quote (yytext));
+ complain (loc, complaint,
+ _("unexpected identifier in bracketed name: %s"),
+ quote (yytext));
}
else
{
- bracketed_id_str = uniqstr_new (yytext);
- bracketed_id_loc = *loc;
+ bracketed_id_str = uniqstr_new (yytext);
+ bracketed_id_loc = *loc;
}
}
"]" {
BEGIN bracketed_id_context_state;
if (bracketed_id_str)
{
- if (INITIAL == bracketed_id_context_state)
- {
- val->uniqstr = bracketed_id_str;
- bracketed_id_str = 0;
- *loc = bracketed_id_loc;
- return BRACKETED_ID;
- }
+ if (INITIAL == bracketed_id_context_state)
+ {
+ val->uniqstr = bracketed_id_str;
+ bracketed_id_str = 0;
+ *loc = bracketed_id_loc;
+ return BRACKETED_ID;
+ }
}
else
- complain_at (*loc, _("an identifier expected"));
+ complain (loc, complaint, _("an identifier expected"));
}
[^\].A-Za-z0-9_/ \f\n\t\v]+|. {
- complain_at (*loc, "%s: %s",
- ngettext ("invalid character in bracketed name",
- "invalid characters in bracketed name", yyleng),
- quote_mem (yytext, yyleng));
+ complain (loc, complaint, "%s: %s",
+ ngettext ("invalid character in bracketed name",
+ "invalid characters in bracketed name", yyleng),
+ quote_mem (yytext, yyleng));
}
<<EOF>> {
<SC_YACC_COMMENT>
{
"*/" BEGIN context_state;
- .|\n continue;
+ .|\n continue;
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
}
<SC_COMMENT>
{
"*"{splice}"/" STRING_GROW; BEGIN context_state;
- <<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
+ <<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
}
<SC_LINE_COMMENT>
{
- "\n" STRING_GROW; BEGIN context_state;
- {splice} STRING_GROW;
- <<EOF>> BEGIN context_state;
+ "\n" STRING_GROW; BEGIN context_state;
+ {splice} STRING_GROW;
+ <<EOF>> BEGIN context_state;
}
/*----------------------------------------------------------.
| Scanning a Bison character literal, decoding its escapes. |
- | The initial quote is already eaten. |
+ | The initial quote is already eaten. |
`----------------------------------------------------------*/
<SC_ESCAPED_CHARACTER>
/* FIXME: Eventually, make these errors. */
if (last_string[0] == '\0')
{
- warn_at (*loc, _("empty character literal"));
+ complain (loc, Wother, _("empty character literal"));
/* '\0' seems dangerous even if we are about to complain. */
val->character = '\'';
}
else if (last_string[1] != '\0')
- warn_at (*loc, _("extra characters in character literal"));
+ complain (loc, Wother,
+ _("extra characters in character literal"));
}
if (yytext[0] == '\n')
unexpected_newline (token_start, "'");
/* FIXME: Eventually, make these errors. */
if (last_string[0] == '\0')
{
- warn_at (*loc, _("empty character literal"));
+ complain (loc, Wother, _("empty character literal"));
/* '\0' seems dangerous even if we are about to complain. */
val->character = '\'';
}
else if (last_string[1] != '\0')
- warn_at (*loc, _("extra characters in character literal"));
+ complain (loc, Wother,
+ _("extra characters in character literal"));
}
unexpected_eof (token_start, "'");
STRING_FREE;
}
}
-<SC_ESCAPED_CHARACTER,SC_ESCAPED_STRING>
+ /*-----------------------------------------------------------.
+ | Scanning a Bison nested tag. The initial angle bracket is |
+ | already eaten. |
+ `-----------------------------------------------------------*/
+
+<SC_TAG>
{
- \0 complain_at (*loc, _("invalid null character"));
-}
+ ">" {
+ --nesting;
+ if (nesting < 0)
+ {
+ STRING_FINISH;
+ loc->start = token_start;
+ val->uniqstr = uniqstr_new (last_string);
+ STRING_FREE;
+ BEGIN INITIAL;
+ return TAG;
+ }
+ STRING_GROW;
+ }
+ [^<>]+ STRING_GROW;
+ "<"+ STRING_GROW; nesting += yyleng;
+
+ <<EOF>> {
+ unexpected_eof (token_start, ">");
+ STRING_FINISH;
+ loc->start = token_start;
+ val->uniqstr = uniqstr_new (last_string);
+ STRING_FREE;
+ BEGIN INITIAL;
+ return TAG;
+ }
+}
/*----------------------------.
| Decode escaped characters. |
\\[0-7]{1,3} {
unsigned long int c = strtoul (yytext + 1, NULL, 8);
if (!c || UCHAR_MAX < c)
- complain_at (*loc, _("invalid number after \\-escape: %s"),
+ complain (loc, complaint, _("invalid number after \\-escape: %s"),
yytext+1);
else
obstack_1grow (&obstack_for_string, c);
verify (UCHAR_MAX < ULONG_MAX);
unsigned long int c = strtoul (yytext + 2, NULL, 16);
if (!c || UCHAR_MAX < c)
- complain_at (*loc, _("invalid number after \\-escape: %s"),
+ complain (loc, complaint, _("invalid number after \\-escape: %s"),
yytext+1);
else
obstack_1grow (&obstack_for_string, c);
}
- \\a obstack_1grow (&obstack_for_string, '\a');
- \\b obstack_1grow (&obstack_for_string, '\b');
- \\f obstack_1grow (&obstack_for_string, '\f');
- \\n obstack_1grow (&obstack_for_string, '\n');
- \\r obstack_1grow (&obstack_for_string, '\r');
- \\t obstack_1grow (&obstack_for_string, '\t');
- \\v obstack_1grow (&obstack_for_string, '\v');
+ \\a obstack_1grow (&obstack_for_string, '\a');
+ \\b obstack_1grow (&obstack_for_string, '\b');
+ \\f obstack_1grow (&obstack_for_string, '\f');
+ \\n obstack_1grow (&obstack_for_string, '\n');
+ \\r obstack_1grow (&obstack_for_string, '\r');
+ \\t obstack_1grow (&obstack_for_string, '\t');
+ \\v obstack_1grow (&obstack_for_string, '\v');
/* \\[\"\'?\\] would be shorter, but it confuses xgettext. */
\\("\""|"'"|"?"|"\\") obstack_1grow (&obstack_for_string, yytext[1]);
\\(u|U[0-9abcdefABCDEF]{4})[0-9abcdefABCDEF]{4} {
int c = convert_ucn_to_byte (yytext);
if (c <= 0)
- complain_at (*loc, _("invalid number after \\-escape: %s"),
+ complain (loc, complaint, _("invalid number after \\-escape: %s"),
yytext+1);
else
obstack_1grow (&obstack_for_string, c);
}
- \\(.|\n) {
+ \\(.|\n) {
char const *p = yytext + 1;
/* Quote only if escaping won't make the character visible. */
if (c_isspace ((unsigned char) *p) && c_isprint ((unsigned char) *p))
p = quote (p);
else
p = quotearg_style_mem (escape_quoting_style, p, 1);
- complain_at (*loc, _("invalid character after \\-escape: %s"), p);
+ complain (loc, complaint, _("invalid character after \\-escape: %s"),
+ p);
}
}
<SC_CHARACTER,SC_STRING>
{
- {splice}|\\{splice}[^\n\[\]] STRING_GROW;
+ {splice}|\\{splice}[^\n\[\]] STRING_GROW;
}
<SC_CHARACTER>
{
- "'" STRING_GROW; BEGIN context_state;
- \n unexpected_newline (token_start, "'"); BEGIN context_state;
- <<EOF>> unexpected_eof (token_start, "'"); BEGIN context_state;
+ "'" STRING_GROW; BEGIN context_state;
+ \n unexpected_newline (token_start, "'"); BEGIN context_state;
+ <<EOF>> unexpected_eof (token_start, "'"); BEGIN context_state;
}
<SC_STRING>
{
- "\"" STRING_GROW; BEGIN context_state;
- \n unexpected_newline (token_start, "\""); BEGIN context_state;
- <<EOF>> unexpected_eof (token_start, "\""); BEGIN context_state;
+ "\"" STRING_GROW; BEGIN context_state;
+ \n unexpected_newline (token_start, "\""); BEGIN context_state;
+ <<EOF>> unexpected_eof (token_start, "\""); BEGIN context_state;
}
| Strings, comments etc. can be found in user code. |
`---------------------------------------------------*/
-<SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>
+<SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE,SC_PREDICATE>
{
"'" {
STRING_GROW;
/*-----------------------------------------------------------.
- | Scanning some code in braces (actions). The initial "{" is |
- | already eaten. |
+ | Scanning some code in braces (actions, predicates). The |
+ | initial "{" is already eaten. |
`-----------------------------------------------------------*/
-<SC_BRACED_CODE>
+<SC_BRACED_CODE,SC_PREDICATE>
{
- "{"|"<"{splice}"%" STRING_GROW; braces_level++;
- "%"{splice}">" STRING_GROW; braces_level--;
- "}" {
- obstack_1grow (&obstack_for_string, '}');
-
- --braces_level;
- if (braces_level < 0)
- {
- STRING_FINISH;
- loc->start = code_start;
- val->code = last_string;
- BEGIN INITIAL;
- return BRACED_CODE;
- }
- }
+ "{"|"<"{splice}"%" STRING_GROW; nesting++;
+ "%"{splice}">" STRING_GROW; nesting--;
/* Tokenize '<<%' correctly (as '<<' '%') rather than incorrrectly
(as '<' '<%'). */
"<"{splice}"<" STRING_GROW;
<<EOF>> {
+ int token = (YY_START == SC_BRACED_CODE) ? BRACED_CODE : BRACED_PREDICATE;
unexpected_eof (code_start, "}");
STRING_FINISH;
loc->start = code_start;
val->code = last_string;
BEGIN INITIAL;
- return BRACED_CODE;
+ return token;
}
}
+<SC_BRACED_CODE>
+{
+ "}" {
+ obstack_1grow (&obstack_for_string, '}');
+
+ --nesting;
+ if (nesting < 0)
+ {
+ STRING_FINISH;
+ loc->start = code_start;
+ val->code = last_string;
+ BEGIN INITIAL;
+ return BRACED_CODE;
+ }
+ }
+}
+
+<SC_PREDICATE>
+{
+ "}" {
+ --nesting;
+ if (nesting < 0)
+ {
+ STRING_FINISH;
+ loc->start = code_start;
+ val->code = last_string;
+ BEGIN INITIAL;
+ return BRACED_PREDICATE;
+ }
+ else
+ obstack_1grow (&obstack_for_string, '}');
+ }
+}
/*--------------------------------------------------------------.
| Scanning some prologue: from "%{" (already scanned) to "%}". |
| By default, grow the string obstack with the input. |
`-----------------------------------------------------*/
-<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE,SC_STRING,SC_CHARACTER,SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>. |
-<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>\n STRING_GROW;
+<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PREDICATE,SC_PROLOGUE,SC_EPILOGUE,SC_STRING,SC_CHARACTER,SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>. |
+ <SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PREDICATE,SC_PROLOGUE,SC_EPILOGUE>\n STRING_GROW;
%%
{
char *w = memchr (buf, '\r', bytes_read);
if (w)
- {
- char const *r = ++w;
- char const *lim = buf + bytes_read;
-
- for (;;)
- {
- /* Found an '\r'. Treat it like '\n', but ignore any
- '\n' that immediately follows. */
- w[-1] = '\n';
- if (r == lim)
- {
- int ch = getc (fp);
- if (ch != '\n' && ungetc (ch, fp) != ch)
- break;
- }
- else if (*r == '\n')
- r++;
-
- /* Copy until the next '\r'. */
- do
- {
- if (r == lim)
- return w - buf;
- }
- while ((*w++ = *r++) != '\r');
- }
-
- return w - buf;
- }
+ {
+ char const *r = ++w;
+ char const *lim = buf + bytes_read;
+
+ for (;;)
+ {
+ /* Found an '\r'. Treat it like '\n', but ignore any
+ '\n' that immediately follows. */
+ w[-1] = '\n';
+ if (r == lim)
+ {
+ int ch = getc (fp);
+ if (ch != '\n' && ungetc (ch, fp) != ch)
+ break;
+ }
+ else if (*r == '\n')
+ r++;
+
+ /* Copy until the next '\r'. */
+ do
+ {
+ if (r == lim)
+ return w - buf;
+ }
+ while ((*w++ = *r++) != '\r');
+ }
+
+ return w - buf;
+ }
}
return bytes_read;
if (INT_MAX < num)
{
- complain_at (loc, _("integer out of range: %s"), quote (number));
+ complain (&loc, complaint, _("integer out of range: %s"),
+ quote (number));
num = INT_MAX;
}
/*------------------------------------------------------------------.
| Convert universal character name UCN to a single-byte character, |
| and return that character. Return -1 if UCN does not correspond |
-| to a single-byte character. |
+| to a single-byte character. |
`------------------------------------------------------------------*/
static int
about. */
static signed char const table[] =
{
- '\0', -1, -1, -1, -1, -1, -1, '\a',
- '\b', '\t', '\n', '\v', '\f', '\r', -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- ' ', '!', '"', '#', '$', '%', '&', '\'',
- '(', ')', '*', '+', ',', '-', '.', '/',
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', ':', ';', '<', '=', '>', '?',
- '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
- 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
- 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
- '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
- 'x', 'y', 'z', '{', '|', '}', '~'
+ '\0', -1, -1, -1, -1, -1, -1, '\a',
+ '\b', '\t', '\n', '\v', '\f', '\r', -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ ' ', '!', '"', '#', '$', '%', '&', '\'',
+ '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+ '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', '{', '|', '}', '~'
};
code = code < sizeof table ? table[code] : -1;
unsigned long int lineno = strtoul (args, &file, 10);
if (INT_MAX <= lineno)
{
- warn_at (loc, _("line number overflow"));
+ complain (&loc, Wother, _("line number overflow"));
lineno = INT_MAX;
}
- file = mbschr (file, '"');
+ file = strchr (file, '"');
if (file)
{
- *mbschr (file + 1, '"') = '\0';
+ *strchr (file + 1, '"') = '\0';
current_file = uniqstr_new (file + 1);
}
boundary_set (&scanner_cursor, current_file, lineno, 1);
/*----------------------------------------------------------------.
| For a token or comment starting at START, report message MSGID, |
-| which should say that an end marker was found before |
-| the expected TOKEN_END. |
+| which should say that an end marker was found before |
+| the expected TOKEN_END. |
`----------------------------------------------------------------*/
static void
loc.end = scanner_cursor;
token_end = quote (token_end);
// Instead of '\'', display "'".
- if (!strcmp (token_end, "'\\''"))
+ if (STREQ (token_end, "'\\''"))
token_end = "\"'\"";
- complain_at (loc, _(msgid), token_end);
+ complain (&loc, complaint, _(msgid), token_end);
}
#include <config.h>
#include "system.h"
-#include "scan-skel.c"
+#include "src/scan-skel.c"
/* Scan Bison Skeletons. -*- C -*-
- Copyright (C) 2001-2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001-2012 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
#define skel_wrap() 1
#define FLEX_PREFIX(Id) skel_ ## Id
-#include "flex-scanner.h"
+#include <src/flex-scanner.h>
#include <dirname.h>
#include <error.h>
#include <quotearg.h>
-#include "complain.h"
-#include "getargs.h"
-#include "files.h"
-#include "scan-skel.h"
+#include <src/complain.h>
+#include <src/getargs.h>
+#include <src/files.h>
+#include <src/scan-skel.h>
#define YY_DECL static int skel_lex (void)
YY_DECL;
-#define QPUTS(String) \
- fputs (quotearg_style (c_quoting_style, String), yyout)
-
-static void at_directive_perform (int at_directive_argc,
- char *at_directive_argv[],
- char **outnamep, int *out_linenop);
+typedef void (*at_directive)(int, char**, char **, int*);
+static void at_init (int *argc, char *argv[], at_directive *at_ptr, at_directive fun);
+static void at_basename (int argc, char *argv[], char**, int*);
+static void at_complain (int argc, char *argv[], char**, int*);
+static void at_output (int argc, char *argv[], char **name, int *lineno);
static void fail_for_at_directive_too_many_args (char const *at_directive_name);
static void fail_for_at_directive_too_few_args (char const *at_directive_name);
static void fail_for_invalid_at (char const *at);
%{
int out_lineno PACIFY_CC (= 0);
- char *outname = NULL;
-
- /* Currently, only the @warn, @complain, @fatal, @warn_at, @complain_at, and
- @fatal_at directives take multiple arguments, and the last three already
- can't take more than 7. at_directive_argv[0] is the directive name. */
- #define AT_DIRECTIVE_ARGC_MAX 8
- int at_directive_argc = 0;
- char *at_directive_argv[AT_DIRECTIVE_ARGC_MAX];
+ char *out_name = NULL;
+
+ /* Currently, only the @complain directive takes multiple arguments, and
+ never more than 7, with argv[0] being the directive name and argv[1]
+ being the type of complaint to dispatch. */
+#define ARGC_MAX 9
+ int argc = 0;
+ char *argv[ARGC_MAX];
+ at_directive at_ptr = NULL;
%}
"@@" fputc ('@', yyout);
@\n continue;
"@oline@" fprintf (yyout, "%d", out_lineno + 1);
-"@ofile@" QPUTS (outname);
+"@ofile@" fputs (quotearg_style (c_quoting_style, out_name), yyout);
-@[a-z_]+"(" {
- yytext[yyleng-1] = '\0';
- obstack_grow (&obstack_for_string, yytext, yyleng);
- at_directive_argv[at_directive_argc++] =
- obstack_finish (&obstack_for_string);
- BEGIN SC_AT_DIRECTIVE_ARGS;
-}
+"@basename(" at_init (&argc, argv, &at_ptr, &at_basename);
+"@complain(" at_init (&argc, argv, &at_ptr, &at_complain);
+"@output(" at_init (&argc, argv, &at_ptr, &at_output);
/* This pattern must not match more than the previous @ patterns. */
-@[^@{}`(\n]* fail_for_invalid_at (yytext);
-\n out_lineno++; ECHO;
-[^@\n]+ ECHO;
+@[^@{}`(\n]* fail_for_invalid_at (yytext);
+\n out_lineno++; ECHO;
+[^@\n]+ ECHO;
<INITIAL><<EOF>> {
- if (outname)
+ if (out_name)
{
- free (outname);
+ free (out_name);
xfclose (yyout);
}
return EOF;
@\n continue;
@[,)] {
- if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX)
- fail_for_at_directive_too_many_args (at_directive_argv[0]);
+ if (argc >= ARGC_MAX)
+ fail_for_at_directive_too_many_args (argv[0]);
- obstack_1grow (&obstack_for_string, '\0');
- at_directive_argv[at_directive_argc++] =
- obstack_finish (&obstack_for_string);
+ argv[argc++] = obstack_finish0 (&obstack_for_string);
/* Like M4, skip whitespace after a comma. */
if (yytext[1] == ',')
BEGIN SC_AT_DIRECTIVE_SKIP_WS;
else
{
- at_directive_perform (at_directive_argc, at_directive_argv,
- &outname, &out_lineno);
- obstack_free (&obstack_for_string, at_directive_argv[0]);
- at_directive_argc = 0;
+ aver (at_ptr);
+ at_ptr (argc, argv, &out_name, &out_lineno);
+ obstack_free (&obstack_for_string, argv[0]);
+ argc = 0;
BEGIN INITIAL;
}
}
<SC_AT_DIRECTIVE_SKIP_WS>
{
[ \t\r\n] continue;
- . { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
+ . yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS;
}
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>
{
- <<EOF>> {
- fatal (_("unclosed %s directive in skeleton"), at_directive_argv[0]);
- }
+ <<EOF>> complain (NULL, fatal, _("unclosed %s directive in skeleton"), argv[0]);
}
%%
+static void
+at_init (int *argc, char *argv[], at_directive *at_ptr, at_directive fun)
+{
+ *at_ptr = fun;
+ yytext[yyleng-1] = '\0';
+ obstack_grow (&obstack_for_string, yytext, yyleng);
+ argv[(*argc)++] = obstack_finish (&obstack_for_string);
+ BEGIN SC_AT_DIRECTIVE_ARGS;
+}
+
/*------------------------.
| Scan a Bison skeleton. |
`------------------------*/
yylex_destroy ();
}
+static inline warnings
+flag (const char *arg)
+{
+ /* compare with values issued from b4_error */
+ if (STREQ (arg, "complain"))
+ return complaint;
+ else if (STREQ (arg, "fatal"))
+ return fatal;
+ else if (STREQ (arg, "note"))
+ return silent | complaint;
+ else if (STREQ (arg, "warn"))
+ return Wother;
+ else
+ aver (false);
+}
+
static void
-at_directive_perform (int at_directive_argc,
- char *at_directive_argv[],
- char **outnamep, int *out_linenop)
+at_basename (int argc, char *argv[], char **out_namep, int *out_linenop)
{
- if (0 == strcmp (at_directive_argv[0], "@basename"))
- {
- if (at_directive_argc > 2)
- fail_for_at_directive_too_many_args (at_directive_argv[0]);
- fputs (last_component (at_directive_argv[1]), yyout);
- }
- else if (0 == strcmp (at_directive_argv[0], "@warn")
- || 0 == strcmp (at_directive_argv[0], "@complain")
- || 0 == strcmp (at_directive_argv[0], "@fatal"))
- {
- void (*func)(char const *, ...);
- switch (at_directive_argv[0][1])
- {
- case 'w': func = warn; break;
- case 'c': func = complain; break;
- case 'f': func = fatal; break;
- default: aver (false); break;
- }
- switch (at_directive_argc)
- {
- case 2:
- func (_(at_directive_argv[1]));
- break;
- case 3:
- func (_(at_directive_argv[1]), at_directive_argv[2]);
- break;
- case 4:
- func (_(at_directive_argv[1]), at_directive_argv[2],
- at_directive_argv[3]);
- break;
- case 5:
- func (_(at_directive_argv[1]), at_directive_argv[2],
- at_directive_argv[3], at_directive_argv[4]);
- break;
- case 6:
- func (_(at_directive_argv[1]), at_directive_argv[2],
- at_directive_argv[3], at_directive_argv[4],
- at_directive_argv[5]);
- break;
- default:
- fail_for_at_directive_too_many_args (at_directive_argv[0]);
- break;
- }
- }
- else if (0 == strcmp (at_directive_argv[0], "@warn_at")
- || 0 == strcmp (at_directive_argv[0], "@complain_at")
- || 0 == strcmp (at_directive_argv[0], "@fatal_at"))
+ (void) out_namep;
+ (void) out_linenop;
+ if (2 < argc)
+ fail_for_at_directive_too_many_args (argv[0]);
+ fputs (last_component (argv[1]), yyout);
+}
+
+static void
+at_complain (int argc, char *argv[], char **out_namep, int *out_linenop)
+{
+ static unsigned indent;
+ warnings w = flag (argv[1]);
+ location loc;
+ location *locp = NULL;
+
+ (void) out_namep;
+ (void) out_linenop;
+
+ if (argc < 4)
+ fail_for_at_directive_too_few_args (argv[0]);
+ if (argv[2] && argv[2][0])
{
- void (*func)(location, char const *, ...);
- location loc;
- if (at_directive_argc < 4)
- fail_for_at_directive_too_few_args (at_directive_argv[0]);
- switch (at_directive_argv[0][1])
- {
- case 'w': func = warn_at; break;
- case 'c': func = complain_at; break;
- case 'f': func = fatal_at; break;
- default: aver (false); break;
- }
- boundary_set_from_string (&loc.start, at_directive_argv[1]);
- boundary_set_from_string (&loc.end, at_directive_argv[2]);
- switch (at_directive_argc)
- {
- case 4:
- func (loc, _(at_directive_argv[3]));
- break;
- case 5:
- func (loc, _(at_directive_argv[3]), at_directive_argv[4]);
- break;
- case 6:
- func (loc, _(at_directive_argv[3]), at_directive_argv[4],
- at_directive_argv[5]);
- break;
- case 7:
- func (loc, _(at_directive_argv[3]), at_directive_argv[4],
- at_directive_argv[5], at_directive_argv[6]);
- break;
- case 8:
- func (loc, _(at_directive_argv[3]), at_directive_argv[4],
- at_directive_argv[5], at_directive_argv[6],
- at_directive_argv[7]);
- break;
- default:
- fail_for_at_directive_too_many_args (at_directive_argv[0]);
- break;
- }
+ boundary_set_from_string (&loc.start, argv[2]);
+ boundary_set_from_string (&loc.end, argv[3]);
+ locp = &loc;
}
- else if (0 == strcmp (at_directive_argv[0], "@output"))
+ if (w & silent)
+ indent += SUB_INDENT;
+ else
+ indent = 0;
+ complain_args (locp, w, &indent, argc - 4, argv + 4);
+ if (w & silent)
+ indent -= SUB_INDENT;
+}
+
+static void
+at_output (int argc, char *argv[], char **out_namep, int *out_linenop)
+{
+ if (2 < argc)
+ fail_for_at_directive_too_many_args (argv[0]);
+ if (*out_namep)
{
- if (at_directive_argc > 2)
- fail_for_at_directive_too_many_args (at_directive_argv[0]);
- if (*outnamep)
- {
- free (*outnamep);
- xfclose (yyout);
- }
- *outnamep = xstrdup (at_directive_argv[1]);
- output_file_name_check (outnamep);
- yyout = xfopen (*outnamep, "w");
- *out_linenop = 1;
+ free (*out_namep);
+ xfclose (yyout);
}
- else
- fail_for_invalid_at (at_directive_argv[0]);
+ *out_namep = xstrdup (argv[1]);
+ output_file_name_check (out_namep);
+ yyout = xfopen (*out_namep, "w");
+ *out_linenop = 1;
}
static void
fail_for_at_directive_too_few_args (char const *at_directive_name)
{
- fatal (_("too few arguments for %s directive in skeleton"),
- at_directive_name);
+ complain (NULL, fatal, _("too few arguments for %s directive in skeleton"),
+ at_directive_name);
}
static void
fail_for_at_directive_too_many_args (char const *at_directive_name)
{
- fatal (_("too many arguments for %s directive in skeleton"),
- at_directive_name);
+ complain (NULL, fatal, _("too many arguments for %s directive in skeleton"),
+ at_directive_name);
}
static void
fail_for_invalid_at (char const *at)
{
- fatal ("invalid @ in skeleton: %s", at);
+ complain (NULL, fatal, "invalid @ in skeleton: %s", at);
}
#include "print-xml.h"
- /*-------------------.
- | Shifts and Gotos. |
- `-------------------*/
+ /*-------------------.
+ | Shifts and Gotos. |
+ `-------------------*/
/*-----------------------------------------.
{
aver (j < shifts->num);
if (TRANSITION_SYMBOL (shifts, j) == sym)
- return shifts->states[j];
+ return shifts->states[j];
}
}
- /*--------------------.
- | Error transitions. |
- `--------------------*/
+ /*--------------------.
+ | Error transitions. |
+ `--------------------*/
/*---------------------------------.
- /*-------------.
- | Reductions. |
- `-------------*/
+ /*-------------.
+ | Reductions. |
+ `-------------*/
/*---------------------------------------.
- /*---------.
- | States. |
- `---------*/
+ /*---------.
+ | States. |
+ `---------*/
state_number nstates = 0;
state *
state_new (symbol_number accessing_symbol,
- size_t nitems, item_number *core)
+ size_t nitems, item_number *core)
{
state *res;
size_t items_size = nitems * sizeof *core;
char const *sep = "";
fprintf (out, " [");
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
- {
- fprintf (out, "%s%s", sep, symbols[k]->tag);
- sep = ", ";
- }
+ {
+ fprintf (out, "%s%s", sep, symbols[k]->tag);
+ sep = ", ";
+ }
fprintf (out, "]");
}
}
void
state_rule_lookahead_tokens_print_xml (state *s, rule *r,
- FILE *out, int level)
+ FILE *out, int level)
{
/* Find the reduction we are handling. */
reductions *reds = s->reductions;
int k;
xml_puts (out, level, "<lookaheads>");
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
- {
- xml_printf (out, level + 1, "<symbol>%s</symbol>",
- xml_escape (symbols[k]->tag));
- }
+ {
+ xml_printf (out, level + 1, "<symbol>%s</symbol>",
+ xml_escape (symbols[k]->tag));
+ }
xml_puts (out, level, "</lookaheads>");
}
}
state_hash_new (void)
{
state_table = hash_initialize (HT_INITIAL_CAPACITY,
- NULL,
- state_hasher,
- state_comparator,
- NULL);
+ NULL,
+ state_hasher,
+ state_comparator,
+ NULL);
}
/* Iterate over each transition over a token (shifts). */
-#define FOR_EACH_SHIFT(Transitions, Iter) \
- for (Iter = 0; \
- Iter < Transitions->num \
- && (TRANSITION_IS_DISABLED (Transitions, Iter) \
- || TRANSITION_IS_SHIFT (Transitions, Iter)); \
- ++Iter) \
+#define FOR_EACH_SHIFT(Transitions, Iter) \
+ for (Iter = 0; \
+ Iter < Transitions->num \
+ && (TRANSITION_IS_DISABLED (Transitions, Iter) \
+ || TRANSITION_IS_SHIFT (Transitions, Iter)); \
+ ++Iter) \
if (!TRANSITION_IS_DISABLED (Transitions, Iter))
/* Create a new state with ACCESSING_SYMBOL for those items. */
state *state_new (symbol_number accessing_symbol,
- size_t core_size, item_number *core);
+ size_t core_size, item_number *core);
state *state_new_isocore (state const *s);
/* Set the transitions of STATE. */
reduce R. */
void state_rule_lookahead_tokens_print (state *s, rule *r, FILE *out);
void state_rule_lookahead_tokens_print_xml (state *s, rule *r,
- FILE *out, int level);
+ FILE *out, int level);
/* Create/destroy the states hash table. */
void state_hash_new (void);
#include "complain.h"
#include "symlist.h"
-
/*--------------------------------------.
| Create a list containing SYM at LOC. |
`--------------------------------------*/
symbol_list *res = xmalloc (sizeof *res);
res->content_type = SYMLIST_TYPE;
- res->content.type_name = type_name;
- res->location = res->sym_loc = loc;
- res->named_ref = NULL;
- res->next = NULL;
-
- return res;
-}
-
-
-/*----------------------------------------.
-| Create a list containing a <*> at LOC. |
-`----------------------------------------*/
+ res->content.sem_type = xmalloc (sizeof (semantic_type));
+ res->content.sem_type->tag = type_name;
+ res->content.sem_type->location = loc;
+ res->content.sem_type->status = undeclared;
-symbol_list *
-symbol_list_default_tagged_new (location loc)
-{
- symbol_list *res = xmalloc (sizeof *res);
-
- res->content_type = SYMLIST_DEFAULT_TAGGED;
- res->location = res->sym_loc = loc;
- res->named_ref = NULL;
- res->next = NULL;
-
- return res;
-}
-
-
-/*---------------------------------------.
-| Create a list containing a <> at LOC. |
-`---------------------------------------*/
-
-symbol_list *
-symbol_list_default_tagless_new (location loc)
-{
- symbol_list *res = xmalloc (sizeof *res);
-
- res->content_type = SYMLIST_DEFAULT_TAGLESS;
res->location = res->sym_loc = loc;
res->named_ref = NULL;
res->next = NULL;
symbol_print (l->content.sym, f);
fprintf (stderr, l->action_props.is_value_used ? " used" : " unused");
if (l && l->content.sym)
- fprintf (f, ", ");
+ fprintf (f, ", ");
}
}
l = l->next;
if (l == NULL
|| (l->content_type == SYMLIST_SYMBOL && l->content.sym == NULL))
- return NULL;
+ return NULL;
}
return l;
l = symbol_list_n_get (l, n);
if (!l)
{
- complain_at (loc, _("invalid $ value: $%d"), n);
+ complain (&loc, complaint, _("invalid $ value: $%d"), n);
return NULL;
}
aver (l->content_type == SYMLIST_SYMBOL);
}
void
-symbol_list_destructor_set (symbol_list *node, code_props const *destructor)
-{
- switch (node->content_type)
- {
- case SYMLIST_SYMBOL:
- symbol_destructor_set (node->content.sym, destructor);
- break;
- case SYMLIST_TYPE:
- semantic_type_destructor_set (
- semantic_type_get (node->content.type_name), destructor);
- break;
- case SYMLIST_DEFAULT_TAGGED:
- default_tagged_destructor_set (destructor);
- break;
- case SYMLIST_DEFAULT_TAGLESS:
- default_tagless_destructor_set (destructor);
- break;
- }
-}
-
-void
-symbol_list_printer_set (symbol_list *node, code_props const *printer)
+symbol_list_code_props_set (symbol_list *node, code_props_type kind,
+ code_props const *cprops)
{
switch (node->content_type)
{
- case SYMLIST_SYMBOL:
- symbol_printer_set (node->content.sym, printer);
- break;
- case SYMLIST_TYPE:
- semantic_type_printer_set (
- semantic_type_get (node->content.type_name), printer);
- break;
- case SYMLIST_DEFAULT_TAGGED:
- default_tagged_printer_set (printer);
- break;
- case SYMLIST_DEFAULT_TAGLESS:
- default_tagless_printer_set (printer);
- break;
+ case SYMLIST_SYMBOL:
+ symbol_code_props_set (node->content.sym, kind, cprops);
+ if (node->content.sym->status == undeclared)
+ node->content.sym->status = used;
+ break;
+ case SYMLIST_TYPE:
+ semantic_type_code_props_set
+ (semantic_type_get (node->content.sem_type->tag,
+ &node->content.sem_type->location),
+ kind, cprops);
+ if (node->content.sem_type->status == undeclared)
+ node->content.sem_type->status = used;
+ break;
}
}
* \c <>.
*/
enum {
- SYMLIST_SYMBOL, SYMLIST_TYPE,
- SYMLIST_DEFAULT_TAGGED, SYMLIST_DEFAULT_TAGLESS
+ SYMLIST_SYMBOL,
+ SYMLIST_TYPE
} content_type;
union {
/**
/**
* The semantic type iff <tt>symbol_list::content_type = SYMLIST_TYPE</tt>.
*/
- uniqstr type_name;
+ semantic_type *sem_type;
} content;
location location;
/** Create a list containing \c type_name at \c loc. */
symbol_list *symbol_list_type_new (uniqstr type_name, location loc);
-/** Create a list containing a \c <*> at \c loc. */
-symbol_list *symbol_list_default_tagged_new (location loc);
-/** Create a list containing a \c <> at \c loc. */
-symbol_list *symbol_list_default_tagless_new (location loc);
-
/** Print this list.
\pre For every node \c n in the list, <tt>n->content_type =
/* Check whether the node is a border element of a rule. */
bool symbol_list_null (symbol_list *node);
-/** Set the \c \%destructor for \c node as \c code at \c loc. */
-void symbol_list_destructor_set (symbol_list *node,
- code_props const *destructor);
-
-/** Set the \c \%printer for \c node as \c code at \c loc. */
-void symbol_list_printer_set (symbol_list *node,
- code_props const *printer);
+/** Set the \c \%destructor or \c \%printer for \c node as \c cprops. */
+void symbol_list_code_props_set (symbol_list *node, code_props_type kind,
+ code_props const *cprops);
#endif /* !SYMLIST_H_ */
`-------------------------------------------------------------------*/
static symbol **symbols_sorted = NULL;
+static symbol **semantic_types_sorted = NULL;
/*------------------------.
| Distinguished symbols. |
symbol *startsymbol = NULL;
location startsymbol_location;
-/*---------------------------------------.
-| Default %destructor's and %printer's. |
-`---------------------------------------*/
-
-static code_props default_tagged_destructor = CODE_PROPS_NONE_INIT;
-static code_props default_tagless_destructor = CODE_PROPS_NONE_INIT;
-static code_props default_tagged_printer = CODE_PROPS_NONE_INIT;
-static code_props default_tagless_printer = CODE_PROPS_NONE_INIT;
/*---------------------------------.
| Create a new symbol, named TAG. |
/* If the tag is not a string (starts with a double quote), check
that it is valid for Yacc. */
- if (tag[0] != '\"' && tag[0] != '\'' && mbschr (tag, '-'))
- yacc_at (loc, _("POSIX Yacc forbids dashes in symbol names: %s"),
- tag);
+ if (tag[0] != '\"' && tag[0] != '\'' && strchr (tag, '-'))
+ complain (&loc, Wyacc,
+ _("POSIX Yacc forbids dashes in symbol names: %s"), tag);
res->tag = tag;
res->location = loc;
res->type_name = NULL;
- code_props_none_init (&res->destructor);
- code_props_none_init (&res->printer);
+ for (int i = 0; i < CODE_PROPS_SIZE; ++i)
+ code_props_none_init (&res->props[i]);
res->number = NUMBER_UNDEFINED;
res->prec = 0;
res->alias = NULL;
res->class = unknown_sym;
- res->declared = false;
+ res->status = undeclared;
if (nsyms == SYMBOL_NUMBER_MAXIMUM)
- fatal (_("too many symbols in input grammar (limit is %d)"),
- SYMBOL_NUMBER_MAXIMUM);
+ complain (NULL, fatal, _("too many symbols in input grammar (limit is %d)"),
+ SYMBOL_NUMBER_MAXIMUM);
nsyms++;
return res;
}
+char const *
+code_props_type_string (code_props_type kind)
+{
+ switch (kind)
+ {
+ case destructor:
+ return "%destructor";
+ case printer:
+ return "%printer";
+ }
+ assert (0);
+}
+
/*----------------------------------------.
| Create a new semantic type, named TAG. |
`----------------------------------------*/
static semantic_type *
-semantic_type_new (uniqstr tag)
+semantic_type_new (uniqstr tag, const location *loc)
{
semantic_type *res = xmalloc (sizeof *res);
uniqstr_assert (tag);
res->tag = tag;
- code_props_none_init (&res->destructor);
- code_props_none_init (&res->printer);
+ if (loc)
+ res->location = *loc;
+ for (int i = 0; i < CODE_PROPS_SIZE; ++i)
+ code_props_none_init (&res->props[i]);
return res;
}
| Print a symbol. |
`-----------------*/
-#define SYMBOL_ATTR_PRINT(Attr) \
- if (s->Attr) \
+#define SYMBOL_ATTR_PRINT(Attr) \
+ if (s->Attr) \
fprintf (f, " %s { %s }", #Attr, s->Attr)
-#define SYMBOL_CODE_PRINT(Attr) \
- if (s->Attr.code) \
- fprintf (f, " %s { %s }", #Attr, s->Attr.code)
+#define SYMBOL_CODE_PRINT(Attr) \
+ if (s->props[Attr].code) \
+ fprintf (f, " %s { %s }", #Attr, s->props[Attr].code)
void
-symbol_print (symbol *s, FILE *f)
+symbol_print (symbol const *s, FILE *f)
{
if (s)
{
#undef SYMBOL_ATTR_PRINT
#undef SYMBOL_CODE_PRINT
+
+/*----------------------------------.
+| Whether S is a valid identifier. |
+`----------------------------------*/
+
+static bool
+is_identifier (uniqstr s)
+{
+ static char const alphanum[26 + 26 + 1 + 10] =
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "_"
+ "0123456789";
+ if (!s || ! memchr (alphanum, *s, sizeof alphanum - 10))
+ return false;
+ for (++s; *s; ++s)
+ if (! memchr (alphanum, *s, sizeof alphanum))
+ return false;
+ return true;
+}
+
+
+/*-----------------------------------------------.
+| Get the identifier associated to this symbol. |
+`-----------------------------------------------*/
+uniqstr
+symbol_id_get (symbol const *sym)
+{
+ aver (sym->user_token_number != USER_NUMBER_HAS_STRING_ALIAS);
+ if (sym->alias)
+ sym = sym->alias;
+ return is_identifier (sym->tag) ? sym->tag : 0;
+}
+
+
/*------------------------------------------------------------------.
| Complain that S's WHAT is redeclared at SECOND, and was first set |
| at FIRST. |
location second)
{
unsigned i = 0;
- complain_at_indent (second, &i, _("%s redeclaration for %s"), what, s->tag);
+ complain_indent (&second, complaint, &i,
+ _("%s redeclaration for %s"), what, s->tag);
i += SUB_INDENT;
- complain_at_indent (first, &i, _("previous declaration"));
+ complain_indent (&first, complaint, &i,
+ _("previous declaration"));
}
static void
location second)
{
unsigned i = 0;
- complain_at_indent (second, &i, _("%s redeclaration for <%s>"), what, s->tag);
+ complain_indent (&second, complaint, &i,
+ _("%s redeclaration for <%s>"), what, s->tag);
i += SUB_INDENT;
- complain_at_indent (first, &i, _("previous declaration"));
+ complain_indent (&first, complaint, &i,
+ _("previous declaration"));
}
if (type_name)
{
if (sym->type_name)
- symbol_redeclaration (sym, "%type", sym->type_location, loc);
+ symbol_redeclaration (sym, "%type", sym->type_location, loc);
uniqstr_assert (type_name);
sym->type_name = type_name;
sym->type_location = loc;
}
}
-/*-----------------------------------------.
-| Set the DESTRUCTOR associated with SYM. |
-`-----------------------------------------*/
+/*--------------------------------------------------------.
+| Set the DESTRUCTOR or PRINTER associated with the SYM. |
+`--------------------------------------------------------*/
void
-symbol_destructor_set (symbol *sym, code_props const *destructor)
+symbol_code_props_set (symbol *sym, code_props_type kind,
+ code_props const *code)
{
- if (sym->destructor.code)
- symbol_redeclaration (sym, "%destructor", sym->destructor.location,
- destructor->location);
- sym->destructor = *destructor;
+ if (sym->props[kind].code)
+ symbol_redeclaration (sym, code_props_type_string (kind),
+ sym->props[kind].location,
+ code->location);
+ sym->props[kind] = *code;
}
-/*------------------------------------------.
-| Set the DESTRUCTOR associated with TYPE. |
-`------------------------------------------*/
+/*-----------------------------------------------------.
+| Set the DESTRUCTOR or PRINTER associated with TYPE. |
+`-----------------------------------------------------*/
void
-semantic_type_destructor_set (semantic_type *type,
- code_props const *destructor)
+semantic_type_code_props_set (semantic_type *type,
+ code_props_type kind,
+ code_props const *code)
{
- if (type->destructor.code)
- semantic_type_redeclaration (type, "%destructor",
- type->destructor.location,
- destructor->location);
- type->destructor = *destructor;
+ if (type->props[kind].code)
+ semantic_type_redeclaration (type, code_props_type_string (kind),
+ type->props[kind].location,
+ code->location);
+ type->props[kind] = *code;
}
-/*---------------------------------------.
-| Get the computed %destructor for SYM. |
-`---------------------------------------*/
+/*---------------------------------------------------.
+| Get the computed %destructor or %printer for SYM. |
+`---------------------------------------------------*/
-code_props const *
-symbol_destructor_get (symbol const *sym)
+code_props *
+symbol_code_props_get (symbol *sym, code_props_type kind)
{
- /* Per-symbol %destructor. */
- if (sym->destructor.code)
- return &sym->destructor;
+ /* Per-symbol code props. */
+ if (sym->props[kind].code)
+ return &sym->props[kind];
- /* Per-type %destructor. */
+ /* Per-type code props. */
if (sym->type_name)
{
- code_props const *destructor =
- &semantic_type_get (sym->type_name)->destructor;
- if (destructor->code)
- return destructor;
+ code_props *code =
+ &semantic_type_get (sym->type_name, NULL)->props[kind];
+ if (code->code)
+ return code;
}
- /* Apply default %destructor's only to user-defined symbols. */
- if (sym->tag[0] == '$' || sym == errtoken)
- return &code_props_none;
-
- if (sym->type_name)
- return &default_tagged_destructor;
- return &default_tagless_destructor;
-}
-
-/*--------------------------------------.
-| Set the PRINTER associated with SYM. |
-`--------------------------------------*/
-
-void
-symbol_printer_set (symbol *sym, code_props const *printer)
-{
- if (sym->printer.code)
- symbol_redeclaration (sym, "%printer",
- sym->printer.location, printer->location);
- sym->printer = *printer;
-}
-
-/*---------------------------------------.
-| Set the PRINTER associated with TYPE. |
-`---------------------------------------*/
-
-void
-semantic_type_printer_set (semantic_type *type, code_props const *printer)
-{
- if (type->printer.code)
- semantic_type_redeclaration (type, "%printer",
- type->printer.location, printer->location);
- type->printer = *printer;
-}
-
-/*------------------------------------.
-| Get the computed %printer for SYM. |
-`------------------------------------*/
-
-code_props const *
-symbol_printer_get (symbol const *sym)
-{
- /* Per-symbol %printer. */
- if (sym->printer.code)
- return &sym->printer;
-
- /* Per-type %printer. */
- if (sym->type_name)
+ /* Apply default code props's only to user-defined symbols. */
+ if (sym->tag[0] != '$' && sym != errtoken)
{
- code_props const *printer = &semantic_type_get (sym->type_name)->printer;
- if (printer->code)
- return printer;
+ code_props *code =
+ &semantic_type_get (sym->type_name ? "*" : "", NULL)->props[kind];
+ if (code->code)
+ return code;
}
-
- /* Apply the default %printer only to user-defined symbols. */
- if (sym->tag[0] == '$' || sym == errtoken)
- return &code_props_none;
-
- if (sym->type_name)
- return &default_tagged_printer;
- return &default_tagless_printer;
+ return &code_props_none;
}
/*-----------------------------------------------------------------.
if (a != undef_assoc)
{
if (sym->prec != 0)
- symbol_redeclaration (sym, assoc_to_string (a), sym->prec_location,
+ symbol_redeclaration (sym, assoc_to_string (a), sym->prec_location,
loc);
sym->prec = prec;
sym->assoc = a;
void
symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
{
+ bool warned = false;
if (sym->class != unknown_sym && sym->class != class)
{
- complain_at (loc, _("symbol %s redefined"), sym->tag);
- sym->declared = false;
+ complain (&loc, complaint, _("symbol %s redefined"), sym->tag);
+ // Don't report both "redefined" and "redeclared".
+ warned = true;
}
if (class == nterm_sym && sym->class != nterm_sym)
if (declaring)
{
- if (sym->declared)
- warn_at (loc, _("symbol %s redeclared"), sym->tag);
- sym->declared = true;
+ if (sym->status == declared && !warned)
+ complain (&loc, Wother, _("symbol %s redeclared"), sym->tag);
+ sym->status = declared;
}
}
user_token_numberp = &sym->alias->user_token_number;
if (*user_token_numberp != USER_NUMBER_UNDEFINED
&& *user_token_numberp != user_token_number)
- complain_at (loc, _("redefining user token number of %s"), sym->tag);
+ complain (&loc, complaint, _("redefining user token number of %s"),
+ sym->tag);
*user_token_numberp = user_token_number;
/* User defined $end token? */
{
endtoken = sym;
/* It is always mapped to 0, so it was already counted in
- NTOKENS. */
+ NTOKENS. */
if (endtoken->number != NUMBER_UNDEFINED)
--ntokens;
endtoken->number = 0;
{
if (sym->class == unknown_sym)
{
- complain_at
- (sym->location,
- _("symbol %s is used, but is not defined as a token and has no rules"),
- sym->tag);
+ assert (sym->status != declared);
+ complain (&sym->location,
+ sym->status == needed ? complaint : Wother,
+ _("symbol %s is used, but is not defined as a token"
+ " and has no rules"),
+ sym->tag);
sym->class = nterm_sym;
sym->number = nvars++;
}
+ for (int i = 0; i < 2; ++i)
+ symbol_code_props_get (sym, i)->is_used = true;
+
+ /* Set the semantic type status associated to the current symbol to
+ 'declared' so that we could check semantic types unnecessary uses. */
+ if (sym->type_name)
+ {
+ semantic_type *sem_type = semantic_type_get (sym->type_name, NULL);
+ if (sem_type)
+ sem_type->status = declared;
+ }
+
+ return true;
+}
+
+static inline bool
+semantic_type_check_defined (semantic_type *sem_type)
+{
+ // <*> and <> do not have to be "declared".
+ if (sem_type->status == declared
+ || !*sem_type->tag
+ || STREQ(sem_type->tag, "*"))
+ {
+ for (int i = 0; i < 2; ++i)
+ if (sem_type->props[i].kind != CODE_PROPS_NONE
+ && ! sem_type->props[i].is_used)
+ complain (&sem_type->location, Wother,
+ _("useless %s for type <%s>"),
+ code_props_type_string (i), sem_type->tag);
+ }
+ else
+ complain (&sem_type->location, Wother,
+ _("type <%s> is used, but is not associated to any symbol"),
+ sem_type->tag);
+
return true;
}
return symbol_check_defined (sym);
}
+static bool
+semantic_type_check_defined_processor (void *sem_type,
+ void *null ATTRIBUTE_UNUSED)
+{
+ return semantic_type_check_defined (sem_type);
+}
+
void
symbol_make_alias (symbol *sym, symbol *str, location loc)
{
if (str->alias)
- warn_at (loc, _("symbol %s used more than once as a literal string"),
- str->tag);
+ complain (&loc, Wother,
+ _("symbol %s used more than once as a literal string"), str->tag);
else if (sym->alias)
- warn_at (loc, _("symbol %s given more than one literal string"),
- sym->tag);
+ complain (&loc, Wother,
+ _("symbol %s given more than one literal string"), sym->tag);
else
{
str->class = token_sym;
if (str->type_name != sym->type_name)
{
if (str->type_name)
- symbol_type_set (sym, str->type_name, str->type_location);
+ symbol_type_set (sym, str->type_name, str->type_location);
else
- symbol_type_set (str, sym->type_name, sym->type_location);
+ symbol_type_set (str, sym->type_name, sym->type_location);
}
- if (str->destructor.code || sym->destructor.code)
- {
- if (str->destructor.code)
- symbol_destructor_set (sym, &str->destructor);
- else
- symbol_destructor_set (str, &sym->destructor);
- }
-
- if (str->printer.code || sym->printer.code)
- {
- if (str->printer.code)
- symbol_printer_set (sym, &str->printer);
- else
- symbol_printer_set (str, &sym->printer);
- }
+ for (int i = 0; i < CODE_PROPS_SIZE; ++i)
+ if (str->props[i].code)
+ symbol_code_props_set (sym, i, &str->props[i]);
+ else if (sym->props[i].code)
+ symbol_code_props_set (str, i, &sym->props[i]);
if (sym->prec || str->prec)
{
if (str->prec)
- symbol_precedence_set (sym, str->prec, str->assoc,
- str->prec_location);
+ symbol_precedence_set (sym, str->prec, str->assoc,
+ str->prec_location);
else
- symbol_precedence_set (str, sym->prec, sym->assoc,
- sym->prec_location);
+ symbol_precedence_set (str, sym->prec, sym->assoc,
+ sym->prec_location);
}
}
static bool
symbol_check_alias_consistency_processor (void *this,
- void *null ATTRIBUTE_UNUSED)
+ void *null ATTRIBUTE_UNUSED)
{
symbol_check_alias_consistency (this);
return true;
first = second;
second = tmp;
}
- complain_at_indent (second->location, &i,
- _("user token number %d redeclaration for %s"),
- num, second->tag);
+ complain_indent (&second->location, complaint, &i,
+ _("user token number %d redeclaration for %s"),
+ num, second->tag);
i += SUB_INDENT;
- complain_at_indent (first->location, &i,
- _("previous declaration for %s"),
- first->tag);
+ complain_indent (&first->location, complaint, &i,
+ _("previous declaration for %s"),
+ first->tag);
}
/*--------------------------------------------------.
{
/* A token which translation has already been set? */
if (token_translations[this->user_token_number] != undeftoken->number)
- user_token_number_redeclaration
+ user_token_number_redeclaration
(this->user_token_number,
symbols[token_translations[this->user_token_number]],
this);
symbols_new (void)
{
symbol_table = hash_initialize (HT_INITIAL_CAPACITY,
- NULL,
- hash_symbol_hasher,
- hash_symbol_comparator,
- free);
+ NULL,
+ hash_symbol_hasher,
+ hash_symbol_comparator,
+ free);
semantic_type_table = hash_initialize (HT_INITIAL_CAPACITY,
- NULL,
- hash_semantic_type_hasher,
- hash_semantic_type_comparator,
- free);
+ NULL,
+ hash_semantic_type_hasher,
+ hash_semantic_type_comparator,
+ free);
}
`-----------------------------------------------------------------------*/
semantic_type *
-semantic_type_from_uniqstr (const uniqstr key)
+semantic_type_from_uniqstr (const uniqstr key, const location *loc)
{
semantic_type probe;
semantic_type *entry;
if (!entry)
{
/* First insertion in the hash. */
- entry = semantic_type_new (key);
+ entry = semantic_type_new (key, loc);
if (!hash_insert (semantic_type_table, entry))
xalloc_die ();
}
`-----------------------------------------------------------------------*/
semantic_type *
-semantic_type_get (const char *key)
+semantic_type_get (const char *key, const location *loc)
{
- return semantic_type_from_uniqstr (uniqstr_new (key));
+ return semantic_type_from_uniqstr (uniqstr_new (key), loc);
}
}
static void
-symbols_do (Hash_processor processor, void *processor_data)
+symbols_do (Hash_processor processor, void *processor_data,
+ struct hash_table *table, symbol **sorted)
{
- size_t count = hash_get_n_entries (symbol_table);
- if (!symbols_sorted)
+ size_t count = hash_get_n_entries (table);
+ if (!sorted)
{
- symbols_sorted = xnmalloc (count, sizeof *symbols_sorted);
- hash_get_entries (symbol_table, (void**)symbols_sorted, count);
- qsort (symbols_sorted, count, sizeof *symbols_sorted,
- symbols_cmp_qsort);
+ sorted = xnmalloc (count, sizeof *sorted);
+ hash_get_entries (table, (void**)sorted, count);
+ qsort (sorted, count, sizeof *sorted, symbols_cmp_qsort);
}
{
size_t i;
for (i = 0; i < count; ++i)
- processor (symbols_sorted[i], processor_data);
+ processor (sorted[i], processor_data);
}
}
void
symbols_check_defined (void)
{
- symbols_do (symbol_check_defined_processor, NULL);
+ symbols_do (symbol_check_defined_processor, NULL,
+ symbol_table, symbols_sorted);
+ symbols_do (semantic_type_check_defined_processor, NULL,
+ semantic_type_table, semantic_types_sorted);
}
/*------------------------------------------------------------------.
{
symbol *this = symbols[i];
if (this->user_token_number != USER_NUMBER_UNDEFINED)
- {
- if (this->user_token_number > max_user_token_number)
- max_user_token_number = this->user_token_number;
- if (this->user_token_number == 256)
- num_256_available_p = false;
- }
+ {
+ if (this->user_token_number > max_user_token_number)
+ max_user_token_number = this->user_token_number;
+ if (this->user_token_number == 256)
+ num_256_available_p = false;
+ }
}
/* If 256 is not used, assign it to error, to follow POSIX. */
{
symbol *this = symbols[i];
if (this->user_token_number == USER_NUMBER_UNDEFINED)
- this->user_token_number = ++max_user_token_number;
+ this->user_token_number = ++max_user_token_number;
if (this->user_token_number > max_user_token_number)
- max_user_token_number = this->user_token_number;
+ max_user_token_number = this->user_token_number;
}
token_translations = xnmalloc (max_user_token_number + 1,
- sizeof *token_translations);
+ sizeof *token_translations);
- /* Initialize all entries for literal tokens to 2, the internal
- token number for $undefined, which represents all invalid inputs.
- */
+ /* Initialize all entries for literal tokens to the internal token
+ number for $undefined, which represents all invalid inputs. */
for (i = 0; i < max_user_token_number + 1; i++)
token_translations[i] = undeftoken->number;
- symbols_do (symbol_translation_processor, NULL);
+ symbols_do (symbol_translation_processor, NULL,
+ symbol_table, symbols_sorted);
}
void
symbols_pack (void)
{
- symbols_do (symbol_check_alias_consistency_processor, NULL);
+ symbols_do (symbol_check_alias_consistency_processor, NULL,
+ symbol_table, symbols_sorted);
symbols = xcalloc (nsyms, sizeof *symbols);
- symbols_do (symbol_pack_processor, NULL);
+ symbols_do (symbol_pack_processor, NULL, symbol_table, symbols_sorted);
/* Aliases leave empty slots in symbols, so remove them. */
{
symbols_token_translations_init ();
if (startsymbol->class == unknown_sym)
- fatal_at (startsymbol_location,
- _("the start symbol %s is undefined"),
- startsymbol->tag);
+ complain (&startsymbol_location, fatal,
+ _("the start symbol %s is undefined"),
+ startsymbol->tag);
else if (startsymbol->class == token_sym)
- fatal_at (startsymbol_location,
- _("the start symbol %s is a token"),
- startsymbol->tag);
-}
-
-
-/*--------------------------------------------------.
-| Set default tagged/tagless %destructor/%printer. |
-`--------------------------------------------------*/
-
-void
-default_tagged_destructor_set (code_props const *destructor)
-{
- if (default_tagged_destructor.code)
- {
- unsigned i = 0;
- complain_at_indent (destructor->location, &i,
- _("redeclaration for default tagged %%destructor"));
- i += SUB_INDENT;
- complain_at_indent (default_tagged_destructor.location, &i,
- _("previous declaration"));
- }
- default_tagged_destructor = *destructor;
-}
-
-void
-default_tagless_destructor_set (code_props const *destructor)
-{
- if (default_tagless_destructor.code)
- {
- unsigned i = 0;
- complain_at_indent (destructor->location, &i,
- _("redeclaration for default tagless %%destructor"));
- i += SUB_INDENT;
- complain_at_indent (default_tagless_destructor.location, &i,
- _("previous declaration"));
- }
- default_tagless_destructor = *destructor;
-}
-
-void
-default_tagged_printer_set (code_props const *printer)
-{
- if (default_tagged_printer.code)
- {
- unsigned i = 0;
- complain_at_indent (printer->location, &i,
- _("redeclaration for default tagged %%printer"));
- i += SUB_INDENT;
- complain_at_indent (default_tagged_printer.location, &i,
- _("previous declaration"));
- }
- default_tagged_printer = *printer;
-}
-
-void
-default_tagless_printer_set (code_props const *printer)
-{
- if (default_tagless_printer.code)
- {
- unsigned i = 0;
- complain_at_indent (printer->location, &i,
- _("redeclaration for default tagless %%printer"));
- i += SUB_INDENT;
- complain_at_indent (default_tagless_printer.location, &i,
- _("previous declaration"));
- }
- default_tagless_printer = *printer;
+ complain (&startsymbol_location, fatal,
+ _("the start symbol %s is a token"),
+ startsymbol->tag);
}
/* Definitions for symtab.c and callers, part of Bison.
- Copyright (C) 1984, 1989, 1992, 2000-2002, 2004-2007, 2009-2012 Free
- Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1992, 2000-2002, 2004-2012 Free Software
+ Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
typedef enum
{
unknown_sym, /**< Undefined. */
- token_sym, /**< Terminal. */
- nterm_sym /**< Non-terminal. */
+ token_sym, /**< Terminal. */
+ nterm_sym /**< Non-terminal. */
} symbol_class;
typedef struct symbol symbol;
+/* Declaration status of a symbol.
+
+ First, it is "undeclared". Then, if "undeclared" and used in a
+ %printer/%destructor, it is "used". If not "declared" but used in
+ a rule, it is "needed". Finally, if declared (via a rule for
+ nonterminals, or %token), it is "declared".
+
+ When status are checked at the end, "declared" symbols are fine,
+ "used" symbols trigger warnings, otherwise it's an error. */
+
+typedef enum
+ {
+ /** Used in the input file for an unknown reason (error). */
+ undeclared,
+ /** Used by %destructor/%printer but not defined (warning). */
+ used,
+ /** Used in the gramar (rules) but not defined (error). */
+ needed,
+ /** Defined with %type or %token (good). */
+ declared,
+ } status;
+
+typedef enum code_props_type code_props_type;
+enum code_props_type
+ {
+ destructor = 0,
+ printer = 1,
+ };
+
+enum { CODE_PROPS_SIZE = 2 };
+
/* When extending this structure, be sure to complete
symbol_check_alias_consistency. */
struct symbol
/** Its \c \%type's location. */
location type_location;
- /** Any \c \%destructor declared specifically for this symbol.
-
- Access this field only through <tt>symbol</tt>'s interface
- functions. For example, if <tt>symbol::destructor = NULL</tt>, a
- default \c \%destructor or a per-type \c \%destructor might be
- appropriate, and \c symbol_destructor_get will compute the
- correct one. */
- code_props destructor;
-
- /** Any \c \%printer declared specifically for this symbol.
+ /** Any \c \%destructor (resp. \%printer) declared specificially for this
+ symbol.
- Access this field only through <tt>symbol</tt>'s interface functions.
- \sa symbol::destructor */
- code_props printer;
+ Access this field only through <tt>symbol</tt>'s interface functions. For
+ example, if <tt>symbol::destructor = NULL</tt> (resp. <tt>symbol::printer
+ = NULL</tt>), a default \c \%destructor (resp. \%printer) or a per-type
+ \c symbol_destructor_printer_get will compute the correct one. */
+ code_props props[CODE_PROPS_SIZE];
symbol_number number;
location prec_location;
symbol-string pair for an alias. */
symbol *alias;
symbol_class class;
- bool declared;
+ status status;
};
/** Undefined user number. */
/* Undefined internal token number. */
#define NUMBER_UNDEFINED (-1)
-/** Print a symbol (for debugging). */
-void symbol_print (symbol *s, FILE *f);
-
/** Fetch (or create) the symbol associated to KEY. */
symbol *symbol_from_uniqstr (const uniqstr key, location loc);
Its name cannot conflict with the user's names. */
symbol *dummy_symbol_get (location loc);
+
+/*--------------------.
+| Methods on symbol. |
+`--------------------*/
+
+/** Print a symbol (for debugging). */
+void symbol_print (symbol const *s, FILE *f);
+
/** Is this a dummy nonterminal? */
bool symbol_is_dummy (const symbol *sym);
+/** The name of the code_props type: "\%destructor" or "\%printer". */
+char const *code_props_type_string (code_props_type kind);
+
+/** The name of the symbol that can be used as an identifier.
+ ** Consider the alias if needed.
+ ** Return 0 if there is none (e.g., the symbol is only defined as
+ ** a string). */
+uniqstr symbol_id_get (symbol const *sym);
+
/**
* Make \c str the literal string alias of \c sym. Copy token number,
* symbol number, and type from \c sym to \c str.
Do nothing if passed 0 as \c type_name. */
void symbol_type_set (symbol *sym, uniqstr type_name, location loc);
-/** Set the \c destructor associated with \c sym. */
-void symbol_destructor_set (symbol *sym, code_props const *destructor);
-
-/** Get the computed \c \%destructor for \c sym, which was initialized with
- \c code_props_none_init if there's no \c \%destructor. */
-code_props const *symbol_destructor_get (symbol const *sym);
+/** Set the \c \%destructor or \c \%printer associated with \c sym. */
+void symbol_code_props_set (symbol *sym, code_props_type kind,
+ code_props const *destructor);
-/** Set the \c printer associated with \c sym. */
-void symbol_printer_set (symbol *sym, code_props const *printer);
+/** Get the computed \c \%destructor or \c %printer for \c sym, which was
+ initialized with \c code_props_none_init if there's no \c \%destructor or
+ \c %printer. */
+code_props *symbol_code_props_get (symbol *sym, code_props_type kind);
-/** Get the computed \c \%printer for \c sym, which was initialized with
- \c code_props_none_init if there's no \c \%printer. */
-code_props const *symbol_printer_get (symbol const *sym);
+/** Set the \c precedence associated with \c sym.
-/* Set the \c precedence associated with \c sym.
-
- Ensure that \a symbol is a terminal.
- Do nothing if invoked with \c undef_assoc as \c assoc. */
+ Ensure that \a symbol is a terminal.
+ Do nothing if invoked with \c undef_assoc as \c assoc. */
void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc);
/** Set the \c class associated with \c sym. */
void symbol_class_set (symbol *sym, symbol_class class, location loc,
- bool declaring);
+ bool declaring);
/** Set the \c user_token_number associated with \c sym. */
void symbol_user_token_number_set (symbol *sym, int user_number, location loc);
+
+/*------------------.
+| Special symbols. |
+`------------------*/
+
/** The error token. */
extern symbol *errtoken;
/** The token for unknown tokens. */
/** The key, name of the semantic type. */
uniqstr tag;
- /** Any \c %destructor declared for this semantic type. */
- code_props destructor;
- /** Any \c %printer declared for this semantic type. */
- code_props printer;
+ /** The location of its first occurence. */
+ location location;
+
+ /** Its status : "undeclared", "used" or "declared".
+ It cannot be "needed". */
+ status status;
+
+ /** Any \c %destructor and %printer declared for this
+ semantic type. */
+ code_props props[CODE_PROPS_SIZE];
+
} semantic_type;
/** Fetch (or create) the semantic type associated to KEY. */
-semantic_type *semantic_type_from_uniqstr (const uniqstr key);
+semantic_type *semantic_type_from_uniqstr (const uniqstr key,
+ const location *loc);
/** Fetch (or create) the semantic type associated to KEY. */
-semantic_type *semantic_type_get (const char *key);
+semantic_type *semantic_type_get (const char *key, const location *loc);
-/** Set the \c destructor associated with \c type. */
-void semantic_type_destructor_set (semantic_type *type,
- code_props const *destructor);
-
-/** Set the \c printer associated with \c type. */
-void semantic_type_printer_set (semantic_type *type,
- code_props const *printer);
+/** Set the \c destructor or \c printer associated with \c type. */
+void semantic_type_code_props_set (semantic_type *type,
+ code_props_type kind,
+ code_props const *code);
/*----------------------------------.
| Symbol and semantic type tables. |
#token_translations. */
void symbols_pack (void);
-
-/*---------------------------------------.
-| Default %destructor's and %printer's. |
-`---------------------------------------*/
-
-/** Set the default \c \%destructor for tagged values. */
-void default_tagged_destructor_set (code_props const *destructor);
-/** Set the default \c \%destructor for tagless values. */
-void default_tagless_destructor_set (code_props const *destructor);
-
-/** Set the default \c \%printer for tagged values. */
-void default_tagged_printer_set (code_props const *printer);
-/** Set the default \c \%printer for tagless values. */
-void default_tagless_printer_set (code_props const *printer);
-
#endif /* !SYMTAB_H_ */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef BISON_SYSTEM_H
-# define BISON_SYSTEM_H
+#define BISON_SYSTEM_H
/* flex 2.5.31 gratutiously defines macros like INT8_MIN. But this
runs afoul of pre-C99 compilers that have <inttypes.h> or
<stdint.h>, which are included below if available. It also runs
afoul of pre-C99 compilers that define these macros in <limits.h>. */
-# if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901
-# undef INT8_MIN
-# undef INT16_MIN
-# undef INT32_MIN
-# undef INT8_MAX
-# undef INT16_MAX
-# undef UINT8_MAX
-# undef INT32_MAX
-# undef UINT16_MAX
-# undef UINT32_MAX
-# endif
+#if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901
+# undef INT8_MIN
+# undef INT16_MIN
+# undef INT32_MIN
+# undef INT8_MAX
+# undef INT16_MAX
+# undef UINT8_MAX
+# undef INT32_MAX
+# undef UINT16_MAX
+# undef UINT32_MAX
+#endif
+
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
+#define STREQ(L, R) (strcmp(L, R) == 0)
+#define STRNEQ(L, R) (!STREQ(L, R))
-# include <limits.h>
-# include <stddef.h>
-# include <stdlib.h>
-# include <string.h>
-# include <unistd.h>
-# include <inttypes.h>
+/* Just like strncmp, but the second argument must be a literal string
+ and you don't specify the length. */
+#define STRNCMP_LIT(S, Literal) \
+ strncmp (S, "" Literal "", sizeof (Literal) - 1)
+
+/* Whether Literal is a prefix of S. */
+#define STRPREFIX_LIT(Literal, S) \
+ (STRNCMP_LIT (S, Literal) == 0)
+
+#include <unistd.h>
+#include <inttypes.h>
#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
#define STREQ(L, R) (strcmp(L, R) == 0)
#define STRNEQ(L, R) (!STREQ(L, R))
-# ifndef UINTPTR_MAX
+#ifndef UINTPTR_MAX
/* This isn't perfect, but it's good enough for Bison, which needs
only to hash pointers. */
typedef size_t uintptr_t;
-# endif
+#endif
// Version mismatch.
-# define EX_MISMATCH 63
+#define EX_MISMATCH 63
/*---------.
| Gnulib. |
`---------*/
-# include <unlocked-io.h>
-# include <verify.h>
-# include <xalloc.h>
+#include <unlocked-io.h>
+#include <verify.h>
+#include <xalloc.h>
/*-----------------.
and safer logic than it would for users. Due to the overhead of M4,
suppressing Code is unlikely to offer any significant improvement in
Bison's performance anyway. */
-# define PACIFY_CC(Code) Code
+#define PACIFY_CC(Code) Code
-# ifndef __attribute__
+#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
-# if (! defined __GNUC__ || __GNUC__ < 2 \
+# if (! defined __GNUC__ || __GNUC__ < 2 \
|| (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
-# define __attribute__(Spec) /* empty */
-# endif
+# define __attribute__(Spec) /* empty */
# endif
+#endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __format__ format
-# define __printf__ printf
-# endif
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+# define __format__ format
+# define __printf__ printf
+#endif
-# ifndef ATTRIBUTE_NORETURN
-# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
-# endif
+#ifndef ATTRIBUTE_NORETURN
+# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#endif
-# ifndef ATTRIBUTE_UNUSED
-# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
-# endif
+#ifndef ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+#endif
/*------.
| NLS. |
`------*/
-# include <locale.h>
+#include <locale.h>
-# include <gettext.h>
-# define _(Msgid) gettext (Msgid)
-# define N_(Msgid) (Msgid)
+#include <gettext.h>
+#define _(Msgid) gettext (Msgid)
+#define N_(Msgid) (Msgid)
/*-----------.
| Booleans. |
`-----------*/
-# include <stdbool.h>
+#include <stdbool.h>
For now, we use assert but we call it aver throughout Bison in case
we later wish to try another scheme.
*/
-# include <assert.h>
-# define aver assert
+#include <assert.h>
+#define aver assert
/*-----------.
| Obstacks. |
`-----------*/
-# define obstack_chunk_alloc xmalloc
-# define obstack_chunk_free free
-# include <obstack.h>
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+#include <obstack.h>
+
+/* String-grow: append Str to Obs. */
-# define obstack_sgrow(Obs, Str) \
+#define obstack_sgrow(Obs, Str) \
obstack_grow (Obs, Str, strlen (Str))
/* Output Str escaped for our postprocessing (i.e., escape M4 special
# define obstack_escape(Obs, Str) \
do { \
- char const *p; \
- for (p = Str; *p; p++) \
- switch (*p) \
+ char const *p__; \
+ for (p__ = Str; *p__; p__++) \
+ switch (*p__) \
{ \
case '$': obstack_sgrow (Obs, "$]["); break; \
case '@': obstack_sgrow (Obs, "@@" ); break; \
case '[': obstack_sgrow (Obs, "@{" ); break; \
case ']': obstack_sgrow (Obs, "@}" ); break; \
- default: obstack_1grow (Obs, *p ); break; \
+ default: obstack_1grow (Obs, *p__ ); break; \
} \
} while (0)
| Extensions to use for the output files. |
`-----------------------------------------*/
-# ifndef OUTPUT_EXT
-# define OUTPUT_EXT ".output"
-# endif
+#ifndef OUTPUT_EXT
+# define OUTPUT_EXT ".output"
+#endif
-# ifndef TAB_EXT
-# define TAB_EXT ".tab"
-# endif
+#ifndef TAB_EXT
+# define TAB_EXT ".tab"
+#endif
| Free a linked list. |
`---------------------*/
-# define LIST_FREE(Type, List) \
- do { \
- Type *_node, *_next; \
- for (_node = List; _node; _node = _next) \
- { \
- _next = _node->next; \
- free (_node); \
- } \
- } while (0)
+#define LIST_FREE(Type, List) \
+do { \
+ Type *_node, *_next; \
+ for (_node = List; _node; _node = _next) \
+ { \
+ _next = _node->next; \
+ free (_node); \
+ } \
+} while (0)
/*---------------------------------------------.
if (trace_flag & trace_resource)
fprintf (stderr, "growing table and check from: %d to %d\n",
- old_size, table_size);
+ old_size, table_size);
table = xnrealloc (table, table_size, sizeof *table);
conflict_table = xnrealloc (conflict_table, table_size,
- sizeof *conflict_table);
+ sizeof *conflict_table);
check = xnrealloc (check, table_size, sizeof *check);
for (/* Nothing. */; old_size < table_size; ++old_size)
/*-------------------------------------------------------------------.
| For GLR parsers, for each conflicted token in S, as indicated |
-| by non-zero entries in CONFLROW, create a list of possible |
-| reductions that are alternatives to the shift or reduction |
+| by non-zero entries in CONFLROW, create a list of possible |
+| reductions that are alternatives to the shift or reduction |
| currently recorded for that token in S. Store the alternative |
-| reductions followed by a 0 in CONFLICT_LIST, updating |
+| reductions followed by a 0 in CONFLICT_LIST, updating |
| CONFLICT_LIST_CNT, and storing an index to the start of the list |
-| back into CONFLROW. |
+| back into CONFLROW. |
`-------------------------------------------------------------------*/
static void
for (j = 0; j < ntokens; j += 1)
if (conflrow[j])
{
- conflrow[j] = conflict_list_cnt;
-
- /* Find all reductions for token J, and record all that do not
- match ACTROW[J]. */
- for (i = 0; i < reds->num; i += 1)
- if (bitset_test (reds->lookahead_tokens[i], j)
- && (actrow[j]
- != rule_number_as_item_number (reds->rules[i]->number)))
- {
- aver (0 < conflict_list_free);
- conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
- conflict_list_cnt += 1;
- conflict_list_free -= 1;
- }
-
- /* Leave a 0 at the end. */
- aver (0 < conflict_list_free);
- conflict_list[conflict_list_cnt] = 0;
- conflict_list_cnt += 1;
- conflict_list_free -= 1;
+ conflrow[j] = conflict_list_cnt;
+
+ /* Find all reductions for token J, and record all that do not
+ match ACTROW[J]. */
+ for (i = 0; i < reds->num; i += 1)
+ if (bitset_test (reds->lookahead_tokens[i], j)
+ && (actrow[j]
+ != rule_number_as_item_number (reds->rules[i]->number)))
+ {
+ aver (0 < conflict_list_free);
+ conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
+ conflict_list_cnt += 1;
+ conflict_list_free -= 1;
+ }
+
+ /* Leave a 0 at the end. */
+ aver (0 < conflict_list_free);
+ conflict_list[conflict_list_cnt] = 0;
+ conflict_list_cnt += 1;
+ conflict_list_free -= 1;
}
}
| default action (yydefact) for the state. In addition, ACTROW is |
| filled with what to do for each kind of token, index by symbol |
| number, with zero meaning do the default action. The value |
-| ACTION_NUMBER_MINIMUM, a very negative number, means this |
-| situation is an error. The parser recognizes this value |
-| specially. |
+| ACTION_NUMBER_MINIMUM, a very negative number, means this |
+| situation is an error. The parser recognizes this value |
+| specially. |
| |
| This is where conflicts are resolved. The loop over lookahead |
| rules considered lower-numbered rules last, and the last rule |
int j;
bitset_iterator biter;
/* loop over all the rules available here which require
- lookahead (in reverse order to give precedence to the first
- rule) */
+ lookahead (in reverse order to give precedence to the first
+ rule) */
for (i = reds->num - 1; i >= 0; --i)
- /* and find each token which the rule finds acceptable
- to come next */
- BITSET_FOR_EACH (biter, reds->lookahead_tokens[i], j, 0)
- {
- /* and record this rule as the rule to use if that
- token follows. */
- if (actrow[j] != 0)
- {
- conflicted = true;
- conflrow[j] = 1;
- }
- actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
- }
+ /* and find each token which the rule finds acceptable
+ to come next */
+ BITSET_FOR_EACH (biter, reds->lookahead_tokens[i], j, 0)
+ {
+ /* and record this rule as the rule to use if that
+ token follows. */
+ if (actrow[j] != 0)
+ {
+ conflicted = true;
+ conflrow[j] = 1;
+ }
+ actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
+ }
}
/* Now see which tokens are allowed for shifts in this state. For
state *shift_state = trans->states[i];
if (actrow[sym] != 0)
- {
- conflicted = true;
- conflrow[sym] = 1;
- }
+ {
+ conflicted = true;
+ conflrow[sym] = 1;
+ }
actrow[sym] = state_number_as_int (shift_state->number);
/* Do not use any default reduction if there is a shift for
- error */
+ error */
if (sym == errtoken->number)
- nodefault = true;
+ nodefault = true;
}
/* See which tokens are an explicit error in this state (due to
labeled as consistent. */
{
char *default_reductions =
- muscle_percent_define_get ("lr.default-reductions");
- if (0 != strcmp (default_reductions, "most") && !s->consistent)
+ muscle_percent_define_get ("lr.default-reduction");
+ if (STRNEQ (default_reductions, "most") && !s->consistent)
nodefault = true;
free (default_reductions);
}
if (reds->num >= 1 && !nodefault)
{
if (s->consistent)
- default_reduction = reds->rules[0];
+ default_reduction = reds->rules[0];
else
- {
- int max = 0;
- for (i = 0; i < reds->num; i++)
- {
- int count = 0;
- rule *r = reds->rules[i];
- symbol_number j;
-
- for (j = 0; j < ntokens; j++)
- if (actrow[j] == rule_number_as_item_number (r->number))
- count++;
-
- if (count > max)
- {
- max = count;
- default_reduction = r;
- }
- }
-
- /* GLR parsers need space for conflict lists, so we can't
- default conflicted entries. For non-conflicted entries
- or as long as we are not building a GLR parser,
- actions that match the default are replaced with zero,
- which means "use the default". */
-
- if (max > 0)
- {
- int j;
- for (j = 0; j < ntokens; j++)
- if (actrow[j]
+ {
+ int max = 0;
+ for (i = 0; i < reds->num; i++)
+ {
+ int count = 0;
+ rule *r = reds->rules[i];
+ symbol_number j;
+
+ for (j = 0; j < ntokens; j++)
+ if (actrow[j] == rule_number_as_item_number (r->number))
+ count++;
+
+ if (count > max)
+ {
+ max = count;
+ default_reduction = r;
+ }
+ }
+
+ /* GLR parsers need space for conflict lists, so we can't
+ default conflicted entries. For non-conflicted entries
+ or as long as we are not building a GLR parser,
+ actions that match the default are replaced with zero,
+ which means "use the default". */
+
+ if (max > 0)
+ {
+ int j;
+ for (j = 0; j < ntokens; j++)
+ if (actrow[j]
== rule_number_as_item_number (default_reduction->number)
- && ! (nondeterministic_parser && conflrow[j]))
- actrow[j] = 0;
- }
- }
+ && ! (nondeterministic_parser && conflrow[j]))
+ actrow[j] = 0;
+ }
+ }
}
/* If have no default reduction, the default is an error.
if (!default_reduction)
for (i = 0; i < ntokens; i++)
if (actrow[i] == ACTION_NUMBER_MINIMUM)
- actrow[i] = 0;
+ actrow[i] = 0;
if (conflicted)
conflict_row (s);
for (i = 0; i < ntokens; i++)
if (actrow[i] != 0)
{
- *sp1++ = i;
- *sp2++ = actrow[i];
- if (nondeterministic_parser)
- *sp3++ = conflrow[i];
+ *sp1++ = i;
+ *sp2++ = actrow[i];
+ if (nondeterministic_parser)
+ *sp3++ = conflrow[i];
}
tally[s] = count;
save_row (i);
/* Now that the parser was computed, we can find which rules are
- really reduced, and which are not because of SR or RR
- conflicts. */
+ really reduced, and which are not because of SR or RR
+ conflicts. */
if (!nondeterministic_parser)
- {
- for (j = 0; j < ntokens; ++j)
- if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
- rules[item_number_as_rule_number (actrow[j])].useful = true;
- if (yydefact[i])
- rules[yydefact[i] - 1].useful = true;
- }
+ {
+ for (j = 0; j < ntokens; ++j)
+ if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
+ rules[item_number_as_rule_number (actrow[j])].useful = true;
+ if (yydefact[i])
+ rules[yydefact[i] - 1].useful = true;
+ }
}
free (actrow);
for (i = begin; i < end; i++)
if (to_state[i] != default_state)
{
- *sp1++ = from_state[i];
- *sp2++ = to_state[i];
+ *sp1++ = from_state[i];
+ *sp2++ = to_state[i];
}
tally[symno] = count;
for (s = 0; s < nstates; s++)
if (state_count[s] > max)
{
- max = state_count[s];
- default_state = s;
+ max = state_count[s];
+ default_state = s;
}
return default_state;
for (i = 0; i < nvectors; i++)
if (tally[i] > 0)
{
- int k;
- int t = tally[i];
- int w = width[i];
- int j = nentries - 1;
+ int k;
+ int t = tally[i];
+ int w = width[i];
+ int j = nentries - 1;
- while (j >= 0 && (width[order[j]] < w))
- j--;
+ while (j >= 0 && (width[order[j]] < w))
+ j--;
- while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
- j--;
+ while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
+ j--;
- for (k = nentries - 1; k > j; k--)
- order[k + 1] = order[k];
+ for (k = nentries - 1; k > j; k--)
+ order[k + 1] = order[k];
- order[j + 1] = i;
- nentries++;
+ order[j + 1] = i;
+ nentries++;
}
}
{
int j;
for (j = 0; j < t; j += 1)
- if (conflict_tos[i][j] != 0)
- return -1;
+ if (conflict_tos[i][j] != 0)
+ return -1;
}
for (prev = vector - 1; prev >= 0; prev--)
int match = 1;
/* Given how ORDER was computed, if the WIDTH or TALLY is
- different, there cannot be a matching state. */
+ different, there cannot be a matching state. */
if (width[j] != w || tally[j] != t)
- return -1;
+ return -1;
for (k = 0; match && k < t; k++)
- if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
- || (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
- match = 0;
+ if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
+ || (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
+ match = 0;
if (match)
- return j;
+ return j;
}
return -1;
aver (j < table_size);
for (k = 0; ok && k < t; k++)
- {
- loc = j + state_number_as_int (from[k]);
- if (table_size <= loc)
- table_grow (loc);
+ {
+ loc = j + state_number_as_int (from[k]);
+ if (table_size <= loc)
+ table_grow (loc);
- if (table[loc] != 0)
- ok = false;
- }
+ if (table[loc] != 0)
+ ok = false;
+ }
for (k = 0; ok && k < vector; k++)
- if (pos[k] == j)
- ok = false;
+ if (pos[k] == j)
+ ok = false;
if (ok)
- {
- for (k = 0; k < t; k++)
- {
- loc = j + from[k];
- table[loc] = to[k];
- if (nondeterministic_parser && conflict_to != NULL)
- conflict_table[loc] = conflict_to[k];
- check[loc] = from[k];
- }
-
- while (table[lowzero] != 0)
- lowzero++;
-
- if (loc > high)
- high = loc;
-
- aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
- return j;
- }
+ {
+ for (k = 0; k < t; k++)
+ {
+ loc = j + from[k];
+ table[loc] = to[k];
+ if (nondeterministic_parser && conflict_to != NULL)
+ conflict_table[loc] = conflict_to[k];
+ check[loc] = from[k];
+ }
+
+ while (table[lowzero] != 0)
+ lowzero++;
+
+ if (loc > high)
+ high = loc;
+
+ aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
+ return j;
+ }
}
}
base_number place;
if (s < 0)
- /* A new set of state actions, or a nonterminal. */
- place = pack_vector (i);
+ /* A new set of state actions, or a nonterminal. */
+ place = pack_vector (i);
else
- /* Action of I were already coded for S. */
- place = base[s];
+ /* Action of I were already coded for S. */
+ place = base[s];
pos[i] = place;
base[order[i]] = place;
correlated. In particular the signedness is not taken into
account. But it's not useless. */
verify (sizeof nstates <= sizeof nvectors
- && sizeof nvars <= sizeof nvectors);
+ && sizeof nvars <= sizeof nvectors);
nvectors = state_number_as_int (nstates) + nvars;
if (!hash_lookup (uniqstrs_table, str))
{
error (0, 0,
- "not a uniqstr: %s", quotearg (str));
+ "not a uniqstr: %s", quotearg (str));
abort ();
}
}
static bool
hash_compare_uniqstr (void const *m1, void const *m2)
{
- return strcmp (m1, m2) == 0;
+ return STREQ (m1, m2);
}
static size_t
uniqstrs_new (void)
{
uniqstrs_table = hash_initialize (HT_INITIAL_CAPACITY,
- NULL,
- hash_uniqstr,
- hash_compare_uniqstr,
- free);
+ NULL,
+ hash_uniqstr,
+ hash_compare_uniqstr,
+ free);
}
/calc
/calc.[chy]
/calc.tab.*
-/Makefile
-/Makefile.in
-/Makefile.in
/package.m4
/testsuite
/testsuite.dir
+++ /dev/null
-## Process this file with automake to create Makefile.in.
-
-## Makefile for Bison testsuite.
-
-## Copyright (C) 2000-2012 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4
-
-DISTCLEANFILES = atconfig $(check_SCRIPTS)
-MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
-
-## ------------ ##
-## package.m4. ##
-## ------------ ##
-
-$(srcdir)/package.m4: $(top_srcdir)/configure
- $(AM_V_GEN) { \
- echo '# Signature of the current package.'; \
- echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])'; \
- echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])'; \
- echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])'; \
- echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])'; \
- echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \
- } >$@.tmp
- $(AM_V_at) mv $@.tmp $@
-
-## ------------ ##
-## Test suite. ##
-## ------------ ##
-
-TESTSUITE_AT = \
- local.at \
- testsuite.at \
- input.at named-refs.at \
- output.at skeletons.at sets.at reduce.at \
- synclines.at headers.at actions.at conflicts.at \
- calc.at \
- torture.at existing.at regression.at \
- c++.at \
- java.at \
- cxx-type.at glr-regression.at \
- push.at
-
-TESTSUITE = $(srcdir)/testsuite
-
-AUTOTEST = $(AUTOM4TE) --language=autotest
-$(TESTSUITE): $(srcdir)/package.m4 $(TESTSUITE_AT)
- $(AM_V_GEN) $(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp
- $(AM_V_at) mv $@.tmp $@
-
-atconfig: $(top_builddir)/config.status
- cd $(top_builddir) && ./config.status tests/$@
-
-clean-local:
- test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
-
-check-local: atconfig atlocal $(TESTSUITE)
- $(SHELL) $(TESTSUITE) $(TESTSUITEFLAGS)
-
-check_SCRIPTS = bison
-
-# Run the test suite on the *installed* tree.
-installcheck-local: atconfig atlocal $(TESTSUITE)
- $(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
-
-# Be real mean with it.
-.PHONY: maintainer-check-g++
-maintainer-check-g++: atconfig atlocal $(TESTSUITE)
- $(TESTSUITE) $(TESTSUITEFLAGS) --compile-c-with-cxx
-
-.PHONY: maintainer-check-posix
-maintainer-check-posix: atconfig atlocal $(TESTSUITE)
- $(TESTSUITE) $(TESTSUITEFLAGS) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112
-
-.PHONY: maintainer-check-valgrind
-maintainer-check-valgrind: atconfig atlocal $(TESTSUITE)
- test -z '$(VALGRIND)' || \
- $(TESTSUITE) $(TESTSUITEFLAGS) \
- PREBISON='$(VALGRIND_PREBISON)' PREPARSER='$(VALGRIND) -q' \
- VALGRIND_OPTS='--leak-check=full --show-reachable=yes'
-
-.PHONY: maintainer-check
-maintainer-check: maintainer-check-posix maintainer-check-valgrind maintainer-check-g++
-
-.PHONY: maintainer-push-check
-maintainer-push-check:
- BISON_USE_PUSH_FOR_PULL=1 $(MAKE) $(AM_MAKEFLAGS) maintainer-check
-
-.PHONY: maintainer-xml-check
-maintainer-xml-check:
- BISON_TEST_XML=1 $(MAKE) $(AM_MAKEFLAGS) maintainer-check
-
-.PHONY: maintainer-release-check
-maintainer-release-check: maintainer-check maintainer-push-check maintainer-xml-check
-# Executing Actions. -*- Autotest -*-
+e# Executing Actions. -*- Autotest -*-
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([[input.y]],
-[[%error-verbose
+[[%define parse.error verbose
%debug
%{
]AT_YYERROR_DECLARE[
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([[input.y]],
-[[%error-verbose
+[[%define parse.error verbose
%debug
%{
]AT_YYERROR_DECLARE[
AT_DATA_GRAMMAR([[input.y]],
[[
%{
-#include <stdio.h>
+# include <stdio.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
typedef struct { int val; } stype;
$$ = -1;
V(line, $$, @$, ": ");
V('(', $1, @1, " ");
- fprintf (stderr, "error (@%d-%d) ", RANGE (@2));
+ fprintf (stderr, "error (@%d-%d) ", RANGE(@2));
V(')', $3, @3, "\n");
}
;
$3
_AT_CHECK_PRINTER_AND_DESTRUCTOR($[1], $[2], $[3], $[4],
-[%error-verbose
+[%define parse.error verbose
%debug
%verbose
%locations
AT_CHECK_PRINTER_AND_DESTRUCTOR([])
-AT_CHECK_PRINTER_AND_DESTRUCTOR([], [ with union])
+AT_CHECK_PRINTER_AND_DESTRUCTOR([], [with union])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"])
-AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"], [ with union])
+AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"], [with union])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser])
-AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser], [ with union])
+AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser], [with union])
AT_SETUP([Default tagless %printer and %destructor])
AT_BISON_OPTION_PUSHDEFS([%locations])
AT_DATA_GRAMMAR([[input.y]],
-[[%error-verbose
+[[%define parse.error verbose
%debug
%locations
}
]])
-AT_BISON_CHECK([-o input.c input.y])
+AT_BISON_CHECK([-o input.c input.y], [], [],
+[[input.y:23.3-5: warning: useless %destructor for type <*> [-Wother]
+input.y:23.3-5: warning: useless %printer for type <*> [-Wother]
+]])
AT_COMPILE([input])
AT_PARSER_CHECK([./input], 1,
[[<> destructor for 'd' @ 4.
AT_SETUP([Default tagged and per-type %printer and %destructor])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([[input.y]],
-[[%error-verbose
+[[%define parse.error verbose
%debug
%{
}
]])
-AT_BISON_CHECK([-o input.c input.y])
+AT_BISON_CHECK([-o input.c input.y], [], [],
+[[input.y:22.3-4: warning: useless %destructor for type <> [-Wother]
+input.y:22.3-4: warning: useless %printer for type <> [-Wother]
+]])
AT_COMPILE([input])
AT_PARSER_CHECK([./input], 1,
[[<*>/<field2>/e destructor.
AT_SETUP([Default %printer and %destructor for user-defined end token])
-# _AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN(TYPED)
-# -------------------------------------------------------------
-m4_define([_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN],
+# AT_TEST(TYPED)
+# --------------
+m4_pushdef([AT_TEST],
[m4_if($1, 0,
[m4_pushdef([kind], []) m4_pushdef([not_kind], [*])],
[m4_pushdef([kind], [*]) m4_pushdef([not_kind], [])])
AT_BISON_OPTION_PUSHDEFS([%locations])
AT_DATA_GRAMMAR([[input]]$1[[.y]],
-[[%error-verbose
+[[%define parse.error verbose
%debug
%locations
]])
AT_BISON_OPTION_POPDEFS
-AT_BISON_CHECK([-o input$1.c input$1.y])
+AT_BISON_CHECK([-o input$1.c input$1.y], [], [],
+[m4_if([$1], [0],
+[[input0.y:23.3-5: warning: useless %destructor for type <*> [-Wother]
+input0.y:23.3-5: warning: useless %printer for type <*> [-Wother]
+]],
+[[input1.y:23.3-4: warning: useless %destructor for type <> [-Wother]
+input1.y:23.3-4: warning: useless %printer for type <> [-Wother]
+]])])
+
AT_COMPILE([input$1])
+
AT_PARSER_CHECK([./input$1], 0,
[[<]]kind[[> for 'E' @ 1.
<]]kind[[> for 'S' @ 1.
m4_popdef([not_kind])
])
-_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN(0)
-_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN(1)
+AT_TEST(0)
+AT_TEST(1)
+
+m4_popdef([AT_TEST])
AT_CLEANUP
]])
AT_BISON_OPTION_POPDEFS
-AT_BISON_CHECK([-o input.c input.y])
+AT_BISON_CHECK([-o input.c input.y], [], [],
+[[input.y:21.6-8: warning: useless %destructor for type <*> [-Wother]
+input.y:21.6-8: warning: useless %printer for type <*> [-Wother]
+]])
AT_COMPILE([input])
AT_PARSER_CHECK([./input], [1], [],
[[Starting parse
]])
AT_BISON_OPTION_POPDEFS
-AT_BISON_CHECK([-o input.c input.y])
+AT_BISON_CHECK([-o input.c input.y], [], [],
+[[input.y:22.3-4: warning: useless %destructor for type <> [-Wother]
+input.y:22.3-4: warning: useless %printer for type <> [-Wother]
+]])
AT_COMPILE([input])
AT_CLEANUP
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y], 0,,
-[[input.y:33.3-23: warning: unset value: $$
-input.y:32.3-23: warning: unused value: $3
+[[input.y:24.70-72: warning: useless %destructor for type <*> [-Wother]
+input.y:24.70-72: warning: useless %printer for type <*> [-Wother]
+input.y:33.3-23: warning: unset value: $$ [-Wother]
+input.y:32.3-23: warning: unused value: $3 [-Wother]
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], 0,,
-[[input.y:33.3-23: warning: unset value: $$
+[[input.y:24.70-72: warning: useless %destructor for type <*> [-Wother]
+ %printer { fprintf (yyoutput, "<*> printer should not be called"); } <*>
+ ^^^
+input.y:24.70-72: warning: useless %printer for type <*> [-Wother]
+ %printer { fprintf (yyoutput, "<*> printer should not be called"); } <*>
+ ^^^
+input.y:33.3-23: warning: unset value: $$ [-Wother]
{ @$ = 4; } // Only used.
^^^^^^^^^^^^^^^^^^^^^
-input.y:32.3-23: warning: unused value: $3
+input.y:32.3-23: warning: unused value: $3 [-Wother]
{ USE ($$); @$ = 3; } // Only set.
^^^^^^^^^^^^^^^^^^^^^
]])
## Qualified $$ in actions. ##
## ------------------------- ##
-# Check that we can used qualified $$ (v.g., $<type>$) not only in
-# rule actions, but also where $$ is valid: %printer and %destructor.
+# Check that we can use qualified $$ (v.g., $<type>$) not only in rule
+# actions, but also where $$ is valid: %destructor/%printer and
+# %initial-action.
#
# FIXME: Not actually checking %destructor, but it's the same code as
# %printer...
m4_pushdef([AT_TEST],
[AT_SETUP([[Qualified $$ in actions: $1]])
-AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1"])
+AT_BISON_OPTION_PUSHDEFS([%skeleton "$1"])
AT_DATA_GRAMMAR([[input.y]],
[[%skeleton "$1"
-%defines // FIXME: Mandated by lalr1.cc in Bison 2.6.
-%locations // FIXME: Mandated by lalr1.cc in Bison 2.6.
%debug
%code requires
{
AT_PARSER_CHECK([./input], 0, [], [stderr])
# Don't be too picky on the traces, GLR is not exactly the same. Keep
# only the lines from the printer.
-#
-# Don't care about locations. FIXME: remove their removal when Bison
-# supports C++ without locations.
-AT_CHECK([[sed -ne 's/([-0-9.]*: /(/;/ival:/p' stderr]], 0,
+AT_CHECK([[sed -ne '/ival:/p' stderr]], 0,
[[Reading a token: Next token is token UNTYPED (ival: 10, fval: 0.1)
Shifting token UNTYPED (ival: 10, fval: 0.1)
Reading a token: Next token is token INT (ival: 20, fval: 0.2)
start: test2 test1 test0 testc;
test2
-: 'a' { semi; /* TEST:N:2 */ }
-| 'b' { if (0) {no_semi} /* TEST:N:2 */ }
-| 'c' { if (0) {semi;} /* TEST:N:2 */ }
-| 'd' { semi; no_semi /* TEST:Y:2 */ }
-| 'e' { semi(); no_semi() /* TEST:Y:2 */ }
-| 'f' { semi[]; no_semi[] /* TEST:Y:2 */ }
-| 'g' { semi++; no_semi++ /* TEST:Y:2 */ }
-| 'h' { {no_semi} no_semi /* TEST:Y:2 */ }
-| 'i' { {semi;} no_semi /* TEST:Y:2 */ }
+: 'a' { semi; /* TEST:N:2 */ }
+| 'b' { if (0) {no_semi} /* TEST:N:2 */ }
+| 'c' { if (0) {semi;} /* TEST:N:2 */ }
+| 'd' { semi; no_semi /* TEST:Y:2 */ }
+| 'e' { semi(); no_semi() /* TEST:Y:2 */ }
+| 'f' { semi[]; no_semi[] /* TEST:Y:2 */ }
+| 'g' { semi++; no_semi++ /* TEST:Y:2 */ }
+| 'h' { {no_semi} no_semi /* TEST:Y:2 */ }
+| 'i' { {semi;} no_semi /* TEST:Y:2 */ }
;
test1
- : 'a' { semi; // TEST:N:1 ;
-} | 'b' { if (0) {no_semi} // TEST:N:1 ;
-} | 'c' { if (0) {semi;} // TEST:N:1 ;
-} | 'd' { semi; no_semi // TEST:Y:1 ;
-} | 'e' { semi(); no_semi() // TEST:Y:1 ;
-} | 'f' { semi[]; no_semi[] // TEST:Y:1 ;
-} | 'g' { semi++; no_semi++ // TEST:Y:1 ;
-} | 'h' { {no_semi} no_semi // TEST:Y:1 ;
-} | 'i' { {semi;} no_semi // TEST:Y:1 ;
+ : 'a' { semi; // TEST:N:1 ;
+} | 'b' { if (0) {no_semi} // TEST:N:1 ;
+} | 'c' { if (0) {semi;} // TEST:N:1 ;
+} | 'd' { semi; no_semi // TEST:Y:1 ;
+} | 'e' { semi(); no_semi() // TEST:Y:1 ;
+} | 'f' { semi[]; no_semi[] // TEST:Y:1 ;
+} | 'g' { semi++; no_semi++ // TEST:Y:1 ;
+} | 'h' { {no_semi} no_semi // TEST:Y:1 ;
+} | 'i' { {semi;} no_semi // TEST:Y:1 ;
} ;
test0
- : 'a' { semi; // TEST:N:1 {}
-} | 'b' { if (0) {no_semi} // TEST:N:1 {}
-} | 'c' { if (0) {semi;} // TEST:N:1 {}
-} | 'd' { semi; no_semi // TEST:Y:1 {}
-} | 'e' { semi(); no_semi() // TEST:Y:1 {}
-} | 'f' { semi[]; no_semi[] // TEST:Y:1 {}
-} | 'g' { semi++; no_semi++ // TEST:Y:1 {}
-} | 'h' { {no_semi} no_semi // TEST:Y:1 {}
-} | 'i' { {semi;} no_semi // TEST:Y:1 {}
+ : 'a' { semi; // TEST:N:1 {}
+} | 'b' { if (0) {no_semi} // TEST:N:1 {}
+} | 'c' { if (0) {semi;} // TEST:N:1 {}
+} | 'd' { semi; no_semi // TEST:Y:1 {}
+} | 'e' { semi(); no_semi() // TEST:Y:1 {}
+} | 'f' { semi[]; no_semi[] // TEST:Y:1 {}
+} | 'g' { semi++; no_semi++ // TEST:Y:1 {}
+} | 'h' { {no_semi} no_semi // TEST:Y:1 {}
+} | 'i' { {semi;} no_semi // TEST:Y:1 {}
} ;
testc
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o input.c input.y]], [0], [],
-[[input.y:8.48: warning: a ';' might be needed at the end of action code
+[[input.y:8.48: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:8.48: future versions of Bison will not add the ';'
-input.y:9.48: warning: a ';' might be needed at the end of action code
+input.y:9.48: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:9.48: future versions of Bison will not add the ';'
-input.y:10.48: warning: a ';' might be needed at the end of action code
+input.y:10.48: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:10.48: future versions of Bison will not add the ';'
-input.y:11.48: warning: a ';' might be needed at the end of action code
+input.y:11.48: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:11.48: future versions of Bison will not add the ';'
-input.y:12.48: warning: a ';' might be needed at the end of action code
+input.y:12.48: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:12.48: future versions of Bison will not add the ';'
-input.y:13.48: warning: a ';' might be needed at the end of action code
+input.y:13.48: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:13.48: future versions of Bison will not add the ';'
-input.y:20.1: warning: a ';' might be needed at the end of action code
+input.y:20.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:20.1: future versions of Bison will not add the ';'
-input.y:21.1: warning: a ';' might be needed at the end of action code
+input.y:21.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:21.1: future versions of Bison will not add the ';'
-input.y:22.1: warning: a ';' might be needed at the end of action code
+input.y:22.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:22.1: future versions of Bison will not add the ';'
-input.y:23.1: warning: a ';' might be needed at the end of action code
+input.y:23.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:23.1: future versions of Bison will not add the ';'
-input.y:24.1: warning: a ';' might be needed at the end of action code
+input.y:24.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:24.1: future versions of Bison will not add the ';'
-input.y:25.1: warning: a ';' might be needed at the end of action code
+input.y:25.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:25.1: future versions of Bison will not add the ';'
-input.y:31.1: warning: a ';' might be needed at the end of action code
+input.y:31.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:31.1: future versions of Bison will not add the ';'
-input.y:32.1: warning: a ';' might be needed at the end of action code
+input.y:32.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:32.1: future versions of Bison will not add the ';'
-input.y:33.1: warning: a ';' might be needed at the end of action code
+input.y:33.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:33.1: future versions of Bison will not add the ';'
-input.y:34.1: warning: a ';' might be needed at the end of action code
+input.y:34.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:34.1: future versions of Bison will not add the ';'
-input.y:35.1: warning: a ';' might be needed at the end of action code
+input.y:35.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:35.1: future versions of Bison will not add the ';'
-input.y:36.1: warning: a ';' might be needed at the end of action code
+input.y:36.1: warning: a ';' might be needed at the end of action code [-Wdeprecated]
input.y:36.1: future versions of Bison will not add the ';'
]])
-# @configure_input@ -*- shell-script -*-
+# @configure_input@ -*- shell-script -*-
# Configurable variable values for Bison test suite.
# Copyright (C) 2000-2012 Free Software Foundation, Inc.
CFLAGS="$NO_WERROR_CFLAGS @WERROR_CFLAGS@"
CXXFLAGS="$NO_WERROR_CXXFLAGS @WERROR_CXXFLAGS@"
-# If 'exit 77'; skip all C/C++ tests; otherwise ':'.
-BISON_C_WORKS='@BISON_C_WORKS@'
+# C++ variants break strict aliasing analysis.
+NO_STRICT_ALIAS_CXXFLAGS='@NO_STRICT_ALIAS_CXXFLAGS@'
+
+# If 'exit 77'; skip all C++ tests; otherwise ':'.
BISON_CXX_WORKS='@BISON_CXX_WORKS@'
# Whether the compiler supports POSIXLY_CORRECT defined.
# Empty if no Java VM was found
CONF_JAVA='@CONF_JAVA@'
-# We need egrep.
+# We need egrep and perl.
: ${EGREP='@EGREP@'}
+: ${PERL='@PERL@'}
# Use simple quotes (lib/quote.c).
LC_CTYPE=C
# Empty if no xsltproc was found
: ${XSLTPROC='@XSLTPROC@'}
-: ${PERL='@PERL@'}
+# Don't just check if $POSIXLY_CORRECT is set, as Bash, when launched
+# as /bin/sh, sets the shell variable POSIXLY_CORRECT to y, but not
+# the environment variable.
+: ${C_COMPILER_POSIXLY_CORRECT='@C_COMPILER_POSIXLY_CORRECT@'}
+if env | grep '^POSIXLY_CORRECT=' >/dev/null; then
+ POSIXLY_CORRECT_IS_EXPORTED=true
+else
+ POSIXLY_CORRECT_IS_EXPORTED=false
+fi
for i
do
case $i in
- */parse-gram.y)
+ */src/parse-gram.y)
if $PERL --version >/dev/null; then
# We are called by ylwrap which still uses y.tab.*, and
# post-processes the synclines on y.tab.c itself. Don't let it
# do it. Besides, it leaves "parse-gram.y" as the source,
# dropping the src/ part.
- $PERL -pi -e 's{"y\.tab\.}{"parse-gram.}g;' \
- -e 's{".*/(parse-gram\.y)"}{"$1"}g;' \
+ $PERL -pi -e 's{"y\.tab\.}{"src/parse-gram.}g;' \
+ -e 's{".*/(parse-gram\.y)"}{"src/$1"}g;' \
+ -e 's{GRAM_Y_TAB_H}{GRAM_SRC_PARSE_GRAM_H}g;' \
y.tab.[ch]
fi
;;
# Checking the C++ Features. -*- Autotest -*-
-# Copyright (C) 2004-2005, 2007, 2009-2012 Free Software Foundation,
-# Inc.
+# Copyright (C) 2004-2005, 2007-2012 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
AT_BANNER([[C++ Features.]])
+## ---------- ##
+## Variants. ##
+## ---------- ##
+
+# AT_TEST([DIRECTIVES])
+# ---------------------
+# Check the support of variants in C++, with the additional DIRECTIVES.
+m4_pushdef([AT_TEST],
+[AT_SETUP([Variants $1])
+
+AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" $1])
+# Store strings and integers in a list of strings.
+AT_DATA_GRAMMAR([list.yy],
+[[%debug
+%skeleton "lalr1.cc"
+%defines
+%define variant
+]m4_bpatsubst([$1], [\\n], [
+])[
+
+%code requires // code for the .hh file
+{
+#include <list>
+#include <string>
+typedef std::list<std::string> strings_type;
+}
+
+%code // code for the .cc file
+{
+#include <cstdlib> // abort, getenv
+#include <iostream>
+#include <sstream>
+
+ namespace yy
+ {
+ static]AT_TOKEN_CTOR_IF([[
+ parser::symbol_type yylex ()]], [[
+ parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
+ parser::location_type* yylloc])[)]])[;
+ }
+
+ // Printing a list of strings (for %printer).
+ // 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)
+ {
+ o << '(';
+ for (strings_type::const_iterator i = s.begin (); i != s.end (); ++i)
+ {
+ if (i != s.begin ())
+ o << ", ";
+ o << *i;
+ }
+ 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;
+%token END_OF_FILE 0;
+
+%type <::std::string> item;
+// Using the template type to exercize its parsing.
+// Starting with :: to ensure we don't output "<::" which starts by the
+// digraph for the left square bracket.
+%type <::std::list<std::string>> list result;
+
+%printer { yyo << $][$; }
+ <int> <::std::string> <::std::list<std::string>>;
+%%
+
+result:
+ list { std::cout << $][1 << std::endl; }
+;
+
+list:
+ /* nothing */ { /* Generates an empty string list */ }
+| list item { std::swap ($][$,$][1); $$.push_back ($][2); }
+| list error { std::swap ($][$,$][1); }
+;
+
+item:
+ TEXT { std::swap ($][$,$][1); }
+| NUMBER { if ($][1 == 3) YYERROR; else $][$ = string_cast ($][1); }
+;
+%%
+
+#ifdef TWO_STAGE_BUILD
+# define BUILD(Type, Value) build<Type> () = Value
+#else
+# define BUILD(Type, Value) build (Value)
+#endif
+
+#define STAGE_MAX 5
+namespace yy
+{
+ static]AT_TOKEN_CTOR_IF([[
+ parser::symbol_type yylex ()]], [[
+ parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
+ parser::location_type* yylloc])[)]])[
+ {]AT_LOCATION_IF([
+ typedef parser::location_type location;])[
+ static int stage = -1;
+ ++stage;
+ if (stage == STAGE_MAX)
+ {]AT_TOKEN_CTOR_IF([[
+ return parser::make_END_OF_FILE (]AT_LOCATION_IF([location ()])[);]],
+[AT_LOCATION_IF([
+ *yylloc = location ();])[
+ return parser::token::END_OF_FILE;]])[
+ }
+ else if (stage % 2)
+ {]AT_TOKEN_CTOR_IF([[
+ return parser::make_NUMBER (stage]AT_LOCATION_IF([, location ()])[);]],
+[[
+ yylval->BUILD (int, stage);]AT_LOCATION_IF([
+ *yylloc = location ();])[
+ return parser::token::NUMBER;]])[
+ }
+ else
+ {]AT_TOKEN_CTOR_IF([[
+ return parser::make_TEXT (string_cast (stage)]AT_LOCATION_IF([, location ()])[);]], [[
+ yylval->BUILD (std::string, string_cast (stage));]AT_LOCATION_IF([
+ *yylloc = location ();])[
+ return parser::token::TEXT;]])[
+ }
+ abort ();
+ }
+}
+
+]AT_YYERROR_DEFINE[
+
+int
+main ()
+{
+ yy::parser p;
+ p.set_debug_level (!!getenv ("YYDEBUG"));
+ return p.parse ();
+}
+]])
+
+AT_BISON_CHECK([-o list.cc list.yy])
+AT_COMPILE_CXX([list], [$NO_STRICT_ALIAS_CXXFLAGS list.cc])
+AT_PARSER_CHECK([./list], 0,
+[(0, 1, 2, 4)
+])
+
+AT_BISON_OPTION_POPDEFS
+AT_CLEANUP
+])
+
+AT_TEST([])
+AT_TEST([%define parse.assert])
+AT_TEST([%locations %define parse.assert])
+AT_TEST([[%define parse.assert %code {\n#define TWO_STAGE_BUILD\n}]])
+AT_TEST([[%define parse.assert %define api.token.constructor]])
+AT_TEST([[%define parse.assert %define api.token.constructor %define api.token.prefix "TOK_"]])
+AT_TEST([[%locations %define parse.assert %define api.token.constructor %define api.token.prefix "TOK_"]])
+
+m4_popdef([AT_TEST])
+
+
## ----------------------- ##
## Doxygen Documentation. ##
## ----------------------- ##
[m4_case([$1],
[Public], [m4_pushdef([AT_DOXYGEN_PRIVATE], [NO])],
[Private], [m4_pushdef([AT_DOXYGEN_PRIVATE], [YES])],
- [m4_fatal([invalid argument: $1])])
+ [m4_fatal([invalid argument: $1])])
AT_SETUP([Doxygen $1 Documentation])
AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"])
AT_CHECK_DOXYGEN([Public])
AT_CHECK_DOXYGEN([Private])
+
## ------------ ##
## Namespaces. ##
## ------------ ##
AT_DATA_GRAMMAR([[input.y]],
[[%language "C++"
%defines
-%define namespace "]$1["
+%define api.namespace "]$1["
%union { int i; }
%define global_tokens_and_yystype
+%locations
%code {
// YYSTYPE contains a namespace reference.
- int yylex (YYSTYPE *lval) {
+ int yylex (YYSTYPE *lval, const ]$1[::parser::location_type*) {
lval->i = 3;
return 0;
}
}
int
-main (void)
+main ()
{
]$1[::parser p;
return p.parse ();
# contains single occurrences of `:'.
AT_CHECK_NAMESPACE([[foo[3]::bar::baz]], [[-]])
AT_CHECK_NAMESPACE([[foo::bar,baz]], [[-]])
-AT_CHECK_NAMESPACE([[foo::bar::(baz]], [[-]])
+AT_CHECK_NAMESPACE([[foo::bar::(baz /* Pacify Emacs ) */]], [[-]])
+AT_CLEANUP
+
+
+## -------------------------------------- ##
+## Syntax error discarding no lookahead. ##
+## -------------------------------------- ##
+
+# After a syntax error, lalr1.cc used to not check whether there
+# actually is a lookahead before discarding the lookahead. As a result,
+# it mistakenly invoked the destructor for the previous lookahead.
+
+AT_SETUP([[Syntax error discarding no lookahead]])
+
+AT_DATA_GRAMMAR([[input.yy]],
+[[%skeleton "lalr1.cc"
+
+%code {
+ #include <string>
+ int yylex (yy::parser::semantic_type *);
+ #define USE(Args)
+}
+
+%defines
+%define parse.error verbose
+
+%nonassoc 'a' ;
+
+%destructor {
+ std::cerr << "Discarding 'a'." << std::endl;
+} 'a'
+
+%%
+
+start: error-reduce consistent-error 'a' { USE ($3); };
+
+error-reduce:
+ 'a' 'a' consistent-error 'a' { USE (($1, $2, $4)); }
+| 'a' error { std::cerr << "Reducing 'a'." << std::endl; USE ($1); }
+;
+
+consistent-error:
+ 'a'
+| /*empty*/ %prec 'a'
+;
+
+// Provide another context in which all rules are useful so that this
+// test case looks a little more realistic.
+start: 'b' consistent-error ;
+
+%%
+
+int
+yylex (yy::parser::semantic_type *)
+{
+ static char const *input = "aa";
+ return *input++;
+}
+
+void
+yy::parser::error (const std::string &m)
+{
+ std::cerr << m << std::endl;
+}
+
+int
+main ()
+{
+ yy::parser parser;
+ return parser.parse ();
+}
+]])
+AT_BISON_CHECK([[-o input.cc input.yy]])
+AT_COMPILE_CXX([[input]])
+# This used to print "Discarding 'a'." again at the end.
+AT_PARSER_CHECK([[./input]], [[1]], [[]],
+[[syntax error
+Discarding 'a'.
+Reducing 'a'.
+]])
+
+AT_CLEANUP
+
+
+## --------------------------- ##
+## Syntax error as exception. ##
+## --------------------------- ##
+
+AT_SETUP([[Syntax error as exception]])
+
+AT_DATA_GRAMMAR([[input.yy]],
+[[%skeleton "lalr1.cc"
+
+%code
+{
+ #include <cstdlib>
+ int yylex (yy::parser::semantic_type *);
+}
+
+%defines
+%define variant
+%define parse.error verbose
+%define parse.trace
+%%
+
+start:
+ thing
+| start thing
+;
+
+thing:
+ error { std::cerr << "caught error" << std::endl; }
+| item
+;
+
+item:
+ 'a'
+| 's'
+ {
+ throw yy::parser::syntax_error ("invalid expression");
+ }
+
+%%
+
+int
+yylex (yy::parser::semantic_type *)
+{
+ // 's': syntax error, 'l': lexical error.
+ static char const *input = "asal";
+ switch (int res = *input++)
+ {
+ case 'l':
+ throw yy::parser::syntax_error ("invalid character");
+ default:
+ return res;
+ }
+}
+
+void
+yy::parser::error (const std::string &m)
+{
+ std::cerr << "error: " << m << std::endl;
+}
+
+int
+main ()
+{
+ yy::parser parser;
+ parser.set_debug_level (!!getenv ("YYDEBUG"));
+ return parser.parse ();
+}
+]])
+AT_BISON_CHECK([[-o input.cc input.yy]])
+AT_COMPILE_CXX([[input]])
+
+AT_PARSER_CHECK([[./input]], [[0]], [[]],
+[[error: invalid expression
+caught error
+error: invalid character
+caught error
+]])
+
AT_CLEANUP
item:
'a' { $$ = $1; }
-| 'e' { YYUSE ($$); YYUSE($1); error (location_type(), "syntax error"); }
+| 'e' { YYUSE ($$); YYUSE($1); error ("syntax error"); }
// Not just 'E', otherwise we reduce when 'E' is the lookahead, and
// then the stack is emptied, defeating the point of the test.
| 'E' 'a' { YYUSE($1); $$ = $2; }
/* A C++ error reporting function. */
void
-yy::parser::error (const location_type& l, const std::string& m)
+yy::parser::error (const std::string& m)
{
- YYUSE (l);
throw std::runtime_error (m);
}
input = argv[1];
break;
case 3:
- assert (!strcmp (argv[1], "--debug"));
+ assert (std::string(argv[1]) == "--debug");
debug = 1;
input = argv[2];
break;
{
unget_char (]AT_YYLEX_PRE_ARGS[ c);
]AT_VAL[.ival = read_signed_integer (]AT_YYLEX_ARGS[);
- return NUM;
+ return ]AT_TOKEN_PREFIX[NUM;
}
/* Return end-of-file. */
if (c == EOF)
- return CALC_EOF;
+ return ]AT_TOKEN_PREFIX[CALC_EOF;
/* Return single chars. */
return c;
%token <ival> NUM "number"
%type <ival> exp
-%nonassoc '=' /* comparison */
+%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
-%left NEG /* negation--unary minus */
-%right '^' /* exponentiation */
+%precedence NEG /* negation--unary minus */
+%right '^' /* exponentiation */
/* Grammar follows */
%%
# If BISON-OPTIONS contains `%location', then make sure the ERROR-LOCATION
# is correctly output on stderr.
#
-# If BISON-OPTIONS contains `%error-verbose', then make sure the
+# If BISON-OPTIONS contains `%define parse.error verbose', then make sure the
# IF-YYERROR-VERBOSE message is properly output after `syntax error, '
# on STDERR.
#
[[sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout]])
# 4. If error-verbose is not used, strip the`, unexpected....' part.
-m4_bmatch([$1], [%error-verbose], [],
+m4_bmatch([$1], [%define parse.error verbose], [],
[[sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout]])
# 5. Check
])
-# AT_CHECK_SPACES([FILE])
-# -----------------------
+# AT_CHECK_SPACES([FILES])
+# ------------------------
# Make sure we did not introduce bad spaces. Checked here because all
# the skeletons are (or should be) exercized here.
m4_define([AT_CHECK_SPACES],
[AT_CHECK([$PERL -ne '
chomp;
- print "$.: {$_}\n"
+ print "$ARGV:$.: {$_}\n"
if (# No starting/ending empty lines.
(eof || $. == 1) && /^\s*$/
- # No trailing space. FIXME: not ready for "maint".
- # || /\s$/
+ # No trailing space.
+ || /\s$/
+ # No tabs.
+ || /\t/
)' $1
])dnl
])
AT_DATA_CALC_Y([$1])
AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]]))
-AT_CHECK_SPACES([calc.AT_SKEL_CC_IF([cc], [c])])
-AT_DEFINES_IF([AT_CHECK_SPACES([calc.AT_SKEL_CC_IF([hh], [h])])])
+AT_CHECK_SPACES(m4_join([ ],
+ [calc.AT_SKEL_CC_IF([cc], [c])],
+ [AT_DEFINES_IF([calc.AT_SKEL_CC_IF([hh], [h])])]))
# Test the priorities.
_AT_CHECK_CALC([$1],
AT_CHECK_CALC_LALR([%defines])
AT_CHECK_CALC_LALR([%locations])
-AT_CHECK_CALC_LALR([%name-prefix="calc"]) dnl test deprecated `='
+AT_CHECK_CALC_LALR([%name-prefix "calc"])
AT_CHECK_CALC_LALR([%verbose])
AT_CHECK_CALC_LALR([%yacc])
-AT_CHECK_CALC_LALR([%error-verbose])
+AT_CHECK_CALC_LALR([%define parse.error verbose])
AT_CHECK_CALC_LALR([%define api.pure full %locations])
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %locations])
-AT_CHECK_CALC_LALR([%error-verbose %locations])
+AT_CHECK_CALC_LALR([%define parse.error verbose %locations])
-AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%error-verbose %locations %defines %define api.prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %define api.prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %name-prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc])
AT_CHECK_CALC_LALR([%debug])
-AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define parse.error verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%define api.pure full %verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define api.pure full %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %define parse.error verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_LALR([%define api.pure %define parse.error verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
# ----------------------- #
AT_CHECK_CALC_GLR([%define api.prefix "calc"])
AT_CHECK_CALC_GLR([%verbose])
AT_CHECK_CALC_GLR([%yacc])
-AT_CHECK_CALC_GLR([%error-verbose])
+AT_CHECK_CALC_GLR([%define parse.error verbose])
AT_CHECK_CALC_GLR([%define api.pure %locations])
-AT_CHECK_CALC_GLR([%error-verbose %locations])
+AT_CHECK_CALC_GLR([%define parse.error verbose %locations])
-AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error verbose %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR([%debug])
-AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %define api.prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc])
-AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
-AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
# ----------------------------- #
AT_BANNER([[Simple LALR(1) C++ Calculator.]])
# First let's try using %skeleton
-AT_CHECK_CALC([%skeleton "lalr1.cc" %defines %locations])
+AT_CHECK_CALC([%skeleton "lalr1.cc" %defines])
# AT_CHECK_CALC_LALR1_CC([BISON-OPTIONS])
# ---------------------------------------
# Start a testing chunk which compiles `calc' grammar with
# the C++ skeleton, and performs several tests over the parser.
m4_define([AT_CHECK_CALC_LALR1_CC],
-[AT_CHECK_CALC([%language "C++" %defines %locations] $@)])
+[AT_CHECK_CALC([%language "C++"] $@)])
AT_CHECK_CALC_LALR1_CC([])
-AT_CHECK_CALC_LALR1_CC([%define api.location.type Span])
-AT_CHECK_CALC_LALR1_CC([%error-verbose %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR1_CC([%error-verbose %define api.prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations])
+AT_CHECK_CALC_LALR1_CC([%locations %define api.location.type Span])
+AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %define api.prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
-AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc])
+
+AT_CHECK_CALC_LALR1_CC([%defines %locations %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+
+AT_CHECK_CALC_LALR1_CC([%pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_LALR1_CC([%defines %locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
AT_BANNER([[Simple GLR C++ Calculator.]])
# Again, we try also using %skeleton.
-AT_CHECK_CALC([%skeleton "glr.cc" %defines %locations])
+AT_CHECK_CALC([%skeleton "glr.cc"])
# AT_CHECK_CALC_GLR_CC([BISON-OPTIONS])
# -------------------------------------
# Start a testing chunk which compiles `calc' grammar with
# the GLR C++ skeleton, and performs several tests over the parser.
m4_define([AT_CHECK_CALC_GLR_CC],
-[AT_CHECK_CALC([%language "C++" %glr-parser %defines %locations] $@)])
+[AT_CHECK_CALC([%language "C++" %glr-parser] $@)])
AT_CHECK_CALC_GLR_CC([])
-AT_CHECK_CALC_GLR_CC([%define api.location.type Span])
-AT_CHECK_CALC_GLR_CC([%error-verbose %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_GLR_CC([%error-verbose %define api.prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%locations])
+AT_CHECK_CALC_GLR_CC([%locations %define api.location.type Span])
+AT_CHECK_CALC_GLR_CC([%defines %define parse.error verbose %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%define parse.error verbose %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR_CC([%debug])
-AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc])
-AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
-AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_GLR_CC([%locations %defines %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_GLR_CC([%locations %defines %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
# Exercising Bison on conflicts. -*- Autotest -*-
-# Copyright (C) 2002-2005, 2007, 2009-2012 Free Software Foundation,
-# Inc.
+# Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
]])
AT_BISON_CHECK([-o input.c input.y], 0, [],
-[[input.y:4.9: warning: rule useless in parser due to conflicts: e: /* empty */
+[[input.y:4.9: warning: rule useless in parser due to conflicts: e: /* empty */ [-Wother]
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], 0, [],
-[[input.y:4.9: warning: rule useless in parser due to conflicts
+[[input.y:4.9: warning: rule useless in parser due to conflicts [-Wother]
e: 'e' | /* Nothing. */;
^
]])
# We must disable default reductions in inconsistent states in order to
# have an explicit list of all expected tokens.
-AT_NONASSOC_AND_EOF_CHECK([[-Dlr.default-reductions=consistent]],
+AT_NONASSOC_AND_EOF_CHECK([[-Dlr.default-reduction=consistent]],
[[correct]])
-# lr.default-reductions=consistent happens to work for this test case.
+# lr.default-reduction=consistent happens to work for this test case.
# However, for other grammars, lookahead sets can be merged for
# different left contexts, so it is still possible to have an incorrect
# expected list. Canonical LR is almost a general solution (that is, it
-## -------------------------------------- ##
-## %error-verbose and consistent errors. ##
-## -------------------------------------- ##
+## ------------------------------------------- ##
+## parse.error=verbose and consistent errors. ##
+## ------------------------------------------- ##
-AT_SETUP([[%error-verbose and consistent errors]])
+AT_SETUP([[parse.error=verbose and consistent errors]])
m4_pushdef([AT_CONSISTENT_ERRORS_CHECK], [
}]], [[
%code {]AT_SKEL_CC_IF([[
- #include <cassert>
#include <string>]], [[
#include <assert.h>
#include <stdio.h>
]$1[
-%error-verbose
+%define parse.error verbose
%%
# Even canonical LR doesn't foresee the error for 'a'!
AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
- %define lr.default-reductions consistent]],
+ %define lr.default-reduction consistent]],
[AT_PREVIOUS_STATE_GRAMMAR],
[AT_PREVIOUS_STATE_INPUT],
[[$end]], [[ab]])
AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
- %define lr.default-reductions accepting]],
+ %define lr.default-reduction accepting]],
[AT_PREVIOUS_STATE_GRAMMAR],
[AT_PREVIOUS_STATE_INPUT],
[[$end]], [[ab]])
;
consistent-reduction: /*empty*/ {
- assert (yychar == ]AT_SKEL_CC_IF([[yyempty_]], [[YYEMPTY]])[);
+ assert (yychar == YYEMPTY);
yylval = 0;
yychar = 'b';
} ;
[AT_USER_ACTION_GRAMMAR],
[AT_USER_ACTION_INPUT],
[['b']], [[none]])
-AT_CONSISTENT_ERRORS_CHECK([[%language "c++"]],
- [AT_USER_ACTION_GRAMMAR],
- [AT_USER_ACTION_INPUT],
- [['b']], [[none]])
-# No Java test because yychar cannot be manipulated by users.
+# No C++ or Java test because yychar cannot be manipulated by users.
-AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions consistent]],
+AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reduction consistent]],
[AT_USER_ACTION_GRAMMAR],
[AT_USER_ACTION_INPUT],
[['b']], [[none]])
# Canonical LR doesn't foresee the error for 'a'!
-AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions accepting]],
+AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reduction accepting]],
[AT_USER_ACTION_GRAMMAR],
[AT_USER_ACTION_INPUT],
[[$end]], [[a]])
[AT_USER_ACTION_INPUT],
[['b']], [[none]])
AT_CONSISTENT_ERRORS_CHECK([[%define parse.lac full
- %define lr.default-reductions accepting]],
+ %define lr.default-reduction accepting]],
[AT_USER_ACTION_GRAMMAR],
[AT_USER_ACTION_INPUT],
[[$end]], [[none]])
# Show canonical LR's failure.
AT_BISON_CHECK([[-Dlr.type=canonical-lr -o input.c input.y]],
[[0]], [[]],
-[[input.y: conflicts: 2 shift/reduce
+[[input.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr]
]])
AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input]], [[1]], [[]],
# It's corrected by LAC.
AT_BISON_CHECK([[-Dlr.type=canonical-lr -Dparse.lac=full \
-o input.c input.y]], [[0]], [[]],
-[[input.y: conflicts: 2 shift/reduce
+[[input.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr]
]])
AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input]], [[1]], [[]],
# IELR is sufficient when LAC is used.
AT_BISON_CHECK([[-Dlr.type=ielr -Dparse.lac=full -o input.c input.y]],
[[0]], [[]],
-[[input.y: conflicts: 2 shift/reduce
+[[input.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr]
]])
AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input]], [[1]], [[]],
]])
AT_BISON_CHECK([-o input.c --report=all input.y], 0, [],
-[input.y: conflicts: 1 shift/reduce
-])
+[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
+]])
# Check the contents of the report.
AT_CHECK([cat input.output], [],
AT_CLEANUP
+## ---------------------- ##
+## %precedence suffices. ##
+## ---------------------- ##
+
+AT_SETUP([%precedence suffices])
+
+AT_DATA([input.y],
+[[%precedence "then"
+%precedence "else"
+%%
+stmt:
+ "if" cond "then" stmt
+| "if" cond "then" stmt "else" stmt
+| "stmt"
+;
+
+cond:
+ "exp"
+;
+]])
+
+AT_BISON_CHECK([-o input.c input.y])
+
+AT_CLEANUP
+
+
+## ------------------------------ ##
+## %precedence does not suffice. ##
+## ------------------------------ ##
+
+AT_SETUP([%precedence does not suffice])
+
+AT_DATA([input.y],
+[[%precedence "then"
+%precedence "else"
+%%
+stmt:
+ "if" cond "then" stmt
+| "if" cond "then" stmt "else" stmt
+| "stmt"
+;
+
+cond:
+ "exp"
+| cond "then" cond
+;
+]])
+
+AT_BISON_CHECK([-o input.c input.y], 0, [],
+[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
+input.y:12.3-18: warning: rule useless in parser due to conflicts: cond: cond "then" cond [-Wother]
+]])
+
+AT_CLEANUP
+
+
## -------------------------------- ##
## Defaulted Conflicted Reduction. ##
## -------------------------------- ##
]])
AT_BISON_CHECK([-o input.c --report=all input.y], 0, [],
-[[input.y: conflicts: 1 reduce/reduce
-input.y:4.6-8: warning: rule useless in parser due to conflicts: id: '0'
+[[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+input.y:4.6-8: warning: rule useless in parser due to conflicts: id: '0' [-Wother]
]])
# Check the contents of the report.
]])
AT_BISON_CHECK([-o input.c input.y], 1, [],
-[input.y: conflicts: 1 shift/reduce
-input.y: error: expected 0 shift/reduce conflicts
-])
+[[input.y: error: shift/reduce conflicts: 1 found, 0 expected
+]])
AT_CLEANUP
]])
AT_BISON_CHECK([-o input.c input.y], 1, [],
-[input.y: conflicts: 1 shift/reduce
-input.y: error: expected 2 shift/reduce conflicts
-])
+[[input.y: error: shift/reduce conflicts: 1 found, 2 expected
+]])
AT_CLEANUP
]])
AT_BISON_CHECK([-o input.c input.y], 1, [],
-[input.y: conflicts: 1 reduce/reduce
-input.y: error: expected 0 reduce/reduce conflicts
-])
+[[input.y: error: reduce/reduce conflicts: 1 found, 0 expected
+]])
AT_CLEANUP
]])
AT_BISON_CHECK([-o input.c input.y], 0, [],
-[[input.y: conflicts: 4 shift/reduce
+[[input.y: warning: 4 shift/reduce conflicts [-Wconflicts-sr]
]])
AT_CLEANUP
]])
AT_BISON_CHECK([[--report=all input.y]], 0, [],
-[[input.y: conflicts: 1 shift/reduce, 1 reduce/reduce
-input.y:12.5-20: warning: rule useless in parser due to conflicts: resolved_conflict: 'a' unreachable1
-input.y:20.5-20: warning: rule useless in parser due to conflicts: unreachable1: 'a' unreachable2
-input.y:21.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */
-input.y:25.13: warning: rule useless in parser due to conflicts: unreachable2: /* empty */
-input.y:25.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */
-input.y:31.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a'
-input.y:32.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */
+[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
+input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+input.y:12.5-20: warning: rule useless in parser due to conflicts: resolved_conflict: 'a' unreachable1 [-Wother]
+input.y:20.5-20: warning: rule useless in parser due to conflicts: unreachable1: 'a' unreachable2 [-Wother]
+input.y:21.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */ [-Wother]
+input.y:25.13: warning: rule useless in parser due to conflicts: unreachable2: /* empty */ [-Wother]
+input.y:25.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */ [-Wother]
+input.y:31.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a' [-Wother]
+input.y:32.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */ [-Wother]
]])
AT_CHECK([[cat input.output]], 0,
]])
AT_DATA([[input-keep.y]],
-[[%define lr.keep-unreachable-states
+[[%define lr.keep-unreachable-state
]])
AT_CHECK([[cat input.y >> input-keep.y]])
AT_BISON_CHECK([[input-keep.y]], 0, [],
-[[input-keep.y: conflicts: 2 shift/reduce, 2 reduce/reduce
-input-keep.y:22.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */
-input-keep.y:26.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */
-input-keep.y:32.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a'
-input-keep.y:33.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */
+[[input-keep.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr]
+input-keep.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
+input-keep.y:22.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */ [-Wother]
+input-keep.y:26.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */ [-Wother]
+input-keep.y:32.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a' [-Wother]
+input-keep.y:33.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */ [-Wother]
]])
AT_CLEANUP
AT_CLEANUP
-## --------------------------------- ##
-## -W versus %expect and %expect-rr ##
-## --------------------------------- ##
+## -------------------- ##
+## %expect-rr non GLR. ##
+## -------------------- ##
+
+AT_SETUP([[%expect-rr non GLR]])
+
+AT_DATA([[1.y]],
+[[%expect-rr 0
+%%
+exp: 'a'
+]])
+
+AT_BISON_CHECK([[1.y]], [[0]], [],
+[[1.y: warning: %expect-rr applies only to GLR parsers [-Wother]
+]])
+
+AT_DATA([[2.y]],
+[[%expect-rr 1
+%%
+exp: 'a' | 'a';
+]])
+
+AT_BISON_CHECK([[2.y]], [[0]], [],
+[[2.y: warning: %expect-rr applies only to GLR parsers [-Wother]
+2.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+2.y:3.12-14: warning: rule useless in parser due to conflicts: exp: 'a' [-Wother]
+]])
+
+AT_CLEANUP
+
+
+## ---------------------------------- ##
+## -W versus %expect and %expect-rr. ##
+## ---------------------------------- ##
AT_SETUP([[-W versus %expect and %expect-rr]])
]])
AT_BISON_CHECK([[sr-rr.y]], [[0]], [[]],
-[[sr-rr.y: conflicts: 1 shift/reduce, 1 reduce/reduce
+[[sr-rr.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
+sr-rr.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
]])
AT_BISON_CHECK([[-Wno-conflicts-sr sr-rr.y]], [[0]], [[]],
-[[sr-rr.y: conflicts: 1 reduce/reduce
+[[sr-rr.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
]])
AT_BISON_CHECK([[-Wno-conflicts-rr sr-rr.y]], [[0]], [[]],
-[[sr-rr.y: conflicts: 1 shift/reduce
+[[sr-rr.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
]])
-[for gram in sr-rr sr rr; do
+[
+# This is piece of code is rather complex for a simple task: try every
+# combinaison of (0 or 1 real SR) x (0 or 1 real RR) x (don't %expect
+# or %expect 0, 1, or 2 SR) x (don't %expect-rr or %expect-rr 0, 1, or 2
+# RR).
+
+# Number and types of genuine conflicts in the grammar.
+for gram in sr-rr sr rr; do
+ # Number of expected s/r conflicts.
for sr_exp_i in '' 0 1 2; do
+ # Number of expected r/r conflicts.
for rr_exp_i in '' 0 1 2; do
test -z "$sr_exp_i" && test -z "$rr_exp_i" && continue
echo "$directives" > $file
cat $gram.y >> $file
- # Count actual conflicts.
- conflicts=
- sr_count=0
- rr_count=0
- if test $gram = sr || test $gram = sr-rr; then
- conflicts="1 shift/reduce"
- sr_count=1
- fi
- if test $gram = rr || test $gram = sr-rr; then
- if test -n "$conflicts"; then
- conflicts="$conflicts, "
- fi
- conflicts="${conflicts}1 reduce/reduce"
- rr_count=1
- fi
+ # Number of found conflicts.
+ case $gram in
+ (sr) sr_count=1; rr_count=0;;
+ (rr) sr_count=0; rr_count=1;;
+ (sr-rr) sr_count=1; rr_count=1;;
+ esac
+
+ # Update number of expected conflicts: if %expect is given then
+ # %expect-rr defaults to 0, and vice-versa. Leave empty if
+ # nothing expected.
+ case $sr_exp_i:$rr_exp_i in
+ ?:) rr_exp_i=0;;
+ :?) sr_exp_i=0;;
+ esac
# Run tests.
if test $sr_count -eq $sr_exp && test $rr_count -eq $rr_exp; then
]AT_BISON_CHECK([[-Wnone $file]])[
]AT_BISON_CHECK([[-Werror $file]])[
else
- echo "$file: conflicts: $conflicts" > experr
- if test $sr_count -ne $sr_exp; then
- if test $sr_exp -ne 1; then s=s; else s= ; fi
- echo "$file: error: expected $sr_exp shift/reduce conflict$s" >> experr
- fi
- if test $rr_count -ne $rr_exp; then
- if test $rr_exp -ne 1; then s=s; else s= ; fi
- echo "$file: error: expected $rr_exp reduce/reduce conflict$s" >> experr
- fi
+ {
+ if test -z "$sr_exp_i" && test "$sr_count" -ne 0; then
+ echo "warning: $sr_count shift/reduce conflicts"
+ elif test "$sr_exp_i" -ne "$sr_count"; then
+ echo "error: shift/reduce conflicts: $sr_count found, $sr_exp_i expected"
+ fi
+ if test -z "$rr_exp_i" && test "$rr_count" -ne 0; then
+ echo "warning: $rr_count reduce/reduce conflicts"
+ elif test "$rr_exp_i" -ne "$rr_count"; then
+ echo "error: reduce/reduce conflicts: $rr_count found, $rr_exp_i expected"
+ fi
+ } | sed -e "s/^/$file: /" > experr
]AT_BISON_CHECK([[-Wnone $file]], [[1]], [[]], [[experr]])[
]AT_BISON_CHECK([[-Werror $file]], [[1]], [[]], [[experr]])[
fi
]],
[[
start
- : opt_nls program opt_nls
- ;
+ : opt_nls program opt_nls
+ ;
program
- : rule
- | program rule
- | error
- | program error
- | /* empty */
- ;
+ : rule
+ | program rule
+ | error
+ | program error
+ | /* empty */
+ ;
rule
- : LEX_BEGIN {} action
- | LEX_END {} action
- | LEX_BEGIN statement_term
- | LEX_END statement_term
- | pattern action
- | action
- | pattern statement_term
- | function_prologue function_body
- ;
+ : LEX_BEGIN {} action
+ | LEX_END {} action
+ | LEX_BEGIN statement_term
+ | LEX_END statement_term
+ | pattern action
+ | action
+ | pattern statement_term
+ | function_prologue function_body
+ ;
func_name
- : NAME
- | FUNC_CALL
- | lex_builtin
- ;
+ : NAME
+ | FUNC_CALL
+ | lex_builtin
+ ;
lex_builtin
- : LEX_BUILTIN
- | LEX_LENGTH
- ;
+ : LEX_BUILTIN
+ | LEX_LENGTH
+ ;
function_prologue
- : LEX_FUNCTION {} func_name '(' opt_param_list r_paren opt_nls
- ;
+ : LEX_FUNCTION {} func_name '(' opt_param_list r_paren opt_nls
+ ;
function_body
- : l_brace statements r_brace opt_semi opt_nls
- | l_brace r_brace opt_semi opt_nls
- ;
+ : l_brace statements r_brace opt_semi opt_nls
+ | l_brace r_brace opt_semi opt_nls
+ ;
pattern
- : exp
- | exp ',' exp
- ;
+ : exp
+ | exp ',' exp
+ ;
regexp
- /*
- * In this rule, want_regexp tells yylex that the next thing
- * is a regexp so it should read up to the closing slash.
- */
- : '/' {} REGEXP '/'
- ;
+ /*
+ * In this rule, want_regexp tells yylex that the next thing
+ * is a regexp so it should read up to the closing slash.
+ */
+ : '/' {} REGEXP '/'
+ ;
action
- : l_brace statements r_brace opt_semi opt_nls
- | l_brace r_brace opt_semi opt_nls
- ;
+ : l_brace statements r_brace opt_semi opt_nls
+ | l_brace r_brace opt_semi opt_nls
+ ;
statements
- : statement
- | statements statement
- | error
- | statements error
- ;
+ : statement
+ | statements statement
+ | error
+ | statements error
+ ;
statement_term
- : nls
- | semi opt_nls
- ;
+ : nls
+ | semi opt_nls
+ ;
statement
- : semi opt_nls
- | l_brace r_brace
- | l_brace statements r_brace
- | if_statement
- | LEX_WHILE '(' exp r_paren opt_nls statement
- | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls
- | LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement
- | LEX_FOR '(' opt_exp semi opt_nls exp semi opt_nls opt_exp r_paren opt_nls statement
- | LEX_FOR '(' opt_exp semi opt_nls semi opt_nls opt_exp r_paren opt_nls statement
- | LEX_BREAK statement_term
- | LEX_CONTINUE statement_term
- | print '(' expression_list r_paren output_redir statement_term
- | print opt_rexpression_list output_redir statement_term
- | LEX_NEXT statement_term
- | LEX_NEXTFILE statement_term
- | LEX_EXIT opt_exp statement_term
- | LEX_RETURN {} opt_exp statement_term
- | LEX_DELETE NAME '[' expression_list ']' statement_term
- | LEX_DELETE NAME statement_term
- | exp statement_term
- ;
+ : semi opt_nls
+ | l_brace r_brace
+ | l_brace statements r_brace
+ | if_statement
+ | LEX_WHILE '(' exp r_paren opt_nls statement
+ | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls
+ | LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement
+ | LEX_FOR '(' opt_exp semi opt_nls exp semi opt_nls opt_exp r_paren opt_nls statement
+ | LEX_FOR '(' opt_exp semi opt_nls semi opt_nls opt_exp r_paren opt_nls statement
+ | LEX_BREAK statement_term
+ | LEX_CONTINUE statement_term
+ | print '(' expression_list r_paren output_redir statement_term
+ | print opt_rexpression_list output_redir statement_term
+ | LEX_NEXT statement_term
+ | LEX_NEXTFILE statement_term
+ | LEX_EXIT opt_exp statement_term
+ | LEX_RETURN {} opt_exp statement_term
+ | LEX_DELETE NAME '[' expression_list ']' statement_term
+ | LEX_DELETE NAME statement_term
+ | exp statement_term
+ ;
print
- : LEX_PRINT
- | LEX_PRINTF
- ;
+ : LEX_PRINT
+ | LEX_PRINTF
+ ;
if_statement
- : LEX_IF '(' exp r_paren opt_nls statement
- | LEX_IF '(' exp r_paren opt_nls statement
- LEX_ELSE opt_nls statement
- ;
+ : LEX_IF '(' exp r_paren opt_nls statement
+ | LEX_IF '(' exp r_paren opt_nls statement
+ LEX_ELSE opt_nls statement
+ ;
nls
- : NEWLINE
- | nls NEWLINE
- ;
+ : NEWLINE
+ | nls NEWLINE
+ ;
opt_nls
- : /* empty */
- | nls
- ;
+ : /* empty */
+ | nls
+ ;
input_redir
- : /* empty */
- | '<' simp_exp
- ;
+ : /* empty */
+ | '<' simp_exp
+ ;
output_redir
- : /* empty */
- | '>' exp
- | APPEND_OP exp
- | '|' exp
- | TWOWAYIO exp
- ;
+ : /* empty */
+ | '>' exp
+ | APPEND_OP exp
+ | '|' exp
+ | TWOWAYIO exp
+ ;
opt_param_list
- : /* empty */
- | param_list
- ;
+ : /* empty */
+ | param_list
+ ;
param_list
- : NAME
- | param_list comma NAME
- | error
- | param_list error
- | param_list comma error
- ;
+ : NAME
+ | param_list comma NAME
+ | error
+ | param_list error
+ | param_list comma error
+ ;
/* optional expression, as in for loop */
opt_exp
- : /* empty */
- | exp
- ;
+ : /* empty */
+ | exp
+ ;
opt_rexpression_list
- : /* empty */
- | rexpression_list
- ;
+ : /* empty */
+ | rexpression_list
+ ;
rexpression_list
- : rexp
- | rexpression_list comma rexp
- | error
- | rexpression_list error
- | rexpression_list error rexp
- | rexpression_list comma error
- ;
+ : rexp
+ | rexpression_list comma rexp
+ | error
+ | rexpression_list error
+ | rexpression_list error rexp
+ | rexpression_list comma error
+ ;
opt_expression_list
- : /* empty */
- | expression_list
- ;
+ : /* empty */
+ | expression_list
+ ;
expression_list
- : exp
- | expression_list comma exp
- | error
- | expression_list error
- | expression_list error exp
- | expression_list comma error
- ;
+ : exp
+ | expression_list comma exp
+ | error
+ | expression_list error
+ | expression_list error exp
+ | expression_list comma error
+ ;
/* Expressions, not including the comma operator. */
-exp : variable ASSIGNOP {} exp
- | '(' expression_list r_paren LEX_IN NAME
- | exp '|' LEX_GETLINE opt_variable
- | exp TWOWAYIO LEX_GETLINE opt_variable
- | LEX_GETLINE opt_variable input_redir
- | exp LEX_AND exp
- | exp LEX_OR exp
- | exp MATCHOP exp
- | regexp
- | '!' regexp %prec UNARY
- | exp LEX_IN NAME
- | exp RELOP exp
- | exp '<' exp
- | exp '>' exp
- | exp '?' exp ':' exp
- | simp_exp
- | exp simp_exp %prec CONCAT_OP
- ;
+exp : variable ASSIGNOP {} exp
+ | '(' expression_list r_paren LEX_IN NAME
+ | exp '|' LEX_GETLINE opt_variable
+ | exp TWOWAYIO LEX_GETLINE opt_variable
+ | LEX_GETLINE opt_variable input_redir
+ | exp LEX_AND exp
+ | exp LEX_OR exp
+ | exp MATCHOP exp
+ | regexp
+ | '!' regexp %prec UNARY
+ | exp LEX_IN NAME
+ | exp RELOP exp
+ | exp '<' exp
+ | exp '>' exp
+ | exp '?' exp ':' exp
+ | simp_exp
+ | exp simp_exp %prec CONCAT_OP
+ ;
rexp
- : variable ASSIGNOP {} rexp
- | rexp LEX_AND rexp
- | rexp LEX_OR rexp
- | LEX_GETLINE opt_variable input_redir
- | regexp
- | '!' regexp %prec UNARY
- | rexp MATCHOP rexp
- | rexp LEX_IN NAME
- | rexp RELOP rexp
- | rexp '?' rexp ':' rexp
- | simp_exp
- | rexp simp_exp %prec CONCAT_OP
- ;
+ : variable ASSIGNOP {} rexp
+ | rexp LEX_AND rexp
+ | rexp LEX_OR rexp
+ | LEX_GETLINE opt_variable input_redir
+ | regexp
+ | '!' regexp %prec UNARY
+ | rexp MATCHOP rexp
+ | rexp LEX_IN NAME
+ | rexp RELOP rexp
+ | rexp '?' rexp ':' rexp
+ | simp_exp
+ | rexp simp_exp %prec CONCAT_OP
+ ;
simp_exp
- : non_post_simp_exp
- /* Binary operators in order of decreasing precedence. */
- | simp_exp '^' simp_exp
- | simp_exp '*' simp_exp
- | simp_exp '/' simp_exp
- | simp_exp '%' simp_exp
- | simp_exp '+' simp_exp
- | simp_exp '-' simp_exp
- | variable INCREMENT
- | variable DECREMENT
- ;
+ : non_post_simp_exp
+ /* Binary operators in order of decreasing precedence. */
+ | simp_exp '^' simp_exp
+ | simp_exp '*' simp_exp
+ | simp_exp '/' simp_exp
+ | simp_exp '%' simp_exp
+ | simp_exp '+' simp_exp
+ | simp_exp '-' simp_exp
+ | variable INCREMENT
+ | variable DECREMENT
+ ;
non_post_simp_exp
- : '!' simp_exp %prec UNARY
- | '(' exp r_paren
- | LEX_BUILTIN
- '(' opt_expression_list r_paren
- | LEX_LENGTH '(' opt_expression_list r_paren
- | LEX_LENGTH
- | FUNC_CALL '(' opt_expression_list r_paren
- | variable
- | INCREMENT variable
- | DECREMENT variable
- | YNUMBER
- | YSTRING
- | '-' simp_exp %prec UNARY
- | '+' simp_exp %prec UNARY
- ;
+ : '!' simp_exp %prec UNARY
+ | '(' exp r_paren
+ | LEX_BUILTIN
+ '(' opt_expression_list r_paren
+ | LEX_LENGTH '(' opt_expression_list r_paren
+ | LEX_LENGTH
+ | FUNC_CALL '(' opt_expression_list r_paren
+ | variable
+ | INCREMENT variable
+ | DECREMENT variable
+ | YNUMBER
+ | YSTRING
+ | '-' simp_exp %prec UNARY
+ | '+' simp_exp %prec UNARY
+ ;
opt_variable
- : /* empty */
- | variable
- ;
+ : /* empty */
+ | variable
+ ;
variable
- : NAME
- | NAME '[' expression_list ']'
- | '$' non_post_simp_exp
- ;
+ : NAME
+ | NAME '[' expression_list ']'
+ | '$' non_post_simp_exp
+ ;
l_brace
- : '{' opt_nls
- ;
+ : '{' opt_nls
+ ;
r_brace
- : '}' opt_nls
- ;
+ : '}' opt_nls
+ ;
r_paren
- : ')'
- ;
+ : ')'
+ ;
opt_semi
- : /* empty */
- | semi
- ;
+ : /* empty */
+ | semi
+ ;
semi
- : ';'
- ;
+ : ';'
+ ;
-comma : ',' opt_nls
- ;
+comma : ',' opt_nls
+ ;
]],
dnl INPUT
dnl BISON-STDERR
[AT_COND_CASE([[canonical LR]],
-[[input.y: conflicts: 265 shift/reduce]],
-[[input.y: conflicts: 65 shift/reduce]])[
+[[input.y: warning: 265 shift/reduce conflicts [-Wconflicts-sr]]],
+[[input.y: warning: 65 shift/reduce conflicts [-Wconflicts-sr]]])[
]],
dnl LAST-STATE
AT_TEST_EXISTING_GRAMMAR([[GNU Cim Grammar]],
[[
%token
- HACTIVATE HAFTER /*HAND*/ HARRAY HAT
- HBEFORE HBEGIN HBOOLEAN
- HCHARACTER HCLASS /*HCOMMENT*/ HCONC
- HDELAY HDO
- HELSE HEND HEQ /*HEQV*/ HEXTERNAL
- HFOR
- HGE HGO HGOTO HGT
- HHIDDEN
- HIF /*HIMP*/ HIN HINNER HINSPECT HINTEGER HIS
- HLABEL HLE HLONG HLT
- HNAME HNE HNEW HNONE /*HNOT*/ HNOTEXT
- /*HOR*/ HOTHERWISE
- HPRIOR HPROCEDURE HPROTECTED
- HQUA
- HREACTIVATE HREAL HREF
- HSHORT HSTEP HSWITCH
- HTEXT HTHEN HTHIS HTO
- HUNTIL
- HVALUE HVAR HVIRTUAL
- HWHEN HWHILE
-
- HASSIGNVALUE HASSIGNREF
- /*HDOT*/ HPAREXPSEPARATOR HLABELSEPARATOR HSTATEMENTSEPARATOR
- HBEGPAR HENDPAR
- HEQR HNER
- HADD HSUB HMUL HDIV HINTDIV HEXP
- HDOTDOTDOT
+ HACTIVATE HAFTER /*HAND*/ HARRAY HAT
+ HBEFORE HBEGIN HBOOLEAN
+ HCHARACTER HCLASS /*HCOMMENT*/ HCONC
+ HDELAY HDO
+ HELSE HEND HEQ /*HEQV*/ HEXTERNAL
+ HFOR
+ HGE HGO HGOTO HGT
+ HHIDDEN
+ HIF /*HIMP*/ HIN HINNER HINSPECT HINTEGER HIS
+ HLABEL HLE HLONG HLT
+ HNAME HNE HNEW HNONE /*HNOT*/ HNOTEXT
+ /*HOR*/ HOTHERWISE
+ HPRIOR HPROCEDURE HPROTECTED
+ HQUA
+ HREACTIVATE HREAL HREF
+ HSHORT HSTEP HSWITCH
+ HTEXT HTHEN HTHIS HTO
+ HUNTIL
+ HVALUE HVAR HVIRTUAL
+ HWHEN HWHILE
+
+ HASSIGNVALUE HASSIGNREF
+ /*HDOT*/ HPAREXPSEPARATOR HLABELSEPARATOR HSTATEMENTSEPARATOR
+ HBEGPAR HENDPAR
+ HEQR HNER
+ HADD HSUB HMUL HDIV HINTDIV HEXP
+ HDOTDOTDOT
%token HIDENTIFIER
%token HBOOLEANKONST HINTEGERKONST HCHARACTERKONST
%left HVALRELOPERATOR HREFRELOPERATOR HOBJRELOPERATOR
-%left HCONC
+%left HCONC
%left HTERMOPERATOR
%left UNEAR
[[
/* GRAMATIKK FOR PROGRAM MODULES */
MAIN_MODULE : {}
- MODULS
- | error HSTATEMENTSEPARATOR MBEE_DECLSTMS
- ;
-EXT_DECLARATION : HEXTERNAL
- MBEE_TYPE
- HPROCEDURE
- {}
- EXT_LIST
- |
- HEXTERNAL
- HIDENTIFIER
- HPROCEDURE
- {}
- HIDENTIFIER {}
- EXTERNAL_KIND_ITEM
- | HEXTERNAL
- HCLASS
- {}
- EXT_LIST
-
- ;
-EXTERNAL_KIND_ITEM: EXT_IDENT
- HOBJRELOPERATOR
- {}
- MBEE_TYPE HPROCEDURE
- HIDENTIFIER
- {}
- HEADING EMPTY_BLOCK
- {}
-/* |
- EXT_IDENT
- {}
- MBEE_REST_EXT_LIST
- ;
-MBEE_REST_EXT_LIST: /* EMPTY
- | HPAREXPSEPARATOR EXT_KIND_LIST
- ;
-EXT_KIND_LIST : EXT_KIND_ITEM
- | EXT_KIND_LIST HPAREXPSEPARATOR EXT_KIND_ITEM
- ;
-EXT_KIND_ITEM : HIDENTIFIER
- EXT_IDENT
- {}*/
- ;
-EMPTY_BLOCK : /*EMPT*/
- | HBEGIN HEND
- ;
-EXT_LIST : EXT_ITEM
- | EXT_LIST HPAREXPSEPARATOR EXT_ITEM
- ;
-EXT_ITEM : HIDENTIFIER
- EXT_IDENT
- ;
-EXT_IDENT : /* EMPTY */
- | HVALRELOPERATOR {}
- HTEXTKONST
- ;
+ MODULS
+ | error HSTATEMENTSEPARATOR MBEE_DECLSTMS
+ ;
+EXT_DECLARATION : HEXTERNAL
+ MBEE_TYPE
+ HPROCEDURE
+ {}
+ EXT_LIST
+ |
+ HEXTERNAL
+ HIDENTIFIER
+ HPROCEDURE
+ {}
+ HIDENTIFIER {}
+ EXTERNAL_KIND_ITEM
+ | HEXTERNAL
+ HCLASS
+ {}
+ EXT_LIST
+
+ ;
+EXTERNAL_KIND_ITEM: EXT_IDENT
+ HOBJRELOPERATOR
+ {}
+ MBEE_TYPE HPROCEDURE
+ HIDENTIFIER
+ {}
+ HEADING EMPTY_BLOCK
+ {}
+/* |
+ EXT_IDENT
+ {}
+ MBEE_REST_EXT_LIST
+ ;
+MBEE_REST_EXT_LIST: /* EMPTY
+ | HPAREXPSEPARATOR EXT_KIND_LIST
+ ;
+EXT_KIND_LIST : EXT_KIND_ITEM
+ | EXT_KIND_LIST HPAREXPSEPARATOR EXT_KIND_ITEM
+ ;
+EXT_KIND_ITEM : HIDENTIFIER
+ EXT_IDENT
+ {}*/
+ ;
+EMPTY_BLOCK : /*EMPT*/
+ | HBEGIN HEND
+ ;
+EXT_LIST : EXT_ITEM
+ | EXT_LIST HPAREXPSEPARATOR EXT_ITEM
+ ;
+EXT_ITEM : HIDENTIFIER
+ EXT_IDENT
+ ;
+EXT_IDENT : /* EMPTY */
+ | HVALRELOPERATOR {}
+ HTEXTKONST
+ ;
/* GRAMATIKK FOR TYPER */
NO_TYPE : /*EMPT*/
- ;
+ ;
MBEE_TYPE : NO_TYPE
- | TYPE
- ;
+ | TYPE
+ ;
TYPE : HREF HBEGPAR
- HIDENTIFIER
- {}
- HENDPAR
- | HTEXT
- | HBOOLEAN
- | HCHARACTER
- | HSHORT HINTEGER
- | HINTEGER
- | HREAL
- | HLONG HREAL
- ;
+ HIDENTIFIER
+ {}
+ HENDPAR
+ | HTEXT
+ | HBOOLEAN
+ | HCHARACTER
+ | HSHORT HINTEGER
+ | HINTEGER
+ | HREAL
+ | HLONG HREAL
+ ;
/* GRAMATIKK FOR DEL AV SETNINGER */
MBEE_ELSE_PART : /*EMPT*/
-/* | HELSE
- HIF
- EXPRESSION
- HTHEN {}
- BLOCK {}
- MBEE_ELSE_PART {}*/
- | HELSE {}
- BLOCK
- ;
+/* | HELSE
+ HIF
+ EXPRESSION
+ HTHEN {}
+ BLOCK {}
+ MBEE_ELSE_PART {}*/
+ | HELSE {}
+ BLOCK
+ ;
FOR_LIST : FOR_LIST_ELEMENT
- | FOR_LIST_ELEMENT
- HPAREXPSEPARATOR
- FOR_LIST
- ;
+ | FOR_LIST_ELEMENT
+ HPAREXPSEPARATOR
+ FOR_LIST
+ ;
FOR_LIST_ELEMENT: EXPRESSION
- MBEE_F_L_EL_R_PT
- ;
+ MBEE_F_L_EL_R_PT
+ ;
MBEE_F_L_EL_R_PT: /*EMPT*/
- | HWHILE
- EXPRESSION
- | HSTEP
- EXPRESSION
- HUNTIL
- EXPRESSION
- ;
+ | HWHILE
+ EXPRESSION
+ | HSTEP
+ EXPRESSION
+ HUNTIL
+ EXPRESSION
+ ;
GOTO : HGO
- HTO
- | HGOTO
- ;
+ HTO
+ | HGOTO
+ ;
CONN_STATE_R_PT : WHEN_CLAUSE_LIST
- | HDO {}
- BLOCK
- ;
+ | HDO {}
+ BLOCK
+ ;
WHEN_CLAUSE_LIST: HWHEN
- HIDENTIFIER
- HDO {}
- BLOCK
- | WHEN_CLAUSE_LIST
- HWHEN
- HIDENTIFIER
- HDO {}
- BLOCK
- ;
+ HIDENTIFIER
+ HDO {}
+ BLOCK
+ | WHEN_CLAUSE_LIST
+ HWHEN
+ HIDENTIFIER
+ HDO {}
+ BLOCK
+ ;
MBEE_OTWI_CLAUS : /*EMPT*/
- | HOTHERWISE {}
-
- BLOCK
- ;
-ACTIVATOR : HACTIVATE
- | HREACTIVATE
- ;
-SCHEDULE : /*EMPT*/
- | ATDELAY EXPRESSION {}
- PRIOR
- | BEFOREAFTER {}
- EXPRESSION
- ;
-ATDELAY : HAT
- | HDELAY
- ;
-BEFOREAFTER : HBEFORE
- | HAFTER
- ;
-PRIOR : /*EMPT*/
- | HPRIOR
- ;
+ | HOTHERWISE {}
+
+ BLOCK
+ ;
+ACTIVATOR : HACTIVATE
+ | HREACTIVATE
+ ;
+SCHEDULE : /*EMPT*/
+ | ATDELAY EXPRESSION {}
+ PRIOR
+ | BEFOREAFTER {}
+ EXPRESSION
+ ;
+ATDELAY : HAT
+ | HDELAY
+ ;
+BEFOREAFTER : HBEFORE
+ | HAFTER
+ ;
+PRIOR : /*EMPT*/
+ | HPRIOR
+ ;
/* GRAMATIKK FOR SETNINGER OG DEKLARASJONER */
MODULSTATEMENT : HWHILE
- EXPRESSION
- HDO {}
- BLOCK
- | HIF
- EXPRESSION
- HTHEN {}
- BLOCK {}
- MBEE_ELSE_PART
- | HFOR
- HIDENTIFIER
- HASSIGN {}
- FOR_LIST
- HDO {}
- BLOCK
- | GOTO
- EXPRESSION
- | HINSPECT
- EXPRESSION {}
- CONN_STATE_R_PT
- {}
- MBEE_OTWI_CLAUS
- | HINNER
- | HIDENTIFIER
- HLABELSEPARATOR
- {}
- DECLSTATEMENT
- | EXPRESSION_SIMP
- HBEGIN
- {}
- IMPORT_SPEC_MODULE
- {}
- MBEE_DECLSTMS
- HEND
- | EXPRESSION_SIMP HBEGIN error HSTATEMENTSEPARATOR
- MBEE_DECLSTMS HEND
- | EXPRESSION_SIMP HBEGIN error HEND
- | EXPRESSION_SIMP
- | ACTIVATOR EXPRESSION SCHEDULE
- | HBEGIN
- {}
- MBEE_DECLSTMS
- HEND
- | MBEE_TYPE HPROCEDURE
- HIDENTIFIER
- {}
- HEADING BLOCK
- | HIDENTIFIER
- HCLASS
- NO_TYPE
- {}
- IMPORT_SPEC_MODULE
- HIDENTIFIER
- {}
- HEADING
- BLOCK
- | HCLASS
- NO_TYPE
- HIDENTIFIER
- {}
- HEADING
- BLOCK
- | EXT_DECLARATION
- | /*EMPT*/
- ;
+ EXPRESSION
+ HDO {}
+ BLOCK
+ | HIF
+ EXPRESSION
+ HTHEN {}
+ BLOCK {}
+ MBEE_ELSE_PART
+ | HFOR
+ HIDENTIFIER
+ HASSIGN {}
+ FOR_LIST
+ HDO {}
+ BLOCK
+ | GOTO
+ EXPRESSION
+ | HINSPECT
+ EXPRESSION {}
+ CONN_STATE_R_PT
+ {}
+ MBEE_OTWI_CLAUS
+ | HINNER
+ | HIDENTIFIER
+ HLABELSEPARATOR
+ {}
+ DECLSTATEMENT
+ | EXPRESSION_SIMP
+ HBEGIN
+ {}
+ IMPORT_SPEC_MODULE
+ {}
+ MBEE_DECLSTMS
+ HEND
+ | EXPRESSION_SIMP HBEGIN error HSTATEMENTSEPARATOR
+ MBEE_DECLSTMS HEND
+ | EXPRESSION_SIMP HBEGIN error HEND
+ | EXPRESSION_SIMP
+ | ACTIVATOR EXPRESSION SCHEDULE
+ | HBEGIN
+ {}
+ MBEE_DECLSTMS
+ HEND
+ | MBEE_TYPE HPROCEDURE
+ HIDENTIFIER
+ {}
+ HEADING BLOCK
+ | HIDENTIFIER
+ HCLASS
+ NO_TYPE
+ {}
+ IMPORT_SPEC_MODULE
+ HIDENTIFIER
+ {}
+ HEADING
+ BLOCK
+ | HCLASS
+ NO_TYPE
+ HIDENTIFIER
+ {}
+ HEADING
+ BLOCK
+ | EXT_DECLARATION
+ | /*EMPT*/
+ ;
IMPORT_SPEC_MODULE:
- ;
-DECLSTATEMENT : MODULSTATEMENT
- | TYPE
- HIDENTIFIER
- MBEE_CONSTANT
- HPAREXPSEPARATOR
- {}
- IDENTIFIER_LISTC
- | TYPE
- HIDENTIFIER
- MBEE_CONSTANT
- | MBEE_TYPE
- HARRAY {}
- ARR_SEGMENT_LIST
- | HSWITCH
- HIDENTIFIER
- HASSIGN {}
- SWITCH_LIST
- ;
+ ;
+DECLSTATEMENT : MODULSTATEMENT
+ | TYPE
+ HIDENTIFIER
+ MBEE_CONSTANT
+ HPAREXPSEPARATOR
+ {}
+ IDENTIFIER_LISTC
+ | TYPE
+ HIDENTIFIER
+ MBEE_CONSTANT
+ | MBEE_TYPE
+ HARRAY {}
+ ARR_SEGMENT_LIST
+ | HSWITCH
+ HIDENTIFIER
+ HASSIGN {}
+ SWITCH_LIST
+ ;
BLOCK : DECLSTATEMENT
- | HBEGIN MBEE_DECLSTMS HEND
- | HBEGIN error HSTATEMENTSEPARATOR MBEE_DECLSTMS HEND
- | HBEGIN error HEND
- ;
+ | HBEGIN MBEE_DECLSTMS HEND
+ | HBEGIN error HSTATEMENTSEPARATOR MBEE_DECLSTMS HEND
+ | HBEGIN error HEND
+ ;
MBEE_DECLSTMS : MBEE_DECLSTMSU
- ;
+ ;
MBEE_DECLSTMSU : DECLSTATEMENT
- | MBEE_DECLSTMSU
- HSTATEMENTSEPARATOR
- DECLSTATEMENT
- ;
-MODULS : MODULSTATEMENT
- | MODULS HSTATEMENTSEPARATOR MODULSTATEMENT
- ;
+ | MBEE_DECLSTMSU
+ HSTATEMENTSEPARATOR
+ DECLSTATEMENT
+ ;
+MODULS : MODULSTATEMENT
+ | MODULS HSTATEMENTSEPARATOR MODULSTATEMENT
+ ;
/* GRAMATIKK FOR DEL AV DEKLARASJONER */
ARR_SEGMENT_LIST: ARR_SEGMENT
- | ARR_SEGMENT_LIST
- HPAREXPSEPARATOR
- ARR_SEGMENT
- ;
-ARR_SEGMENT : ARRAY_SEGMENT
- HBEGPAR
- BAUND_PAIR_LIST HENDPAR
- ;
+ | ARR_SEGMENT_LIST
+ HPAREXPSEPARATOR
+ ARR_SEGMENT
+ ;
+ARR_SEGMENT : ARRAY_SEGMENT
+ HBEGPAR
+ BAUND_PAIR_LIST HENDPAR
+ ;
ARRAY_SEGMENT : ARRAY_SEGMENT_EL {}
- | ARRAY_SEGMENT_EL
- HPAREXPSEPARATOR
- ARRAY_SEGMENT
- ;
+ | ARRAY_SEGMENT_EL
+ HPAREXPSEPARATOR
+ ARRAY_SEGMENT
+ ;
ARRAY_SEGMENT_EL: HIDENTIFIER
- ;
+ ;
BAUND_PAIR_LIST : BAUND_PAIR
- | BAUND_PAIR
- HPAREXPSEPARATOR
- BAUND_PAIR_LIST
- ;
+ | BAUND_PAIR
+ HPAREXPSEPARATOR
+ BAUND_PAIR_LIST
+ ;
BAUND_PAIR : EXPRESSION
- HLABELSEPARATOR
- EXPRESSION
- ;
+ HLABELSEPARATOR
+ EXPRESSION
+ ;
SWITCH_LIST : EXPRESSION
- | EXPRESSION
- HPAREXPSEPARATOR
- SWITCH_LIST
- ;
+ | EXPRESSION
+ HPAREXPSEPARATOR
+ SWITCH_LIST
+ ;
HEADING : MBEE_FMAL_PAR_P HSTATEMENTSEPARATOR {}
- MBEE_MODE_PART {}
- MBEE_SPEC_PART {}
- MBEE_PROT_PART {}
- MBEE_VIRT_PART
- ;
+ MBEE_MODE_PART {}
+ MBEE_SPEC_PART {}
+ MBEE_PROT_PART {}
+ MBEE_VIRT_PART
+ ;
MBEE_FMAL_PAR_P : /*EMPT*/
- | FMAL_PAR_PART
- ;
+ | FMAL_PAR_PART
+ ;
FMAL_PAR_PART : HBEGPAR NO_TYPE
- MBEE_LISTV HENDPAR
- ;
+ MBEE_LISTV HENDPAR
+ ;
MBEE_LISTV : /*EMPT*/
- | LISTV
- ;
+ | LISTV
+ ;
LISTV : HIDENTIFIER
- | FPP_CATEG HDOTDOTDOT
- | HIDENTIFIER {}
- HPAREXPSEPARATOR LISTV
- | FPP_SPEC
- | FPP_SPEC
- HPAREXPSEPARATOR LISTV
- ;
+ | FPP_CATEG HDOTDOTDOT
+ | HIDENTIFIER {}
+ HPAREXPSEPARATOR LISTV
+ | FPP_SPEC
+ | FPP_SPEC
+ HPAREXPSEPARATOR LISTV
+ ;
FPP_HEADING : HBEGPAR NO_TYPE
- FPP_MBEE_LISTV HENDPAR
- ;
+ FPP_MBEE_LISTV HENDPAR
+ ;
FPP_MBEE_LISTV : /*EMPT*/
- | FPP_LISTV
- ;
-FPP_LISTV : FPP_CATEG HDOTDOTDOT
- | FPP_SPEC
- | FPP_SPEC
- HPAREXPSEPARATOR LISTV
- ;
+ | FPP_LISTV
+ ;
+FPP_LISTV : FPP_CATEG HDOTDOTDOT
+ | FPP_SPEC
+ | FPP_SPEC
+ HPAREXPSEPARATOR LISTV
+ ;
FPP_SPEC : FPP_CATEG SPECIFIER HIDENTIFIER
- | FPP_CATEG FPP_PROC_DECL_IN_SPEC
- ;
+ | FPP_CATEG FPP_PROC_DECL_IN_SPEC
+ ;
FPP_CATEG : HNAME HLABELSEPARATOR
- | HVALUE HLABELSEPARATOR
- | HVAR HLABELSEPARATOR
- | /*EMPT*/
- ;
-FPP_PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE
- HIDENTIFIER
- {}
- FPP_HEADING {} { /* Yes, two "final" actions. */ }
- ;
+ | HVALUE HLABELSEPARATOR
+ | HVAR HLABELSEPARATOR
+ | /*EMPT*/
+ ;
+FPP_PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE
+ HIDENTIFIER
+ {}
+ FPP_HEADING {} { /* Yes, two "final" actions. */ }
+ ;
IDENTIFIER_LISTV: HIDENTIFIER
- | HDOTDOTDOT
- | HIDENTIFIER {}
- HPAREXPSEPARATOR IDENTIFIER_LISTV
- ;
+ | HDOTDOTDOT
+ | HIDENTIFIER {}
+ HPAREXPSEPARATOR IDENTIFIER_LISTV
+ ;
MBEE_MODE_PART : /*EMPT*/
- | MODE_PART
- ;
+ | MODE_PART
+ ;
MODE_PART : NAME_PART
- | VALUE_PART
- | VAR_PART
- | NAME_PART VALUE_PART
- | VALUE_PART NAME_PART
- | NAME_PART VAR_PART
- | VAR_PART NAME_PART
- | VALUE_PART VAR_PART
- | VAR_PART VALUE_PART
- | VAR_PART NAME_PART VALUE_PART
- | NAME_PART VAR_PART VALUE_PART
- | NAME_PART VALUE_PART VAR_PART
- | VAR_PART VALUE_PART NAME_PART
- | VALUE_PART VAR_PART NAME_PART
- | VALUE_PART NAME_PART VAR_PART
- ;
+ | VALUE_PART
+ | VAR_PART
+ | NAME_PART VALUE_PART
+ | VALUE_PART NAME_PART
+ | NAME_PART VAR_PART
+ | VAR_PART NAME_PART
+ | VALUE_PART VAR_PART
+ | VAR_PART VALUE_PART
+ | VAR_PART NAME_PART VALUE_PART
+ | NAME_PART VAR_PART VALUE_PART
+ | NAME_PART VALUE_PART VAR_PART
+ | VAR_PART VALUE_PART NAME_PART
+ | VALUE_PART VAR_PART NAME_PART
+ | VALUE_PART NAME_PART VAR_PART
+ ;
NAME_PART : HNAME {}
- IDENTIFIER_LISTV
- HSTATEMENTSEPARATOR
- ;
+ IDENTIFIER_LISTV
+ HSTATEMENTSEPARATOR
+ ;
VAR_PART : HVAR {}
- IDENTIFIER_LISTV
- HSTATEMENTSEPARATOR
- ;
+ IDENTIFIER_LISTV
+ HSTATEMENTSEPARATOR
+ ;
VALUE_PART : HVALUE {}
- IDENTIFIER_LISTV HSTATEMENTSEPARATOR
- ;
+ IDENTIFIER_LISTV HSTATEMENTSEPARATOR
+ ;
MBEE_SPEC_PART : /*EMPT*/
- | SPEC_PART
- ;
+ | SPEC_PART
+ ;
SPEC_PART : ONE_SPEC
- | SPEC_PART ONE_SPEC
- ;
-ONE_SPEC : SPECIFIER IDENTIFIER_LIST HSTATEMENTSEPARATOR
- | NO_TYPE HPROCEDURE HIDENTIFIER HOBJRELOPERATOR
- {}
- PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR
- | FPP_PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR
- | MBEE_TYPE HPROCEDURE HIDENTIFIER HSTATEMENTSEPARATOR
- | MBEE_TYPE HPROCEDURE HIDENTIFIER HPAREXPSEPARATOR
- IDENTIFIER_LIST HSTATEMENTSEPARATOR
- ;
+ | SPEC_PART ONE_SPEC
+ ;
+ONE_SPEC : SPECIFIER IDENTIFIER_LIST HSTATEMENTSEPARATOR
+ | NO_TYPE HPROCEDURE HIDENTIFIER HOBJRELOPERATOR
+ {}
+ PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR
+ | FPP_PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR
+ | MBEE_TYPE HPROCEDURE HIDENTIFIER HSTATEMENTSEPARATOR
+ | MBEE_TYPE HPROCEDURE HIDENTIFIER HPAREXPSEPARATOR
+ IDENTIFIER_LIST HSTATEMENTSEPARATOR
+ ;
SPECIFIER : TYPE
- | MBEE_TYPE
- HARRAY
- | HLABEL
- | HSWITCH
- ;
-PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE
- HIDENTIFIER
- {}
- HEADING
- {}
- MBEE_BEGIN_END
- ;
-MBEE_BEGIN_END : /* EMPTY */
- | HBEGIN HEND
- ;
+ | MBEE_TYPE
+ HARRAY
+ | HLABEL
+ | HSWITCH
+ ;
+PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE
+ HIDENTIFIER
+ {}
+ HEADING
+ {}
+ MBEE_BEGIN_END
+ ;
+MBEE_BEGIN_END : /* EMPTY */
+ | HBEGIN HEND
+ ;
MBEE_PROT_PART : /*EMPT*/
- | PROTECTION_PART
- ;
+ | PROTECTION_PART
+ ;
PROTECTION_PART : PROT_SPECIFIER IDENTIFIER_LIST
- HSTATEMENTSEPARATOR
- | PROTECTION_PART PROT_SPECIFIER
- IDENTIFIER_LIST HSTATEMENTSEPARATOR
- ;
+ HSTATEMENTSEPARATOR
+ | PROTECTION_PART PROT_SPECIFIER
+ IDENTIFIER_LIST HSTATEMENTSEPARATOR
+ ;
PROT_SPECIFIER : HHIDDEN
- | HPROTECTED
- | HHIDDEN
- HPROTECTED
- | HPROTECTED
- HHIDDEN
- ;
+ | HPROTECTED
+ | HHIDDEN
+ HPROTECTED
+ | HPROTECTED
+ HHIDDEN
+ ;
MBEE_VIRT_PART : /*EMPT*/
- | VIRTUAL_PART
- ;
+ | VIRTUAL_PART
+ ;
VIRTUAL_PART : HVIRTUAL
- HLABELSEPARATOR
- MBEE_SPEC_PART
- ;
+ HLABELSEPARATOR
+ MBEE_SPEC_PART
+ ;
IDENTIFIER_LIST : HIDENTIFIER
- | IDENTIFIER_LIST HPAREXPSEPARATOR
- HIDENTIFIER
- ;
+ | IDENTIFIER_LIST HPAREXPSEPARATOR
+ HIDENTIFIER
+ ;
IDENTIFIER_LISTC: HIDENTIFIER
- MBEE_CONSTANT
- | IDENTIFIER_LISTC HPAREXPSEPARATOR
- HIDENTIFIER
- MBEE_CONSTANT
- ;
-MBEE_CONSTANT : /* EMPTY */
- | HVALRELOPERATOR
- {}
- EXPRESSION
- ;
+ MBEE_CONSTANT
+ | IDENTIFIER_LISTC HPAREXPSEPARATOR
+ HIDENTIFIER
+ MBEE_CONSTANT
+ ;
+MBEE_CONSTANT : /* EMPTY */
+ | HVALRELOPERATOR
+ {}
+ EXPRESSION
+ ;
/* GRAMATIKK FOR UTTRYKK */
EXPRESSION : EXPRESSION_SIMP
- | HIF
- EXPRESSION
- HTHEN
- EXPRESSION
- HELSE
- EXPRESSION
- ;
-EXPRESSION_SIMP : EXPRESSION_SIMP
- HASSIGN
- EXPRESSION
- |
-
- EXPRESSION_SIMP
- HCONC
- EXPRESSION_SIMP
- | EXPRESSION_SIMP HOR
- HELSE
- EXPRESSION_SIMP
- %prec HORELSE
- | EXPRESSION_SIMP HAND
- HTHEN
- EXPRESSION_SIMP
- %prec HANDTHEN
- | EXPRESSION_SIMP
- HEQV EXPRESSION_SIMP
- | EXPRESSION_SIMP
- HIMP EXPRESSION_SIMP
- | EXPRESSION_SIMP
- HOR EXPRESSION_SIMP
- | EXPRESSION_SIMP
- HAND EXPRESSION_SIMP
- | HNOT EXPRESSION_SIMP
- | EXPRESSION_SIMP
- HVALRELOPERATOR
- EXPRESSION_SIMP
- | EXPRESSION_SIMP
- HREFRELOPERATOR
- EXPRESSION_SIMP
- | EXPRESSION_SIMP
- HOBJRELOPERATOR
- EXPRESSION_SIMP
- | HTERMOPERATOR
- EXPRESSION_SIMP %prec UNEAR
- | EXPRESSION_SIMP
- HTERMOPERATOR
- EXPRESSION_SIMP
- | EXPRESSION_SIMP
- HFACTOROPERATOR
- EXPRESSION_SIMP
- | EXPRESSION_SIMP
- HPRIMARYOPERATOR
- EXPRESSION_SIMP
- | HBEGPAR
- EXPRESSION HENDPAR
- | HTEXTKONST
- | HCHARACTERKONST
- | HREALKONST
- | HINTEGERKONST
- | HBOOLEANKONST
- | HNONE
- | HIDENTIFIER
- {}
- MBEE_ARG_R_PT
- | HTHIS HIDENTIFIER
- | HNEW
- HIDENTIFIER
- ARG_R_PT
- | EXPRESSION_SIMP
- HDOT
- EXPRESSION_SIMP
- | EXPRESSION_SIMP
- HQUA HIDENTIFIER
- ;
+ | HIF
+ EXPRESSION
+ HTHEN
+ EXPRESSION
+ HELSE
+ EXPRESSION
+ ;
+EXPRESSION_SIMP : EXPRESSION_SIMP
+ HASSIGN
+ EXPRESSION
+ |
+
+ EXPRESSION_SIMP
+ HCONC
+ EXPRESSION_SIMP
+ | EXPRESSION_SIMP HOR
+ HELSE
+ EXPRESSION_SIMP
+ %prec HORELSE
+ | EXPRESSION_SIMP HAND
+ HTHEN
+ EXPRESSION_SIMP
+ %prec HANDTHEN
+ | EXPRESSION_SIMP
+ HEQV EXPRESSION_SIMP
+ | EXPRESSION_SIMP
+ HIMP EXPRESSION_SIMP
+ | EXPRESSION_SIMP
+ HOR EXPRESSION_SIMP
+ | EXPRESSION_SIMP
+ HAND EXPRESSION_SIMP
+ | HNOT EXPRESSION_SIMP
+ | EXPRESSION_SIMP
+ HVALRELOPERATOR
+ EXPRESSION_SIMP
+ | EXPRESSION_SIMP
+ HREFRELOPERATOR
+ EXPRESSION_SIMP
+ | EXPRESSION_SIMP
+ HOBJRELOPERATOR
+ EXPRESSION_SIMP
+ | HTERMOPERATOR
+ EXPRESSION_SIMP %prec UNEAR
+ | EXPRESSION_SIMP
+ HTERMOPERATOR
+ EXPRESSION_SIMP
+ | EXPRESSION_SIMP
+ HFACTOROPERATOR
+ EXPRESSION_SIMP
+ | EXPRESSION_SIMP
+ HPRIMARYOPERATOR
+ EXPRESSION_SIMP
+ | HBEGPAR
+ EXPRESSION HENDPAR
+ | HTEXTKONST
+ | HCHARACTERKONST
+ | HREALKONST
+ | HINTEGERKONST
+ | HBOOLEANKONST
+ | HNONE
+ | HIDENTIFIER
+ {}
+ MBEE_ARG_R_PT
+ | HTHIS HIDENTIFIER
+ | HNEW
+ HIDENTIFIER
+ ARG_R_PT
+ | EXPRESSION_SIMP
+ HDOT
+ EXPRESSION_SIMP
+ | EXPRESSION_SIMP
+ HQUA HIDENTIFIER
+ ;
ARG_R_PT : /*EMPTY*/
- | HBEGPAR
- ARGUMENT_LIST HENDPAR
- ;
+ | HBEGPAR
+ ARGUMENT_LIST HENDPAR
+ ;
MBEE_ARG_R_PT : /*EMPTY*/
- | HBEGPAR
- ARGUMENT_LIST HENDPAR
- ;
+ | HBEGPAR
+ ARGUMENT_LIST HENDPAR
+ ;
ARGUMENT_LIST : EXPRESSION
- | EXPRESSION
- HPAREXPSEPARATOR
- ARGUMENT_LIST
- ;
+ | EXPRESSION
+ HPAREXPSEPARATOR
+ ARGUMENT_LIST
+ ;
]],
dnl INPUT
dnl BISON-STDERR
[AT_COND_CASE([[canonical LR]],
-[[input.y: conflicts: 1876 shift/reduce, 144 reduce/reduce]],
-[[input.y: conflicts: 78 shift/reduce, 10 reduce/reduce]])[
+[[input.y: warning: 1876 shift/reduce conflicts [-Wconflicts-sr]
+input.y: warning: 144 reduce/reduce conflicts [-Wconflicts-rr]]],
+[[input.y: warning: 78 shift/reduce conflicts [-Wconflicts-sr]
+input.y: warning: 10 reduce/reduce conflicts [-Wconflicts-rr]]])[
]],
dnl LAST-STATE
]],
[[
top:
- optional_separator
- | element_list
- ;
+ optional_separator
+ | element_list
+ ;
element_list:
- optional_separator middle_element_list optional_separator
- ;
+ optional_separator middle_element_list optional_separator
+ ;
middle_element_list:
- element
- | middle_element_list separator element
- ;
+ element
+ | middle_element_list separator element
+ ;
optional_separator:
- /* empty */
- | separator
- ;
+ /* empty */
+ | separator
+ ;
separator:
- ';'
- | separator ';'
- ;
+ ';'
+ | separator ';'
+ ;
placeless_element:
- VARIABLE '=' any_expr
- | VARIABLE ':' '=' any_expr
- | UP
- | DOWN
- | LEFT
- | RIGHT
- | COMMAND_LINE
- | COMMAND print_args
- | PRINT print_args
- | SH
- {}
- DELIMITED
- | COPY TEXT
- | COPY TEXT THROUGH
- {}
- DELIMITED
- {}
- until
- | COPY THROUGH
- {}
- DELIMITED
- {}
- until
- | FOR VARIABLE '=' expr TO expr optional_by DO
- {}
- DELIMITED
- | simple_if
- | simple_if ELSE
- {}
- DELIMITED
- | reset_variables
- | RESET
- ;
+ VARIABLE '=' any_expr
+ | VARIABLE ':' '=' any_expr
+ | UP
+ | DOWN
+ | LEFT
+ | RIGHT
+ | COMMAND_LINE
+ | COMMAND print_args
+ | PRINT print_args
+ | SH
+ {}
+ DELIMITED
+ | COPY TEXT
+ | COPY TEXT THROUGH
+ {}
+ DELIMITED
+ {}
+ until
+ | COPY THROUGH
+ {}
+ DELIMITED
+ {}
+ until
+ | FOR VARIABLE '=' expr TO expr optional_by DO
+ {}
+ DELIMITED
+ | simple_if
+ | simple_if ELSE
+ {}
+ DELIMITED
+ | reset_variables
+ | RESET
+ ;
reset_variables:
- RESET VARIABLE
- | reset_variables VARIABLE
- | reset_variables ',' VARIABLE
- ;
+ RESET VARIABLE
+ | reset_variables VARIABLE
+ | reset_variables ',' VARIABLE
+ ;
print_args:
- print_arg
- | print_args print_arg
- ;
+ print_arg
+ | print_args print_arg
+ ;
print_arg:
- expr %prec ','
- | text
- | position %prec ','
- ;
+ expr %prec ','
+ | text
+ | position %prec ','
+ ;
simple_if:
- IF any_expr THEN
- {}
- DELIMITED
- ;
+ IF any_expr THEN
+ {}
+ DELIMITED
+ ;
until:
- /* empty */
- | UNTIL TEXT
- ;
+ /* empty */
+ | UNTIL TEXT
+ ;
any_expr:
- expr
- | text_expr
- ;
+ expr
+ | text_expr
+ ;
text_expr:
- text EQUALEQUAL text
- | text NOTEQUAL text
- | text_expr ANDAND text_expr
- | text_expr ANDAND expr
- | expr ANDAND text_expr
- | text_expr OROR text_expr
- | text_expr OROR expr
- | expr OROR text_expr
- | '!' text_expr
- ;
+ text EQUALEQUAL text
+ | text NOTEQUAL text
+ | text_expr ANDAND text_expr
+ | text_expr ANDAND expr
+ | expr ANDAND text_expr
+ | text_expr OROR text_expr
+ | text_expr OROR expr
+ | expr OROR text_expr
+ | '!' text_expr
+ ;
optional_by:
- /* empty */
- | BY expr
- | BY '*' expr
- ;
+ /* empty */
+ | BY expr
+ | BY '*' expr
+ ;
element:
- object_spec
- | LABEL ':' optional_separator element
- | LABEL ':' optional_separator position_not_place
- | LABEL ':' optional_separator place
- | '{' {} element_list '}'
- {}
- optional_element
- | placeless_element
- ;
+ object_spec
+ | LABEL ':' optional_separator element
+ | LABEL ':' optional_separator position_not_place
+ | LABEL ':' optional_separator place
+ | '{' {} element_list '}'
+ {}
+ optional_element
+ | placeless_element
+ ;
optional_element:
- /* empty */
- | element
- ;
+ /* empty */
+ | element
+ ;
object_spec:
- BOX
- | CIRCLE
- | ELLIPSE
- | ARC
- | LINE
- | ARROW
- | MOVE
- | SPLINE
- | text %prec TEXT
- | PLOT expr
- | PLOT expr text
- | '['
- {}
- element_list ']'
- | object_spec HEIGHT expr
- | object_spec RADIUS expr
- | object_spec WIDTH expr
- | object_spec DIAMETER expr
- | object_spec expr %prec HEIGHT
- | object_spec UP
- | object_spec UP expr
- | object_spec DOWN
- | object_spec DOWN expr
- | object_spec RIGHT
- | object_spec RIGHT expr
- | object_spec LEFT
- | object_spec LEFT expr
- | object_spec FROM position
- | object_spec TO position
- | object_spec AT position
- | object_spec WITH path
- | object_spec WITH position %prec ','
- | object_spec BY expr_pair
- | object_spec THEN
- | object_spec SOLID
- | object_spec DOTTED
- | object_spec DOTTED expr
- | object_spec DASHED
- | object_spec DASHED expr
- | object_spec FILL
- | object_spec FILL expr
- | object_spec SHADED text
- | object_spec COLORED text
- | object_spec OUTLINED text
- | object_spec CHOP
- | object_spec CHOP expr
- | object_spec SAME
- | object_spec INVISIBLE
- | object_spec LEFT_ARROW_HEAD
- | object_spec RIGHT_ARROW_HEAD
- | object_spec DOUBLE_ARROW_HEAD
- | object_spec CW
- | object_spec CCW
- | object_spec text %prec TEXT
- | object_spec LJUST
- | object_spec RJUST
- | object_spec ABOVE
- | object_spec BELOW
- | object_spec THICKNESS expr
- | object_spec ALIGNED
- ;
+ BOX
+ | CIRCLE
+ | ELLIPSE
+ | ARC
+ | LINE
+ | ARROW
+ | MOVE
+ | SPLINE
+ | text %prec TEXT
+ | PLOT expr
+ | PLOT expr text
+ | '['
+ {}
+ element_list ']'
+ | object_spec HEIGHT expr
+ | object_spec RADIUS expr
+ | object_spec WIDTH expr
+ | object_spec DIAMETER expr
+ | object_spec expr %prec HEIGHT
+ | object_spec UP
+ | object_spec UP expr
+ | object_spec DOWN
+ | object_spec DOWN expr
+ | object_spec RIGHT
+ | object_spec RIGHT expr
+ | object_spec LEFT
+ | object_spec LEFT expr
+ | object_spec FROM position
+ | object_spec TO position
+ | object_spec AT position
+ | object_spec WITH path
+ | object_spec WITH position %prec ','
+ | object_spec BY expr_pair
+ | object_spec THEN
+ | object_spec SOLID
+ | object_spec DOTTED
+ | object_spec DOTTED expr
+ | object_spec DASHED
+ | object_spec DASHED expr
+ | object_spec FILL
+ | object_spec FILL expr
+ | object_spec SHADED text
+ | object_spec COLORED text
+ | object_spec OUTLINED text
+ | object_spec CHOP
+ | object_spec CHOP expr
+ | object_spec SAME
+ | object_spec INVISIBLE
+ | object_spec LEFT_ARROW_HEAD
+ | object_spec RIGHT_ARROW_HEAD
+ | object_spec DOUBLE_ARROW_HEAD
+ | object_spec CW
+ | object_spec CCW
+ | object_spec text %prec TEXT
+ | object_spec LJUST
+ | object_spec RJUST
+ | object_spec ABOVE
+ | object_spec BELOW
+ | object_spec THICKNESS expr
+ | object_spec ALIGNED
+ ;
text:
- TEXT
- | SPRINTF '(' TEXT sprintf_args ')'
- ;
+ TEXT
+ | SPRINTF '(' TEXT sprintf_args ')'
+ ;
sprintf_args:
- /* empty */
- | sprintf_args ',' expr
- ;
+ /* empty */
+ | sprintf_args ',' expr
+ ;
position:
- position_not_place
- | place
- ;
+ position_not_place
+ | place
+ ;
position_not_place:
- expr_pair
- | position '+' expr_pair
- | position '-' expr_pair
- | '(' position ',' position ')'
- | expr between position AND position
- | expr '<' position ',' position '>'
- ;
+ expr_pair
+ | position '+' expr_pair
+ | position '-' expr_pair
+ | '(' position ',' position ')'
+ | expr between position AND position
+ | expr '<' position ',' position '>'
+ ;
between:
- BETWEEN
- | OF THE WAY BETWEEN
- ;
+ BETWEEN
+ | OF THE WAY BETWEEN
+ ;
expr_pair:
- expr ',' expr
- | '(' expr_pair ')'
- ;
+ expr ',' expr
+ | '(' expr_pair ')'
+ ;
place:
- /* line at A left == line (at A) left */
- label %prec CHOP
- | label corner
- | corner label
- | corner OF label
- | HERE
- ;
+ /* line at A left == line (at A) left */
+ label %prec CHOP
+ | label corner
+ | corner label
+ | corner OF label
+ | HERE
+ ;
label:
- LABEL
- | nth_primitive
- | label '.' LABEL
- ;
+ LABEL
+ | nth_primitive
+ | label '.' LABEL
+ ;
ordinal:
- ORDINAL
- | '`' any_expr TH
- ;
+ ORDINAL
+ | '`' any_expr TH
+ ;
optional_ordinal_last:
- LAST
- | ordinal LAST
- ;
+ LAST
+ | ordinal LAST
+ ;
nth_primitive:
- ordinal object_type
- | optional_ordinal_last object_type
- ;
+ ordinal object_type
+ | optional_ordinal_last object_type
+ ;
object_type:
- BOX
- | CIRCLE
- | ELLIPSE
- | ARC
- | LINE
- | ARROW
- | SPLINE
- | '[' ']'
- | TEXT
- ;
+ BOX
+ | CIRCLE
+ | ELLIPSE
+ | ARC
+ | LINE
+ | ARROW
+ | SPLINE
+ | '[' ']'
+ | TEXT
+ ;
label_path:
- '.' LABEL
- | label_path '.' LABEL
- ;
+ '.' LABEL
+ | label_path '.' LABEL
+ ;
relative_path:
- corner %prec CHOP
- /* give this a lower precedence than LEFT and RIGHT so that
- [A: box] with .A left == [A: box] with (.A left) */
- | label_path %prec TEXT
- | label_path corner
- ;
+ corner %prec CHOP
+ /* give this a lower precedence than LEFT and RIGHT so that
+ [A: box] with .A left == [A: box] with (.A left) */
+ | label_path %prec TEXT
+ | label_path corner
+ ;
path:
- relative_path
- | '(' relative_path ',' relative_path ')'
- {}
- /* The rest of these rules are a compatibility sop. */
- | ORDINAL LAST object_type relative_path
- | LAST object_type relative_path
- | ORDINAL object_type relative_path
- | LABEL relative_path
- ;
+ relative_path
+ | '(' relative_path ',' relative_path ')'
+ {}
+ /* The rest of these rules are a compatibility sop. */
+ | ORDINAL LAST object_type relative_path
+ | LAST object_type relative_path
+ | ORDINAL object_type relative_path
+ | LABEL relative_path
+ ;
corner:
- DOT_N
- | DOT_E
- | DOT_W
- | DOT_S
- | DOT_NE
- | DOT_SE
- | DOT_NW
- | DOT_SW
- | DOT_C
- | DOT_START
- | DOT_END
- | TOP
- | BOTTOM
- | LEFT
- | RIGHT
- | UPPER LEFT
- | LOWER LEFT
- | UPPER RIGHT
- | LOWER RIGHT
- | LEFT_CORNER
- | RIGHT_CORNER
- | UPPER LEFT_CORNER
- | LOWER LEFT_CORNER
- | UPPER RIGHT_CORNER
- | LOWER RIGHT_CORNER
- | NORTH
- | SOUTH
- | EAST
- | WEST
- | CENTER
- | START
- | END
- ;
+ DOT_N
+ | DOT_E
+ | DOT_W
+ | DOT_S
+ | DOT_NE
+ | DOT_SE
+ | DOT_NW
+ | DOT_SW
+ | DOT_C
+ | DOT_START
+ | DOT_END
+ | TOP
+ | BOTTOM
+ | LEFT
+ | RIGHT
+ | UPPER LEFT
+ | LOWER LEFT
+ | UPPER RIGHT
+ | LOWER RIGHT
+ | LEFT_CORNER
+ | RIGHT_CORNER
+ | UPPER LEFT_CORNER
+ | LOWER LEFT_CORNER
+ | UPPER RIGHT_CORNER
+ | LOWER RIGHT_CORNER
+ | NORTH
+ | SOUTH
+ | EAST
+ | WEST
+ | CENTER
+ | START
+ | END
+ ;
expr:
- VARIABLE
- | NUMBER
- | place DOT_X
- | place DOT_Y
- | place DOT_HT
- | place DOT_WID
- | place DOT_RAD
- | expr '+' expr
- | expr '-' expr
- | expr '*' expr
- | expr '/' expr
- | expr '%' expr
- | expr '^' expr
- | '-' expr %prec '!'
- | '(' any_expr ')'
- | SIN '(' any_expr ')'
- | COS '(' any_expr ')'
- | ATAN2 '(' any_expr ',' any_expr ')'
- | LOG '(' any_expr ')'
- | EXP '(' any_expr ')'
- | SQRT '(' any_expr ')'
- | K_MAX '(' any_expr ',' any_expr ')'
- | K_MIN '(' any_expr ',' any_expr ')'
- | INT '(' any_expr ')'
- | RAND '(' any_expr ')'
- | RAND '(' ')'
- | SRAND '(' any_expr ')'
- | expr '<' expr
- | expr LESSEQUAL expr
- | expr '>' expr
- | expr GREATEREQUAL expr
- | expr EQUALEQUAL expr
- | expr NOTEQUAL expr
- | expr ANDAND expr
- | expr OROR expr
- | '!' expr
- ;
+ VARIABLE
+ | NUMBER
+ | place DOT_X
+ | place DOT_Y
+ | place DOT_HT
+ | place DOT_WID
+ | place DOT_RAD
+ | expr '+' expr
+ | expr '-' expr
+ | expr '*' expr
+ | expr '/' expr
+ | expr '%' expr
+ | expr '^' expr
+ | '-' expr %prec '!'
+ | '(' any_expr ')'
+ | SIN '(' any_expr ')'
+ | COS '(' any_expr ')'
+ | ATAN2 '(' any_expr ',' any_expr ')'
+ | LOG '(' any_expr ')'
+ | EXP '(' any_expr ')'
+ | SQRT '(' any_expr ')'
+ | K_MAX '(' any_expr ',' any_expr ')'
+ | K_MIN '(' any_expr ',' any_expr ')'
+ | INT '(' any_expr ')'
+ | RAND '(' any_expr ')'
+ | RAND '(' ')'
+ | SRAND '(' any_expr ')'
+ | expr '<' expr
+ | expr LESSEQUAL expr
+ | expr '>' expr
+ | expr GREATEREQUAL expr
+ | expr EQUALEQUAL expr
+ | expr NOTEQUAL expr
+ | expr ANDAND expr
+ | expr OROR expr
+ | '!' expr
+ ;
]],
dnl INPUT
[[VARIABLE, '=', LABEL, LEFT, DOT_X]],
dnl BISON-STDERR
-[[input.y:470.11-48: warning: rule useless in parser due to conflicts: path: ORDINAL LAST object_type relative_path
+[[input.y:470.11-48: warning: rule useless in parser due to conflicts: path: ORDINAL LAST object_type relative_path [-Wother]
]],
dnl LAST-STATE
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr1.c glr-regr1.y]], 0, [],
-[glr-regr1.y: conflicts: 1 shift/reduce
-])
+[[glr-regr1.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
+]])
AT_COMPILE([glr-regr1])
AT_PARSER_CHECK([[./glr-regr1 BPBPB]], 0,
[[E -> 'B'
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr2a.c glr-regr2a.y]], 0, [],
-[glr-regr2a.y: conflicts: 2 shift/reduce
-])
+[[glr-regr2a.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr]
+]])
AT_COMPILE([glr-regr2a])
AT_DATA([input1.txt],
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr3.c glr-regr3.y]], 0, [],
-[glr-regr3.y: conflicts: 1 shift/reduce, 1 reduce/reduce
-])
+[[glr-regr3.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
+glr-regr3.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr3])
AT_DATA([input.txt],
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr4.c glr-regr4.y]], 0, [],
-[glr-regr4.y: conflicts: 1 reduce/reduce
-])
+[[glr-regr4.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr4])
AT_PARSER_CHECK([[./glr-regr4]], 0,
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr5.c glr-regr5.y]], 0, [],
-[glr-regr5.y: conflicts: 1 reduce/reduce
-])
+[[glr-regr5.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr5])
AT_PARSER_CHECK([[./glr-regr5]], 0, [],
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr6.c glr-regr6.y]], 0, [],
-[glr-regr6.y: conflicts: 1 reduce/reduce
-])
+[[glr-regr6.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr6])
AT_PARSER_CHECK([[./glr-regr6]], 0,
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr7.c glr-regr7.y]], 0, [],
-[glr-regr7.y: conflicts: 2 reduce/reduce
-])
+[[glr-regr7.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr7])
AT_PARSER_CHECK([[./glr-regr7]], 2, [],
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr8.c glr-regr8.y]], 0, [],
-[glr-regr8.y: conflicts: 1 reduce/reduce
-])
+[[glr-regr8.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr8])
AT_PARSER_CHECK([[./glr-regr8]], 0,
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr9.c glr-regr9.y]], 0, [],
-[glr-regr9.y: conflicts: 1 reduce/reduce
-])
+[[glr-regr9.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr9])
AT_PARSER_CHECK([[./glr-regr9]], 0, [],
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr10.c glr-regr10.y]], 0, [],
-[glr-regr10.y: conflicts: 1 reduce/reduce
-])
+[[glr-regr10.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr10])
AT_PARSER_CHECK([[./glr-regr10]], 0, [], [])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr11.c glr-regr11.y]], 0, [],
-[glr-regr11.y: conflicts: 1 reduce/reduce
-])
+[[glr-regr11.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr11])
AT_PARSER_CHECK([[./glr-regr11]], 0, [], [])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr12.c glr-regr12.y]], 0, [],
-[glr-regr12.y: conflicts: 1 shift/reduce, 1 reduce/reduce
-])
+[[glr-regr12.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
+glr-regr12.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr12])
AT_PARSER_CHECK([[./glr-regr12]], 0, [], [])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr14.c glr-regr14.y]], 0, [],
-[glr-regr14.y: conflicts: 3 reduce/reduce
-])
+[[glr-regr14.y: warning: 3 reduce/reduce conflicts [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr14])
AT_PARSER_CHECK([[./glr-regr14]], 0,
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr15.c glr-regr15.y]], 0, [],
-[glr-regr15.y: conflicts: 2 reduce/reduce
-])
+[[glr-regr15.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr15])
AT_PARSER_CHECK([[./glr-regr15]], 0, [],
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr16.c glr-regr16.y]], 0, [],
-[glr-regr16.y: conflicts: 1 reduce/reduce
-])
+[[glr-regr16.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr16])
AT_PARSER_CHECK([[./glr-regr16]], 0, [],
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
-[glr-regr17.y: conflicts: 3 reduce/reduce
-])
+[[glr-regr17.y: warning: 3 reduce/reduce conflicts [-Wconflicts-rr]
+]])
AT_COMPILE([glr-regr17])
AT_PARSER_CHECK([[./glr-regr17]], 0, [],
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
-[glr-regr18.y:26.18-24: error: result type clash on merge function 'merge': <type2> != <type1>
+[[glr-regr18.y:26.18-24: error: result type clash on merge function 'merge': <type2> != <type1>
glr-regr18.y:25.18-24: previous declaration
glr-regr18.y:27.13-19: error: result type clash on merge function 'merge': <type3> != <type2>
glr-regr18.y:26.18-24: previous declaration
-])
+]])
AT_CLEANUP
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o input.c input.y]], 0, [],
-[input.y: conflicts: 1 reduce/reduce
-])
+[[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
AT_COMPILE([input])
AT_PARSER_CHECK([[./input]], 1, [],
AT_BISON_CHECK([input.y], [1], [],
[[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type
input.y:5.24-25: error: $2 of 'exp' has no declared type
-input.y:5.6-32: warning: type clash on default action: <bar> != <>
-input.y:6.6-8: warning: type clash on default action: <bar> != <>
-input.y:7.5: warning: empty rule for typed nonterminal, and no action
+input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother]
+input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother]
+input.y:7.5: warning: empty rule for typed nonterminal, and no action [-Wother]
]])
AT_CLEANUP
# --------------------------------
# Generate the token, type, and destructor
# declarations for the unused values tests.
-
m4_define([_AT_UNUSED_VALUES_DECLARATIONS],
[[[%token <integer> INT;
%type <integer> a b c d e f g h i j k l;
# AT_CHECK_UNUSED_VALUES(DECLARATIONS_AFTER, CHECK_MIDRULE_VALUES)
-# ------------------------------------------------------------------
-# Generate a grammar to test unused values,
-# compile it, run it. If DECLARATIONS_AFTER
-# is set, then the token, type, and destructor
-# declarations are generated after the rules
-# rather than before. If CHECK_MIDRULE_VALUES
-# is set, then --warnings=midrule-values is
-# set.
-
+# ----------------------------------------------------------------
+# Generate a grammar to test unused values, compile it, run it. If
+# DECLARATIONS_AFTER is set, then the token, type, and destructor
+# declarations are generated after the rules rather than before. If
+# CHECK_MIDRULE_VALUES is set, then --warnings=midrule-values is set.
m4_define([AT_CHECK_UNUSED_VALUES],
[AT_DATA([input.y],
m4_ifval($1, [
AT_BISON_CHECK(m4_ifval($2, [--warnings=midrule-values ])[-fcaret input.y],
[0], [],
-[[input.y:11.10-32: warning: unset value: $][$
+[[input.y:11.10-32: warning: unset value: $][$ [-Wother]
a: INT | INT { } INT { } INT { };
^^^^^^^^^^^^^^^^^^^^^^^
-input.y:11.10-12: warning: unused value: $][1
+input.y:11.10-12: warning: unused value: $][1 [-Wother]
a: INT | INT { } INT { } INT { };
^^^
-input.y:11.18-20: warning: unused value: $][3
+input.y:11.18-20: warning: unused value: $][3 [-Wother]
a: INT | INT { } INT { } INT { };
^^^
-input.y:11.26-28: warning: unused value: $][5
+input.y:11.26-28: warning: unused value: $][5 [-Wother]
a: INT | INT { } INT { } INT { };
^^^
-input.y:12.9: warning: empty rule for typed nonterminal, and no action
+input.y:12.9: warning: empty rule for typed nonterminal, and no action [-Wother]
b: INT | /* empty */;
^
-]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $][$
+]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $][$ [-Wmidrule-values]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^
-input.y:13.26-41: warning: unset value: $][$
+input.y:13.26-41: warning: unset value: $][$ [-Wmidrule-values]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^
-]]])[[input.y:13.10-62: warning: unset value: $][$
+]]])[[input.y:13.10-62: warning: unset value: $][$ [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-input.y:13.22-24: warning: unused value: $][3
+input.y:13.22-24: warning: unused value: $][3 [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^
-input.y:13.43-45: warning: unused value: $][5
+input.y:13.43-45: warning: unused value: $][5 [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^
-]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $][$
+]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $][$ [-Wmidrule-values]
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^
-]]])[[input.y:14.10-49: warning: unset value: $][$
+]]])[[input.y:14.10-49: warning: unset value: $][$ [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-input.y:14.18-20: warning: unused value: $][3
+input.y:14.18-20: warning: unused value: $][3 [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^
-input.y:14.30-32: warning: unused value: $][5
+input.y:14.30-32: warning: unused value: $][5 [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^
-input.y:15.10-37: warning: unset value: $][$
+input.y:15.10-37: warning: unset value: $][$ [-Wother]
e: INT | INT { } INT { } INT { $][1; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-input.y:15.18-20: warning: unused value: $][3
+input.y:15.18-20: warning: unused value: $][3 [-Wother]
e: INT | INT { } INT { } INT { $][1; };
^^^
-input.y:15.27-29: warning: unused value: $][5
+input.y:15.27-29: warning: unused value: $][5 [-Wother]
e: INT | INT { } INT { } INT { $][1; };
^^^
-input.y:17.10-58: warning: unset value: $][$
+input.y:17.10-58: warning: unset value: $][$ [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-input.y:17.10-12: warning: unused value: $][1
+input.y:17.10-12: warning: unused value: $][1 [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^
-]]m4_ifval($2, [[[input.y:17.14-29: warning: unused value: $][2
+]]m4_ifval($2, [[[input.y:17.14-29: warning: unused value: $][2 [-Wmidrule-values]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^
-]]])[[input.y:17.31-33: warning: unused value: $][3
+]]])[[input.y:17.31-33: warning: unused value: $][3 [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^
-]]m4_ifval($2, [[[input.y:17.35-50: warning: unused value: $][4
+]]m4_ifval($2, [[[input.y:17.35-50: warning: unused value: $][4 [-Wmidrule-values]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^
-]]])[[input.y:17.52-54: warning: unused value: $][5
+]]])[[input.y:17.52-54: warning: unused value: $][5 [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^
-input.y:18.10-72: warning: unset value: $][$
+input.y:18.10-72: warning: unset value: $][$ [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-input.y:18.10-12: warning: unused value: $][1
+input.y:18.10-12: warning: unused value: $][1 [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^
-input.y:18.31-33: warning: unused value: $][3
+input.y:18.31-33: warning: unused value: $][3 [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^
-]]m4_ifval($2, [[[input.y:18.35-64: warning: unused value: $][4
+]]m4_ifval($2, [[[input.y:18.35-64: warning: unused value: $][4 [-Wmidrule-values]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-]]])[[input.y:18.66-68: warning: unused value: $][5
+]]])[[input.y:18.66-68: warning: unused value: $][5 [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^
-]]m4_ifval($2, [[[input.y:20.18-37: warning: unused value: $][3
+]]m4_ifval($2, [[[input.y:20.18-37: warning: unused value: $][3 [-Wmidrule-values]
j: INT | INT INT { $<integer>$ = 1; } { $][$ = $][1 + $][2; };
^^^^^^^^^^^^^^^^^^^^
-]]])[[input.y:21.10-68: warning: unset value: $][$
+]]])[[input.y:21.10-68: warning: unset value: $][$ [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-input.y:21.10-12: warning: unused value: $][1
+input.y:21.10-12: warning: unused value: $][1 [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^
-input.y:21.14-16: warning: unused value: $][2
+input.y:21.14-16: warning: unused value: $][2 [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^
-]]m4_ifval($2, [[[input.y:21.35-64: warning: unused value: $][4
+]]m4_ifval($2, [[[input.y:21.35-64: warning: unused value: $][4 [-Wmidrule-values]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]]]))
]])
AT_BISON_CHECK([input.y], [1], [],
-[[input.y:1.13-29: error: redeclaration for default tagged %destructor
+[[input.y:1.13-29: error: %destructor redeclaration for <*>
input.y:1.13-29: previous declaration
-input.y:2.10-24: error: redeclaration for default tagged %printer
+input.y:2.10-24: error: %printer redeclaration for <*>
input.y:2.10-24: previous declaration
-input.y:4.13-29: error: redeclaration for default tagged %destructor
+input.y:4.13-29: error: %destructor redeclaration for <*>
input.y:1.13-29: previous declaration
-input.y:5.10-24: error: redeclaration for default tagged %printer
+input.y:5.10-24: error: %printer redeclaration for <*>
input.y:2.10-24: previous declaration
-input.y:7.13-29: error: redeclaration for default tagless %destructor
+input.y:7.13-29: error: %destructor redeclaration for <>
input.y:7.13-29: previous declaration
-input.y:8.10-24: error: redeclaration for default tagless %printer
+input.y:8.10-24: error: %printer redeclaration for <>
input.y:8.10-24: previous declaration
-input.y:10.13-29: error: redeclaration for default tagless %destructor
+input.y:10.13-29: error: %destructor redeclaration for <>
input.y:7.13-29: previous declaration
-input.y:11.10-24: error: redeclaration for default tagless %printer
+input.y:11.10-24: error: %printer redeclaration for <>
input.y:8.10-24: previous declaration
-input.y:17.13-29: error: redeclaration for default tagged %destructor
+input.y:17.13-29: error: %destructor redeclaration for <*>
input.y:4.13-29: previous declaration
-input.y:18.10-24: error: redeclaration for default tagged %printer
+input.y:18.10-24: error: %printer redeclaration for <*>
input.y:5.10-24: previous declaration
-input.y:20.13-29: error: redeclaration for default tagless %destructor
+input.y:20.13-29: error: %destructor redeclaration for <>
input.y:10.13-29: previous declaration
-input.y:21.10-24: error: redeclaration for default tagless %printer
+input.y:21.10-24: error: %printer redeclaration for <>
input.y:11.10-24: previous declaration
]])
AT_CLEANUP
+## ------------------- ##
+## Undefined symbols. ##
+## ------------------- ##
+
+AT_SETUP([Undefined symbols])
+
+AT_DATA([[input.y]],
+[[%printer {} foo baz
+%destructor {} bar
+%type <foo> qux
+%%
+exp: bar;
+]])
+
+AT_BISON_CHECK([input.y], [1], [],
+[[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules
+input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
+input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
+input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother]
+]])
+
+AT_CLEANUP
+
+
+## ----------------------------------------------------- ##
+## Unassociated types used for a printer or destructor. ##
+## ----------------------------------------------------- ##
+
+AT_SETUP([Unassociated types used for a printer or destructor])
+
+AT_DATA([[input.y]],
+[[%token <type1> tag1
+%type <type2> tag2
+
+%printer { } <type1> <type3>
+%destructor { } <type2> <type4>
+
+%%
+
+exp: tag1 { $1; }
+ | tag2 { $1; }
+
+tag2: "a" { $$; }
+]])
+
+AT_BISON_CHECK([input.y], [0], [],
+[[input.y:4.22-28: warning: type <type3> is used, but is not associated to any symbol [-Wother]
+input.y:5.25-31: warning: type <type4> is used, but is not associated to any symbol [-Wother]
+]])
+
+AT_CLEANUP
+
+
+## --------------------------------- ##
+## Useless printers or destructors. ##
+## --------------------------------- ##
+
+AT_SETUP([Useless printers or destructors])
+
+# AT_TEST([INPUT], [STDERR])
+# --------------------------
+m4_pushdef([AT_TEST],
+[AT_DATA([[input.y]],
+[$1
+])
+AT_BISON_CHECK([input.y], [0], [], [$2
+])])
+
+AT_TEST([[%token <type1> token1
+%token <type2> token2
+%token <type3> token3
+%token <type4> token4
+%token <type5> token51 token52
+%token <type6> token61 token62
+%token <type7> token7
+
+%printer {} token1
+%destructor {} token2
+%printer {} token51
+%destructor {} token61
+
+%printer {} token7
+
+%printer {} <type1>
+%destructor {} <type2>
+%printer {} <type3>
+%destructor {} <type4>
+
+%printer {} <type5>
+%destructor {} <type6>
+
+%destructor {} <type7>
+
+%%
+exp: "a";]],
+[[input.y:16.13-19: warning: useless %printer for type <type1> [-Wother]
+input.y:17.16-22: warning: useless %destructor for type <type2> [-Wother]]])
+
+# If everybody is typed, <> is useless.
+AT_TEST([[%type <type> exp
+%token <type> a
+%printer {} <> <*>
+%%
+exp: a;]],
+[[input.y:3.13-14: warning: useless %printer for type <> [-Wother]]])
+
+# If nobody is typed, <*> is useless.
+AT_TEST([[%token a
+%printer {} <> <*>
+%%
+exp: a;]],
+[[input.y:2.16-18: warning: useless %printer for type <*> [-Wother]]])
+
+m4_popdef([AT_TEST])
+
+AT_CLEANUP
+
## ---------------------------------------- ##
## Unused values with default %destructor. ##
]])
AT_BISON_CHECK([input.y], [0], [],
-[[input.y:6.8-45: warning: unset value: $$
-input.y:6.12-14: warning: unused value: $2
-input.y:7.6-8: warning: unset value: $$
+[[input.y:6.8-45: warning: unset value: $$ [-Wother]
+input.y:6.12-14: warning: unused value: $2 [-Wother]
+input.y:7.6-8: warning: unset value: $$ [-Wother]
]])
AT_DATA([[input.y]],
]])
AT_BISON_CHECK([input.y], [0], [],
-[[input.y:6.23-28: warning: unused value: $4
-input.y:8.9-11: warning: unset value: $$
+[[input.y:6.23-28: warning: unused value: $4 [-Wother]
+input.y:8.9-11: warning: unset value: $$ [-Wother]
]])
AT_CLEANUP
]])
AT_BISON_CHECK([input.y], [0], [],
-[[input.y:6.8-22: warning: unset value: $$
-input.y:6.12-14: warning: unused value: $2
-input.y:7.6-8: warning: unset value: $$
+[[input.y:6.8-22: warning: unset value: $$ [-Wother]
+input.y:6.12-14: warning: unused value: $2 [-Wother]
+input.y:7.6-8: warning: unset value: $$ [-Wother]
]])
AT_CLEANUP
}
]])
-# Pacify Emacs' font-lock-mode: "
+# Pacify Emacs'font-lock-mode: "
AT_DATA([main.c],
[[typedef int value;
AT_SETUP([String aliases for character tokens])
-# Bison once thought a character token and its alias were different symbols
-# with the same user token number.
+# Bison once thought a character token and its alias were different
+# symbols with the same user token number.
AT_DATA_GRAMMAR([input.y],
[[%token 'a' "a"
AT_BISON_OPTION_POPDEFS
# POSIX Yacc accept periods, but not dashes.
-AT_BISON_CHECK([--yacc input.y], [1], [],
-[[input.y:9.8-16: POSIX Yacc forbids dashes in symbol names: WITH-DASH
-input.y:18.8-16: POSIX Yacc forbids dashes in symbol names: with-dash
+AT_BISON_CHECK([--yacc -Wno-error input.y], [], [],
+[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
+input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
]])
# So warn about them.
AT_BISON_CHECK([-Wyacc input.y], [], [],
-[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH
-input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash
+[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
+input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
]])
# Dashes are fine for GNU Bison.
AT_SETUP([Unclosed constructs])
-# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed constructs, so
-# they were prepended to whatever it STRING_GROW'ed next. It also threw them
-# away rather than returning them to the parser. The effect was confusing
-# subsequent error messages.
+# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed
+# constructs, so they were prepended to whatever it STRING_GROW'ed
+# next. It also threw them away rather than returning them to the
+# parser. The effect was confusing subsequent error messages.
AT_DATA([input.y],
[[%token A "a
AT_SETUP([%start after first rule])
-# Bison once complained that a %start after the first rule was a redeclaration
-# of the start symbol.
+# Bison once complained that a %start after the first rule was a
+# redeclaration of the start symbol.
AT_DATA([input.y],
[[%%
]])
AT_BISON_CHECK([[input.y]], [[0]], [],
-[[input.y:2.8-17: warning: token for %prec is not defined: PREC
+[[input.y:2.8-17: warning: token for %prec is not defined: PREC [-Wother]
]])
AT_CLEANUP
# Front-end.
AT_DATA([[input.y]],
-[[%define lr.default-reductions bogus
+[[%define lr.default-reduction bogus
%%
start: ;
]])
AT_BISON_CHECK([[input.y]], [[1]], [[]],
-[[input.y:1.9-29: error: invalid value for %define variable 'lr.default-reductions': 'bogus'
-input.y:1.9-29: accepted value: 'most'
-input.y:1.9-29: accepted value: 'consistent'
-input.y:1.9-29: accepted value: 'accepting'
+[[input.y:1.9-28: error: invalid value for %define variable 'lr.default-reduction': 'bogus'
+input.y:1.9-28: accepted value: 'most'
+input.y:1.9-28: accepted value: 'consistent'
+input.y:1.9-28: accepted value: 'accepting'
]])
# Back-end.
]])
AT_BISON_CHECK([[input.y]], [1], [],
[[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
-input.y:1.9-21: error: accepted value: 'pull'
-input.y:1.9-21: error: accepted value: 'push'
-input.y:1.9-21: error: accepted value: 'both'
+input.y:1.9-21: accepted value: 'pull'
+input.y:1.9-21: accepted value: 'push'
+input.y:1.9-21: accepted value: 'both'
]])
AT_CLEANUP
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
-input.y:1.9-21: error: accepted value: 'pull'
-input.y:1.9-21: error: accepted value: 'push'
-input.y:1.9-21: error: accepted value: 'both'
+[[input.y:1.9-21: warning: deprecated %define variable name: 'api.push_pull', use 'api.push-pull' [-Wdeprecated]
+input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
+input.y:1.9-21: accepted value: 'pull'
+input.y:1.9-21: accepted value: 'push'
+input.y:1.9-21: accepted value: 'both'
]])
AT_DATA([[input.y]],
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-states'
+[[input.y:1.9-34: warning: deprecated %define variable name: 'lr.keep_unreachable_states', use 'lr.keep-unreachable-state' [-Wdeprecated]
+input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-state'
+]])
+
+AT_DATA([[input.y]],
+[[%define namespace "foo"
+%define api.namespace "foo"
+%%
+start: ;
+]])
+AT_BISON_CHECK([[input.y]], [1], [],
+[[input.y:1.9-17: warning: deprecated %define variable name: 'namespace', use 'api.namespace' [-Wdeprecated]
+input.y:2.9-21: error: %define variable 'api.namespace' redefined
+input.y:1.9-17: previous definition
]])
AT_DATA([[input.y]],
AT_DATA([[input.y]],
[[%language "C++"
%defines
-%define namespace "]$1["
+%define api.namespace "]$1["
%%
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
[m4_foreach([b4_arg], m4_dquote(m4_shift($@)),
-[[input.y:3.9-17: error: ]b4_arg[
+[[input.y:3.9-21: error: ]b4_arg[
]])])
])
AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]])
AT_BISON_CHECK([empty.y], [1], [],
-[[empty.y:2.8-9: warning: empty character literal
-empty.y:3.8-4.0: warning: empty character literal
+[[empty.y:2.8-9: warning: empty character literal [-Wother]
+empty.y:3.8-4.0: warning: empty character literal [-Wother]
empty.y:3.8-4.0: error: missing "'" at end of line
-empty.y:4.8: warning: empty character literal
+empty.y:4.8: warning: empty character literal [-Wother]
empty.y:4.8: error: missing "'" at end of file
]])
AT_CHECK([[$PERL -e "print 'start: \'ab';" >> two.y || exit 77]])
AT_BISON_CHECK([two.y], [1], [],
-[[two.y:2.8-11: warning: extra characters in character literal
-two.y:3.8-4.0: warning: extra characters in character literal
+[[two.y:2.8-11: warning: extra characters in character literal [-Wother]
+two.y:3.8-4.0: warning: extra characters in character literal [-Wother]
two.y:3.8-4.0: error: missing "'" at end of line
-two.y:4.8-10: warning: extra characters in character literal
+two.y:4.8-10: warning: extra characters in character literal [-Wother]
two.y:4.8-10: error: missing "'" at end of file
]])
AT_CHECK([[$PERL -e "print 'start: \'abc';" >> three.y || exit 77]])
AT_BISON_CHECK([three.y], [1], [],
-[[three.y:2.8-12: warning: extra characters in character literal
-three.y:3.8-4.0: warning: extra characters in character literal
+[[three.y:2.8-12: warning: extra characters in character literal [-Wother]
+three.y:3.8-4.0: warning: extra characters in character literal [-Wother]
three.y:3.8-4.0: error: missing "'" at end of line
-three.y:4.8-11: warning: extra characters in character literal
+three.y:4.8-11: warning: extra characters in character literal [-Wother]
three.y:4.8-11: error: missing "'" at end of file
]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:2.9-12: error: invalid number after \-escape: 777
-input.y:2.8-13: warning: empty character literal
+input.y:2.8-13: warning: empty character literal [-Wother]
input.y:2.16-17: error: invalid number after \-escape: 0
-input.y:2.15-18: warning: empty character literal
+input.y:2.15-18: warning: empty character literal [-Wother]
input.y:2.21-25: error: invalid number after \-escape: xfff
-input.y:2.20-26: warning: empty character literal
+input.y:2.20-26: warning: empty character literal [-Wother]
input.y:2.29-31: error: invalid number after \-escape: x0
-input.y:2.28-32: warning: empty character literal
+input.y:2.28-32: warning: empty character literal [-Wother]
input.y:3.9-14: error: invalid number after \-escape: uffff
-input.y:3.8-15: warning: empty character literal
+input.y:3.8-15: warning: empty character literal [-Wother]
input.y:3.18-23: error: invalid number after \-escape: u0000
-input.y:3.17-24: warning: empty character literal
+input.y:3.17-24: warning: empty character literal [-Wother]
input.y:3.27-36: error: invalid number after \-escape: Uffffffff
-input.y:3.26-37: warning: empty character literal
+input.y:3.26-37: warning: empty character literal [-Wother]
input.y:3.40-49: error: invalid number after \-escape: U00000000
-input.y:3.39-50: warning: empty character literal
+input.y:3.39-50: warning: empty character literal [-Wother]
input.y:4.9-10: error: invalid character after \-escape: ' '
-input.y:4.8-11: warning: empty character literal
+input.y:4.8-11: warning: empty character literal [-Wother]
input.y:4.14-15: error: invalid character after \-escape: A
-input.y:4.13-16: warning: empty character literal
+input.y:4.13-16: warning: empty character literal [-Wother]
input.y:5.9-16: error: invalid character after \-escape: \t
input.y:5.17: error: invalid character after \-escape: \f
input.y:5.18: error: invalid character after \-escape: \0
# -Werror is not enabled by -Wall or equivalent.
AT_BISON_CHECK([[-Wall input.y]], [[0]], [[]],
-[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar
+[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
]])
AT_BISON_CHECK([[-W input.y]], [[0]], [[]],
-[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar
+[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
]])
AT_BISON_CHECK([[-Wno-none input.y]], [[0]], [[]],
-[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar
+[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
]])
# -Werror is not disabled by -Wnone or equivalent.
AT_BISON_CHECK([[-Werror,none,yacc input.y]], [[1]], [[]], [[stderr]])
AT_CHECK([[sed 's/^.*bison:/bison:/' stderr]], [[0]],
-[[bison: warnings being treated as errors
-input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar
+[[input.y:2.1-7: error: POSIX Yacc forbids dashes in symbol names: foo-bar [-Werror=yacc]
]])
[mv stderr experr]
AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]])
# check that the warnings are reported once, not three times.
AT_DATA_GRAMMAR([[input.y]],
-[[%token TOK
+[[%type <TYPE> exp
+%token <TYPE> TOK TOK2
%destructor { $%; @%; } <*> exp TOK;
%initial-action { $%; @%; };
%printer { $%; @%; } <*> exp TOK;
]])
AT_BISON_CHECK([[input.y]], 0, [],
-[[input.y:10.19: warning: stray '$'
-input.y:10.23: warning: stray '@'
-input.y:11.19: warning: stray '$'
-input.y:11.23: warning: stray '@'
-input.y:12.19: warning: stray '$'
-input.y:12.23: warning: stray '@'
-input.y:14.19: warning: stray '$'
-input.y:14.23: warning: stray '@'
+[[input.y:11.19: warning: stray '$' [-Wother]
+input.y:11.23: warning: stray '@' [-Wother]
+input.y:12.19: warning: stray '$' [-Wother]
+input.y:12.23: warning: stray '@' [-Wother]
+input.y:13.19: warning: stray '$' [-Wother]
+input.y:13.23: warning: stray '@' [-Wother]
+input.y:15.19: warning: stray '$' [-Wother]
+input.y:15.23: warning: stray '@' [-Wother]
]])
AT_CLEANUP
[AT_DATA([[input.y]],
[[%type <$1(DEAD %type)> exp
%token <$1(DEAD %token)> a
+%token b
%initial-action
{
$$;
};
%%
exp:
- a a[last]
+ a a[name] b
{
$$;
$][1;
$<$1(DEAD action 1)>$
$<$1(DEAD action 2)>1
- $<$1(DEAD action 3)>last
+ $<$1(DEAD action 3)>name
$<$1(DEAD action 4)>0
;
};
m4_popdef([AT_TEST])
AT_CLEANUP
+
+##----------------------- ##
+## Deprecated directives. ##
+## ---------------------- ##
+
+AT_SETUP([[Deprecated directives]])
+
+AT_KEYWORDS([[deprec]])
+
+AT_DATA_GRAMMAR([[input.y]],
+[[
+%default_prec
+%error_verbose
+%expect_rr 0
+%file-prefix = "foo"
+%file-prefix
+ =
+"bar"
+%fixed-output_files
+%fixed_output-files
+%fixed-output-files
+%name-prefix= "foo"
+%no-default_prec
+%no_default-prec
+%no_lines
+%output = "foo"
+%pure_parser
+%token_table
+%glr-parser
+%% exp : '0'
+]])
+
+AT_BISON_CHECK([[input.y]], [[0]], [[]],
+[[input.y:10.1-13: warning: deprecated directive: '%default_prec', use '%default-prec' [-Wdeprecated]
+input.y:11.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
+input.y:12.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
+input.y:13.1-14: warning: deprecated directive: '%file-prefix =', use '%file-prefix' [-Wdeprecated]
+input.y:14.1-15.2: warning: deprecated directive: '%file-prefix\n =', use '%file-prefix' [-Wdeprecated]
+input.y:17.1-19: warning: deprecated directive: '%fixed-output_files', use '%fixed-output-files' [-Wdeprecated]
+input.y:18.1-19: warning: deprecated directive: '%fixed_output-files', use '%fixed-output-files' [-Wdeprecated]
+input.y:20.1-13: warning: deprecated directive: '%name-prefix=', use '%name-prefix' [-Wdeprecated]
+input.y:21.1-16: warning: deprecated directive: '%no-default_prec', use '%no-default-prec' [-Wdeprecated]
+input.y:22.1-16: warning: deprecated directive: '%no_default-prec', use '%no-default-prec' [-Wdeprecated]
+input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wdeprecated]
+input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated]
+input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated]
+input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated]
+]])
+
+AT_CLEANUP
+
+## ---------------------------- ##
+## Unput's effect on locations. ##
+## ---------------------------- ##
+dnl When the scanner detects a deprecated construct, it unputs the correct
+dnl version, but it should *not* have any impact on the scanner cursor. If it
+dnl does, the locations of directives on the same line become erroneous.
+
+AT_SETUP([[Unput's effect on locations]])
+
+AT_KEYWORDS([[deprec]])
+
+AT_DATA_GRAMMAR([[input.y]],
+[[
+%glr-parser
+%expect_rr 42 %expect_rr 42
+ %expect_rr 42
+%error_verbose %error_verbose
+ %error_verbose
+%% exp: '0'
+]])
+
+AT_BISON_CHECK([[input.y]], [[1]], [[]],
+[[input.y:11.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
+input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
+input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
+input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
+input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
+input.y:13.11-21: error: %define variable 'parse.error' redefined
+input.y:13-6: previous definition
+input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
+input.y:14.11-21: error: %define variable 'parse.error' redefined
+input.y:13.11-21: previous definition
+]])
+
+AT_CLEANUP
+
+##--------------------------- ##
+## Non-deprecated directives. ##
+## -------------------------- ##
+
+AT_SETUP([[Non-deprecated directives]])
+
+AT_KEYWORDS([[deprec]])
+
+AT_DATA_GRAMMAR([[input.y]],
+[[
+%default-prec
+%error-verbose
+%expect-rr 42
+%file-prefix "foo"
+%file-prefix
+"bar"
+%fixed-output-files
+%name-prefix "foo"
+%no-default-prec
+%no-lines
+%output "foo"
+%pure-parser
+%token-table
+%% exp : '0'
+]])
+
+AT_BISON_CHECK([[input.y]], [[0]], [[]],
+[[input.y: warning: %expect-rr applies only to GLR parsers [-Wother]
+]])
+
+AT_CLEANUP
# _AT_DATA_JAVA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES])
-# ----------------------------------------------------------------------
+# ----------------------------------------------------
# Produce `calc.y'. Don't call this macro directly, because it contains
# some occurrences of `$1' etc. which will be interpreted by m4. So
# you should call it with $1, $2, and $3 as arguments, which is what
]AT_LOCATION_IF([[yypos = new Position (yypos.lineno (),
yypos.token () + 1);]])[
if (ttype == st.TT_EOF)
- return Calc.EOF;
+ return EOF;
else if (ttype == st.TT_EOL)
{
else if (ttype == st.TT_WORD)
{
yylval = new Integer (st.sval);
- return Calc.NUM;
+ return NUM;
}
else
])
# _AT_CHECK_JAVA_CALC([BISON-DIRECTIVES], [BISON-CODE])
-# -----------------------------------------------------------------------
+# -----------------------------------------------------
# Start a testing chunk which compiles `calc' grammar with
# BISON-DIRECTIVES, and performs several tests over the parser.
m4_define([_AT_CHECK_JAVA_CALC],
# AT_CHECK_JAVA_CALC([BISON-DIRECTIVES])
-# --------------------------------------------------------
+# --------------------------------------
# Start a testing chunk which compiles `calc' grammar with
# BISON-DIRECTIVES, and performs several tests over the parser.
# Run the test with and without %error-verbose.
%debug
%error-verbose
%token-table
+%token END "end"
$1
%%
-start: "end" {$2};
+start: END {$2};
%%
class m4_default([$3], [Position]) {}
])
# Check that YYParser.java contains exactly COUNT lines matching ^LINE$
# with grep.
m4_define([AT_CHECK_JAVA_GREP],
- [AT_CHECK([grep -c '^$1$' YYParser.java], [], [m4_default([$2], [1])
+ [AT_CHECK([grep -c '^$1$' YYParser.java], [], [m4_default([$2], [1])
])
])
-# ----------------------------------- #
-# Java parser class and package names #
-# ----------------------------------- #
+# ------------------------------------- #
+# Java parser class and package names. #
+# ------------------------------------- #
AT_SETUP([Java parser class and package names])
AT_CHECK_JAVA_MINIMAL([[%name-prefix "Prefix"]])
AT_CHECK_JAVA_GREP([[class PrefixParser]])
+AT_CHECK_JAVA_MINIMAL([[%define api.token.prefix "TOK_"]])
+AT_CHECK_JAVA_GREP([[.*TOK_END.*]])
+
AT_CHECK_JAVA_MINIMAL([[%define parser_class_name "ParserClassName"]])
AT_CHECK_JAVA_GREP([[class ParserClassName]])
AT_CLEANUP
-# --------------------------- #
-# Java parser class modifiers #
-# --------------------------- #
+# ----------------------------- #
+# Java parser class modifiers. #
+# ----------------------------- #
AT_SETUP([Java parser class modifiers])
%define strictfp]])
AT_CHECK_JAVA_GREP([[public final strictfp class YYParser]])
+# FIXME: Can't do a Java compile because javacomp.sh is configured for 1.3
+AT_CHECK_JAVA_MINIMAL([[
+%define annotations "/*@Deprecated @SupressWarnings(\"unchecked\") @SupressWarnings({\"unchecked\", \"deprecation\"}) @SupressWarnings(value={\"unchecked\", \"deprecation\"})*/"
+%define public]])
+AT_CHECK_JAVA_GREP([[/\*@Deprecated @SupressWarnings("unchecked") @SupressWarnings({"unchecked", "deprecation"}) @SupressWarnings(value={"unchecked", "deprecation"})\*/ public class YYParser]])
+
AT_CLEANUP
AT_SETUP([Java %parse-param and %lex-param])
AT_CHECK_JAVA_MINIMAL([])
-AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer) {]])
+AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer) *]])
AT_CHECK_JAVA_MINIMAL([[%parse-param {int parse_param1}]])
AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]])
-AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1) {]])
-AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]])
+AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1) *]])
+AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]])
AT_CHECK_JAVA_MINIMAL([[
%parse-param {int parse_param1}
%parse-param {long parse_param2}]])
AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]])
AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]])
-AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) {]])
-AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]])
-AT_CHECK_JAVA_GREP([[[ ]*this.parse_param2 = parse_param2;]])
+AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]])
+AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]])
+AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]])
AT_CHECK_JAVA_MINIMAL_W_LEXER([], [], [[return EOF;]])
-AT_CHECK_JAVA_GREP([[ *public YYParser () {]])
-AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer) {]])
+AT_CHECK_JAVA_GREP([[ *public YYParser () *]])
+AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer) *]])
AT_CHECK_JAVA_MINIMAL_W_LEXER([[%parse-param {int parse_param1}]],
- [], [[return EOF;]])
+ [], [[return EOF;]])
AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]])
-AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1) {]])
-AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1) {]])
-AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]], [2])
+AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1) *]])
+AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1) *]])
+AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2])
AT_CHECK_JAVA_MINIMAL_W_LEXER([[
%parse-param {int parse_param1}
%parse-param {long parse_param2}]],
- [], [[return EOF;]])
+ [], [[return EOF;]])
AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]])
AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]])
-AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1, *long parse_param2) {]])
-AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) {]])
-AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]], [2])
-AT_CHECK_JAVA_GREP([[[ ]*this.parse_param2 = parse_param2;]], [2])
+AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1, *long parse_param2) *]])
+AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]])
+AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2])
+AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]], [2])
AT_CHECK_JAVA_MINIMAL_W_LEXER([[%lex-param {char lex_param1}]],
- [], [[return EOF;]], [[YYLexer (char lex_param1) {}]])
-AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1) {]])
+ [], [[return EOF;]], [[YYLexer (char lex_param1) {}]])
+AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1) *]])
AT_CHECK_JAVA_GREP([[.* = new YYLexer *(lex_param1);]])
AT_CHECK_JAVA_MINIMAL_W_LEXER([[
%lex-param {char lex_param1}
%lex-param {short lex_param2}]],
- [], [[return EOF;]], [[YYLexer (char lex_param1, short lex_param2) {}]])
-AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2) {]])
+ [], [[return EOF;]], [[YYLexer (char lex_param1, short lex_param2) {}]])
+AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2) *]])
AT_CHECK_JAVA_GREP([[.* = new YYLexer *(lex_param1, *lex_param2);]])
AT_CHECK_JAVA_MINIMAL_W_LEXER([[
%parse-param {long parse_param2}
%lex-param {char lex_param1}
%lex-param {short lex_param2}]],
- [], [[return EOF;]], [[YYLexer (char lex_param1, short lex_param2) {}]])
+ [], [[return EOF;]], [[YYLexer (char lex_param1, short lex_param2) {}]])
AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]])
AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]])
-AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2, *int parse_param1, *long parse_param2) {]])
+AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2, *int parse_param1, *long parse_param2) *]])
AT_CHECK_JAVA_GREP([[.* = new YYLexer *(lex_param1, *lex_param2);]])
-AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) {]])
-AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]], [2])
-AT_CHECK_JAVA_GREP([[[ ]*this.parse_param2 = parse_param2;]], [2])
+AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]])
+AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2])
+AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]], [2])
AT_CLEANUP
AT_SETUP([Java throws specifications])
-# %define throws - 0 1 2
-# %define lex-throws - 0 1 2
-# %code lexer 0 1
+# %define throws - 0 1 2
+# %define lex-throws - 0 1 2
+# %code lexer 0 1
m4_define([AT_JT_lex_throws_define], [m4_case(AT_JT_lex_throws,
- -1, [],
- 0, [[%define lex_throws ""]],
- 1, [[%define lex_throws "InterruptedException"]],
- 2, [[%define lex_throws "InterruptedException, IllegalAccessException"]])])
+ -1, [],
+ 0, [[%define lex_throws ""]],
+ 1, [[%define lex_throws "InterruptedException"]],
+ 2, [[%define lex_throws "InterruptedException, IllegalAccessException"]])])
m4_define([AT_JT_yylex_throws], [m4_case(AT_JT_lex_throws,
- -1, [[ throws java.io.IOException]],
- 0, [],
- 1, [[ throws InterruptedException]],
- 2, [[ throws InterruptedException, IllegalAccessException]])])
+ -1, [[ throws java.io.IOException]],
+ 0, [],
+ 1, [[ throws InterruptedException]],
+ 2, [[ throws InterruptedException, IllegalAccessException]])])
m4_define([AT_JT_yylex_action], [m4_case(AT_JT_lex_throws,
- -1, [[throw new java.io.IOException();]],
- 0, [[return EOF;]],
- 1, [[throw new InterruptedException();]],
- 2, [[throw new IllegalAccessException();]])])
+ -1, [[throw new java.io.IOException();]],
+ 0, [[return EOF;]],
+ 1, [[throw new InterruptedException();]],
+ 2, [[throw new IllegalAccessException();]])])
m4_define([AT_JT_throws_define], [m4_case(AT_JT_throws,
- -1, [],
- 0, [[%define throws ""]],
- 1, [[%define throws "ClassNotFoundException"]],
- 2, [[%define throws "ClassNotFoundException, InstantiationException"]])])
+ -1, [],
+ 0, [[%define throws ""]],
+ 1, [[%define throws "ClassNotFoundException"]],
+ 2, [[%define throws "ClassNotFoundException, InstantiationException"]])])
m4_define([AT_JT_yyaction_throws], [m4_case(AT_JT_throws,
- -1, [],
- 0, [],
- 1, [[ throws ClassNotFoundException]],
- 2, [[ throws ClassNotFoundException, InstantiationException]])])
+ -1, [],
+ 0, [],
+ 1, [[ throws ClassNotFoundException]],
+ 2, [[ throws ClassNotFoundException, InstantiationException]])])
m4_define([AT_JT_parse_throws_2], [m4_case(AT_JT_throws,
- -1, [],
- 0, [],
- 1, [[, ClassNotFoundException]],
- 2, [[, ClassNotFoundException, InstantiationException]])])
+ -1, [],
+ 0, [],
+ 1, [[, ClassNotFoundException]],
+ 2, [[, ClassNotFoundException, InstantiationException]])])
m4_define([AT_JT_parse_throws],
- [m4_if(m4_quote(AT_JT_yylex_throws), [],
- [AT_JT_yyaction_throws],
- [AT_JT_yylex_throws[]AT_JT_parse_throws_2])])
+ [m4_if(m4_quote(AT_JT_yylex_throws), [],
+ [AT_JT_yyaction_throws],
+ [AT_JT_yylex_throws[]AT_JT_parse_throws_2])])
m4_define([AT_JT_initial_action], [m4_case(AT_JT_throws,
- -1, [],
- 0, [],
- 1, [[%initial-action {if (true) throw new ClassNotFoundException();}]],
- 2, [[%initial-action {if (true) throw new InstantiationException();}]])])
+ -1, [],
+ 0, [],
+ 1, [[%initial-action {if (true) throw new ClassNotFoundException();}]],
+ 2, [[%initial-action {if (true) throw new InstantiationException();}]])])
m4_define([AT_JT_parse_action], [m4_case(AT_JT_throws,
- -1, [],
- 0, [],
- 1, [[throw new ClassNotFoundException();]],
- 2, [[throw new ClassNotFoundException();]])])
+ -1, [],
+ 0, [],
+ 1, [[throw new ClassNotFoundException();]],
+ 2, [[throw new ClassNotFoundException();]])])
m4_for([AT_JT_lexer], 0, 1, 1,
[m4_for([AT_JT_lex_throws], -1, 2, 1,
[m4_for([AT_JT_throws], -1, 2, 1,
[m4_if(AT_JT_lexer, 0,
- [AT_CHECK_JAVA_MINIMAL([
+ [AT_CHECK_JAVA_MINIMAL([
AT_JT_throws_define
AT_JT_lex_throws_define
AT_JT_initial_action],
[AT_JT_parse_action])],
- [AT_CHECK_JAVA_MINIMAL_W_LEXER([
+ [AT_CHECK_JAVA_MINIMAL_W_LEXER([
AT_JT_throws_define
AT_JT_lex_throws_define
AT_JT_initial_action],
AT_CLEANUP
+# ------------------------------------- #
+# Java constructor init and init_throws #
+# ------------------------------------- #
+
+AT_SETUP([Java constructor init and init_throws])
+
+AT_CHECK_JAVA_MINIMAL([[
+%define extends "Thread"
+%code init { super("Test Thread"); if (true) throw new InterruptedException(); }
+%define init_throws "InterruptedException"
+%lex-param {int lex_param}]])
+AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedException();' YYParser.java]])
+
+AT_CHECK_JAVA_MINIMAL_W_LEXER([[
+%define extends "Thread"
+%code init { super("Test Thread"); if (true) throw new InterruptedException(); }
+%define init_throws "InterruptedException"]], [], [[return EOF;]])
+AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedException();' YYParser.java]])
+
+AT_CLEANUP
+
+
# --------------------------------------------- #
# Java stype, position_class and location_class #
# --------------------------------------------- #
# --------------------------------------------------
# This macro works around the impossibility to define macros
# inside macros, because issuing `[$1]' is not possible in M4 :(.
-# This sucks hard, GNU M4 should really provide M5 like $$1.
+# This sucks hard, GNU M4 should really provide M5-like $$1.
m4_define([_AT_BISON_OPTION_PUSHDEFS],
[m4_if([$1$2], $[1]$[2], [],
[m4_fatal([$0: Invalid arguments: $@])])dnl
m4_pushdef([AT_PARAM_IF],
[m4_bmatch([$3], [%parse-param], [$1], [$2])])
# Comma-terminated list of formals parse-parameters.
-# E.g., %parse-param { int x } {int y} -> "int x, int y, ".
+# E.g., %parse-param { int x } %parse-param {int y} -> "int x, int y, ".
+# FIXME: Support grouped parse-param.
m4_pushdef([AT_PARSE_PARAMS])
m4_bpatsubst([$3], [%parse-param { *\([^{}]*[^{} ]\) *}],
[m4_append([AT_PARSE_PARAMS], [\1, ])])
[m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"],
[m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])],
[yy])])
+m4_pushdef([AT_TOKEN_CTOR_IF],
+[m4_bmatch([$3], [%define api.token.constructor], [$1], [$2])])
+m4_pushdef([AT_TOKEN_PREFIX],
+[m4_bmatch([$3], [%define api.token.prefix ".*"],
+ [m4_bregexp([$3], [%define api.token.prefix "\(.*\)"], [\1])])])
m4_pushdef([AT_API_prefix],
[m4_bmatch([$3], [%define api\.prefix ".*"],
[m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])],
[%skeleton "?glr.c"?])),
[$1], [$2])],
[$2])],
- [$2])])
+ [$2])])
# yyerror always sees the locations (when activated) if the parser is impure.
# When the parser is pure, yyerror sees the location if it is received as an
# are using the C++ parsers.
m4_pushdef([AT_PURE_LEX_IF],
[AT_PURE_IF([$1],
- [AT_SKEL_CC_IF([$1], [$2])])])
+ [AT_SKEL_CC_IF([$1], [$2])])])
m4_pushdef([AT_YYSTYPE],
[AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::semantic_type]],
[m4_pushdef([AT_LOC], [(*llocp)])
m4_pushdef([AT_VAL], [(*lvalp)])
m4_pushdef([AT_YYLEX_FORMALS],
- [AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])])
+ [AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])])
m4_pushdef([AT_YYLEX_ARGS],
- [lvalp[]AT_LOCATION_IF([, llocp])])
+ [lvalp[]AT_LOCATION_IF([, llocp])])
m4_pushdef([AT_USE_LEX_ARGS],
- [(void) lvalp;AT_LOCATION_IF([(void) llocp])])
+ [(void) lvalp;AT_LOCATION_IF([(void) llocp])])
m4_pushdef([AT_YYLEX_PRE_FORMALS],
- [AT_YYLEX_FORMALS, ])
+ [AT_YYLEX_FORMALS, ])
m4_pushdef([AT_YYLEX_PRE_ARGS],
- [AT_YYLEX_ARGS, ])
+ [AT_YYLEX_ARGS, ])
],
[m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
[AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])])],
[AT_LOC_PUSHDEF([first_line], [first_column], [last_line], [last_column])])
+
+AT_GLR_IF([AT_KEYWORDS([glr])])
])# _AT_BISON_OPTION_PUSHDEFS
m4_popdef([AT_YYERROR_ARG_LOC_IF])
m4_popdef([AT_API_PREFIX])
m4_popdef([AT_API_prefix])
+m4_popdef([AT_TOKEN_PREFIX])
+m4_popdef([AT_TOKEN_CTOR_IF])
m4_popdef([AT_NAME_PREFIX])
m4_popdef([AT_LOCATION_TYPE_IF])
m4_popdef([AT_LOCATION_IF])
}]],
[c++], [[/* A C++ error reporting function. */
void
-]AT_NAME_PREFIX[::parser::error (const location_type& l, const std::string& m)
-{
- (void) l;
- std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
+]AT_NAME_PREFIX[::parser::error (]AT_LOCATION_IF([[const location_type& l, ]])[const std::string& m)
+{ std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
}]],
[java], [AT_LOCATION_IF([[public void yyerror (Calc.Location l, String s)
- {
+{
if (l == null)
System.err.println (s);
else
[m4_null_if([$2], [AT_BISON_CHECK_XML($@)])
AT_BISON_CHECK_NO_XML($@)])
-m4_define([AT_BISON_WERROR_MSG],
- [[bison: warnings being treated as errors]])
-
-
# AT_BISON_CHECK_(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
# --------------------------------------------------
# Low-level macro to run bison once.
# added after the grammar file name, so skip these checks in that
# case.
if test "$POSIXLY_CORRECT_IS_EXPORTED" = false; then
- ]AT_SAVE_SPECIAL_FILES[
+ ]AT_SAVE_SPECIAL_FILES[
# To avoid expanding it repeatedly, store specified stdout.
]AT_DATA([expout], [$3])[
# Build expected stderr up to and including the "warnings being
# treated as errors" message.
- ]AT_DATA([[at-bison-check-warnings]], [$4])[
- at_bison_check_first=`sed -n \
- '/: warning: /{=;q;}' at-bison-check-warnings`
- : ${at_bison_check_first:=1}
- at_bison_check_first_tmp=`sed -n \
- '/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings`
- : ${at_bison_check_first_tmp:=1}
- if test $at_bison_check_first_tmp -lt $at_bison_check_first; then
- at_bison_check_first=$at_bison_check_first_tmp
- fi
- if test $at_bison_check_first -gt 1; then
- sed -n "1,`expr $at_bison_check_first - 1`"p \
- at-bison-check-warnings > experr
- fi
- echo ']AT_BISON_WERROR_MSG[' >> experr
-
- # Finish building expected stderr and check. Unlike warnings,
- # complaints cause bison to exit early. Thus, with -Werror, bison
- # does not necessarily report all warnings that it does without
- # -Werror, but it at least reports one.
- at_bison_check_last=`sed -n '$=' stderr`
- : ${at_bison_check_last:=1}
- at_bison_check_last=`expr $at_bison_check_last - 1`
- sed -n "$at_bison_check_first,$at_bison_check_last"p \
- at-bison-check-warnings >> experr
- ]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \
- stderr 1>&2]], [[0]], [[]], [experr])[
+ ]AT_DATA([[experr]], [$4])[
+ $PERL -pi -e 's{(.*): warning: (.*)\[-W(.*)\]$}
+ {$][1: error: $][2\@<:@-Werror=$][3@:>@}' experr
+ ]AT_CHECK([[sed 's,.*/$,,' stderr 1>&2]], [[0]], [[]], [experr])[
# Now check --warnings=error.
cp stderr experr
# Don't combine these Bison invocations since we want to be sure that
# --report=all isn't required to get the full XML file.
AT_BISON_CHECK_([[--report=all --report-file=xml-tests/test.output \
- --graph=xml-tests/test.dot ]]AT_BISON_ARGS,
- [[0]], [ignore], [ignore])
+ --graph=xml-tests/test.dot ]]AT_BISON_ARGS,
+ [[0]], [ignore], [ignore])
AT_BISON_CHECK_([[--xml=xml-tests/test.xml ]]AT_BISON_ARGS,
- [[0]], [ignore], [ignore])
+ [[0]], [ignore], [ignore])
m4_popdef([AT_BISON_ARGS])dnl
[cp xml-tests/test.output expout]
AT_CHECK([[$XSLTPROC \
[-o $1],
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).c])],
[m4_bmatch([$1], [[.]], [], [$LIBS])]),
- 0, [ignore], [ignore])])
+ 0, [ignore], [ignore])])
# AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
# ---------------------------------------------
[-o $1],
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])],
[m4_bmatch([$1], [[.]], [], [$LIBS])]),
- 0, [ignore], [ignore])])
+ 0, [ignore], [ignore])])
# AT_JAVA_COMPILE(SOURCES)
# ------------------------
[java],
[AT_BISON_CHECK([-o $1.java $1.y])
AT_LANG_COMPILE([$1],
- m4_join([ ],
- [$1.java],
- m4_ifval($2, [[$1-$2.java]]),
+ m4_join([ ],
+ [$1.java],
+ m4_ifval($2, [[$1-$2.java]]),
m4_ifval($3, [[$1-$3.java]])))],
[c++],
[AT_BISON_CHECK([-o $1.cc $1.y])
AT_LANG_COMPILE([$1],
- m4_join([ ],
- [$1.cc],
- m4_ifval($2, [[$1-$2.cc]]),
+ m4_join([ ],
+ [$1.cc],
+ m4_ifval($2, [[$1-$2.cc]]),
m4_ifval($3, [[$1-$3.cc]])))],
[c],
[AT_BISON_CHECK([-o $1.c $1.y])
AT_LANG_COMPILE([$1],
- m4_join([ ],
- [$1.c],
- m4_ifval($2, [[$1-$2.c]]),
+ m4_join([ ],
+ [$1.c],
+ m4_ifval($2, [[$1-$2.c]]),
m4_ifval($3, [[$1-$3.c]])))])
])
--- /dev/null
+## Makefile for Bison testsuite.
+
+# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+EXTRA_DIST += $(TESTSUITE_AT) tests/testsuite
+
+DISTCLEANFILES += tests/atconfig $(check_SCRIPTS)
+MAINTAINERCLEANFILES += $(TESTSUITE)
+
+## ------------ ##
+## package.m4. ##
+## ------------ ##
+
+$(top_srcdir)/tests/package.m4: $(top_srcdir)/configure
+ $(AM_V_GEN)rm -f $@ $@.tmp
+ $(AM_V_at){ \
+ echo '# Signature of the current package.'; \
+ echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])'; \
+ echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])'; \
+ echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])'; \
+ echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])'; \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \
+ } >$@.tmp
+ $(AM_V_at)mv $@.tmp $@
+
+## ------------------------- ##
+## Generate the test suite. ##
+## ------------------------- ##
+
+TESTSUITE_AT = \
+ tests/testsuite.at \
+ \
+ tests/actions.at \
+ tests/c++.at \
+ tests/calc.at \
+ tests/conflicts.at \
+ tests/cxx-type.at \
+ tests/existing.at \
+ tests/glr-regression.at \
+ tests/headers.at \
+ tests/input.at \
+ tests/java.at \
+ tests/local.at \
+ tests/named-refs.at \
+ tests/output.at \
+ tests/package.m4 \
+ tests/push.at \
+ tests/reduce.at \
+ tests/regression.at \
+ tests/sets.at \
+ tests/skeletons.at \
+ tests/synclines.at \
+ tests/torture.at
+
+TESTSUITE = $(top_srcdir)/tests/testsuite
+
+AUTOTEST = $(AUTOM4TE) --language=autotest
+AUTOTESTFLAGS = -I $(top_srcdir)/tests
+$(TESTSUITE): $(TESTSUITE_AT)
+ $(AM_V_GEN) \
+ $(AUTOTEST) $(AUTOTESTFLAGS) $(srcdir)/tests/testsuite.at -o $@.tmp
+ $(AM_V_at)mv $@.tmp $@
+
+
+## -------------------- ##
+## Run the test suite. ##
+## -------------------- ##
+
+# Move into tests/ so that testsuite.dir etc. be created there.
+RUN_TESTSUITE = $(TESTSUITE) -C tests $(TESTSUITEFLAGS)
+check_SCRIPTS = $(BISON) tests/atconfig tests/atlocal
+RUN_TESTSUITE_deps = $(TESTSUITE) $(check_SCRIPTS)
+
+clean-local: clean-local-tests
+clean-local-tests:
+ test ! -f $(TESTSUITE) || $(TESTSUITE) -C tests --clean
+
+check-local: $(RUN_TESTSUITE_deps)
+ $(RUN_TESTSUITE)
+
+# Run the test suite on the *installed* tree.
+installcheck-local: $(RUN_TESTSUITE_deps)
+ $(RUN_TESTSUITE) AUTOTEST_PATH='$(bindir)'
+
+# Be real mean with it.
+.PHONY: maintainer-check-g++
+maintainer-check-g++: $(RUN_TESTSUITE_deps)
+ $(RUN_TESTSUITE) --compile-c-with-cxx
+
+.PHONY: maintainer-check-posix
+maintainer-check-posix: $(RUN_TESTSUITE_deps)
+ $(RUN_TESTSUITE) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112
+
+.PHONY: maintainer-check-valgrind
+maintainer-check-valgrind: $(RUN_TESTSUITE_deps)
+ test -z '$(VALGRIND)' || \
+ $(RUN_TESTSUITE) \
+ PREBISON='$(VALGRIND_PREBISON)' PREPARSER='$(VALGRIND) -q' \
+ VALGRIND_OPTS='--leak-check=full --show-reachable=yes'
+
+.PHONY: maintainer-check
+maintainer-check: maintainer-check-posix maintainer-check-valgrind maintainer-check-g++
+
+.PHONY: maintainer-push-check
+maintainer-push-check:
+ $(MAKE) $(AM_MAKEFLAGS) maintainer-check \
+ TESTSUITEFLAGS='BISON_USE_PUSH_FOR_PULL=1 $(TESTSUITEFLAGS)'
+
+.PHONY: maintainer-xml-check
+maintainer-xml-check:
+ $(MAKE) $(AM_MAKEFLAGS) maintainer-check \
+ TESTSUITEFLAGS='BISON_TEST_XML=1 $(TESTSUITEFLAGS)'
%token <ival> NUM "number"
%type <ival> exp
-%nonassoc '=' /* comparison */
+%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
-%left NEG /* negation--unary minus */
+%precedence NEG /* negation--unary minus */
%right '^' /* exponentiation */
%%
{
if ($l != $r)
fprintf (stderr, "calc: error: %d != %d\n", $l, $r);
- $$ = $l;
+ $$ = $l;
}
| exp[x] '+' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>l + $r; }
| exp[l] '-' exp[r] { $$ = $l - $r; }
%token <ival> NUM "number"
%type <ival> exp
-%nonassoc '=' /* comparison */
+%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
-%left NEG /* negation--unary minus */
+%precedence NEG /* negation--unary minus */
%right '^' /* exponentiation */
%%
{
if ($l != $r)
fprintf (stderr, "calc: error: %d != %d\n", $l, $r);
- $$ = $l;
+ $$ = $l;
}
| exp[x] '+' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>lo9 + $r; }
| exp[x] '-' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>exp - $r; }
AT_BISON_CHECK([-o test.c test.y], 1, [],
[[test.y:50.51-60: error: invalid reference: '$<ival>lo9'
test.y:50.3-68: symbol not found in production: lo9
-test.y:51.51-60: warning: misleading reference: '$<ival>exp'
+test.y:51.51-60: warning: misleading reference: '$<ival>exp' [-Wother]
test.y:42.1-3: refers to: $exp at $$
test.y:51.7: possibly meant: $x, hiding $exp at $1
test.y:51.41: possibly meant: $r, hiding $exp at $4
foo.bar: '2'
]])
AT_BISON_CHECK([-o test.c test.y], 0, [],
-[[test.y:11.22-29: warning: misleading reference: '$foo.bar'
+[[test.y:11.22-29: warning: misleading reference: '$foo.bar' [-Wother]
test.y:11.8-10: refers to: $foo at $1
test.y:11.12-18: possibly meant: $[foo.bar] at $2
]])
;
]])
AT_BISON_CHECK([[test.y]], [[0]], [],
-[[test.y:4.9: warning: stray '$'
-test.y:5.9: warning: stray '@'
+[[test.y:4.9: warning: stray '$' [-Wother]
+test.y:5.9: warning: stray '@' [-Wother]
]])
AT_CLEANUP
# [ADDITIONAL-TESTS], [PRE-TESTS])
# -----------------------------------------------------------------------------
m4_define([AT_CHECK_OUTPUT],
-[AT_SETUP([[Output files: $2 $3 $5]])
-$7
-for file in $1 $4; do
- case "$file" in
- */*) mkdir -p `echo "$file" | sed 's,/.*,,'`;;
+[AT_SETUP([[Output files: ]$2 $3 $5])[
+]$7[
+for file in ]$1 $4[; do
+ case $file in
+ */*) mkdir -p `echo "$file" | sed 's,/[^/]*,,'`;;
esac
done
-AT_DATA([$1],
-[[$2
+]AT_DATA([$1],
+[$2[
%%
foo: {};
+]])[
+
+]AT_BISON_CHECK([$3 $1 $5], 0)[
+# Ignore the files non-generated files
+]AT_CHECK([find . -type f -and -not -path './$1' -and -not -path './testsuite.log' |
+ sed 's,\./,,' |
+ sort |
+ xargs echo],
+ [], [$4
+])[
+]$6[
+]AT_CLEANUP[
]])
-AT_BISON_CHECK([$3 $1 $5], 0)
-AT_CHECK([ls $4], [], [ignore])
-$6
-AT_CLEANUP
-])
-
AT_CHECK_OUTPUT([foo.y], [], [-dv],
- [foo.output foo.tab.c foo.tab.h])
+ [foo.output foo.tab.c foo.tab.h])
# Some versions of Valgrind (at least valgrind-3.6.0.SVN-Debian) report
# "fgrep: write error: Bad file descriptor" when stdout is closed, so we
# skip this test group during maintainer-check-valgrind.
AT_CHECK_OUTPUT([foo.y], [], [-dv],
- [foo.output foo.tab.c foo.tab.h],
- [>&-], [],
- [AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])])
+ [foo.output foo.tab.c foo.tab.h],
+ [>&-], [],
+ [AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])])
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
- [foo.c foo.h foo.output])
+ [foo.c foo.h foo.output])
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
- [foo.output foo.tab.c foo.tab.h])
+ [foo.output foo.tab.c foo.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -y],
- [y.output y.tab.c y.tab.h])
+ [y.output y.tab.c y.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
- [bar.output bar.tab.c bar.tab.h])
+ [bar.output bar.tab.c bar.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
- [foo.c foo.dot foo.h foo.output])
+ [foo.c foo.dot foo.h foo.output])
AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [],
- [foo.output foo.tab.c foo.tab.h])
+ [foo.output foo.tab.c foo.tab.h])
AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[],
- [y.output y.tab.c y.tab.h])
+ [y.output y.tab.c y.tab.h])
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[],
- [y.output y.tab.c y.tab.h])
+ [y.output y.tab.c y.tab.h])
# Exercise %output and %file-prefix including deprecated '='
AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [],
- [bar.output bar.tab.c bar.tab.h])
-AT_CHECK_OUTPUT([foo.y], [%output="bar.c" %defines %verbose %yacc],[],
- [bar.output bar.c bar.h])
+ [bar.output bar.tab.c bar.tab.h])
+AT_CHECK_OUTPUT([foo.y], [%output "bar.c" %defines %verbose %yacc],[],
+ [bar.c bar.h bar.output])
AT_CHECK_OUTPUT([foo.y],
- [%file-prefix="baz" %output "bar.c" %defines %verbose %yacc],
- [],
- [bar.output bar.c bar.h])
+ [%file-prefix "baz" %output "bar.c" %defines %verbose %yacc],
+ [],
+ [bar.c bar.h bar.output])
# Check priorities of extension control.
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
- [foo.output foo.tab.cc foo.tab.hh])
+ [foo.output foo.tab.cc foo.tab.hh])
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c],
- [foo.c foo.h foo.output])
+ [foo.c foo.h foo.output])
AT_CHECK_OUTPUT([foo.yy], [],
- [--defines=foo.hpp -o foo.c++],
- [foo.c++ foo.hpp])
+ [--defines=foo.hpp -o foo.c++],
+ [foo.c++ foo.hpp])
AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
- [-o foo.c++],
- [foo.c++ foo.hpp])
+ [-o foo.c++],
+ [foo.c++ foo.hpp])
AT_CHECK_OUTPUT([foo.yy], [],
- [-o foo.c++ --graph=foo.gph],
- [foo.c++ foo.gph])
+ [-o foo.c++ --graph=foo.gph],
+ [foo.c++ foo.gph])
## ------------ ##
AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
])
+AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose], [],
+ [foo.output foo.tab.cc])
+
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
- [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh])
+ [foo.output foo.tab.cc foo.tab.hh stack.hh])
+
+AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose %locations], [],
+ [foo.output foo.tab.cc])
+
+AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], [],
+ [foo.output foo.tab.cc foo.tab.hh location.hh position.hh stack.hh])
AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
- [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh],
- [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
+ [foo.output foo.tab.cc foo.tab.hh stack.hh],
+ [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
-AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose],
- [-o subdir/foo.cc],
- [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
- [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
+AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations],
+ [-o subdir/foo.cc],
+ [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/position.hh subdir/stack.hh],
+ [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
AT_CHECK_OUTPUT([gram_dir/foo.yy],
[%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"],
[],
- [output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/location.hh output_dir/stack.hh output_dir/position.hh])
+ [output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/stack.hh])
+
+AT_CHECK_OUTPUT([gram_dir/foo.yy],
+ [%skeleton "lalr1.cc" %defines %locations %verbose %file-prefix "output_dir/foo"],
+ [],
+ [output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/location.hh output_dir/position.hh output_dir/stack.hh])
# AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR,
AT_CHECK_CONFLICTING_OUTPUT([foo.y],
[], [--graph="foo.tab.c"],
-[foo.y: warning: conflicting outputs to file 'foo.tab.c'
-])
+[[foo.y: warning: conflicting outputs to file 'foo.tab.c' [-Wother]
+]])
AT_CHECK_CONFLICTING_OUTPUT([foo.y],
[%defines "foo.output"], [-v],
-[foo.y: warning: conflicting outputs to file 'foo.output'
-])
+[[foo.y: warning: conflicting outputs to file 'foo.output' [-Wother]
+]])
AT_CHECK_CONFLICTING_OUTPUT([foo.y],
-[%skeleton "lalr1.cc" %defines], [--graph="location.hh"],
-[foo.y: warning: conflicting outputs to file 'location.hh'
-])
+[%skeleton "lalr1.cc" %defines %locations], [--graph="location.hh"],
+[[foo.y: warning: conflicting outputs to file 'location.hh' [-Wother]
+]])
AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
-[foo.y: error: refusing to overwrite the input file 'foo.y'
-], 1)
+[[foo.y: error: refusing to overwrite the input file 'foo.y'
+]], 1)
# AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
]])
AT_BISON_CHECK([[input.y]], 0, [],
-[[input.y: warning: 9 nonterminals useless in grammar
-input.y:4.8-15: warning: nonterminal useless in grammar: useless1
-input.y:5.8-15: warning: nonterminal useless in grammar: useless2
-input.y:6.8-15: warning: nonterminal useless in grammar: useless3
-input.y:7.8-15: warning: nonterminal useless in grammar: useless4
-input.y:8.8-15: warning: nonterminal useless in grammar: useless5
-input.y:9.8-15: warning: nonterminal useless in grammar: useless6
-input.y:10.8-15: warning: nonterminal useless in grammar: useless7
-input.y:11.8-15: warning: nonterminal useless in grammar: useless8
-input.y:12.8-15: warning: nonterminal useless in grammar: useless9
+[[input.y: warning: 9 nonterminals useless in grammar [-Wother]
+input.y:4.8-15: warning: nonterminal useless in grammar: useless1 [-Wother]
+input.y:5.8-15: warning: nonterminal useless in grammar: useless2 [-Wother]
+input.y:6.8-15: warning: nonterminal useless in grammar: useless3 [-Wother]
+input.y:7.8-15: warning: nonterminal useless in grammar: useless4 [-Wother]
+input.y:8.8-15: warning: nonterminal useless in grammar: useless5 [-Wother]
+input.y:9.8-15: warning: nonterminal useless in grammar: useless6 [-Wother]
+input.y:10.8-15: warning: nonterminal useless in grammar: useless7 [-Wother]
+input.y:11.8-15: warning: nonterminal useless in grammar: useless8 [-Wother]
+input.y:12.8-15: warning: nonterminal useless in grammar: useless9 [-Wother]
]])
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0,
]])
AT_BISON_CHECK([[-fcaret input.y]], 0, [],
-[[input.y: warning: 9 nonterminals useless in grammar
-input.y: warning: 9 rules useless in grammar
-input.y:6.1-8: warning: nonterminal useless in grammar: useless1
+[[input.y: warning: 9 nonterminals useless in grammar [-Wother]
+input.y: warning: 9 rules useless in grammar [-Wother]
+input.y:6.1-8: warning: nonterminal useless in grammar: useless1 [-Wother]
useless1: '1';
^^^^^^^^
-input.y:7.1-8: warning: nonterminal useless in grammar: useless2
+input.y:7.1-8: warning: nonterminal useless in grammar: useless2 [-Wother]
useless2: '2';
^^^^^^^^
-input.y:8.1-8: warning: nonterminal useless in grammar: useless3
+input.y:8.1-8: warning: nonterminal useless in grammar: useless3 [-Wother]
useless3: '3';
^^^^^^^^
-input.y:9.1-8: warning: nonterminal useless in grammar: useless4
+input.y:9.1-8: warning: nonterminal useless in grammar: useless4 [-Wother]
useless4: '4';
^^^^^^^^
-input.y:10.1-8: warning: nonterminal useless in grammar: useless5
+input.y:10.1-8: warning: nonterminal useless in grammar: useless5 [-Wother]
useless5: '5';
^^^^^^^^
-input.y:11.1-8: warning: nonterminal useless in grammar: useless6
+input.y:11.1-8: warning: nonterminal useless in grammar: useless6 [-Wother]
useless6: '6';
^^^^^^^^
-input.y:12.1-8: warning: nonterminal useless in grammar: useless7
+input.y:12.1-8: warning: nonterminal useless in grammar: useless7 [-Wother]
useless7: '7';
^^^^^^^^
-input.y:13.1-8: warning: nonterminal useless in grammar: useless8
+input.y:13.1-8: warning: nonterminal useless in grammar: useless8 [-Wother]
useless8: '8';
^^^^^^^^
-input.y:14.1-8: warning: nonterminal useless in grammar: useless9
+input.y:14.1-8: warning: nonterminal useless in grammar: useless9 [-Wother]
useless9: '9';
^^^^^^^^
-input.y:6.11-13: warning: rule useless in grammar
+input.y:6.11-13: warning: rule useless in grammar [-Wother]
useless1: '1';
^^^
-input.y:7.11-13: warning: rule useless in grammar
+input.y:7.11-13: warning: rule useless in grammar [-Wother]
useless2: '2';
^^^
-input.y:8.11-13: warning: rule useless in grammar
+input.y:8.11-13: warning: rule useless in grammar [-Wother]
useless3: '3';
^^^
-input.y:9.11-13: warning: rule useless in grammar
+input.y:9.11-13: warning: rule useless in grammar [-Wother]
useless4: '4';
^^^
-input.y:10.11-13: warning: rule useless in grammar
+input.y:10.11-13: warning: rule useless in grammar [-Wother]
useless5: '5';
^^^
-input.y:11.11-13: warning: rule useless in grammar
+input.y:11.11-13: warning: rule useless in grammar [-Wother]
useless6: '6';
^^^
-input.y:12.11-13: warning: rule useless in grammar
+input.y:12.11-13: warning: rule useless in grammar [-Wother]
useless7: '7';
^^^
-input.y:13.11-13: warning: rule useless in grammar
+input.y:13.11-13: warning: rule useless in grammar [-Wother]
useless8: '8';
^^^
-input.y:14.11-13: warning: rule useless in grammar
+input.y:14.11-13: warning: rule useless in grammar [-Wother]
useless9: '9';
^^^
]])
AT_BISON_CHECK([[input.y]], 0, [],
-[[input.y: warning: 9 nonterminals useless in grammar
-input.y: warning: 9 rules useless in grammar
-input.y:6.1-8: warning: nonterminal useless in grammar: useless1
-input.y:7.1-8: warning: nonterminal useless in grammar: useless2
-input.y:8.1-8: warning: nonterminal useless in grammar: useless3
-input.y:9.1-8: warning: nonterminal useless in grammar: useless4
-input.y:10.1-8: warning: nonterminal useless in grammar: useless5
-input.y:11.1-8: warning: nonterminal useless in grammar: useless6
-input.y:12.1-8: warning: nonterminal useless in grammar: useless7
-input.y:13.1-8: warning: nonterminal useless in grammar: useless8
-input.y:14.1-8: warning: nonterminal useless in grammar: useless9
-input.y:6.11-13: warning: rule useless in grammar: useless1: '1'
-input.y:7.11-13: warning: rule useless in grammar: useless2: '2'
-input.y:8.11-13: warning: rule useless in grammar: useless3: '3'
-input.y:9.11-13: warning: rule useless in grammar: useless4: '4'
-input.y:10.11-13: warning: rule useless in grammar: useless5: '5'
-input.y:11.11-13: warning: rule useless in grammar: useless6: '6'
-input.y:12.11-13: warning: rule useless in grammar: useless7: '7'
-input.y:13.11-13: warning: rule useless in grammar: useless8: '8'
-input.y:14.11-13: warning: rule useless in grammar: useless9: '9'
+[[input.y: warning: 9 nonterminals useless in grammar [-Wother]
+input.y: warning: 9 rules useless in grammar [-Wother]
+input.y:6.1-8: warning: nonterminal useless in grammar: useless1 [-Wother]
+input.y:7.1-8: warning: nonterminal useless in grammar: useless2 [-Wother]
+input.y:8.1-8: warning: nonterminal useless in grammar: useless3 [-Wother]
+input.y:9.1-8: warning: nonterminal useless in grammar: useless4 [-Wother]
+input.y:10.1-8: warning: nonterminal useless in grammar: useless5 [-Wother]
+input.y:11.1-8: warning: nonterminal useless in grammar: useless6 [-Wother]
+input.y:12.1-8: warning: nonterminal useless in grammar: useless7 [-Wother]
+input.y:13.1-8: warning: nonterminal useless in grammar: useless8 [-Wother]
+input.y:14.1-8: warning: nonterminal useless in grammar: useless9 [-Wother]
+input.y:6.11-13: warning: rule useless in grammar: useless1: '1' [-Wother]
+input.y:7.11-13: warning: rule useless in grammar: useless2: '2' [-Wother]
+input.y:8.11-13: warning: rule useless in grammar: useless3: '3' [-Wother]
+input.y:9.11-13: warning: rule useless in grammar: useless4: '4' [-Wother]
+input.y:10.11-13: warning: rule useless in grammar: useless5: '5' [-Wother]
+input.y:11.11-13: warning: rule useless in grammar: useless6: '6' [-Wother]
+input.y:12.11-13: warning: rule useless in grammar: useless7: '7' [-Wother]
+input.y:13.11-13: warning: rule useless in grammar: useless8: '8' [-Wother]
+input.y:14.11-13: warning: rule useless in grammar: useless9: '9' [-Wother]
]])
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0,
]])
AT_BISON_CHECK([[-fcaret not-reduced.y]], 0, [],
-[[not-reduced.y: warning: 2 nonterminals useless in grammar
-not-reduced.y: warning: 3 rules useless in grammar
-not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable
+[[not-reduced.y: warning: 2 nonterminals useless in grammar [-Wother]
+not-reduced.y: warning: 3 rules useless in grammar [-Wother]
+not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable [-Wother]
not_reachable: useful { /* A not reachable action. */ }
^^^^^^^^^^^^^
-not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive
+not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive [-Wother]
| non_productive { /* A non productive action. */ }
^^^^^^^^^^^^^^
-not-reduced.y:11.6-57: warning: rule useless in grammar
+not-reduced.y:11.6-57: warning: rule useless in grammar [-Wother]
| non_productive { /* A non productive action. */ }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-not-reduced.y:14.16-56: warning: rule useless in grammar
+not-reduced.y:14.16-56: warning: rule useless in grammar [-Wother]
not_reachable: useful { /* A not reachable action. */ }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-not-reduced.y:17.17-18.63: warning: rule useless in grammar
+not-reduced.y:17.17-18.63: warning: rule useless in grammar [-Wother]
non_productive: non_productive useless_token
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]])
AT_BISON_CHECK([[not-reduced.y]], 0, [],
-[[not-reduced.y: warning: 2 nonterminals useless in grammar
-not-reduced.y: warning: 3 rules useless in grammar
-not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable
-not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive
-not-reduced.y:11.6-57: warning: rule useless in grammar: exp: non_productive
-not-reduced.y:14.16-56: warning: rule useless in grammar: not_reachable: useful
-not-reduced.y:17.17-18.63: warning: rule useless in grammar: non_productive: non_productive useless_token
+[[not-reduced.y: warning: 2 nonterminals useless in grammar [-Wother]
+not-reduced.y: warning: 3 rules useless in grammar [-Wother]
+not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable [-Wother]
+not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive [-Wother]
+not-reduced.y:11.6-57: warning: rule useless in grammar: exp: non_productive [-Wother]
+not-reduced.y:14.16-56: warning: rule useless in grammar: not_reachable: useful [-Wother]
+not-reduced.y:17.17-18.63: warning: rule useless in grammar: non_productive: non_productive useless_token [-Wother]
]])
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' not-reduced.output]], 0,
]])
AT_BISON_CHECK([[input.y]], 0, [],
-[[input.y: warning: 2 nonterminals useless in grammar
-input.y: warning: 3 rules useless in grammar
-input.y:5.15-25: warning: nonterminal useless in grammar: underivable
-input.y:6.14-24: warning: nonterminal useless in grammar: indirection
-input.y:5.15-25: warning: rule useless in grammar: exp: underivable
-input.y:6.14-24: warning: rule useless in grammar: underivable: indirection
-input.y:7.14-24: warning: rule useless in grammar: indirection: underivable
+[[input.y: warning: 2 nonterminals useless in grammar [-Wother]
+input.y: warning: 3 rules useless in grammar [-Wother]
+input.y:5.15-25: warning: nonterminal useless in grammar: underivable [-Wother]
+input.y:6.14-24: warning: nonterminal useless in grammar: indirection [-Wother]
+input.y:5.15-25: warning: rule useless in grammar: exp: underivable [-Wother]
+input.y:6.14-24: warning: rule useless in grammar: underivable: indirection [-Wother]
+input.y:7.14-24: warning: rule useless in grammar: indirection: underivable [-Wother]
]])
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0,
]])
AT_BISON_CHECK([[input.y]], 1, [],
-[[input.y: warning: 2 nonterminals useless in grammar
-input.y: warning: 2 rules useless in grammar
+[[input.y: warning: 2 nonterminals useless in grammar [-Wother]
+input.y: warning: 2 rules useless in grammar [-Wother]
input.y:3.1-3: fatal error: start symbol exp does not derive any sentence
]])
[[%left 'a'
// Conflict resolution renders state 12 unreachable for canonical LR(1). We
// keep it so that the paser table diff is easier to code.
-%define lr.keep-unreachable-states]],
+%define lr.keep-unreachable-state]],
[[
S: 'a' A 'a' /* rule 1 */
| 'b' A 'b' /* rule 2 */
[[%left 'a'
// Conflict resolution renders state 16 unreachable for canonical LR(1). We
// keep it so that the paser table diff is easier to code.
-%define lr.keep-unreachable-states]],
+%define lr.keep-unreachable-state]],
[[
/* Similar to the last test case set but two states must be split. */
S: 'a' A 'a' /* rule 1 */
[[%left 'a'
// Conflict resolution renders state 16 unreachable for canonical LR(1). We
// keep it so that the paser table diff is easier to code.
-%define lr.keep-unreachable-states]],
+%define lr.keep-unreachable-state]],
[[
/* Similar to the last test case set but forseeing the S/R conflict from the
first state that must be split is becoming difficult. Imagine if B were
]])])
AT_TEST_LR_TYPE([[Split During Added Lookahead Propagation]],
-[[%define lr.keep-unreachable-states]],
+[[%define lr.keep-unreachable-state]],
[[
/* The partial state chart diagram below is for LALR(1). State 0 is the start
state. States are iterated for successor construction in numerical order.
dnl BISON-STDERR
[AT_COND_CASE([[LALR]],
-[[input.y: conflicts: 1 reduce/reduce
+[[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
]], [])],
dnl TABLES
## ------------------------------- ##
-## %define lr.default-reductions. ##
+## %define lr.default-reduction. ##
## ------------------------------- ##
# AT_TEST_LR_DEFAULT_REDUCTIONS(GRAMMAR, INPUT, TABLES)
# -----------------------------------------------------
m4_define([AT_TEST_LR_DEFAULT_REDUCTIONS],
[
-AT_TEST_TABLES_AND_PARSE([[no %define lr.default-reductions]],
+AT_TEST_TABLES_AND_PARSE([[no %define lr.default-reduction]],
[[most]], [[]],
[[]],
[$1], [$2], [[]], [$3])
-AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions most]],
+AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction most]],
[[most]], [[]],
- [[%define lr.default-reductions most]],
+ [[%define lr.default-reduction most]],
[$1], [$2], [[]], [$3])
-AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions consistent]],
+AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction consistent]],
[[consistent]], [[]],
- [[%define lr.default-reductions consistent]],
+ [[%define lr.default-reduction consistent]],
[$1], [$2], [[]], [$3])
-AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions accepting]],
+AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction accepting]],
[[accepting]], [[]],
- [[%define lr.default-reductions accepting]],
+ [[%define lr.default-reduction accepting]],
[$1], [$2], [[]], [$3])
])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-v -o input.c input.y], 0, [],
-[[input.y:6.8-14: warning: symbol "<=" used more than once as a literal string
+[[input.y:6.8-14: warning: symbol "<=" used more than once as a literal string [-Wother]
]])
AT_CLEANUP
# C-string literal. Also notice that unnecessary escaping, such as "\?", from
# the user specification is eliminated.
AT_BISON_CHECK([-o input.c input.y], [[0]], [[]],
-[[input.y:22.8-14: warning: symbol SPECIAL redeclared
-input.y:22.8-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string
+[[input.y:22.8-14: warning: symbol SPECIAL redeclared [-Wother]
+input.y:22.8-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother]
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], [[0]], [[]],
-[[input.y:22.8-14: warning: symbol SPECIAL redeclared
+[[input.y:22.8-14: warning: symbol SPECIAL redeclared [-Wother]
%token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
^^^^^^^
-input.y:22.8-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string
+input.y:22.8-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother]
%token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]])
AT_KEYWORDS([report])
AT_DATA([input.y],
-[[%token undef_id_tok const_id_tok
+[[%token undef_id_tok const_id_tok
%start CONST_DEC_PART
\f
;
CONST_DEC_LIST:
- CONST_DEC
+ CONST_DEC
| CONST_DEC_LIST CONST_DEC
;
CONST_DEC:
- { } undef_id_tok '=' const_id_tok ';'
+ { } undef_id_tok '=' const_id_tok ';'
;
%%
]])
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6
};
-static const yytype_uint8 yyprhs[] =
-{
- 0, 0, 3, 5, 6, 9, 14
-};
-static const yytype_int8 yyrhs[] =
-{
- 8, 0, -1, 9, -1, -1, 10, 11, -1, 3,
- 4, 5, 8, -1, 6, 8, -1
-};
static const yytype_uint8 yyrline[] =
{
0, 2, 2, 3, 3, 4, 5
{
0, 256, 257, 258, 259, 260, 261
};
-static const yytype_uint8 yyr1[] =
-{
- 0, 7, 8, 9, 9, 10, 11
-};
-static const yytype_uint8 yyr2[] =
+static const yytype_int8 yypact[] =
{
- 0, 2, 1, 0, 2, 4, 2
+ -2, -1, 4, -8, 0, 2, -8, -2, -8, -2,
+ -8, -8
};
static const yytype_uint8 yydefact[] =
{
3, 0, 0, 2, 0, 0, 1, 3, 4, 3,
6, 5
};
-static const yytype_int8 yydefgoto[] =
-{
- -1, 2, 3, 4, 8
-};
-static const yytype_int8 yypact[] =
-{
- -2, -1, 4, -8, 0, 2, -8, -2, -8, -2,
- -8, -8
-};
static const yytype_int8 yypgoto[] =
{
-8, -7, -8, -8, -8
};
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 2, 3, 4, 8
+};
static const yytype_uint8 yytable[] =
{
10, 1, 11, 5, 6, 0, 7, 9
0, 3, 8, 9, 10, 4, 0, 6, 11, 5,
8, 8
};
+static const yytype_uint8 yyr1[] =
+{
+ 0, 7, 8, 9, 9, 10, 11
+};
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 1, 0, 2, 4, 2
+};
]])
AT_CLEANUP
# --------------------------------
m4_define([_AT_DATA_EXPECT2_Y],
[AT_DATA_GRAMMAR([expect2.y],
-[[%{
-static int yylex (]AT_LALR1_CC_IF([int *], [void]));
-AT_LALR1_CC_IF([],
-[[#include <stdio.h>
-#include <stdlib.h>
+[%{
+static int yylex (AT_LALR1_CC_IF([int *], [void]));
+AT_LALR1_CC_IF([[#include <cstdlib>]],
+[[#include <stdlib.h>
+#include <stdio.h>
]AT_YYERROR_DECLARE])[
%}
$1
start:
{
printf ("Bison would once convert this action to a midrule because of the"
- " subsequent braced code.\n");
+ " subsequent braced code.\n");
}
;
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
-[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start
-input.y:27.5-19: warning: rule useless in parser due to conflicts: sr_conflict: TK2 "tok alias"
+[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start [-Wother]
+input.y:27.5-19: warning: rule useless in parser due to conflicts: sr_conflict: TK2 "tok alias" [-Wother]
]])
AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input]])
AT_SETUP([[parse-gram.y: LALR = IELR]])
-# Avoid differences in synclines by telling bison that the output files
-# have the same name.
+# Avoid tests/bison's dark magic by processing a local copy of the
+# grammar. Avoid differences in synclines by telling bison that the
+# output files have the same name.
[cp $abs_top_srcdir/src/parse-gram.y input.y]
AT_BISON_CHECK([[-o input.c -Dlr.type=lalr input.y]])
[mv input.c lalr.c]
-## --------------------------------------- ##
-## %error-verbose and YYSTACK_USE_ALLOCA. ##
-## --------------------------------------- ##
+## -------------------------------------------- ##
+## parse.error=verbose and YYSTACK_USE_ALLOCA. ##
+## -------------------------------------------- ##
-AT_SETUP([[%error-verbose and YYSTACK_USE_ALLOCA]])
+AT_SETUP([[parse.error=verbose and YYSTACK_USE_ALLOCA]])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
#define YYSTACK_USE_ALLOCA 1
}
-%error-verbose
+%define parse.error verbose
%%
%%
]AT_YYERROR_DEFINE[
-/* Induce two syntax error messages (which requires full error
- recovery by shifting 3 tokens) in order to detect any loss of the
- reallocated buffer. */
+ /* Induce two syntax error messages (which requires full error
+ recovery by shifting 3 tokens) in order to detect any loss of the
+ reallocated buffer. */
]AT_YYLEX_DEFINE(["abc"])[
int
main (void)
-## ------------------------- ##
-## %error-verbose overflow. ##
-## ------------------------- ##
+## ------------------------------ ##
+## parse.error=verbose overflow. ##
+## ------------------------------ ##
# Imagine the case where YYSTACK_ALLOC_MAXIMUM = YYSIZE_MAXIMUM and an
# invocation of yysyntax_error has caused yymsg_alloc to grow to exactly
# size calculation would return YYSIZE_MAXIMUM to yyparse. Then,
# yyparse would invoke yyerror using the old contents of yymsg.
-AT_SETUP([[%error-verbose overflow]])
+AT_SETUP([[parse.error=verbose overflow]])
+
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%code {
#define YYMAXDEPTH 100
}
-%error-verbose
+%define parse.error verbose
%%
%%
]AT_YYERROR_DEFINE[
-/* Induce two syntax error messages (which requires full error
- recovery by shifting 3 tokens). */
+ /* Induce two syntax error messages (which requires full error
+ recovery by shifting 3 tokens). */
]AT_YYLEX_DEFINE(["abc"])[
int
main (void)
}
]$1[
-%error-verbose
+%define parse.error verbose
%token 'c'
%%
AT_BISON_CHECK([[-Dparse.lac=full -Dparse.lac.es-capacity-initial=1 \
-Dparse.lac.memory-trace=full \
-t -o input.c input.y]], [[0]], [],
-[[input.y: conflicts: 21 shift/reduce
+[[input.y: warning: 21 shift/reduce conflicts [-Wconflicts-sr]
]])
AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input > stdout.txt 2> stderr.txt]], [[1]])
AT_BISON_CHECK([[-Dparse.lac=full -Dparse.lac.es-capacity-initial=1 \
-t -o input.c input.y]], [[0]], [],
-[[input.y: conflicts: 8 shift/reduce
+[[input.y: warning: 8 shift/reduce conflicts [-Wconflicts-sr]
]])
AT_COMPILE([[input]])
AT_BISON_OPTION_POPDEFS
]])
AT_BISON_CHECK([[input1.y]], [[1]], [[]],
-[[input1.y: warning: foow fubar
-foow.y:2.3-5.3: warning: foowat fubar
+[[input1.y: warning: foow fubar [-Wother]
+foow.y:2.3-5.3: warning: foowat fubar [-Wother]
input1.y: error: fooc fubar
fooc.y:1.1-10.5: error: foocat fubar
input1.y: fatal error: foof fubar
]])
AT_BISON_CHECK([[input2.y]], [[1]], [[]],
-[[input2.y: warning: morning
+[[input2.y: warning: morning [-Wother]
foo.y:1.5-6: fatal error: M4 should exit immediately here
]])
-# Test suite for GNU Bison. -*- Autotest -*-
+# Test suite for GNU Bison. -*- Autotest -*-
# Copyright (C) 2000-2004, 2006-2007, 2009-2012 Free Software
# Foundation, Inc.