antlr3.BaseRecognizer Class Reference

Common recognizer functionality. More...

Inheritance diagram for antlr3.BaseRecognizer:

Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def setInput
def reset
 reset the parser's state; subclasses must rewinds the input stream
def match
 Match current input symbol against ttype.
def matchAny
 Match the wildcard: in a symbol.
def mismatchIsUnwantedToken
def mismatchIsMissingToken
def mismatch
 Factor out what to do upon token mismatch so tree parsers can behave differently.

Public Attributes

 input

Static Public Attributes

int MEMO_RULE_FAILED = 2
int MEMO_RULE_UNKNOWN = 1
 DEFAULT_TOKEN_CHANNEL = DEFAULT_CHANNEL
 HIDDEN = HIDDEN_CHANNEL
 tokenNames = None

Private Attributes

 _state
 State of a lexer, parser, or tree parser are collected into a state object so the state can be shared.


Detailed Description

Common recognizer functionality.

A generic recognizer that can handle recognizers generated from lexer, parser, and tree grammars. This is all the parsing support code essentially; most of it is error recovery stuff and backtracking.

Definition at line 2428 of file antlr3.py.


Member Function Documentation

def antlr3.BaseRecognizer.__init__ (   self,
  state = None 
)

Definition at line 2442 of file antlr3.py.

def antlr3.BaseRecognizer.setInput (   self,
  input 
)

Definition at line 2457 of file antlr3.py.

def antlr3.BaseRecognizer.reset (   self  ) 

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

Reimplemented in antlr3.Lexer, and antlr3.Parser.

Definition at line 2465 of file antlr3.py.

def antlr3.BaseRecognizer.match (   self,
  input,
  ttype,
  follow 
)

Match current input symbol against ttype.

Attempt single token insertion or deletion error recovery. If that fails, throw MismatchedTokenException.

To turn off single token insertion or deletion error recovery, override mismatchRecover() and have it call plain mismatch(), which does not recover. Then any error in a rule will cause an exception and immediate exit from rule. Rule would recover by resynchronizing to the set of symbols that can follow rule ref.

Definition at line 2495 of file antlr3.py.

def antlr3.BaseRecognizer.matchAny (   self,
  input 
)

Match the wildcard: in a symbol.

Definition at line 2513 of file antlr3.py.

def antlr3.BaseRecognizer.mismatchIsUnwantedToken (   self,
  input,
  ttype 
)

Definition at line 2519 of file antlr3.py.

def antlr3.BaseRecognizer.mismatchIsMissingToken (   self,
  input,
  follow 
)

Definition at line 2523 of file antlr3.py.

def antlr3.BaseRecognizer.mismatch (   self,
  input,
  ttype,
  follow 
)

Factor out what to do upon token mismatch so tree parsers can behave differently.

Override and call mismatchRecover(input, ttype, follow) to get single token insertion and deletion. Use this to turn of single token insertion and deletion. Override mismatchRecover to call this instead.

Definition at line 2555 of file antlr3.py.


Member Data Documentation

Definition at line 2430 of file antlr3.py.

Definition at line 2431 of file antlr3.py.

Definition at line 2434 of file antlr3.py.

Definition at line 2437 of file antlr3.py.

Definition at line 2440 of file antlr3.py.

Reimplemented in antlr3.Lexer, and antlr3.Parser.

Definition at line 2444 of file antlr3.py.

State of a lexer, parser, or tree parser are collected into a state object so the state can be shared.

This sharing is needed to have one grammar import others and share same error variables and other state variables. It's a kind of explicit multiple inheritance via delegation of methods and shared state.

Definition at line 2453 of file antlr3.py.


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

Generated on Tue May 20 18:34:06 2008 for ANTLR Python API by  doxygen 1.5.5