org.antlr.runtime.Parser Class Reference

Inheritance diagram for org.antlr.runtime.Parser:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Parser (TokenStream input)
 Parser (TokenStream input, RecognizerSharedState state)
void reset ()
void setTokenStream (TokenStream input)
TokenStream getTokenStream ()
String getSourceName ()
void traceIn (String ruleName, int ruleIndex)
void traceOut (String ruleName, int ruleIndex)

Public Attributes

TokenStream input

Protected Member Functions

Object getCurrentInputSymbol (IntStream input)
Object getMissingSymbol (IntStream input, RecognitionException e, int expectedTokenType, BitSet follow)


Detailed Description

A parser for TokenStreams. "parser grammars" result in a subclass of this.

Definition at line 33 of file Parser.java.


Constructor & Destructor Documentation

org.antlr.runtime.Parser.Parser ( TokenStream  input  ) 

Definition at line 36 of file Parser.java.

org.antlr.runtime.Parser.Parser ( TokenStream  input,
RecognizerSharedState  state 
)

Definition at line 41 of file Parser.java.


Member Function Documentation

void org.antlr.runtime.Parser.reset (  ) 

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

Reimplemented from org.antlr.runtime.BaseRecognizer.

Definition at line 46 of file Parser.java.

Object org.antlr.runtime.Parser.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 53 of file Parser.java.

Object org.antlr.runtime.Parser.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.

Definition at line 57 of file Parser.java.

void org.antlr.runtime.Parser.setTokenStream ( TokenStream  input  ) 

Set the token stream and reset the parser

Definition at line 77 of file Parser.java.

TokenStream org.antlr.runtime.Parser.getTokenStream (  ) 

Definition at line 83 of file Parser.java.

String org.antlr.runtime.Parser.getSourceName (  )  [virtual]

Implements org.antlr.runtime.BaseRecognizer.

Definition at line 87 of file Parser.java.

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

Definition at line 91 of file Parser.java.

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

Definition at line 95 of file Parser.java.


Member Data Documentation

Definition at line 34 of file Parser.java.


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

Generated on Wed Oct 1 14:13:42 2008 for ANTLR API by  doxygen 1.5.5