Commit Graph

7 Commits

Author SHA1 Message Date
Akim Demaille
6653c912da glr.c: factor the calls to yylex
The call protocol of yylex is quite complex, and repeated three
times.  Let's factor it.

* data/skeletons/glr.c (yygetToken): New.
Use it.
2018-12-31 07:31:27 +01:00
Akim Demaille
5bcd4292bb style: reduce scopes in glr.c
* data/skeletons/glr.c (yyrecoverSyntaxError): here.
2018-12-31 07:29:50 +01:00
Akim Demaille
7ff7ef678c c++: inline the implementation of syntax_error in its definition
This way, it is easier to make sure its implementation is available in
glr.cc too, which is not the case currently.

* data/skeletons/c++.m4 (b4_public_types_define): Move the
implementation of syntax_error...
(b4_public_types_declare): here.
2018-12-30 10:16:03 +01:00
Akim Demaille
0dc44adbf6 parsers: fix minor stylistic issues
* data/skeletons/variant.hh (b4_token_constructor_declare): Remove,
unused since the previous commit.
Fix indentation issues.
* data/skeletons/c++.m4: Fix indentation issues.
2018-12-27 18:23:49 +01:00
Akim Demaille
5fb0d276b3 c++: variants: fuse declarations and definitions
We used to create a short definition of yy::parser with all the
implementations of its member functions outside.  But yy::parser is no
longer short and simple to read.  Maintaining each function twice is
painful: a lot of redundancy but different indentation levels, output
which depends on whether we are in a header or not (see
d132c2d545), etc.

Let's simplify this and put the implementations into the class
definition itself.

Discussed in this monologue:
https://lists.gnu.org/archive/html/bison-patches/2018-12/msg00058.html.

* data/skeletons/c++.m4, data/skeletons/lalr1.cc,
* data/skeletons/variant.hh (b4_basic_symbol_constructor_define)
(_b4_token_constructor_declare, b4_token_constructor_declare)
Merge into...
(b4_basic_symbol_constructor_define, _b4_token_constructor_define)
(b4_token_constructor_define): these.
2018-12-26 09:12:25 +01:00
Akim Demaille
f44fcd30ea 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.
2018-12-26 08:24:38 +01:00
Akim Demaille
112ccb5ed7 package: move skeletons into data/skeletons
* data/bison.m4, data/c++-skel.m4, data/c++.m4, data/c-like.m4,
* data/c-skel.m4, data/c.m4, data/d-skel.m4, data/d.m4, data/glr.c,
* data/glr.cc, data/java-skel.m4, data/java.m4, data/lalr1.cc,
* data/lalr1.d, data/lalr1.java, data/location.cc, data/stack.hh,
* data/variant.hh, data/yacc.c:
Move to...
* data/skeletons: here.
Use b4_skeletonsdir instead of b4_pkgdatadir.

* data/local.mk, src/output.c: Adjust.
2018-12-25 07:47:51 +01:00