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
tuple antlr_version = (3, 0, 1, 0)
string antlr_version_str = "3.0.1"

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 2539 of file antlr3.py.


Member Function Documentation

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

Definition at line 2558 of file antlr3.py.

def antlr3.BaseRecognizer.setInput (   self,
  input 
)

Definition at line 2592 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 2600 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 2630 of file antlr3.py.

def antlr3.BaseRecognizer.matchAny (   self,
  input 
)

Match the wildcard: in a symbol.

Definition at line 2648 of file antlr3.py.

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

Definition at line 2654 of file antlr3.py.

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

Definition at line 2658 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 2690 of file antlr3.py.


Member Data Documentation

Definition at line 2541 of file antlr3.py.

Definition at line 2542 of file antlr3.py.

Definition at line 2545 of file antlr3.py.

Definition at line 2548 of file antlr3.py.

Definition at line 2551 of file antlr3.py.

tuple antlr3.BaseRecognizer.antlr_version = (3, 0, 1, 0) [static]

Definition at line 2555 of file antlr3.py.

string antlr3.BaseRecognizer.antlr_version_str = "3.0.1" [static]

Definition at line 2556 of file antlr3.py.

Reimplemented in antlr3.Lexer, and antlr3.Parser.

Definition at line 2560 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 2569 of file antlr3.py.


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

Generated on Tue Aug 12 11:42:05 2008 for ANTLR Python API by  doxygen 1.5.5