Package antlr3

ANTLR3 runtime package. More...


Classes

class  BacktrackingFailed
 Raised to signal failed backtrack attempt. More...
class  RecognitionException
 The root of the ANTLR exception hierarchy. More...
class  MismatchedTokenException
 A mismatched char or Token or tree node. More...
class  UnwantedTokenException
 An extra token while parsing a TokenStream. More...
class  MissingTokenException
 We were expecting a token but it's not found. More...
class  MismatchedRangeException
 The next token does not match a range of expected types. More...
class  MismatchedSetException
 The next token does not match a set of expected types. More...
class  MismatchedNotSetException
 Used for remote debugger deserialization. More...
class  NoViableAltException
 Unable to decide which alternative to choose. More...
class  EarlyExitException
 The recognizer did not match anything for a (. More...
class  FailedPredicateException
 A semantic predicate failed during validation. More...
class  MismatchedTreeNodeException
 The next tree mode does not match the expected type. More...
class  Token
 Abstract token baseclass. More...
class  CommonToken
 Basic token implementation. More...
class  ClassicToken
 Alternative token implementation. More...
class  IntStream
 Base interface for streams of integer values. More...
class  CharStream
 A source of characters for an ANTLR lexer. More...
class  TokenStream
 A stream of tokens accessing tokens from a TokenSource. More...
class  ANTLRStringStream
 CharStream that pull data from a unicode string. More...
class  ANTLRFileStream
 CharStream that opens a file to read the data. More...
class  ANTLRInputStream
 CharStream that reads data from a file-like object. More...
class  CommonTokenStream
 The most common stream of tokens. More...
class  RewriteOperation
 Internal helper class. More...
class  InsertBeforeOp
 Internal helper class. More...
class  ReplaceOp
 Internal helper class. More...
class  DeleteOp
 Internal helper class. More...
class  TokenRewriteStream
 CommonTokenStream that can be modified. More...
class  RecognizerSharedState
 The set of fields needed by an abstract recognizer to recognize input and recover from errors etc. More...
class  BaseRecognizer
 Common recognizer functionality. More...
class  TokenSource
 Abstract baseclass for token producers. More...
class  Lexer
 Baseclass for generated lexer classes. More...
class  Parser
 Baseclass for generated parser classes. More...
class  RuleReturnScope
 Rules can return start/stop info as well as possible trees and templates. More...
class  ParserRuleReturnScope
 Rules that return more than a single value must return an object containing all the values. More...

Packages

package  tree
 ANTLR3 runtime package, tree module.
package  treewizard

Functions

def version_str_to_tuple
def consumeUntil
 def recoverFromMissingElement(self, input, e, follow): """ This code is factored out from mismatched token and mismatched set recovery.
def getRuleInvocationStack
def _getRuleInvocationStack
 A more general version of getRuleInvocationStack where you can pass in, for example, a RecognitionException to get it's rule stack trace.
def getBacktrackingLevel
def setBacktrackingLevel
def failed
 Return whether or not a backtracking attempt failed.
def getGrammarFileName
 For debugging and other purposes, might want the grammar name.
def getSourceName
def toStrings
 A convenience method for use most often with template rewrites.
def getRuleMemoization
 Given a rule number and a start token index number, return MEMO_RULE_UNKNOWN if the rule has not parsed input starting from start index.
def alreadyParsedRule
 Has this rule already parsed input at the current index in the input stream? Return the stop token index or MEMO_RULE_UNKNOWN.
def memoize
 Record whether or not this rule parsed the input at this position successfully.
def traceIn
def traceOut

Variables

string __version__ = '3.1.3'
 runtime_version_str = __version__
tuple runtime_version = version_str_to_tuple(runtime_version_str)
int EOF = 1
int DEFAULT_CHANNEL = 0
 All tokens go to the parser (unless skip() is called in that rule) on a particular "channel".
int HIDDEN_CHANNEL = 99
 Anything on different channel than DEFAULT_CHANNEL is not parsed by parser.
int EOR_TOKEN_TYPE = 1
int DOWN = 2
 imaginary tree navigation type; traverse "get child" link
int UP = 3
 imaginary tree navigation type; finish with a child list
int MIN_TOKEN_TYPE = 1
int INVALID_TOKEN_TYPE = 0
tuple EOF_TOKEN = CommonToken(type=EOF)
tuple INVALID_TOKEN = CommonToken(type=INVALID_TOKEN_TYPE)
tuple SKIP_TOKEN = CommonToken(type=INVALID_TOKEN_TYPE)
 StringStream = ANTLRStringStream
 FileStream = ANTLRFileStream
 InputStream = ANTLRInputStream
tuple _getRuleInvocationStack = classmethod(_getRuleInvocationStack)


Detailed Description

ANTLR3 runtime package.

This module contains all support classes, which are needed to use recognizers generated by ANTLR3.


Function Documentation

def antlr3._getRuleInvocationStack (   cls,
  module 
) [private]

A more general version of getRuleInvocationStack where you can pass in, for example, a RecognitionException to get it's rule stack trace.

This routine is shared with all recognizers, hence, static.

TODO: move to a utility class or something; weird having lexer call this

Definition at line 3288 of file antlr3.py.

def antlr3.alreadyParsedRule (   self,
  input,
  ruleIndex 
)

Has this rule already parsed input at the current index in the input stream? Return the stop token index or MEMO_RULE_UNKNOWN.

If we attempted but failed to parse properly before, return MEMO_RULE_FAILED.

This method has a side-effect: if we have seen this input for this rule and successfully parsed before, then seek ahead to 1 past the stop token matched for this rule last time.

Definition at line 3386 of file antlr3.py.

def antlr3.consumeUntil (   self,
  input,
  tokenTypes 
)

def recoverFromMissingElement(self, input, e, follow): """ This code is factored out from mismatched token and mismatched set recovery.

It handles "single token insertion" error recovery for both. No tokens are consumed to recover from insertions. Return true if recovery was possible else return false. """ if self.mismatchIsMissingToken(input, follow): self.reportError(e) return True # nothing to do; throw exception return False Consume tokens until one matches the given token or token set

tokenTypes can be a single token type or a set of token types

Definition at line 3241 of file antlr3.py.

def antlr3.failed (   self  ) 

Return whether or not a backtracking attempt failed.

Definition at line 3325 of file antlr3.py.

def antlr3.getBacktrackingLevel (   self  ) 

Definition at line 3316 of file antlr3.py.

def antlr3.getGrammarFileName (   self  ) 

For debugging and other purposes, might want the grammar name.

Have ANTLR generate an implementation for this method.

Definition at line 3335 of file antlr3.py.

def antlr3.getRuleInvocationStack (   self  ) 

Definition at line 3252 of file antlr3.py.

def antlr3.getRuleMemoization (   self,
  ruleIndex,
  ruleStartIndex 
)

Given a rule number and a start token index number, return MEMO_RULE_UNKNOWN if the rule has not parsed input starting from start index.

If this rule has parsed input starting from the start index before, then return where the rule stopped parsing. It returns the index of the last token matched by the rule.

Definition at line 3365 of file antlr3.py.

def antlr3.getSourceName (   self  ) 

Definition at line 3340 of file antlr3.py.

def antlr3.memoize (   self,
  input,
  ruleIndex,
  ruleStartIndex,
  success 
)

Record whether or not this rule parsed the input at this position successfully.

Definition at line 3406 of file antlr3.py.

def antlr3.setBacktrackingLevel (   self,
  n 
)

Definition at line 3319 of file antlr3.py.

def antlr3.toStrings (   self,
  tokens 
)

A convenience method for use most often with template rewrites.

Convert a List<Token> to List<String>

Definition at line 3349 of file antlr3.py.

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

Definition at line 3417 of file antlr3.py.

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

Definition at line 3426 of file antlr3.py.

def antlr3.version_str_to_tuple (   version_str  ) 

Definition at line 144 of file antlr3.py.


Variable Documentation

string antlr3.__version__ = '3.1.3'

Definition at line 142 of file antlr3.py.

Definition at line 3313 of file antlr3.py.

All tokens go to the parser (unless skip() is called in that rule) on a particular "channel".

The parser tunes to a particular channel so that whitespace etc... can go to the parser on a "hidden" channel.

Definition at line 529 of file antlr3.py.

int antlr3.DOWN = 2

imaginary tree navigation type; traverse "get child" link

Definition at line 540 of file antlr3.py.

int antlr3.EOF = 1

Definition at line 524 of file antlr3.py.

Definition at line 947 of file antlr3.py.

Definition at line 536 of file antlr3.py.

Definition at line 1544 of file antlr3.py.

Anything on different channel than DEFAULT_CHANNEL is not parsed by parser.

Definition at line 533 of file antlr3.py.

Definition at line 1545 of file antlr3.py.

Definition at line 949 of file antlr3.py.

Definition at line 547 of file antlr3.py.

Definition at line 545 of file antlr3.py.

tuple antlr3.runtime_version = version_str_to_tuple(runtime_version_str)

Definition at line 164 of file antlr3.py.

Definition at line 163 of file antlr3.py.

Definition at line 953 of file antlr3.py.

Definition at line 1543 of file antlr3.py.

int antlr3.UP = 3

imaginary tree navigation type; finish with a child list

Definition at line 543 of file antlr3.py.


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