Previous: , Up: Java Parsers   [Contents][Index]


10.3.10 Java Declarations Summary

This summary only include declarations specific to Java or have special meaning when used in a Java parser.

Directive: %language "Java"

Generate a Java class for the parser.

Directive: %lex-param {type name}

A parameter for the lexer class defined by %code lexer only, added as parameters to the lexer constructor and the parser constructor that creates a lexer. Default is none. See Java Scanner Interface.

Directive: %parse-param {type name}

A parameter for the parser class added as parameters to constructor(s) and as fields initialized by the constructor(s). Default is none. See Java Parser Interface.

Directive: %token <type> token

Declare tokens. Note that the angle brackets enclose a Java type. See Java Semantic Values.

Directive: %nterm <type> nonterminal

Declare the type of nonterminals. Note that the angle brackets enclose a Java type. See Java Semantic Values.

Directive: %code { code … }

Code appended to the inside of the parser class. See Differences between C/C++ and Java Grammars.

Directive: %code imports { code … }

Code inserted just after the package declaration. See Differences between C/C++ and Java Grammars.

Directive: %code init { code … }

Code inserted at the beginning of the parser constructor body. See Java Parser Interface.

Directive: %code lexer { code … }

Code added to the body of a inner lexer class within the parser class. See Java Scanner Interface.

Directive: %% code

Code (after the second %%) appended to the end of the file, outside the parser class. See Differences between C/C++ and Java Grammars.

Directive: %{ code … %}

Not supported. Use %code imports instead. See Differences between C/C++ and Java Grammars.

Directive: %define api.prefix {prefix}

The prefix of the parser class name prefixParser if ‘%define api.parser.class’ is not used. Default is YY. See Java Bison Interface.

Directive: %define api.parser.abstract

Whether the parser class is declared abstract. Default is false. See Java Bison Interface.

Directive: %define api.parser.annotations {annotations}

The Java annotations for the parser class. Default is none. See Java Bison Interface.

Directive: %define api.parser.class {name}

The name of the parser class. Default is YYParser or api.prefixParser. See Java Bison Interface.

Directive: %define api.parser.extends {superclass}

The superclass of the parser class. Default is none. See Java Bison Interface.

Directive: %define api.parser.final

Whether the parser class is declared final. Default is false. See Java Bison Interface.

Directive: %define api.parser.implements {interfaces}

The implemented interfaces of the parser class, a comma-separated list. Default is none. See Java Bison Interface.

Directive: %define api.parser.public

Whether the parser class is declared public. Default is false. See Java Bison Interface.

Directive: %define api.parser.strictfp

Whether the parser class is declared strictfp. Default is false. See Java Bison Interface.

Directive: %define init_throws {exceptions}

The exceptions thrown by %code init from the parser class constructor. Default is none. See Java Parser Interface.

Directive: %define lex_throws {exceptions}

The exceptions thrown by the yylex method of the lexer, a comma-separated list. Default is java.io.IOException. See Java Scanner Interface.

Directive: %define api.location.type {class}

The name of the class used for locations (a range between two positions). This class is generated as an inner class of the parser class by bison. Default is Location. Formerly named location_type. See Java Location Values.

Directive: %define api.package {package}

The package to put the parser class in. Default is none. See Java Bison Interface. Renamed from package in Bison 3.7.

Directive: %define api.position.type {class}

The name of the class used for positions. This class must be supplied by the user. Default is Position. Formerly named position_type. See Java Location Values.

Directive: %define api.value.type {class}

The base type of semantic values. Default is Object. See Java Semantic Values.

Directive: %define throws {exceptions}

The exceptions thrown by user-supplied parser actions and %initial-action, a comma-separated list. Default is none. See Java Parser Interface.


Previous: Differences between C/C++ and Java Grammars, Up: Java Parsers   [Contents][Index]