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

10.2.5 Java Parser Context Interface

The parser context provides information to build error reports when you invoke ‘%define parse.error custom’.

Type of YYParser: SymbolKind

An enum of all the grammar symbols, tokens and nonterminals. Its enumerators are forged from the symbol names:

public enum SymbolKind
  S_YYEOF(0),          /* "end of file"  */
  S_YYERROR(1),        /* error  */
  S_YYUNDEF(2),        /* "invalid token"  */
  S_BANG(3),           /* "!"  */
  S_PLUS(4),           /* "+"  */
  S_MINUS(5),          /* "-"  */
  S_NUM(13),           /* "number"  */
  S_NEG(14),           /* NEG  */
  S_YYACCEPT(15),      /* $accept  */
  S_input(16),         /* input  */
  S_line(17);          /* line  */
Method on YYParser.SymbolKind: String getName ()

The name of this symbol, possibly translated.

Method on YYParser.Context: YYParser.SymbolKind getToken ()

The kind of the lookahead. Return null iff there is no lookahead.

Method on YYParser.Context: YYParser.Location getLocation ()

The location of the lookahead.

Method on YYParser.Context: int getExpectedTokens (YYParser.SymbolKind[] argv, int argc)

Fill argv with the expected tokens, which never includes SymbolKind.S_YYERROR, or SymbolKind.S_YYUNDEF.

Never put more than argc elements into argv, and on success return the number of tokens stored in argv. If there are more expected tokens than argc, fill argv up to argc and return 0. If there are no expected tokens, also return 0, but set argv[0] to null.

If argv is null, return the size needed to store all the possible values, which is always less than YYNTOKENS.