Commit Graph

683 Commits

Author SHA1 Message Date
Akim Demaille
56f772e95e lalr1.cc: avoid GCC 4.3 warnings.
GCC 4.3 now warns about "a || b && c" and asks for explicit
parentheses.
Reported by Alexandre Duret-Lutz.
	* data/location.cc: Update copyright years.
	(Position::operator==): Use parens to make precedence explicit.
	Compare lines and columns first, as they are more likely to be
	different, and they are faster to compare.
2009-03-27 07:26:24 +01:00
Akim Demaille
91be6b283e Comment changes. 2009-03-02 17:06:55 +01:00
Akim Demaille
cbf25ce74f Share b4_yytranslate_define.
* data/lalr1.cc (b4_yytranslate_define): Move to...
	* data/c++.m4: here.
2009-03-02 16:34:09 +01:00
Akim Demaille
0623bacc05 Dub make_TOKEN as a public type interface.
* data/c++.m4 (b4_symbol_constructor_declare)
	(b4_symbol_constructor_define): New empty stubs.
	(b4_public_types_declare, b4_public_types_define): Use them.
	* data/lalr1.cc (b4_symbol_constructor_declare)
	(b4_symbol_constructor_declare_)
	(b4_symbol_constructor_define_, b4_symbol_constructor_define):
	Move to...
	* data/variant.hh: here.
	Remove the "b4_variant_if" parts, as variant.hh is loaded only if
	needed.
	* data/lalr1.cc: No longer invoke b4_symbol_constructor_define and
	b4_symbol_constructor_declare, as it is now done by
	b4_public_types_define and b4_public_types_declare.
2009-03-02 16:27:48 +01:00
Akim Demaille
5f5a90dff6 Coding style changes.
* data/lalr1.cc (b4_symbol_constructor_declaration_)
	(b4_symbol_constructor_declarations)
	(b4_symbol_constructor_definition_)
	(b4_symbol_constructor_definitions)
	(b4_yytranslate_definition): Rename as...
	(b4_symbol_constructor_declare_)
	(b4_symbol_constructor_declare)
	(b4_symbol_constructor_define_)
	(b4_symbol_constructor_define)
	(b4_yytranslate_define): these.
	* data/variant.hh (b4_variant_definition): Rename as...
	(b4_variant_define): this.
2009-03-02 16:24:21 +01:00
Akim Demaille
b47b6ff7fd Factor b4_assert_if, b4_lex_symbol_if, and b4_variant_if.
* data/bison.m4 (b4_percent_define_if_define): New.
	* data/c++.m4 (b4_variant_if): Move to...
	* data/bison.m4: Here, using b4_percent_define_if_define.
	* data/lalr1.cc (b4_assert_if, b4_lex_symbol_if): Move to...
	* data/bison.m4: Here, using b4_percent_define_if_define.
2009-03-02 16:20:26 +01:00
Akim Demaille
1d6b689b26 Dub symbol_type_base as a public type.
* data/c++.m4 (b4_public_types_declare): Now define
	symbol_type_base and symbol_type.
	(b4_public_types_define): New.
	In both cases, the definitions are taken verbatim from lalr1.cc.
	* data/lalr1.cc: Adjust.
2009-03-02 16:15:28 +01:00
Akim Demaille
4f84717d23 b4_public_types_declare.
* data/c++.m4 (b4_public_types_declare): New.
	* data/glr.cc, data/lalr1.cc: Use it.
2009-03-02 16:12:11 +01:00
Akim Demaille
b9e4eb5b72 b4_semantic_type_declare.
* data/c++.m4 (b4_semantic_type_declare): New.
	Factors and generalizes what was in glr.cc and lalr1.cc.
	* data/variant.hh (b4_semantic_type_declare): Redefine it for
	variants.
	* data/lalr1.cc, data/glr.cc: Use it.
2009-03-02 16:08:07 +01:00
Akim Demaille
e9e61b0002 Remove useless arguments.
* data/glr.c (yy_reduce_print): $$ and @$ are not used and not
	relevant.
2009-02-25 23:45:46 +01:00
Akim Demaille
3eead995a4 Comment changes.
* data/lalr1.cc: here.
2009-02-25 23:41:40 +01:00
Akim Demaille
87f28efe7e Fix glr.cc's debug level handling.
* data/glr.cc (yydebug_): Remove, as it is actually yydebug from
	glr.c which is used.
	(debug_level, set_debug_level): Adjust.
