mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +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:
@@ -46,13 +46,14 @@ typedef std::list<std::string> strings_type;
|
||||
}
|
||||
}
|
||||
|
||||
%token <std::string> TEXT;
|
||||
%token <::std::string> TEXT;
|
||||
%token <int> NUMBER;
|
||||
%printer { debug_stream () << $$; } <int> <std::string> <strings_type>;
|
||||
%printer { debug_stream () << $$; }
|
||||
<int> <::std::string> <::std::list<std::string>>;
|
||||
%token END_OF_FILE 0;
|
||||
|
||||
%type <std::string> item;
|
||||
%type <strings_type> list;
|
||||
%type <::std::string> item;
|
||||
%type <::std::list<std::string>> list;
|
||||
|
||||
%%
|
||||
|
||||
|
||||
Reference in New Issue
Block a user