c++: move stack<T> inside yy::parser

We used to define such auxiliary structures outside the class, mainly
as a matter of style to keep the definition of yy::parser short and
simple.  However, now there's a lot more code generated inside the
class definition (e.g., all the token constructors), so the
readability no longer applies.

However, if we move stack (and slice) inside yy::parser, then it
should no longer be needed to change the namespace to have multiple
parsers: changing the class name should suffice.

One common argument against inner classes is that they code bloat.  It
hardly applies here, since typically different parsers will have
different semantic value types, hence different actual stack types.

* data/skeletons/lalr1.cc: Invoke b4_stack_define inside yy::parser.
This commit is contained in:
Akim Demaille
2018-12-25 18:55:18 +01:00
parent a4ede8f85b
commit f44fcd30ea
3 changed files with 121 additions and 120 deletions

View File

@@ -172,7 +172,6 @@ m4_define([b4_shared_declarations],
]b4_namespace_open[
]b4_stack_define[
]b4_bison_locations_if([m4_ifndef([b4_location_file],
[b4_location_define])])[
@@ -339,6 +338,8 @@ m4_define([b4_shared_declarations],
#endif
};
]b4_stack_define[
/// Stack type.
typedef stack<stack_symbol_type> stack_type;