antlr

Class LLkParser

Known Direct Subclasses:
ANTLRParser, ANTLRTokdefParser, LLkDebuggingParser, ParseTreeDebugParser, Preprocessor

public class LLkParser
extends Parser

An LL(k) parser.
See Also:
Token, TokenBuffer

Field Summary

(package private) int
k

Fields inherited from class antlr.Parser

astFactory, inputState, returnAST, tokenNames, tokenTypeToASTClassMap, traceDepth

Constructor Summary

LLkParser(ParserSharedInputState state, int k_)
LLkParser(TokenBuffer tokenBuf, int k_)
LLkParser(TokenStream lexer, int k_)
LLkParser(int k_)

Method Summary

int
LA(int i)
Token
LT(int i)
void
consume()
Consume another token from the input stream.
void
traceIn(String rname)
void
traceOut(String rname)

Methods inherited from class antlr.Parser

LA, LT, addMessageListener, addParserListener, addParserMatchListener, addParserTokenListener, addSemanticPredicateListener, addSyntacticPredicateListener, addTraceListener, consume, consumeUntil, consumeUntil, defaultDebuggingSetup, getAST, getASTFactory, getFilename, getInputState, getTokenName, getTokenNames, getTokenTypeToASTClassMap, isDebugMode, mark, match, match, matchNot, panic, recover, removeMessageListener, removeParserListener, removeParserMatchListener, removeParserTokenListener, removeSemanticPredicateListener, removeSyntacticPredicateListener, removeTraceListener, reportError, reportError, reportWarning, rewind, setASTFactory, setASTNodeClass, setASTNodeType, setDebugMode, setFilename, setIgnoreInvalidDebugCalls, setInputState, setTokenBuffer, traceIn, traceIndent, traceOut

Field Details

k

(package private)  int k

Constructor Details

LLkParser

public LLkParser(ParserSharedInputState state,
                 int k_)

LLkParser

public LLkParser(TokenBuffer tokenBuf,
                 int k_)

LLkParser

public LLkParser(TokenStream lexer,
                 int k_)

LLkParser

public LLkParser(int k_)

Method Details

LA

public int LA(int i)
            throws TokenStreamException
Overrides:
LA in interface Parser

LT

public Token LT(int i)
            throws TokenStreamException
Overrides:
LT in interface Parser

consume

public void consume()
            throws TokenStreamException
Consume another token from the input stream. Can only write sequentially! If you need 3 tokens ahead, you must consume() 3 times.

Note that it is possible to overwrite tokens that have not been matched. For example, calling consume() 3 times when k=2, means that the first token consumed will be overwritten with the 3rd.

Overrides:
consume in interface Parser

traceIn

public void traceIn(String rname)
            throws TokenStreamException
Overrides:
traceIn in interface Parser

traceOut

public void traceOut(String rname)
            throws TokenStreamException
Overrides:
traceOut in interface Parser