| java.lang.Object org.antlr.tool.Interpreter
Interpreter | public class Interpreter implements TokenSource(Code) | | The recognition interpreter/engine for grammars. Separated
out of Grammar as it's related, but technically not a Grammar function.
You create an interpreter for a grammar and an input stream. This object
can act as a TokenSource so that you can hook up two grammars (via
a CommonTokenStream) to lex/parse. Being a token source only makes sense
for a lexer grammar of course.
|
Method Summary | |
public Token | nextToken() | public void | parse(String startRule, DebugEventListener actions, List visitedStates) | public ParseTree | parse(String startRule) | public ParseTree | parse(String startRule, List visitedStates) | protected void | parseEngine(String startRule, NFAState start, NFAState stop, IntStream input, Stack ruleInvocationStack, DebugEventListener actions, List visitedStates) | public int | predict(DFA dfa) Given an input stream, return the unique alternative predicted by
matching the input. | public void | reportScanError(RecognitionException re) | public void | scan(String startRule, DebugEventListener actions, List visitedStates) For a given input char stream, try to match against the NFA
starting at startRule. | public CommonToken | scan(String startRule) | public CommonToken | scan(String startRule, List visitedStates) |
predict | public int predict(DFA dfa)(Code) | | Given an input stream, return the unique alternative predicted by
matching the input. Upon error, return NFA.INVALID_ALT_NUMBER
The first symbol of lookahead is presumed to be primed; that is,
input.lookahead(1) must point at the input symbol you want to start
predicting with.
|
scan | public void scan(String startRule, DebugEventListener actions, List visitedStates) throws RecognitionException(Code) | | For a given input char stream, try to match against the NFA
starting at startRule. This is a deterministic parse even though
it is using an NFA because it uses DFAs at each decision point to
predict which alternative will succeed. This is exactly what the
generated parser will do.
This only does lexer grammars.
Return the token type associated with the final rule end state.
|
|
|