2009-02-25 23:38:27 +01:00
Akim Demaille
9be2a009c4 Copyright years.
* data/glr.c: Add 2007 and 2008 here, consistenly with the comments.
2009-02-25 23:34:45 +01:00
Akim Demaille
33c78bd23e Comment change.
* data/lalr1.cc: here.
2009-02-25 23:28:15 +01:00
Akim Demaille
49572920dd Make yyparser::error public.
* data/lalr1.cc: here.
	There is no good reason to keep it private (and it is convenient
	to use it from the scanner for instance).  It is already public in
	glr.cc.
2009-02-19 22:16:19 +01:00
Akim Demaille
88654b47c9 Comment changes.
* data/glr.cc: here.
2009-02-19 22:12:44 +01:00
Akim Demaille
4524c55bcf Remove trailing blanks.
The epilogue has its own ending \n, no need to add another.

	* data/glr.c, data/lalr1.java, data/yacc.c: dnl when outputing the
	epilogue.
	* data/glr.cc: dnl when extending the epilogue.
	Remove stray "private:".
2009-02-19 22:08:08 +01:00
Akim Demaille
6ceccee88d Use b4_c_modern.
* data/c.m4 (b4_c_function_decl): Here.
2009-02-19 22:02:56 +01:00
Akim Demaille
9c6a89660e Comment changes.
* data/lalr1.cc: here.
2009-02-19 21:58:13 +01:00
Akim Demaille
507aa0e2a8 Extract variant.hh
* data/variant.hh: New, extracted from...
	* data/lalr1.cc: here.
	Adjust.
	* data/local.mk: Adjust.
2009-02-19 21:53:58 +01:00
Akim Demaille
51bacae6b5 Extract stack.hh from lalr1.cc.
* data/stack.hh: New.
	* data/lalr1.cc: Extract from here.
	* data/local.mk: Adjust.
2009-02-19 21:49:46 +01:00
Samuel Tardieu
253192e69a Force a large alignment of a variant structure.
This is a temporary band-aid until Bison gets proper alignment handling.
We need it on ARM.

	* data/lalr1.cc (variant): Declare the buffer as a union to force
	the same alignment as "long double".
2009-01-28 15:46:05 +01:00
Akim Demaille
84eedf86fe Pass the token type to yysyntax_error.
* data/yacc.c (yysyntax_error): Take the transated token instead
	of the raw number.
	Adjust callers.
	* TODO: Update.
2008-12-11 10:47:14 +01:00
Akim Demaille
5860cc8c1c Formatting changes.
* data/glr.c: Formatting changes.
2008-12-11 10:47:10 +01:00
Akim Demaille
2b008529ed Propagate i18n changes into glr.c.
* TODO: Update.
	* data/glr.c (yyreportSyntaxError): Use "switch" instead of
	building the error message format dynamically.
	* data/lalr1.java: Formatting changes.
2008-12-11 10:47:06 +01:00
Akim Demaille
eeb2942237 Simplify the i18n of the error messages.
* data/lalr1.cc: Comment changes.
	* data/yacc.c (yysyntax_error): Rewrite, using a switch as in
	lalr1.cc instead of building dynamically the format string.
2008-12-11 10:45:52 +01:00
Akim Demaille
2ca1136c7c Update data/README.
* data/README: Document glr.cc, lalr1.java, m4sugar and xslt.
2008-12-08 09:47:35 +01:00
Akim Demaille
6c63b895fb Install autoconf as a submodule to get m4sugar.
* .gitmodules: Add submodules/autoconf.
	* data/m4sugar/foreach.m4, data/m4sugar/m4sugar.m4: Now links into
	submodules/autoconf.
2008-12-08 09:47:31 +01:00
Akim Demaille
417e31d2c3 Test token.prefix in all the skeletons.
* data/java.m4 (b4_token_enum): Use the token.prefix.
	* tests/local.at (AT_BISON_OPTION_PUSHDEFS): Define AT_TOKEN_PREFIX.
	* tests/calc.at (_AT_DATA_CALC_Y): Use it.
	Add checks for yacc.c, glr.c, lalr1.cc and glr.cc.
	* tests/java.at: Comment changes.
	(AT_CHECK_JAVA_MINIMAL): Define the END token.
	(Java parser class and package names): Add token.prefix check.
2008-12-08 09:47:26 +01:00
Akim Demaille
3bb211139b Use b4_symbol for printers and destructors everywhere.
* data/bison.m4 (b4_symbol_action_location): New.
	* data/c.m4 (b4_symbol_actions): Remove.
	Adjust all callers to use by b4_symbol_foreach and the corresponding
	b4_symbol_printer/destructor macro.
	* data/glr.cc: Adjust.
	* data/lalr1.java: Adjust the %destructor sanity check.
	* src/output.c (symbol_code_props_output): Remove, we no longer
	need the b4_symbol_printers/destructors tables.
