Package schrodinger :: Package application :: Package desmond :: Package antlr3 :: Module recognizers :: Class Parser
[hide private]
[frames] | no frames]

Class Parser

    object --+    
             |    
BaseRecognizer --+
                 |
                Parser
Known Subclasses:

@brief Baseclass for generated parser classes.

Instance Methods [hide private]
 
__init__(self, lexer, state=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
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.
 
getMissingSymbol(self, input, e, expectedTokenType, follow)
Conjure up a missing token during error recovery.
 
getSourceName(self)
 
getTokenStream(self)
 
reset(self)
reset the parser's state; subclasses must rewinds the input stream
 
setTokenStream(self, input)
Set the token stream and reset the parser
 
traceIn(self, ruleName, ruleIndex)
 
traceOut(self, ruleName, ruleIndex)

Inherited from BaseRecognizer: alreadyParsedRule, beginResync, combineFollows, computeContextSensitiveRuleFOLLOW, computeErrorRecoverySet, consumeUntil, displayRecognitionError, emitErrorMessage, endResync, failed, getBacktrackingLevel, getErrorHeader, getErrorMessage, getGrammarFileName, getNumberOfSyntaxErrors, getRuleInvocationStack, getRuleMemoization, getTokenErrorDisplay, match, matchAny, memoize, mismatchIsMissingToken, mismatchIsUnwantedToken, recover, recoverFromMismatchedSet, recoverFromMismatchedToken, reportError, setBacktrackingLevel, setInput, toStrings

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]

Inherited from BaseRecognizer (private): _getRuleInvocationStack

Class Variables [hide private]

Inherited from BaseRecognizer: DEFAULT_TOKEN_CHANNEL, HIDDEN, MEMO_RULE_FAILED, MEMO_RULE_UNKNOWN, antlr_version, antlr_version_str, tokenNames

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, lexer, state=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

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.

Overrides: BaseRecognizer.getCurrentInputSymbol
(inherited documentation)

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.

Overrides: BaseRecognizer.getMissingSymbol
(inherited documentation)

getSourceName(self)

 
Overrides: BaseRecognizer.getSourceName

reset(self)

 

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

Overrides: BaseRecognizer.reset
(inherited documentation)

traceIn(self, ruleName, ruleIndex)

 
Overrides: BaseRecognizer.traceIn

traceOut(self, ruleName, ruleIndex)

 
Overrides: BaseRecognizer.traceOut