程序包 org.antlr.tool
类 Interpreter
- java.lang.Object
-
- org.antlr.tool.Interpreter
-
- 所有已实现的接口:
TokenSource
public class Interpreter extends java.lang.Object implements TokenSource
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.
-
-
构造器概要
构造器 构造器 说明 Interpreter(Grammar grammar, IntStream input)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 java.lang.String
getSourceName()
Where are you getting tokens from? normally the implication will simply ask lexers input stream.Token
nextToken()
Return a Token object from your input stream (usually a CharStream).ParseTree
parse(java.lang.String startRule)
ParseTree
parse(java.lang.String startRule, java.util.List<NFAState> visitedStates)
void
parse(java.lang.String startRule, DebugEventListener actions, java.util.List<NFAState> visitedStates)
protected void
parseEngine(java.lang.String startRule, NFAState start, NFAState stop, IntStream input, java.util.Stack<NFAState> ruleInvocationStack, DebugEventListener actions, java.util.List<NFAState> visitedStates)
Fill a list of all NFA states visited during the parseint
predict(DFA dfa)
Given an input stream, return the unique alternative predicted by matching the input.void
reportScanError(RecognitionException re)
CommonToken
scan(java.lang.String startRule)
CommonToken
scan(java.lang.String startRule, java.util.List<NFAState> visitedStates)
void
scan(java.lang.String startRule, DebugEventListener actions, java.util.List<NFAState> visitedStates)
For a given input char stream, try to match against the NFA starting at startRule.
-
-
-
方法详细资料
-
nextToken
public Token nextToken()
从接口复制的说明:TokenSource
Return a Token object from your input stream (usually a CharStream). Do not fail/return upon lexing error; keep chewing on the characters until you get a good one; errors are not passed through to the parser.- 指定者:
nextToken
在接口中TokenSource
-
scan
public void scan(java.lang.String startRule, DebugEventListener actions, java.util.List<NFAState> visitedStates) throws RecognitionException
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.
-
scan
public CommonToken scan(java.lang.String startRule) throws RecognitionException
-
scan
public CommonToken scan(java.lang.String startRule, java.util.List<NFAState> visitedStates) throws RecognitionException
-
parse
public void parse(java.lang.String startRule, DebugEventListener actions, java.util.List<NFAState> visitedStates) throws RecognitionException
-
parse
public ParseTree parse(java.lang.String startRule) throws RecognitionException
-
parse
public ParseTree parse(java.lang.String startRule, java.util.List<NFAState> visitedStates) throws RecognitionException
-
parseEngine
protected void parseEngine(java.lang.String startRule, NFAState start, NFAState stop, IntStream input, java.util.Stack<NFAState> ruleInvocationStack, DebugEventListener actions, java.util.List<NFAState> visitedStates) throws RecognitionException
Fill a list of all NFA states visited during the parse
-
predict
public int predict(DFA dfa)
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.
-
reportScanError
public void reportScanError(RecognitionException re)
-
getSourceName
public java.lang.String getSourceName()
从接口复制的说明:TokenSource
Where are you getting tokens from? normally the implication will simply ask lexers input stream.- 指定者:
getSourceName
在接口中TokenSource
-
-