2008-12-01 22:32:33 +01:00
Akim Demaille
fb7c5b1f23 Use b4_symbol_case_.
* data/lalr1.cc, data/bison.m4 (b4_symbol_action): Use
	b4_symbol_case_.
2008-12-01 22:29:20 +01:00
Akim Demaille
cf6fb2226d Move b4_symbol based macro to bison.m4.
* data/lalr1.cc (b4_symbol_, b4_symbol, b4_symbol_if)
	(b4_symbol_action, b4_symbol_destructor, b4_symbol_printer)
	(b4_symbol_case_, b4_symbol_foreach, b4_type_action_)
	(b4_type_foreach): Move to...
	* data/bison.m4: Here.
	* data/lalr1.cc (b4_symbol_action): Specialize for C++: use
	b4_symbol_value_template instead of b4_symbol_value.

s b4_symbols in bison.m4
2008-12-01 22:25:51 +01:00
Akim Demaille
e3c52a6362 b4_symbol/type_foreach.
* data/lalr1.cc (b4_symbol_foreach, b4_type_foreach): New.
	Use them.
2008-12-01 22:22:35 +01:00
Akim Demaille
2bde91138d Use the symbol properties to output the printer/destructor for lalr1.cc.
Instead of defining complex list of tuples to define various properties of
the symbols, we now prefer to define symbols as "structs" in m4: using the
symbol key (its number), and the property name, b4_symbol gives it value.
Use this to handle destructors and printers.

	* src/output.c (CODE_PROP): New.
	(prepare_symbol_definitions): Use it to define the printer and
	destructor related attributes of the symbols.
	* data/lalr1.cc (b4_symbol_actions): Rename as...
	(b4_symbol_action): this.
	Use b4_symbol instead of 6 arguments.
	(b4_symbol_printer, b4_symbol_destructor): New.
	Use them instead of b4_symbol_actions.
2008-12-01 22:19:11 +01:00
Akim Demaille
fad814bd0c Remove spurious empty line before syncline.
* data/bison.m4 (b4_syncline): Don't output an empty line before
	the output.
2008-12-01 22:11:50 +01:00
Akim Demaille
728e89a09b Use b4_parser_tables_define in glr.cc.
* data/glr.c: Use b4_parser_tables_define instead of defining the
	(deterministic integral) tables by hand.
2008-11-26 10:11:46 +01:00
Akim Demaille
2c1bf9bd68 Use b4_parser_tables_define in Java.
* data/java.m4 (b4_typed_parser_table): Rename as...
	(b4_typed_parser_table_define): this, for consistency.
	Accept a comment as $4.
	Move $2 into yy*_.
	(b4_integral_parser_table): Rename as...
	(b4_integral_parser_table_define): this.
	* data/lalr1.java: Adjust all uses.
	Use b4_parser_tables_define instead of generation by hand.
2008-11-26 10:08:41 +01:00
Akim Demaille
ba206cf40a Prepare the convergence bw C style and Java table generation.
* data/bison.m4 (b4_tables_map, b4_tables_declare)
	(b4_tables_define): Rename as...
	(b4_integral_parser_tables_map, b4_parser_tables_declare)
	(b4_parser_tables_define): these.
	* data/c.m4 (b4_table_define): Rename as...
	(b4_integral_parser_table_define): this.
	* data/lalr1.cc: Adjust.
	(b4_table_define, b4_table_declare): Rename as...
	(b4_integral_parser_table_define)
	(b4_integral_parser_table_declare): these.
	(yyrline_): Move the comment where it is actually used.
	* data/yacc.c: Adjust.
	(yyrline): Use b4_integral_parser_table_define.
2008-11-26 10:05:20 +01:00
Akim Demaille
0991e29b75 Factor the generation of the (integral) tables bw yacc.c and lalr1.cc.
* data/lalr1.cc (b4_tables_map): Move to...
	* data/bison.m4: here.
	Update the comment for yytable during the flight.
	(b4_tables_declare, b4_tables_define): New.
	* data/lalr1.cc: Use them.
	* data/c.m4 (b4_table_define): New.
	* data/yacc.c: Use b4_tables_define instead of output the tables
	by hand.
	* tests/regression.at (Web2c Actions): Adjust the expected output,
	the order of the tables changed.
2008-11-26 09:58:50 +01:00
Akim Demaille
932b0c960a Get rid of lalr1-split.cc.
It was no longer maintainer.

	* data/lalr1-split.cc: Remove.
	* etc/bench.pl.in (bench_fusion_parser): Remove.
	Adjust.
