antlr3.Parser Class Reference

Baseclass for generated parser classes. More...

Inheritance diagram for antlr3.Parser:

Inheritance graph
[legend]
Collaboration diagram for antlr3.Parser:

Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def reset
 reset the parser's state; subclasses must rewinds the input stream
def getCurrentInputSymbol
 Match needs to return the current input symbol, which gets put into the label for the associated token ref; e.g., x=ID.
def getMissingSymbol
 Conjure up a missing token during error recovery.
def setTokenStream
 Set the token stream and reset the parser.
def getTokenStream
def getSourceName
def traceIn
def traceOut

Public Attributes

 input


Detailed Description

Baseclass for generated parser classes.

Definition at line 3818 of file antlr3.py.


Member Function Documentation

def antlr3.Parser.__init__ (   self,
  lexer,
  state = None 
)

Definition at line 3820 of file antlr3.py.

def antlr3.Parser.reset (   self  ) 

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

Reimplemented from antlr3.BaseRecognizer.

Definition at line 3826 of file antlr3.py.

def antlr3.Parser.getCurrentInputSymbol (   self,
  input 
)

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 antlr3.BaseRecognizer.

Definition at line 3832 of file antlr3.py.

def antlr3.Parser.getMissingSymbol (   self,
  input,
  e,
  expectedTokenType,
  follow 
)

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 antlr3.BaseRecognizer.

Definition at line 3836 of file antlr3.py.

def antlr3.Parser.setTokenStream (   self,
  input 
)

Set the token stream and reset the parser.

Definition at line 3855 of file antlr3.py.

def antlr3.Parser.getTokenStream (   self  ) 

Definition at line 3862 of file antlr3.py.

def antlr3.Parser.getSourceName (   self  ) 

Definition at line 3866 of file antlr3.py.

def antlr3.Parser.traceIn (   self,
  ruleName,
  ruleIndex 
)

Definition at line 3870 of file antlr3.py.

def antlr3.Parser.traceOut (   self,
  ruleName,
  ruleIndex 
)

Definition at line 3874 of file antlr3.py.


Member Data Documentation

Reimplemented from antlr3.BaseRecognizer.

Definition at line 3857 of file antlr3.py.


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

Generated on Mon Nov 29 17:24:28 2010 for ANTLR Python API by  doxygen 1.5.5