java: add push-parser support
authorDennis Heimbigner <dmh@unidata.ucar.edu>
Thu, 13 Jun 2013 08:08:19 +0000 (10:08 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Thu, 13 Jun 2013 08:38:14 +0000 (10:38 +0200)
commitaa94def12d5256d2bd3d5ed49d905f00372a0111
tree7d9b45fd39730671dc1609c5aff187d2e1052613
parent0fcc2e9a740785bc2aade5199f979832ebd74fdf
java: add push-parser support

* data/lalr1.java: Capture the declarations as m4 macros to avoid
duplication.  When push parsing, the declarations occur at the class
instance level rather than within the parse() function.

Change the way that the parser state is initialized.  For
push-parsing, the parse state declarations are moved to
"push_parse_initialize()", which is called on the first invocation of
"push_parse()". The %initial-action code is also inserted after the
invocation of "push_parse_initialize()".

The body of the parse loop is modified to return values at appropriate
points when doing push parsing.  In order to make push parsing work,
it is necessary to divide YYNEWSTATE into two states: YYNEWSTATE and
YYGETTOKEN. On the first call to push_parse(), the state is
YYNEWSTATE. On all later entries, the state is set to YYGETTOKEN. The
YYNEWSTATE switch arm falls through into YYGETTOKEN. YYGETTOKEN
indicates that a new token is potentially needed.  Normally, with a
pull parser, this new token would be obtained by calling "yylex()". In
the push parser, the value YYMORE is returned to the caller. On the
next call to push_parse(), the parser will return to the YYGETTOKEN
state and continue operation.

* tests/javapush.at: New test file for java push parsing.
* tests/testsuite.at: Use it.
* tests/local.mk: Adjust.
* doc/bison.texi (Java Push Parser Interface): New.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
NEWS
data/lalr1.java
doc/bison.texi
tests/javapush.at [new file with mode: 0644]
tests/local.mk
tests/testsuite.at