(The current Java interface is experimental and may evolve. More user feedback will help to stabilize it.)
The Java parser skeletons are selected using the
directive or the -L java/--language=java option.
When generating a Java parser,
create a single Java source file named basename.java
containing the parser implementation. Using a grammar file without a
.y suffix is currently broken. The basename of the parser
implementation file can be changed by the
directive or the -p/--name-prefix option. The
entire parser implementation file name can be changed by the
%output directive or the -o/--output option.
The parser implementation file contains a single class for the parser.
You can create documentation for generated parsers using Javadoc.
Contrary to C parsers, Java parsers do not use global variables; the
state of the parser is always local to an instance of the parser class.
Therefore, all Java parsers are “pure”, and the
%define api.pure full directives does not do anything when used in
Push parsers are currently unsupported in Java and
api.push-pull have no effect.
GLR parsers are currently unsupported in Java. Do not use the
No header file can be generated for Java parsers. Do not use the
%defines directive or the -d/--defines options.
Currently, support for debugging and verbose errors are always compiled
in. Thus the
%token-table directives and the
-t/--debug and -k/--token-table
options have no effect. This may change in the future to eliminate
unused code in the generated parser, so use
%verbose-error explicitly if needed. Also, in the future the
%token-table directive might enable a public interface to
access the token names and codes.