mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-12 05:43:03 +00:00
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.
This commit is contained in:
@@ -72,7 +72,7 @@ b4_variant_if([
|
||||
# ----------------------------
|
||||
m4_define([b4_symbol_value],
|
||||
[m4_ifval([$2],
|
||||
[$1.as<$2>()],
|
||||
[$1.as< $2 >()],
|
||||
[$1])])
|
||||
|
||||
# b4_symbol_value_template(VAL, [TYPE])
|
||||
@@ -80,7 +80,7 @@ b4_variant_if([
|
||||
# Same as b4_symbol_value, but used in a template method.
|
||||
m4_define([b4_symbol_value_template],
|
||||
[m4_ifval([$2],
|
||||
[$1.template as<$2>()],
|
||||
[$1.template as< $2 >()],
|
||||
[$1])])
|
||||
]) # b4_variant_if
|
||||
|
||||
@@ -366,7 +366,7 @@ m4_map([b4_symbol_constructor_definition_], m4_defn([b4_symbol_numbers]))])])
|
||||
# YYTYPE.
|
||||
m4_define([b4_symbol_variant],
|
||||
[m4_pushdef([b4_dollar_dollar],
|
||||
[$2.$3<$][3>(m4_shift3($@))])dnl
|
||||
[$2.$3< $][3 >(m4_shift3($@))])dnl
|
||||
switch ($1)
|
||||
{
|
||||
m4_map([b4_type_action_], m4_defn([b4_type_names]))[]dnl
|
||||
|
||||
Reference in New Issue
Block a user