Compare commits

...
Author SHA1 Message Date
Akim Demaille a24e6b0d21 version 2.6.90
* NEWS: Record release date.
2012-12-07 11:37:14 +01:00
Akim Demaille 1a9ac9bdba build: fix syntax-check error.
* cfg.mk: Exclude names-refs, it includes a "double" if (end of first
line, first of second line below).

test.y:43.12-44.59:  symbol not found in production: if
 if-stmt-a: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2012-12-07 11:34:51 +01:00
Theophile Ranquet 9318e335c8 cpp: simplify the Flex version checking macro
* src/flex-scanner,h (FLEX_VERSION): Consider YY_FLEX_SUBMINOR_VERSION
defined.
2012-12-07 12:13:38 +01:00
Theophile Ranquet fb6040f0a8 news: improve the carets example and fix a typo
* NEWS: Here.
2012-12-07 12:02:00 +01:00
Theophile Ranquet c49e2f1535 cpp: improve the Flex version checking macro
* src/flex-scanner.h (FLEX_VERSION): Here.
2012-12-07 12:02:00 +01:00
Theophile Ranquet dbda560400 carets: improve the code
* src/location.c: Remove duplicate documentations.
(caret_info): Stylistic change.
(location_caret): Many reworks.
2012-12-07 12:02:00 +01:00
Akim Demaille edf9a06f27 maint: update news
* NEWS: There is no 2.6.6, remove its stub.
2012-12-07 10:40:31 +01:00
Akim Demaille 85a2f27fc4 build: keep -Wmissing-declarations and -Wmissing-prototypes for modern GCCs
Fixes a -Werror failure of xalloc.h used in src.
From Eric Blake.
http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00006.html

* configure.ac: Check whether GCC pragma diagnostic push/pop works.
Enable these warnings for bison if it does.
Enable these warnings for the test suite anyway.
2012-12-07 10:16:47 +01:00
Akim Demaille 28d16d1f7c build: drop -Wcast-qual
Suggested by Jim Meyering.
http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00017.html
* configure.ac (warn_common): Remove -Wcast-qual.
2012-12-07 09:48:41 +01:00
Akim Demaille f72721518b gnulib: update 2012-12-07 09:15:13 +01:00
Theophile Ranquet 9960a6ae75 misc: pacify the Tiny C Compiler
* src/graphviz.c (conclude_red): Remove a useless return.
2012-12-06 10:53:30 +01:00
Theophile Ranquet b56484a5d3 cpp: make the check of Flex version portable
This was problematic with tcc 0.9.25

* src/flex-scanner.h (FLEX_VERSION_GT): Rewrite and rename as...
(FLEX_VERSION): This.
2012-12-05 19:14:23 +01:00
Theophile Ranquet e35cd6def7 misc: require getline
* bootstrap.conf: Here, used by src/location.c.
* src/getargs.c (long_options): Rename --flags to --feature.
2012-12-05 15:39:52 +01:00
Akim Demaille 7ae57e2a35 c++: support wide strings for file names
Reported by Mark Boyall.
http://lists.gnu.org/archive/html/help-bison/2011-08/msg00002.html

* data/location.cc (operator<<): Be templated on the type of
output stream.
* tests/headers.at (Several parsers): Adjust.
2012-12-05 13:22:21 +01:00
Theophile Ranquet 7bada5355e doc: document carets
* NEWS: Announce it.
* doc/bison.texi (Bison Options):  Here.
2012-12-05 13:46:01 +01:00
Theophile Ranquet 505ece5171 tests: enhance existing tests with carets
* tests/actions.at: Unset value.
* tests/conflicts.at: Rule useless due to conflicts.
* tests/input.at: Missing terminator, unexpected end of file, command line
redefinition of variable.
* tests/named-refs.at: Many errors.
* tests/reduce.at: Useless nonterminals and rules.
* tests/regression.at: Large token.
2012-12-05 13:46:01 +01:00
Theophile Ranquet 3f5d1b2c67 errors: show carets
* src/locations.c (caret_info): New, persistant information useful
for...
(location_caret): New, print a caret.
(cleanup_caret): Release caret_info cleanly, call it...
* src/main.c (main): Here.
* src/complain.c (error_message): Call location_caret here.
2012-12-05 13:46:01 +01:00
Theophile Ranquet 0db2648930 getargs: add support for --flags/-f
Introduce -fdiagnostics-show-caret

* src/getargs.c (flag_flag): New global.
* src/getargs.h (flag): New enum.
2012-12-05 12:10:51 +01:00
Theophile Ranquet effd30c08d getargs: don't label --language/-l as experimental
* NEWS: Announce it.
* doc/bison.texi, src/getargs.c (usage): Here.
2012-12-04 15:54:43 +01:00
Theophile Ranquet a37131cc63 getargs: fix the locations of command-line input
* src/getargs.c (command_line_location): Here.
* tests/input.at: Adjust.
2012-12-03 17:21:15 +01:00
Theophile Ranquet d4e985d587 errors: indent missing action code semicolon warning
Also, remove a duplicate #define.

* src/scan-code.l (SC_RULE_ACTION): Here.
* tests/actions.at: Adjust.
2012-12-03 17:21:15 +01:00
Akim Demaille 03dbf629d5 parser: accept #line NUM
* src/scan-gram.l (scanner): Accept '#line NUM'.
(handle_syncline): Adjust to the possible missing file name.
2012-12-03 15:59:57 +01:00
Akim Demaille 1c7ec959b1 m4: use a safer pattern to enable/disable output
Work on some other areas of Bison revealed that some macros expanded
to be expanded only once were actually expanded several times.  This
was due to the fact that changecom was not properly restored each
time, and macro names appearing in comments were then expanded.

Introduce begin/end macros which are easier to match that
changecom()/changecom(#).

* data/bison.m4 (b4_output_begin, b4_output_end): New.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java,
* data/location.cc, data/stack.hh, data/yacc.c:
Use them.
2012-12-03 15:44:40 +01:00
Akim Demaille 6ee95cd0d9 tests: beware of gnulib's need for config.h
* tests/skeletons.at, tests/torture.at: Be sure to include config.h
where appropriate.
2012-12-03 15:44:40 +01:00
Akim Demaille 8aef6e0db5 gnulib: update
* lib/yyerror.c: Include config.h since the following stdio.h might be
from gnulib.
2012-11-30 12:37:34 +01:00
Akim Demaille 3804aa260b yacc.c, glr.c: check and fix the display of locations
In some case, negative column number could be displayed.
Make YY_LOCATION_PRINT similar to bison's own implementation of
locations.  Since the macro is getting fat, make it a static
function.
Reported by Jonathan Fabrizio.

* data/c.m4 (yy_location_print_define): Improve the implementation,
and generate the yy_location_print_ function.
Adjust YY_LOCATION_PRINT.
* tests/actions.at (Location Print): New tests.
2012-11-30 11:19:43 +01:00
Akim Demaille 4c36bc2b8d formatting changes
* data/c.m4: Fix comments, put macros in a more natural order.
Space changes (from M-x whitespace-cleanup).
* src/location.c: Fix spaces.
* tests/actions.at: Space changes.
2012-11-30 11:19:33 +01:00
Akim Demaille 5215919366 glr.c: remove stray macro
* data/glr.c (YYOPTIONAL_LOC): Remove, unused since commit
769a8ef9bc.
2012-11-30 11:15:12 +01:00
Akim Demaille 511dd971ba doc: minor fixes
* doc/bison.texi: Use stderr for error messages.
Meta-variables are usually spelled in lower case.
Use @code for function names.
2012-11-29 14:35:48 +01:00
Akim Demaille 371f1b2b7b doc: improve the index
* doc/bison.texi: Fix uses of "deffn" so that the arguments of the
directives do not show in the index.
Remove a duplicate entry for api.pure.
2012-11-29 14:09:34 +01:00
Theophile Ranquet 1f1bd57297 doc: introduce api.pure full, rearrange some examples
* NEWS: Add entry.
* doc/bison.texi (%define Summary): Show the old Yacc behaviour.
(Parser Function): Move parse-param examples here.
(Pure Calling): Remove parse-param examples.
(Error Reporting): Don't show the old behavior, stick to 'full'.
2012-11-29 11:08:58 +01:00
Theophile Ranquet 6428a8a4a5 yacc.c: support "%define api.pure full"
This makes the interface for yyerror() pure without the need for a spurious
parse_param.

* data/yacc.c (b4_pure_if, b4_pure_flag): New definition, accept three states.
(b4_yacc_pure_if): Rename as...
(b4_yyerror_arg_loc_if): This, and use b4_pure_flag.
* tests/actions.at (%define api.pure): Modernize.
* test/calc.at (Simple LALR Calculator): Modernize.
* tests/local.at (AT_YYERROR_ARG_LOC_IF): Adjust.
2012-11-29 11:08:36 +01:00
Theophile Ranquet dbb998364f local.at: improvements
* tests/local.at (AT_YYERROR_FORMALS): Make llocp const.
(AT_PURE_AND_LOC_IF, AT_GLR_OR_PARAM_IF): Remove, expand...
(AT_YYERROR_ARG_LOC_IF): Here, and use m4_join for readability.
2012-11-26 12:00:14 +00:00
Akim Demaille c6bf97ccb4 Merge remote-tracking branch 'origin/branch-2.6' into maint
* origin/branch-2.6:
  yacc.c: always initialize yylloc
  doc: one of the fixes for an ambiguous grammar was ambiguous too
  doc: fix the dangling else with precedence directives
  doc: prefer "token" to TOKEN
  doc: formatting changes

Conflicts:
	NEWS
	doc/bison.texi
2012-11-26 09:05:28 +01:00
Theophile RanquetandAkim Demaille fb4c8a7cb9 yacc.c: always initialize yylloc
The initial location might be used if the parser starts by an empty
reduction, so really ensure proper initialization of the initial
location.  The previous approach fails for PostgreSQL, which uses
Reported by Peter Eisentraut.
http://lists.gnu.org/archive/html/bug-bison/2012-11/msg00023.html
With help from Théophile Ranquet.

* data/yacc.c (b4_declare_scanner_communication_variables): Be sure
to initialize yylloc, even when its structure is unknown.
(yyparse): Simplify the call to b4_dollar_pushdef.
* tests/actions.at (Initial location): Check of similar pattern
as in the case of PostgreSQL.
2012-11-23 15:44:19 +01:00
Akim Demaille 68ac70bc7b scanner: issue a single error for groups of invalid characters
* src/scan-gram.l: Scan groups of invalid characters together.
* tests/input.at, tests/named-refs.at: Adjust.
2012-11-23 11:36:42 +01:00
Akim Demaille ac7f308c8e tests: formatting changes
* tests/named-refs.at: Here.
2012-11-23 11:31:10 +01:00
Akim Demaille 53e2cd1ebd doc: one of the fixes for an ambiguous grammar was ambiguous too
Reported by Аскар Сафин.
http://lists.gnu.org/archive/html/bug-bison/2012-11/msg00024.html

* doc/bison.texi (Reduce/Reduce): Fix the resulting ambiguity using
precedence/associativity directives.
2012-11-23 09:47:20 +01:00
Akim Demaille c28cd5dc5a doc: fix the dangling else with precedence directives
* doc/bison.texi (Non Operators): New node.
(Shift/Reduce): Point to it.
Don't promote "%expect n" too much.
2012-11-22 15:58:44 +01:00
Akim Demaille 534cee7ae8 doc: prefer "token" to TOKEN
This is more readable in short examples.

* doc/bison.texi (Shift/Reduce): here.
Make "win" and "lose" action more alike.
2012-11-22 15:58:43 +01:00
Akim Demaille 51356dd2ad doc: formatting changes
* doc/bison.texi: Use @group.
2012-11-22 14:24:54 +01:00
Akim Demaille 96029914a6 scanner: use explicit "ignore" statements
* src/scan-gram.l: here.
2012-11-14 10:57:45 +01:00
Theophile RanquetandAkim Demaille 05c93b7d84 tests: close files in glr-regression
* tests/glr-regression.at: Here.
2012-11-12 16:46:57 +01:00
Theophile RanquetandAkim Demaille be3517b007 xml: match DOT output and xml2dot.xsl processing
Make the DOT produced by XSLT processing equivalent to the one made with the
--graph option.

* data/xslt/xml2dot.xsl: Stylistic changes, and add support for reductions.
* doc/bison.texi (Xml): Update.
* src/graphviz.c (conclude_red): Minor stylistic changes to DOT internals.
(output_red): Swap enabled and disabled reductions output, for coherence
with XSLT output.
* src/print_graph.c (print_core): Minor stylistic change to States' output.
(print_actions): Swap order of output for reductions and transitions.
* tests/local.at (AT_BISON_CHECK_XML): Ignore differences in order.
* tests/output.at: Adjust to changes in DOT internals.
2012-11-12 16:46:55 +01:00
Theophile RanquetandAkim Demaille 489b320d4a xml: factor xslt space template
* data/xslt/bison.xsl (space): New, import from...
* data/xslt/xml2text.xsl: Here.
2012-11-12 16:45:09 +01:00
Theophile RanquetandAkim Demaille ccda5c9eac graph: fix a memory leak
* src/graphviz.c (output_red): Here.
2012-11-12 16:45:09 +01:00
Theophile RanquetandAkim Demaille 9c16d39944 xml: documentation
The XML output combined with the XSL Transformations provided in data/ are
incredibly useful, they should be documented.

* doc/bison.texi (Xml): New node.
2012-11-12 16:44:54 +01:00
Theophile Ranquet d42fe46ec3 output: capitalize State
* src/print.c (print_state): Here.
* tests/conflicts.at, tests/existing.at, tests/local.at, tests/reduce.at,
tests/regression.at, tests/sets.at: Adjust.
2012-11-12 10:25:13 +00:00
Akim Demaille bfdcc3a0b2 maint: address syntax-check errors.
* cfg.mk: Ignore the "error" call in tests/c++.at, it is not to be
translated.
* doc/bison.texi: Fix incorrect @pxref use.
* po/POTFILES.in: Add missing file.
* src/print_graph.c: Remove useless include.
2012-11-12 09:39:41 +01:00
Akim Demaille ebbc76d0d7 tests: use valgrind where appropriate
Reported by Théophile Ranquet.

* cfg.mk (sc_at_parser_check): New.
* tests/c++.at: Fix use of AT_CHECK vs. AT_PARSER_CHECK.
2012-11-12 09:33:26 +01:00
Akim Demaille 9bf1eca7c9 Merge remote-tracking branch 'origin/branch-2.6' into maint
* origin/branch-2.6:
  tests: use valgrind where appropriate
  tests: don't expect $EGREP to support -w
2012-11-12 09:06:55 +01:00
Akim Demaille 2bb8f621eb tests: use valgrind where appropriate
Reported by Théophile Ranquet.

* tests/glr-regression.at: Rewrite some test cases so that AT_PARSER_CHECK,
which runs valgrind, is exposed with the parser, not with "echo".
* tests/local.at, tests/regression.at, tests/headers.at:
Use AT_PARSER_CHECK for generated parsers.
2012-11-10 09:29:33 +01:00
Akim Demaille 3a526f5cc3 tests: don't expect $EGREP to support -w
Does not work on Solaris 10.  Reported by Dennis Clarke.
http://lists.gnu.org/archive/html/bug-bison/2012-11/msg00009.html
* tests/headers.at (Several parsers): Use Perl instead.
While at it, run it only once, on all the generated headers.
Adjust to YY_NULL be defined in position.hh.
2012-11-08 19:41:45 +01:00
Akim Demaille 2cf5f72e9e tests: more possible error compiler messages for "#error"
* tests/synclines.at (AT_SYNCLINES_COMPILE): Adjust for Clang.
Verified with GCC 4.0, 4.2 to 4.8, and Clang 2.9, 3.2: none skip.
2012-11-08 10:25:15 +01:00
Akim Demaille 429436aaf2 regen 2012-11-08 09:22:58 +01:00
Akim Demaille 3ada393894 Merge branch 'branch-2.6' into maint
* origin/branch-2.6:
  maint: post-release administrivia
  version 2.6.5
  regen
  tests: syntax-check
  tests: beware of compilers that do not support POSIXLY_CORRECT
  gnulib: update

Conflicts:
	NEWS
	src/parse-gram.c
	src/parse-gram.h
2012-11-08 09:20:48 +01:00
Akim Demaille 9d2423f55d maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-11-07 18:35:36 +01:00
Akim Demaille 9d3f7eaf1d version 2.6.5
* NEWS: Record release date.
2012-11-07 18:09:46 +01:00
Akim Demaille 2ead0fb793 regen 2012-11-07 17:33:14 +01:00
Akim Demaille 63951be29f tests: syntax-check
* tests/actions.at: Fix typo.
2012-11-07 17:31:32 +01:00
Akim Demaille 0a36880ad1 tests: beware of compilers that do not support POSIXLY_CORRECT
Running "maintainer-release-check" on OS X with Clang 2.9 fails,
because "clang-mp-2.9 -o test -g test.c" launches "/usr/bin/dsymutil
test -o test.dSYM" which fails with "error: unable to open executable
'-o'".

* m4/c-working.m4 (BISON_CHECK_WITH_POSIXLY_CORRECT)
(BISON_C_COMPILER_POSIXLY_CORRECT): New.
* configure.ac: Use the latter.
* tests/atlocal.in (POSIXLY_CORRECT_IS_EXPORTED): New.
* tests/local.at (AT_BISON_CHECK_WARNINGS_): Use it instead of computing its
value each time.
(AT_QUELL_VALGRIND): Skip tests that cannot work because of compilers
that do not support POSIXLY_CORRECT.
2012-11-07 17:23:06 +01:00
Akim Demaille 5a000c51f7 gnulib: update 2012-11-07 12:46:30 +01:00
Akim Demaille 049016237e Merge branch 'branch-2.6' into maint
* origin/branch-2.6: (24 commits)
  tests: calc: modernize the use of locations
  tests: remove useless location initializations
  lalr1.cc: always initialize yylval.
  tests: check that C and C++ objects can be linked together.
  yacc.c: also disable -Wuninitialized.
  glr.cc, yacc.c: initialize yylloc properly
  yacc.c, glr.c: a better YY_LOCATION_PRINT
  yacc.c: simplify initialization
  doc: formatting changes
  c++: fix position operator signatures
  tests: remove useless location initialization.
  tests: fix locations in C
  tests: handle %parse-param in the generated yyerror
  tests: simplifications
  grammars: fix display of nul character in error message
  tests: sort
  tests: cosmetic changes
  comment changes
  autoconf: update
  gnulib: update
  ...

Conflicts:
	NEWS
	gnulib
	tests/named-refs.at
	tests/regression.at
2012-11-06 18:12:05 +01:00
Akim Demaille 3154ff8ef6 tests: calc: modernize the use of locations
* tests/calc.at: Don't initialize the location, let the parser
do it.
Use a $printer.
Change some testing input to be easier to distinguish (instead of always
"0 0" for instance).
2012-11-06 17:36:04 +01:00
Akim Demaille d03c0413f0 tests: remove useless location initializations
* tests/actions.at, tests/calc.at: here.
2012-11-06 17:36:04 +01:00
Akim Demaille 41a4806a82 lalr1.cc: always initialize yylval.
* data/lalr1.cc: here.
2012-11-06 17:36:04 +01:00
Akim Demaille 8aaa0c2f86 tests: check that C and C++ objects can be linked together.
* tests/local.at (AT_SKIP_IF_CANNOT_LINK_C_AND_CXX): New.
* tests/headers.at (Several parsers): Use it.
2012-11-06 17:36:04 +01:00
Akim Demaille 63e8426ac6 yacc.c: also disable -Wuninitialized.
* data/yacc.c (YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN): For some versions
of GCC, -Wmaybe-uninitialized alone does not suffice.
2012-11-06 17:36:04 +01:00
Akim Demaille a1d1ab50a0 glr.cc, yacc.c: initialize yylloc properly
There are several issues to address here.  One is that yylloc should
be initialized when possible.  Another is that the push parser needs
to update yypushed_loc when the user modified it.  And if the parser
starts by a reduction of an empty, it uses the first location on the
stack, which, therefore, must also be initialized to this initial
location.

This is getting complex, especially since because initializing a
global (impure interface) is different from initializing a local
variable.  To simplify, the local yylloc is not initialized during its
definition.

* data/c.m4 (b4_yyloc_default_define): Replace by...
(b4_yyloc_default): this.
Adjust dependencies.
* data/glr.cc: Initialize yylloc.
* data/yacc.c (b4_declare_scanner_communication_variables):
Initialize yylloc during its definition.
Don't define yyloc_default.
(yypush_parse): The location formal is not const, as we might
initialize it.
(yyparse): Define yyloc_default.
Use it before running the user initial action.
Possibly update the first location on the stack, and the pushed
location after the user initial action.
* tests/actions.at (Initial locations): Check that the initial
location is correct.
2012-11-06 17:35:38 +01:00
Akim Demaille 3237f57096 yacc.c, glr.c: a better YY_LOCATION_PRINT
* data/c.m4 (b4_yy_location_print_define): New.
Now issues "short" locations, e.g., "1.1" instead of "1.1-1.1".
Was initially a function, but then we face "static but unused"
warnings.
Simpler as a macro.
* tests/local.at, data/glr.c, data/yacc.c: Use it instead of duplicating.
* tests/actions.at: Adjust expectations.
2012-11-06 13:36:24 +01:00
Akim Demaille 7d846072c7 yacc.c: simplify initialization
* data/yacc.c: Fuse the initializations of yyssp, yyss and the like.
Remove an obsolete comment: we do initialize these initial stack
members (in some cases).
2012-11-06 13:36:19 +01:00
Akim Demaille 8b49e6bfc5 doc: formatting changes
* doc/bison.texi: In a pointer type.
2012-11-05 13:13:19 +01:00
Akim Demaille 0e1ccdfae0 c++: fix position operator signatures
* data/location.cc (operator+=, operator-=): Remove const from return
type.
2012-11-05 13:13:19 +01:00
Akim Demaille 86649705b4 tests: remove useless location initialization.
* tests/glr-regression.at: here.
glr.c does initialize yylloc.
2012-11-05 13:13:19 +01:00
Akim Demaille 7dbb8d8aba tests: fix locations in C
* tests/local.at (AT_YYERROR_DEFINE): Don't display the end of the location
if it is not after its beginning.
* tests/actions.at, tests/cxx-type.at: Adjust the expected output.
2012-11-05 13:13:19 +01:00
Akim Demaille 3472de825e tests: handle %parse-param in the generated yyerror
* tests/local.at (AT_PARSE_PARAMS): New.
(AT_YYERROR_FORMALS, AT_YYERROR_DEFINE): Use it to add the parse-param
to yyerror.
* tests/calc.at, tests/regression.at: Use AT_YYERROR_DEFINE and
AT_YYERROR_DECLARE, now that they handle properly the parse-params.
Be sure to let AT_BISON_OPTION_PUSHDEFS now what parse-params are used.
2012-11-05 10:15:12 +01:00
Akim Demaille 3112e7a82b tests: simplifications
* tests/actions.at (Exotic Dollars): Formatting changes.
Use AT_FULL_COMPILE.
(AT_CHECK_PRINTER_AND_DESTRUCTOR): Remove useless initialization of @$.
2012-11-05 10:15:12 +01:00
Akim Demaille 95066e9208 grammars: fix display of nul character in error message
Reported by Marc Mendiola.
http://lists.gnu.org/archive/html/help-bison/2012-10/msg00017.html

* gnulib: Update to get quote_mem.
* src/scan-gram.l: Use it.
* tests/input.at (Invalid inputs): Additional checks.
* tests/named-refs.at: Likewise.
2012-11-01 16:14:14 +01:00
Akim Demaille baf0bd6145 tests: sort
* tests/regression.at (Invalid inputs, Invalid inputs with {}): Move to...
* tests/input.at: here, for consistency.
2012-11-01 16:14:14 +01:00
Akim Demaille 623a5147e6 tests: cosmetic changes
* tests/actions.at (AT_CHECK_PRINTER_AND_DESTRUCTOR): Improve the
displayed title.
2012-11-01 16:14:14 +01:00
Akim Demaille b720fedf83 comment changes
* data/lalr1.cc: here.
2012-11-01 16:14:14 +01:00
Akim Demaille a7ab55af2a autoconf: update
There are comment changes only in the files we use.
2012-11-01 15:37:57 +01:00
Akim Demaille 003db649bb gnulib: update 2012-11-01 15:37:57 +01:00
Akim Demaille a21733f2b4 regen 2012-10-28 16:53:39 +01:00
Akim Demaille a68b1f237e yacc.c: initialize yylval and yylloc.
When generating a pure push parser, the initialization of yylval and
yylloc may not be visible to the compiler.  With warnings enabled, GCC
4.3.6, 4.4.7, 4.5.4, and 4.6.3 report uninitialized uses of
yylval/yylloc.  Using local pragmas to disable these warnings is not
supported before 4.6, and 4.6 does not support it properly.  So
initialize yylval and yylloc at their definition.  Reported by Peter
Simons.  See
http://lists.gnu.org/archive/html/bison-patches/2012-10/msg00133.html

* data/c.m4 (b4_yyloc_default_define): New.
* data/yacc.c: Use it when locations are requested.
(YYLVAL_INITIALIZE): Replace by...
(YY_INITIAL_VALUE): this.
(yyparse): Initialize yylloc and yylval.
Therefore, remove the initialization of yylloc's field.
* data/glr.c: Likewise.
2012-10-28 16:53:18 +01:00
Akim Demaille 71cb558dfe Merge branch 'branch-2.6' into maint
* origin/branch-2.6:
  regen
  yacc.c: do not define location support when not using locations
  maint: be compilable with GCC 4.0
  tests: address a warning from GCC 4.4
  tests: don't use options that Clang does not support
  tests: restore the tests on -Werror
  regen
  parse-gram: update the Bison interface
  fix comment
2012-10-26 16:33:20 +02:00
Akim Demaille ead713a176 doc: minor style change
* doc/figs/example-reduce.txt: here.
2012-10-26 16:32:51 +02:00
Akim Demaille e20daefe98 maint: use gendocs's new -I option
* gnulib: Update gendocs.
* cfg.mk (gendocs_options_): New.
2012-10-26 16:32:51 +02:00
Akim Demaille 0fb7b95c5f regen 2012-10-26 14:28:34 +02:00
Akim Demaille 4f4a54ab92 yacc.c: don't use _Pragma GCC diagnostic with 4.6
Reported by Peter Simons.
http://lists.gnu.org/archive/html/bug-bison/2012-10/msg00033.html

* data/yacc.c (b4_declare_scanner_communication_variables): 4.7
seems fine though.
2012-10-26 14:27:37 +02:00
Akim Demaille bb8674a537 regen 2012-10-26 14:27:32 +02:00
Akim Demaille 5fb07775a1 yacc.c: do not define location support when not using locations
* data/yacc.c (YYLLOC_DEFAULT, YYRHSLOC): Don't define when not
using locations.
2012-10-26 14:25:11 +02:00
Akim Demaille e0992e5458 maint: be compilable with GCC 4.0
The "shadows a global declaration" warning in GCC 4.0 was a bit
annoying.  It does not like that a type name be used in a prototype of
a function (not the implementation, just the declaration):

  In file included from src/LR0.c:38:
  src/reader.h:56: warning: declaration of 'named_ref' shadows a
                            global declaration
  src/named-ref.h:35: warning: shadowed declaration is here

It does not like either when a global variable name is used in a
prototype.  Flex 2.5.37 generates this prototype:

  void gram_set_debug (int debug_flag  );

* src/getargs.h, src/getargs.c (debug_flag): Rename as...
(debug): this.
Adjust dependencies.
* src/reader.h: Don't use "named_ref" as a formal argument name.
2012-10-26 14:25:11 +02:00
Akim Demaille 54dccdb2ca tests: address a warning from GCC 4.4
236. torture.at:465: testing Exploding the Stack Size with Alloca ...
../../../tests/torture.at:474: bison -o input.c input.y
../../../tests/torture.at:474: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS
stderr:
cc1: warnings being treated as errors
input.y: In function 'main':
input.y:60: error: 'status' may be used uninitialized in this function

* tests/torture.at (AT_DATA_STACK_TORTURE): Initial status to avoid
the previous error.
2012-10-25 14:42:24 +02:00
Akim Demaille 324a557651 tests: don't use options that Clang does not support
* configure.ac (WARN_CFLAGS, WARN_CXXFLAGS): Do not include options
that Clang does not support.
2012-10-25 14:26:09 +02:00
Akim Demaille 94843f0aa3 tests: restore the tests on -Werror
When run as /bin/sh, Bash sets the shell variable POSIXLY_CORRECT to
y.  The test suite checks for the envvar POSIXLY_CORRECT to turn of
some tests not supported in POSIX mode.  Restore these tests.

Reported by the Hydra build farm, from Rob Vermaas.

* tests/local.at (AT_BISON_CHECK_WARNINGS_): Check the envvar
POSIXLY_CORRECT, not the shell variable.
2012-10-25 12:28:35 +02:00
Akim Demaille 20df0160bc regen 2012-10-25 09:43:52 +02:00
Akim Demaille e73ac5a09b parse-gram: update the Bison interface
* src/parse-gram.y (%pure-parser, %name-prefix): Replace with...
(%define api.pure, %define api.prefix)
* src/location.h, src/scan-gram.h: Adjust to api.prefix.
2012-10-25 09:43:09 +02:00
Akim Demaille 851e3f8468 fix comment
* data/c.m4 (b4_YYDEBUG_define): here.
2012-10-25 09:43:09 +02:00
Akim Demaille df04a68ab5 Merge branch 'branch-2.6' into maint
* origin/branch-2.6:
  maint: post-release administrivia
  version 2.6.4
  regen
  2.6.4: botched 2.6.3
2012-10-23 14:03:11 +02:00
Akim Demaille 6f1360bd89 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-10-23 13:58:51 +02:00
Akim Demaille 0ac1584946 version 2.6.4
* NEWS: Record release date.
2012-10-23 13:46:28 +02:00
Akim Demaille 40a1cd37f3 regen 2012-10-22 18:33:47 +02:00
Akim Demaille 468455e12b 2.6.4: botched 2.6.3
* NEWS: here.
2012-10-22 18:32:19 +02:00
Akim Demaille b7226022b0 Merge branch '2.6.3' into maint
* 2.6.3: (22 commits)
  maint: post-release administrivia
  version 2.6.3
  gnulib: update
  tests: check %no-lines
  NEWS: warnings with clang
  warnings: avoid warnings from clang
  tests: no longer disable -O compiler options
  yacc.c: initialize yylval in pure-parser mode
  skeletons: style changes
  tests: minor improvements
  tests: use $PERL instead of perl
  build: look for Perl in configure.
  tests: fix sed portability issues
  tests: diff -u is not portable
  maint: word changes
  lalr1.cc: fix test suite portability
  maint: fix an erroneous include
  tests: check that headers are self contained
  doc: add missing documentation for --report
  headers: move CPP guards into YY_*_INCLUDED to avoid collisions
  ...

Conflicts:
	NEWS
	doc/bison.texi
	tests/headers.at
2012-10-22 16:04:12 +02:00
Akim Demaille a4eb820f17 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-10-22 15:28:10 +02:00
Akim Demaille 6eb8f74f8f version 2.6.3
* NEWS: Record release date.
2012-10-22 15:16:12 +02:00
Akim Demaille cc5a986ce4 gnulib: update 2012-10-22 12:17:37 +02:00
Akim Demaille ae2199381e tests: check %no-lines
* tests/synclines.at: here.
2012-10-22 12:17:37 +02:00
Akim Demaille 7b70847e58 NEWS: warnings with clang
* NEWS: here.
2012-10-22 12:17:35 +02:00
Akim Demaille 19d9b60787 warnings: avoid warnings from clang
Fix the following warning

  parse-gram.c:2078:14: error: equality comparison with extraneous parentheses
                        [-Werror,-Wparentheses-equality]
    if (((yyn) == (-91)))
         ~~~~~~^~~~~~~~
  parse-gram.c:2078:14: note: remove extraneous parentheses around the
                        comparison to silence this warning
    if (((yyn) == (-91)))
        ~      ^       ~
  parse-gram.c:2078:14: note: use '=' to turn this equality comparison into
                        an assignment
    if (((yyn) == (-91)))
               ^~
               =
  1 error generated.

and the following one:

  input.cc:740:1: error: function declared 'noreturn' should not return
                         [-Werror,-Winvalid-noreturn]
  static void yyMemoryExhausted (yyGLRStack* yystackp)
    __attribute__ ((__noreturn__));
  static void
  yyMemoryExhausted (yyGLRStack* yystackp)
  {
    YYLONGJMP (yystackp->yyexception_buffer, 2);
  }
  ^
  1 warning and 1 error generated.

This is Apple clang version 3.1 (tags/Apple/clang-318.0.61).

* data/c.m4 (b4_table_value_equals): Use (!!(A == B)) instead of (A == B)
to avoid this warning.
Any reasonable compiler should generate the same code.
* src/uniqstr.h (UNIQSTR_EQ): Likewise.
* data/glr.c (LONGJMP): abort after longjmp to pacify clang.
2012-10-22 12:17:17 +02:00
Akim Demaille 8f8439cee1 tests: no longer disable -O compiler options
Tests are running without -O since
f377f69fec because some warnings (about
yylval not being initialized) show only when GCC is given -O2.  The
previous patch fixes the warnings. Run the test suite with compiler
options unmodified.

* tests/atlocal.in (O0CFLAGS, O0CXXFLAGS): Remove, use CFLAGS and
CXXFLAGS.
2012-10-22 12:17:14 +02:00
Paul EggertandAkim Demaille fa5303b8ff yacc.c: initialize yylval in pure-parser mode
See http://lists.gnu.org/archive/html/bison-patches/2012-08/msg00024.html
(spreading over September and October).

* data/yacc.c (YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN)
(YY_IGNORE_MAYBE_UNINITIALIZED_END, YYLVAL_INITIALIZE):
New macros.  Use them to suppress an unwanted GCC diagnostic.
2012-10-22 12:16:33 +02:00
Akim Demaille 39845e8e40 skeletons: style changes
* data/yacc.c, data/glr.c: Prefer Title case for (CPP) macro arguments.
2012-10-22 12:16:33 +02:00
Akim Demaille 5b34bb3110 tests: minor improvements
* tests/c++.at: Space changes.
Use AT_YYERROR_DEFINE.
* tests/local.at (AT_YYERROR_DEFINE): Issue errors on unknown languages.
2012-10-22 12:16:33 +02:00
Akim Demaille c955769a75 tests: use $PERL instead of perl
* tests/atlocal.in (PERL): New.
Sort.
* tests/calc.at, tests/input.at, tests/local.at, tests/regression.at,
* tests/skeletons.at, tests/synclines.at, tests/torture.at: here.
2012-10-22 12:16:33 +02:00
Akim Demaille 82443642d2 build: look for Perl in configure.
Bison uses "/usr/bin/perl" or "perl" in several places, and it does
not appear to be a problem.  But, at least to make it simpler to
change PERL on the make command line, check for perl in configure.

* configure.ac (PERL): New.
* doc/Doxyfile.in, doc/Makefile.am, tests/bison.in: Use it.
2012-10-22 12:16:33 +02:00
Akim Demaille e272d9dc80 tests: fix sed portability issues
Reported by Didier Godefroy,
<http://lists.gnu.org/archive/html/bug-bison/2012-10/msg00005.html>.

* tests/calc.at (AT_CHECK_SPACES): Use Perl.
2012-10-22 12:16:33 +02:00
Akim Demaille 9a50c55af7 tests: diff -u is not portable
Reported by Didier Godefroy
<http://lists.gnu.org/archive/html/bug-bison/2012-10/msg00006.html>.

* tests/existing.at (AT_LALR1_DIFF_CHECK): Skip if diff -u does not
work.
2012-10-22 12:16:33 +02:00
Akim Demaille e28ce5def0 maint: word changes
* README-hacking (Typical errors): Improve wording.
2012-10-22 12:16:32 +02:00
Akim Demaille 7aa15a0026 lalr1.cc: fix test suite portability
Reported by Rob Vermaas' Hydra build farm on x86_64-darwin 10.2.0 with
G++ 4.6.3.

* tests/headers.at (Several parsers): Include AT_DATA_SOURCE_PROLOGUE
in the files to compile.
* data/location.cc: Do not include twice string and iostream (once
by position.hh, and then by location.hh).
* README-hacking (Typical errors): Some hints for other maintainers.
2012-10-22 12:16:32 +02:00
Theophile RanquetandAkim Demaille 90b1335aed maint: fix an erroneous include
This fixes test 130 (Several parsers).

* data/location.cc: Include <iostream> rather than <iosfwd> since
we really need << on strings for instance.
* NEWS: Document this.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-22 12:16:28 +02:00
Akim Demaille ddbd0c40dc tests: check that headers are self contained
Reported by Alexandre Duret-Lutz.

* tests/headers.at (Several parsers): here.
2012-10-22 12:16:08 +02:00
Akim Demaille c473e022d9 doc: add missing documentation for --report
* doc/bison.texi (Bison Options): Document --report's "solved", "all",
and "none".
2012-10-22 12:16:08 +02:00
Akim Demaille 6192d2c6de headers: move CPP guards into YY_*_INCLUDED to avoid collisions
See <http://lists.gnu.org/archive/html/bug-bison/2012-09/msg00016.html>.

* data/c.m4 (b4_cpp_guard): Prepend YY_ and append _INCLUDED.
* tests/headers.at: Adjust.
* NEWS, doc/bison.texi: Document.
2012-10-22 12:16:04 +02:00
Akim Demaille 3746fc33c4 minor changes.
* NEWS: Word changes.
* doc/bison.texi: Spell check.
Fix minor issues.
* tests/headers.at: Comment and formatting changes.
2012-10-22 12:14:57 +02:00
Akim Demaille 36cdaaac53 gnulib: update 2012-10-22 12:14:04 +02:00
Akim Demaille 73c2a97540 gnulib: update 2012-10-19 12:56:48 +02:00
Akim Demaille a8ad048142 xml: slight improvement of the DOT output
This was completely forgotten...  Nothing about XML is actually
documented...

* data/xslt/xml2dot.xsl: Use boxes, and Courier font.
2012-10-19 12:56:48 +02:00
Akim Demaille a029e56f5c maint: check for dot before using it
* configure.ac: here.
* doc/Makefile.am: Use $(DOT).
Ship the generated files, to spare the user the need for Graphviz.
2012-10-19 12:56:48 +02:00
Theophile RanquetandAkim Demaille fc4fdd623e graphs: documentation
Note that 'make web-manual' fails.

* NEWS: Document these changes.
* doc/Makefile.am: Adjust to generate example files.
* doc/bison.texi: Add a Graphviz section after "Understanding::", the section
describing the .output file, because these are similar.
* doc/figs/example-reduce.dot, doc/figs/example-reduce.txt,
doc/figs/example-shift.dot, doc/figs/example-shift.txt: New, minimal
examples to illustrate the documentation.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-18 17:03:30 +02:00
Theophile RanquetandAkim Demaille dd47b5220c graphs: add tests, introducing -k graph
* tests/output.at (AT_TEST): New.
Use it to add 6 --graph tests.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-18 16:49:39 +02:00
Theophile RanquetandAkim Demaille ce6cf10f73 graphs: change the output format of the rules
Use something similar to the report file.

* src/print_graph.c (print_lhs): New, obstack equivalent of rule_lhs_print.
(print_core): Use here.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-18 16:27:11 +02:00
Theophile RanquetandAkim Demaille 8048226f50 graphs: style changes
* src/graphviz.c (start_graph): Use courier font.
(conclude_red): Use commas to separate attributes. Show the acceptation
as a special reduction, with a blue color and an "Acc" label. Show the
lookahead tokens between square brackets.
(output_red): No longer label default reductions.
* src/print_graph.c (print_core): Refactor spacing, and print an
additional space between a rule's rhs and its lookahead tokens. Also,
capitalize "State".
(print_actions): Style, move a declaration.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-18 16:23:27 +02:00
Theophile RanquetandAkim Demaille 85935600ad graphs: address an issue with R/R conflicts
All disabled reductions should now be shown as such.

* src/graphviz.c (output_red): Here.
(conclude_red): New.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-18 16:17:10 +02:00
Akim Demaille 715978d726 java: fixes
* data/java.m4: Remove stray M4 characters.
2012-10-16 11:04:03 +02:00
Akim Demaille 7287be84f1 java: use api.location.type and api.position.type
* data/java.m4: here.
* NEWS, doc/bison.texi, tests/java.at: Adjust.
2012-10-12 13:00:59 +02:00
Akim Demaille e94ca80bbb tests: check %no-lines
* tests/synclines.at: here.
2012-10-12 12:25:53 +02:00
Akim Demaille d74d8cb6c5 tests: minor simplification
* tests/headers.at (Several parsers): Use *.y even for C++.
2012-10-12 10:09:40 +02:00
Akim Demaille 43eb7674aa graphs: stylistic changes.
* src/graphviz.c (output_red): Comment and formatting changes.
2012-10-11 16:58:03 +02:00
Theophile RanquetandAkim Demaille d79683fa95 graphs: minor style changes
* src/graphviz.c (output_red): Fix C90 issues.
Reduce variable scopes.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-11 16:50:37 +02:00
Theophile RanquetandAkim Demaille 83bae26d3f graphs: show reductions
* src/graphviz.c (output_red): New, show reductions on the graph.
(no_reduce_bitset_init): New, initialize a bitset.
(print_token): New, print a lookahead token.
(escape): New, print "foo" as \"foo\" because Dot doesn't like quotes within
a label.

* src/graphviz.h : Adjust.
* src/print_graph.c (print_actions): Call output_red here.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-11 15:59:55 +02:00
Theophile RanquetandAkim Demaille 9fc99ca350 graphs: style: prefix state number with "state"
* src/print_graph.c (print_core): Here.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-11 15:59:35 +02:00
Theophile RanquetandAkim Demaille a13121f759 graphs: style: use left justification for states
The label text of nodes is centered "by default" (by the use of '\n' as
a line feed). This gives bad readability to the grammar rules shown in
state nodes, a left justification is much nicer. This is done by using '\l'
as the line feed.

In order to allow \l in the DOT file, changes to the quoting system seem
necessary.

* src/print_graph.c (print_core): Escape tokens here, instead of...
* src/graphviz.c (output_node): Here...
(escape): Using this, new.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-11 15:46:43 +02:00
Theophile RanquetandAkim Demaille 2be37f19fe graphs: style: prefix rules and change shapes
* src/graphviz.c (start_graph): Use box rather than ellipsis.
* src/print_graph.c (print_core): Prefix rules with their number.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-11 09:31:32 +02:00
Theophile RanquetandAkim Demaille 47a31596c6 obstack: import obstack_finish0 from master
* src/system.h (obstack_finish0): New.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-11 09:30:18 +02:00
Akim Demaille db8ab2be33 c++: api.location.type
This feature was introduced in 95a2de5695
(which is part of 2.5), but not documented.  Give it a proper name, and
make it public.

* data/c++.m4, data/lalr1.cc, data/glr.cc, data/java.m4: Use
api.location.type instead of location_type.
* src/muscle-tab.c (muscle_percent_variable_update): Map the latter to
the former.
* tests/local.at: Adjust.
* tests/calc.at: Use api.location.type.
Leave tests/java.at with location_type, at least for the time being,
to cover both names.
* doc/bison.texi: Document api.location.type.
(User Defined Location Type): New.
* NEWS: Update.
2012-10-09 15:59:18 +02:00
Akim Demaille 2aa5b25995 muscles: a function for backward compatibility
Based on commit 171ad99d64 from master.

* src/muscle-tab.c (muscle_percent_variable_update): New.
(muscle_percent_define_insert): Use it.
Define the variables with their initial value.
2012-10-09 15:58:37 +02:00
Akim Demaille 211c818502 maint: more macros
* src/output.c (ARRAY_CARDINALITY): Move to...
* src/system.h: here.
(STREQ, STRNEQ): new.
2012-10-09 12:13:09 +02:00
Akim Demaille c12c4c507d NEWS: warnings with clang
* NEWS: here.
2012-10-08 13:48:13 +02:00
Akim Demaille 34076080cd warnings: avoid warnings from clang
Fix the following warning

  parse-gram.c:2078:14: error: equality comparison with extraneous parentheses
                        [-Werror,-Wparentheses-equality]
    if (((yyn) == (-91)))
         ~~~~~~^~~~~~~~
  parse-gram.c:2078:14: note: remove extraneous parentheses around the
                        comparison to silence this warning
    if (((yyn) == (-91)))
        ~      ^       ~
  parse-gram.c:2078:14: note: use '=' to turn this equality comparison into
                        an assignment
    if (((yyn) == (-91)))
               ^~
               =
  1 error generated.

and the following one:

  input.cc:740:1: error: function declared 'noreturn' should not return
                         [-Werror,-Winvalid-noreturn]
  static void yyMemoryExhausted (yyGLRStack* yystackp)
    __attribute__ ((__noreturn__));
  static void
  yyMemoryExhausted (yyGLRStack* yystackp)
  {
    YYLONGJMP (yystackp->yyexception_buffer, 2);
  }
  ^
  1 warning and 1 error generated.

This is Apple clang version 3.1 (tags/Apple/clang-318.0.61).

* data/c.m4 (b4_table_value_equals): Use (!!(A == B)) instead of (A == B)
to avoid this warning.
Any reasonable compiler should generate the same code.
* src/uniqstr.h (UNIQSTR_EQ): Likewise.
* data/glr.c (LONGJMP): abort after longjmp to pacify clang.
2012-10-08 09:51:52 +02:00
Akim Demaille 321d3e35d5 tests: no longer disable -O compiler options
Tests are running without -O since
f377f69fec because some warnings (about
yylval not being initialized) show only when GCC is given -O2.  The
previous patch fixes the warnings. Run the test suite with compiler
options unmodified.

* tests/atlocal.in (O0CFLAGS, O0CXXFLAGS): Remove, use CFLAGS and
CXXFLAGS.
2012-10-08 09:51:08 +02:00
Paul EggertandAkim Demaille e365aa4c3d yacc.c: initialize yylval in pure-parser mode
See http://lists.gnu.org/archive/html/bison-patches/2012-08/msg00024.html
(spreading over September and October).

* data/yacc.c (YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN)
(YY_IGNORE_MAYBE_UNINITIALIZED_END, YYLVAL_INITIALIZE):
New macros.  Use them to suppress an unwanted GCC diagnostic.
2012-10-08 09:47:44 +02:00
Akim Demaille c5178eb75d skeletons: style changes
* data/yacc.c, data/glr.c: Prefer Title case for (CPP) macro arguments.
2012-10-08 09:34:40 +02:00
Akim Demaille d3e4409ad1 lalr1.cc: document exception safety
* NEWS: here.
* doc/bison.texi (Destructor Decl, C++ Parser Interface): and there.
2012-10-06 19:53:45 +02:00
Akim Demaille e8b86af83d lalr1.cc: check exception safety of error handling
* tests/c++.at (Exception safety): Don't use swap here, it
is useless.
Cover more test cases: yyerror, YYERROR, YYABORT, and
error recovery.
(Object): Instead of just keeping a counter of instances, keep
a list of them.
2012-10-06 19:53:45 +02:00
Akim Demaille 25a6ad2f10 lalr1.cc: check (and fix) %printer exception safety
* tests/c++.at (Exception safety): Let the parser support the --debug
option.
On 'p', throw an exception from the %printer.
* data/lalr1.cc (yyparse): Do not display the values we discard, as it
uses %printer, which might have thrown the exception.
2012-10-06 19:53:45 +02:00
Akim Demaille a26424642b lalr1.cc: check (and fix) %initial-action exception safety
* data/lalr1.cc: Check size > 1, rather than size != 1, when cleaning
the stack, as at the beginning, size is 0.
* tests/c++.at (Exception safety): Check exception safety in
%initial-action.
2012-10-06 19:53:45 +02:00
Akim Demaille 7e1fabbeae lalr1.cc: fix exception safety
lalr1.cc does not reclaim its memory when ended by an exception.

Reported by Oleksii Taran:
http://lists.gnu.org/archive/html/help-bison/2012-09/msg00000.html

* data/lalr1.cc (yyparse): Protect the whole yyparse by a try-catch
block that cleans the stack and the lookahead.
2012-10-06 19:53:45 +02:00
Akim Demaille cff926615f lalr1.cc: check exception safety.
* tests/c++.at (Exception safety): New.
2012-10-06 19:53:45 +02:00
Akim Demaille 117c794200 lalr1.cc: indentation fixes.
* data/lalr1.cc (yyparse): here.
Untabify a block of code.
2012-10-06 19:53:45 +02:00
Akim Demaille 88322b77b1 lalr1.cc: don't leave macros define to nothing
* data/lalr1.cc (YY_SYMBOL_PRINT, YY_REDUCE_PRINT, YY_STACK_PRINT):
Define to something so that, for instance, "if (foo) YY_SYMBOL_PRINT"
is valid even when !YYDEBUG.
2012-10-06 19:53:45 +02:00
Akim Demaille 535ee0cb54 tests: minor improvements
* tests/c++.at: Space changes.
Use AT_YYERROR_DEFINE.
* tests/local.at (AT_YYERROR_DEFINE): Issue errors on unknown languages.
2012-10-06 19:53:45 +02:00
Akim Demaille ff020c3061 tests: use $PERL instead of perl
* tests/atlocal.in (PERL): New.
Sort.
* tests/calc.at, tests/input.at, tests/local.at, tests/regression.at,
* tests/skeletons.at, tests/synclines.at, tests/torture.at: here.
2012-10-05 09:34:53 +02:00
Akim Demaille 45fdfd8108 build: look for Perl in configure.
Bison uses "/usr/bin/perl" or "perl" in several places, and it does
not appear to be a problem.  But, at least to make it simpler to
change PERL on the make command line, check for perl in configure.

* configure.ac (PERL): New.
* doc/Doxyfile.in, doc/Makefile.am, tests/bison.in: Use it.
2012-10-05 09:34:52 +02:00
Akim Demaille a727e7124d tests: fix sed portability issues
Reported by Didier Godefroy,
<http://lists.gnu.org/archive/html/bug-bison/2012-10/msg00005.html>.

* tests/calc.at (AT_CHECK_SPACES): Use Perl.
2012-10-05 09:34:16 +02:00
Akim Demaille a1a77e1fcc tests: diff -u is not portable
Reported by Didier Godefroy
<http://lists.gnu.org/archive/html/bug-bison/2012-10/msg00006.html>.

* tests/existing.at (AT_LALR1_DIFF_CHECK): Skip if diff -u does not
work.
2012-10-05 08:57:29 +02:00
Akim Demaille 10b009fa50 maint: word changes
* README-hacking (Typical errors): Improve wording.
2012-10-04 11:45:09 +02:00
Akim Demaille ec78bdab6d lalr1.cc: fix test suite portability
Reported by Rob Vermaas' Hydra build farm on x86_64-darwin 10.2.0 with
G++ 4.6.3.

* tests/headers.at (Several parsers): Include AT_DATA_SOURCE_PROLOGUE
in the files to compile.
* data/location.cc: Do not include twice string and iostream (once
by position.hh, and then by location.hh).
* README-hacking (Typical errors): Some hints for other maintainers.
2012-10-04 11:42:26 +02:00
Theophile RanquetandAkim Demaille a2b3f10183 maint: fix an erroneous include
This fixes test 130 (Several parsers).

* data/location.cc: Include <iostream> rather than <iosfwd> since
we really need << on strings for instance.
* NEWS: Document this.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-03 16:03:06 +02:00
Akim Demaille 04a4684a51 tests: check that headers are self contained
Reported by Alexandre Duret-Lutz.

* tests/headers.at (Several parsers): here.
2012-10-03 16:00:30 +02:00
Akim Demaille 57f8bd8d18 doc: add missing documentation for --report
* doc/bison.texi (Bison Options): Document --report's "solved", "all",
and "none".
2012-10-03 08:47:37 +02:00
Akim Demaille c9d5bcc938 headers: move CPP guards into YY_*_INCLUDED to avoid collisions
See <http://lists.gnu.org/archive/html/bug-bison/2012-09/msg00016.html>.

* data/c.m4 (b4_cpp_guard): Prepend YY_ and append _INCLUDED.
* tests/headers.at: Adjust.
* NEWS, doc/bison.texi: Document.
2012-10-01 11:18:22 +02:00
Akim Demaille 5a05f42ecf minor changes.
* NEWS: Word changes.
* doc/bison.texi: Spell check.
Fix minor issues.
* tests/headers.at: Comment and formatting changes.
2012-10-01 11:18:22 +02:00
Akim Demaille 93d133c932 gnulib: update 2012-09-28 15:04:57 +02:00
Theophile RanquetandAkim Demaille b506d9bfcb errors: indent "user token number redeclaration" context
This is the continuation of the work on the readability of errors
context.

* src/symtab.c (user_token_number_redeclaration): Use
complain_at_indent to output with increased indentation level.
* tests/input:at: Apply this change.

Signed-off-by: Akim Demaille <[email protected]>
2012-09-28 14:00:09 +02:00
Theophile RanquetandAkim Demaille bd52638008 warnings: introduce -Wdeprecated in the usage info
The deprecated warning, introduced some time ago, was not displayed in
the usage message. This patch addresses the issue.

* src/getargs.c (usage): Insert here.

Signed-off-by: Akim Demaille <[email protected]>
2012-09-26 12:28:10 +02:00
Theophile RanquetandAkim Demaille b8e7ad5887 errors: prefix the output with "error: "
This improves readability. This is also what gcc does.

* NEWS: Document this change.
* src/complain.c (complain_at): Prefix all errors with "error: ".
(complain_at_indent, warn_at_indent): Do not prefix the context
information of errors, which are basically just indented errors.
* tests/conflicts.at, tests/glr-regression.at, tests/input.at,
tests/named-refs.at, tests/output.at, tests/push.at,
tests/regression.at, tests/skeletons.at: Apply this change.

Signed-off-by: Akim Demaille <[email protected]>
2012-09-26 12:11:51 +02:00
Theophile RanquetandAkim Demaille a974c1ec26 errors: indent "invalid value for %define" context
This is the continuation of the work on the readability of errors
    context.

For example, what used to be:
  input.y:1.9-29: invalid value for %define variable 'foo' : 'bar'
  input.y:1.9-29: accepted value: 'most'

is now:
  input.y:1.9-29: invalid value for %define variable 'foo' : 'bar'
  input.y:1.9-29:     accepted value: 'most'

* src/muscle-tab.c (muscle_percent_define_check_values): Use
complain_at_indent to output with increased indentation level.
* tests/input:at: Apply this change.

Signed-off-by: Akim Demaille <[email protected]>
2012-09-26 12:08:55 +02:00
Theophile RanquetandAkim Demaille 6b1e1872d4 errors: indent "%define var" redefinition context
This is the continuation of the work on the readability of errors
context.

For example, what used to be:
  input.y:2.9-11: %define variable 'var' redefined
  input.y:1.9-11: previous definition

is now:
  input.y:2.9-11: %define variable 'var' redefined
  input.y:1.9-11:     previous definition

* src/muscle-tab.c (muscle_percent_define_insert): Use
complain_at_indent to output with increased indentation level.
* tests/input.at: Apply this change.

Signed-off-by: Akim Demaille <[email protected]>
2012-09-26 12:06:03 +02:00
Theophile RanquetandAkim Demaille cbaea0106d errors: indent "symbol redeclaration" context
This is the continuation of the work on the readability of errors
context.

For example, what used to be:
  input.y:5.10-24: %printer redeclaration for <field2>
  input.y:3.11-25: previous declaration

is now:
  input.y:5.10-24: %printer redeclaration for <field2>
  input.y:3.11-25:     previous declaration

* NEWS: Document this change.
* src/symtab.c (symbol_redeclaration, semantic_type_redeclaration,
user_token_number_redeclaration, default_tagged_destructor_set,
default_tagless_destructor_set, default_tagged_printer_set,
default_tagless_printer_set): Use complain_at_indent to
output with increased indentation level.
* tests/input.at: Apply this change.

Signed-off-by: Akim Demaille <[email protected]>
2012-09-26 12:03:57 +02:00
Theophile RanquetandAkim Demaille 24d96dd3eb errors: indent "result type clash" error context
This used to be the format of the error report:

  input.y:6.5-10: result type clash on merge function 'merge': [...]
  input.y:2.4-9: previous declaration

In order to distinguish the actual error from the context provided, we
rather this new output:

  input.y:6.5-10: result type clash on merge function 'merge': [...]
  input.y:2.4-9:     previous declaration

Another patch will introduce an "error: " prefix to all non-indented
lines, giving yet better readability to the reports.

* src/complain.h (SUB_INDENT): Move to here.
* src/reader.c (record_merge_function_type): Use complain_at_indent to
output with increased indentation level.
* src/scan-code.l (SUB_INDENT): Remove from here.
* tests/glr-regression.at: Apply this change.

Signed-off-by: Akim Demaille <[email protected]>
2012-09-26 12:00:29 +02:00
Akim Demaille 63fec1eeba regen 2012-09-25 10:29:02 +02:00
Akim Demaille 6b4cb804b5 yacc: fix handling of CPP guards when no header is generated
When no header was to be generated, Bison would issue:

  /* In a future release of Bison, this section will be replaced
     by #include "".  */
  #ifndef YY_
  # define YY_

It now properly generates nothing.

* data/c.m4 (b4_cpp_guard_open, b4_cpp_guard_close): Issue nothing when
the file name is empty.
* data/yacc.c: Do not generate the above comment when there is no header
to generate.
* NEWS: Update.
2012-09-25 10:24:37 +02:00
Akim Demaille 53425dbfaa gnulib: update 2012-09-25 10:24:36 +02:00
Akim Demaille 403ddfb7e0 maint: remove useless file
* externals/bootstrap.cfg: Remove.
This file was used by a specific build system.
It was added to the master repository by accident.
2012-09-04 11:00:11 +02:00
Akim Demaille 76e5017732 update files to ignore
* doc/.gitignore: Don't ignore split info files as we don't split our
info file.
See <http://lists.gnu.org/archive/html/bug-bison/2012-08/msg00006.html>.
2012-09-04 10:50:30 +02:00
Akim Demaille 592bdad15e remove useless include
* src/system.h: Don't include sys/types.h.
Reported by Eric Blake,
<http://lists.gnu.org/archive/html/bug-bison/2012-09/msg00002.html>.
(FUNCTION_PRINT): Remove, unused.
2012-09-04 09:51:12 +02:00
Jim Meyering 457bf91968 use locale-indep. c_is* functions for parsing, not isspace, isprint etc
* src/parse-gram.y: Include "c-ctype.h".
(add_param): Parse with c_isspace, not isspace.
* src/parse-gram.c: Likewise.
* src/scan-gram.l: Include c-ctype.h, not ctype.h.
(SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER): Use c_isspace and c_isprint,
not ctype.h's locale-dependent functions.
2012-09-03 19:45:03 +02:00
Akim Demaille 2e350a617f gnulib: update 2012-09-03 16:40:03 +02:00
Akim Demaille d740d2b541 --help: include a place to report translation issues
http://lists.gnu.org/archive/html/bug-bison/2012-08/msg00007.html
shows that it is useful to help users report translation issues.
While at it, include other informative bits that the coreutils shows.

* src/getargs.c (usage): Report more URLs where the user can
refer to.
Mostly copied/pasted from coreutils' emit_ancillary_info function.
2012-09-03 16:40:03 +02:00
Akim Demaille e411069eee tests: style changes
* tests/torture.at (AT_DATA_STACK_TORTURE): M4 style changes to
improve readability.
Fix an assertion which, because of a <= instead of ==, did not check
new_status as visibly meant.
(get_args): New.
2012-08-31 17:50:43 +02:00
Akim Demaille ae62d0fc4f tests: fix push-pull test
* tests/torture.at: %push-pull-parser is no longer supported.
2012-08-31 17:50:43 +02:00
Akim Demaille e3f8c4ef69 yacc.c: style changes
* data/yacc.c: (yytoken): Define with initial value.
2012-08-31 17:50:31 +02:00
Akim Demaille 933ec5449f maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-08-03 09:52:05 +02:00
Akim Demaille e1eeecd384 version 2.6.2
* NEWS: Record release date.
2012-08-03 09:43:02 +02:00
Akim Demaille 43ca804096 NEWS: update.
* NEWS: Catch up with the other changes from 2.6.1.
2012-08-02 13:51:52 +02:00
Akim Demaille dcd5344dcd yacc: remove trailing end of line at end of file
There are still spurious spaces at the end of some lines.  But this is
addressed in the master branch, and I am reluctant to try to backport
this.

* data/yacc.c, data/glr.c, data/lalr1.cc, data/glr.cc: here.
* tests/calc.at (AT_CHECK_SPACES): New.
Use it.
Be sure not to introduce trailing empty lines in the *.y files.
* NEWS: Doc it.
* cfg.mk (syntax-check): Remove the exception.
2012-08-02 13:51:52 +02:00
Akim Demaille 62a58c14bd thanks: fix a contributor name
* THANKS: On his request.
2012-08-02 08:29:18 +02:00
Akim Demaille e39eff37e2 gnulib: update 2012-08-01 15:02:25 +02:00
Akim Demaille 06f2ac78d7 tests: synch line -> syncline, for consistency
* tests/synclines.at: Do it, as "syncline" is used consistently
everywhere else in Bison.
2012-08-01 15:02:25 +02:00
Akim Demaille 1914a78115 tests: synclines: style changes
* tests/synclines.at (AT_TEST_SYNCLINE): Rename as...
(AT_TEST): this.
Use pushdef/popdef.
Formatting changes.
Use '+' instead of '*' where appropriate.
2012-08-01 15:02:25 +02:00
Akim Demaille d6e2a57964 tests: synclines: fix perl invocation
Reported by Summum Bonum.

* tests/synclines.at: Fix Perl invocation: its -f is not like sed's.
2012-08-01 15:02:21 +02:00
Akim Demaille a0c45dd5d2 regen 2012-08-01 09:16:56 +02:00
Akim Demaille c9d546b2a8 c++: trailing end-of-lines in %parse-param
* src/parse-gram.y (add_param): No only skip ' ' and '\t', skip all
leading and trailing spaces.
* tests/regression.at (Lex and parse params): Check it.
* NEWS: Document it.
2012-08-01 09:16:55 +02:00
Akim Demaille d61e59ea0e tests: simplify
* tests/regression.at: Remove useless compilations: AT_FULL_COMPILE
includes the compilation by bison.
2012-08-01 09:16:55 +02:00
Akim Demaille aaf63e45b6 use obstack_printf
This is not just nicer, it is also much safer, since we were
using sprintf...

* bootstrap.conf: Require it.
* src/system.h (obstack_fgrow1, obstack_fgrow2, obstack_fgrow3)
(obstack_fgrow4): Remove.
Adjust dependencies.
2012-07-31 10:50:06 +02:00
Akim Demaille dbfcf7a89f scanner: restore a missing start condition
$ flex src/scan-skel.l
src/scan-skel.l:145: multiple <<EOF>> rules for start condition SC_AT_DIRECTIVE_ARGS
src/scan-skel.l:145: multiple <<EOF>> rules for start condition SC_AT_DIRECTIVE_SKIP_WS
This is warning, and it seems there are no means to make it an error.

* src/scan-skel.l: Restore the start-condition INITIAL for an <<EOF>>
clause.
2012-07-30 14:54:27 +02:00
Akim Demaille 8c707b10e7 gnulib: update 2012-07-30 14:53:58 +02:00
Akim Demaille 9c26b8fc03 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-07-30 11:47:29 +02:00
Akim Demaille 77b214ef48 version 2.6.1
* NEWS: Record release date.
2012-07-30 11:18:23 +02:00
Akim Demaille d35d6dd2cd gnulib: update 2012-07-30 11:17:44 +02:00
Akim Demaille 466a2de317 maint: fix some syntax-check issues
* cfg.mk: Nuke the following warnings which are confused by our
text reports (that state that the error token is number 256).
  prohibit_magic_number_exit
  ../../doc/bison.texi:8170:error (256)
  ../../tests/conflicts.at:570:error (256)
  ../../tests/conflicts.at:673:error (256)
  ../../tests/conflicts.at:811:error (256)
  ../../tests/conflicts.at:1154:error (256)
  ../../tests/regression.at:281:error (256)
  ../../tests/regression.at:582:error (256)
  maint.mk: use EXIT_* values rather than magic number
2012-07-27 17:00:28 +02:00
Akim Demaille 4acc22e5cf tests: do not depend on __cplusplus to decide for C++ or C output
Since we do support compiling C code with a C++ compiler.

* tests/actions.at (Qualified $$ in actions): Use AT_SKEL_CC_IF.
2012-07-27 16:36:07 +02:00
Akim Demaille 7b18c11231 regen 2012-07-27 14:52:55 +02:00
Akim Demaille e6cab382c5 synclines: remove spurious empty line
* data/bison.m4 (b4_syncline): Do not start with an empty line.
2012-07-27 14:52:23 +02:00
Akim Demaille cd735a8c6c also support $<foo>$ in the %initial-action
scan-code.l is already passing argument to b4_dollar_dollar for the
initial acton, but its definition (of b4_dollar_dollar) does not use
this argument.

Generalize this definition, and use it for the %initial-action too.

* data/c.m4 (b4_dollar_dollar_, b4_dollar_pushdef, b4_dollar_popdef):
Instead of expecting a pointer, require a value, and use ".".
Since they are now generic enough, move to...
* data/c-like.m4: this new file.
* data/c.m4, data/java.m4: Load it.
* data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Use
b4_dollar_pushdef for the %initial-action.
* tests/actions.at: Check that.
* data/Makefile.am: Adjust.
* NEWS, doc/bison.texi: Document.
2012-07-27 14:47:20 +02:00
Akim Demaille d6a44ffd00 skeletons: b4_dollar_pushdef and popdef to simpify complex definitions
M4 is really making it uselessly hard to define macros that define
macros.
* data/c.m4 (b4_dollar_pushdef, b4_dollar_popdef): New.
Use it.
2012-07-27 13:47:24 +02:00
Akim Demaille 93e3dbab95 regen 2012-07-27 12:54:31 +02:00
Akim Demaille 1c292035e1 printer/destructor: translate only once
Currently "%printer {...} a b c d e f" translates the {...} six times.
Not only is this bad for time and space, it also issues six times the
same warnings.

* src/symlist.h, src/symlist.c (symbol_list_destructor_set)
(symbol_list_printer_set): Take the action as code_props instead of
const char *.
* src/parse-gram.y: Translate these actions here.
* src/scan-code.h: Comment change.
* tests/input.at: Check that warnings are issued only once.
2012-07-27 12:54:31 +02:00
Akim Demaille 263137264f factor the handling of m4 escaping
The conversion from @ to @@ and so forth is coded is too many
different places.  Factor, a bit.

* src/scan-code.l: Instead of duplicating the logic of obstack_escape,
use it.
It sure is less efficient, but the cost is negligible.
This allows to factor rules that are alike.
And to factor some start-condition clauses.
* tests/input.at (Stray $ or @): New.
* NEWS: Document it.
2012-07-27 12:54:31 +02:00
Akim Demaille e20e6a50d5 news: schedule the removal of the ";" hack
scan-code.l is significantly more complex because of this.

* NEWS: Doc it.
2012-07-27 12:54:31 +02:00
Akim Demaille 4d24ffb75e style changes in the scanners
* src/scan-code.l, src/scan-skel.l: Use a more traditional indentation
style for start-conditions.
Prefer "continue" to a comment, for empty actions.
Strip useless {}.
Remove useless start-condition clauses.
2012-07-27 12:13:40 +02:00
Akim Demaille a74a3158d4 regen 2012-07-26 18:30:43 +02:00
Akim Demaille 4982f078bf support $<tag>$ in printers and destructors
* src/scan-code.l (SC_SYMBOL_ACTION): Accept $<tag>$, not just $$.
* data/c.m4 (b4_dollar_dollar_): New.
(b4_symbol_actions): Let b4_dollar_dollar use b4_dollar_dollar_.
* NEWS, doc/bison.texi: Document it.
* tests/actions.at: Check this for C and C++.
2012-07-26 18:30:43 +02:00
Akim Demaille 65a99eca25 scan-code: factor the handling of the type in $<TYPE>$
* src/scan-code.l (fetch_type_name): New.
(handle_action_dollar): Use it.
(gt_ptr): Remove, useless.
2012-07-26 17:03:54 +02:00
Akim Demaille 9a86ee6058 muscles: fix another occurrence of unescaped type name
* src/output.c (quoted_output): Split into...
(quoted_output, string_output): these.
Use the former when outputting a type_name.
* tests/input.at: Check this case.
* src/symtab.h: Comment changes.
2012-07-26 17:03:54 +02:00
Akim Demaille 0e164d43d1 glr.cc: fix the handling of yydebug
* data/glr.cc (yydebug_): Remove, unused.
(set_debug_level, debug_level): Work on yydebug instead.
* doc/bison.texi, NEWS: Document this.
2012-07-26 17:03:52 +02:00
Akim Demaille d511fbd576 gnulib: update 2012-07-26 16:51:26 +02:00
Akim Demaille 9c46ba16e3 formatting changes
* src/symtab.h: here.
2012-07-26 16:51:26 +02:00
Akim Demaille 55e075f229 tests: fix an assertion
* tests/local.at (AT_YYLEX_DEFINE): Be sure to check the array
against its length, not its size in bytes.
2012-07-26 16:51:26 +02:00
Akim Demaille 0bb672d87c tests: adjust to GCC 4.8, which displays caret errors
With GCC 4.8, the tests on synclines are skipped.  Transform

  input.y:1:2: error: #error "1"
   #error "1"
    ^

into

  input.y:1: #error "1"

* tests/synclines.at (AT_SYNCLINES_COMPILE): Do it, using Perl instead of
sed.
2012-07-26 16:51:26 +02:00
Akim Demaille 8617d87e24 be sure to properly escape type names
* src/scan-code.l: Use obstack_quote when passing type_name to m4.
* tests/input.at (Code injection): New.
* NEWS: Document it.
Thanks to Paul Eggert for the wording.
2012-07-26 14:20:47 +02:00
Akim Demaille 0601c3bf0f obstack_quote: escape and quote for M4
* src/system.h (obstack_quote): New.
* src/muscle-tab.c: Use it instead of obstack_escape where applicable.
* src/scan-code.l: Since obstack_quote supports NULL, leave type_name
as NULL instead of defaulting to "".
2012-07-26 14:20:18 +02:00
Akim Demaille eea7239a23 muscles: shuffle responsabilities
* src/muscle-tab.c (muscle_boundary_grow): Be in charge of quotation,
instead of leaving this to the caller.
2012-07-26 12:30:03 +02:00
Akim Demaille e58782294d muscles: make private functions static
* src/muscle-tab.h, src/muscle-tab.c (muscle_boundary_grow)
(muscle_location_grow): Now static.
2012-07-26 12:30:03 +02:00
Akim Demaille c1cc91bdcd muscles: rename private functions/macros
* src/muscle-tab.c (MUSCLE_COMMON_DECODE, muscle_string_decode)
(muscle_location_decode): Not related to muscles, rename as...
(COMMON_DECODE, string_decode, location_decode): these.
2012-07-26 12:30:03 +02:00
Akim Demaille 13b712d7d4 obstack_escape: escape M4 characters
* src/muscle-tab.h (MUSCLE_OBSTACK_SGROW): This is not related to
muscles, so move to, and rename as...
* src/system.h (obstack_escape): this.
Adjust dependencies.
2012-07-26 12:30:02 +02:00
Akim Demaille dba9149595 remove dead macro
* src/system.h (DEFAULT_TMPDIR): Remove, unused.
2012-07-26 12:28:40 +02:00
Akim Demaille 9b8585410a maint: style changes
* src/scan-code.l: Remove useless braces.
Formatting changes.
Prefer NULL to 0.
* src/muscle-tab.c, src/system.h: Formatting changes.
2012-07-26 12:28:17 +02:00
Akim Demaille f9b8635172 doc: avoid problems with case insensitive file systems
makeinfo --html generates index.html, and the node "Index" will result
in Index.html.  On case insensitive file systems, such as on Mac OS X
by default, this results in a single, invalid, file (Texinfo 4.13).
See http://lists.gnu.org/archive/html/bug-texinfo/2012-07/msg00032.html

* doc/bison.texi (Index): Rename as...
(Index of Terms): this.
2012-07-24 13:30:49 +02:00
Stefano LattariniandAkim Demaille 733d4546ce configure: fix botched quoting
* configure.ac: In the AC_SUBST call on 'VALGRIND_PREBISON'.  Without
this change, when running ./configure, I see:

    ...
    checking for valgrind... valgrind
    ./configure: line 35221: -q: command not found
    checking for Java compiler... gcj -C -fsource=1.3 -ftarget=1.4
    ...

Copyright-paperwork-exempt: yes
Signed-off-by: Stefano Lattarini <[email protected]>
2012-07-24 12:22:17 +02:00
Akim Demaille aaf6103699 news: fix typo.
* NEWS: here.
Reported by Ben Pfaff.
2012-07-20 10:01:48 +02:00
98 changed files with 5591 additions and 2310 deletions
+1 -1
View File
@@ -11,6 +11,7 @@
/INSTALL
/Makefile
/Makefile.in
/README-release
/_*
/a.exe
/a.out
@@ -31,4 +32,3 @@
/patches
/releases
/stamp-h*
/README-release
+1 -1
View File
@@ -1 +1 @@
2.6
2.6.5
+225 -3
View File
@@ -1,7 +1,228 @@
GNU Bison NEWS
* Noteworthy changes in release ?.? (????-??-??) [?]
* Noteworthy changes in release 2.6.90 (2012-12-07) [beta]
** Bug fixes
Warnings about uninitialized yylloc in yyparse have been fixed.
** %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.
** New format for error reports: carets
Caret errors have been added to Bison, for example (taken from the
documentation):
input.y:3.20-23: error: ambiguous reference: '$exp'
exp: exp '+' exp { $exp = $1 + $3; };
^^^^
input.y:3.1-3: refers to: $exp at $$
exp: exp '+' exp { $exp = $1 + $3; };
^^^
input.y:3.6-8: refers to: $exp at $1
exp: exp '+' exp { $exp = $1 + $3; };
^^^
input.y:3.14-16: refers to: $exp at $3
exp: exp '+' exp { $exp = $1 + $3; };
^^^
The default behaviour for now is still not to display these unless explictly
asked with -fall of -fcaret. However, in a later release, it will be made the
default behavior (but may still be deactivated with -fno-caret).
** New value for %define variable: api.pure full
The %define variable api.pure requests a pure (reentrant) parser. However,
for historical reasons, using it in a location-tracking Yacc parser resulted
in a yyerror function that did not take a location as a parameter. With this
new value, the user may request a better pure parser, where yyerror does take
a location as a parameter (in location-tracking parsers).
The use of "%define api.pure true" is deprecated in favor of this new
"%define api.pure full".
** Changes in the format of error messages
This used to be the format of many error reports:
foo.y:5.10-24: result type clash on merge function 'merge': <t3> != <t2>
foo.y:4.13-27: previous declaration
It is now:
foo.y:5.10-25: result type clash on merge function 'merge': <t3> != <t2>
foo.y:4.13-27: previous declaration
** Exception safety (lalr1.cc)
The parse function now catches exceptions, uses the %destructors to
release memory (the lookahead symbol and the symbols pushed on the stack)
before re-throwing the exception.
This feature is somewhat experimental. User feedback would be
appreciated.
** New %define variable: api.location.type (glr.cc, lalr1.cc, lalr1.java)
The %define variable api.location.type defines the name of the type to use
for locations. When defined, Bison no longer generates the position.hh
and location.hh files, nor does the parser will include them: the user is
then responsible to define her type.
This can be used in programs with several parsers to factor their location
and position files: let one of them generate them, and the others just use
them.
This feature was actually introduced, but not documented, in Bison 2.5,
under the name "location_type" (which is maintained for backward
compatibility).
For consistency, lalr1.java's %define variables location_type and
position_type are deprecated in favor of api.location.type and
api.position.type.
** Graph improvements in DOT and XSLT
The graphical presentation of the states is more readable: their shape is
now rectangular, the state number is clearly displayed, and the items are
numbered and left-justified.
The reductions are now explicitly represented as transitions to other
diamond shaped nodes.
These changes are present in both --graph output and xml2dot.xsl XSLT
processing, with minor (documented) differences.
Two nodes were added to the documentation: Xml and Graphviz.
** Documentation
The sections about shift/reduce and reduce/reduce conflicts resolution
have been fixed and extended.
* Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
We consider compiler warnings about Bison generated parsers to be bugs.
Rather than working around them in your own project, please consider
reporting them to us.
** Bug fixes
Warnings about uninitialized yylval and/or yylloc for push parsers with a
pure interface have been fixed for GCC 4.0 up to 4.8, and Clang 2.9 to
3.2.
Other issues in the test suite have been addressed.
Nul characters are correctly displayed in error messages.
When possible, yylloc is correctly initialized before calling yylex. It
is no longer necessary to initialize it in the %initial-action.
* Noteworthy changes in release 2.6.4 (2012-10-23) [stable]
Bison 2.6.3's --version was incorrect. This release fixes this issue.
* Noteworthy changes in release 2.6.3 (2012-10-22) [stable]
** Bug fixes
Bugs and portability issues in the test suite have been fixed.
Some errors in translations have been addressed, and --help now directs
users to the appropriate place to report them.
Stray Info files shipped by accident are removed.
Incorrect definitions of YY_, issued by yacc.c when no parser header is
generated, are removed.
All the generated headers are self-contained.
** Header guards (yacc.c, glr.c, glr.cc)
In order to avoid collisions, the header guards are now
YY_<PREFIX>_<FILE>_INCLUDED, instead of merely <PREFIX>_<FILE>.
For instance the header generated from
%define api.prefix "calc"
%defines "lib/parse.h"
will use YY_CALC_LIB_PARSE_H_INCLUDED as guard.
** Fix compiler warnings in the generated parser (yacc.c, glr.c)
The compilation of pure parsers (%define api.pure) can trigger GCC
warnings such as:
input.c: In function 'yyparse':
input.c:1503:12: warning: 'yylval' may be used uninitialized in this
function [-Wmaybe-uninitialized]
*++yyvsp = yylval;
^
This is now fixed; pragmas to avoid these warnings are no longer needed.
Warnings from clang ("equality comparison with extraneous parentheses" and
"function declared 'noreturn' should not return") have also been
addressed.
* Noteworthy changes in release 2.6.2 (2012-08-03) [stable]
** Bug fixes
Buffer overruns, complaints from Flex, and portability issues in the test
suite have been fixed.
** Spaces in %lex- and %parse-param (lalr1.cc, glr.cc)
Trailing end-of-lines in %parse-param or %lex-param would result in
invalid C++. This is fixed.
** Spurious spaces and end-of-lines
The generated files no longer end (nor start) with empty lines.
* Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
Bison no longer executes user-specified M4 code when processing a grammar.
** Future Changes
In addition to the removal of the features announced in Bison 2.6, the
next major release will remove the "Temporary hack for adding a semicolon
to the user action", as announced in the release 2.5. Instead of:
exp: exp "+" exp { $$ = $1 + $3 };
write:
exp: exp "+" exp { $$ = $1 + $3; };
** Bug fixes
*** Type names are now properly escaped.
*** glr.cc: set_debug_level and debug_level work as expected.
*** Stray @ or $ in actions
While Bison used to warn about stray $ or @ in action rules, it did not
for other actions such as printers, destructors, or initial actions. It
now does.
** Type names in actions
For consistency with rule actions, it is now possible to qualify $$ by a
type-name in destructors, printers, and initial actions. For instance:
%printer { fprintf (yyo, "(%d, %f)", $<ival>$, $<fval>$); } <*> <>;
will display two values for each typed and untyped symbol (provided
that YYSTYPE has both "ival" and "fval" fields).
* Noteworthy changes in release 2.6 (2012-07-19) [stable]
@@ -10,7 +231,7 @@ GNU Bison NEWS
The next major release of Bison will drop support for the following
deprecated features. Please report disagreements to [email protected].
*** K&C parsers
*** K&R C parsers
Support for generating parsers in K&R C will be removed. Parsers
generated for C support ISO C90, and are tested with ISO C99 and ISO C11
@@ -1806,7 +2027,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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
LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp calc yyo fval Wmaybe
LocalWords: yyvsp pragmas noreturn java's
Local Variables:
mode: outline
+26 -12
View File
@@ -43,16 +43,17 @@ These requirements do not apply when building from a distribution tarball.
** Requirements
We've opted to keep only the highest-level sources in the repository.
This eases our maintenance burden, (fewer merges etc.), but imposes more
We've opted to keep only the highest-level sources in the repository. This
eases our maintenance burden, (fewer merges etc.), but imposes more
requirements on anyone wishing to build from the just-checked-out sources.
For example, you have to use the latest stable versions of the maintainer
tools we depend upon, including:
- Automake <http://www.gnu.org/software/automake/>
- Autoconf <http://www.gnu.org/software/autoconf/>
- Automake <http://www.gnu.org/software/automake/>
- Flex <http://www.gnu.org/software/flex/>
- Gettext <http://www.gnu.org/software/gettext/>
- Graphviz <http://www.graphviz.org>
- Gzip <http://www.gnu.org/software/gzip/>
- Perl <http://www.cpan.org/>
- Rsync <http://samba.anu.edu.au/rsync/>
@@ -61,16 +62,16 @@ tools we depend upon, including:
Valgrind <http://valgrind.org/> is also highly recommended, if it supports
your architecture.
Bison is written using Bison grammars, so there are bootstrapping
issues. The bootstrap script attempts to discover when the C code
generated from the grammars is out of date, and to bootstrap with an
out-of-date version of the C code, but the process is not foolproof.
Also, you may run into similar problems yourself if you modify Bison.
Bison is written using Bison grammars, so there are bootstrapping issues.
The bootstrap script attempts to discover when the C code generated from the
grammars is out of date, and to bootstrap with an out-of-date version of the
C code, but the process is not foolproof. Also, you may run into similar
problems yourself if you modify Bison.
Only building the initial full source tree will be a bit painful.
Later, after synchronizing from the repository a plain 'make' should
be sufficient. Note, however, that when gnulib is updated, running
'./bootstrap' again might be needed.
Only building the initial full source tree will be a bit painful. Later,
after synchronizing from the repository a plain 'make' should be sufficient.
Note, however, that when gnulib is updated, running './bootstrap' again
might be needed.
** First checkout
@@ -168,6 +169,19 @@ decide whether to update.
** make check
Use liberally.
** Typical errors
If the test suite shows failures such as the following one
.../bison/lib/getopt.h:196:8: error: redefinition of 'struct option'
/usr/include/getopt.h:54:8: error: previous definition of 'struct option'
it probably means that some file was compiled without
AT_DATA_SOURCE_PROLOGUE. This error is due to the fact that our -I options
pick up gnulib's replacement headers, such as getopt.h, and this will go
wrong if config.h was not included first.
See tests/local.at for details.
** make maintainer-check-valgrind
This target uses valgrind both to check bison, and the generated parsers.
+15 -3
View File
@@ -1,11 +1,12 @@
Bison was originally written by Robert Corbett. It would not be what
it is today without the invaluable help of these people:
Аскар Сафин [email protected]
Airy Andre [email protected]
Akim Demaille akim@freefriends.org
Akim Demaille akim@lrde.epita.fr
Albert Chin-A-Young [email protected]
Alexander Belopolsky [email protected]
Alexandre Duret-Lutz adl@src.lip6.fr
Alexandre Duret-Lutz adl@lrde.epita.fr
Andreas Schwab [email protected]
Andrew Suffield [email protected]
Angelo Borsotti [email protected]
@@ -13,6 +14,7 @@ Anthony Heading [email protected]
Arnold Robbins [email protected]
Art Haas [email protected]
Baron Schwartz [email protected]
Ben Pfaff [email protected]
Benoit Perrot [email protected]
Bernd Kiefer [email protected]
Bert Deknuydt [email protected]
@@ -30,6 +32,7 @@ Dagobert Michelsen [email protected]
Daniel Hagerty [email protected]
David J. MacKenzie [email protected]
David Kastrup [email protected]
Dennis Clarke [email protected]
Derek M. Jones [email protected]
Di-an Jan [email protected]
Dick Streefland [email protected]
@@ -55,6 +58,7 @@ Jim Kent [email protected]
Jim Meyering [email protected]
Joel E. Denny [email protected]
Johan van Selst [email protected]
Jonathan Fabrizio [email protected]
Jonathan Nieder [email protected]
Juan Manuel Guerrero [email protected]
Kees Zeelenberg [email protected]
@@ -63,6 +67,8 @@ Laurent Mascherpa [email protected]
Lie Yan [email protected]
Magnus Fromreide [email protected]
Marc Autret [email protected]
Marc Mendiola [email protected]
Mark Boyall [email protected]
Martin Jacobs [email protected]
Martin Mokrejs [email protected]
Martin Nylin [email protected]
@@ -79,19 +85,23 @@ Nicolas Tisserand [email protected]
Noah Friedman [email protected]
Odd Arild Olsen [email protected]
Oleg Smolsky [email protected]
Oleksii Taran [email protected]
Paolo Bonzini [email protected]
Pascal Bart [email protected]
Paul Eggert [email protected]
Paul Hilfinger [email protected]
Per Allansson [email protected]
Peter Eisentraut [email protected]
Peter Fales [email protected]
Peter Hamorsky [email protected]
Peter Simons [email protected]
Piotr Gackiewicz [email protected]
Quoc Peyrot [email protected]
R Blake [email protected]
Raja R Harinath [email protected]
Ralf Wildenhues [email protected]
Richard Stallman [email protected]
Rob Vermaas [email protected]
Robert Anisko [email protected]
Satya Kiran Popuri [email protected]
Sebastian Setzer [email protected]
@@ -100,7 +110,8 @@ Sergei Steshenko [email protected]
Shura [email protected]
Stefano Lattarini [email protected]
Steve Murphy [email protected]
Summum Bonum [email protected]
Sum Wu [email protected]
Théophile Ranquet [email protected]
Thiru Ramakrishnan [email protected]
Tim Josling [email protected]
Tim Landscheidt [email protected]
@@ -124,6 +135,7 @@ thank them! Please, help us keeping this list up to date.
Local Variables:
mode: text
coding: utf-8
End:
-----
+13
View File
@@ -1,4 +1,17 @@
* Short term
** Graphviz display code thoughts
The code for the --graph option is over two files: print_graph, and
graphviz. I believe this is because Bison used to also produce VCG graphs,
but since this is no longer true, maybe we could consider these files for
fusion.
Little effort factoring seems to have been given to factoring in these files,
and their print-xml and print counterpart. We would very much like to re-use
the pretty format of states from .output in the .dot
Also, the underscore in print_graph.[ch] isn't very fitting considering
the dashes in the other filenames.
** Variable names.
What should we name `variant' and `lex_symbol'?
+3 -1
View File
@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
scriptversion=2012-07-10.09; # UTC
scriptversion=2012-07-19.14; # UTC
# Bootstrap this package from checked-out sources.
@@ -214,6 +214,8 @@ use_git=true
# otherwise find the first of the NAMES that can be run (i.e.,
# supports --version). If found, set ENVVAR to the program name,
# die otherwise.
#
# FIXME: code duplication, see also gnu-web-doc-update.
find_tool ()
{
find_tool_envvar=$1
+7 -2
View File
@@ -20,11 +20,16 @@ gnulib_modules='
argmatch assert calloc-posix close closeout config-h c-strcase
configmake
dirname
error extensions fdl fopen-safer getopt-gnu
error extensions fdl fopen-safer
getline
getopt-gnu
gettext git-version-gen gitlog-to-changelog
gpl-3.0 hash inttypes isnan javacomp-script
javaexec-script ldexpl malloc-gnu mbschr mbsrchr
mbswidth obstack perror progname
mbswidth
obstack
obstack-printf
perror progname
quote quotearg
readme-release
realloc-posix
+5
View File
@@ -1,3 +1,8 @@
# This file is expected to be used via gitlog-to-changelog's --amend=FILE
# option. It specifies what changes to make to each given SHA1's commit
# log and metadata, using Perl-eval'able expressions.
0db2648930e3b6c376a539aabe368aade83ee29a
s/--flags/--feature/;
s/flag_flag/feature_flag/;
s/\bflag\b/feature/;
+18 -3
View File
@@ -24,6 +24,7 @@ regen: _version
# Used in maint.mk's web-manual rule
manual_title = The Yacc-compatible Parser Generator
gendocs_options_ = -I $(abs_top_srcdir)/doc -I $(abs_top_builddir)/doc
# It's useful to run maintainer-*check* targets during development, but we
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
@@ -60,19 +61,33 @@ update-copyright: update-b4-copyright update-package-copyright-year
update-copyright-env = \
UPDATE_COPYRIGHT_FORCE=1 UPDATE_COPYRIGHT_USE_INTERVALS=1
# At least for Mac OS X's grep, the order between . and [ in "[^.[]"
# matters:
# $ LC_ALL=fr_FR grep -nE '[^[.]' /dev/null
# $ LC_ALL=C grep -nE '[^[.]' /dev/null
# grep: invalid collating element or class
# $ LC_ALL=fr_FR grep -nE '[^.[]' /dev/null
# $ LC_ALL=C grep -nE '[^.[]' /dev/null
sc_at_parser_check:
@prohibit='AT_PARSER_CHECK\(\[+[^.[]|AT_CHECK\(\[+\./' \
halt='use AT_PARSER_CHECK for and only for generated parsers' \
$(_sc_search_regexp)
exclude = \
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
$(call exclude, \
bindtextdomain=^lib/main.c$$ \
program_name=^lib/main.c$$ \
prohibit_always-defined_macros=^data/yacc.c|^djgpp/ \
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
prohibit_empty_lines_at_EOF=^src/parse-gram.[ch]$$ \
prohibit_doubled_word=^tests/named-refs.at$$ \
prohibit_magic_number_exit=^doc/bison.texi$$ \
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
space_tab=^tests/(input|c\+\+)\.at$$ \
trailing_blank=^src/parse-gram.[ch]$$ \
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$) \
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \
)
+49 -5
View File
@@ -58,6 +58,20 @@ AC_PROG_CXX
# Gnulib (early checks).
gl_EARLY
# Gnulib uses '#pragma GCC diagnostic push' to silence some
# warnings, but older gcc doesn't support this.
AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
[lv_cv_gcc_pragma_push_works], [
save_CFLAGS=$CFLAGS
CFLAGS='-Wunknown-pragmas -Werror'
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#pragma GCC diagnostic push
#pragma GCC diagnostic pop
]])],
[lv_cv_gcc_pragma_push_works=yes],
[lv_cv_gcc_pragma_push_works=no])
CFLAGS=$save_CFLAGS])
AC_ARG_ENABLE([gcc-warnings],
[ --enable-gcc-warnings turn on lots of GCC warnings (not recommended)],
[case $enable_gcc_warnings in
@@ -67,37 +81,62 @@ AC_ARG_ENABLE([gcc-warnings],
[enable_gcc_warnings=no])
if test "$enable_gcc_warnings" = yes; then
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
-Wcast-qual -Wformat -Wpointer-arith -Wwrite-strings'
warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes
-Wshadow -Wstrict-prototypes'
-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
# thinks the option is supported, and unknown options are then added
# to CFLAGS. But then, when -Werror is added in the test suite for
# instance, the warning about the unknown option turns into an
# error.
#
# This should be addressed by gnulib's gl_WARN_ADD, but in the
# meanwhile, turn warnings about unknown options into errors in
# CFLAGS, and restore CFLAGS after the tests.
save_CFLAGS=$CFLAGS
gl_WARN_ADD([-Werror=unknown-warning-option], [CFLAGS])
for i in $warn_common $warn_c;
do
gl_WARN_ADD([$i], [WARN_CFLAGS])
done
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
# Warnings for the test suite, and maybe for bison if GCC is modern
# enough.
gl_WARN_ADD([-Wmissing-declarations], [WARN_CFLAGS_TEST])
gl_WARN_ADD([-Wmissing-prototypes], [WARN_CFLAGS_TEST])
test $lv_cv_gcc_pragma_push_works = yes &&
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
# Warnings for the test suite only.
gl_WARN_ADD([-Wundef], [WARN_CFLAGS_TEST])
gl_WARN_ADD([-pedantic], [WARN_CFLAGS_TEST])
CFLAGS=$save_CFLAGS
AC_LANG_POP([C])
AC_LANG_PUSH([C++])
save_CXXFLAGS=$CXXFLAGS
gl_WARN_ADD([-Werror=unknown-warning-option], [CXXFLAGS])
for i in $warn_common $warn_cxx;
do
gl_WARN_ADD([$i], [WARN_CXXFLAGS])
done
gl_WARN_ADD([ -Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
[AC_LANG_PROGRAM([], [nullptr])])
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
# Warnings for the test suite only.
gl_WARN_ADD([-Wundef], [WARN_CXXFLAGS_TEST])
gl_WARN_ADD([-pedantic], [WARN_CXXFLAGS_TEST])
CXXFLAGS=$save_CXXFLAGS
AC_LANG_POP([C++])
fi
BISON_TEST_FOR_WORKING_C_COMPILER
BISON_TEST_FOR_WORKING_CXX_COMPILER
BISON_C_COMPILER_POSIXLY_CORRECT
AC_ARG_ENABLE([yacc],
[AC_HELP_STRING([--disable-yacc],
@@ -115,6 +154,7 @@ AC_SUBST([YACC_SCRIPT])
AC_SUBST([YACC_LIBRARY])
# Checks for programs.
AM_MISSING_PROG([DOT], [dot])
AC_PROG_LEX
$LEX_IS_FLEX || AC_MSG_ERROR([Flex is required])
AC_PROG_YACC
@@ -123,6 +163,10 @@ AC_PROG_GNU_M4
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4
supports -g, otherwise to "".])
AC_PATH_PROG([PERL], [perl])
if test -z "$PERL"; then
AC_MSG_ERROR([perl not found])
fi
AM_MISSING_PROG([HELP2MAN], [help2man])
AC_PATH_PROG([XSLTPROC], [xsltproc])
AC_SUBST([XSLTPROC])
@@ -170,7 +214,7 @@ case $VALGRIND:$host_os in
# VALGRIND+=' --suppressions=$(abs_top_srcdir)/build-aux/darwin11.4.0.valgrind'
VALGRIND=;;
*:*)
AC_SUBST([VALGRIND_PREBISON], [$VALGRIND -q]);;
AC_SUBST([VALGRIND_PREBISON], ["$VALGRIND -q"]);;
esac
AM_MISSING_PROG([AUTOM4TE], [autom4te])
+1
View File
@@ -14,6 +14,7 @@
# 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
+26 -2
View File
@@ -58,6 +58,30 @@ This special exception was added by the Free Software Foundation in
version 2.2 of Bison.])])
## -------- ##
## Output. ##
## -------- ##
# b4_output_begin(FILE)
# ---------------------
# Enable output, i.e., send to diversion 0, expand after "#", and
# generate the tag to output into FILE. Must be followed by EOL.
m4_define([b4_output_begin],
[m4_changecom()
m4_divert_push(0)dnl
@output(m4_unquote([$1])@)@dnl
])
# b4_output_end()
# ---------------
# Output nothing, restore # as comment character (no expansions after #).
m4_define([b4_output_end],
[m4_divert_pop(0)
m4_changecom([#])
])
## ---------------- ##
## Error handling. ##
## ---------------- ##
@@ -259,8 +283,8 @@ m4_define([b4_basename],
# b4_syncline(LINE, FILE)
# -----------------------
m4_define([b4_syncline],
[b4_flag_if([synclines], [
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
[b4_flag_if([synclines],
[b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
b4_sync_start([$1], [$2])])])
m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
+1 -1
View File
@@ -29,7 +29,7 @@ b4_percent_define_default([[parser_class_name]], [[parser]])
# Don't do that so that we remember whether we're using a user
# request, or the default value.
#
# b4_percent_define_default([[location_type]], [[location]])
# 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]))
+44
View File
@@ -0,0 +1,44 @@
-*- Autoconf -*-
# Common code for C-like languages (C, C++, Java, etc.)
# Copyright (C) 2012 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)
# ----------------------------------------------
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
# pointer.
m4_define([b4_dollar_dollar_],
[m4_if([$2], [[]],
[m4_ifval([$3], [($1.$3)],
[$1])],
[($1.$2)])])
# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION)
# b4_dollar_popdef
# ---------------------------------------------------------
# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD,
# and b4_at_dollar for LOCATION.
m4_define([b4_dollar_pushdef],
[m4_pushdef([b4_dollar_dollar],
[b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl
m4_pushdef([b4_at_dollar], [$3])dnl
])
m4_define([b4_dollar_popdef],
[m4_popdef([b4_at_dollar])dnl
m4_popdef([b4_dollar_dollar])dnl
])
+109 -36
View File
@@ -17,6 +17,7 @@
# 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_include(b4_pkgdatadir/[c-like.m4])
# b4_tocpp(STRING)
# ----------------
@@ -29,19 +30,21 @@ m4_define([b4_tocpp],
# ------------------
# A valid C macro name to use as a CPP header guard for FILE.
m4_define([b4_cpp_guard],
[b4_tocpp(m4_defn([b4_prefix])/[$1])])
[[YY_]b4_tocpp(m4_defn([b4_prefix])/[$1])[_INCLUDED]])
# b4_cpp_guard_open(FILE)
# b4_cpp_guard_close(FILE)
# ------------------------
# Open/close CPP inclusion guards for FILE.
# If FILE does not expand to nothing, open/close CPP inclusion guards for FILE.
m4_define([b4_cpp_guard_open],
[m4_ifval(m4_quote($1),
[#ifndef b4_cpp_guard([$1])
# define b4_cpp_guard([$1])])
# define b4_cpp_guard([$1])])])
m4_define([b4_cpp_guard_close],
[#endif b4_comment([!b4_cpp_guard([$1])])])
[m4_ifval(m4_quote($1),
[#endif b4_comment([!b4_cpp_guard([$1])])])])
## ---------------- ##
@@ -160,7 +163,7 @@ m4_define([b4_int_type],
m4_eval([0 <= $1]), [1], [unsigned int],
[int])])
[int])])
# b4_int_type_for(NAME)
@@ -181,7 +184,7 @@ 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)]],
[[((]$2[) == (]$3[))]])])
[(!!(($2) == ($3)))])])
## ---------##
@@ -253,7 +256,7 @@ m4_define([b4_token_enums],
enum ]b4_api_prefix[tokentype {
]m4_map_sep([ b4_token_enum], [,
],
[$@])[
[$@])[
};
#endif
]])])
@@ -317,7 +320,7 @@ $1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl
m4_define([b4_c_ansi_formals],
[m4_if([$#], [0], [void],
[$#$1], [1], [void],
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
m4_define([b4_c_ansi_formal],
[$1])
@@ -338,9 +341,9 @@ m4_define([b4_c_knr_formal_name],
# 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;])
@@ -352,9 +355,18 @@ m4_define([b4_c_knr_formal_decl],
## ------------------------------------------------------------ ##
# b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
# ----------------------------------------------------------------
# Declare the function NAME ANSI C style.
m4_define([b4_c_ansi_function_decl],
[$2 $1 (b4_c_ansi_formals(m4_shift2($@)));[]dnl
])
# b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
# -----------------------------------------------------------
# Declare the function NAME.
# 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($@)
@@ -364,15 +376,6 @@ $2 $1 ();
])
# b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
# ----------------------------------------------------------------
# Declare the function NAME.
m4_define([b4_c_ansi_function_decl],
[$2 $1 (b4_c_ansi_formals(m4_shift2($@)));[]dnl
])
## --------------------- ##
## Calling C functions. ##
@@ -421,17 +424,18 @@ $2
# 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],
[m4_pushdef([b4_dollar_dollar],
[m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
[b4_dollar_pushdef([(*yyvaluep)], [$6], [(*yylocationp)])dnl
case $4: /* $3 */
b4_syncline([$2], [$1])
$5;
$5;
b4_syncline([@oline@], [@ofile@])
break;
m4_popdef([b4_at_dollar])dnl
m4_popdef([b4_dollar_dollar])dnl
break;
b4_dollar_popdef[]dnl
])
@@ -467,7 +471,7 @@ b4_parse_param_use[]dnl
{
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
default:
break;
break;
}
}]dnl
])
@@ -487,9 +491,9 @@ m4_define_default([b4_yy_symbol_print_generate],
/*ARGSUSED*/
]$1([yy_symbol_value_print],
[static void],
[[FILE *yyoutput], [yyoutput]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
[[FILE *yyoutput], [yyoutput]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
@@ -510,7 +514,7 @@ b4_parse_param_use[]dnl
{
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
[ default:
break;
break;
}
}
@@ -521,9 +525,9 @@ b4_parse_param_use[]dnl
]$1([yy_symbol_print],
[static void],
[[FILE *yyoutput], [yyoutput]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
[[FILE *yyoutput], [yyoutput]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
@@ -598,7 +602,7 @@ m4_define([b4_YYDEBUG_define],
# endif
# else /* ! defined YYDEBUG */
# define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[
# endif /* ! defined ]b4_api_PREFIX[DEBUG */
# endif /* ! defined YYDEBUG */
#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
])
@@ -639,3 +643,72 @@ m4_define([b4_yylloc_default_define],
while (YYID (0))
#endif
]])
# b4_yy_location_print_define
# ---------------------------
# Define YY_LOCATION_PRINT.
m4_define([b4_yy_location_print_define],
[b4_locations_if([[
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
__attribute__((__unused__))
]b4_c_function_def([yy_location_print_],
[static unsigned],
[[FILE *yyo], [yyo]],
[[YYLTYPE const * const yylocp], [yylocp]])[
{
unsigned res = 0;
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
if (0 <= yylocp->first_line)
{
res += fprintf (yyo, "%d", yylocp->first_line);
if (0 <= yylocp->first_column)
res += fprintf (yyo, ".%d", yylocp->first_column);
}
if (0 <= yylocp->last_line)
{
if (yylocp->first_line < yylocp->last_line)
{
res += fprintf (yyo, "-%d", yylocp->last_line);
if (0 <= end_col)
res += fprintf (yyo, ".%d", end_col);
}
else if (0 <= end_col && yylocp->first_column < end_col)
res += fprintf (yyo, "-%d", end_col);
}
return res;
}
# define YY_LOCATION_PRINT(File, Loc) \
yy_location_print_ (File, &(Loc))
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
#endif]],
[[/* This macro is provided for backward compatibility. */
#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif]])
])
# b4_yyloc_default
# ----------------
# Expand to a possible default value for yylloc.
m4_define([b4_yyloc_default],
[[
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
= { ]m4_join([, ],
m4_defn([b4_location_initial_line]),
m4_defn([b4_location_initial_column]),
m4_defn([b4_location_initial_line]),
m4_defn([b4_location_initial_column]))[ }
# endif
]])
+36 -72
View File
@@ -179,13 +179,10 @@ m4_define([b4_shared_declarations],
## Output files. ##
## -------------- ##
# We do want M4 expansion after # for CPP macros.
m4_changecom()
m4_divert_push(0)dnl
@output(b4_parser_file_name@)@
b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
[2002-2012])
[
[2002-2012])[
/* C GLR parser skeleton written by Paul Hilfinger. */
]b4_identification
@@ -223,11 +220,11 @@ b4_percent_code_get([[top]])[
#endif
/* Default (constant) value used for initialization for null
right-hand sides. Unlike the standard yacc.c template,
here we set the default value of $$ to a zeroed-out value.
Since the default value is undefined, this behavior is
technically correct. */
static YYSTYPE yyval_default;
right-hand sides. Unlike the standard yacc.c template, here we set
the default value of $$ to a zeroed-out value. Since the default
value is undefined, this behavior is technically correct. */
static YYSTYPE yyval_default;]b4_locations_if([[
static YYLTYPE yyloc_default][]b4_yyloc_default;])[
/* Copy the second part of user declarations. */
]b4_user_post_prologue
@@ -241,24 +238,24 @@ b4_percent_code_get[]dnl
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# define YY_(Msgid) Msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(e) /* empty */
# define YYUSE(E) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(n) (n)
# define YYID(N) (N)
#else
]b4_c_function_def([YYID], [static int], [[int i], [i]])[
{
@@ -289,8 +286,9 @@ b4_percent_code_get[]dnl
#ifndef YYSETJMP
# include <setjmp.h>
# define YYJMP_BUF jmp_buf
# define YYSETJMP(env) setjmp (env)
# define YYLONGJMP(env, val) longjmp (env, val)
# define YYSETJMP(Env) setjmp (Env)
// Pacify clang.
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
#endif
/*-----------------.
@@ -305,15 +303,8 @@ b4_percent_code_get[]dnl
# endif
#endif
]b4_locations_if([#define YYOPTIONAL_LOC(Name) Name],[
#ifdef __cplusplus
# define YYOPTIONAL_LOC(Name) /* empty */
#else
# define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
#endif])[
#ifndef YYASSERT
# define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
#endif
/* YYFINAL -- State number of the termination state. */
@@ -474,28 +465,10 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
#define YYTERROR 1
]b4_locations_if([[
#ifndef YYLLOC_DEFAULT
]b4_yylloc_default_define[
# define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
#endif
]],[
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
#endif
])[
#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif
]])[
]b4_yy_location_print_define[
/* YYLEX -- calling `yylex' with the right arguments. */
#define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
@@ -972,8 +945,8 @@ yylhsNonterm (yyRuleNum yyrule)
return yyr1[yyrule];
}
#define yypact_value_is_default(yystate) \
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
#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
* of token). */
@@ -990,8 +963,8 @@ yydefaultAction (yyStateNum yystate)
return yydefact[yystate];
}
#define yytable_value_is_error(yytable_value) \
]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
#define yytable_value_is_error(Yytable_value) \
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
* Result R means
@@ -2294,20 +2267,13 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
YYDPRINTF ((stderr, "Starting parse\n"));
yychar = YYEMPTY;
yylval = yyval_default;
]b4_locations_if([
#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
#endif
])
m4_ifdef([b4_initial_action], [
m4_pushdef([b4_at_dollar], [yylloc])dnl
m4_pushdef([b4_dollar_dollar], [yylval])dnl
/* User initialization code. */
b4_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
m4_popdef([b4_at_dollar])])dnl
yylval = yyval_default;]b4_locations_if([
yylloc = yyloc_default;])[
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef])[]dnl
[
if (! yyinitGLRStack (yystackp, YYINITDEPTH))
goto yyexhaustedlab;
@@ -2601,20 +2567,18 @@ yypdumpstack (yyGLRStack* yystackp)
YYFPRINTF (stderr, "\n");
}
#endif
]
]b4_epilogue[]dnl
b4_output_end()
b4_epilogue
dnl
dnl glr.cc produces its own header.
dnl
# glr.cc produces its own header.
m4_if(b4_skeleton, ["glr.c"],
[b4_defines_if(
[@output(b4_spec_defines_file@)@
[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002-2012])[
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
]])])
m4_divert_pop(0)
]b4_output_end()
])])
+17 -15
View File
@@ -54,7 +54,7 @@ b4_defines_if([],
[b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
m4_include(b4_pkgdatadir/[c++.m4])
b4_percent_define_ifdef([[location_type]], [],
b4_percent_define_ifdef([[api.location.type]], [],
[m4_include(b4_pkgdatadir/[location.cc])])
m4_define([b4_parser_class_name],
@@ -87,12 +87,17 @@ m4_define([b4_yy_symbol_print_generate],
]b4_parse_param_use[]dnl
[ yyparser.yy_symbol_print_ (yytype, yyvaluep]b4_locations_if([, yylocationp])[);
}
]])
]])[
# Hijack the initial action to initialize the locations.
]b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
[m4_define([b4_initial_action],
[yylloc.initialize ();]m4_ifdef([b4_initial_action], [
m4_defn([b4_initial_action])]))])])[
# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT
# and declaration of yyerror.
m4_append([b4_post_prologue],
]m4_append([b4_post_prologue],
[b4_syncline([@oline@], [@ofile@])[
]b4_yylloc_default_define[
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
@@ -131,7 +136,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
]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], [ ], [ :])[yydebug_ (false),
]m4_ifset([b4_parse_param], [ ], [ :])[
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
#endif]b4_parse_param_cons[
{
@@ -199,20 +204,19 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
]b4_parser_class_name[::debug_level_type
]b4_parser_class_name[::debug_level () const
{
return yydebug_;
return yydebug;
}
void
]b4_parser_class_name[::set_debug_level (debug_level_type l)
{
yydebug_ = l;
// Actually, it is yydebug which is really used.
yydebug = l;
}
#endif
]m4_popdef([b4_parse_param])dnl
b4_namespace_close[
]])
b4_namespace_close])
# Let glr.c believe that the user arguments include the parser itself.
@@ -226,8 +230,7 @@ m4_defn([b4_parse_param]))],
m4_include(b4_pkgdatadir/[glr.c])
m4_popdef([b4_parse_param])
m4_divert_push(0)
@output(b4_spec_defines_file@)@
b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
[2002-2006, 2009-2012])[
@@ -239,7 +242,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
# include <string>
# include <iostream>
]b4_percent_define_ifdef([[location_type]], [],
]b4_percent_define_ifdef([[api.location.type]], [],
[[# include "location.hh"]])[
]b4_YYDEBUG_define[
@@ -263,7 +266,7 @@ b4_user_stype
typedef ]b4_api_PREFIX[STYPE semantic_type;
# endif
/// Symbol locations.
typedef ]b4_percent_define_get([[location_type]],
typedef ]b4_percent_define_get([[api.location.type]],
[[location]])[ location_type;
/// Tokens.
struct token
@@ -320,7 +323,6 @@ b4_user_stype
const location_type* yylocationp);
private:
/* Debugging. */
int yydebug_;
std::ostream* yycdebug_;
# endif
@@ -341,4 +343,4 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
]b4_namespace_close[
]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])[
]m4_divert_pop(0)
]b4_output_end()
+12 -11
View File
@@ -17,6 +17,7 @@
# 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_include(b4_pkgdatadir/[c-like.m4])
# b4_comment(TEXT)
# ----------------
@@ -154,25 +155,25 @@ m4_define([b4_case], [ case $1:
## ---------------- ##
m4_define([b4_yystype], [b4_percent_define_get([[stype]])])
b4_percent_define_default([[stype]], [[Object]])])
b4_percent_define_default([[stype]], [[Object]])
# %name-prefix
m4_define_default([b4_prefix], [[YY]])
b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])])
b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])
m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])])
b4_percent_define_default([[lex_throws]], [[java.io.IOException]])])
b4_percent_define_default([[lex_throws]], [[java.io.IOException]])
m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])])
b4_percent_define_default([[throws]], [])])
b4_percent_define_default([[throws]], [])
m4_define([b4_throws], [b4_percent_define_get([[throws]])])
b4_percent_define_default([[location_type]], [Location])])
m4_define([b4_location_type], [b4_percent_define_get([[location_type]])])
b4_percent_define_default([[api.location.type]], [Location])
m4_define([b4_location_type], [b4_percent_define_get([[api.location.type]])])
b4_percent_define_default([[position_type]], [Position])])
m4_define([b4_position_type], [b4_percent_define_get([[position_type]])])
b4_percent_define_default([[api.position.type]], [Position])
m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])])
## ----------------- ##
@@ -218,9 +219,9 @@ m4_define([b4_rhs_location],
# it to be single quoted. Same for b4_parse_param.
# TODO: should be in bison.m4
m4_define_default([b4_lex_param], [[]]))
m4_define([b4_lex_param], b4_lex_param))
m4_define([b4_parse_param], b4_parse_param))
m4_define_default([b4_lex_param], [[]])
m4_define([b4_lex_param], b4_lex_param)
m4_define([b4_parse_param], b4_parse_param)
# b4_lex_param_decl
# -------------------
+85 -52
View File
@@ -24,17 +24,14 @@ m4_define([b4_parser_class_name],
b4_defines_if([],
[b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
b4_percent_define_ifdef([[location_type]], [],
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])
# We do want M4 expansion after # for CPP macros.
m4_changecom()
m4_divert_push(0)dnl
b4_defines_if(
[@output(b4_spec_defines_file@)@
[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
[2002-2012])
[
@@ -52,7 +49,7 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
#include <string>
#include <iostream>
#include "stack.hh"
]b4_percent_define_ifdef([[location_type]], [],
]b4_percent_define_ifdef([[api.location.type]], [],
[[#include "location.hh"]])[
]b4_YYDEBUG_define[
@@ -77,7 +74,7 @@ b4_user_stype
typedef ]b4_api_PREFIX[STYPE semantic_type;
#endif
/// Symbol locations.
typedef ]b4_percent_define_get([[location_type]],
typedef ]b4_percent_define_get([[api.location.type]],
[[location]])[ location_type;
/// Tokens.
struct token
@@ -227,6 +224,7 @@ b4_user_stype
/// \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.
@@ -264,8 +262,11 @@ b4_user_stype
])[
]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])
])dnl
@output(b4_parser_file_name@)@
b4_output_end()
])
b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++],
[2002-2012])
b4_percent_code_get([[top]])[]dnl
@@ -335,9 +336,9 @@ do { \
#else /* !]b4_api_PREFIX[DEBUG */
# define YYCDEBUG if (false) std::cerr
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_REDUCE_PRINT(Rule)
# define YY_STACK_PRINT()
# 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)
#endif /* !]b4_api_PREFIX[DEBUG */
@@ -446,7 +447,8 @@ do { \
YYUSE (yymsg);
YYUSE (yyvaluep);
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
if (yymsg)
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
switch (yytype)
{
@@ -510,17 +512,18 @@ do { \
int yychar = yyempty_;
int yytoken = 0;
/* State. */
// State.
int yyn;
int yylen = 0;
int yystate = 0;
/* Error handling. */
// Error handling.
int yynerrs_ = 0;
int yyerrstatus_ = 0;
/// Semantic value of the lookahead.
semantic_type yylval;
static semantic_type yyval_default;
semantic_type yylval = yyval_default;
/// Location of the lookahead.
location_type yylloc;
/// The locations where the error started and ended.
@@ -533,15 +536,17 @@ do { \
int yyresult;
// FIXME: This shoud be completely indented. It is not yet to
// avoid gratuitous conflicts when merging into the master branch.
try
{
YYCDEBUG << "Starting parse" << std::endl;
]m4_ifdef([b4_initial_action], [
m4_pushdef([b4_at_dollar], [yylloc])dnl
m4_pushdef([b4_dollar_dollar], [yylval])dnl
/* User initialization code. */
b4_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
m4_popdef([b4_at_dollar])])dnl
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef])[]dnl
[ /* Initialize the stacks. The initial state will be pushed in
yynewstate, since the latter expects the semantical and the
@@ -575,14 +580,13 @@ m4_popdef([b4_at_dollar])])dnl
/* Read a lookahead token. */
if (yychar == yyempty_)
{
YYCDEBUG << "Reading a token: ";
yychar = ]b4_c_function_call([yylex], [int],
[b4_api_PREFIX[STYPE*], [&yylval]][]dnl
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_)
{
@@ -653,17 +657,21 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
else
yyval = yysemantic_stack_[0];
// Compute the default @@$.
{
slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
YYLLOC_DEFAULT (yyloc, slice, yylen);
}
// Perform the reduction.
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
]b4_user_actions[
default:
break;
]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.
@@ -714,20 +722,19 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
yyerror_range[1] = yylloc;
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
{
yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
yychar = yyempty_;
}
/* 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
{
yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
yychar = yyempty_;
}
}
/* Else will try to reuse lookahead token after shifting the error
@@ -776,7 +783,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
/* Pop the current state because it cannot handle the error token. */
if (yystate_stack_.height () == 1)
YYABORT;
YYABORT;
yyerror_range[1] = yylocation_stack_[0];
yydestruct_ ("Error: popping",
@@ -824,16 +831,42 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
/* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */
yypop_ (yylen);
while (yystate_stack_.height () != 1)
while (1 < yystate_stack_.height ())
{
yydestruct_ ("Cleanup: popping",
yystos_[yystate_stack_[0]],
&yysemantic_stack_[0],
&yylocation_stack_[0]);
yypop_ ();
yydestruct_ ("Cleanup: popping",
yystos_[yystate_stack_[0]],
&yysemantic_stack_[0],
&yylocation_stack_[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);
}
while (1 < yystate_stack_.height ())
{
yydestruct_ (YY_NULL,
yystos_[yystate_stack_[0]],
&yysemantic_stack_[0],
&yylocation_stack_[0]);
yypop_ ();
}
throw;
}
}
// Generate an error message.
@@ -1106,5 +1139,5 @@ b4_error_verbose_if([int yystate, int yytoken],
const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
]b4_namespace_close[
]b4_epilogue
m4_divert_pop(0)
]b4_epilogue[]dnl
b4_output_end()
+6 -9
View File
@@ -22,8 +22,7 @@ m4_ifval(m4_defn([b4_symbol_destructors]),
[b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])],
[])
m4_divert_push(0)dnl
@output(b4_parser_file_name@)@
b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
[2007-2012])
@@ -458,12 +457,10 @@ b4_lexer_if([[
yyerrstatus_ = 0;
]m4_ifdef([b4_initial_action], [
m4_pushdef([b4_at_dollar], [yylloc])dnl
m4_pushdef([b4_dollar_dollar], [yylval])dnl
/* User initialization code. */
b4_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
m4_popdef([b4_at_dollar])])dnl
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef])[]dnl
[ /* Initialize the stack. */
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
@@ -927,4 +924,4 @@ b4_percent_code_get[]dnl
}
b4_epilogue
m4_divert_pop(0)dnl
b4_output_end()
+16 -15
View File
@@ -15,10 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# We do want M4 expansion after # for CPP macros.
m4_changecom()
m4_divert_push(0)dnl
@output(b4_dir_prefix[]position.hh@)@
b4_output_begin([b4_dir_prefix[]position.hh])
b4_copyright([Positions for Bison parsers in C++],
[2002-2007, 2009-2012])[
@@ -30,7 +28,7 @@ b4_copyright([Positions for Bison parsers in C++],
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
# include <algorithm> // std::max
# include <iosfwd>
# include <iostream>
# include <string>
]b4_null_define[
@@ -87,7 +85,7 @@ b4_copyright([Positions for Bison parsers in C++],
};
/// Add and assign a position.
inline const position&
inline position&
operator+= (position& res, const int width)
{
res.columns (width);
@@ -103,7 +101,7 @@ b4_copyright([Positions for Bison parsers in C++],
}
/// Add and assign a position.
inline const position&
inline position&
operator-= (position& res, const int width)
{
return res += -width;
@@ -138,8 +136,9 @@ b4_copyright([Positions for Bison parsers in C++],
** \param ostr the destination output stream
** \param pos a reference to the position to redirect
*/
inline std::ostream&
operator<< (std::ostream& ostr, const position& pos)
template <typename YYChar>
inline std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
{
if (pos.filename)
ostr << *pos.filename << ':';
@@ -148,7 +147,10 @@ b4_copyright([Positions for Bison parsers in C++],
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
@output(b4_dir_prefix[]location.hh@)@
b4_output_end()
b4_output_begin([b4_dir_prefix[]location.hh])
b4_copyright([Locations for Bison parsers in C++],
[2002-2007, 2009-2012])[
@@ -159,8 +161,6 @@ b4_copyright([Locations for Bison parsers in C++],
]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[
# include <iostream>
# include <string>
# include "position.hh"
]b4_namespace_open[
@@ -276,7 +276,9 @@ b4_copyright([Locations for Bison parsers in C++],
**
** Avoid duplicate information.
*/
inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
template <typename YYChar>
inline std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{
position last = loc.end - 1;
ostr << loc.begin;
@@ -294,5 +296,4 @@ b4_copyright([Locations for Bison parsers in C++],
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
m4_divert_pop(0)
m4_changecom([#])
b4_output_end()
+4 -7
View File
@@ -18,10 +18,7 @@
m4_pushdef([b4_copyright_years],
[2002-2012])
# We do want M4 expansion after # for CPP macros.
m4_changecom()
m4_divert_push(0)dnl
@output(b4_dir_prefix[]stack.hh@)@
b4_output_begin([b4_dir_prefix[]stack.hh])
b4_copyright([Stack handling for Bison parsers in C++],
[2002-2012])[
@@ -119,6 +116,6 @@ b4_copyright([Stack handling for Bison parsers in C++],
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
m4_divert_pop(0)
m4_popdef([b4_copyright_years])dnl
m4_changecom([#])
b4_output_end()
m4_popdef([b4_copyright_years])
+12
View File
@@ -90,4 +90,16 @@
<xsl:value-of select="string-length(translate($conflict-data, 's', ''))"/>
</xsl:template>
<xsl:template name="space">
<xsl:param name="repeat">0</xsl:param>
<xsl:param name="fill" select="' '"/>
<xsl:if test="number($repeat) &gt;= 1">
<xsl:call-template name="space">
<xsl:with-param name="repeat" select="$repeat - 1"/>
<xsl:with-param name="fill" select="$fill"/>
</xsl:call-template>
<xsl:value-of select="$fill"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
+182 -7
View File
@@ -55,7 +55,11 @@
<xsl:call-template name="escape">
<xsl:with-param name="subject" select="$filename"/>
</xsl:call-template>
<xsl:text>"&#10;{&#10;</xsl:text>
<xsl:text>"&#10;{
node [fontname = courier, shape = box, colorscheme = paired6]
edge [fontname = courier]
</xsl:text>
<xsl:apply-templates select="state"/>
<xsl:text>}&#10;</xsl:text>
</xsl:template>
@@ -64,11 +68,87 @@
<xsl:call-template name="output-node">
<xsl:with-param name="number" select="@number"/>
<xsl:with-param name="label">
<xsl:value-of select="@number"/>
<xsl:apply-templates select="itemset/item"/>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates select="actions/transitions"/>
<xsl:apply-templates select="actions/reductions">
<xsl:with-param name="staten">
<xsl:value-of select="@number"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="actions/reductions">
<xsl:param name="staten"/>
<xsl:for-each select='reduction'>
<!-- These variables are needed because the current context can't be
refered to directly in XPath expressions. -->
<xsl:variable name="rul">
<xsl:value-of select="@rule"/>
</xsl:variable>
<xsl:variable name="ena">
<xsl:value-of select="@enabled"/>
</xsl:variable>
<!-- The foreach's body is protected by this, so that we are actually
going to iterate once per reduction rule, and not per lookahead. -->
<xsl:if test='not(preceding-sibling::*[@rule=$rul and @enabled=$ena])'>
<xsl:variable name="rule">
<xsl:choose>
<!-- The acceptation state is refered to as 'accept' in the XML, but
just as '0' in the DOT. -->
<xsl:when test="@rule='accept'">
<xsl:text>0</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@rule"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- The edge's beginning -->
<xsl:call-template name="reduction-edge-start">
<xsl:with-param name="state" select="$staten"/>
<xsl:with-param name="rule" select="$rule"/>
<xsl:with-param name="enabled" select="@enabled"/>
</xsl:call-template>
<!-- The edge's tokens -->
<!-- Don't show labels for the default action. In other cases, there will
always be at least one token, so 'label="[]"' will not occur. -->
<xsl:if test='$rule!=0 and not(../reduction[@enabled=$ena and @rule=$rule and @symbol="$default"])'>
<xsl:text>label="[</xsl:text>
<xsl:for-each select='../reduction[@enabled=$ena and @rule=$rule]'>
<xsl:call-template name="escape">
<xsl:with-param name="subject" select="@symbol"/>
</xsl:call-template>
<xsl:if test="position() != last ()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>]", </xsl:text>
</xsl:if>
<!-- The edge's end -->
<xsl:text>style=solid]&#10;</xsl:text>
<!-- The diamond representing the reduction -->
<xsl:call-template name="reduction-node">
<xsl:with-param name="state" select="$staten"/>
<xsl:with-param name="rule" select="$rule"/>
<xsl:with-param name="color">
<xsl:choose>
<xsl:when test='@enabled="true"'>
<xsl:text>3</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>5</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="actions/transitions">
@@ -76,17 +156,48 @@
</xsl:template>
<xsl:template match="item">
<xsl:param name="prev-rule-number"
select="preceding-sibling::item[1]/@rule-number"/>
<xsl:apply-templates select="key('bison:ruleByNumber', @rule-number)">
<xsl:with-param name="point" select="@point"/>
<xsl:with-param name="num" select="@rule-number"/>
<xsl:with-param name="prev-lhs"
select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]"
/>
</xsl:apply-templates>
<xsl:apply-templates select="lookaheads"/>
</xsl:template>
<xsl:template match="rule">
<xsl:param name="point"/>
<xsl:param name="num"/>
<xsl:param name="prev-lhs"/>
<xsl:text>&#10;</xsl:text>
<xsl:value-of select="lhs"/>
<xsl:text> -&gt;</xsl:text>
<xsl:choose>
<xsl:when test="$num &lt; 10">
<xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="$num &lt; 100">
<xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text></xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$num"/>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="$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()])) + 1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="lhs"/>
<xsl:text>:</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$point = 0">
<xsl:text> .</xsl:text>
</xsl:if>
@@ -106,7 +217,7 @@
<xsl:template match="empty"/>
<xsl:template match="lookaheads">
<xsl:text>[</xsl:text>
<xsl:text> [</xsl:text>
<xsl:apply-templates select="symbol"/>
<xsl:text>]</xsl:text>
</xsl:template>
@@ -118,6 +229,50 @@
</xsl:if>
</xsl:template>
<xsl:template name="reduction-edge-start">
<xsl:param name="state"/>
<xsl:param name="rule"/>
<xsl:param name="enabled"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$state"/>
<xsl:text> -> "</xsl:text>
<xsl:value-of select="$state"/>
<xsl:text>R</xsl:text>
<xsl:value-of select="$rule"/>
<xsl:if test='$enabled = "false"'>
<xsl:text>d</xsl:text>
</xsl:if>
<xsl:text>" [</xsl:text>
</xsl:template>
<xsl:template name="reduction-node">
<xsl:param name="state"/>
<xsl:param name="rule"/>
<xsl:param name="color"/>
<xsl:text> "</xsl:text>
<xsl:value-of select="$state"/>
<xsl:text>R</xsl:text>
<xsl:value-of select="$rule"/>
<xsl:if test="$color = 5">
<xsl:text>d</xsl:text>
</xsl:if>
<xsl:text>" [label="</xsl:text>
<xsl:choose>
<xsl:when test="$rule = 0">
<xsl:text>Acc", fillcolor=1</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>R</xsl:text>
<xsl:value-of select="$rule"/>
<xsl:text>", fillcolor=</xsl:text>
<xsl:value-of select="$color"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>, shape=diamond, style=filled]&#10;</xsl:text>
</xsl:template>
<xsl:template match="transition">
<xsl:call-template name="output-edge">
<xsl:with-param name="src" select="../../../@number"/>
@@ -149,10 +304,13 @@
<xsl:text> </xsl:text>
<xsl:value-of select="$number"/>
<xsl:text> [label="</xsl:text>
<xsl:text>State </xsl:text>
<xsl:value-of select="$number"/>
<xsl:text>\n</xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="subject" select="$label"/>
</xsl:call-template>
<xsl:text>"]&#10;</xsl:text>
<xsl:text>\l"]&#10;</xsl:text>
</xsl:template>
<xsl:template name="output-edge">
@@ -193,7 +351,7 @@
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="search" select="'&#10;'"/>
<xsl:with-param name="replace" select="'\n'"/>
<xsl:with-param name="replace" select="'\l'"/>
</xsl:call-template>
</xsl:template>
@@ -219,4 +377,21 @@
</xsl:choose>
</xsl:template>
<xsl:template name="lpad">
<xsl:param name="str" select="''"/>
<xsl:param name="pad" select="0"/>
<xsl:variable name="diff" select="$pad - string-length($str)" />
<xsl:choose>
<xsl:when test="$diff &lt; 0">
<xsl:value-of select="$str"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="space">
<xsl:with-param name="repeat" select="$diff"/>
</xsl:call-template>
<xsl:value-of select="$str"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
+1 -13
View File
@@ -230,7 +230,7 @@
<xsl:template match="automaton/state">
<xsl:param name="pad"/>
<xsl:text>&#10;&#10;</xsl:text>
<xsl:text>state </xsl:text>
<xsl:text>State </xsl:text>
<xsl:value-of select="@number"/>
<xsl:text>&#10;&#10;</xsl:text>
<xsl:apply-templates select="itemset/item">
@@ -522,18 +522,6 @@
</xsl:choose>
</xsl:template>
<xsl:template name="space">
<xsl:param name="repeat">0</xsl:param>
<xsl:param name="fill" select="' '"/>
<xsl:if test="number($repeat) &gt;= 1">
<xsl:call-template name="space">
<xsl:with-param name="repeat" select="$repeat - 1"/>
<xsl:with-param name="fill" select="$fill"/>
</xsl:call-template>
<xsl:value-of select="$fill"/>
</xsl:if>
</xsl:template>
<xsl:template name="line-wrap">
<xsl:param name="line-length"/> <!-- required -->
<xsl:param name="first-line-length" select="$line-length"/>
+96 -91
View File
@@ -65,24 +65,36 @@ m4_define_default([b4_stack_depth_init], [200])
## ------------------------ ##
b4_percent_define_default([[api.pure]], [[false]])
b4_define_flag_if([pure])
m4_define([b4_pure_flag],
[b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])
b4_percent_define_check_values([[[[api.pure]],
[[false]], [[true]], [[]], [[full]]]])
# b4_yacc_pure_if(IF-TRUE, IF-FALSE)
# ----------------------------------
# Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.
m4_define([b4_yacc_pure_if],
[b4_pure_if([m4_ifset([b4_parse_param],
[$1], [$2])],
[$2])])
m4_define([b4_pure_flag], [[0]])
m4_case(b4_percent_define_get([[api.pure]]),
[false], [m4_define([b4_pure_flag], [[0]])],
[true], [m4_define([b4_pure_flag], [[1]])],
[], [m4_define([b4_pure_flag], [[1]])],
[full], [m4_define([b4_pure_flag], [[2]])])
m4_define([b4_pure_if],
[m4_case(b4_pure_flag,
[0], [$2],
[1], [$1],
[2], [$1])])
[m4_fatal([invalid api.pure value: ]$1)])])
# b4_yyerror_arg_loc_if(ARG)
# --------------------------
# Expand ARG iff yyerror is to be given a location as argument.
m4_define([b4_yyerror_arg_loc_if],
[b4_locations_if([m4_case(b4_pure_flag,
[1], [m4_ifset([b4_parse_param], [$1])],
[2], [$1])])])
# b4_yyerror_args
# ---------------
# Arguments passed to yyerror: user args plus yylloc.
m4_define([b4_yyerror_args],
[b4_yacc_pure_if([b4_locations_if([&yylloc, ])])dnl
[b4_yyerror_arg_loc_if([&yylloc, ])dnl
m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
@@ -170,11 +182,36 @@ m4_define([b4_declare_scanner_communication_variables], [[
/* The lookahead symbol. */
int yychar;
]b4_pure_if([[
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
static YYSTYPE yyval_default;
# define YY_INITIAL_VALUE(Value) = Value
#endif]b4_locations_if([[
static YYLTYPE yyloc_default][]b4_yyloc_default[;]])])[
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;]b4_locations_if([[
YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);]b4_locations_if([[
/* Location data for the lookahead symbol. */
YYLTYPE yylloc;]])b4_pure_if([], [[
YYLTYPE yylloc]b4_pure_if([ = yyloc_default], [b4_yyloc_default])[;
]])b4_pure_if([], [[
/* Number of syntax errors so far. */
int yynerrs;]])])
@@ -242,7 +279,7 @@ typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
[[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([,
[[[int pushed_char]], [[pushed_char]]],
[[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([,
[[b4_api_PREFIX[LTYPE const *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [,
[[b4_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_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [,
@@ -289,14 +326,12 @@ m4_define([b4_shared_declarations],
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
])
## -------------- ##
## Output files. ##
## -------------- ##
# We do want M4 expansion after # for CPP macros.
m4_changecom()
m4_divert_push(0)dnl
@output(b4_parser_file_name@)@
b4_output_begin([b4_parser_file_name])
b4_copyright([Bison implementation for Yacc-like parsers in C],
[1984, 1989-1990, 2000-2012])[
@@ -345,9 +380,11 @@ m4_if(b4_api_prefix, [yy], [],
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
#endif
/* In a future release of Bison, this section will be replaced
]m4_ifval(m4_quote(b4_spec_defines_file),
[[/* In a future release of Bison, this section will be replaced
by #include "@basename(]b4_spec_defines_file[@)". */
]b4_shared_declarations[
]])dnl
b4_shared_declarations[
/* Copy the second part of user declarations. */
]b4_user_post_prologue
@@ -402,24 +439,24 @@ typedef short int yytype_int16;
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# define YY_(Msgid) Msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(e) /* empty */
# define YYUSE(E) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(n) (n)
# define YYID(N) (N)
#else
]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[
{
@@ -678,11 +715,11 @@ 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 yypact_value_is_default(Yystate) \
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
#define yytable_value_is_error(yytable_value) \
]b4_table_value_equals([[table]], [[yytable_value]], [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[] =
{
@@ -741,40 +778,17 @@ do \
} \
while (YYID (0))
/* Error token number */
#define YYTERROR 1
#define YYERRCODE 256
]b4_locations_if([[
]b4_yylloc_default_define[
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
]b4_locations_if([[
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
#endif]], [[
/* This macro is provided for backward compatibility. */
#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif]])[
]])[
]b4_yy_location_print_define[
/* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM
# define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM)
#else
@@ -1407,7 +1421,8 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
yypstate *yyps_local;]b4_pure_if([[
int yychar;
YYSTYPE yylval;]b4_locations_if([[
YYLTYPE yylloc;]])])[
static YYLTYPE yyloc_default][]b4_yyloc_default[;
YYLTYPE yylloc = yyloc_default;]])])[
if (yyps)
yyps_local = yyps;
else
@@ -1487,7 +1502,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
[[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
[[[int yypushed_char]], [[yypushed_char]]],
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
[[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
[[[YYLTYPE *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
b4_parse_param]))], [[
@@ -1513,7 +1528,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken;
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;]b4_locations_if([[
@@ -1538,10 +1553,9 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
goto yyread_pushed_token;
}]])[
yytoken = 0;
yyss = yyssa;
yyvs = yyvsa;]b4_locations_if([[
yyls = yylsa;]])[
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;]b4_locations_if([[
yylsp = yyls = yylsa;]])[
yystacksize = YYINITDEPTH;]b4_lac_if([[
yyes = yyesa;
@@ -1555,32 +1569,17 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;]b4_locations_if([[
yylsp = yyls;
#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
#endif]])
m4_ifdef([b4_initial_action],[
m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl
m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [],
[b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])])dnl
/* User initialization code. */
b4_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
m4_popdef([b4_at_dollar])])dnl
b4_dollar_popdef[]dnl
m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
]])])dnl
b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])[;
]])dnl
m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
]])[
goto yysetstate;
[ goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
@@ -1750,7 +1749,9 @@ yyread_pushed_token:]])[
YY_LAC_DISCARD ("shift");]])[
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
]b4_locations_if([ *++yylsp = yylloc;])[
goto yynewstate;
@@ -1970,7 +1971,9 @@ yyerrlab1:
current lookahead token, the shift below will for sure. */
YY_LAC_DISCARD ("error recovery");]])[
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
]b4_locations_if([[
yyerror_range[2] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
@@ -2046,12 +2049,14 @@ yypushreturn:]])[
}
]b4_epilogue
]b4_epilogue[]dnl
b4_output_end()
b4_defines_if(
[@output(b4_spec_defines_file@)@
b4_copyright([Bison interface for Yacc-like parsers in C],
[1984, 1989-1990, 2000-2012])[
[b4_output_begin([b4_spec_defines_file])[
]b4_copyright([Bison interface for Yacc-like parsers in C],
[1984, 1989-1990, 2000-2012])[
]b4_shared_declarations[
]])dnl b4_defines_if
m4_divert_pop(0)
]b4_output_end()
])
+1 -1
View File
@@ -1,4 +1,3 @@
/*.info*
/*~
/.dirstamp
/Makefile
@@ -10,6 +9,7 @@
/bison.dvi
/bison.fn
/bison.html
/bison.info
/bison.ky
/bison.log
/bison.pdf
+1 -1
View File
@@ -940,7 +940,7 @@ EXTERNAL_GROUPS = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
PERL_PATH = /usr/bin/perl
PERL_PATH = @PERL@
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
+31 -1
View File
@@ -30,7 +30,7 @@ $(srcdir)/cross-options.texi: $(top_srcdir)/src/getargs.c $(CROSS_OPTIONS_PL)
$(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
| $(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
@@ -96,6 +96,36 @@ PREPATH = $(top_builddir)/src
nodist_man_MANS = yacc.1
## ----------------------------- ##
## Graphviz examples generation. ##
## ----------------------------- ##
CLEANDIRS += figs
FIGS_DOT = figs/example-reduce.dot 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
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. ##
## -------------- ##
+594 -159
View File
File diff suppressed because it is too large Load Diff
+11
View File
@@ -0,0 +1,11 @@
digraph "reduce.y"
{
node [fontname=courier shape=box]
edge [fontname=courier]
1 [label="State 1\n 3 a: \"0\" . [\".\"]\l 4 b: \"0\" . [\";\"]\l"]
1 -> "1R3" [label="" style=solid]
"1R3" [style=filled shape=diamond fillcolor=yellowgreen label="R3"]
1 -> "1R4" [label="[\";\"]" style=solid]
"1R4" [style=filled shape=diamond fillcolor=yellowgreen label="R4"]
}
+13
View File
@@ -0,0 +1,13 @@
.------------------.
| State 1 |
| 3 a: "0" . [";"] |
| 4 b: "0" . ["."] |
`------------------'
/ \
/ \ ["."]
/ \
v v
/ \ / \
/ R \ / R \
(green) \ 3 / \ 4 / (green)
\ / \ /
+9
View File
@@ -0,0 +1,9 @@
digraph "shift.y"
{
node [fontname=courier shape=box]
edge [fontname=courier]
3 [label="State 3\n 1 exp: a . \".\"\l"]
3 -> 6 [style=solid label="\".\""]
6 [label="State 6\n 1 exp: a \".\" .\l"]
}
+12
View File
@@ -0,0 +1,12 @@
.----------------.
| State 3 |
| 1 exp: a . ";" |
`----------------'
|
| ";"
|
v
.----------------.
| State 6 |
| 1 exp: a ";" . |
`----------------'
-1
View File
@@ -1 +0,0 @@
external: gnulib
+1 -1
Submodule gnulib updated: 2f67aa79c6...c457e702ba
+12
View File
@@ -268,3 +268,15 @@
/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
+2
View File
@@ -17,6 +17,8 @@
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 <config.h>
#include <stdio.h>
int yyerror (char const *);
+4 -1
View File
@@ -48,7 +48,6 @@
/hash.m4
/iconv.m4
/include_next.m4
/inline.m4
/intdiv0.m4
/intl.m4
/intldir.m4
@@ -179,3 +178,7 @@
/xalloc.m4
/xsize.m4
/xstrndup.m4
/obstack-printf.m4
/extern-inline.m4
/getdelim.m4
/getline.m4
+44
View File
@@ -25,3 +25,47 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_C_COMPILER], [
[],
[AC_MSG_FAILURE([cannot compile a simple C program])])
])
# BISON_CHECK_WITH_POSIXLY_CORRECT(CODE)
# --------------------------------------
# Run the Autoconf CODE with POSIXLY_CORRECT set to 1, and restored to
# its initial value afterwards.
AC_DEFUN([BISON_CHECK_WITH_POSIXLY_CORRECT],
[gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }'
case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in
xx) gl_had_POSIXLY_CORRECT=exported ;;
x) gl_had_POSIXLY_CORRECT=yes ;;
*) gl_had_POSIXLY_CORRECT= ;;
esac
POSIXLY_CORRECT=1
export POSIXLY_CORRECT
$1
case $gl_had_POSIXLY_CORRECT in
exported) ;;
yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;;
*) AS_UNSET([POSIXLY_CORRECT]) ;;
esac
])
# BISON_C_COMPILER_POSIXLY_CORRECT
# --------------------------------
# Whether the compiler supports -g in POSIXLY_CORRECT mode. clang-2.9
# on OS X does not, because "clang-mp-2.9 -o test -g test.c" launches
# "/usr/bin/dsymutil test -o test.dSYM" which fails with "error:
# unable to open executable '-o'".
#
# Sets C_COMPILER_POSIXLY_CORRECT to true/false.
AC_DEFUN([BISON_C_COMPILER_POSIXLY_CORRECT],
[AC_CACHE_CHECK([whether $CC supports POSIXLY_CORRECT=1],
[bison_cv_cc_supports_posixly_correct],
[BISON_CHECK_WITH_POSIXLY_CORRECT(
[AC_LANG_PUSH([C])
AC_LINK_IFELSE([AC_LANG_PROGRAM],
[bison_cv_cc_supports_posixly_correct=yes],
[bison_cv_cc_supports_posixly_correct=no])
AC_LANG_POP([C])])])
case $bison_cv_cc_supports_posixly_correct in
yes) AC_SUBST([C_COMPILER_POSIXLY_CORRECT], [true]) ;;
no) AC_SUBST([C_COMPILER_POSIXLY_CORRECT], [false]);;
esac
])
+1
View File
@@ -9,6 +9,7 @@ src/main.c
src/muscle-tab.c
src/parse-gram.y
src/print.c
src/print_graph.c
src/reader.c
src/reduce.c
src/scan-code.l
+12 -8
View File
@@ -74,11 +74,15 @@ error_message (location *loc,
vfprintf (stderr, message, args);
{
size_t l = strlen (message);
if (l < 2 || message[l-2] != ':' || message[l-1] != ' ') {
putc ('\n', stderr);
fflush (stderr);
}
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')
{
putc ('\n', stderr);
fflush (stderr);
if (loc && feature_flag & feature_caret)
location_caret (stderr, *loc);
}
}
fflush (stderr);
}
/** Wrap error_message() with varargs handling. */
@@ -124,7 +128,7 @@ warn_at_indent (location loc, unsigned *indent,
return;
set_warning_issued ();
indent_ptr = indent;
ERROR_MESSAGE (&loc, _("warning"), message);
ERROR_MESSAGE (&loc, *indent ? NULL : _("warning"), message);
}
void
@@ -144,7 +148,7 @@ warn (const char *message, ...)
void
complain_at (location loc, const char *message, ...)
{
ERROR_MESSAGE (&loc, NULL, message);
ERROR_MESSAGE (&loc, _("error"), message);
complaint_issued = true;
}
@@ -153,14 +157,14 @@ complain_at_indent (location loc, unsigned *indent,
const char *message, ...)
{
indent_ptr = indent;
ERROR_MESSAGE (&loc, NULL, message);
ERROR_MESSAGE (&loc, *indent ? NULL : _("error"), message);
complaint_issued = true;
}
void
complain (const char *message, ...)
{
ERROR_MESSAGE (NULL, NULL, message);
ERROR_MESSAGE (NULL, _("error"), message);
complaint_issued = true;
}
+3
View File
@@ -25,6 +25,9 @@
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.
+16 -16
View File
@@ -73,7 +73,7 @@ log_resolution (rule *r, symbol_number token,
{
case shift_resolution:
case right_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as shift"),
r->number,
@@ -82,7 +82,7 @@ log_resolution (rule *r, symbol_number token,
case reduce_resolution:
case left_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as reduce"),
r->number,
@@ -90,7 +90,7 @@ log_resolution (rule *r, symbol_number token,
break;
case nonassoc_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as an error"),
r->number,
@@ -102,33 +102,33 @@ log_resolution (rule *r, symbol_number token,
switch (resolution)
{
case shift_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
" (%s < %s)",
r->prec->tag,
symbols[token]->tag);
break;
case reduce_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
" (%s < %s)",
symbols[token]->tag,
r->prec->tag);
break;
case left_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
" (%%left %s)",
symbols[token]->tag);
break;
case right_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
" (%%right %s)",
symbols[token]->tag);
break;
case nonassoc_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
" (%%nonassoc %s)",
symbols[token]->tag);
break;
@@ -145,7 +145,7 @@ log_resolution (rule *r, symbol_number token,
{
case shift_resolution:
case right_resolution:
obstack_fgrow2 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
" <resolution rule=\"%d\" symbol=\"%s\""
" type=\"shift\">",
r->number,
@@ -154,7 +154,7 @@ log_resolution (rule *r, symbol_number token,
case reduce_resolution:
case left_resolution:
obstack_fgrow2 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
" <resolution rule=\"%d\" symbol=\"%s\""
" type=\"reduce\">",
r->number,
@@ -162,7 +162,7 @@ log_resolution (rule *r, symbol_number token,
break;
case nonassoc_resolution:
obstack_fgrow2 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
" <resolution rule=\"%d\" symbol=\"%s\""
" type=\"error\">",
r->number,
@@ -174,33 +174,33 @@ log_resolution (rule *r, symbol_number token,
switch (resolution)
{
case shift_resolution:
obstack_fgrow2 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
"%s &lt; %s",
xml_escape_n (0, r->prec->tag),
xml_escape_n (1, symbols[token]->tag));
break;
case reduce_resolution:
obstack_fgrow2 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
"%s &lt; %s",
xml_escape_n (0, symbols[token]->tag),
xml_escape_n (1, r->prec->tag));
break;
case left_resolution:
obstack_fgrow1 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
"%%left %s",
xml_escape (symbols[token]->tag));
break;
case right_resolution:
obstack_fgrow1 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
"%%right %s",
xml_escape (symbols[token]->tag));
break;
case nonassoc_resolution:
obstack_fgrow1 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
"%%nonassoc %s",
xml_escape (symbols[token]->tag));
break;
+7 -13
View File
@@ -21,20 +21,14 @@
# error "FLEX_PREFIX not defined"
#endif
/* Whether this version of Flex is (strictly) greater than
Major.Minor.Subminor. */
#define FLEX_VERSION_GT(Major, Minor, Subminor) \
(defined YY_FLEX_MAJOR_VERSION \
&& (Major < YY_FLEX_MAJOR_VERSION \
|| (Major == YY_FLEX_MAJOR_VERSION \
&& (defined YY_FLEX_MINOR_VERSION \
&& (Minor < YY_FLEX_MINOR_VERSION \
|| (Minor == YY_FLEX_MINOR_VERSION \
&& defined YY_FLEX_SUBMINOR_VERSION \
&& Subminor < YY_FLEX_SUBMINOR_VERSION))))))
/* Flex full version as a number. */
#define FLEX_VERSION \
((YY_FLEX_MAJOR_VERSION) * 1000000 \
+ (YY_FLEX_MINOR_VERSION) * 1000 \
+ (YY_FLEX_SUBMINOR_VERSION))
/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */
# if ! FLEX_VERSION_GT (2, 5, 31)
# if FLEX_VERSION <= 2005031
int FLEX_PREFIX (get_lineno) (void);
FILE *FLEX_PREFIX (get_in) (void);
FILE *FLEX_PREFIX (get_out) (void);
@@ -65,7 +59,7 @@ int FLEX_PREFIX (lex_destroy) (void);
versions according to the Flex manual) leak memory if yylex_destroy is not
invoked. However, yylex_destroy is not defined before Flex 2.5.9, so give
an implementation here that at least appears to work with Flex 2.5.4. */
#if ! FLEX_VERSION_GT (2, 5, 9)
#if FLEX_VERSION <= 2005009
# define yylex_destroy() yy_delete_buffer (YY_CURRENT_BUFFER)
#endif
+62 -8
View File
@@ -49,7 +49,7 @@
#include "quote.h"
#include "uniqstr.h"
bool debug_flag;
bool debug;
bool defines_flag;
bool graph_flag;
bool xml_flag;
@@ -63,6 +63,7 @@ bool error_verbose = false;
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
@@ -257,6 +258,26 @@ static const int warnings_types[] =
ARGMATCH_VERIFY (warnings_args, warnings_types);
/*-----------------------.
| --feature's handling. |
`-----------------------*/
static const char * const feature_args[] =
{
"none",
"caret", "diagnostics-show-caret",
"all",
0
};
static const int feature_types[] =
{
feature_none,
feature_caret, feature_caret,
feature_all
};
ARGMATCH_VERIFY (feature_args, feature_types);
/*-------------------------------------------.
| Display the help message and exit STATUS. |
@@ -301,13 +322,13 @@ Operation modes:\n\
--print-datadir output directory containing skeletons and XSLT\n\
-y, --yacc emulate POSIX Yacc\n\
-W, --warnings[=CATEGORY] report the warnings falling in CATEGORY\n\
-f, --feature[=FEATURE] activate miscellaneous features\n\
\n\
"), stdout);
fputs (_("\
Parser:\n\
-L, --language=LANGUAGE specify the output programming language\n\
(this is an experimental feature)\n\
-S, --skeleton=FILE specify the skeleton to use\n\
-t, --debug instrument the parser for debugging\n\
--locations enable location support\n\
@@ -317,8 +338,8 @@ Parser:\n\
deprecated by '-Dapi.prefix=PREFIX'\n\
-l, --no-lines don't generate '#line' directives\n\
-k, --token-table include a table of token names\n\
\n\
"), stdout);
putc ('\n', stdout);
/* Keep -d and --defines separate so that ../build-aux/cross-options.pl
* won't assume that -d also takes an argument. */
@@ -334,8 +355,8 @@ Output:\n\
-g, --graph[=FILE] also output a graph of the automaton\n\
-x, --xml[=FILE] also output an XML report of the automaton\n\
(the XML schema is experimental)\n\
\n\
"), stdout);
putc ('\n', stdout);
fputs (_("\
Warning categories include:\n\
@@ -343,13 +364,14 @@ Warning categories include:\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\
\n\
"), stdout);
putc ('\n', stdout);
fputs (_("\
THINGS is a list of comma separated words that can include:\n\
@@ -360,8 +382,34 @@ THINGS is a list of comma separated words that can include:\n\
`all' include all the above information\n\
`none' disable the report\n\
"), stdout);
putc ('\n', stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
fputs (_("\
FEATURE is a list of comma separated words that can include:\n\
`caret' show errors with carets\n\
`all' all of the above\n\
`none' disable all of the above\n\
"), stdout);
putc ('\n', stdout);
printf (_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
printf (_("%s home page: <%s>.\n"), PACKAGE_NAME, PACKAGE_URL);
fputs (_("General help using GNU software: "
"<http://www.gnu.org/gethelp/>.\n"),
stdout);
/* Don't output this redundant message for English locales.
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_"))
/* 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/.
Otherwise, replace the entire URL with your translation team's
email address. */
fputs (_("Report translation bugs to "
"<http://translationproject.org/team/>.\n"), stdout);
fputs (_("For complete documentation, run: info bison.\n"), stdout);
}
exit (status);
@@ -451,6 +499,7 @@ static char const short_options[] =
"W::"
"b:"
"d"
"f::"
"e"
"g::"
"h"
@@ -503,6 +552,7 @@ static struct option const long_options[] =
/* Output. */
{ "defines", optional_argument, 0, 'd' },
{ "feature", optional_argument, 0, 'f' },
/* Operation modes. */
{ "fixed-output-files", no_argument, 0, 'y' },
@@ -537,7 +587,7 @@ command_line_location (void)
{
location res;
/* "<command line>" is used in GCC's messages about -D. */
boundary_set (&res.start, uniqstr_new ("<command line>"), optind, -1);
boundary_set (&res.start, uniqstr_new ("<command line>"), optind - 1, -1);
res.end = res.start;
return res;
}
@@ -595,6 +645,10 @@ getargs (int argc, char *argv[])
version ();
exit (EXIT_SUCCESS);
case 'f':
FLAGS_ARGMATCH (feature, optarg);
break;
case 'W':
FLAGS_ARGMATCH (warnings, optarg);
break;
@@ -646,7 +700,7 @@ getargs (int argc, char *argv[])
break;
case 't':
debug_flag = true;
debug = true;
break;
case 'v':
+13 -1
View File
@@ -34,7 +34,7 @@ extern int skeleton_prio;
/* for -I */
extern char const *include;
extern bool debug_flag; /* for -t */
extern bool debug; /* for -t */
extern bool defines_flag; /* for -d */
extern bool graph_flag; /* for -g */
extern bool xml_flag; /* for -x */
@@ -130,6 +130,18 @@ enum warnings
/** What warnings are issued. */
extern int warnings_flag;
/*-------------.
| --features. |
`-------------*/
enum feature
{
feature_none = 0, /**< No additional feature. */
feature_caret = 1 << 0, /**< Enhance the output of errors with carets. */
feature_all = ~0 /**< All above features. */
};
/** What additional features to use. */
extern int feature_flag;
/** Process the command line arguments.
*
+9 -4
View File
@@ -308,11 +308,16 @@ grammar_rules_useless_report (const char *message)
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)
warn_at (rules[r].location, "%s", message);
else
{
rule_print (&rules[r], stderr);
fflush (stderr);
warn_at (rules[r].location, "%s: ", message);
if (warnings_flag & warnings_other)
{
rule_print (&rules[r], stderr);
fflush (stderr);
}
}
}
}
+145 -3
View File
@@ -25,12 +25,14 @@
#include <quotearg.h>
#include "files.h"
#include "gram.h"
#include "graphviz.h"
#include "tables.h"
/* Return an unambiguous printable representation for NAME, suitable
for C strings. Use slot 2 since the user may use slots 0 and 1. */
static char const *
static char *
quote (char const *name)
{
return quotearg_n_style (2, c_quoting_style, name);
@@ -51,17 +53,21 @@ start_graph (FILE *fout)
"digraph %s\n"
"{\n",
quote (grammar_file));
fprintf (fout,
" node [fontname = courier, shape = box, colorscheme = paired6]\n"
" edge [fontname = courier]\n"
"\n");
}
void
output_node (int id, char const *label, FILE *fout)
{
fprintf (fout, " %d [label=%s]\n", id, quote (label));
fprintf (fout, " %d [label=\"%s\"]\n", id, label);
}
void
output_edge (int source, int destination, char const *label,
char const *style, FILE *fout)
char const *style, FILE *fout)
{
fprintf (fout, " %d -> %d [style=%s", source, destination, style);
if (label)
@@ -69,6 +75,142 @@ output_edge (int source, int destination, char const *label,
fputs ("]\n", fout);
}
char const *
escape (char const *name)
{
char *q = quote (name);
q[strlen (q) - 1] = '\0';
return q + 1;
}
static void
no_reduce_bitset_init (state const *s, bitset *no_reduce_set)
{
int n;
*no_reduce_set = bitset_create (ntokens, BITSET_FIXED);
bitset_zero (*no_reduce_set);
FOR_EACH_SHIFT (s->transitions, n)
bitset_set (*no_reduce_set, TRANSITION_SYMBOL (s->transitions, n));
for (n = 0; n < s->errs->num; ++n)
if (s->errs->symbols[n])
bitset_set (*no_reduce_set, s->errs->symbols[n]->number);
}
static void
conclude_red (struct obstack *out, int source, rule_number ruleno,
bool enabled, bool first, FILE *fout)
{
/* If no lookahead tokens were valid transitions, this reduction is
actually hidden, so cancel everything. */
if (first)
(void) obstack_finish0 (out);
else
{
char const *ed = enabled ? "" : "d";
char const *color = enabled ? ruleno ? "3" : "1" : "5";
/* First, build the edge's head. The name of reduction nodes is "nRm",
with n the source state and m the rule number. This is because we
don't want all the reductions bearing a same rule number to point to
the same state, since that is not the desired format. */
fprintf (fout, " %1$d -> \"%1$dR%2$d%3$s\" [",
source, ruleno, ed);
/* (The lookahead tokens have been added to the beginning of the
obstack, in the caller function.) */
if (! obstack_empty_p (out))
{
char *label = obstack_finish0 (out);
fprintf (fout, "label=\"[%s]\", ", label);
obstack_free (out, label);
}
/* Then, the edge's tail. */
fprintf (fout, "style=solid]\n");
/* Build the associated diamond representation of the target rule. */
fprintf (fout, " \"%dR%d%s\" [label=\"",
source, ruleno, ed);
if (ruleno)
fprintf (fout, "R%d", ruleno);
else
fprintf (fout, "Acc");
fprintf (fout, "\", fillcolor=%s, shape=diamond, style=filled]\n",
color);
}
}
static bool
print_token (struct obstack *out, bool first, char const *tok)
{
char const *q = escape (tok);
if (! first)
obstack_sgrow (out, ", ");
obstack_sgrow (out, q);
return false;
}
void
output_red (state const *s, reductions const *reds, FILE *fout)
{
bitset no_reduce_set;
int j;
int source = s->number;
/* Two obstacks are needed: one for the enabled reductions, and one
for the disabled reductions, because in the end we want two
separate edges, even though in most cases only one will actually
be printed. */
struct obstack dout;
struct obstack eout;
no_reduce_bitset_init (s, &no_reduce_set);
obstack_init (&dout);
obstack_init (&eout);
for (j = 0; j < reds->num; ++j)
{
bool defaulted = false;
bool firstd = true;
bool firste = true;
rule_number ruleno = reds->rules[j]->number;
rule *default_reduction = NULL;
if (yydefact[s->number] != 0)
default_reduction = &rules[yydefact[s->number] - 1];
/* Build the lookahead tokens lists, one for enabled transitions and one
for disabled transistions. */
if (default_reduction && default_reduction == reds->rules[j])
defaulted = true;
if (reds->lookahead_tokens)
{
int i;
for (i = 0; i < ntokens; i++)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (bitset_test (no_reduce_set, i))
firstd = print_token (&dout, firstd, symbols[i]->tag);
else
{
if (! defaulted)
firste = print_token (&eout, firste, symbols[i]->tag);
bitset_set (no_reduce_set, i);
}
}
}
/* Do the actual output. */
conclude_red (&dout, source, ruleno, false, firstd, fout);
conclude_red (&eout, source, ruleno, true, firste && !defaulted, fout);
}
obstack_free (&dout, 0);
obstack_free (&eout, 0);
bitset_free (no_reduce_set);
}
void
finish_graph (FILE *fout)
{
+13 -1
View File
@@ -22,6 +22,8 @@
#ifndef GRAPHVIZ_H_
# define GRAPHVIZ_H_
#include "state.h"
/// Begin a Dot graph.
/// \param fout output stream.
void start_graph (FILE *fout);
@@ -40,10 +42,20 @@ void output_node (int id, char const *label, FILE *fout);
/// \param style Dot style of the edge (e.g., "dotted" or "solid").
/// \param fout output stream.
void output_edge (int source, int destination, char const *label,
char const *style, FILE *fout);
char const *style, FILE *fout);
/// Output a reduction.
/// \param s current state
/// \param reds the set of reductions
/// \param fout output stream.
void output_red (state const *s, reductions const *reds, FILE *fout);
/// End a Dot graph.
/// \param fout output stream.
void finish_graph (FILE *fout);
/// Escape a lookahead token.
/// \param name the token.
char const *escape (char const *name);
#endif /* ! GRAPHVIZ_H_ */
+77 -2
View File
@@ -107,7 +107,7 @@ location_print (FILE *out, location loc)
quotearg_n_style (3, escape_quoting_style, loc.start.file));
if (0 <= loc.start.line)
{
res += fprintf(out, ":%d", loc.start.line);
res += fprintf (out, ":%d", loc.start.line);
if (0 <= loc.start.column)
res += fprintf (out, ".%d", loc.start.column);
}
@@ -118,7 +118,7 @@ location_print (FILE *out, location loc)
loc.end.file));
if (0 <= loc.end.line)
{
res += fprintf(out, ":%d", loc.end.line);
res += fprintf (out, ":%d", loc.end.line);
if (0 <= end_col)
res += fprintf (out, ".%d", end_col);
}
@@ -138,6 +138,81 @@ location_print (FILE *out, location loc)
return res;
}
/* Persistant data used by location_caret to avoid reopening and rereading the
same file all over for each error. */
struct caret_info
{
FILE *source;
size_t line;
size_t offset;
};
static struct caret_info caret_info = { NULL, 1, 0 };
void
cleanup_caret ()
{
if (caret_info.source)
fclose (caret_info.source);
}
void
location_caret (FILE *out, location loc)
{
/* FIXME: find a way to support multifile locations, and only open once each
file. That would make the procedure future-proof. */
if (! (caret_info.source
|| (caret_info.source = fopen (loc.start.file, "r")))
|| loc.start.column == -1 || loc.start.line == -1)
return;
/* If the line we want to quote is seekable (the same line as the previous
location), just seek it. If it was before, we lost track of it, so
return to the start of file. */
if (caret_info.line <= loc.start.line)
fseek (caret_info.source, caret_info.offset, SEEK_SET);
else
{
caret_info.line = 1;
caret_info.offset = 0;
fseek (caret_info.source, caret_info.offset, SEEK_SET);
}
/* Advance to the line's position, keeping track of the offset. */
while (caret_info.line < loc.start.line)
caret_info.line += fgetc (caret_info.source) == '\n';
caret_info.offset = ftell (caret_info.source);
/* Read the actual line. Don't update the offset, so that we keep a pointer
to the start of the line. */
{
char *buf = NULL;
size_t size = 0;
ssize_t len = getline (&buf, &size, caret_info.source);
if (0 < len)
{
/* The caret of a multiline location ends with the first line. */
int end = loc.start.line != loc.end.line ? len : loc.end.column;
/* Quote the file, indent by a single column. */
fputc (' ', out);
fwrite (buf, 1, len, out);
/* Print the caret, with the same indent as above. */
fprintf (out, " %*s", loc.start.column - 1, "");
{
int i = loc.start.column;
do
fputc ('^', out);
while (++i < end);
}
fputc ('\n', out);
}
free (buf);
}
}
void
boundary_set_from_string (boundary *bound, char *loc_str)
{
+8 -1
View File
@@ -88,7 +88,7 @@ typedef struct
} location;
#define YYLTYPE location
#define GRAM_LTYPE location
#define EMPTY_LOCATION_INIT {{NULL, 0, 0}, {NULL, 0, 0}}
extern location const empty_location;
@@ -102,6 +102,13 @@ void location_compute (location *loc,
characters. */
unsigned location_print (FILE *out, location loc);
/* Free any allocated ressources and close any open file handles that are
left-over by the usage of location_caret. */
void cleanup_caret (void);
/* Output to OUT the line and caret corresponding to location LOC. */
void location_caret (FILE *out, location loc);
/* Return -1, 0, 1, depending whether a is before, equal, or
after b. */
static inline int
+2
View File
@@ -216,5 +216,7 @@ main (int argc, char *argv[])
timevar_stop (TV_TOTAL);
timevar_print (stderr);
cleanup_caret ();
return complaint_issued ? EXIT_FAILURE : EXIT_SUCCESS;
}
+102 -79
View File
@@ -177,10 +177,10 @@ static void
muscle_syncline_grow (char const *key, location loc)
{
char *extension = NULL;
obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, "]])[");
obstack_printf (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line);
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);
muscle_grow (key, extension, "");
@@ -205,11 +205,11 @@ void muscle_pair_list_grow (const char *muscle,
const char *a1, const char *a2)
{
char *pair;
obstack_sgrow (&muscle_obstack, "[[[");
MUSCLE_OBSTACK_SGROW (&muscle_obstack, a1);
obstack_sgrow (&muscle_obstack, "]], [[");
MUSCLE_OBSTACK_SGROW (&muscle_obstack, a2);
obstack_sgrow (&muscle_obstack, "]]]");
obstack_sgrow (&muscle_obstack, "[");
obstack_quote (&muscle_obstack, a1);
obstack_sgrow (&muscle_obstack, ", ");
obstack_quote (&muscle_obstack, a2);
obstack_sgrow (&muscle_obstack, "]");
obstack_1grow (&muscle_obstack, 0);
pair = obstack_finish (&muscle_obstack);
muscle_grow (muscle, pair, ",\n");
@@ -259,53 +259,61 @@ muscle_find (char const *key)
}
void
/* In the format `file_name:line.column', append BOUND to MUSCLE. Use
digraphs for special characters in the file name. */
static void
muscle_boundary_grow (char const *key, boundary bound)
{
char *extension;
MUSCLE_OBSTACK_SGROW (&muscle_obstack, bound.file);
obstack_1grow (&muscle_obstack, ':');
obstack_fgrow1 (&muscle_obstack, "%d", bound.line);
obstack_1grow (&muscle_obstack, '.');
obstack_fgrow1 (&muscle_obstack, "%d", bound.column);
obstack_1grow (&muscle_obstack, '\0');
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);
muscle_grow (key, extension, "");
obstack_free (&muscle_obstack, extension);
}
void
/* In the format `[[file_name:line.column]], [[file_name:line.column]]',
append LOC to MUSCLE. Use digraphs for special characters in each
file name. */
static void
muscle_location_grow (char const *key, location loc)
{
muscle_grow (key, "[[", "");
muscle_boundary_grow (key, loc.start);
muscle_grow (key, "]], [[", "");
muscle_grow (key, "", ", ");
muscle_boundary_grow (key, loc.end);
muscle_grow (key, "]]", "");
}
#define MUSCLE_COMMON_DECODE(Value) \
case '$': \
aver (*++(Value) == ']'); \
aver (*++(Value) == '['); \
obstack_sgrow (&muscle_obstack, "$"); \
break; \
case '@': \
switch (*++(Value)) \
{ \
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
default: aver (false); break; \
} \
break; \
default: \
obstack_1grow (&muscle_obstack, *(Value)); \
#define COMMON_DECODE(Value) \
case '$': \
aver (*++(Value) == ']'); \
aver (*++(Value) == '['); \
obstack_sgrow (&muscle_obstack, "$"); \
break; \
case '@': \
switch (*++(Value)) \
{ \
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
default: aver (false); break; \
} \
break; \
default: \
obstack_1grow (&muscle_obstack, *(Value)); \
break;
/* Reverse of MUSCLE_OBSTACK_SGROW. */
/* Reverse of obstack_escape. */
static char *
muscle_string_decode (char const *key)
string_decode (char const *key)
{
char const *value;
char *value_decoded;
@@ -317,7 +325,7 @@ muscle_string_decode (char const *key)
do {
switch (*value)
{
MUSCLE_COMMON_DECODE (value)
COMMON_DECODE (value)
case '[':
case ']':
aver (false);
@@ -332,7 +340,7 @@ muscle_string_decode (char const *key)
/* Reverse of muscle_location_grow. */
static location
muscle_location_decode (char const *key)
location_decode (char const *key)
{
location loc;
char const *value = muscle_find_const (key);
@@ -342,7 +350,7 @@ muscle_location_decode (char const *key)
while (*++value)
switch (*value)
{
MUSCLE_COMMON_DECODE (value)
COMMON_DECODE (value)
case '[':
aver (false);
break;
@@ -388,47 +396,61 @@ muscle_user_name_list_grow (char const *key, char const *user_name,
muscle_grow (key, "]]", "");
}
/** If the \a variable name is obsolete, return the name to use,
* otherwise \a variable. */
static
char const *
muscle_percent_variable_update (char const *variable)
{
typedef struct
{
const char *obsolete;
const char *updated;
} conversion_type;
const conversion_type conversion[] =
{
{ "api.push_pull", "api.push-pull", },
{ "location_type", "api.location.type", },
{ "lr.keep_unreachable_states", "lr.keep-unreachable-states", },
};
char const *res = variable;
int i;
for (i = 0; i < ARRAY_CARDINALITY (conversion); ++i)
if (STREQ (conversion[i].obsolete, variable))
{
res = conversion[i].updated;
break;
}
return res;
}
void
muscle_percent_define_insert (char const *variable, location variable_loc,
muscle_percent_define_insert (char const *var, location variable_loc,
char const *value,
muscle_percent_define_how how)
{
char *variable_tr = NULL;
char const *name;
char const *loc_name;
char const *syncline_name;
char const *how_name;
/* Permit certain names with underscores for backward compatibility. */
if (0 == strcmp (variable, "api.push_pull")
|| 0 == strcmp (variable, "lr.keep_unreachable_states"))
{
variable_tr = strdup (variable);
tr (variable_tr, '_', '-');
variable = variable_tr;
}
name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
syncline_name =
/* Backward compatibility. */
char const *variable = muscle_percent_variable_update (var);
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, ")");
how_name = UNIQSTR_CONCAT ("percent_define_how(", variable, ")");
char const *how_name = UNIQSTR_CONCAT ("percent_define_how(", variable, ")");
/* Command-line options are processed before the grammar file. */
if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
&& muscle_find_const (name))
{
unsigned i = 0;
muscle_percent_define_how how_old =
atoi (muscle_find_const (how_name));
if (how_old == MUSCLE_PERCENT_DEFINE_F)
{
free (variable_tr);
return;
}
complain_at (variable_loc, _("%%define variable %s redefined"),
quote (variable));
complain_at (muscle_percent_define_get_loc (variable),
_("previous definition"));
return;
complain_at_indent (variable_loc, &i,
_("%%define variable %s redefined"), quote (variable));
i += SUB_INDENT;
complain_at_indent (muscle_percent_define_get_loc (variable), &i,
_("previous definition"));
}
MUSCLE_INSERT_STRING (name, value);
@@ -439,8 +461,6 @@ muscle_percent_define_insert (char const *variable, location variable_loc,
muscle_user_name_list_grow ("percent_define_user_variables", variable,
variable_loc);
MUSCLE_INSERT_INT (how_name, how);
free (variable_tr);
}
char *
@@ -455,7 +475,7 @@ muscle_percent_define_get (char const *variable)
variable, ")");
muscle_insert (usage_name, "");
value = muscle_string_decode (name);
value = string_decode (name);
if (!value)
value = xstrdup ("");
return value;
@@ -469,7 +489,7 @@ muscle_percent_define_get_loc (char const *variable)
if (!muscle_find_const (loc_name))
fatal(_("%s: undefined %%define variable %s"),
"muscle_percent_define_get_loc", quote (variable));
return muscle_location_decode (loc_name);
return location_decode (loc_name);
}
char const *
@@ -573,7 +593,7 @@ muscle_percent_define_check_values (char const * const *values)
name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
value = muscle_string_decode (name);
value = string_decode (name);
if (value)
{
for (++values; *values; ++values)
@@ -583,12 +603,15 @@ muscle_percent_define_check_values (char const * const *values)
}
if (!*values)
{
unsigned i = 0;
location loc = muscle_percent_define_get_loc (*variablep);
complain_at(loc,
_("invalid value for %%define variable %s: %s"),
quote (*variablep), quote_n (1, value));
complain_at_indent (loc, &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 (loc, _("accepted value: %s"), quote (*values));
complain_at_indent (loc, &i, _("accepted value: %s"),
quote (*values));
}
else
{
+37 -60
View File
@@ -35,62 +35,47 @@ void muscle_free (void);
/* An obstack dedicated to receive muscle keys and values. */
extern struct obstack muscle_obstack;
#define MUSCLE_INSERT_BOOL(Key, Value) \
do { \
int v = Value; \
MUSCLE_INSERT_INT (Key, v); \
} while(0)
#define MUSCLE_INSERT_BOOL(Key, Value) \
do { \
int v = Value; \
MUSCLE_INSERT_INT (Key, v); \
} while (0)
#define MUSCLE_INSERT_INT(Key, Value) \
do { \
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#define MUSCLE_INSERT_INT(Key, Value) \
do { \
obstack_printf (&muscle_obstack, "%d", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
do { \
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#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)
#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)
#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)
#define MUSCLE_INSERT_STRING(Key, Value) \
do { \
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#define MUSCLE_INSERT_STRING(Key, Value) \
do { \
obstack_escape (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
do { \
char const *p; \
for (p = Value; *p; p++) \
switch (*p) \
{ \
case '$': obstack_sgrow (Obstack, "$]["); break; \
case '@': obstack_sgrow (Obstack, "@@" ); break; \
case '[': obstack_sgrow (Obstack, "@{" ); break; \
case ']': obstack_sgrow (Obstack, "@}" ); break; \
default: obstack_1grow (Obstack, *p); break; \
} \
} while(0)
#define MUSCLE_INSERT_C_STRING(Key, Value) \
do { \
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
quotearg_style (c_quoting_style, \
Value)); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#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)); \
} while (0)
/* Append VALUE to the current value of KEY. If KEY did not already
exist, create it. Use MUSCLE_OBSTACK. De-allocate the previously
@@ -110,15 +95,7 @@ void muscle_code_grow (const char *key, const char *value, location loc);
muscle values are output *double* quoted, one needs to strip the first level
of quotes to reach the list itself. */
void muscle_pair_list_grow (const char *muscle,
const char *a1, const char *a2);
/* In the format `[[file_name:line.column]], [[file_name:line.column]]', append
LOC to MUSCLE. Use digraphs for special characters in each file name. */
void muscle_location_grow (char const *key, location loc);
/* In the format `file_name:line.column', append BOUND to MUSCLE. Use digraphs
for special characters in the file name. */
void muscle_boundary_grow (char const *key, boundary bound);
const char *a1, const char *a2);
/* Grow KEY for the occurrence of the name USER_NAME at LOC appropriately for
use with b4_check_user_names in ../data/bison.m4. USER_NAME is not escaped
+31 -20
View File
@@ -41,8 +41,6 @@
#include "symtab.h"
#include "tables.h"
# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
static struct obstack format_obstack;
@@ -70,7 +68,7 @@ Name (char const *name, \
int i; \
int j = 1; \
\
obstack_fgrow1 (&format_obstack, "%6d", first); \
obstack_printf (&format_obstack, "%6d", first); \
for (i = begin; i < end; ++i) \
{ \
obstack_1grow (&format_obstack, ','); \
@@ -81,7 +79,7 @@ Name (char const *name, \
} \
else \
++j; \
obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
obstack_printf (&format_obstack, "%6d", table_data[i]); \
if (table_data[i] < min) \
min = table_data[i]; \
if (max < table_data[i]) \
@@ -93,10 +91,10 @@ Name (char const *name, \
lmin = min; \
lmax = max; \
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
obstack_fgrow1 (&format_obstack, "%s_min", name); \
obstack_printf (&format_obstack, "%s_min", name); \
obstack_1grow (&format_obstack, 0); \
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
obstack_fgrow1 (&format_obstack, "%s_max", name); \
obstack_printf (&format_obstack, "%s_max", name); \
obstack_1grow (&format_obstack, 0); \
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
}
@@ -110,29 +108,39 @@ GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_item_number_table, item_number)
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
/*--------------------------------------------------------------------.
| Print to OUT a representation of STRING escaped both for C and M4. |
`--------------------------------------------------------------------*/
/*----------------------------------------------------------------.
| Print to OUT a representation of CP quoted and escaped for M4. |
`----------------------------------------------------------------*/
static void
escaped_output (FILE *out, char const *string)
quoted_output (FILE *out, char const *cp)
{
char const *p;
fprintf (out, "[[");
for (p = quotearg_style (c_quoting_style, string); *p; p++)
switch (*p)
for (; *cp; cp++)
switch (*cp)
{
case '$': fputs ("$][", out); break;
case '@': fputs ("@@", out); break;
case '[': fputs ("@{", out); break;
case ']': fputs ("@}", out); break;
default: fputc (*p, out); break;
default: fputc (*cp, out); break;
}
fprintf (out, "]]");
}
/*----------------------------------------------------------------.
| Print to OUT a representation of STRING quoted and escaped both |
| for C and M4. |
`----------------------------------------------------------------*/
static void
string_output (FILE *out, char const *string)
{
quoted_output (out, quotearg_style (c_quoting_style, string));
}
/*------------------------------------------------------------------.
| Prepare the muscles related to the symbols: translate, tname, and |
@@ -175,7 +183,7 @@ prepare_symbols (void)
if (i)
obstack_1grow (&format_obstack, ' ');
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
obstack_escape (&format_obstack, cp);
free (cp);
obstack_1grow (&format_obstack, ',');
j += width;
@@ -299,7 +307,7 @@ user_actions_output (FILE *out)
{
fprintf (out, "b4_case(%d, [b4_syncline(%d, ", r + 1,
rules[r].action_location.start.line);
escaped_output (out, rules[r].action_location.start.file);
string_output (out, rules[r].action_location.start.file);
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
}
fputs ("])\n\n", out);
@@ -405,12 +413,15 @@ symbol_code_props_output (FILE *out, char const *what,
code, optional typename. */
fprintf (out, "%s[", sep);
sep = ",\n";
escaped_output (out, loc.start.file);
string_output (out, loc.start.file);
fprintf (out, ", %d, ", loc.start.line);
escaped_output (out, sym->tag);
quoted_output (out, sym->tag);
fprintf (out, ", %d, [[%s]]", sym->number, code);
if (sym->type_name)
fprintf (out, ", [[%s]]", sym->type_name);
{
fputs (", ", out);
quoted_output (out, sym->type_name);
}
fputc (']', out);
}
}
@@ -615,7 +626,7 @@ prepare (void)
use_push_for_pull_flag = true;
/* Flags. */
MUSCLE_INSERT_BOOL ("debug_flag", debug_flag);
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);
+639 -546
View File
File diff suppressed because it is too large Load Diff
+36 -30
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.5.1.19-ced26-dirty. */
/* A Bison parser, made by GNU Bison 2.6.5.63-3ada. */
/* Bison interface for Yacc-like parsers in C
@@ -30,22 +30,30 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef GRAM__________SRC_PARSE_GRAM_H
# define GRAM__________SRC_PARSE_GRAM_H
#ifndef YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED
# define YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
#ifndef GRAM_DEBUG
# if defined YYDEBUG
# if YYDEBUG
# define GRAM_DEBUG 1
# else
# define GRAM_DEBUG 0
# endif
# else /* ! defined YYDEBUG */
# define GRAM_DEBUG 1
# endif /* ! defined YYDEBUG */
#endif /* ! defined GRAM_DEBUG */
#if GRAM_DEBUG
extern int gram_debug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
#ifndef GRAM_TOKENTYPE
# define GRAM_TOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
enum gram_tokentype {
GRAM_EOF = 0,
STRING = 258,
INT = 259,
@@ -164,12 +172,11 @@ extern int gram_debug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED
typedef union GRAM_STYPE
{
/* Line 2063 of yacc.c */
#line 114 "parse-gram.y"
/* Line 2042 of yacc.c */
#line 115 "parse-gram.y"
symbol *symbol;
symbol_list *list;
@@ -182,28 +189,28 @@ typedef union YYSTYPE
named_ref *named_ref;
/* Line 2063 of yacc.c */
#line 188 "parse-gram.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
/* Line 2042 of yacc.c */
#line 194 "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
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
#if ! defined GRAM_LTYPE && ! defined GRAM_LTYPE_IS_DECLARED
typedef struct GRAM_LTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} YYLTYPE;
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
} 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);
@@ -218,5 +225,4 @@ int gram_parse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !GRAM__________SRC_PARSE_GRAM_H */
#endif /* !YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED */
+32 -19
View File
@@ -20,6 +20,7 @@
#include <config.h>
#include "system.h"
#include "c-ctype.h"
#include "complain.h"
#include "conflicts.h"
#include "files.h"
@@ -93,14 +94,14 @@ current_lhs(symbol *sym, location loc, named_ref *ref)
%}
%debug
%verbose
%defines
%locations
%pure-parser
%error-verbose
%define api.prefix "gram_"
%define api.pure
%define parse.lac full
%name-prefix="gram_"
%defines
%error-verbose
%expect 0
%locations
%verbose
%initial-action
{
@@ -251,7 +252,7 @@ prologue_declaration:
plain_code.code, @1);
code_scanner_last_string_free ();
}
| "%debug" { debug_flag = true; }
| "%debug" { debug = true; }
| "%define" variable content.opt
{
muscle_percent_define_insert ($2, @2, $3,
@@ -347,17 +348,27 @@ grammar_declaration:
}
| "%destructor" "{...}" generic_symlist
{
symbol_list *list;
for (list = $3; list; list = list->next)
symbol_list_destructor_set (list, $2, @2);
symbol_list_free ($3);
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_destructor_set (list, &code);
symbol_list_free ($3);
}
}
| "%printer" "{...}" generic_symlist
{
symbol_list *list;
for (list = $3; list; list = list->next)
symbol_list_printer_set (list, $2, @2);
symbol_list_free ($3);
code_props code;
code_props_symbol_action_init (&code, $2, @2);
code_props_translate_code (&code);
{
symbol_list *list;
for (list = $3; list; list = list->next)
symbol_list_printer_set (list, &code);
symbol_list_free ($3);
}
}
| "%default-prec"
{
@@ -724,11 +735,13 @@ add_param (char const *type, char *decl, location loc)
/* Strip the surrounding '{' and '}', and any blanks just inside
the braces. */
while (*--p == ' ' || *p == '\t')
continue;
--p;
while (c_isspace ((unsigned char) *p))
--p;
p[1] = '\0';
while (*++decl == ' ' || *decl == '\t')
continue;
++decl;
while (c_isspace ((unsigned char) *decl))
++decl;
if (! name_start)
complain_at (loc, _("missing identifier in parameter declaration"));
+1 -1
View File
@@ -370,7 +370,7 @@ static void
print_state (FILE *out, state *s)
{
fputs ("\n\n", out);
fprintf (out, _("state %d"), s->number);
fprintf (out, _("State %d"), s->number);
fputc ('\n', out);
print_core (out, s);
print_actions (out, s);
+55 -28
View File
@@ -39,11 +39,32 @@
| Construct the node labels. |
`----------------------------*/
/* Print the lhs of a rule in such a manner that there is no vertical
repetition, like in *.output files. */
static void
print_lhs (struct obstack *oout, rule *previous_rule, rule *r)
{
if (previous_rule && STREQ (previous_rule->lhs->tag, r->lhs->tag))
{
int i;
for (i = 0; i < strlen (r->lhs->tag); ++i)
obstack_1grow (oout, ' ');
obstack_1grow (oout, '|');
}
else
{
obstack_sgrow (oout, escape (r->lhs->tag));
obstack_1grow (oout, ':');
}
}
static void
print_core (struct obstack *oout, state *s)
{
size_t i;
item_number *sitems = s->items;
rule *previous_rule = NULL;
size_t i;
size_t snritems = s->nitems;
/* Output all the items of a state, not only its kernel. */
@@ -54,7 +75,8 @@ print_core (struct obstack *oout, state *s)
snritems = nitemset;
}
obstack_fgrow1 (oout, "%d", s->number);
obstack_printf (oout, _("State %d"), s->number);
obstack_sgrow (oout, "\\n\\l");
for (i = 0; i < snritems; i++)
{
item_number *sp;
@@ -64,43 +86,47 @@ print_core (struct obstack *oout, state *s)
sp1 = sp = ritem + sitems[i];
while (*sp >= 0)
sp++;
sp++;
r = item_number_as_rule_number (*sp);
obstack_fgrow1 (oout, "\n%s -> ", rules[r].lhs->tag);
obstack_printf (oout, "%3d ", r);
print_lhs (oout, previous_rule, &rules[r]);
previous_rule = &rules[r];
for (sp = rules[r].rhs; sp < sp1; sp++)
obstack_fgrow1 (oout, "%s ", symbols[*sp]->tag);
obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
obstack_1grow (oout, '.');
obstack_sgrow (oout, " .");
for (/* Nothing */; *sp >= 0; ++sp)
obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
/* Experimental feature: display the lookahead tokens. */
if (report_flag & report_lookahead_tokens
&& item_number_is_rule_number (*sp1))
{
/* Find the reduction we are handling. */
reductions *reds = s->reductions;
int redno = state_reduction_find (s, &rules[r]);
{
/* Find the reduction we are handling. */
reductions *reds = s->reductions;
int redno = state_reduction_find (s, &rules[r]);
/* Print them if there are. */
if (reds->lookahead_tokens && redno != -1)
{
bitset_iterator biter;
int k;
char const *sep = "";
obstack_sgrow (oout, "[");
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
{
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
sep = ", ";
}
obstack_sgrow (oout, "]");
}
}
/* Print them if there are. */
if (reds->lookahead_tokens && redno != -1)
{
bitset_iterator biter;
int k;
char const *sep = "";
obstack_sgrow (oout, " [");
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
{
obstack_sgrow (oout, sep);
obstack_sgrow (oout, escape (symbols[k]->tag));
sep = ", ";
}
obstack_1grow (oout, ']');
}
}
obstack_sgrow (oout, "\\l");
}
}
@@ -113,9 +139,8 @@ print_core (struct obstack *oout, state *s)
static void
print_actions (state const *s, FILE *fgraph)
{
int i;
transitions const *trans = s->transitions;
int i;
if (!trans->num && !s->reductions)
return;
@@ -139,6 +164,8 @@ print_actions (state const *s, FILE *fgraph)
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
style, fgraph);
}
/* Display reductions. */
output_red (s, s->reductions, fgraph);
}
+10 -6
View File
@@ -128,12 +128,16 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
aver (merge_function != NULL && merger_find == merger);
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
{
complain_at (declaration_loc,
_("result type clash on merge function %s: <%s> != <%s>"),
quote (merge_function->name), type, merge_function->type);
complain_at (merge_function->type_declaration_location,
_("previous declaration"));
}
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);
indent += SUB_INDENT;
complain_at_indent (merge_function->type_declaration_location, &indent,
_("previous declaration"));
}
merge_function->type = uniqstr_new (type);
merge_function->type_declaration_location = declaration_loc;
}
+2 -2
View File
@@ -51,9 +51,9 @@ 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 *named_ref);
named_ref *nref);
void grammar_current_rule_action_append (const char *action, location loc,
named_ref *named_ref);
named_ref *nref);
void reader (void);
void free_merger_functions (void);
+4 -1
View File
@@ -45,7 +45,10 @@ typedef struct code_props {
CODE_PROPS_SYMBOL_ACTION, CODE_PROPS_RULE_ACTION
} kind;
/** \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE. */
/**
* \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE.
* Memory is allocated in an obstack freed elsewhere.
*/
char const *code;
/** Undefined iff \c code_props::code is \c NULL. */
location location;
+95 -93
View File
@@ -46,6 +46,9 @@ YY_DECL;
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
static char *fetch_type_name (char *cp, char const **type_name,
location dollar_loc);
static void handle_action_dollar (symbol_list *rule, char *cp,
location dollar_loc);
static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
@@ -95,11 +98,15 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
int braces_level = 0;
/* Whether a semicolon is probably needed.
The heuristic is that a semicolon is not needed after '{', '}', ';',
or a C preprocessor directive, and that whitespaces and comments
do not affect this flag.
Note that '{' does not need a semicolon because of '{}'.
A semicolon may be needed before a cpp direcive, but don't bother. */
The heuristic is that a semicolon is not needed after '{', '}',
';', or a C preprocessor directive, and that whitespaces and
comments do not affect this flag. Note that '{' does not need a
semicolon because of '{}'. A semicolon may be needed before a
cpp directive, but don't bother.
While it is maintained in several start-conditions (factoring
opportunities), it is meaningful only for SC_RULE_ACTION. */
bool need_semicolon = false;
/* Whether in a C preprocessor directive. Don't use a start condition
@@ -157,7 +164,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
}
<SC_RULE_ACTION,SC_SYMBOL_ACTION>{
<SC_RULE_ACTION,SC_SYMBOL_ACTION>
{
"'" {
STRING_GROW;
BEGIN SC_CHARACTER;
@@ -176,42 +184,31 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
STRING_GROW;
BEGIN SC_LINE_COMMENT;
}
[$@] {
warn_at (*loc, _("stray '%s'"), yytext);
obstack_escape (&obstack_for_string, yytext);
need_semicolon = true;
}
[\[\]] {
obstack_escape (&obstack_for_string, yytext);
need_semicolon = true;
}
}
<SC_RULE_ACTION>
{
"$"("<"{tag}">")?{ref} {
ref_tail_fields = 0;
ref_tail_fields = NULL;
handle_action_dollar (self->rule, yytext, *loc);
if (ref_tail_fields) {
if (ref_tail_fields)
obstack_sgrow (&obstack_for_string, ref_tail_fields);
}
need_semicolon = true;
}
"@"{ref} {
ref_tail_fields = 0;
ref_tail_fields = NULL;
handle_action_at (self->rule, yytext, *loc);
if (ref_tail_fields) {
if (ref_tail_fields)
obstack_sgrow (&obstack_for_string, ref_tail_fields);
}
need_semicolon = true;
}
"$" {
warn_at (*loc, _("stray '$'"));
obstack_sgrow (&obstack_for_string, "$][");
need_semicolon = true;
}
"@" {
warn_at (*loc, _("stray '@'"));
obstack_sgrow (&obstack_for_string, "@@");
need_semicolon = true;
}
"[" {
obstack_sgrow (&obstack_for_string, "@{");
need_semicolon = true;
}
"]" {
obstack_sgrow (&obstack_for_string, "@}");
need_semicolon = true;
}
@@ -223,12 +220,16 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
/* As an undocumented Bison extension, append ';' before the last
brace in braced code, so that the user code can omit trailing
';'. But do not append ';' if emulating Yacc, since Yacc does
not append one. */
not append one. This is deprecated since release 2.4.1. */
if (outer_brace && !yacc_flag && language_prio == default_prio
&& skeleton_prio == default_prio && need_semicolon && ! in_cpp)
{
warn_at (*loc, _("a ';' might be needed at the end of action code"));
warn_at (*loc, _("future versions of Bison will not add the ';'"));
unsigned int indent = 0;
warn_at_indent (*loc, &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 ';'"));
obstack_1grow (&obstack_for_string, ';');
}
@@ -263,8 +264,12 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
<SC_SYMBOL_ACTION>
{
"$$" {
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar[");
"$"("<"{tag}">")?"$" {
const char *type_name = NULL;
fetch_type_name (yytext + 1, &type_name, *loc)[-1] = 0;
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar(");
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
self->is_value_used = true;
}
"@$" {
@@ -274,30 +279,18 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
}
/*-----------------------------------------.
| Escape M4 quoting characters in C code. |
`-----------------------------------------*/
<*>
{
\$ obstack_sgrow (&obstack_for_string, "$][");
\@ obstack_sgrow (&obstack_for_string, "@@");
\[ obstack_sgrow (&obstack_for_string, "@{");
\] obstack_sgrow (&obstack_for_string, "@}");
/* Escape M4 quoting characters in C code. */
[$@\[\]] obstack_escape (&obstack_for_string, yytext);
/* By default, grow the string obstack with the input. */
.|\n STRING_GROW;
/* End of processing. */
<<EOF>> STRING_FINISH; return last_string;
}
/*-----------------------------------------------------.
| By default, grow the string obstack with the input. |
`-----------------------------------------------------*/
<*>.|\n STRING_GROW;
/* End of processing. */
<*><<EOF>> {
STRING_FINISH;
return last_string;
}
%%
static inline bool
@@ -345,7 +338,7 @@ typedef struct
not visible from current midrule. */
#define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2)
static variant *variant_table = 0;
static variant *variant_table = NULL;
static unsigned variant_table_size = 0;
static unsigned variant_count = 0;
@@ -367,7 +360,7 @@ static void
variant_table_free (void)
{
free (variant_table);
variant_table = 0;
variant_table = NULL;
variant_table_size = variant_count = 0;
}
@@ -410,7 +403,7 @@ variant_add (uniqstr id, location id_loc, unsigned symbol_index,
}
static const char *
get_at_spec(unsigned symbol_index)
get_at_spec (unsigned symbol_index)
{
static char at_buf[20];
if (symbol_index == 0)
@@ -454,30 +447,30 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
/* Create the explanation message. */
obstack_init (&msg_buf);
obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at);
obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at);
if (contains_dot_or_dash (id))
obstack_fgrow1 (&msg_buf, "[%s]", id);
obstack_printf (&msg_buf, "[%s]", id);
else
obstack_sgrow (&msg_buf, id);
obstack_sgrow (&msg_buf, tail);
if (var->err & VARIANT_HIDDEN)
{
obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at);
obstack_printf (&msg_buf, _(", hiding %c"), dollar_or_at);
if (contains_dot_or_dash (var->id))
obstack_fgrow1 (&msg_buf, "[%s]", var->id);
obstack_printf (&msg_buf, "[%s]", var->id);
else
obstack_sgrow (&msg_buf, var->id);
obstack_sgrow (&msg_buf, tail);
}
obstack_fgrow1 (&msg_buf, _(" at %s"), at_spec);
obstack_printf (&msg_buf, _(" at %s"), at_spec);
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
{
const char *format =
_(", cannot be accessed from mid-rule action at $%d");
obstack_fgrow1 (&msg_buf, format, midrule_rhs_index);
obstack_printf (&msg_buf, format, midrule_rhs_index);
}
obstack_1grow (&msg_buf, '\0');
@@ -500,9 +493,6 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
points to LHS ($$) of the current rule or midrule. */
#define LHS_REF (INT_MIN + 1)
/* Sub-messages indent. */
#define SUB_INDENT (4)
/* Parse named or positional reference. In case of positional
references, can return negative values for $-n "deep" stack
accesses. */
@@ -688,6 +678,31 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
int max_left_semantic_context = 0;
/* If CP points to a typename (i.e., <.*?>), set TYPE_NAME to its
beginning (i.e., after the opening "<", and return the pointer
immediately after it. */
static
char *
fetch_type_name (char *cp, char const **type_name,
location dollar_loc)
{
if (*cp == '<')
{
*type_name = ++cp;
while (*cp != '>')
++cp;
/* The '>' symbol will be later replaced by '\0'. Original
'text' is needed for error messages. */
++cp;
if (untyped_var_seen)
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
tag_seen = true;
}
return cp;
}
/*------------------------------------------------------------------.
| TEXT is pointing to a wannabee semantic value (i.e., a '$'). |
| |
@@ -701,7 +716,6 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
{
char const *type_name = NULL;
char *cp = text + 1;
char *gt_ptr = 0;
symbol_list *effective_rule;
int effective_rule_length;
int n;
@@ -718,26 +732,14 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
}
/* Get the type name if explicit. */
if (*cp == '<')
{
type_name = ++cp;
while (*cp != '>')
++cp;
/* The '>' symbol will be later replaced by '\0'. Original
'text' is needed for error messages. */
gt_ptr = cp;
++cp;
if (untyped_var_seen)
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
tag_seen = true;
}
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, '$');
if (gt_ptr)
*gt_ptr = '\0';
/* End type_name. */
if (type_name)
cp[-1] = '\0';
switch (n)
{
@@ -764,11 +766,11 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
}
else
untyped_var_seen = true;
type_name = "";
}
obstack_fgrow1 (&obstack_for_string,
"]b4_lhs_value([%s])[", type_name);
obstack_sgrow (&obstack_for_string, "]b4_lhs_value(");
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
rule->action_props.is_value_used = true;
break;
@@ -785,12 +787,12 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
cp, quote (effective_rule->content.sym->tag));
else
untyped_var_seen = true;
type_name = "";
}
obstack_fgrow3 (&obstack_for_string,
"]b4_rhs_value(%d, %d, [%s])[",
effective_rule_length, n, type_name);
obstack_printf (&obstack_for_string,
"]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;
@@ -826,7 +828,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
locations_flag = 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:
@@ -837,7 +839,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
break;
default:
obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
obstack_printf (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
effective_rule_length, n);
break;
}
+1 -1
View File
@@ -32,7 +32,7 @@ void gram_scanner_last_string_free (void);
extern FILE *gram_out;
extern int gram_lineno;
# define GRAM_LEX_DECL int gram_lex (YYSTYPE *val, location *loc)
# define GRAM_LEX_DECL int gram_lex (GRAM_STYPE *val, location *loc)
GRAM_LEX_DECL;
#endif /* !SCAN_GRAM_H_ */
+31 -21
View File
@@ -36,7 +36,7 @@
#include "reader.h"
#include "uniqstr.h"
#include <ctype.h>
#include <c-ctype.h>
#include <mbswidth.h>
#include <quote.h>
@@ -103,9 +103,9 @@ static void unexpected_newline (boundary, char const *);
/* Bracketed identifiers support. */
%x SC_BRACKETED_ID SC_RETURN_BRACKETED_ID
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
notletter [^.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]{-}[%\{]
id {letter}({letter}|[-0-9])*
directive %{id}
int [0-9]+
/* POSIX says that a tag must be both an id and a C union member, but
@@ -148,7 +148,7 @@ splice (\\[ \f\t\v]*\n)*
/* Comments and white space. */
"," warn_at (*loc, _("stray ',' treated as white space"));
[ \f\n\t\v] |
"//".* ;
"//".* continue;
"/*" {
token_start = loc->start;
context_state = YY_START;
@@ -157,7 +157,7 @@ splice (\\[ \f\t\v]*\n)*
/* #line directives are not documented, and may be withdrawn or
modified in future versions of Bison. */
^"#line "{int}" \"".*"\"\n" {
^"#line "{int}(" \"".*"\"")?"\n" {
handle_syncline (yytext + sizeof "#line " - 1, *loc);
}
}
@@ -218,7 +218,7 @@ splice (\\[ \f\t\v]*\n)*
"%verbose" return PERCENT_VERBOSE;
"%yacc" return PERCENT_YACC;
{directive} {
"%"{id}|"%"{notletter}([[:graph:]])+ {
complain_at (*loc, _("invalid directive: %s"), quote (yytext));
}
@@ -290,8 +290,10 @@ splice (\\[ \f\t\v]*\n)*
BEGIN SC_BRACKETED_ID;
}
. {
complain_at (*loc, _("invalid character: %s"), quote (yytext));
[^\[%A-Za-z0-9_<>{}\"\'*;|=/, \f\n\t\v]+|. {
complain_at (*loc, "%s: %s",
ngettext ("invalid character", "invalid characters", yyleng),
quote_mem (yytext, yyleng));
}
<<EOF>> {
@@ -373,10 +375,14 @@ splice (\\[ \f\t\v]*\n)*
else
complain_at (*loc, _("an identifier expected"));
}
. {
complain_at (*loc, _("invalid character in bracketed name: %s"),
quote (yytext));
[^\].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));
}
<<EOF>> {
BEGIN bracketed_id_context_state;
unexpected_eof (bracketed_id_start, "]");
@@ -403,7 +409,7 @@ splice (\\[ \f\t\v]*\n)*
<SC_YACC_COMMENT>
{
"*/" BEGIN context_state;
.|\n ;
.|\n continue;
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
}
@@ -560,7 +566,7 @@ splice (\\[ \f\t\v]*\n)*
\\(.|\n) {
char const *p = yytext + 1;
/* Quote only if escaping won't make the character visible. */
if (isspace ((unsigned char) *p) && isprint ((unsigned char) *p))
if (c_isspace ((unsigned char) *p) && c_isprint ((unsigned char) *p))
p = quote (p);
else
p = quotearg_style_mem (escape_quoting_style, p, 1);
@@ -839,23 +845,27 @@ convert_ucn_to_byte (char const *ucn)
}
/*----------------------------------------------------------------.
| Handle '#line INT "FILE"'. ARGS has already skipped '#line '. |
`----------------------------------------------------------------*/
/*---------------------------------------------------------------------.
| Handle '#line INT( "FILE")?\n'. ARGS has already skipped '#line '. |
`---------------------------------------------------------------------*/
static void
handle_syncline (char *args, location loc)
{
char *after_num;
unsigned long int lineno = strtoul (args, &after_num, 10);
char *file = mbschr (after_num, '"') + 1;
*mbschr (file, '"') = '\0';
char *file;
unsigned long int lineno = strtoul (args, &file, 10);
if (INT_MAX <= lineno)
{
warn_at (loc, _("line number overflow"));
lineno = INT_MAX;
}
current_file = uniqstr_new (file);
file = mbschr (file, '"');
if (file)
{
*mbschr (file + 1, '"') = '\0';
current_file = uniqstr_new (file + 1);
}
boundary_set (&scanner_cursor, current_file, lineno, 1);
}
+20 -18
View File
@@ -72,8 +72,8 @@ static void fail_for_invalid_at (char const *at);
"@@" fputc ('@', yyout);
"@{" fputc ('[', yyout);
"@}" fputc (']', yyout);
"@`" /* Empty. Used by b4_cat in ../data/bison.m4. */
@\n /* Likewise. */
"@`" continue; /* Used by b4_cat in ../data/bison.m4. */
@\n continue;
"@oline@" fprintf (yyout, "%d", out_lineno + 1);
"@ofile@" QPUTS (outname);
@@ -87,9 +87,9 @@ static void fail_for_invalid_at (char const *at);
}
/* This pattern must not match more than the previous @ patterns. */
@[^@{}`(\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)
@@ -100,15 +100,15 @@ static void fail_for_invalid_at (char const *at);
return EOF;
}
<SC_AT_DIRECTIVE_ARGS>{
[^@]+ { STRING_GROW; }
<SC_AT_DIRECTIVE_ARGS>
{
[^@]+ STRING_GROW;
"@@" { obstack_1grow (&obstack_for_string, '@'); }
"@{" { obstack_1grow (&obstack_for_string, '['); }
"@}" { obstack_1grow (&obstack_for_string, ']'); }
"@`" /* Empty. Useful for starting an argument
that begins with whitespace. */
@\n /* Empty. */
"@@" obstack_1grow (&obstack_for_string, '@');
"@{" obstack_1grow (&obstack_for_string, '[');
"@}" obstack_1grow (&obstack_for_string, ']');
"@`" continue; /* For starting an argument that begins with whitespace. */
@\n continue;
@[,)] {
if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX)
@@ -131,15 +131,17 @@ static void fail_for_invalid_at (char const *at);
}
}
@.? { fail_for_invalid_at (yytext); }
@.? fail_for_invalid_at (yytext);
}
<SC_AT_DIRECTIVE_SKIP_WS>{
[ \t\r\n]
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
<SC_AT_DIRECTIVE_SKIP_WS>
{
[ \t\r\n] continue;
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
}
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>{
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>
{
<<EOF>> {
fatal (_("unclosed %s directive in skeleton"), at_directive_argv[0]);
}
+10 -16
View File
@@ -223,49 +223,43 @@ symbol_list_null (symbol_list *node)
}
void
symbol_list_destructor_set (symbol_list *node, char const *code, location loc)
symbol_list_destructor_set (symbol_list *node, code_props const *destructor)
{
code_props destructor;
code_props_symbol_action_init (&destructor, code, loc);
code_props_translate_code (&destructor);
switch (node->content_type)
{
case SYMLIST_SYMBOL:
symbol_destructor_set (node->content.sym, &destructor);
symbol_destructor_set (node->content.sym, destructor);
break;
case SYMLIST_TYPE:
semantic_type_destructor_set (
semantic_type_get (node->content.type_name), &destructor);
semantic_type_get (node->content.type_name), destructor);
break;
case SYMLIST_DEFAULT_TAGGED:
default_tagged_destructor_set (&destructor);
default_tagged_destructor_set (destructor);
break;
case SYMLIST_DEFAULT_TAGLESS:
default_tagless_destructor_set (&destructor);
default_tagless_destructor_set (destructor);
break;
}
}
void
symbol_list_printer_set (symbol_list *node, char const *code, location loc)
symbol_list_printer_set (symbol_list *node, code_props const *printer)
{
code_props printer;
code_props_symbol_action_init (&printer, code, loc);
code_props_translate_code (&printer);
switch (node->content_type)
{
case SYMLIST_SYMBOL:
symbol_printer_set (node->content.sym, &printer);
symbol_printer_set (node->content.sym, printer);
break;
case SYMLIST_TYPE:
semantic_type_printer_set (
semantic_type_get (node->content.type_name), &printer);
semantic_type_get (node->content.type_name), printer);
break;
case SYMLIST_DEFAULT_TAGGED:
default_tagged_printer_set (&printer);
default_tagged_printer_set (printer);
break;
case SYMLIST_DEFAULT_TAGLESS:
default_tagless_printer_set (&printer);
default_tagless_printer_set (printer);
break;
}
}
+4 -4
View File
@@ -119,11 +119,11 @@ uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n);
bool symbol_list_null (symbol_list *node);
/** Set the \c \%destructor for \c node as \c code at \c loc. */
void symbol_list_destructor_set (symbol_list *node, char const *code,
location 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, char const *code,
location loc);
void symbol_list_printer_set (symbol_list *node,
code_props const *printer);
#endif /* !SYMLIST_H_ */
+40 -25
View File
@@ -150,16 +150,20 @@ static void
symbol_redeclaration (symbol *s, const char *what, location first,
location second)
{
complain_at (second, _("%s redeclaration for %s"), what, s->tag);
complain_at (first, _("previous declaration"));
unsigned i = 0;
complain_at_indent (second, &i, _("%s redeclaration for %s"), what, s->tag);
i += SUB_INDENT;
complain_at_indent (first, &i, _("previous declaration"));
}
static void
semantic_type_redeclaration (semantic_type *s, const char *what, location first,
location second)
{
complain_at (second, _("%s redeclaration for <%s>"), what, s->tag);
complain_at (first, _("previous declaration"));
unsigned i = 0;
complain_at_indent (second, &i, _("%s redeclaration for <%s>"), what, s->tag);
i += SUB_INDENT;
complain_at_indent (first, &i, _("previous declaration"));
}
@@ -515,6 +519,7 @@ symbol_pack_processor (void *this, void *null ATTRIBUTE_UNUSED)
static void
user_token_number_redeclaration (int num, symbol *first, symbol *second)
{
unsigned i = 0;
/* User token numbers are not assigned during the parsing, but in a
second step, via a traversal of the symbol table sorted on tag.
@@ -526,11 +531,13 @@ user_token_number_redeclaration (int num, symbol *first, symbol *second)
first = second;
second = tmp;
}
complain_at (second->location,
_("user token number %d redeclaration for %s"),
num, second->tag);
complain_at (first->location, _("previous declaration for %s"),
first->tag);
complain_at_indent (second->location, &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);
}
/*--------------------------------------------------.
@@ -923,10 +930,12 @@ default_tagged_destructor_set (code_props const *destructor)
{
if (default_tagged_destructor.code)
{
complain_at (destructor->location,
_("redeclaration for default tagged %%destructor"));
complain_at (default_tagged_destructor.location,
_("previous declaration"));
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;
}
@@ -936,10 +945,12 @@ default_tagless_destructor_set (code_props const *destructor)
{
if (default_tagless_destructor.code)
{
complain_at (destructor->location,
_("redeclaration for default tagless %%destructor"));
complain_at (default_tagless_destructor.location,
_("previous declaration"));
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;
}
@@ -949,10 +960,12 @@ default_tagged_printer_set (code_props const *printer)
{
if (default_tagged_printer.code)
{
complain_at (printer->location,
_("redeclaration for default tagged %%printer"));
complain_at (default_tagged_printer.location,
_("previous declaration"));
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;
}
@@ -962,10 +975,12 @@ default_tagless_printer_set (code_props const *printer)
{
if (default_tagless_printer.code)
{
complain_at (printer->location,
_("redeclaration for default tagless %%printer"));
complain_at (default_tagless_printer.location,
_("previous declaration"));
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;
}
+14 -7
View File
@@ -60,23 +60,30 @@ struct symbol
/** The location of its first occurrence. */
location location;
/** Its \c \%type. */
/** Its \c \%type.
Beware that this is the type_name as was entered by the user,
including silly things such as "]" if she entered "%token <]> t".
Therefore, when outputting type_name to M4, be sure to escape it
into "@}". See quoted_output for instance. */
uniqstr type_name;
/** 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. */
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.
Access this field only through <tt>symbol</tt>'s interface functions.
\sa symbol::destructor */
Access this field only through <tt>symbol</tt>'s interface functions.
\sa symbol::destructor */
code_props printer;
symbol_number number;
+55 -44
View File
@@ -38,14 +38,13 @@
# include <stddef.h>
# include <stdlib.h>
# include <string.h>
# if HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
# 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
/* This isn't perfect, but it's good enough for Bison, which needs
only to hash pointers. */
@@ -105,7 +104,6 @@ typedef size_t uintptr_t;
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# endif
# define FUNCTION_PRINT() fprintf (stderr, "%s: ", __func__)
/*------.
| NLS. |
@@ -160,37 +158,54 @@ typedef size_t uintptr_t;
# define obstack_chunk_free free
# include <obstack.h>
# define obstack_sgrow(Obs, Str) \
# define obstack_sgrow(Obs, Str) \
obstack_grow (Obs, Str, strlen (Str))
# define obstack_fgrow1(Obs, Format, Arg1) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
/* Output Str escaped for our postprocessing (i.e., escape M4 special
characters).
# define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
For instance "[foo]" -> "@{foo@}", "$$" -> "$][$][". */
# define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
# define obstack_escape(Obs, Str) \
do { \
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; \
} \
} while (0)
# define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
/* Output Str both quoted for M4 (i.e., embed in [[...]]), and escaped
for our postprocessing (i.e., escape M4 special characters). If
Str is empty (or NULL), output "[]" instead of "[[]]" as it make M4
programming easier (m4_ifval can be used).
For instance "[foo]" -> "[[@{foo@}]]", "$$" -> "[[$][$][]]". */
# define obstack_quote(Obs, Str) \
do { \
char const* obstack_quote_p = Str; \
if (obstack_quote_p && obstack_quote_p[0]) \
{ \
obstack_sgrow (Obs, "[["); \
obstack_escape (Obs, obstack_quote_p); \
obstack_sgrow (Obs, "]]"); \
} \
else \
obstack_sgrow (Obs, "[]"); \
} while (0)
/* Append the ending 0, finish Obs, and return the string. */
# define obstack_finish0(Obs) \
(obstack_1grow (Obs, '\0'), (char *) obstack_finish (Obs))
/*-----------------------------------------.
@@ -205,25 +220,21 @@ do { \
# define TAB_EXT ".tab"
# endif
# ifndef DEFAULT_TMPDIR
# define DEFAULT_TMPDIR "/tmp"
# 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)
/*---------------------------------------------.
+1 -1
View File
@@ -36,7 +36,7 @@ uniqstr uniqstr_vsprintf (char const *format, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
/* Two uniqstr values have the same value iff they are the same. */
#define UNIQSTR_EQ(USTR1, USTR2) ((USTR1) == (USTR2))
#define UNIQSTR_EQ(USTR1, USTR2) (!!((USTR1) == (USTR2)))
/* Compare two uniqstr a la strcmp: negative for <, nul for =, and
positive for >. Undefined order, relies on addresses. */
+355 -53
View File
@@ -69,6 +69,183 @@ AT_PARSER_CHECK([./input], 0,
AT_CLEANUP
## ------------------ ##
## Initial location. ##
## ------------------ ##
# AT_TEST(SKELETON-NAME, DIRECTIVES, [MORE-DIRECTIVES], [LOCATION = 1.1])
# -----------------------------------------------------------------------
# Check that the initial location is correct.
m4_pushdef([AT_TEST],
[AT_SETUP([Initial location: $1 $2])
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" $2])
AT_DATA_GRAMMAR([[input.y]],
[[%defines /* FIXME: Required by lalr1.cc in Bison 2.6. */
%locations
%debug
%skeleton "$1"
]$2[
]$3[
%code
{
# include <stdio.h>
# include <stdlib.h> // getenv
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
}
%%
exp: { ]AT_SKEL_CC_IF([[std::cerr << @$ << std::endl]],
[[YY_LOCATION_PRINT(stderr, @$); fputc ('\n', stderr)]])[; }
%%
]AT_YYERROR_DEFINE[
]AT_YYLEX_PROTOTYPE[
{]AT_PURE_IF([
YYUSE(lvalp);
YYUSE(llocp);], [AT_SKEL_CC_IF([
YYUSE(lvalp);
YYUSE(llocp);])])[
return 'x';
}
int
main (void)
{]AT_SKEL_CC_IF([[
yy::parser p;
p.set_debug_level (!!getenv("YYDEBUG"));
return p.parse ();]], [[
yydebug = !!getenv("YYDEBUG");
return !!yyparse (]AT_PARAM_IF([0])[);]])[
}
]])
AT_FULL_COMPILE([input])
AT_PARSER_CHECK([./input], 1, [],
[m4_default([$4], [1.1])
m4_default([$4], [1.1])[: syntax error
]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
## FIXME: test Java, and iterate over skeletons.
AT_TEST([yacc.c])
AT_TEST([yacc.c], [%define api.pure full])
AT_TEST([yacc.c], [%define api.pure %parse-param { int x }])
AT_TEST([yacc.c], [%define api.push-pull both])
AT_TEST([yacc.c], [%define api.push-pull both %define api.pure full])
AT_TEST([glr.c])
AT_TEST([glr.c], [%define api.pure])
AT_TEST([lalr1.cc])
AT_TEST([glr.cc])
## A very different test, based on PostgreSQL's implementation of the
## locations. See
## http://lists.gnu.org/archive/html/bug-bison/2012-11/msg00023.html
##
## Weirdly enough, to trigger the warning with GCC 4.7, we must not
## use fprintf, so run the test twice: once to check the warning
## (absence thereof), and another time to check the value.
AT_TEST([yacc.c], [%define api.pure full],
[[%{
# define YYLTYPE int
# define YY_LOCATION_PRINT(Stream, Loc) \
(void) (Loc)
# define YYLLOC_DEFAULT(Current, Rhs, N) \
(Current) = ((Rhs)[N ? 1 : 0])
%}
]],
[@&t@])
AT_TEST([yacc.c], [%define api.pure full],
[[%{
# define YYLTYPE int
# define YY_LOCATION_PRINT(Stream, Loc) \
fprintf ((Stream), "%d", (Loc))
# define YYLLOC_DEFAULT(Current, Rhs, N) \
(Current) = ((Rhs)[N ? 1 : 0])
%}
]],
[0])
m4_popdef([AT_TEST])
## ---------------- ##
## Location Print. ##
## ---------------- ##
# AT_TEST(SKELETON-NAME, DIRECTIVES, [MORE-DIRECTIVES], [LOCATION = 1.1])
# -----------------------------------------------------------------------
# Check that the initial location is correct.
m4_pushdef([AT_TEST],
[AT_SETUP([Location print: $1 $2])
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" $2])
AT_DATA_GRAMMAR([[input.y]],
[[%defines /* FIXME: Required by lalr1.cc in Bison 2.6. */
%locations
%debug
%skeleton "$1"
]$2[
]$3[
%code
{
# include <stdio.h>
# include <stdlib.h> // getenv
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
}
%%
exp:;
%%
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE[
int
main (void)
{
#define TEST(L1, C1, L2, C2) \
]AT_LOC_FIRST_LINE[ = L1; \
]AT_LOC_FIRST_COLUMN[ = C1; \
]AT_LOC_LAST_LINE[ = L2; \
]AT_LOC_LAST_COLUMN[ = C2; \
]YY_LOCATION_PRINT(stdout, AT_LOC)[;\
putchar ('\n');
TEST(1, 1, 1, 1);
TEST(2, 1, 2, 10);
TEST(3, 1, 4, 1);
TEST(5, 1, 6, 10);
TEST(7, 2, 0, 2);
TEST(8, 0, 8, 0);
}
]])
AT_FULL_COMPILE([input])
AT_PARSER_CHECK([./input], 0,
[[1.1
2.1-9
3.1-4.0
5.1-6.9
7.2
8.0
]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
## FIXME: test Java, and iterate over skeletons.
AT_TEST([yacc.c])
AT_TEST([glr.c])
#AT_TEST([lalr1.cc])
#AT_TEST([glr.cc])
m4_popdef([AT_TEST])
@@ -159,8 +336,7 @@ main (void)
}
]])
AT_BISON_CHECK([[-o input.c input.y]])
AT_COMPILE([[input]])
AT_FULL_COMPILE([input])
AT_PARSER_CHECK([[./input]], [[0]],
[[6
]])
@@ -264,7 +440,7 @@ input:
V(input, $$, @$, ": /* Nothing */\n");
}
| line input /* Right recursive to load the stack so that popping at
END can be exercised. */
END can be exercised. */
{
$$ = 2;
V(input, $$, @$, ": ");
@@ -305,7 +481,7 @@ line:
$$ = -1;
V(line, $$, @$, ": ");
V('(', $1, @1, " ");
fprintf (stderr, "error (@%d-%d) ", RANGE(@2));
fprintf (stderr, "error (@%d-%d) ", RANGE (@2));
V(')', $3, @3, "\n");
}
;
@@ -557,7 +733,7 @@ AT_BISON_OPTION_POPDEFS
# AT_CHECK_PRINTER_AND_DESTRUCTOR([BISON-OPTIONS], [UNION-FLAG], [SKIP_FLAG])
# ---------------------------------------------------------------------------
m4_define([AT_CHECK_PRINTER_AND_DESTRUCTOR],
[AT_SETUP([Printers and Destructors $2: $1])
[AT_SETUP([Printers and Destructors$2]m4_ifval([$1], [[: $1]]))
$3
_AT_CHECK_PRINTER_AND_DESTRUCTOR($[1], $[2], $[3], $[4],
@@ -572,13 +748,13 @@ AT_CLEANUP
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])
@@ -595,10 +771,6 @@ AT_DATA_GRAMMAR([[input.y]],
[[%error-verbose
%debug
%locations
%initial-action {
@$.first_line = @$.last_line = 1;
@$.first_column = @$.last_column = 1;
}
%{
# include <stdio.h>
@@ -656,29 +828,29 @@ AT_PARSER_CHECK([./input], 1,
]],
[[Starting parse
Entering state 0
Reading a token: Next token is token 'a' (1.1-1.1: <> printer for 'a' @ 1)
Shifting token 'a' (1.1-1.1: <> printer for 'a' @ 1)
Reading a token: Next token is token 'a' (1.1: <> printer for 'a' @ 1)
Shifting token 'a' (1.1: <> printer for 'a' @ 1)
Entering state 1
Reading a token: Next token is token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2)
Shifting token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2)
Reading a token: Next token is token 'b' (1.2: 'b'/'c' printer for 'b' @ 2)
Shifting token 'b' (1.2: 'b'/'c' printer for 'b' @ 2)
Entering state 3
Reading a token: Next token is token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
Shifting token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
Reading a token: Next token is token 'c' (1.3: 'b'/'c' printer for 'c' @ 3)
Shifting token 'c' (1.3: 'b'/'c' printer for 'c' @ 3)
Entering state 5
Reading a token: Next token is token 'd' (1.4-1.4: <> printer for 'd' @ 4)
Shifting token 'd' (1.4-1.4: <> printer for 'd' @ 4)
Reading a token: Next token is token 'd' (1.4: <> printer for 'd' @ 4)
Shifting token 'd' (1.4: <> printer for 'd' @ 4)
Entering state 6
Reading a token: Now at end of input.
1.5-4: syntax error, unexpected $end, expecting 'e'
Error: popping token 'd' (1.4-1.4: <> printer for 'd' @ 4)
1.5: syntax error, unexpected $end, expecting 'e'
Error: popping token 'd' (1.4: <> printer for 'd' @ 4)
Stack now 0 1 3 5
Error: popping token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
Error: popping token 'c' (1.3: 'b'/'c' printer for 'c' @ 3)
Stack now 0 1 3
Error: popping token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2)
Error: popping token 'b' (1.2: 'b'/'c' printer for 'b' @ 2)
Stack now 0 1
Error: popping token 'a' (1.1-1.1: <> printer for 'a' @ 1)
Error: popping token 'a' (1.1: <> printer for 'a' @ 1)
Stack now 0
Cleanup: discarding lookahead token $end (1.5-1.5: )
Cleanup: discarding lookahead token $end (1.5: )
Stack now 0
]])
@@ -829,10 +1001,6 @@ AT_DATA_GRAMMAR([[input]]$1[[.y]],
[[%error-verbose
%debug
%locations
%initial-action {
@$.first_line = @$.last_line = 1;
@$.first_column = @$.last_column = 1;
}
%{
# include <stdio.h>
@@ -899,16 +1067,16 @@ AT_PARSER_CHECK([./input$1], 0,
]],
[[Starting parse
Entering state 0
Reducing stack by rule 1 (line 46):
-> $$ = nterm start (1.1-1.1: <]]kind[[> for 'S' @ 1)
Reducing stack by rule 1 (line 42):
-> $$ = nterm start (1.1: <]]kind[[> for 'S' @ 1)
Stack now 0
Entering state 1
Reading a token: Now at end of input.
Shifting token END (1.1-1.1: <]]kind[[> for 'E' @ 1)
Shifting token END (1.1: <]]kind[[> for 'E' @ 1)
Entering state 2
Stack now 0 1 2
Cleanup: popping token END (1.1-1.1: <]]kind[[> for 'E' @ 1)
Cleanup: popping nterm start (1.1-1.1: <]]kind[[> for 'S' @ 1)
Cleanup: popping token END (1.1: <]]kind[[> for 'E' @ 1)
Cleanup: popping nterm start (1.1: <]]kind[[> for 'S' @ 1)
]])
m4_popdef([kind])
@@ -1136,6 +1304,15 @@ AT_BISON_CHECK([-o input.c input.y], 0,,
input.y:30.3-35.37: warning: unused value: $3
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], 0,,
[[input.y:33.3-23: warning: unset value: $$
{ @$ = 4; } // Only used.
^^^^^^^^^^^^^^^^^^^^^
input.y:30.3-35.37: warning: unused value: $3
{ @$ = 1; } // Not set or used.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]])
AT_COMPILE([input])
AT_PARSER_CHECK([./input], 1,,
[[Starting parse
@@ -1230,6 +1407,131 @@ AT_CHECK_ACTION_LOCATIONS([[%destructor]])
AT_CHECK_ACTION_LOCATIONS([[%printer]])
## ------------------------- ##
## 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.
#
# FIXME: Not actually checking %destructor, but it's the same code as
# %printer...
#
# To do that, use a semantic value that has two fields (sem_type),
# declare symbols to have only one of these types (INT, float), and
# use $<type>$ to get the other one. Including for symbols that are
# not typed (UNTYPED).
m4_pushdef([AT_TEST],
[AT_SETUP([[Qualified $$ in actions: $1]])
AT_BISON_OPTION_PUSHDEFS([%locations %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
{
typedef struct sem_type
{
int ival;
float fval;
} sem_type;
# define YYSTYPE sem_type
]AT_SKEL_CC_IF([[
# include <iostream>
static void
report (std::ostream& yyo, int ival, float fval)
{
yyo << "ival: " << ival << ", fval: " << fval;
}
]], [[
# include <stdio.h>
static void
report (FILE* yyo, int ival, float fval)
{
fprintf (yyo, "ival: %d, fval: %1.1f", ival, fval);
}
]])[
}
%code
{
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
}
%token UNTYPED
%token <ival> INT
%type <fval> float
%printer { report (yyo, $$, $<fval>$); } <ival>;
%printer { report (yyo, $<ival>$, $$ ); } <fval>;
%printer { report (yyo, $<ival>$, $<fval>$); } <>;
%initial-action
{
$<ival>$ = 42;
$<fval>$ = 4.2;
}
%%
float: UNTYPED INT
{
$$ = $<fval>1 + $<fval>2;
$<ival>$ = $<ival>1 + $][2;
};
%%
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(AT_SKEL_CC_IF([[{yy::parser::token::UNTYPED,
yy::parser::token::INT,
EOF}]],
[[{UNTYPED, INT, EOF}]]),
[AT_VAL.ival = toknum * 10; AT_VAL.fval = toknum / 10.0;])[
int
main (void)
{]AT_SKEL_CC_IF([[
yy::parser p;
p.set_debug_level(1);
return p.parse ();]], [[
yydebug = 1;
return yyparse ();]])[
}
]])
AT_FULL_COMPILE([[input]])
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,
[[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)
Shifting token INT (ival: 20, fval: 0.2)
$][1 = token UNTYPED (ival: 10, fval: 0.1)
$][2 = token INT (ival: 20, fval: 0.2)
-> $$ = nterm float (ival: 30, fval: 0.3)
Cleanup: popping nterm float (ival: 30, fval: 0.3)
]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
AT_TEST([yacc.c])
AT_TEST([glr.c])
AT_TEST([lalr1.cc])
AT_TEST([glr.cc])
m4_popdef([AT_TEST])
## ----------------------------------------------- ##
## Fix user actions without a trailing semicolon. ##
## ----------------------------------------------- ##
@@ -1293,41 +1595,41 @@ 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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
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: future versions of Bison will not add the ';'
input.y:36.1: future versions of Bison will not add the ';'
]])
AT_MATCHES_CHECK([input.c], [[/\* TEST:N:2 \*/ \}$]], [[3]])
+23 -18
View File
@@ -29,16 +29,10 @@ CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@"
# Is the compiler GCC?
GCC='@GCC@'
# We want no optimization, as they uncover warnings (therefore,
# failures) about uninitialized variables in the test suite. FIXME:
# fix the warnings, not the flags.
O0CFLAGS=`echo '@CFLAGS@' | sed 's/-O[0-9s] *//g'`
O0CXXFLAGS=`echo '@CXXFLAGS@' | sed 's/-O[0-9s] *//g'`
# Sometimes a test group needs to ignore gcc warnings, so it locally
# sets CFLAGS to this.
NO_WERROR_CFLAGS="$O0CFLAGS @WARN_CFLAGS@ @WARN_CFLAGS_TEST@"
NO_WERROR_CXXFLAGS="$O0CXXFLAGS @WARN_CXXFLAGS@ @WARN_CXXFLAGS_TEST@"
NO_WERROR_CFLAGS='@CFLAGS@ @WARN_CFLAGS@ @WARN_CFLAGS_TEST@'
NO_WERROR_CXXFLAGS='@CXXFLAGS@ @WARN_CXXFLAGS@ @WARN_CXXFLAGS_TEST@'
# But most of the time, we want -Werror.
CFLAGS="$NO_WERROR_CFLAGS @WERROR_CFLAGS@"
@@ -51,7 +45,6 @@ BISON_CXX_WORKS='@BISON_CXX_WORKS@'
if "$at_arg_compile_c_with_cxx"; then
CC_IS_CXX=1
CC=$CXX
O0CFLAGS=$O0CXXFLAGS
NO_WERROR_CFLAGS=$NO_WERROR_CXXFLAGS
CFLAGS=$CXXFLAGS
else
@@ -63,24 +56,36 @@ fi
## Other. ##
## ------- ##
# Are special link options needed?
LDFLAGS='@LDFLAGS@'
# Are special libraries needed?
LIBS="$abs_top_builddir/lib/libbison.a @LIBS@ @INTLLIBS@"
# Empty if no javac was found
CONF_JAVAC='@CONF_JAVAC@'
# Empty if no Java VM was found
CONF_JAVA='@CONF_JAVA@'
# Empty if no xsltproc was found
: ${XSLTPROC='@XSLTPROC@'}
# We need egrep.
: ${EGREP='@EGREP@'}
# Use simple quotes (lib/quote.c).
LC_CTYPE=C
export LC_CTYPE
# Are special link options needed?
LDFLAGS='@LDFLAGS@'
# Are special libraries needed?
LIBS="$abs_top_builddir/lib/libbison.a @LIBS@ @INTLLIBS@"
# 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
+1 -1
View File
@@ -19,7 +19,7 @@
abs_top_srcdir='@abs_top_srcdir@'
abs_top_builddir='@abs_top_builddir@'
: ${PERL=perl}
: ${PERL='@PERL@'}
# Use the shipped files, not those installed.
BISON_PKGDATADIR=$abs_top_srcdir/data
+238 -5
View File
@@ -1,4 +1,4 @@
# Checking the output filenames. -*- Autotest -*-
# Checking the C++ Features. -*- Autotest -*-
# Copyright (C) 2004-2005, 2007, 2009-2012 Free Software Foundation,
# Inc.
@@ -30,6 +30,7 @@ m4_define([AT_CHECK_DOXYGEN],
[m4_fatal([invalid argument: $1])])
AT_SETUP([Doxygen $1 Documentation])
AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"])
AT_DATA([input.yy],
[[%skeleton "lalr1.cc"
%locations
@@ -38,10 +39,7 @@ AT_DATA([input.yy],
%%
exp:;
%%
yy::parser::error (const location& l, const std::string& m)
{
std::cerr << l << s << std::endl;
}
]AT_YYERROR_DEFINE[
]])
AT_BISON_CHECK([-o input.cc input.yy], 0)
@@ -94,6 +92,7 @@ EXTRACT_STATIC = AT_DOXYGEN_PRIVATE
AT_CHECK([doxygen --version || exit 77], 0, ignore)
AT_CHECK([doxygen], 0, [], [ignore])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
m4_popdef([AT_DOXYGEN_PRIVATE])
@@ -182,3 +181,237 @@ AT_CHECK_NAMESPACE([[foo[3]::bar::baz]], [[-]])
AT_CHECK_NAMESPACE([[foo::bar,baz]], [[-]])
AT_CHECK_NAMESPACE([[foo::bar::(baz]], [[-]])
AT_CLEANUP
## ------------------ ##
## Exception safety. ##
## ------------------ ##
AT_SETUP([[Exception safety]])
AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"])
AT_DATA_GRAMMAR([[input.yy]],
[[%skeleton "lalr1.cc"
%defines // FIXME: Mandated in 2.6.
%debug
%error-verbose
%code requires
{
#include <cassert>
#include <cstdlib> // size_t and getenv.
#include <iostream>
#include <list>
bool debug = false;
/// A class that counts its number of instances.
struct Object
{
typedef std::list<const Object*> objects;
static objects instances;
char val;
static bool
empty ()
{
return instances.empty();
}
static void
log (Object const *o, const std::string& msg)
{
if (debug)
{
if (o)
std::cerr << o << "->";
std::cerr << msg << " {";
const char* sep = " ";
for (objects::const_iterator i = instances.begin(),
i_end = instances.end();
i != i_end;
++i)
{
std::cerr << sep << *i;
sep = ", ";
}
std::cerr << " }" << std::endl;
}
}
Object (char v)
: val (v)
{
instances.push_back(this);
log (this, "Object::Object");
}
~Object ()
{
instances.remove(this);
log (this, "Object::~Object");
}
};
}
%code
{
#include <cassert>
#include <cstring> // strchr
#include <stdexcept>
int yylex (yy::parser::semantic_type *);
Object::objects Object::instances;
static char const *input;
}
%union
{
Object *obj;
}
%initial-action
{
if (strchr (input, 'i'))
throw std::runtime_error ("initial-action");
}
%destructor { delete $$; } <obj>;
%printer
{
yyo << $$ << " '" << $$->val << '\'';
if ($$->val == 'p')
throw std::runtime_error ("printer");
} <obj>;
%token <obj> 'a' 'E' 'e' 'p' 'R' 's' 'T'
%type <obj> list item
%%
start: list { delete $1; };
list:
item { $$ = $1; }
| item list { $$ = $1; delete $2; } // Right recursion to load the stack.
;
item:
'a' { $$ = $1; }
| 'e' { YYUSE ($$); YYUSE($1); error (location_type(), "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; }
| 'R' { $$ = YY_NULL; delete $1; YYERROR; }
| 'p' { $$ = $1; }
| 's' { $$ = $1; throw std::runtime_error ("reduction"); }
| 'T' { $$ = YY_NULL; delete $1; YYABORT; }
| error { $$ = YY_NULL; yyerrok; }
;
%%
int
yylex (yy::parser::semantic_type *lvalp)
{
// 'a': no error.
// 'e': user action calls error.
// 'E': syntax error, with yyerror that throws.
// 'i': initial action throws.
// 'l': yylex throws.
// 'R': call YYERROR in the action
// 's': reduction throws.
// 'T': call YYABORT in the action
switch (int res = *input++)
{
case 'l':
throw std::runtime_error ("yylex");
default:
lvalp->obj = new Object (res);
// Fall through.
case 0:
return res;
}
}
/* A C++ error reporting function. */
void
yy::parser::error (const location_type& l, const std::string& m)
{
YYUSE (l);
throw std::runtime_error (m);
}
int
main (int argc, const char *argv[])
{
switch (argc)
{
case 2:
input = argv[1];
break;
case 3:
assert (!strcmp (argv[1], "--debug"));
debug = 1;
input = argv[2];
break;
default:
abort ();
}
yy::parser parser;
debug |= !!getenv ("YYDEBUG");
parser.set_debug_level (debug);
int res = 2;
try
{
res = parser.parse ();
}
catch (const std::exception& e)
{
std::cerr << "exception caught: " << e.what () << std::endl;
}
catch (...)
{
std::cerr << "unknown exception caught" << std::endl;
}
Object::log (YY_NULL, "end");
assert (Object::empty());
return res;
}
]])
AT_BISON_CHECK([[-o input.cc --report=all input.yy]])
AT_COMPILE_CXX([[input]])
AT_PARSER_CHECK([[./input aaaas]], [[2]], [[]],
[[exception caught: reduction
]])
AT_PARSER_CHECK([[./input aaaal]], [[2]], [[]],
[[exception caught: yylex
]])
AT_PARSER_CHECK([[./input i]], [[2]], [[]],
[[exception caught: initial-action
]])
AT_PARSER_CHECK([[./input aaaap]])
AT_PARSER_CHECK([[./input --debug aaaap]], [[2]], [[]], [[stderr]])
AT_CHECK([[grep '^exception caught: printer$' stderr]], [], [ignore])
AT_PARSER_CHECK([[./input aaaae]], [[2]], [[]],
[[exception caught: syntax error
]])
AT_PARSER_CHECK([[./input aaaaE]], [[2]], [[]],
[[exception caught: syntax error, unexpected $end, expecting 'a'
]])
AT_PARSER_CHECK([[./input aaaaT]], [[1]])
# There is error-recovery, so exit success.
AT_PARSER_CHECK([[./input aaaaR]], [[0]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
+40 -59
View File
@@ -178,18 +178,7 @@ read_signed_integer (]AT_YYLEX_FORMALS[)
]AT_YYLEX_PROTOTYPE[
{
static int init = 1;
int c;
if (init)
{
init = 0;
]AT_LOCATION_IF([
AT_LOC_LAST_COLUMN = 1;
AT_LOC_LAST_LINE = 1;
])[
}
/* Skip current token, then white spaces. */
do
{
@@ -261,6 +250,8 @@ AT_SKEL_CC_IF(
{
semantic_value ival;
};
%printer { ]AT_SKEL_CC_IF([[yyoutput << $$]],
[[fprintf (yyoutput, "%d", $$)]])[; } <ival>;
%code provides
{
@@ -280,24 +271,16 @@ AT_SKEL_CC_IF(
FILE *input;
static int power (int base, int exponent);
]AT_SKEL_CC_IF(,
[static void yyerror (AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])
AT_PARAM_IF([semantic_value *result, int *count, ])
const char *s
);])[
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE_EXTERN[
}
]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [
/* The lalr1.cc skeleton, for backward compatibility, defines
a constructor for position that initializes the filename. The
glr.cc skeleton does not (and in fact cannot: location/position
are stored in a union, from which objects with constructors are
excluded in C++. */
%initial-action {
@$.initialize ();
}
])])[
]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([[
%initial-action
{
@$.first.l = @$.first.c = 1;
@$.last = @$.first;
}]])])[
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
@@ -365,32 +348,11 @@ power (int base, int exponent)
o << '-' << s.last.c - 1;
return o;
}
]])
AT_YYERROR_DEFINE],
[/* A C error reporting function. */
static void
yyerror (AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])
AT_PARAM_IF([semantic_value *result, int *count, ])
const char *s)
{
AT_PARAM_IF([(void) result; (void) count;])
AT_YYERROR_SEES_LOC_IF([
fprintf (stderr, "%d.%d",
AT_LOC_FIRST_LINE, AT_LOC_FIRST_COLUMN);
if (AT_LOC_FIRST_LINE != AT_LOC_LAST_LINE)
fprintf (stderr, "-%d.%d",
AT_LOC_LAST_LINE, AT_LOC_LAST_COLUMN - 1);
else if (AT_LOC_FIRST_COLUMN != AT_LOC_LAST_COLUMN - 1)
fprintf (stderr, "-%d",
AT_LOC_LAST_COLUMN - 1);
fprintf (stderr, ": ");])
fprintf (stderr, "%s\n", s);
}])[
]])])[
]AT_YYERROR_DEFINE[
]AT_DEFINES_IF([],
[AT_CALC_LEX
AT_CALC_MAIN])[
]])
AT_CALC_MAIN])])
AT_DEFINES_IF([AT_DATA_SOURCE([[calc-lex.c]AT_SKEL_CC_IF([[c]])],
[[#include "calc.h]AT_SKEL_CC_IF([[h]])["
@@ -500,6 +462,23 @@ AT_CHECK([cat stderr], 0, [expout])
])
# AT_CHECK_SPACES([FILE])
# -----------------------
# Make sure we did not introduce bad spaces. Checked here because all
# the skeletons are (or should be) exercized here.
m4_define([AT_CHECK_SPACES],
[AT_CHECK([$PERL -ne '
chomp;
print "$.: {$_}\n"
if (# No starting/ending empty lines.
(eof || $. == 1) && /^\s*$/
# No trailing space. FIXME: not ready for "maint".
# || /\s$/
)' $1
])dnl
])
# AT_CHECK_CALC([BISON-OPTIONS])
# ------------------------------
# Start a testing chunk which compiles `calc' grammar with
@@ -514,6 +493,8 @@ AT_BISON_OPTION_PUSHDEFS([$1])
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])])])
# Test the priorities.
_AT_CHECK_CALC([$1],
@@ -533,7 +514,7 @@ _AT_CHECK_CALC([$1],
[842])
# Some syntax errors.
_AT_CHECK_CALC_ERROR([$1], [1], [0 0], [15],
_AT_CHECK_CALC_ERROR([$1], [1], [1 2], [15],
[1.3: syntax error, unexpected number])
_AT_CHECK_CALC_ERROR([$1], [1], [1//2], [20],
[1.3: syntax error, unexpected '/', expecting number or '-' or '(' or '!'])
@@ -577,10 +558,10 @@ calc: error: 4444 != 1])
# The same, but this time exercising explicitly triggered syntax errors.
# POSIX says the lookahead causing the error should not be discarded.
_AT_CHECK_CALC_ERROR([$1], [0], [(!) + (0 0) = 1], [102],
_AT_CHECK_CALC_ERROR([$1], [0], [(!) + (1 2) = 1], [102],
[1.10: syntax error, unexpected number
calc: error: 2222 != 1])
_AT_CHECK_CALC_ERROR([$1], [0], [(- *) + (0 0) = 1], [113],
_AT_CHECK_CALC_ERROR([$1], [0], [(- *) + (1 2) = 1], [113],
[1.4: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.12: syntax error, unexpected number
calc: error: 2222 != 1])
@@ -623,8 +604,8 @@ AT_CHECK_CALC_LALR([%verbose])
AT_CHECK_CALC_LALR([%yacc])
AT_CHECK_CALC_LALR([%error-verbose])
AT_CHECK_CALC_LALR([%define api.pure %locations])
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %locations])
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([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
@@ -634,8 +615,8 @@ 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 api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.pure 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 %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
@@ -696,7 +677,7 @@ m4_define([AT_CHECK_CALC_LALR1_CC],
[AT_CHECK_CALC([%language "C++" %defines %locations] $@)])
AT_CHECK_CALC_LALR1_CC([])
AT_CHECK_CALC_LALR1_CC([%define location_type Span])
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])
@@ -725,7 +706,7 @@ m4_define([AT_CHECK_CALC_GLR_CC],
[AT_CHECK_CALC([%language "C++" %glr-parser %defines %locations] $@)])
AT_CHECK_CALC_GLR_CC([])
AT_CHECK_CALC_GLR_CC([%define location_type Span])
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])
+43 -37
View File
@@ -41,6 +41,12 @@ AT_BISON_CHECK([-o input.c input.y], 0, [],
[[input.y:4.9: warning: rule useless in parser due to conflicts: e: /* empty */
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], 0, [],
[[input.y:4.9: warning: rule useless in parser due to conflicts
e: 'e' | /* Nothing. */;
^
]])
AT_CLEANUP
@@ -580,7 +586,7 @@ exp (6)
on left: 1 2, on right: 0 1
state 0
State 0
0 $accept: . exp $end
1 exp: . exp OP exp
@@ -591,14 +597,14 @@ state 0
exp go to state 2
state 1
State 1
2 exp: NUM .
$default reduce using rule 2 (exp)
state 2
State 2
0 $accept: exp . $end
1 exp: exp . OP exp
@@ -607,14 +613,14 @@ state 2
OP shift, and go to state 4
state 3
State 3
0 $accept: exp $end .
$default accept
state 4
State 4
1 exp: . exp OP exp
1 | exp OP . exp
@@ -625,7 +631,7 @@ state 4
exp go to state 5
state 5
State 5
1 exp: exp . OP exp
1 | exp OP exp . [$end, OP]
@@ -683,7 +689,7 @@ exp (6)
on left: 1 2, on right: 0 1
state 0
State 0
0 $accept: . exp $end
1 exp: . exp OP exp
@@ -694,14 +700,14 @@ state 0
exp go to state 2
state 1
State 1
2 exp: NUM .
$default reduce using rule 2 (exp)
state 2
State 2
0 $accept: exp . $end
1 exp: exp . OP exp
@@ -710,14 +716,14 @@ state 2
OP shift, and go to state 4
state 3
State 3
0 $accept: exp $end .
$default accept
state 4
State 4
1 exp: . exp OP exp
1 | exp OP . exp
@@ -728,7 +734,7 @@ state 4
exp go to state 5
state 5
State 5
1 exp: exp . OP exp
1 | exp OP exp . [$end, OP]
@@ -823,7 +829,7 @@ id (7)
on left: 4, on right: 2
state 0
State 0
0 $accept: . exp $end
1 exp: . num
@@ -838,7 +844,7 @@ state 0
id go to state 4
state 1
State 1
3 num: '0' . [$end]
4 id: '0' . [$end]
@@ -848,28 +854,28 @@ state 1
$default reduce using rule 3 (num)
state 2
State 2
0 $accept: exp . $end
$end shift, and go to state 5
state 3
State 3
1 exp: num .
$default reduce using rule 1 (exp)
state 4
State 4
2 exp: id .
$default reduce using rule 2 (exp)
state 5
State 5
0 $accept: exp $end .
@@ -896,7 +902,7 @@ exp: exp OP exp | NUM;
AT_BISON_CHECK([-o input.c input.y], 1, [],
[input.y: conflicts: 1 shift/reduce
input.y: expected 0 shift/reduce conflicts
input.y: error: expected 0 shift/reduce conflicts
])
AT_CLEANUP
@@ -933,7 +939,7 @@ exp: exp OP exp | NUM;
AT_BISON_CHECK([-o input.c input.y], 1, [],
[input.y: conflicts: 1 shift/reduce
input.y: expected 2 shift/reduce conflicts
input.y: error: expected 2 shift/reduce conflicts
])
AT_CLEANUP
@@ -953,7 +959,7 @@ a: 'a';
AT_BISON_CHECK([-o input.c input.y], 1, [],
[input.y: conflicts: 1 reduce/reduce
input.y: expected 0 reduce/reduce conflicts
input.y: error: expected 0 reduce/reduce conflicts
])
AT_CLEANUP
@@ -1170,7 +1176,7 @@ reported_conflicts (9)
on left: 8 9 10, on right: 1
state 0
State 0
0 $accept: . start $end
1 start: . resolved_conflict 'a' reported_conflicts 'a'
@@ -1185,28 +1191,28 @@ state 0
Conflict between rule 3 and token 'a' resolved as reduce (%left 'a').
state 1
State 1
0 $accept: start . $end
$end shift, and go to state 3
state 2
State 2
1 start: resolved_conflict . 'a' reported_conflicts 'a'
'a' shift, and go to state 4
state 3
State 3
0 $accept: start $end .
$default accept
state 4
State 4
1 start: resolved_conflict 'a' . reported_conflicts 'a'
8 reported_conflicts: . 'a'
@@ -1220,7 +1226,7 @@ state 4
reported_conflicts go to state 6
state 5
State 5
8 reported_conflicts: 'a' . ['a']
9 | 'a' . ['a']
@@ -1230,14 +1236,14 @@ state 5
$default reduce using rule 8 (reported_conflicts)
state 6
State 6
1 start: resolved_conflict 'a' reported_conflicts . 'a'
'a' shift, and go to state 7
state 7
State 7
1 start: resolved_conflict 'a' reported_conflicts 'a' .
@@ -1291,8 +1297,8 @@ empty_c2: %prec 'c' ;
empty_c3: %prec 'd' ;
]])
AT_BISON_CHECK([[--report=all -o input.c input.y]], 0, [], [ignore])
AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0,
[[state 0
AT_CHECK([[cat input.output | sed -n '/^State 0$/,/^State 1$/p']], 0,
[[State 0
0 $accept: . start $end
1 start: . 'a'
@@ -1328,7 +1334,7 @@ AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0,
Conflict between rule 13 and token 'c' resolved as reduce ('c' < 'd').
state 1
State 1
]])
AT_CLEANUP
@@ -1367,8 +1373,8 @@ empty_c3: %prec 'c' ;
]])
AT_BISON_CHECK([[--report=all -o input.c input.y]], 0, [], [ignore])
AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0,
[[state 0
AT_CHECK([[cat input.output | sed -n '/^State 0$/,/^State 1$/p']], 0,
[[State 0
0 $accept: . start $end
1 start: . 'a'
@@ -1404,7 +1410,7 @@ AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0,
Conflict between rule 11 and token 'c' resolved as an error (%nonassoc 'c').
state 1
State 1
]])
AT_CLEANUP
@@ -1494,11 +1500,11 @@ AT_BISON_CHECK([[-Wno-conflicts-rr sr-rr.y]], [[0]], [[]],
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: expected $sr_exp shift/reduce conflict$s" >> experr
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: expected $rr_exp reduce/reduce conflict$s" >> experr
echo "$file: error: expected $rr_exp reduce/reduce conflict$s" >> experr
fi
]AT_BISON_CHECK([[-Wnone $file]], [[1]], [[]], [[experr]])[
]AT_BISON_CHECK([[-Werror $file]], [[1]], [[]], [[experr]])[
+2 -2
View File
@@ -376,7 +376,7 @@ m4_define([_AT_GLR_STDERR],
]])
m4_define([_AT_GLR_STDERR_WITH_LOC],
[[17.5-4: syntax error
[[17.5: syntax error
]])
m4_define([_AT_VERBOSE_GLR_STDERR],
@@ -384,7 +384,7 @@ m4_define([_AT_VERBOSE_GLR_STDERR],
]])
m4_define([_AT_VERBOSE_GLR_STDERR_WITH_LOC],
[[17.5-4: syntax error, unexpected ID, expecting '=' or '+' or ')'
[[17.5: syntax error, unexpected ID, expecting '=' or '+' or ')'
]])
## ---------------------------------------------------- ##
+24 -21
View File
@@ -35,7 +35,10 @@ dnl time comes, just use sed to drop the line numbers. For now, as LR(1)
dnl support is rapidly evolving, let's keep that information to be careful.
dnl However, we don't do diffs for canonical LR(1) because the diff is huge.
m4_pushdef([AT_LALR1_DIFF_CHECK],
[AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
[dnl We need diff -u, which is not portable.
AT_CHECK([diff -u /dev/null /dev/null || exit 77], [0], [ignore])
AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
AT_BISON_CHECK([[--report=all input-lalr.y]], [[0]], [ignore], [ignore])
AT_CHECK([[diff -u input-lalr.output input.output \
| sed -n '/^@@/,$p' | sed 's/^ $//']],
@@ -486,7 +489,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
$default reduce using rule 45 (statement)
+
+
+state 320
+State 320
+
+ 139 non_post_simp_exp: . '!' simp_exp
+ 140 | . '(' exp r_paren
@@ -524,7 +527,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
+ variable go to state 63
+
+
+state 321
+State 321
+
+ 146 non_post_simp_exp: INCREMENT . variable
+ 154 variable: . NAME
@@ -537,7 +540,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
+ variable go to state 50
+
+
+state 322
+State 322
+
+ 147 non_post_simp_exp: DECREMENT . variable
+ 154 variable: . NAME
@@ -550,7 +553,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
+ variable go to state 51
+
+
+state 323
+State 323
+
+ 130 simp_exp: . non_post_simp_exp
+ 131 | . simp_exp '^' simp_exp
@@ -598,7 +601,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
+ variable go to state 57
+
+
+state 324
+State 324
+
+ 130 simp_exp: . non_post_simp_exp
+ 131 | . simp_exp '^' simp_exp
@@ -646,7 +649,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
+ variable go to state 57
+
+
+state 325
+State 325
+
+ 130 simp_exp: . non_post_simp_exp
+ 131 | . simp_exp '^' simp_exp
@@ -694,7 +697,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
+ variable go to state 57
+
+
+state 326
+State 326
+
+ 131 simp_exp: simp_exp . '^' simp_exp
+ 132 | simp_exp . '*' simp_exp
@@ -715,7 +718,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
+ Conflict between rule 151 and token '-' resolved as reduce ('-' < UNARY).
+
+
+state 327
+State 327
+
+ 131 simp_exp: simp_exp . '^' simp_exp
+ 132 | simp_exp . '*' simp_exp
@@ -736,7 +739,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
+ Conflict between rule 150 and token '-' resolved as reduce ('-' < UNARY).
+
+
+state 328
+State 328
+
+ 131 simp_exp: simp_exp . '^' simp_exp
+ 132 | simp_exp . '*' simp_exp
@@ -2037,7 +2040,7 @@ dnl - 383 -> 427
nth_primitive go to state 105
@@ -3256,7 +3256,7 @@
state 102
State 102
- 146 place: label . [$end, LABEL, VARIABLE, NUMBER, TEXT, ORDINAL, LEFT_ARROW_HEAD, RIGHT_ARROW_HEAD, DOUBLE_ARROW_HEAD, LAST, UP, DOWN, LEFT, RIGHT, HEIGHT, RADIUS, WIDTH, DIAMETER, FROM, TO, AT, WITH, BY, THEN, SOLID, DOTTED, DASHED, CHOP, SAME, INVISIBLE, LJUST, RJUST, ABOVE, BELOW, AND, HERE, DOT_X, DOT_Y, DOT_HT, DOT_WID, DOT_RAD, SIN, COS, ATAN2, LOG, EXP, SQRT, K_MAX, K_MIN, INT, RAND, SRAND, CW, CCW, THICKNESS, FILL, COLORED, OUTLINED, SHADED, ALIGNED, SPRINTF, '(', '`', ',', '>', '+', '-', '!', ';', '}', '@:>@', ')']
+ 146 place: label . [$end, LABEL, VARIABLE, NUMBER, TEXT, ORDINAL, LEFT_ARROW_HEAD, RIGHT_ARROW_HEAD, DOUBLE_ARROW_HEAD, LAST, UP, DOWN, LEFT, RIGHT, HEIGHT, RADIUS, WIDTH, DIAMETER, FROM, TO, AT, WITH, BY, THEN, SOLID, DOTTED, DASHED, CHOP, SAME, INVISIBLE, LJUST, RJUST, ABOVE, BELOW, HERE, DOT_X, DOT_Y, DOT_HT, DOT_WID, DOT_RAD, SIN, COS, ATAN2, LOG, EXP, SQRT, K_MAX, K_MIN, INT, RAND, SRAND, CW, CCW, THICKNESS, FILL, COLORED, OUTLINED, SHADED, ALIGNED, SPRINTF, '(', '`', '+', '-', '!', ';', '}', '@:>@']
@@ -2202,7 +2205,7 @@ dnl - 383 -> 427
+ expr go to state 424
state 165
State 165
@@ -7987,7 +7987,7 @@
text_expr go to state 112
text go to state 113
@@ -2319,7 +2322,7 @@ dnl - 383 -> 427
+ between go to state 425
state 193
State 193
@@ -10152,7 +10152,7 @@
expr_pair go to state 317
@@ -2487,7 +2490,7 @@ dnl - 383 -> 427
+ expr go to state 424
state 238
State 238
@@ -12937,7 +12937,7 @@
'!' shift, and go to state 94
@@ -2574,7 +2577,7 @@ dnl - 383 -> 427
+ expr go to state 424
state 315
State 315
@@ -16124,7 +16124,7 @@
$default reduce using rule 239 (expr)
@@ -2625,7 +2628,7 @@ dnl - 383 -> 427
+ expr go to state 424
state 383
State 383
@@ -18071,7 +18071,7 @@
'!' shift, and go to state 94
@@ -2668,7 +2671,7 @@ dnl - 383 -> 427
$default reduce using rule 29 (placeless_element)
+
+
+state 423
+State 423
+
+ 146 place: label . [$end, AND, DOT_X, DOT_Y, DOT_HT, DOT_WID, DOT_RAD, ',', '>', '+', '-', ';', '}', '@:>@', ')']
+ 147 | label . corner
@@ -2739,7 +2742,7 @@ dnl - 383 -> 427
+ corner go to state 205
+
+
+state 424
+State 424
+
+ 140 position_not_place: expr . between position AND position
+ 141 | expr . '<' position ',' position '>'
@@ -2782,7 +2785,7 @@ dnl - 383 -> 427
+ between go to state 425
+
+
+state 425
+State 425
+
+ 134 position: . position_not_place
+ 135 | . place
@@ -2938,7 +2941,7 @@ dnl - 383 -> 427
+ expr go to state 424
+
+
+state 426
+State 426
+
+ 137 position_not_place: position . '+' expr_pair
+ 138 | position . '-' expr_pair
@@ -2949,7 +2952,7 @@ dnl - 383 -> 427
+ '-' shift, and go to state 198
+
+
+state 427
+State 427
+
+ 134 position: . position_not_place
+ 135 | . place
+44 -34
View File
@@ -67,9 +67,13 @@ static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1)
return 0;
}
const char *input = NULL;
int
main (void)
main (int argc, const char* argv[])
{
assert (argc == 2);
input = argv[1];
return yyparse ();
}
@@ -78,16 +82,7 @@ main (void)
int
yylex (void)
{
for (;;)
{
int ch;
assert (!feof (stdin));
ch = getchar ();
if (ch == EOF)
return 0;
else if (ch == 'B' || ch == 'P')
return ch;
}
return *input++;
}
]])
AT_BISON_OPTION_POPDEFS
@@ -96,7 +91,7 @@ AT_BISON_CHECK([[-o glr-regr1.c glr-regr1.y]], 0, [],
[glr-regr1.y: conflicts: 1 shift/reduce
])
AT_COMPILE([glr-regr1])
AT_PARSER_CHECK([[echo BPBPB | ./glr-regr1]], 0,
AT_PARSER_CHECK([[./glr-regr1 BPBPB]], 0,
[[E -> 'B'
E -> 'B'
E -> E 'P' E
@@ -201,8 +196,12 @@ int
main (int argc, char **argv)
{
input = stdin;
if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
return yyparse ();
if (argc == 2 && !(input = fopen (argv[1], "r")))
return 3;
int res = yyparse ();
if (argc == 2 && fclose (input))
return 4;
return res;
}
]])
AT_BISON_OPTION_POPDEFS
@@ -212,16 +211,27 @@ AT_BISON_CHECK([[-o glr-regr2a.c glr-regr2a.y]], 0, [],
])
AT_COMPILE([glr-regr2a])
AT_PARSER_CHECK([[echo s VARIABLE_1 t v x q | ./glr-regr2a]], 0,
AT_DATA([input1.txt],
[[s VARIABLE_1 t v x q
]])
AT_PARSER_CHECK([[./glr-regr2a input1.txt]], 0,
[[Variable: 'VARIABLE_1'
]], [])
AT_PARSER_CHECK([[echo s VARIABLE_1 , ANOTHER_VARIABLE_2 t e | ./glr-regr2a]],
]])
AT_DATA([input2.txt],
[[s VARIABLE_1 , ANOTHER_VARIABLE_2 t e
]])
AT_PARSER_CHECK([[./glr-regr2a input2.txt]],
0,
[[Varlist: 'VARIABLE_1,ANOTHER_VARIABLE_2'
]])
AT_PARSER_CHECK([[echo s VARIABLE_3 t v x | ./glr-regr2a]], 0,
AT_DATA([input3.txt],
[[s VARIABLE_3 t v x
]])
AT_PARSER_CHECK([[./glr-regr2a input3.txt]], 0,
[[Variable: 'VARIABLE_3'
]], [])
]])
AT_CLEANUP
@@ -318,8 +328,12 @@ int
main(int argc, char* argv[])
{
input = stdin;
if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
return yyparse ();
if (argc == 2 && !(input = fopen (argv[1], "r")))
return 3;
int res = yyparse ();
if (argc == 2 && fclose (input))
return 4;
return res;
}
]])
AT_BISON_OPTION_POPDEFS
@@ -329,10 +343,13 @@ AT_BISON_CHECK([[-o glr-regr3.c glr-regr3.y]], 0, [],
])
AT_COMPILE([glr-regr3])
AT_PARSER_CHECK([[echo p1 t4 o2 p1 p1 t1 o1 t2 p2 o1 t3 p2 p2 | ./glr-regr3]],
AT_DATA([input.txt],
[[p1 t4 o2 p1 p1 t1 o1 t2 p2 o1 t3 p2 p2
]])
AT_PARSER_CHECK([[./glr-regr3 input.txt]],
0,
[[Result: 1c04
]], [])
]])
AT_CLEANUP
@@ -1543,13 +1560,6 @@ AT_DATA_GRAMMAR([glr-regr17.y],
]AT_YYLEX_DECLARE[
%}
%initial-action {
@$.first_line = 1;
@$.first_column = 1;
@$.last_line = 1;
@$.last_column = 1;
}
%%
/* Tests the case of an empty RHS that has inherited the location of the
@@ -1650,10 +1660,10 @@ main (void)
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
[glr-regr18.y:26.18-24: result type clash on merge function 'merge': <type2> != <type1>
glr-regr18.y:25.18-24: previous declaration
glr-regr18.y:27.13-19: result type clash on merge function 'merge': <type3> != <type2>
glr-regr18.y:26.18-24: previous declaration
[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
+54 -17
View File
@@ -126,11 +126,12 @@ AT_SETUP([Several parsers])
# AT_TEST([PREFIX], [DIRECTIVES])
# -------------------------------
# Generate and compile to *.o. Make sure there is no YY* nor yy* in
# the header (but YYDEBUG and YYPARSE_PARAM).
# Generate and compile to *.o. Make sure there is no (allowed) YY*
# nor yy* identifiers in the header. Check that headers are
# self-contained, and can be compiled by a C++ compiler.
m4_pushdef([AT_TEST],
[AT_BISON_OPTION_PUSHDEFS([%define api.prefix "$1_" $2])
AT_DATA_GRAMMAR([$1.AT_SKEL_CC_IF([yy], [y])],
AT_DATA_GRAMMAR([$1.y],
[[%define api.prefix "$1_"
$2
%error-verbose
@@ -160,21 +161,9 @@ exp:
]AT_YYLEX_DEFINE(["$1"])[
]])
AT_BISON_CHECK([-d -o AT_SKEL_CC_IF([$1.cc $1.yy], [$1.c $1.y])])
# C++ output relies on namespaces and still uses yy a lot.
AT_SKEL_CC_IF([],
[AT_CHECK([$EGREP yy $1.h], [1])])
AT_BISON_CHECK([-d -o $1.AT_SKEL_CC_IF([cc], [c]) $1.y])
# Ignore comments. Ignore YYPARSE_PARAM (obsolete) and
# YYPUSH_MORE(_DEFINED)? (whose definition is constant).
#
# YYDEBUG (not renamed) can be read, but not changed.
AT_CHECK([[sed -ne 's,/\*[^*]*\*/,,g;s,//.*,,' \
-e '/YY/p' ]$1.AT_SKEL_CC_IF([hh], [h])[ |
$EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?)|(defined|if) YYDEBUG']],
[1])
AT_LANG_COMPILE([$1.o])
AT_CHECK([[echo "$1" >>expout]])
AT_BISON_OPTION_POPDEFS
@@ -236,8 +225,56 @@ AT_TEST([x7], [%define api.push-pull both])
AT_TEST([x8], [%define api.pure %define api.push-pull both])
#AT_TEST([x5], [%locations %language "c++" %glr-parser])
# Check there is no 'yy' left.
# C++ output relies on namespaces and still uses yy a lot.
#
# Check there is no 'YY' left.
# Ignore comments, YYChar (template parameter), YYPARSE_PARAM
# (obsolete), YYPUSH_MORE(_DEFINED)? (constant definition),
# YY_\w+_INCLUDED (header guards).
#
# YYDEBUG (not renamed) can be read, but not changed.
AT_CHECK([[$PERL -n -0777 -e '
s{/\*.*?\*/}{}gs;
s{//.*}{}g;
s{\b(YYChar
|YYPARSE_PARAM
|YYPUSH_MORE(_DEFINED)?
|YY_\w+_INCLUDED
|YY_NULL
|(defined|if)\ YYDEBUG
)\b}{}gx;
while (/^(.*YY.*)$/gm)
{
print "$ARGV: invalid exported YY: $1\n";
}
if ($ARGV =~ /\.h$/)
{
while (/^(.*yy.*)$/gm)
{
print "$ARGV: invalid exported yy: $1\n";
}
}
' -- *.hh *.h]])
# Check that the headers are self-contained, and protected against
# multiple inclusions. While at it, check they are sane for C++.
for h in *.h *.hh
do
# No shell expansion with AT_DATA.
cat >$h.cc <<EOF
AT_DATA_SOURCE_PROLOGUE
#include "$h"
#include "$h"
EOF
AT_COMPILE_CXX([$h.o])
done
# Do this late, so that other checks have been performed.
AT_SKIP_IF_CANNOT_LINK_C_AND_CXX
AT_COMPILE_CXX([parser], [[x[1-8].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
AT_CHECK([./parser], [0], [[expout]])
AT_PARSER_CHECK([./parser], [0], [[expout]])
m4_popdef([AT_TEST])
+330 -144
View File
@@ -20,6 +20,63 @@ AT_BANNER([[Input Processing.]])
# Mostly test that we are robust to mistakes.
## ---------------- ##
## Invalid inputs. ##
## ---------------- ##
AT_SETUP([Invalid inputs])
AT_DATA([input.y],
[[\000\001\002\377?
%%
?
default: 'a' }
%&
%a-does-not-exist
%-
%{
]])
AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' input.y || exit 77]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:1.1-2: error: invalid characters: '\0\001\002\377?'
input.y:3.1: error: invalid character: '?'
input.y:4.14: error: invalid character: '}'
input.y:5.1: error: invalid character: '%'
input.y:5.2: error: invalid character: '&'
input.y:6.1-17: error: invalid directive: '%a-does-not-exist'
input.y:7.1: error: invalid character: '%'
input.y:7.2: error: invalid character: '-'
input.y:8.1-9.0: error: missing '%}' at end of file
input.y:8.1-9.0: error: syntax error, unexpected %{...%}
]])
AT_CLEANUP
AT_SETUP([Invalid inputs with {}])
# We used to SEGV here. See
# http://lists.gnu.org/archive/html/bug-bison/2005-07/msg00053.html
AT_DATA([input.y],
[[
%destructor
%initial-action
%lex-param
%parse-param
%printer
%union
]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:3.1-15: error: syntax error, unexpected %initial-action, expecting {...}
]])
AT_CLEANUP
## ------------ ##
## Invalid $n. ##
## ------------ ##
@@ -33,8 +90,8 @@ exp: { @$ = @1 ; };
]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:2.13-14: integer out of range: '$1'
input.y:3.13-14: integer out of range: '@1'
[[input.y:2.13-14: error: integer out of range: '$1'
input.y:3.13-14: error: integer out of range: '@1'
]])
AT_CLEANUP
@@ -58,8 +115,8 @@ exp: foo { $$; } foo { $2; } foo
]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:5.12-13: $$ for the midrule at $2 of 'exp' has no declared type
input.y:5.24-25: $2 of 'exp' has no declared type
[[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
@@ -205,30 +262,30 @@ start: ;
]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:1.13-29: redeclaration for default tagged %destructor
input.y:1.13-29: previous declaration
input.y:2.10-24: redeclaration for default tagged %printer
input.y:2.10-24: previous declaration
input.y:4.13-29: redeclaration for default tagged %destructor
input.y:1.13-29: previous declaration
input.y:5.10-24: redeclaration for default tagged %printer
input.y:2.10-24: previous declaration
input.y:7.13-29: redeclaration for default tagless %destructor
input.y:7.13-29: previous declaration
input.y:8.10-24: redeclaration for default tagless %printer
input.y:8.10-24: previous declaration
input.y:10.13-29: redeclaration for default tagless %destructor
input.y:7.13-29: previous declaration
input.y:11.10-24: redeclaration for default tagless %printer
input.y:8.10-24: previous declaration
input.y:17.13-29: redeclaration for default tagged %destructor
input.y:4.13-29: previous declaration
input.y:18.10-24: redeclaration for default tagged %printer
input.y:5.10-24: previous declaration
input.y:20.13-29: redeclaration for default tagless %destructor
input.y:10.13-29: previous declaration
input.y:21.10-24: redeclaration for default tagless %printer
input.y:11.10-24: previous declaration
[[input.y:1.13-29: error: redeclaration for default tagged %destructor
input.y:1.13-29: previous declaration
input.y:2.10-24: error: redeclaration for default tagged %printer
input.y:2.10-24: previous declaration
input.y:4.13-29: error: redeclaration for default tagged %destructor
input.y:1.13-29: previous declaration
input.y:5.10-24: error: redeclaration for default tagged %printer
input.y:2.10-24: previous declaration
input.y:7.13-29: error: redeclaration for default tagless %destructor
input.y:7.13-29: previous declaration
input.y:8.10-24: error: redeclaration for default tagless %printer
input.y:8.10-24: previous declaration
input.y:10.13-29: error: redeclaration for default tagless %destructor
input.y:7.13-29: previous declaration
input.y:11.10-24: error: redeclaration for default tagless %printer
input.y:8.10-24: previous declaration
input.y:17.13-29: error: redeclaration for default tagged %destructor
input.y:4.13-29: previous declaration
input.y:18.10-24: error: redeclaration for default tagged %printer
input.y:5.10-24: previous declaration
input.y:20.13-29: error: redeclaration for default tagless %destructor
input.y:10.13-29: previous declaration
input.y:21.10-24: error: redeclaration for default tagless %printer
input.y:11.10-24: previous declaration
]])
AT_CLEANUP
@@ -256,22 +313,22 @@ start: ;
]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:4.13-29: %destructor redeclaration for <field1>
input.y:1.13-29: previous declaration
input.y:4.13-29: %destructor redeclaration for <field1>
input.y:4.13-29: previous declaration
input.y:5.10-24: %printer redeclaration for <field2>
input.y:2.10-24: previous declaration
input.y:5.10-24: %printer redeclaration for <field2>
input.y:5.10-24: previous declaration
input.y:11.13-29: %destructor redeclaration for <field1>
input.y:4.13-29: previous declaration
input.y:11.13-29: %destructor redeclaration for <field2>
input.y:1.13-29: previous declaration
input.y:12.10-24: %printer redeclaration for <field1>
input.y:2.10-24: previous declaration
input.y:12.10-24: %printer redeclaration for <field2>
input.y:5.10-24: previous declaration
[[input.y:4.13-29: error: %destructor redeclaration for <field1>
input.y:1.13-29: previous declaration
input.y:4.13-29: error: %destructor redeclaration for <field1>
input.y:4.13-29: previous declaration
input.y:5.10-24: error: %printer redeclaration for <field2>
input.y:2.10-24: previous declaration
input.y:5.10-24: error: %printer redeclaration for <field2>
input.y:5.10-24: previous declaration
input.y:11.13-29: error: %destructor redeclaration for <field1>
input.y:4.13-29: previous declaration
input.y:11.13-29: error: %destructor redeclaration for <field2>
input.y:1.13-29: previous declaration
input.y:12.10-24: error: %printer redeclaration for <field1>
input.y:2.10-24: previous declaration
input.y:12.10-24: error: %printer redeclaration for <field2>
input.y:5.10-24: previous declaration
]])
AT_CLEANUP
@@ -368,14 +425,14 @@ exp: foo;
]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:8.7-11: %type redeclaration for foo
input.y:3.7-11: previous declaration
input.y:10.13-17: %destructor redeclaration for foo
input.y:5.13-17: previous declaration
input.y:9.10-14: %printer redeclaration for foo
input.y:4.10-14: previous declaration
input.y:11.1-5: %left redeclaration for foo
input.y:6.1-5: previous declaration
[[input.y:8.7-11: error: %type redeclaration for foo
input.y:3.7-11: previous declaration
input.y:10.13-17: error: %destructor redeclaration for foo
input.y:5.13-17: previous declaration
input.y:9.10-14: error: %printer redeclaration for foo
input.y:4.10-14: previous declaration
input.y:11.1-5: error: %left redeclaration for foo
input.y:6.1-5: previous declaration
]])
AT_CLEANUP
@@ -394,7 +451,7 @@ AT_SETUP([Torturing the Scanner])
AT_BISON_OPTION_PUSHDEFS
AT_DATA([input.y], [])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:1.1: syntax error, unexpected end of file
[[input.y:1.1: error: syntax error, unexpected end of file
]])
@@ -402,7 +459,7 @@ AT_DATA([input.y],
[{}
])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:1.1-2: syntax error, unexpected {...}
[[input.y:1.1-2: error: syntax error, unexpected {...}
]])
@@ -668,9 +725,9 @@ AT_DATA_GRAMMAR([input.y],
start: .GOOD GOOD
]])
AT_BISON_CHECK([-o input.c input.y], [1], [],
[[input.y:10.10: invalid character: '-'
input.y:11.10-16: invalid identifier: '1NV4L1D'
input.y:12.10: invalid character: '-'
[[input.y:10.10: error: invalid character: '-'
input.y:11.10-16: error: invalid identifier: '1NV4L1D'
input.y:12.10: error: invalid character: '-'
]])
AT_CLEANUP
@@ -692,10 +749,10 @@ start: DECIMAL_1 HEXADECIMAL_2;
]])
AT_BISON_CHECK([redecl.y], [1], [],
[[redecl.y:10.10-22: user token number 11259375 redeclaration for HEXADECIMAL_1
redecl.y:9.8-16: previous declaration for DECIMAL_1
redecl.y:12.10-18: user token number 16702650 redeclaration for DECIMAL_2
redecl.y:11.10-22: previous declaration for HEXADECIMAL_2
[[redecl.y:10.10-22: error: user token number 11259375 redeclaration for HEXADECIMAL_1
redecl.y:9.8-16: previous declaration for DECIMAL_1
redecl.y:12.10-18: error: user token number 16702650 redeclaration for DECIMAL_2
redecl.y:11.10-22: previous declaration for HEXADECIMAL_2
]])
AT_DATA_GRAMMAR([too-large.y],
@@ -707,8 +764,8 @@ start: TOO_LARGE_DEC TOO_LARGE_HEX
]])
AT_BISON_CHECK([too-large.y], [1], [],
[[too-large.y:9.22-42: integer out of range: '999999999999999999999'
too-large.y:10.24-44: integer out of range: '0xFFFFFFFFFFFFFFFFFFF'
[[too-large.y:9.22-42: error: integer out of range: '999999999999999999999'
too-large.y:10.24-44: error: integer out of range: '0xFFFFFFFFFFFFFFFFFFF'
]])
AT_CLEANUP
@@ -748,12 +805,31 @@ start: ;
]])
AT_BISON_CHECK([-o input.c input.y], 1, [],
[[input.y:1.10-2.0: missing '"' at end of line
input.y:4.10-5.0: missing "'" at end of line
input.y:14.11-15.0: missing "'" at end of line
input.y:16.11-17.0: missing '"' at end of line
input.y:19.13-20.0: missing '}' at end of file
input.y:20.1: syntax error, unexpected end of file
[[input.y:1.10-2.0: error: missing '"' at end of line
input.y:4.10-5.0: error: missing "'" at end of line
input.y:14.11-15.0: error: missing "'" at end of line
input.y:16.11-17.0: error: missing '"' at end of line
input.y:19.13-20.0: error: missing '}' at end of file
input.y:20.1: error: syntax error, unexpected end of file
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], 1, [],
[[input.y:1.10-2.0: error: missing '"' at end of line
%token A "a
^^
input.y:4.10-5.0: error: missing "'" at end of line
%token C '1
^^
input.y:14.11-15.0: error: missing "'" at end of line
%type <f> 'a
^^
input.y:16.11-17.0: error: missing '"' at end of line
%type <f> "a
^^
input.y:19.13-20.0: error: missing '}' at end of file
%destructor { free ($$)
^^^^^^^^^^^
input.y:20.1: error: syntax error, unexpected end of file
]])
AT_CLEANUP
@@ -795,7 +871,7 @@ PREC: ;
]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:3.1-4: rule given for PREC, which is a token
[[input.y:3.1-4: error: rule given for PREC, which is a token
]])
AT_CLEANUP
@@ -836,10 +912,10 @@ AT_DATA([input-c.y],
start: ;
]])
AT_BISON_CHECK([[input-c.y]], [[1]], [],
[[input-c.y:1.7: %code qualifier 'q' is not used
input-c.y:2.7-9: %code qualifier 'bad' is not used
input-c.y:3.7-9: %code qualifier 'bad' is not used
input-c.y:4.7-12: %code qualifier 'format' is not used
[[input-c.y:1.7: error: %code qualifier 'q' is not used
input-c.y:2.7-9: error: %code qualifier 'bad' is not used
input-c.y:3.7-9: error: %code qualifier 'bad' is not used
input-c.y:4.7-12: error: %code qualifier 'format' is not used
]])
AT_DATA([input-c-glr.y],
@@ -850,9 +926,9 @@ AT_DATA([input-c-glr.y],
start: ;
]])
AT_BISON_CHECK([[input-c-glr.y]], [[1]], [],
[[input-c-glr.y:1.7: %code qualifier 'q' is not used
input-c-glr.y:2.7-9: %code qualifier 'bad' is not used
input-c-glr.y:3.8-10: %code qualifier 'bad' is not used
[[input-c-glr.y:1.7: error: %code qualifier 'q' is not used
input-c-glr.y:2.7-9: error: %code qualifier 'bad' is not used
input-c-glr.y:3.8-10: error: %code qualifier 'bad' is not used
]])
AT_DATA([input-c++.y],
@@ -863,9 +939,9 @@ AT_DATA([input-c++.y],
start: ;
]])
AT_BISON_CHECK([[input-c++.y]], [[1]], [],
[[input-c++.y:1.7: %code qualifier 'q' is not used
input-c++.y:2.7-9: %code qualifier 'bad' is not used
input-c++.y:3.8: %code qualifier 'q' is not used
[[input-c++.y:1.7: error: %code qualifier 'q' is not used
input-c++.y:2.7-9: error: %code qualifier 'bad' is not used
input-c++.y:3.8: error: %code qualifier 'q' is not used
]])
AT_DATA([input-c++-glr.y],
@@ -876,9 +952,9 @@ AT_DATA([input-c++-glr.y],
start: ;
]])
AT_BISON_CHECK([[input-c++-glr.y]], [[1]], [],
[[input-c++-glr.y:1.7-9: %code qualifier 'bad' is not used
input-c++-glr.y:2.7: %code qualifier 'q' is not used
input-c++-glr.y:3.7: %code qualifier 'q' is not used
[[input-c++-glr.y:1.7-9: error: %code qualifier 'bad' is not used
input-c++-glr.y:2.7: error: %code qualifier 'q' is not used
input-c++-glr.y:3.7: error: %code qualifier 'q' is not used
]])
AT_DATA([special-char-@@.y],
@@ -889,9 +965,9 @@ AT_DATA([special-char-@@.y],
start: ;
]])
AT_BISON_CHECK([[special-char-@@.y]], [[1]], [],
[[special-char-@@.y:1.7-9: %code qualifier 'bad' is not used
special-char-@@.y:2.7: %code qualifier 'q' is not used
special-char-@@.y:3.7: %code qualifier 'q' is not used
[[special-char-@@.y:1.7-9: error: %code qualifier 'bad' is not used
special-char-@@.y:2.7: error: %code qualifier 'q' is not used
special-char-@@.y:3.7: error: %code qualifier 'q' is not used
]])
AT_DATA([special-char-@:>@.y],
@@ -902,9 +978,9 @@ AT_DATA([special-char-@:>@.y],
start: ;
]])
AT_BISON_CHECK([[special-char-@:>@.y]], [[1]], [],
[[special-char-@:>@.y:1.7-9: %code qualifier 'bad' is not used
special-char-@:>@.y:2.7: %code qualifier 'q' is not used
special-char-@:>@.y:3.7: %code qualifier 'q' is not used
[[special-char-@:>@.y:1.7-9: error: %code qualifier 'bad' is not used
special-char-@:>@.y:2.7: error: %code qualifier 'q' is not used
special-char-@:>@.y:3.7: error: %code qualifier 'q' is not used
]])
AT_CLEANUP
@@ -927,10 +1003,10 @@ start: ;
]])
AT_BISON_CHECK([[input-redefined.y]], [[1]], [],
[[input-redefined.y:2.9-11: %define variable 'var' redefined
input-redefined.y:1.9-11: previous definition
input-redefined.y:3.10-12: %define variable 'var' redefined
input-redefined.y:2.9-11: previous definition
[[input-redefined.y:2.9-11: error: %define variable 'var' redefined
input-redefined.y:1.9-11: previous definition
input-redefined.y:3.10-12: error: %define variable 'var' redefined
input-redefined.y:2.9-11: previous definition
]])
AT_DATA([input-unused.y],
@@ -940,7 +1016,7 @@ start: ;
]])
AT_BISON_CHECK([[input-unused.y]], [[1]], [],
[[input-unused.y:1.9-11: %define variable 'var' is not used
[[input-unused.y:1.9-11: error: %define variable 'var' is not used
]])
AT_CLEANUP
@@ -984,8 +1060,20 @@ AT_DATA([[input-dg.y]],
start: ;
]])
AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [],
[[input-dg.y:1.9-11: %define variable 'var' redefined
<command line>:2: previous definition
[[input-dg.y:1.9-11: error: %define variable 'var' redefined
<command line>:1: previous definition
]])
AT_DATA([[input-dg.y]],
[[%define var "gram"
%%
start: ;
]])
AT_BISON_CHECK([[-fcaret -Dvar=cmd-d input-dg.y]], [[1]], [],
[[input-dg.y:1.9-11: error: %define variable 'var' redefined
%define var "gram"
^^^
<command line>:2: previous definition
]])
AT_DATA([[input-unused.y]],
@@ -993,8 +1081,8 @@ AT_DATA([[input-unused.y]],
start: ;
]])
AT_BISON_CHECK([[-Dunused-d -Funused-f input-unused.y]], [[1]], [],
[[<command line>:2: %define variable 'unused-d' is not used
<command line>:3: %define variable 'unused-f' is not used
[[<command line>:1: error: %define variable 'unused-d' is not used
<command line>:2: error: %define variable 'unused-f' is not used
]])
AT_CLEANUP
@@ -1014,7 +1102,7 @@ start: ;
]])
AT_BISON_CHECK([[Input.y]], [1], [],
[[Input.y:2.9-14: invalid value for %define Boolean variable 'public'
[[Input.y:2.9-14: error: invalid value for %define Boolean variable 'public'
]])
AT_CLEANUP
@@ -1032,23 +1120,24 @@ AT_DATA([[input.y]],
start: ;
]])
AT_BISON_CHECK([[input.y]], [[1]], [[]],
[[input.y:1.9-29: 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-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'
]])
# Back-end.
# FIXME: these should be indented, but we shouldn't mess with the m4 yet
AT_DATA([[input.y]],
[[%define api.push-pull neither
%%
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
[[input.y:1.9-21: 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'
[[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'
]])
AT_CLEANUP
@@ -1068,10 +1157,10 @@ AT_DATA([[input.y]],
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
[[input.y:1.9-21: 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'
[[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'
]])
AT_DATA([[input.y]],
@@ -1080,7 +1169,7 @@ AT_DATA([[input.y]],
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
[[input.y:1.9-34: invalid value for %define Boolean variable 'lr.keep-unreachable-states'
[[input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-states'
]])
AT_DATA([[input.y]],
@@ -1089,7 +1178,7 @@ AT_DATA([[input.y]],
start: ;
]])
AT_BISON_CHECK([[input.y]], [[1]], [],
[[input.y:1.9-15: %define variable 'foo_bar' is not used
[[input.y:1.9-15: error: %define variable 'foo_bar' is not used
]])
AT_CLEANUP
@@ -1114,7 +1203,7 @@ start: ;
]])
AT_BISON_CHECK([[input.y]], [[1]], [],
[[input.y:1.9-16: %define variable 'api.pure' is not used
[[input.y:1.9-16: error: %define variable 'api.pure' is not used
]])
])
@@ -1148,7 +1237,7 @@ start: ;
AT_BISON_CHECK([[input.y]], [1], [],
[m4_foreach([b4_arg], m4_dquote(m4_shift($@)),
[[input.y:3.9-17: ]b4_arg[
[[input.y:3.9-17: error: ]b4_arg[
]])])
])
@@ -1194,14 +1283,14 @@ AT_DATA([empty.y],
start: '';
start: '
]])
AT_CHECK([[perl -e "print 'start: \'';" >> empty.y || exit 77]])
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:3.8-4.0: missing "'" at end of line
empty.y:3.8-4.0: error: missing "'" at end of line
empty.y:4.8: warning: empty character literal
empty.y:4.8: missing "'" at end of file
empty.y:4.8: error: missing "'" at end of file
]])
AT_DATA([two.y],
@@ -1209,14 +1298,14 @@ AT_DATA([two.y],
start: 'ab';
start: 'ab
]])
AT_CHECK([[perl -e "print 'start: \'ab';" >> two.y || exit 77]])
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:3.8-4.0: missing "'" at end of line
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: missing "'" at end of file
two.y:4.8-10: error: missing "'" at end of file
]])
AT_DATA([three.y],
@@ -1224,14 +1313,14 @@ AT_DATA([three.y],
start: 'abc';
start: 'abc
]])
AT_CHECK([[perl -e "print 'start: \'abc';" >> three.y || exit 77]])
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:3.8-4.0: missing "'" at end of line
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: missing "'" at end of file
three.y:4.8-11: error: missing "'" at end of file
]])
AT_CLEANUP
@@ -1253,34 +1342,34 @@ start: '\777' '\0' '\xfff' '\x0'
# Beside we cannot even expect "echo '\0'" to output two characters
# (well three with \n): at least Bash 3.2 converts the two-character
# sequence "\0" into a single NUL character.
AT_CHECK([[perl -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
|| exit 77]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:2.9-12: invalid number after \-escape: 777
[[input.y:2.9-12: error: invalid number after \-escape: 777
input.y:2.8-13: warning: empty character literal
input.y:2.16-17: invalid number after \-escape: 0
input.y:2.16-17: error: invalid number after \-escape: 0
input.y:2.15-18: warning: empty character literal
input.y:2.21-25: invalid number after \-escape: xfff
input.y:2.21-25: error: invalid number after \-escape: xfff
input.y:2.20-26: warning: empty character literal
input.y:2.29-31: invalid number after \-escape: x0
input.y:2.29-31: error: invalid number after \-escape: x0
input.y:2.28-32: warning: empty character literal
input.y:3.9-14: invalid number after \-escape: uffff
input.y:3.9-14: error: invalid number after \-escape: uffff
input.y:3.8-15: warning: empty character literal
input.y:3.18-23: invalid number after \-escape: u0000
input.y:3.18-23: error: invalid number after \-escape: u0000
input.y:3.17-24: warning: empty character literal
input.y:3.27-36: invalid number after \-escape: Uffffffff
input.y:3.27-36: error: invalid number after \-escape: Uffffffff
input.y:3.26-37: warning: empty character literal
input.y:3.40-49: invalid number after \-escape: U00000000
input.y:3.40-49: error: invalid number after \-escape: U00000000
input.y:3.39-50: warning: empty character literal
input.y:4.9-10: invalid character after \-escape: ' '
input.y:4.9-10: error: invalid character after \-escape: ' '
input.y:4.8-11: warning: empty character literal
input.y:4.14-15: invalid character after \-escape: A
input.y:4.14-15: error: invalid character after \-escape: A
input.y:4.13-16: warning: empty character literal
input.y:5.9-16: invalid character after \-escape: \t
input.y:5.17: invalid character after \-escape: \f
input.y:5.18: invalid character after \-escape: \0
input.y:5.19: invalid character after \-escape: \001
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
input.y:5.19: error: invalid character after \-escape: \001
]])
AT_CLEANUP
@@ -1299,11 +1388,11 @@ start: ;
# parse.lac.* options are useless if LAC isn't actually activated.
AT_BISON_CHECK([[-Dparse.lac.es-capacity-initial=1 input.y]],
[[1]], [],
[[<command line>:2: %define variable 'parse.lac.es-capacity-initial' is not used
[[<command line>:1: error: %define variable 'parse.lac.es-capacity-initial' is not used
]])
AT_BISON_CHECK([[-Dparse.lac.memory-trace=full input.y]],
[[1]], [],
[[<command line>:2: %define variable 'parse.lac.memory-trace' is not used
[[<command line>:1: error: %define variable 'parse.lac.memory-trace' is not used
]])
AT_CLEANUP
@@ -1357,15 +1446,112 @@ m4_pushdef([AT_TEST],
exp:;
]])
AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
[[$3: '%name-prefix' and '%define api.prefix' cannot be used together
[[$3: error: '%name-prefix' and '%define api.prefix' cannot be used together
]])
])
AT_TEST([%define api.prefix foo %name-prefix "bar"], [], [input.y:1.9-18])
AT_TEST([], [-Dapi.prefix=foo -p bar], [<command line>:2])
AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [<command line>:2])
AT_TEST([], [-Dapi.prefix=foo -p bar], [<command line>:1])
AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [<command line>:1])
AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18])
m4_popdef([AT_TEST])
AT_CLEANUP
## -------------- ##
## Stray $ or @. ##
## -------------- ##
AT_SETUP([[Stray $ or @]])
# Give %printer and %destructor "<*> exp TOK" instead of "<*>" to
# check that the warnings are reported once, not three times.
AT_DATA_GRAMMAR([[input.y]],
[[%token TOK
%destructor { $%; @%; } <*> exp TOK;
%initial-action { $%; @%; };
%printer { $%; @%; } <*> exp TOK;
%%
exp: TOK { $%; @%; $$ = $1; };
]])
AT_BISON_CHECK([[input.y]], 0, [],
[[input.y:10.19: warning: stray '$'
input.y:10.23: warning: stray '@'
input.y:11.19: warning: stray '$'
input.y:11.23: warning: stray '@'
input.y:12.19: warning: stray '$'
input.y:12.23: warning: stray '@'
input.y:14.19: warning: stray '$'
input.y:14.23: warning: stray '@'
]])
AT_CLEANUP
## ---------------- ##
## Code injection. ##
## ---------------- ##
AT_SETUP([[Code injection]])
m4_pattern_allow([^m4_errprintn$])
# AT_TEST([MACRO])
# ----------------
# Try to have MACRO be run by bison.
m4_pushdef([AT_TEST],
[AT_DATA([[input.y]],
[[%type <$1(DEAD %type)> exp
%token <$1(DEAD %token)> a
%initial-action
{
$$;
$<$1(DEAD %initial-action)>$
};
%printer
{
$$
$<$1(DEAD %printer)>$
} <> <*>;
%lex-param
{
$1(DEAD %lex-param)
};
%parse-param
{
$1(DEAD %parse-param)
};
%%
exp:
a a[last]
{
$$;
$][1;
$<$1(DEAD action 1)>$
$<$1(DEAD action 2)>1
$<$1(DEAD action 3)>last
$<$1(DEAD action 4)>0
;
};
]])
# FIXME: Provide a means to iterate over all the skeletons.
AT_BISON_CHECK([[-d input.y]])
AT_BISON_CHECK([[-d -S glr.c input.y]])
AT_BISON_CHECK([[-d -S lalr1.cc input.y]])
AT_BISON_CHECK([[-d -S glr.cc input.y]])
AT_BISON_CHECK([[ -S lalr1.java input.y]])
])
AT_TEST([m4_errprintn])
AT_TEST([@:>@m4_errprintn])
m4_popdef([AT_TEST])
AT_CLEANUP
+4 -4
View File
@@ -719,8 +719,8 @@ AT_SETUP([Java stype, position_class and location_class])
AT_CHECK_JAVA_MINIMAL([[
%define stype "java.awt.Color"
%type<java.awt.Color> start;
%define location_type "MyLoc"
%define position_type "MyPos"
%define api.location.type "MyLoc"
%define api.position.type "MyPos"
%code { class MyPos {} }]], [[$$ = $<java.awt.Color>1;]], [[MyPos]])
AT_CHECK([[grep 'java.awt.Color' YYParser.java]], [0], [ignore])
AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Position']], [1], [ignore])
@@ -729,8 +729,8 @@ AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Location']], [1], [ignore])
AT_CHECK_JAVA_MINIMAL_W_LEXER([[
%define stype "java.awt.Color"
%type<java.awt.Color> start;
%define location_type "MyLoc"
%define position_type "MyPos"
%define api.location.type "MyLoc"
%define api.position.type "MyPos"
%code { class MyPos {} }]], [], [[return EOF;]], [],
[[$$ = $<java.awt.Color>1;]],
[[java.awt.Color]], [[MyPos]], [[MyLoc]])
+91 -39
View File
@@ -38,7 +38,7 @@ m4_define([m4_null_if],
# Expect COUNT matches of the PERL-REGEXP in FILE. The file is
# taken in "slurp" mode, i.e., one can match end-of-lines.
m4_define([AT_MATCHES_CHECK],
[AT_CHECK([perl -0777 -ne '
[AT_CHECK([$PERL -0777 -ne '
my $count = 0;
s{$2}{ ++$count; "" }gem;
printf "$count\n";' $1], [0], [$3
@@ -119,6 +119,7 @@ m4_pushdef([AT_SKEL_CC_IF],
[m4_bmatch([$3], [%language "[Cc]\+\+"\|%skeleton "[a-z0-9]+\.cc"], [$1], [$2])])
m4_pushdef([AT_SKEL_JAVA_IF],
[m4_bmatch([$3], [%language "[Jj][Aa][Vv][Aa]"\|%skeleton "[a-z0-9]+\.java"], [$1], [$2])])
# The target language: "c", "c++", or "java".
m4_pushdef([AT_LANG],
[AT_SKEL_JAVA_IF([java],
[AT_SKEL_CC_IF([c++],
@@ -137,17 +138,19 @@ m4_pushdef([AT_LEXPARAM_IF],
m4_pushdef([AT_LOCATION_IF],
[m4_bmatch([$3], [%locations], [$1], [$2])])
m4_pushdef([AT_LOCATION_TYPE_IF],
[m4_bmatch([$3], [%define location_type], [$1], [$2])])
[m4_bmatch([$3], [%define \(api\.location\.type\|location_type\)], [$1], [$2])])
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, ".
m4_pushdef([AT_PARSE_PARAMS])
m4_bpatsubst([$3], [%parse-param { *\([^{}]*[^{} ]\) *}],
[m4_append([AT_PARSE_PARAMS], [\1, ])])
m4_pushdef([AT_PURE_IF],
[m4_bmatch([$3], [%define *api\.pure\|%pure-parser],
[m4_bmatch([$3], [%define *api\.pure *"?false"?], [$2], [$1])],
[$2])])
m4_pushdef([AT_PURE_AND_LOC_IF],
[m4_bmatch([$3], [%locations], [AT_PURE_IF($@)], [$2])])
m4_pushdef([AT_GLR_OR_PARAM_IF],
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
m4_pushdef([AT_NAME_PREFIX],
[m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"],
[m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])],
@@ -158,17 +161,29 @@ m4_pushdef([AT_API_prefix],
[yy])])
m4_pushdef([AT_API_PREFIX],
[m4_toupper(AT_API_prefix)])
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
# yyerror receives the location if %location, and if the parser is pure. For
# historical reasons, with the "yacc.c" skeleton, the location is not passed
# unless an additional "%parse-param" is present, or if the purity is defined
# as "full".
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
[$2])])
# yyerror always sees the locations (when activated), except if
# (yacc & pure & !param). FIXME: This is wrong. See the manual.
[AT_LOCATION_IF([AT_PURE_IF([m4_bmatch([$3],
m4_quote(m4_join([\|],
[%define api.pure "?full"?],
[%glr-parser],
[%parse-param],
[%skeleton "?glr.c"?])),
[$1], [$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
# argument.
m4_pushdef([AT_YYERROR_SEES_LOC_IF],
[AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
[$1])],
[$1])],
[$2])])
[AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_YYERROR_ARG_LOC_IF([$1], [$2])],
[$1])],
[$1])],
[$2])])
# The interface is pure: either because %define api.pure, or because we
# are using the C++ parsers.
@@ -237,10 +252,9 @@ m4_popdef([AT_YYERROR_ARG_LOC_IF])
m4_popdef([AT_API_PREFIX])
m4_popdef([AT_API_prefix])
m4_popdef([AT_NAME_PREFIX])
m4_popdef([AT_GLR_OR_PARAM_IF])
m4_popdef([AT_PURE_AND_LOC_IF])
m4_popdef([AT_LOCATION_TYPE_IF])
m4_popdef([AT_LOCATION_IF])
m4_popdef([AT_PARSE_PARAMS])
m4_popdef([AT_PARAM_IF])
m4_popdef([AT_LEXPARAM_IF])
m4_popdef([AT_YACC_IF])
@@ -333,7 +347,7 @@ static
static size_t toknum = 0;
int res;
]AT_USE_LEX_ARGS[;
assert (toknum < sizeof input);
assert (toknum < sizeof input / sizeof input[0]);
res = input[toknum++];
]$2[;]AT_LOCATION_IF([[
]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1;
@@ -342,6 +356,7 @@ static
}]dnl
])
# AT_YYERROR_FORMALS
# AT_YYERROR_PROTOTYPE
# AT_YYERROR_DECLARE_EXTERN
# AT_YYERROR_DECLARE
@@ -350,7 +365,7 @@ static
# Must be called inside a AT_BISON_OPTION_PUSHDEFS/POPDEFS pair.
m4_define([AT_YYERROR_FORMALS],
[m4_case(AT_LANG,
[c], [AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])[const char *msg]])[]dnl
[c], [AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE const * const llocp, ])AT_PARSE_PARAMS [const char *msg]])[]dnl
])
m4_define([AT_YYERROR_PROTOTYPE],
@@ -374,16 +389,11 @@ m4_define([AT_YYERROR_DEFINE],
/* A C error reporting function. */
static
]AT_YYERROR_PROTOTYPE[
{
]AT_YYERROR_SEES_LOC_IF([[
fprintf (stderr, "%d.%d",
]AT_LOC_FIRST_LINE[, ]AT_LOC_FIRST_COLUMN[);
if (]AT_LOC_FIRST_LINE[ != ]AT_LOC_LAST_LINE[)
fprintf (stderr, "-%d.%d",
]AT_LOC_LAST_LINE[, ]AT_LOC_LAST_COLUMN[ - 1);
else if (]AT_LOC_FIRST_COLUMN[ != ]AT_LOC_LAST_COLUMN[ - 1)
fprintf (stderr, "-%d",
]AT_LOC_LAST_COLUMN[ - 1);
{]m4_bpatsubst(m4_defn([AT_PARSE_PARAMS]),
[[^,]+[^A-Za-z_0-9]\([A-Za-z_][A-Za-z_0-9]*\), *], [
YYUSE(\1);])dnl
AT_YYERROR_SEES_LOC_IF([[
YY_LOCATION_PRINT (stderr, ]AT_LOC[);
fprintf (stderr, ": ");]])[
fprintf (stderr, "%s\n", msg);
}]],
@@ -405,7 +415,8 @@ void
public void yyerror (String s)
{
System.err.println (s);
}]])])dnl
}]])],
[m4_fatal([$0: invalid language: ]AT_LANG)])dnl
])
@@ -461,10 +472,10 @@ m4_define([AT_BISON_CHECK_WARNINGS],
[m4_null_if([$2], [AT_BISON_CHECK_WARNINGS_($@)])])])
m4_define([AT_BISON_CHECK_WARNINGS_],
[[# Defining POSIXLY_CORRECT causes bison to complain if options
# are added after the grammar file name, so skip these checks
# in that case.
if test -z "${POSIXLY_CORRECT+set}"; then
[[# Defining POSIXLY_CORRECT causes bison to complain if options are
# added after the grammar file name, so skip these checks in that
# case.
if test "$POSIXLY_CORRECT_IS_EXPORTED" = false; then
]AT_SAVE_SPECIAL_FILES[
# To avoid expanding it repeatedly, store specified stdout.
@@ -552,10 +563,10 @@ m4_define([AT_BISON_CHECK_XML],
AT_CHECK([[$XSLTPROC \
`]]AT_QUELL_VALGRIND[[ bison --print-datadir`/xslt/xml2text.xsl \
xml-tests/test.xml]], [[0]], [expout])
[cp xml-tests/test.dot expout]
[sort xml-tests/test.dot > expout]
AT_CHECK([[$XSLTPROC \
`]]AT_QUELL_VALGRIND[[ bison --print-datadir`/xslt/xml2dot.xsl \
xml-tests/test.xml]], [[0]], [expout])
xml-tests/test.xml | sort]], [[0]], [expout])
[rm -rf xml-tests expout]
AT_RESTORE_SPECIAL_FILES
[fi]])
@@ -589,7 +600,10 @@ m4_define([AT_QUELL_VALGRIND],
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".c" appended.
m4_define([AT_COMPILE],
[AT_CHECK(m4_join([ ],
[AT_CHECK([case $POSIXLY_CORRECT_IS_EXPORTED:$C_COMPILER_POSIXLY_CORRECT in
true:false) echo 'cannot compile properly with POSIXLY_CORRECT' && exit 77;;
esac])
AT_CHECK(m4_join([ ],
[$CC $CFLAGS $CPPFLAGS],
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
[-o $1],
@@ -675,6 +689,44 @@ m4_define([AT_FULL_COMPILE],
])
# AT_SKIP_IF_CANNOT_LINK_C_AND_CXX
# --------------------------------
# Check that we can link together C and C++ objects.
m4_define([AT_SKIP_IF_CANNOT_LINK_C_AND_CXX],
[AT_DATA([c-and-cxx.h],
[[#ifdef __cplusplus
extern "C"
{
#endif
int fortytwo (void);
#ifdef __cplusplus
}
#endif
]])
AT_DATA([c-only.c],
[[#include "c-and-cxx.h"
int
main (void)
{
return fortytwo () == 42 ? 0 : 1;
}
]])
AT_DATA([cxx-only.cc],
[[#include "c-and-cxx.h"
int fortytwo ()
{
return 42;
}
]])
AT_COMPILE([c-only.o], [c-only.c])
AT_COMPILE_CXX([cxx-only.o], [cxx-only.cc])
AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS $LDFLAGS c-only.o cxx-only.o -o c-and-cxx ||
exit 77], [ignore], [ignore])
AT_PARSER_CHECK([./c-and-cxx])
])
## ---------------------------- ##
## Running a generated parser. ##
## ---------------------------- ##
@@ -823,9 +875,9 @@ m4_if(m4_index(m4_quote($3), [no-xml]), -1,
[0], [], m4_dquote($7))
m4_if(m4_index(m4_quote($3), [last-state]), -1,
[AT_CHECK([[sed -n '/^state 0$/,$p' input.output]], [[0]],
[AT_CHECK([[sed -n '/^State 0$/,$p' input.output]], [[0]],
m4_dquote($8))],
[AT_CHECK([[sed -n 's/^state //p' input.output | tail -1]], [[0]],
[AT_CHECK([[sed -n 's/^State //p' input.output | tail -1]], [[0]],
m4_dquote($8)[[
]])])
+183 -62
View File
@@ -49,18 +49,18 @@ static int power (int base, int exponent);
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
%%
input:
line
| input line { }
| input line {}
;
line:
'\n'
| exp '\n' { }
| exp '\n' {}
;
exp:
@@ -69,15 +69,15 @@ exp:
{
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; }
| exp[l] '*' exp[r] { $$ = $l * $r; }
| exp[l] '-' exp[r] { $$ = $l - $r; }
| exp[l] '*' exp[r] { $$ = $l * $r; }
| exp[l] '/' exp[r] { $$ = $l / $r; }
| '-' exp %prec NEG { $$ = -$2; }
| exp[l] '^' exp[r] { $$ = power ($l, $r); }
| '(' exp[e] ')' { $$ = $e; }
| exp[l] '^' exp[r] { $$ = power ($l, $r); }
| '(' exp[e] ')' { $$ = $e; }
| '(' error ')' { $$ = 1111; yyerrok; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
@@ -214,18 +214,18 @@ static int power (int base, int exponent);
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
%%
input:
line
| input line { }
| input line {}
;
line:
'\n'
| exp '\n' { }
| exp '\n' {}
;
exp:
@@ -234,14 +234,14 @@ exp:
{
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; }
| exp[x] '*' { $<ival>$ = $x; } [l] exp[r] { $$ = $l * $r; }
| exp[l] '/' exp[r] { $$ = $l / $r; }
| '-' exp %prec NEG { $$ = -$2; }
| exp[l] '^' exp[r] { $$ = power ($l, $r12); }
| exp[l] '^' exp[r] { $$ = power ($l, $r12); }
| '(' exp ')' { $$ = $expo; }
| '(' error ')' { $$ = 1111; yyerrok; }
| '!' { $$ = 0; YYERROR; }
@@ -251,16 +251,16 @@ exp:
]])
AT_BISON_CHECK([-o test.c test.y], 1, [],
[[test.y:50.51-60: invalid reference: '$<ival>lo9'
[[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:42.1-3: warning: refers to: $exp at $$
test.y:51.7: warning: possibly meant: $x, hiding $exp at $1
test.y:51.41: warning: possibly meant: $r, hiding $exp at $4
test.y:52.51-52: $l of 'exp' has no declared type
test.y:55.46-49: invalid reference: '$r12'
test.y:55.3-53: symbol not found in production: r12
test.y:56.29-33: invalid reference: '$expo'
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
test.y:52.51-52: error: $l of 'exp' has no declared type
test.y:55.40-43: error: invalid reference: '$r12'
test.y:55.3-47: symbol not found in production: r12
test.y:56.29-33: error: invalid reference: '$expo'
test.y:56.3-46: symbol not found in production: expo
]])
AT_BISON_OPTION_POPDEFS
@@ -278,8 +278,8 @@ 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.8-10: warning: refers to: $foo at $1
test.y:11.12-18: warning: possibly meant: $[foo.bar] at $2
test.y:11.8-10: refers to: $foo at $1
test.y:11.12-18: possibly meant: $[foo.bar] at $2
]])
AT_CLEANUP
@@ -353,46 +353,167 @@ factor: '(' expr ')' { $$ = $2; }
;
]])
AT_BISON_CHECK([-o test.c test.y], 1, [],
[[test.y:24.36-41: invalid reference: '$cond1'
[[test.y:24.36-41: error: invalid reference: '$cond1'
test.y:23.11-24.62: symbol not found in production: cond1
test.y:26.43-53: invalid reference: '$stmt.field'
test.y:26.43-53: error: invalid reference: '$stmt.field'
test.y:25.11-26.60: symbol not found in production: stmt
test.y:25.35-38: possibly meant: $then.field, hiding $stmt.field at $4
test.y:28.43-52: invalid reference: '$stmt.list'
test.y:28.43-52: error: invalid reference: '$stmt.list'
test.y:27.11-28.59: symbol not found in production: stmt
test.y:27.30-38: possibly meant: $[stmt.list] at $4
test.y:30.43-46: ambiguous reference: '$xyz'
test.y:30.43-46: error: ambiguous reference: '$xyz'
test.y:29.35-37: refers to: $xyz at $4
test.y:29.50-52: refers to: $xyz at $6
test.y:32.43-52: invalid reference: '$stmt.list'
test.y:32.43-52: error: invalid reference: '$stmt.list'
test.y:31.11-32.63: symbol not found in production: stmt
test.y:31.40-43: possibly meant: $then, hiding $[stmt.list] at $4
test.y:31.61-64: possibly meant: $else, hiding $[stmt.list] at $6
test.y:34.43-58: invalid reference: '$stmt.list.field'
test.y:34.43-58: error: invalid reference: '$stmt.list.field'
test.y:33.11-34.69: symbol not found in production: stmt
test.y:33.40-43: possibly meant: $then.field, hiding $[stmt.list].field at $4
test.y:33.61-64: possibly meant: $else.field, hiding $[stmt.list].field at $6
test.y:36.43-54: invalid reference: '$[stmt.list]'
test.y:36.43-54: error: invalid reference: '$[stmt.list]'
test.y:35.11-36.71: symbol not found in production: stmt.list
test.y:35.40-43: possibly meant: $then, hiding $[stmt.list] at $4
test.y:35.61-64: possibly meant: $else, hiding $[stmt.list] at $6
test.y:38.43-49: invalid reference: '$then.1'
test.y:38.43-49: error: invalid reference: '$then.1'
test.y:37.11-38.60: symbol not found in production: then
test.y:37.40-45: possibly meant: $[then.1] at $4
test.y:40.43-55: invalid reference: '$then.1.field'
test.y:40.43-55: error: invalid reference: '$then.1.field'
test.y:39.11-40.66: symbol not found in production: then
test.y:39.40-45: possibly meant: $[then.1].field at $4
test.y:42.44-50: invalid reference: '$stmt.x'
test.y:42.44-50: error: invalid reference: '$stmt.x'
test.y:41.12-42.57: symbol not found in production: stmt
test.y:41.36-41: possibly meant: $[stmt.x].x, hiding $stmt.x at $4
test.y:41.36-41: possibly meant: $[stmt.x] at $4
test.y:44.13-22: invalid reference: '$if-stmt-a'
test.y:44.13-22: error: invalid reference: '$if-stmt-a'
test.y:43.12-44.59: symbol not found in production: if
test.y:43.1-9: possibly meant: $[if-stmt-a] at $$
test.y:46.46-54: invalid reference: '$then-a.f'
test.y:46.46-54: error: invalid reference: '$then-a.f'
test.y:45.12-46.65: symbol not found in production: then
test.y:45.41-46: possibly meant: $[then-a].f at $4
]])
AT_BISON_CHECK([-fcaret -o test.c test.y], 1, [],
[[test.y:24.36-41: error: invalid reference: '$cond1'
{ $if_stmt1 = new IfStmt($cond1, $then.f1, $else); };
^^^^^^
test.y:23.11-24.62: symbol not found in production: cond1
if_stmt1: IF expr[cond] THEN stmt[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:26.43-53: error: invalid reference: '$stmt.field'
{ $if_stmt2 = new IfStmt($cond, $stmt.field, 0); };
^^^^^^^^^^^
test.y:25.11-26.60: symbol not found in production: stmt
if_stmt2: IF expr[cond] THEN stmt[then] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:25.35-38: possibly meant: $then.field, hiding $stmt.field at $4
if_stmt2: IF expr[cond] THEN stmt[then] FI
^^^^
test.y:28.43-52: error: invalid reference: '$stmt.list'
{ $if_stmt3 = new IfStmt($cond, $stmt.list, 0); };
^^^^^^^^^^
test.y:27.11-28.59: symbol not found in production: stmt
if_stmt3: IF expr[cond] THEN stmt.list FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:27.30-38: possibly meant: $[stmt.list] at $4
if_stmt3: IF expr[cond] THEN stmt.list FI
^^^^^^^^^
test.y:30.43-46: error: ambiguous reference: '$xyz'
{ $if_stmt4 = new IfStmt($cond, $xyz, $cond); };
^^^^
test.y:29.35-37: refers to: $xyz at $4
if_stmt4: IF expr[cond] THEN stmt[xyz] ELSE stmt[xyz] FI
^^^
test.y:29.50-52: refers to: $xyz at $6
if_stmt4: IF expr[cond] THEN stmt[xyz] ELSE stmt[xyz] FI
^^^
test.y:32.43-52: error: invalid reference: '$stmt.list'
{ $if_stmt5 = new IfStmt($cond, $stmt.list, $else); };
^^^^^^^^^^
test.y:31.11-32.63: symbol not found in production: stmt
if_stmt5: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:31.40-43: possibly meant: $then, hiding $[stmt.list] at $4
if_stmt5: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^
test.y:31.61-64: possibly meant: $else, hiding $[stmt.list] at $6
if_stmt5: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^
test.y:34.43-58: error: invalid reference: '$stmt.list.field'
{ $if_stmt6 = new IfStmt($cond, $stmt.list.field, $else); };
^^^^^^^^^^^^^^^^
test.y:33.11-34.69: symbol not found in production: stmt
if_stmt6: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:33.40-43: possibly meant: $then.field, hiding $[stmt.list].field at $4
if_stmt6: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^
test.y:33.61-64: possibly meant: $else.field, hiding $[stmt.list].field at $6
if_stmt6: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^
test.y:36.43-54: error: invalid reference: '$[stmt.list]'
{ $if_stmt7 = new IfStmt($cond, $[stmt.list].field, $else); };
^^^^^^^^^^^^
test.y:35.11-36.71: symbol not found in production: stmt.list
if_stmt7: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:35.40-43: possibly meant: $then, hiding $[stmt.list] at $4
if_stmt7: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^
test.y:35.61-64: possibly meant: $else, hiding $[stmt.list] at $6
if_stmt7: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^
test.y:38.43-49: error: invalid reference: '$then.1'
{ $if_stmt8 = new IfStmt($cond, $then.1, $else); };
^^^^^^^
test.y:37.11-38.60: symbol not found in production: then
if_stmt8: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:37.40-45: possibly meant: $[then.1] at $4
if_stmt8: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI
^^^^^^
test.y:40.43-55: error: invalid reference: '$then.1.field'
{ $if_stmt9 = new IfStmt($cond, $then.1.field, $else); };
^^^^^^^^^^^^^
test.y:39.11-40.66: symbol not found in production: then
if_stmt9: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:39.40-45: possibly meant: $[then.1].field at $4
if_stmt9: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI
^^^^^^
test.y:42.44-50: error: invalid reference: '$stmt.x'
{ $if_stmt10 = new IfStmt($cond, $stmt.x, 0); };
^^^^^^^
test.y:41.12-42.57: symbol not found in production: stmt
if_stmt10: IF expr[cond] THEN stmt[stmt.x] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:41.36-41: possibly meant: $[stmt.x].x, hiding $stmt.x at $4
if_stmt10: IF expr[cond] THEN stmt[stmt.x] FI
^^^^^^
test.y:41.36-41: possibly meant: $[stmt.x] at $4
if_stmt10: IF expr[cond] THEN stmt[stmt.x] FI
^^^^^^
test.y:44.13-22: error: invalid reference: '$if-stmt-a'
{ $if-stmt-a = new IfStmt($cond, $then, $else); };
^^^^^^^^^^
test.y:43.12-44.59: symbol not found in production: if
if-stmt-a: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:43.1-9: possibly meant: $[if-stmt-a] at $$
if-stmt-a: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^
test.y:46.46-54: error: invalid reference: '$then-a.f'
{ $[if-stmt-b] = new IfStmt($cond, $then-a.f, $else); };
^^^^^^^^^
test.y:45.12-46.65: symbol not found in production: then
if-stmt-b: IF expr[cond] THEN if-stmt-a[then-a] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.y:45.41-46: possibly meant: $[then-a].f at $4
if-stmt-b: IF expr[cond] THEN if-stmt-a[then-a] ELSE stmt.list[else] FI
^^^^^^
]])
AT_CLEANUP
#######################################################################
@@ -405,7 +526,7 @@ start: foo[] bar
{ s = $foo; }
]])
AT_BISON_CHECK([-o test.c test.y], 1, [],
[[test.y:11.12: an identifier expected
[[test.y:11.12: error: an identifier expected
]])
AT_CLEANUP
@@ -419,7 +540,7 @@ start: foo[ a d ] bar
{ s = $foo; }
]])
AT_BISON_CHECK([-o test.c test.y], 1, [],
[[test.y:11.15: unexpected identifier in bracketed name: 'd'
[[test.y:11.15: error: unexpected identifier in bracketed name: 'd'
]])
AT_CLEANUP
@@ -433,7 +554,7 @@ start: foo[/* comment */] bar
{ s = $foo; }
]])
AT_BISON_CHECK([-o test.c test.y], 1, [],
[[test.y:11.25: an identifier expected
[[test.y:11.25: error: an identifier expected
]])
AT_CLEANUP
@@ -443,14 +564,14 @@ AT_SETUP([Stray symbols in brackets])
AT_DATA_GRAMMAR([test.y],
[[
%%
start: foo[ /* aaa */ *&-.+ ] bar
start: foo[ % /* aaa */ *&-.+\000\001\002\377 ] bar
{ s = $foo; }
]])
AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' test.y || exit 77]])
AT_BISON_CHECK([-o test.c test.y], 1, [],
[[test.y:11.23: invalid character in bracketed name: '*'
test.y:11.24: invalid character in bracketed name: '&'
test.y:11.25: invalid character in bracketed name: '-'
test.y:11.27: invalid character in bracketed name: '+'
[[test.y:11.13: error: invalid character in bracketed name: '%'
test.y:11.25-27: error: invalid characters in bracketed name: '*&-'
test.y:11.29-30: error: invalid characters in bracketed name: '+\0\001\002\377'
]])
AT_CLEANUP
@@ -463,7 +584,7 @@ AT_DATA_GRAMMAR([test.y],
start[a s]: foo;
]])
AT_BISON_CHECK([-o test.c test.y], 1, [],
[[test.y:11.9: unexpected identifier in bracketed name: 's'
[[test.y:11.9: error: unexpected identifier in bracketed name: 's'
]])
AT_CLEANUP
@@ -510,37 +631,37 @@ sym_a: 'a';
sym_b: 'b';
]])
AT_BISON_CHECK([-o test.c test.y], 1, [],
[[test.y:12.22-31: invalid reference: '$sym.field'
[[test.y:12.22-31: error: invalid reference: '$sym.field'
test.y:12.3-35: symbol not found in production: sym
test.y:13.22-35: invalid reference: '$<aa>sym.field'
test.y:13.22-35: error: invalid reference: '$<aa>sym.field'
test.y:13.3-39: symbol not found in production: sym
test.y:14.22-33: invalid reference: '$[sym.field]'
test.y:14.22-33: error: invalid reference: '$[sym.field]'
test.y:14.3-37: symbol not found in production: sym.field
test.y:15.22-37: invalid reference: '$<aa>[sym.field]'
test.y:15.22-37: error: invalid reference: '$<aa>[sym.field]'
test.y:15.3-41: symbol not found in production: sym.field
test.y:16.22-25: invalid reference: '$sym'
test.y:16.22-25: error: invalid reference: '$sym'
test.y:16.3-29: symbol not found in production: sym
test.y:17.22-29: invalid reference: '$<aa>sym'
test.y:17.22-29: error: invalid reference: '$<aa>sym'
test.y:17.3-33: symbol not found in production: sym
test.y:18.22-27: invalid reference: '$[sym]'
test.y:18.22-27: error: invalid reference: '$[sym]'
test.y:18.3-65: symbol not found in production before $3: sym
test.y:18.52-61: invalid reference: '$<aa>[sym]'
test.y:18.52-61: error: invalid reference: '$<aa>[sym]'
test.y:18.3-65: symbol not found in production: sym
test.y:22.22-31: invalid reference: '$sym-field'
test.y:22.22-31: error: invalid reference: '$sym-field'
test.y:22.3-35: symbol not found in production: sym
test.y:23.22-35: invalid reference: '$<aa>sym-field'
test.y:23.22-35: error: invalid reference: '$<aa>sym-field'
test.y:23.3-39: symbol not found in production: sym
test.y:24.22-33: invalid reference: '$[sym-field]'
test.y:24.22-33: error: invalid reference: '$[sym-field]'
test.y:24.3-37: symbol not found in production: sym-field
test.y:25.22-37: invalid reference: '$<aa>[sym-field]'
test.y:25.22-37: error: invalid reference: '$<aa>[sym-field]'
test.y:25.3-41: symbol not found in production: sym-field
test.y:26.22-25: invalid reference: '$sym'
test.y:26.22-25: error: invalid reference: '$sym'
test.y:26.3-29: symbol not found in production: sym
test.y:27.22-29: invalid reference: '$<aa>sym'
test.y:27.22-29: error: invalid reference: '$<aa>sym'
test.y:27.3-33: symbol not found in production: sym
test.y:28.22-27: invalid reference: '$[sym]'
test.y:28.22-27: error: invalid reference: '$[sym]'
test.y:28.3-65: symbol not found in production before $3: sym
test.y:28.52-61: invalid reference: '$<aa>[sym]'
test.y:28.52-61: error: invalid reference: '$<aa>[sym]'
test.y:28.3-65: symbol not found in production: sym
]])
AT_CLEANUP
@@ -558,10 +679,10 @@ start:
.field: ;
]])
AT_BISON_CHECK([[test.y]], [[1]], [],
[[test.y:4.12-18: invalid reference: '$.field'
[[test.y:4.12-18: error: invalid reference: '$.field'
test.y:4.13: syntax error after '$', expecting integer, letter, '_', '@<:@', or '$'
test.y:4.3-8: possibly meant: $[.field] at $1
test.y:5.12-18: invalid reference: '@.field'
test.y:5.12-18: error: invalid reference: '@.field'
test.y:5.13: syntax error after '@', expecting integer, letter, '_', '@<:@', or '$'
]])
AT_DATA([[test.y]],
+366 -1
View File
@@ -171,7 +171,7 @@ AT_CHECK_CONFLICTING_OUTPUT([foo.y],
])
AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
[foo.y: refusing to overwrite the input file 'foo.y'
[foo.y: error: refusing to overwrite the input file 'foo.y'
], 1)
@@ -231,3 +231,368 @@ AT_CHECK_OUTPUT_FILE_NAME([[@{]])
AT_CHECK_OUTPUT_FILE_NAME([[@}]])
AT_CHECK_OUTPUT_FILE_NAME([[@<:@]])
AT_CHECK_OUTPUT_FILE_NAME([[@:>@]])
# AT_TEST(SETUP-NAME, GRAMMAR, DOT-BODY)
# --------------------------------------
# Check that the DOT graph for GRAMMAR is DOT-BODY.
m4_pushdef([AT_TEST],
[AT_SETUP([$1])
AT_KEYWORDS([[graph]])
AT_DATA([[input.y]], [$2])
AT_BISON_CHECK([[-rall --graph input.y]], [0], [[]], [[ignore]])
AT_CHECK([[grep -v // input.dot]], [0],
[[
digraph "input.y"
{
node [fontname = courier, shape = box, colorscheme = paired6]
edge [fontname = courier]
]$3[}
]])
AT_CLEANUP
])
## ------------------------ ##
## Graph with no conflicts. ##
## ------------------------ ##
AT_TEST([Graph with no conflicts],
[[%%
exp: a '?' b;
a: ;
b: 'b';
]],
[[
0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a '?' b\l 2 a: .\l"]
0 -> 1 [style=dashed label="exp"]
0 -> 2 [style=dashed label="a"]
0 -> "0R2" [style=solid]
"0R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
1 [label="State 1\n\l 0 $accept: exp . $end\l"]
1 -> 3 [style=solid label="$end"]
2 [label="State 2\n\l 1 exp: a . '?' b\l"]
2 -> 4 [style=solid label="'?'"]
3 [label="State 3\n\l 0 $accept: exp $end .\l"]
3 -> "3R0" [style=solid]
"3R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
4 [label="State 4\n\l 1 exp: a '?' . b\l 3 b: . 'b'\l"]
4 -> 5 [style=solid label="'b'"]
4 -> 6 [style=dashed label="b"]
5 [label="State 5\n\l 3 b: 'b' .\l"]
5 -> "5R3" [style=solid]
"5R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
6 [label="State 6\n\l 1 exp: a '?' b .\l"]
6 -> "6R1" [style=solid]
"6R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
]])
## ------------------------ ##
## Graph with unsolved S/R. ##
## ------------------------ ##
AT_TEST([Graph with unsolved S/R],
[[%%
start:
'a'
| empty_a 'a'
| 'b'
| empty_b 'b'
| 'c'
| empty_c 'c'
;
empty_a: %prec 'a';
empty_b: %prec 'b';
empty_c: %prec 'c';
]],
[[
0 [label="State 0\n\l 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . ['b']\l 9 empty_c: . ['c']\l"]
0 -> 1 [style=solid label="'a'"]
0 -> 2 [style=solid label="'b'"]
0 -> 3 [style=solid label="'c'"]
0 -> 4 [style=dashed label="start"]
0 -> 5 [style=dashed label="empty_a"]
0 -> 6 [style=dashed label="empty_b"]
0 -> 7 [style=dashed label="empty_c"]
0 -> "0R7d" [label="['a']", style=solid]
"0R7d" [label="R7", fillcolor=5, shape=diamond, style=filled]
0 -> "0R8d" [label="['b']", style=solid]
"0R8d" [label="R8", fillcolor=5, shape=diamond, style=filled]
0 -> "0R9d" [label="['c']", style=solid]
"0R9d" [label="R9", fillcolor=5, shape=diamond, style=filled]
1 [label="State 1\n\l 1 start: 'a' .\l"]
1 -> "1R1" [style=solid]
"1R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
2 [label="State 2\n\l 3 start: 'b' .\l"]
2 -> "2R3" [style=solid]
"2R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
3 [label="State 3\n\l 5 start: 'c' .\l"]
3 -> "3R5" [style=solid]
"3R5" [label="R5", fillcolor=3, shape=diamond, style=filled]
4 [label="State 4\n\l 0 $accept: start . $end\l"]
4 -> 8 [style=solid label="$end"]
5 [label="State 5\n\l 2 start: empty_a . 'a'\l"]
5 -> 9 [style=solid label="'a'"]
6 [label="State 6\n\l 4 start: empty_b . 'b'\l"]
6 -> 10 [style=solid label="'b'"]
7 [label="State 7\n\l 6 start: empty_c . 'c'\l"]
7 -> 11 [style=solid label="'c'"]
8 [label="State 8\n\l 0 $accept: start $end .\l"]
8 -> "8R0" [style=solid]
"8R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
9 [label="State 9\n\l 2 start: empty_a 'a' .\l"]
9 -> "9R2" [style=solid]
"9R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
10 [label="State 10\n\l 4 start: empty_b 'b' .\l"]
10 -> "10R4" [style=solid]
"10R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
11 [label="State 11\n\l 6 start: empty_c 'c' .\l"]
11 -> "11R6" [style=solid]
"11R6" [label="R6", fillcolor=3, shape=diamond, style=filled]
]])
## ---------------------- ##
## Graph with solved S/R. ##
## ---------------------- ##
AT_TEST([Graph with solved S/R],
[[%left 'a'
%right 'b'
%right 'c'
%%
start:
'a'
| empty_a 'a'
| 'b'
| empty_b 'b'
| 'c'
| empty_c 'c'
;
empty_a: %prec 'a';
empty_b: %prec 'b';
empty_c: %prec 'c';
]],
[[
0 [label="State 0\n\l 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . []\l 9 empty_c: . []\l"]
0 -> 1 [style=solid label="'b'"]
0 -> 2 [style=solid label="'c'"]
0 -> 3 [style=dashed label="start"]
0 -> 4 [style=dashed label="empty_a"]
0 -> 5 [style=dashed label="empty_b"]
0 -> 6 [style=dashed label="empty_c"]
0 -> "0R7" [style=solid]
"0R7" [label="R7", fillcolor=3, shape=diamond, style=filled]
1 [label="State 1\n\l 3 start: 'b' .\l"]
1 -> "1R3" [style=solid]
"1R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
2 [label="State 2\n\l 5 start: 'c' .\l"]
2 -> "2R5" [style=solid]
"2R5" [label="R5", fillcolor=3, shape=diamond, style=filled]
3 [label="State 3\n\l 0 $accept: start . $end\l"]
3 -> 7 [style=solid label="$end"]
4 [label="State 4\n\l 2 start: empty_a . 'a'\l"]
4 -> 8 [style=solid label="'a'"]
5 [label="State 5\n\l 4 start: empty_b . 'b'\l"]
5 -> 9 [style=solid label="'b'"]
6 [label="State 6\n\l 6 start: empty_c . 'c'\l"]
6 -> 10 [style=solid label="'c'"]
7 [label="State 7\n\l 0 $accept: start $end .\l"]
7 -> "7R0" [style=solid]
"7R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
8 [label="State 8\n\l 2 start: empty_a 'a' .\l"]
8 -> "8R2" [style=solid]
"8R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
9 [label="State 9\n\l 4 start: empty_b 'b' .\l"]
9 -> "9R4" [style=solid]
"9R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
10 [label="State 10\n\l 6 start: empty_c 'c' .\l"]
10 -> "10R6" [style=solid]
"10R6" [label="R6", fillcolor=3, shape=diamond, style=filled]
]])
## ---------------- ##
## Graph with R/R. ##
## ---------------- ##
AT_TEST([Graph with R/R],
[[%%
exp: a | b;
a: ;
b: ;
]],
[[
0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a\l 2 | . b\l 3 a: . [$end]\l 4 b: . [$end]\l"]
0 -> 1 [style=dashed label="exp"]
0 -> 2 [style=dashed label="a"]
0 -> 3 [style=dashed label="b"]
0 -> "0R3" [style=solid]
"0R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
0 -> "0R4d" [label="[$end]", style=solid]
"0R4d" [label="R4", fillcolor=5, shape=diamond, style=filled]
1 [label="State 1\n\l 0 $accept: exp . $end\l"]
1 -> 4 [style=solid label="$end"]
2 [label="State 2\n\l 1 exp: a .\l"]
2 -> "2R1" [style=solid]
"2R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
3 [label="State 3\n\l 2 exp: b .\l"]
3 -> "3R2" [style=solid]
"3R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
4 [label="State 4\n\l 0 $accept: exp $end .\l"]
4 -> "4R0" [style=solid]
"4R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
]])
## ---------------------------------------- ##
## Graph with reductions with multiple LAT. ##
## ---------------------------------------- ##
AT_TEST([Graph with reductions with multiple LAT],
[[%%
exp: a ';' | a ';' | a '.' | b '?' | b '!' | c '?' | c ';';
a: ;
b: ;
c: ;
]],
[[
0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a ';'\l 2 | . a ';'\l 3 | . a '.'\l 4 | . b '?'\l 5 | . b '!'\l 6 | . c '?'\l 7 | . c ';'\l 8 a: . [';', '.']\l 9 b: . ['?', '!']\l 10 c: . [';', '?']\l"]
0 -> 1 [style=dashed label="exp"]
0 -> 2 [style=dashed label="a"]
0 -> 3 [style=dashed label="b"]
0 -> 4 [style=dashed label="c"]
0 -> "0R8" [style=solid]
"0R8" [label="R8", fillcolor=3, shape=diamond, style=filled]
0 -> "0R9" [label="['?', '!']", style=solid]
"0R9" [label="R9", fillcolor=3, shape=diamond, style=filled]
0 -> "0R10d" [label="[';', '?']", style=solid]
"0R10d" [label="R10", fillcolor=5, shape=diamond, style=filled]
1 [label="State 1\n\l 0 $accept: exp . $end\l"]
1 -> 5 [style=solid label="$end"]
2 [label="State 2\n\l 1 exp: a . ';'\l 2 | a . ';'\l 3 | a . '.'\l"]
2 -> 6 [style=solid label="';'"]
2 -> 7 [style=solid label="'.'"]
3 [label="State 3\n\l 4 exp: b . '?'\l 5 | b . '!'\l"]
3 -> 8 [style=solid label="'?'"]
3 -> 9 [style=solid label="'!'"]
4 [label="State 4\n\l 6 exp: c . '?'\l 7 | c . ';'\l"]
4 -> 10 [style=solid label="';'"]
4 -> 11 [style=solid label="'?'"]
5 [label="State 5\n\l 0 $accept: exp $end .\l"]
5 -> "5R0" [style=solid]
"5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
6 [label="State 6\n\l 1 exp: a ';' . [$end]\l 2 | a ';' . [$end]\l"]
6 -> "6R1" [style=solid]
"6R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
6 -> "6R2d" [label="[$end]", style=solid]
"6R2d" [label="R2", fillcolor=5, shape=diamond, style=filled]
7 [label="State 7\n\l 3 exp: a '.' .\l"]
7 -> "7R3" [style=solid]
"7R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
8 [label="State 8\n\l 4 exp: b '?' .\l"]
8 -> "8R4" [style=solid]
"8R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
9 [label="State 9\n\l 5 exp: b '!' .\l"]
9 -> "9R5" [style=solid]
"9R5" [label="R5", fillcolor=3, shape=diamond, style=filled]
10 [label="State 10\n\l 7 exp: c ';' .\l"]
10 -> "10R7" [style=solid]
"10R7" [label="R7", fillcolor=3, shape=diamond, style=filled]
11 [label="State 11\n\l 6 exp: c '?' .\l"]
11 -> "11R6" [style=solid]
"11R6" [label="R6", fillcolor=3, shape=diamond, style=filled]
]])
## ------------------------------------------------------ ##
## Graph with a reduction rule both enabled and disabled. ##
## ------------------------------------------------------ ##
AT_TEST([Graph with a reduction rule both enabled and disabled],
[[%%
exp: ifexp | opexp | imm;
ifexp: "if" exp "then" exp elseexp;
elseexp: "else" exp | ;
opexp: exp '+' exp;
imm: '0';
]],
[[
0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"]
0 -> 1 [style=solid label="\"if\""]
0 -> 2 [style=solid label="'0'"]
0 -> 3 [style=dashed label="exp"]
0 -> 4 [style=dashed label="ifexp"]
0 -> 5 [style=dashed label="opexp"]
0 -> 6 [style=dashed label="imm"]
1 [label="State 1\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 4 | \"if\" . exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"]
1 -> 1 [style=solid label="\"if\""]
1 -> 2 [style=solid label="'0'"]
1 -> 7 [style=dashed label="exp"]
1 -> 4 [style=dashed label="ifexp"]
1 -> 5 [style=dashed label="opexp"]
1 -> 6 [style=dashed label="imm"]
2 [label="State 2\n\l 8 imm: '0' .\l"]
2 -> "2R8" [style=solid]
"2R8" [label="R8", fillcolor=3, shape=diamond, style=filled]
3 [label="State 3\n\l 0 $accept: exp . $end\l 7 opexp: exp . '+' exp\l"]
3 -> 8 [style=solid label="$end"]
3 -> 9 [style=solid label="'+'"]
4 [label="State 4\n\l 1 exp: ifexp .\l"]
4 -> "4R1" [style=solid]
"4R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
5 [label="State 5\n\l 2 exp: opexp .\l"]
5 -> "5R2" [style=solid]
"5R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
6 [label="State 6\n\l 3 exp: imm .\l"]
6 -> "6R3" [style=solid]
"6R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
7 [label="State 7\n\l 4 ifexp: \"if\" exp . \"then\" exp elseexp\l 7 opexp: exp . '+' exp\l"]
7 -> 10 [style=solid label="\"then\""]
7 -> 9 [style=solid label="'+'"]
8 [label="State 8\n\l 0 $accept: exp $end .\l"]
8 -> "8R0" [style=solid]
"8R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
9 [label="State 9\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 7 | exp '+' . exp\l 8 imm: . '0'\l"]
9 -> 1 [style=solid label="\"if\""]
9 -> 2 [style=solid label="'0'"]
9 -> 11 [style=dashed label="exp"]
9 -> 4 [style=dashed label="ifexp"]
9 -> 5 [style=dashed label="opexp"]
9 -> 6 [style=dashed label="imm"]
10 [label="State 10\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 4 | \"if\" exp \"then\" . exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"]
10 -> 1 [style=solid label="\"if\""]
10 -> 2 [style=solid label="'0'"]
10 -> 12 [style=dashed label="exp"]
10 -> 4 [style=dashed label="ifexp"]
10 -> 5 [style=dashed label="opexp"]
10 -> 6 [style=dashed label="imm"]
11 [label="State 11\n\l 7 opexp: exp . '+' exp\l 7 | exp '+' exp . [$end, \"then\", \"else\", '+']\l"]
11 -> 9 [style=solid label="'+'"]
11 -> "11R7d" [label="['+']", style=solid]
"11R7d" [label="R7", fillcolor=5, shape=diamond, style=filled]
11 -> "11R7" [style=solid]
"11R7" [label="R7", fillcolor=3, shape=diamond, style=filled]
12 [label="State 12\n\l 4 ifexp: \"if\" exp \"then\" exp . elseexp\l 5 elseexp: . \"else\" exp\l 6 | . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"]
12 -> 13 [style=solid label="\"else\""]
12 -> 9 [style=solid label="'+'"]
12 -> 14 [style=dashed label="elseexp"]
12 -> "12R6d" [label="[\"else\", '+']", style=solid]
"12R6d" [label="R6", fillcolor=5, shape=diamond, style=filled]
12 -> "12R6" [style=solid]
"12R6" [label="R6", fillcolor=3, shape=diamond, style=filled]
13 [label="State 13\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 5 elseexp: \"else\" . exp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"]
13 -> 1 [style=solid label="\"if\""]
13 -> 2 [style=solid label="'0'"]
13 -> 15 [style=dashed label="exp"]
13 -> 4 [style=dashed label="ifexp"]
13 -> 5 [style=dashed label="opexp"]
13 -> 6 [style=dashed label="imm"]
14 [label="State 14\n\l 4 ifexp: \"if\" exp \"then\" exp elseexp .\l"]
14 -> "14R4" [style=solid]
"14R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
15 [label="State 15\n\l 5 elseexp: \"else\" exp . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"]
15 -> 9 [style=solid label="'+'"]
15 -> "15R5d" [label="['+']", style=solid]
"15R5d" [label="R5", fillcolor=5, shape=diamond, style=filled]
15 -> "15R5" [style=solid]
"15R5" [label="R5", fillcolor=3, shape=diamond, style=filled]
]])
m4_popdef([AT_TEST])
+1 -1
View File
@@ -153,7 +153,7 @@ start: ;
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[input.y]], [[1]], [],
[[input.y:2.9-21: %define variable 'api.push-pull' is not used
[[input.y:2.9-21: error: %define variable 'api.push-pull' is not used
]])
AT_CLEANUP
+178 -99
View File
@@ -142,6 +142,65 @@ useless8: '8';
useless9: '9';
]])
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
useless1: '1';
^^^^^^^^
input.y:7.1-8: warning: nonterminal useless in grammar: useless2
useless2: '2';
^^^^^^^^
input.y:8.1-8: warning: nonterminal useless in grammar: useless3
useless3: '3';
^^^^^^^^
input.y:9.1-8: warning: nonterminal useless in grammar: useless4
useless4: '4';
^^^^^^^^
input.y:10.1-8: warning: nonterminal useless in grammar: useless5
useless5: '5';
^^^^^^^^
input.y:11.1-8: warning: nonterminal useless in grammar: useless6
useless6: '6';
^^^^^^^^
input.y:12.1-8: warning: nonterminal useless in grammar: useless7
useless7: '7';
^^^^^^^^
input.y:13.1-8: warning: nonterminal useless in grammar: useless8
useless8: '8';
^^^^^^^^
input.y:14.1-8: warning: nonterminal useless in grammar: useless9
useless9: '9';
^^^^^^^^
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';
^^^
]])
AT_BISON_CHECK([[input.y]], 0, [],
[[input.y: warning: 9 nonterminals useless in grammar
input.y: warning: 9 rules useless in grammar
@@ -238,6 +297,26 @@ non_productive: non_productive useless_token
%%
]])
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_reachable: useful { /* A not reachable action. */ }
^^^^^^^^^^^^^
not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive
| non_productive { /* A non productive action. */ }
^^^^^^^^^^^^^^
not-reduced.y:11.6-57: warning: rule useless in grammar
| non_productive { /* A non productive action. */ }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
not-reduced.y:14.16-56: warning: rule useless in grammar
not_reachable: useful { /* A not reachable action. */ }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
not-reduced.y:17.17-18.63: warning: rule useless in grammar
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
@@ -437,7 +516,7 @@ dnl BISON-STDERR
[],
dnl TABLES
[[state 0
[[State 0
0 $accept: . S $end
1 S: . 'a' A 'a'
@@ -451,7 +530,7 @@ dnl TABLES
S go to state 4
state 1
State 1
1 S: 'a' . A 'a'
4 A: . 'a' 'a'
@@ -462,7 +541,7 @@ state 1
A go to state 6
state 2
State 2
2 S: 'b' . A 'b'
4 A: . 'a' 'a'
@@ -473,7 +552,7 @@ state 2
A go to state 7
state 3
State 3
3 S: 'c' . c
4 A: . 'a' 'a'
@@ -487,14 +566,14 @@ state 3
c go to state 10
state 4
State 4
0 $accept: S . $end
$end shift, and go to state 11
state 5
State 5
4 A: 'a' . 'a'
5 | 'a' . ]AT_COND_CASE([[LALR]], [[['a', 'b']]], [[['a']]])[
@@ -505,21 +584,21 @@ state 5
Conflict between rule 5 and token 'a' resolved as reduce (%left 'a').
state 6
State 6
1 S: 'a' A . 'a'
'a' shift, and go to state 13
state 7
State 7
2 S: 'b' A . 'b'
'b' shift, and go to state 14
state 8
State 8
4 A: 'a' . 'a'
5 | 'a' . [$end]
@@ -533,7 +612,7 @@ state 8
[[$default]])[ reduce using rule 5 (A)
state 9
State 9
7 c: A .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -541,7 +620,7 @@ state 9
[[$default]])[ reduce using rule 7 (c)
state 10
State 10
3 S: 'c' c .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -549,14 +628,14 @@ state 10
[[$default]])[ reduce using rule 3 (S)
state 11
State 11
0 $accept: S $end .
$default accept
state 12
State 12
4 A: 'a' 'a' .]AT_COND_CASE([[canonical LR]], [[ ['a']]])[
@@ -564,7 +643,7 @@ state 12
[[$default]])[ reduce using rule 4 (A)
state 13
State 13
1 S: 'a' A 'a' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -572,7 +651,7 @@ state 13
[[$default]])[ reduce using rule 1 (S)
state 14
State 14
2 S: 'b' A 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -580,7 +659,7 @@ state 14
[[$default]])[ reduce using rule 2 (S)
state 15
State 15
6 c: 'a' 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -589,7 +668,7 @@ state 15
[[]], [[
state 16
State 16
4 A: 'a' . 'a'
5 | 'a' . ['b']
@@ -601,14 +680,14 @@ state 16
[[$default]])[ reduce using rule 5 (A)]AT_COND_CASE([[canonical LR]], [[
state 17
State 17
4 A: 'a' 'a' . [$end]
$end reduce using rule 4 (A)
state 18
State 18
4 A: 'a' 'a' . ['b']
@@ -653,7 +732,7 @@ dnl BISON-STDERR
[],
dnl TABLES
[[state 0
[[State 0
0 $accept: . S $end
1 S: . 'a' A 'a'
@@ -667,7 +746,7 @@ dnl TABLES
S go to state 4
state 1
State 1
1 S: 'a' . A 'a'
4 A: . 'a' 'a' 'a'
@@ -678,7 +757,7 @@ state 1
A go to state 6
state 2
State 2
2 S: 'b' . A 'b'
4 A: . 'a' 'a' 'a'
@@ -689,7 +768,7 @@ state 2
A go to state 7
state 3
State 3
3 S: 'c' . c
4 A: . 'a' 'a' 'a'
@@ -703,14 +782,14 @@ state 3
c go to state 10
state 4
State 4
0 $accept: S . $end
$end shift, and go to state 11
state 5
State 5
4 A: 'a' . 'a' 'a'
5 | 'a' . 'a'
@@ -718,21 +797,21 @@ state 5
'a' shift, and go to state 12
state 6
State 6
1 S: 'a' A . 'a'
'a' shift, and go to state 13
state 7
State 7
2 S: 'b' A . 'b'
'b' shift, and go to state 14
state 8
State 8
4 A: 'a' . 'a' 'a'
5 | 'a' . 'a'
@@ -741,7 +820,7 @@ state 8
'a' shift, and go to state 15
state 9
State 9
7 c: A .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -749,7 +828,7 @@ state 9
[[$default]])[ reduce using rule 7 (c)
state 10
State 10
3 S: 'c' c .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -757,14 +836,14 @@ state 10
[[$default]])[ reduce using rule 3 (S)
state 11
State 11
0 $accept: S $end .
$default accept
state 12
State 12
4 A: 'a' 'a' . 'a'
5 | 'a' 'a' . ]AT_COND_CASE([[LALR]], [[['a', 'b']]], [[['a']]])[
@@ -775,7 +854,7 @@ state 12
Conflict between rule 5 and token 'a' resolved as reduce (%left 'a').
state 13
State 13
1 S: 'a' A 'a' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -783,7 +862,7 @@ state 13
[[$default]])[ reduce using rule 1 (S)
state 14
State 14
2 S: 'b' A 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -791,7 +870,7 @@ state 14
[[$default]])[ reduce using rule 2 (S)
state 15
State 15
4 A: 'a' 'a' . 'a'
5 | 'a' 'a' . [$end]
@@ -805,7 +884,7 @@ state 15
[[$default]])[ reduce using rule 5 (A)
state 16
State 16
4 A: 'a' 'a' 'a' .]AT_COND_CASE([[canonical LR]], [[ ['a']]])[
@@ -813,7 +892,7 @@ state 16
[[$default]])[ reduce using rule 4 (A)
state 17
State 17
6 c: 'a' 'a' 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -822,7 +901,7 @@ state 17
[[]], [[
state 18
State 18
4 A: 'a' . 'a' 'a'
5 | 'a' . 'a'
@@ -831,7 +910,7 @@ state 18
[[19]])[
state 19]AT_COND_CASE([[canonical LR]], [[
State 19]AT_COND_CASE([[canonical LR]], [[
4 A: 'a' 'a' 'a' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -839,7 +918,7 @@ state 19]AT_COND_CASE([[canonical LR]], [[
[[$default]])[ reduce using rule 4 (A)
state 20]])[
State 20]])[
4 A: 'a' 'a' . 'a'
5 | 'a' 'a' . ['b']
@@ -851,7 +930,7 @@ state 20]])[
[[$default]])[ reduce using rule 5 (A)]AT_COND_CASE([[canonical LR]], [[
state 21
State 21
4 A: 'a' 'a' 'a' .]AT_COND_CASE([[canonical LR]], [[ ['b']]])[
@@ -900,7 +979,7 @@ dnl BISON-STDERR
[],
dnl TABLES
[[state 0
[[State 0
0 $accept: . S $end
1 S: . 'a' A 'a'
@@ -914,7 +993,7 @@ dnl TABLES
S go to state 4
state 1
State 1
1 S: 'a' . A 'a'
4 A: . 'a' 'a' B
@@ -924,7 +1003,7 @@ state 1
A go to state 6
state 2
State 2
2 S: 'b' . A 'b'
4 A: . 'a' 'a' B
@@ -934,7 +1013,7 @@ state 2
A go to state 7
state 3
State 3
3 S: 'c' . c
4 A: . 'a' 'a' B
@@ -947,35 +1026,35 @@ state 3
c go to state 10
state 4
State 4
0 $accept: S . $end
$end shift, and go to state 11
state 5
State 5
4 A: 'a' . 'a' B
'a' shift, and go to state 12
state 6
State 6
1 S: 'a' A . 'a'
'a' shift, and go to state 13
state 7
State 7
2 S: 'b' A . 'b'
'b' shift, and go to state 14
state 8
State 8
4 A: 'a' . 'a' B
7 c: 'a' . 'a' 'b'
@@ -983,7 +1062,7 @@ state 8
'a' shift, and go to state 15
state 9
State 9
8 c: A .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -991,7 +1070,7 @@ state 9
[[$default]])[ reduce using rule 8 (c)
state 10
State 10
3 S: 'c' c .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -999,14 +1078,14 @@ state 10
[[$default]])[ reduce using rule 3 (S)
state 11
State 11
0 $accept: S $end .
$default accept
state 12
State 12
4 A: 'a' 'a' . B
5 B: . 'a'
@@ -1020,7 +1099,7 @@ state 12
Conflict between rule 6 and token 'a' resolved as reduce (%left 'a').
state 13
State 13
1 S: 'a' A 'a' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -1028,7 +1107,7 @@ state 13
[[$default]])[ reduce using rule 1 (S)
state 14
State 14
2 S: 'b' A 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -1036,7 +1115,7 @@ state 14
[[$default]])[ reduce using rule 2 (S)
state 15
State 15
4 A: 'a' 'a' . B
5 B: . 'a'
@@ -1053,7 +1132,7 @@ state 15
B go to state ]AT_COND_CASE([[canonical LR]], [[21]], [[17]])[
state 16
State 16
5 B: 'a' .]AT_COND_CASE([[canonical LR]], [[ ['a']]])[
@@ -1061,7 +1140,7 @@ state 16
[[$default]])[ reduce using rule 5 (B)
state 17
State 17
4 A: 'a' 'a' B .]AT_COND_CASE([[canonical LR]], [[ ['a']]])[
@@ -1069,7 +1148,7 @@ state 17
[[$default]])[ reduce using rule 4 (A)
state 18
State 18
7 c: 'a' 'a' 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -1077,7 +1156,7 @@ state 18
[[$default]])[ reduce using rule 7 (c)]AT_COND_CASE([[LALR]], [], [[
state 19
State 19
4 A: 'a' . 'a' B
@@ -1085,21 +1164,21 @@ state 19
[[20]])[
state 20]AT_COND_CASE([[canonical LR]], [[
State 20]AT_COND_CASE([[canonical LR]], [[
5 B: 'a' . [$end]
$end reduce using rule 5 (B)
state 21
State 21
4 A: 'a' 'a' B . [$end]
$end reduce using rule 4 (A)
state 22]])[
State 22]])[
4 A: 'a' 'a' . B
5 B: . 'a'
@@ -1114,14 +1193,14 @@ state 22]])[
B go to state ]AT_COND_CASE([[canonical LR]], [[24
state 23
State 23
5 B: 'a' . ['b']
'b' reduce using rule 5 (B)
state 24
State 24
4 A: 'a' 'a' B . ['b']
@@ -1195,7 +1274,7 @@ dnl BISON-STDERR
]], [])],
dnl TABLES
[[state 0
[[State 0
0 $accept: . S $end
1 S: . 'a' A 'f'
@@ -1213,7 +1292,7 @@ dnl TABLES
S go to state 4
state 1
State 1
1 S: 'a' . A 'f'
2 | 'a' . B
@@ -1226,7 +1305,7 @@ state 1
B go to state 7
state 2
State 2
3 S: 'b' . A 'f'
4 | 'b' . B 'g'
@@ -1240,7 +1319,7 @@ state 2
B go to state 10
state 3
State 3
6 S: 'c' . 'c' A 'g'
7 | 'c' . 'c' B
@@ -1248,14 +1327,14 @@ state 3
'c' shift, and go to state 11
state 4
State 4
0 $accept: S . $end
$end shift, and go to state 12
state 5
State 5
8 A: 'd' . 'e'
9 B: 'd' . 'e'
@@ -1265,14 +1344,14 @@ state 5
[[20]])[
state 6
State 6
1 S: 'a' A . 'f'
'f' shift, and go to state 14
state 7
State 7
2 S: 'a' B .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -1280,7 +1359,7 @@ state 7
[[$default]])[ reduce using rule 2 (S)
state 8
State 8
5 S: 'b' 'd' . [$end]
8 A: 'd' . 'e'
@@ -1293,21 +1372,21 @@ state 8
[[$default]])[ reduce using rule 5 (S)
state 9
State 9
3 S: 'b' A . 'f'
'f' shift, and go to state 15
state 10
State 10
4 S: 'b' B . 'g'
'g' shift, and go to state 16
state 11
State 11
6 S: 'c' 'c' . A 'g'
7 | 'c' 'c' . B
@@ -1321,14 +1400,14 @@ state 11
B go to state 18
state 12
State 12
0 $accept: S $end .
$default accept]AT_COND_CASE([[LALR]], [[
state 13
State 13
8 A: 'd' 'e' . ['f', 'g']
9 B: 'd' 'e' . [$end, 'g']
@@ -1339,7 +1418,7 @@ state 13
$default reduce using rule 8 (A)]], [[
state 13
State 13
8 A: 'd' 'e' . ['f']
9 B: 'd' 'e' . ]AT_COND_CASE([[canonical LR]], [[[$end]]], [[['g']]])[
@@ -1350,7 +1429,7 @@ state 13
[[$default]])[ reduce using rule 8 (A)]])[
state 14
State 14
1 S: 'a' A 'f' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -1358,7 +1437,7 @@ state 14
[[$default]])[ reduce using rule 1 (S)
state 15
State 15
3 S: 'b' A 'f' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -1366,7 +1445,7 @@ state 15
[[$default]])[ reduce using rule 3 (S)
state 16
State 16
4 S: 'b' B 'g' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -1374,14 +1453,14 @@ state 16
[[$default]])[ reduce using rule 4 (S)
state 17
State 17
6 S: 'c' 'c' A . 'g'
'g' shift, and go to state 19
state 18
State 18
7 S: 'c' 'c' B .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -1389,7 +1468,7 @@ state 18
[[$default]])[ reduce using rule 7 (S)
state 19
State 19
6 S: 'c' 'c' A 'g' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[
@@ -1398,7 +1477,7 @@ state 19
[[]], [[
state 20]AT_COND_CASE([[canonical LR]], [[
State 20]AT_COND_CASE([[canonical LR]], [[
8 A: 'd' 'e' . ['f']
9 B: 'd' 'e' . ['g']
@@ -1407,7 +1486,7 @@ state 20]AT_COND_CASE([[canonical LR]], [[
'g' reduce using rule 9 (B)
state 21
State 21
8 A: 'd' . 'e'
9 B: 'd' . 'e'
@@ -1415,7 +1494,7 @@ state 21
'e' shift, and go to state 22
state 22
State 22
8 A: 'd' 'e' . ['g']
9 B: 'd' 'e' . [$end]
@@ -1491,7 +1570,7 @@ c: ;
]],
dnl Visit each state mentioned above.
[['a', 'a']],
[[state 0
[[State 0
0 $accept: . start $end
1 start: . a b
@@ -1505,7 +1584,7 @@ dnl Visit each state mentioned above.
a go to state 3
state 1
State 1
4 a: 'a' .]AT_COND_CASE([[accepting]], [[ [$end, 'a', 'b']
@@ -1516,14 +1595,14 @@ state 1
$default reduce using rule 4 (a)]])[
state 2
State 2
0 $accept: start . $end
$end shift, and go to state 4
state 3
State 3
1 start: a . b
2 | a . b 'a'
@@ -1542,14 +1621,14 @@ state 3
c go to state 6
state 4
State 4
0 $accept: start $end .
$default accept
state 5
State 5
1 start: a b . [$end]
2 | a b . 'a'
@@ -1560,14 +1639,14 @@ state 5
[[$end]])[ reduce using rule 1 (start)
state 6
State 6
3 start: a c . 'b'
'b' shift, and go to state 8
state 7
State 7
2 start: a b 'a' .]AT_COND_CASE([[accepting]], [[ [$end]
@@ -1576,7 +1655,7 @@ state 7
$default reduce using rule 2 (start)]])[
state 8
State 8
3 start: a c 'b' .]AT_COND_CASE([[accepting]], [[ [$end]
+119 -37
View File
@@ -293,7 +293,7 @@ $@2 (9)
on left: 3, on right: 4
state 0
State 0
0 $accept: . expr $end
@@ -305,7 +305,7 @@ state 0
$@2 go to state 3
state 1
State 1
2 expr: 'a' . $@1 'b'
@@ -314,42 +314,42 @@ state 1
$@1 go to state 4
state 2
State 2
0 $accept: expr . $end
$end shift, and go to state 5
state 3
State 3
4 expr: $@2 . 'c'
'c' shift, and go to state 6
state 4
State 4
2 expr: 'a' $@1 . 'b'
'b' shift, and go to state 7
state 5
State 5
0 $accept: expr $end .
$default accept
state 6
State 6
4 expr: $@2 'c' .
$default reduce using rule 4 (expr)
state 7
State 7
2 expr: 'a' $@1 'b' .
@@ -401,15 +401,15 @@ default: 'a' }
]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:2.1: invalid character: '?'
input.y:3.14: invalid character: '}'
input.y:4.1: invalid character: '%'
input.y:4.2: invalid character: '&'
input.y:5.1-17: invalid directive: '%a-does-not-exist'
input.y:6.1: invalid character: '%'
input.y:6.2: invalid character: '-'
input.y:7.1-8.0: missing '%}' at end of file
input.y:7.1-8.0: syntax error, unexpected %{...%}
[[input.y:2.1: error: invalid character: '?'
input.y:3.14: error: invalid character: '}'
input.y:4.1: error: invalid character: '%'
input.y:4.2: error: invalid character: '&'
input.y:5.1-17: error: invalid directive: '%a-does-not-exist'
input.y:6.1: error: invalid character: '%'
input.y:6.2: error: invalid character: '-'
input.y:7.1-8.0: error: missing '%}' at end of file
input.y:7.1-8.0: error: syntax error, unexpected %{...%}
]])
AT_CLEANUP
@@ -428,7 +428,7 @@ AT_DATA([input.y],
]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:3.1-15: syntax error, unexpected %initial-action, expecting {...}
[[input.y:3.1-15: error: syntax error, unexpected %initial-action, expecting {...}
]])
AT_CLEANUP
@@ -481,6 +481,14 @@ 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
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], [[0]], [[]],
[[input.y:22.8-14: warning: symbol SPECIAL redeclared
%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
%token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]])
AT_COMPILE([input])
# Checking the error message here guarantees that yytname, which does contain
@@ -598,7 +606,7 @@ $@1 (11)
on left: 4, on right: 5
state 0
State 0
0 $accept: . CONST_DEC_PART $end
@@ -610,14 +618,14 @@ state 0
$@1 go to state 4
state 1
State 1
0 $accept: CONST_DEC_PART . $end
$end shift, and go to state 5
state 2
State 2
1 CONST_DEC_PART: CONST_DEC_LIST .
3 CONST_DEC_LIST: CONST_DEC_LIST . CONST_DEC
@@ -629,56 +637,56 @@ state 2
$@1 go to state 4
state 3
State 3
2 CONST_DEC_LIST: CONST_DEC .
$default reduce using rule 2 (CONST_DEC_LIST)
state 4
State 4
5 CONST_DEC: $@1 . undef_id_tok '=' const_id_tok ';'
undef_id_tok shift, and go to state 7
state 5
State 5
0 $accept: CONST_DEC_PART $end .
$default accept
state 6
State 6
3 CONST_DEC_LIST: CONST_DEC_LIST CONST_DEC .
$default reduce using rule 3 (CONST_DEC_LIST)
state 7
State 7
5 CONST_DEC: $@1 undef_id_tok . '=' const_id_tok ';'
'=' shift, and go to state 8
state 8
State 8
5 CONST_DEC: $@1 undef_id_tok '=' . const_id_tok ';'
const_id_tok shift, and go to state 9
state 9
State 9
5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok . ';'
';' shift, and go to state 10
state 10
State 10
5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok ';' .
@@ -917,7 +925,6 @@ m4_define([AT_CHECK_DANCER],
[AT_SETUP([Dancer $1])
AT_BISON_OPTION_PUSHDEFS([$1])
_AT_DATA_DANCER_Y([$1])
AT_BISON_CHECK([-o dancer.c dancer.y])
AT_FULL_COMPILE([dancer])
AT_PARSER_CHECK([./dancer], 1, [],
[syntax error, unexpected ':'
@@ -1002,7 +1009,6 @@ m4_define([AT_CHECK_EXPECT2],
[AT_SETUP([Expecting two tokens $1])
AT_BISON_OPTION_PUSHDEFS([$1])
_AT_DATA_EXPECT2_Y([$1])
AT_BISON_CHECK([-o expect2.c expect2.y])
AT_FULL_COMPILE([expect2])
AT_PARSER_CHECK([./expect2], 1, [],
[syntax error, unexpected '+', expecting A or B
@@ -1127,8 +1133,8 @@ a: 'a' ;
]])
AT_BISON_CHECK([[--report=all input.y]])
AT_CHECK([[sed -n '/^state 1$/,/^state 2$/p' input.output]], [[0]],
[[state 1
AT_CHECK([[sed -n '/^State 1$/,/^State 2$/p' input.output]], [[0]],
[[State 1
2 start: 'a' . a 'a'
3 a: . 'a'
@@ -1141,7 +1147,7 @@ AT_CHECK([[sed -n '/^state 1$/,/^state 2$/p' input.output]], [[0]],
a go to state 5
state 2
State 2
]])
AT_CLEANUP
@@ -1483,17 +1489,17 @@ AT_CHECK([[grep 'syntax error,' stderr.txt]], [[0]],
# Check number of default reductions in inconsistent states to be sure
# syntax error is detected before unnecessary reductions are performed.
AT_CHECK([[perl -0777 -ne 'print s/inconsistent default reduction//g;' \
AT_CHECK([[$PERL -0777 -ne 'print s/inconsistent default reduction//g;' \
< stdout.txt || exit 77]], [[0]], [[14]])
# Check number of default reductions in consistent states to be sure
# it is performed before the syntax error is detected.
AT_CHECK([[perl -0777 -ne 'print s/\bconsistent default reduction//g;' \
AT_CHECK([[$PERL -0777 -ne 'print s/\bconsistent default reduction//g;' \
< stdout.txt || exit 77]], [[0]], [[2]])
# Check number of reallocs to be sure reallocated memory isn't somehow
# lost between LAC invocations.
AT_CHECK([[perl -0777 -ne 'print s/\(realloc//g;' < stderr.txt \
AT_CHECK([[$PERL -0777 -ne 'print s/\(realloc//g;' < stderr.txt \
|| exit 77]], [[0]], [[3]])
AT_BISON_OPTION_POPDEFS
@@ -1585,3 +1591,79 @@ Stack now 0
m4_popdef([AT_LAC_CHECK])
AT_CLEANUP
## ---------------------- ##
## Lex and parse params. ##
## ---------------------- ##
# AT_TEST(SKELETON)
# -----------------
# Check that the identifier of the params is properly fetched
# even when there are trailing blanks.
m4_pushdef([AT_TEST],
[AT_SETUP([[Lex and parse params: $1]])
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" %parse-param { int x } %parse-param { int y }])
## FIXME: Improve parsing of parse-param and use the generated
## yyerror.
AT_DATA_GRAMMAR([input.y],
[[%defines
%locations
%skeleton "$1"
%union { int ival; }
%parse-param { int x }
// Spaces, tabs, and new lines.
%parse-param { @&t@
int y @&t@
@&t@
@&t@
}
%{
#include <stdio.h>
#include <stdlib.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%%
exp: 'a' { fprintf (stdout, "x: %d, y: %d\n", x, y); };
%%
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["a"])[
]AT_SKEL_CC_IF(
[int
yyparse (int x, int y)
{
yy::parser parser(x, y);
return parser.parse ();
}
])[
int
main (void)
{
return !!yyparse(1, 2);
}
]])
AT_FULL_COMPILE([input])
AT_PARSER_CHECK([./input], 0, [[x: 1, y: 2
]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
## FIXME: test Java, and iterate over skeletons.
AT_TEST([yacc.c])
AT_TEST([glr.c])
AT_TEST([lalr1.cc])
AT_TEST([glr.cc])
m4_popdef([AT_TEST])
+1 -1
View File
@@ -287,7 +287,7 @@ mv stdout expout
# Get the final state in the report, from the "accept" action..
AT_CHECK([sed -n '
/^state \(.*\)/{
/^State \(.*\)/{
s//final state \1/
x
}
+7 -7
View File
@@ -114,10 +114,10 @@ main (void)
}
]])
AT_DATA([[input-cmd-line.y]],
AT_DATA_GRAMMAR([[input-cmd-line.y]],
[AT_GRAM])
AT_DATA([[input-gram.y]],
AT_DATA_GRAMMAR([[input-gram.y]],
[[%skeleton "yacc.c"]
AT_GRAM])
@@ -157,7 +157,7 @@ start: ;
]])
AT_BISON_CHECK([[input.y]], [[1]], [[]],
[[<skeleton default value>: invalid value for %define Boolean variable 'foo'
[[<skeleton default value>: error: invalid value for %define Boolean variable 'foo'
]])
AT_CLEANUP
@@ -193,8 +193,8 @@ start: ;
AT_BISON_CHECK([[input1.y]], [[1]], [[]],
[[input1.y: warning: foow fubar
foow.y:2.3-5.3: warning: foowat fubar
input1.y: fooc fubar
fooc.y:1.1-10.5: foocat fubar
input1.y: error: fooc fubar
fooc.y:1.1-10.5: error: foocat fubar
input1.y: fatal error: foof fubar
]])
@@ -264,7 +264,7 @@ start: ;
]])
AT_BISON_CHECK([[input1.y]], [[1]], [[]],
[[input1.y: non-fatal error
[[input1.y: error: non-fatal error
input1.y: fatal error: M4 should exit immediately here
]])
@@ -315,7 +315,7 @@ print '@output(@,@)', "\n";
(print "garbage"x10, "\n") for (1..1000);
print "${M4}_divert_pop(0)\n";
]])
AT_CHECK([[perl gen-skel.pl > skel.c || exit 77]])
AT_CHECK([[$PERL gen-skel.pl > skel.c || exit 77]])
AT_DATA([[input.y]],
[[%skeleton "./skel.c"
+113 -29
View File
@@ -27,6 +27,11 @@ AT_BANNER([[User Actions.]])
# errors.
m4_define([AT_SYNCLINES_COMPILE],
[AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
# Transform stderr into something like this:
#
# input.y:4: #error "4"
#
# In case GCC displays column information, strip it down.
#
# input.y:4:2: #error "4" or
@@ -42,6 +47,12 @@ m4_define([AT_SYNCLINES_COMPILE],
# =>
# input.y:4: #error "8"
#
# The message may include a caret-error (indented by GCC 4.8,
# not by clang 3.2):
#
# input.y:1:2: error: #error "1"
# #error "1"
# ^
#
# And possibly distcc adds its bits.
#
@@ -53,20 +64,41 @@ m4_define([AT_SYNCLINES_COMPILE],
#
# distcc[35882] (dcc_connect_by_name) ERROR: failed to look up host "chrisimac": Unknown host
# distcc[35882] Warning: failed to distribute input.c to chrisimac/4, running locally instead
#
# The compiler might end by the number of messages issued (Clang 3.2):
#
# syncline.c:1:2: error: "1"
# #error "1"
# ^
# 1 error generated.
AT_CHECK([[$PERL -p -0777 - stderr <<\EOF
# 1. Remove useless lines.
AT_CHECK([[sed -e '/^distcc\[[0-9]*\] /d' \
-e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' \
-e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' \
-e "/^[^:]*: In function '[^\']*':$/d" \
stderr]],
0, [stdout])
# distcc clutter.
s/^distcc\[\d+\] .*\n//gm;
# Function context.
s/^[^:]*: In function '[^']+':\n//gm;
# Caret error.
s/^ *#error.*\n *\^\n//gm;
# Number of errors.
s/^1 error generated\.\n//gm;
# 2. Normalize the lines we kept.
# Remove column.
s/^([^:]+:\d+)[.:][^:]+:(.+)$/$][1:$][2/gm;
# Map all combinations of "error: " and "#error: " to "#error ".
s/^([^:]+:\d+):( |#error|error|:)+/$][1: #error /gm;
EOF
]],
0, [stdout])
])
# AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
# -----------------------------------------
# AT_TEST(TITLE, INPUT, ERROR-MSG)
# --------------------------------
# Check that compiling the parser produced from INPUT cause GCC
# to issue ERROR-MSG.
m4_define([AT_TEST_SYNCLINE],
m4_pushdef([AT_TEST],
[AT_SETUP([$1])
AT_BISON_OPTION_PUSHDEFS
# It seems impossible to find a generic scheme to check the location
@@ -103,12 +135,12 @@ AT_CLEANUP
])
## --------------------- ##
## Prologue synch line. ##
## --------------------- ##
## ------------------- ##
## Prologue syncline. ##
## ------------------- ##
AT_TEST_SYNCLINE([Prologue synch line],
AT_TEST([Prologue syncline],
[[%{
#error "2"
]AT_YYERROR_DECLARE_EXTERN[
@@ -122,11 +154,11 @@ exp: '0';
])
## ------------------- ##
## %union synch line. ##
## ------------------- ##
## ----------------- ##
## %union syncline. ##
## ----------------- ##
AT_TEST_SYNCLINE([%union synch line],
AT_TEST([%union syncline],
[[%union {
#error "2"
char dummy;
@@ -143,11 +175,11 @@ exp: '0';
])
## ------------------------- ##
## Postprologue synch line. ##
## ------------------------- ##
## ----------------------- ##
## Postprologue syncline. ##
## ----------------------- ##
AT_TEST_SYNCLINE([Postprologue synch line],
AT_TEST([Postprologue syncline],
[[%{
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
@@ -167,11 +199,11 @@ exp: '0';
])
## ------------------- ##
## Action synch line. ##
## ------------------- ##
## ----------------- ##
## Action syncline. ##
## ----------------- ##
AT_TEST_SYNCLINE([Action synch line],
AT_TEST([Action syncline],
[[%{
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
@@ -186,11 +218,11 @@ exp:
])
## --------------------- ##
## Epilogue synch line. ##
## --------------------- ##
## ------------------- ##
## Epilogue syncline. ##
## ------------------- ##
AT_TEST_SYNCLINE([Epilogue synch line],
AT_TEST([Epilogue syncline],
[[%{
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
@@ -202,3 +234,55 @@ exp: '0';
]],
[input.y:8: #error "8"
])
## -------------------- ##
## %code top syncline. ##
## -------------------- ##
AT_TEST([%code top syncline],
[[%code top {
#error "2"
}
%{
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%%
exp: '0';
%%
]],
[input.y:2: #error "2"
])
m4_popdef([AT_TEST])
## ----------- ##
## %no-lines. ##
## ----------- ##
m4_pushdef([AT_TEST],
[AT_SETUP([%no-lines])
AT_BISON_OPTION_PUSHDEFS([%skeleton "$1" %defines])
AT_DATA_GRAMMAR([input.y],
[%skeleton "$1" %defines
%{
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%%
exp: '0'
])
AT_BISON_CHECK([--no-lines -o input.AT_SKEL_CC_IF([cc], [c]) -d input.y])
AT_CHECK([[grep '#line' ]AT_SKEL_CC_IF([*.cc *.hh], [*.c *.h])], 1)
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
AT_TEST([yacc.c])
AT_TEST([glr.c])
AT_TEST([lalr1.cc])
AT_TEST([glr.cc])
m4_popdef([AT_TEST])
+39 -32
View File
@@ -125,7 +125,7 @@ EOF
]])
AT_BISON_OPTION_POPDEFS
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout])
mv stdout $1
])
@@ -214,7 +214,7 @@ main (void)
EOF
]])
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout])
mv stdout $1
AT_BISON_OPTION_POPDEFS
])
@@ -269,6 +269,7 @@ print <<EOF;
%error-verbose
%debug
%{
]AT_DATA_SOURCE_PROLOGUE[
# include <stdio.h>
# include <stdlib.h>
# include <assert.h>
@@ -350,7 +351,7 @@ main (void)
EOF
]])
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout])
mv stdout $1
AT_BISON_OPTION_POPDEFS
])
@@ -383,7 +384,7 @@ m4_define([AT_DATA_STACK_TORTURE],
[AT_BISON_OPTION_PUSHDEFS([$2])
# A grammar of parens growing the stack thanks to right recursion.
# exp:
AT_DATA([input.y],
AT_DATA_GRAMMAR([input.y],
[[%{
#include <errno.h>
#include <limits.h>
@@ -412,38 +413,44 @@ yylex (void)
return EOF;
}
/* Return argv[1] as an int. */
static int
get_args (int argc, const char **argv)
{
int res;
char *endp;
assert (argc == 2);
res = strtol (argv[1], &endp, 10);
assert (argv[1] != endp);
assert (0 <= res);
assert (res <= INT_MAX);
assert (errno != ERANGE);
return res;
}
int
main (int argc, const char **argv)
{
char *endp;
YYSTYPE yylval_init;
assert (argc == 2);
yylval_init = strtol (argv[1], &endp, 10);
assert (argv[1] != endp);
assert (0 <= yylval_init);
assert (yylval_init <= INT_MAX);
assert (errno != ERANGE);
yydebug = 1;
{
int count;
int status;
]m4_bmatch([$2], [%push-],
[[ yypstate *ps = yypstate_new ();
]])[ for (count = 0; count < 2; ++count)
{
int new_status;
yylval = yylval_init;
]m4_bmatch([$2], [%push-],
[[ new_status = yypull_parse (ps);
]],
[[ new_status = yyparse ();
]])[ assert (0 <= count || new_status == status);
YYSTYPE yylval_init = get_args (argc, argv);
int status = 0;
int count;
]m4_bmatch([$2], [api.push-pull both],
[[ yypstate *ps = yypstate_new ();
]])[ yydebug = 1;
for (count = 0; count < 2; ++count)
{
int new_status;
yylval = yylval_init;
new_status = ]m4_bmatch([$2], [api.push-pull both],
[[yypull_parse (ps)]],
[[yyparse ()]])[;
if (count == 0)
status = new_status;
}
]m4_bmatch([$2], [%push-],
[[ yypstate_delete (ps);
]])[ return status;
}
else
assert (new_status == status);
}]m4_bmatch([$2], [api.push-pull both],[[
yypstate_delete (ps);]])[
return status;
}
]])
AT_BISON_OPTION_POPDEFS([$2])