2008-11-26 09:48:24 +01:00
Akim Demaille
8452c667e6 Use yy* consistently.
* data/glr.c: Now that yyrhs no longer exists as a global
	variable, rename local "rhs" variables into "yyrhs" for
	consistency.
2008-11-26 09:44:21 +01:00
Akim Demaille
783aa653f4 Get rid of yyrhs and yyprhs in glr.c.
* data/glr.c (yyrhs, yyprhs): Remove.
	Instead, use the state stack and yystos.
2008-11-25 23:11:34 +01:00
Akim Demaille
b4f1840114 Get rid of yyrhs and yyprhs in larl1.java.
* data/lalr1.java (yyrhs_, yyprhs_): Remove.
	(yy_reduce_print): Rather, use yystos_ and the state stack.
2008-11-25 22:50:10 +01:00
Akim Demaille
68dbdee86a Get rid of yyrhs and yyprhs in yacc.c.
They were used to get the symbol types, given a rule number,  when
displaying the top of the stack before a reduction.  But the symbol type
is available from the state stack.  This has two be benefits: two tables
less in the parser (making it smaller), and a more consistent use of the
three stacks which will help to fuse them.

	* data/yacc.c (yyprhs, yyrhs): Remove.
	(YY_REDUCE_PRINT): Pass yyssp to yy_reduce_print.
	(yy_reduce_print): Take yyssp as argument.
	Use it, together with yystos, to get the symbol type.
	* tests/regression.at (Web2c Report): Remove these tables from the
	expected output.
2008-11-25 22:21:24 +01:00
Akim Demaille
6ab1adbe1e b4_tables_map.
The point is to factor the generation of the tables across skeletons.
This is language dependant.

	* data/c.m4 (b4_comment_): New.
	Should be usable to define how to generate tables independently of
	the language.
	(b4_c_comment): New.
	(b4_comment): Bounce to b4_c_comment.
	Now support $2 = [PREFIX] for indentation.
	* data/lalr1.cc (b4_table_declare): Don't output a comment if
	there is no comment.
	Indent it properly when there is one.
	Output the ending semicolon.
	(b4_table_define): Space changes.
	Output the ending semicolon.
	(b4_tables_map): New.
	Use it twice instead of declaring and defining the (integral)
	tables by hand.
2008-11-25 22:18:09 +01:00
Akim Demaille
0fddb3d59f b4_table_declare.
* data/lalr1.cc (b4_table_declare): New.
	Use it to declare the tables defined with b4_table_define.
	(b4_table_define): Declare a third arg to match b4_table_declare
	signature.
	Move all the comments around invocations of b4_table_define into
	the invocations itselves.
	Move things around to have the order for declarations and
	definitions.
2008-11-25 22:14:39 +01:00
Akim Demaille
c4ddc0fb0b Formatting changes.
* data/lalr1.java: here.
2008-11-25 22:11:09 +01:00
Akim Demaille
e0c653e7e6 b4_args is more general than only C++.
* data/lalr1.cc (b4_args, _b4_args): Move to...
	* data/bison.m4: here.
2008-11-25 22:07:23 +01:00
Joel E. Denny
6c88b51e83 Fix unexpanded macros in GLR defines file.
Reported by Csaba Raduly at
<http://lists.gnu.org/archive/html/bug-bison/2008-11/msg00048.html>.
* THANKS (Csaba Raduly): Add.
* data/glr.c: Fix overquoting on b4_prefix for yylval and yylloc.
* tests/calc.at (_AT_DATA_CALC_Y): If %defines is specified, generate
lexer in a separate module that includes the defines file.
(AT_CHECK_CALC): From AT_FULL_COMPILE, request compilation of lexer
source.
* tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Push AT_DEFINES_IF.
Adjust AT_LOC and AT_VAL to use AT_NAME_PREFIX.
(AT_BISON_OPTION_POPDEFS): Pop AT_DEFINES_IF.
(AT_DATA_SOURCE_PROLOGUE): New.
(AT_DATA_GRAMMAR_PROLOGUE): Use AT_DATA_SOURCE_PROLOGUE.
(AT_DATA_SOURCE): New.
(AT_FULL_COMPILE): Extend to support an additional source file.
2008-11-19 00:24:34 -05:00
Akim Demaille
bd187d7b65 Use b4_subtract where possible.
* data/lalr1.cc (b4_subtract): Move to...
	* data/bison.m4: here.
	* data/glr.c (b4_rhs_data): Use it.
	* data/yacc.c (b4_rhs_value, b4_rhs_location): Use it.
2008-11-18 20:57:26 +01:00