|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.antlr.runtime.BaseRecognizer
org.antlr.runtime.tree.TreeParser
public class TreeParser
A parser for a stream of tree nodes. "tree grammars" result in a subclass of this. All the error reporting and recovery is shared with Parser via the BaseRecognizer superclass.
| Field Summary | |
|---|---|
static int |
DOWN
|
protected TreeNodeStream |
input
|
static int |
UP
|
| Fields inherited from class org.antlr.runtime.BaseRecognizer |
|---|
DEFAULT_TOKEN_CHANNEL, HIDDEN, INITIAL_FOLLOW_STACK_SIZE, MEMO_RULE_FAILED, MEMO_RULE_UNKNOWN, NEXT_TOKEN_RULE_NAME, state |
| Constructor Summary | |
|---|---|
TreeParser(TreeNodeStream input)
|
|
TreeParser(TreeNodeStream input,
RecognizerSharedState state)
|
|
| Method Summary | |
|---|---|
protected static Object |
getAncestor(TreeAdaptor adaptor,
String[] tokenNames,
Object t,
String goal)
Helper for static inContext |
protected Object |
getCurrentInputSymbol(IntStream input)
Match needs to return the current input symbol, which gets put into the label for the associated token ref; e.g., x=ID. |
String |
getErrorHeader(RecognitionException e)
Prefix error message with the grammar name because message is always intended for the programmer because the parser built the input tree not the user. |
String |
getErrorMessage(RecognitionException e,
String[] tokenNames)
Tree parsers parse nodes they usually have a token object as payload. |
protected Object |
getMissingSymbol(IntStream input,
RecognitionException e,
int expectedTokenType,
BitSet follow)
Conjure up a missing token during error recovery. |
String |
getSourceName()
|
TreeNodeStream |
getTreeNodeStream()
|
boolean |
inContext(String context)
Check if current node in input has a context. |
static boolean |
inContext(TreeAdaptor adaptor,
String[] tokenNames,
Object t,
String context)
The worker for inContext. |
void |
matchAny(IntStream ignore)
Match '.' in tree parser has special meaning. |
protected Object |
recoverFromMismatchedToken(IntStream input,
int ttype,
BitSet follow)
We have DOWN/UP nodes in the stream that have no line info; override. |
void |
reset()
reset the parser's state; subclasses must rewinds the input stream |
void |
setTreeNodeStream(TreeNodeStream input)
Set the input stream |
void |
traceIn(String ruleName,
int ruleIndex)
|
void |
traceOut(String ruleName,
int ruleIndex)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DOWN
public static final int UP
protected TreeNodeStream input
| Constructor Detail |
|---|
public TreeParser(TreeNodeStream input)
public TreeParser(TreeNodeStream input,
RecognizerSharedState state)
| Method Detail |
|---|
public void reset()
BaseRecognizer
reset in class BaseRecognizerpublic void setTreeNodeStream(TreeNodeStream input)
public TreeNodeStream getTreeNodeStream()
public String getSourceName()
getSourceName in class BaseRecognizerprotected Object getCurrentInputSymbol(IntStream input)
BaseRecognizer
getCurrentInputSymbol in class BaseRecognizer
protected Object getMissingSymbol(IntStream input,
RecognitionException e,
int expectedTokenType,
BitSet follow)
BaseRecognizer
getMissingSymbol in class BaseRecognizerpublic void matchAny(IntStream ignore)
matchAny in class BaseRecognizer
protected Object recoverFromMismatchedToken(IntStream input,
int ttype,
BitSet follow)
throws RecognitionException
recoverFromMismatchedToken in class BaseRecognizerRecognitionExceptionpublic String getErrorHeader(RecognitionException e)
getErrorHeader in class BaseRecognizer
public String getErrorMessage(RecognitionException e,
String[] tokenNames)
getErrorMessage in class BaseRecognizerpublic boolean inContext(String context)
public static boolean inContext(TreeAdaptor adaptor,
String[] tokenNames,
Object t,
String context)
protected static Object getAncestor(TreeAdaptor adaptor,
String[] tokenNames,
Object t,
String goal)
public void traceIn(String ruleName,
int ruleIndex)
public void traceOut(String ruleName,
int ruleIndex)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||