diff options
author | Akim Demaille <demaille@gostai.com> | 2008-10-23 20:01:48 -0500 |
---|---|---|
committer | Akim Demaille <demaille@gostai.com> | 2008-11-15 14:30:05 +0100 |
commit | cb823b6f0c5d025e3667f994222037476c41ea1a (patch) | |
tree | 6386f30270f5acaaa2d48297855c237b3ebd6a5a /examples | |
parent | 7b6e67533e54ba06ffe69664dee57a39021d2b8d (diff) | |
download | bison-cb823b6f0c5d025e3667f994222037476c41ea1a.tar.gz |
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.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/variant.yy | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/variant.yy b/examples/variant.yy index 016c4b2a..fe5dce0f 100644 --- a/examples/variant.yy +++ b/examples/variant.yy @@ -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; %% |