org.antlr.runtime.tree.TreeParser Class Reference

Inheritance diagram for org.antlr.runtime.tree.TreeParser:

Inheritance graph
[legend]
Collaboration diagram for org.antlr.runtime.tree.TreeParser:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 TreeParser (TreeNodeStream input)
 TreeParser (TreeNodeStream input, RecognizerSharedState state)
void reset ()
void setTreeNodeStream (TreeNodeStream input)
TreeNodeStream getTreeNodeStream ()
String getSourceName ()
void matchAny (IntStream ignore)
String getErrorHeader (RecognitionException e)
String getErrorMessage (RecognitionException e, String[] tokenNames)
void traceIn (String ruleName, int ruleIndex)
void traceOut (String ruleName, int ruleIndex)

Static Public Attributes

static final int DOWN = Token.DOWN
static final int UP = Token.UP

Protected Member Functions

Object getCurrentInputSymbol (IntStream input)
Object getMissingSymbol (IntStream input, RecognitionException e, int expectedTokenType, BitSet follow)
void mismatch (IntStream input, int ttype, BitSet follow) throws RecognitionException

Protected Attributes

TreeNodeStream input


Detailed Description

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.

Definition at line 36 of file TreeParser.java.


Constructor & Destructor Documentation

org.antlr.runtime.tree.TreeParser.TreeParser ( TreeNodeStream  input  ) 

Definition at line 42 of file TreeParser.java.

org.antlr.runtime.tree.TreeParser.TreeParser ( TreeNodeStream  input,
RecognizerSharedState  state 
)

Definition at line 47 of file TreeParser.java.


Member Function Documentation

void org.antlr.runtime.tree.TreeParser.reset (  ) 

reset the parser's state; subclasses must rewinds the input stream

Reimplemented from org.antlr.runtime.BaseRecognizer.

Definition at line 52 of file TreeParser.java.

void org.antlr.runtime.tree.TreeParser.setTreeNodeStream ( TreeNodeStream  input  ) 

Set the input stream

Definition at line 60 of file TreeParser.java.

TreeNodeStream org.antlr.runtime.tree.TreeParser.getTreeNodeStream (  ) 

Definition at line 64 of file TreeParser.java.

String org.antlr.runtime.tree.TreeParser.getSourceName (  )  [virtual]

Implements org.antlr.runtime.BaseRecognizer.

Definition at line 68 of file TreeParser.java.

Object org.antlr.runtime.tree.TreeParser.getCurrentInputSymbol ( IntStream  input  )  [protected]

Match needs to return the current input symbol, which gets put into the label for the associated token ref; e.g., x=ID. Token and tree parsers need to return different objects. Rather than test for input stream type or change the IntStream interface, I use a simple method to ask the recognizer to tell me what the current input symbol is.

This is ignored for lexers.

Reimplemented from org.antlr.runtime.BaseRecognizer.

Definition at line 72 of file TreeParser.java.

Object org.antlr.runtime.tree.TreeParser.getMissingSymbol ( IntStream  input,
RecognitionException  e,
int  expectedTokenType,
BitSet  follow 
) [protected]

Conjure up a missing token during error recovery.

The recognizer attempts to recover from single missing symbols. But, actions might refer to that missing symbol. For example, x=ID {f($x);}. The action clearly assumes that there has been an identifier matched previously and that $x points at that token. If that token is missing, but the next token in the stream is what we want we assume that this token is missing and we keep going. Because we have to return some token to replace the missing token, we have to conjure one up. This method gives the user control over the tokens returned for missing tokens. Mostly, you will want to create something special for identifier tokens. For literals such as '{' and ',', the default action in the parser or tree parser works. It simply creates a CommonToken of the appropriate type. The text will be the token. If you change what tokens must be created by the lexer, override this method to create the appropriate tokens.

Reimplemented from org.antlr.runtime.BaseRecognizer.

Reimplemented in org.antlr.runtime.debug.DebugTreeParser.

Definition at line 76 of file TreeParser.java.

void org.antlr.runtime.tree.TreeParser.matchAny ( IntStream  ignore  ) 

Match '.' in tree parser has special meaning. Skip node or entire tree if node has children. If children, scan until corresponding UP node.

Reimplemented from org.antlr.runtime.BaseRecognizer.

Definition at line 90 of file TreeParser.java.

void org.antlr.runtime.tree.TreeParser.mismatch ( IntStream  input,
int  ttype,
BitSet  follow 
) throws RecognitionException [protected]

We have DOWN/UP nodes in the stream that have no line info; override. plus we want to alter the exception type. Don't try to recover from tree parser errors inline...

Reimplemented from org.antlr.runtime.BaseRecognizer.

Definition at line 120 of file TreeParser.java.

String org.antlr.runtime.tree.TreeParser.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.

Reimplemented from org.antlr.runtime.BaseRecognizer.

Definition at line 130 of file TreeParser.java.

String org.antlr.runtime.tree.TreeParser.getErrorMessage ( RecognitionException  e,
String[]  tokenNames 
)

Tree parsers parse nodes they usually have a token object as payload. Set the exception token and do the default behavior.

Reimplemented from org.antlr.runtime.BaseRecognizer.

Definition at line 138 of file TreeParser.java.

void org.antlr.runtime.tree.TreeParser.traceIn ( String  ruleName,
int  ruleIndex 
)

Definition at line 150 of file TreeParser.java.

void org.antlr.runtime.tree.TreeParser.traceOut ( String  ruleName,
int  ruleIndex 
)

Definition at line 154 of file TreeParser.java.


Member Data Documentation

Definition at line 37 of file TreeParser.java.

Definition at line 38 of file TreeParser.java.

Definition at line 40 of file TreeParser.java.


The documentation for this class was generated from the following file:

Generated on Tue Aug 12 11:41:59 2008 for ANTLR API by  doxygen 1.5.5