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


10.2.5 D Parser Context Interface

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

Type of YYParser: SymbolKind

A struct containing an enum of all the grammar symbols, tokens and nonterminals. Its enumerators are forged from the symbol names. Use ‘void toString(W)(W sink)’ to get the symbol names.

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.YYERROR, or SymbolKind.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.