Commit Graph

15 Commits

Author SHA1 Message Date
Akim Demaille
304b384ea3 examples: minor improvements
* examples/variant.yy: Don't use debug_stream(), obsoleted.
Use <*>.
2012-12-26 10:38:59 +01:00
Akim Demaille
ae8880deec doc: update variant usage
* doc/bison.texi, examples/variant.yy: Use "%define api.value.type variant",
instead of "%define variant".
2012-12-26 10:31:42 +01:00
Akim Demaille
e36ec1f41f lalr1.cc: rename lex_symbol as api.token.constructor
* data/bison.m4 (b4_lex_symbol_if): Rename as...
(b4_token_ctor_if): this.
Depend upon api.token.constructor.
* data/c++.m4, data/lalr1.cc: Adjust.
* doc/bison.texi: Fix all the occurrences of lex_symbol.
* etc/bench.pl.in: Adjust.
* examples/variant.yy: Likewise.

* tests/local.at (AT_BISON_OPTION_PUSHDEFS, AT_BISON_OPTION_POPDEFS):
Handle AT_TOKEN_CTOR_IF.
* tests/c++.at: Adjust to using api.token.constructor and AT_TOKEN_CTOR_IF.
Simplify the test of both build call styles.
(AT_CHECK_VARIANTS): Rename as...
(AT_TEST): this.
And undef when done.
2012-11-01 18:26:04 +01:00
Akim Demaille
0b3287025d examples: simplify/improve
* examples/variant.yy: Put yylex in yy::, and simplify accordingly.
Minor formatting changes.
2012-11-01 18:26:04 +01:00
Akim Demaille
72c12bfa1b variant: fix the example.
* examples/variant.yy: Adjust to "assert" being now
	"parse.assert".
2012-02-14 20:14:55 +01:00
Akim Demaille
3272a7256f maint: add license headers.
* examples/calc++/test, examples/variant.yy, AUTHORS, THANKS,
	* tests/atlocal.in, tests/bison.in: Add license headers.
	Reported by Tys Lefering.
2012-02-14 20:08:20 +01:00
Akim Demaille
882f02ed83 Use locations in the variant example.
Yes, this obfuscates the point of this example, variants only.  But glr.cc
cannot work (yet?) without locations.  This change makes it easier to use
this example with glr.cc.

	* examples/variant.yy (assert): %define it.
	(locations): Request them.
	(yylex): Bind the location to the stage.
2009-03-02 16:30:57 +01:00
Akim Demaille
cb823b6f0c Support parametric types.
There are two issues to handle: first scanning nested angle bracket pairs
to support types such as std::pair< std::string, std::list<std::string> > >.

Another issue is to address idiosyncracies of C++: do not glue two closing
angle brackets together (otherwise it's operator>>), and avoid sticking
blindly a TYPE to the opening <, as it can result in '<:' which is a
digraph for '['.

	* src/scan-gram.l (brace_level): Rename as...
	(nesting): this.
	(SC_TAG): New.
	Implement support for complex tags.
	(tag): Accept \n, but not <.
	* data/lalr1.cc (b4_symbol_value, b4_symbol_value_template)
	(b4_symbol_variant): Leave space around types as parameters.
	* examples/variant.yy: Use nested template types and leading ::.
	* src/parse-gram.y (TYPE, TYPE_TAG_ANY, TYPE_TAG_NONE, type.opt):
	Rename as...
	(TAG, TAG_ANY, TAG_NONE, tag.opt): these.
	* tests/c++.at: Test parametric types.
2008-11-15 14:30:05 +01:00
Akim Demaille
0078681b6b Update variant.yy to newest interface.
* examples/variant.yy: Define lex_symbol.
	Adjust.
2008-11-15 11:29:57 +01:00
Akim Demaille
ff084799a3 Don't use locations in variant.yy.
* examples/variant.yy: Adjust to not using locations.
2008-11-15 11:26:58 +01:00
Akim Demaille
36db78a733 Update the variant example.
* examples/variant.yy: Formatting changes.
	One stage build.
2008-11-10 11:08:09 +01:00
Akim Demaille
5de9c59301 Use a static hierarchy for symbols in the C++ parser.
* data/lalr1.cc (symbol_base_type, symbol_type)
	(stack_symbol_type): Make it a static hierarchy.
	Adjust dependencies.
2008-11-09 19:57:30 +01:00
Akim Demaille
f6038cb8c3 Use "%define variant" in bench.pl.
* etc/bench.pl.in: No longer use the pseudo directive %variants,
	just use %define variants.
2008-11-07 21:37:56 +01:00
Akim Demaille
9718cfa902 Make variant.yy more complex.
std::list cannot be copied via memcpy, they are more demanding than
std::string.  Use one std::list to strengthen the test.

	* examples/variant.yy: Use lalr1-fusion.cc, not lalr1.cc.
	Adjust.
	Create a list of strings, instead of a single large string.
2008-11-04 21:43:19 +01:00
Akim Demaille
5ab8c47bcf Use variants to support objects as semantic values.
This patch was inspired by work by Michiel De Wilde.  But he used Boost
variants which (i) requires Boost on the user side, (ii) is slow, and
(iii) has useless overhead (the parser knows the type of the semantic value
there is no reason to duplicate this information as Boost.Variants do).

This implementation reserves a buffer large enough to store the largest
objects.  yy::variant implements this buffer.  It was implemented with
Quentin Hocquet.

	* src/output.c (type_names_output): New.
	(output_skeleton): Invoke it.
	* data/c++.m4 (b4_variant_if): New.
	(b4_symbol_value): If needed, provide a definition for variants.
	* data/lalr1.cc (b4_symbol_value, b4_symbol_action_)
	(b4_symbol_variant, _b4_char_sizeof_counter, _b4_char_sizeof_dummy)
	(b4_char_sizeof, yy::variant): New.
	(parser::parse): If variants are requested, define
	parser::union_type, parser::variant, change the definition of
	semantic_type, construct $$ before running the user action instead
	of performing a default $$ = $1.
	* examples/variant.yy: New.
	Based on an example by Michiel De Wilde.
2008-11-03 21:50:48 +01:00