Home | Trees | Index | Help |
|
---|
Package parserFwk :: Module pyparsing :: Class ParserElement |
|
object
--+
|
ParserElement
ParseElementEnhance
,
ParseExpression
,
Token
Method Summary | |
---|---|
__init__(self,
savelist)
| |
Implementation of + operator - returns And | |
Implementation of & operator - returns Each | |
Implementation of ~ operator - returns NotAny | |
Implementation of | operator - returns MatchFirst | |
Implementation of += operator | |
Implementation of right-& operator | |
__repr__(self)
| |
Implementation of |= operator | |
Implementation of ^= operator | |
__str__(self)
| |
Implementation of ^ operator - returns Or | |
Add parse action to expression's list of parse actions. | |
checkRecursion(self,
parseElementList)
| |
Make a copy of this ParserElement. | |
Enables "packrat" parsing, which adds memoizing to the parsing logic. (Static method) | |
Define expression to be ignored (e.g., comments) while doing pattern matching; may be called repeatedly, to define multiple comment or other ignorable patterns. | |
Disables the skipping of whitespace before matching the characters in the ParserElement's defined pattern. | |
Internal method used to decorate parse actions that take fewer than 3 arguments, so that all parse actions can be called as f(s,l,t). (Static method) | |
Execute the parse expression on the given file or filename. | |
parseImpl(self,
instring,
loc,
doActions)
| |
Execute the parse expression with the given string. | |
Overrides default behavior to expand <TAB>s to spaces before parsing the input string. | |
postParse(self,
instring,
loc,
tokenlist)
| |
preParse(self,
instring,
loc)
| |
resetCache()
(Static method) | |
Scan the input string for expression matches. | |
Another extension to scanString, simplifying the access to the tokens found to match the given parse expression. | |
Enable display of debugging messages while doing pattern matching. | |
Enable display of debugging messages while doing pattern matching. | |
Overrides the default whitespace chars (Static method) | |
Define action to perform if parsing fails at this expression. | |
Define name for this expression, for use in debugging. | |
Define action to perform when successfully matching parse element definition. | |
Define name for referencing matching tokens as a nested attribute of the returned parse results. | |
Overrides the default whitespace chars | |
skipIgnorables(self,
instring,
loc)
| |
streamline(self)
| |
Suppresses the output of this ParserElement; useful to keep punctuation from cluttering up returned output. | |
Extension to scanString, to modify matching text with modified tokens that may be returned from a parse action. | |
tryParse(self,
instring,
loc)
| |
Check defined expressions for valid structure, check for infinite recursive definitions. | |
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__
|
Class Variable Summary | |
---|---|
str |
DEFAULT_WHITE_CHARS = ' \n\t\r'
|
Instance Method Details |
---|
__add__(self,
other)
Implementation of + operator - returns And
|
__and__(self,
other)
Implementation of & operator - returns Each
|
__invert__(self)Implementation of ~ operator - returns NotAny |
__or__(self,
other)
Implementation of | operator - returns MatchFirst
|
__radd__(self,
other)
Implementation of += operator
|
__rand__(self, other)Implementation of right-& operator |
__ror__(self, other)Implementation of |= operator |
__rxor__(self, other)Implementation of ^= operator |
__xor__(self, other)Implementation of ^ operator - returns Or |
addParseAction(self, *fns)Add parse action to expression's list of parse actions. See setParseAction_. |
copy(self)Make a copy of this ParserElement. Useful for defining different parse actions for the same parsing pattern, using copies of the original parse element. |
ignore(self, other)Define expression to be ignored (e.g., comments) while doing pattern matching; may be called repeatedly, to define multiple comment or other ignorable patterns. |
leaveWhitespace(self)Disables the skipping of whitespace before matching the characters in the ParserElement's defined pattern. This is normally only used internally by the pyparsing module, but may be needed in some whitespace-sensitive grammars. |
parseFile(self, file_or_filename)Execute the parse expression on the given file or filename. If a filename is specified (instead of a file object), the entire file is opened, read, and closed before parsing. |
parseString(self, instring)Execute the parse expression with the given string. This is the main interface to the client code, once the complete expression has been built. |
parseWithTabs(self)Overrides default behavior to expand <TAB>s to spaces before parsing the input string. Must be called before parseString when the input grammar contains elements that match <TAB> characters. |
scanString(self, instring, maxMatches=2147483647)Scan the input string for expression matches. Each match will return the matching tokens, start location, and end location. May be called with optional maxMatches argument, to clip scanning after 'n' matches are found. |
searchString(self, instring, maxMatches=2147483647)Another extension to scanString, simplifying the access to the tokens found to match the given parse expression. May be called with optional maxMatches argument, to clip searching after 'n' matches are found. |
setDebug(self, flag=True)Enable display of debugging messages while doing pattern matching. |
setDebugActions(self, startAction, successAction, exceptionAction)Enable display of debugging messages while doing pattern matching. |
setFailAction(self, fn)Define action to perform if parsing fails at this expression. Fail acton fn is a callable function that takes the arguments fn(s,loc,expr,err) where:
|
setName(self, name)Define name for this expression, for use in debugging. |
setParseAction(self, *fns)Define action to perform when successfully matching parse element definition. Parse action fn is a callable method with 0-3 arguments, called as fn(s,loc,toks), fn(loc,toks), fn(toks), or just fn(), where:
|
setResultsName(self, name, listAllMatches=False)Define name for referencing matching tokens as a nested attribute of the returned parse results. NOTE: this returns a *copy* of the original ParserElement object; this is so that the client can define a basic element, such as an integer, and reference it in multiple places with different names. |
setWhitespaceChars(self, chars)Overrides the default whitespace chars |
suppress(self)Suppresses the output of this ParserElement; useful to keep punctuation from cluttering up returned output. |
transformString(self, instring)Extension to scanString, to modify matching text with modified tokens that may be returned from a parse action. To use transformString, define a grammar and attach a parse action to it that modifies the returned token list. Invoking transformString() on a target string will then scan for matches, and replace the matched text patterns according to the logic in the parse action. transformString() returns the resulting transformed string. |
validate(self, validateTrace=[])Check defined expressions for valid structure, check for infinite recursive definitions. |
Static Method Details |
---|
enablePackrat()Enables "packrat" parsing, which adds memoizing to the parsing logic. Repeated parse attempts at the same string location (which happens often in many complex grammars) can immediately return a cached value, instead of re-executing parsing/validating code. Memoizing is done of both valid results and parsing exceptions. This speedup may break existing programs that use parse actions that have side-effects. For this reason, packrat parsing is disabled when you first import pyparsing. To activate the packrat feature, your program must call the class method ParserElement.enablePackrat(). If your program uses psyco to "compile as you go", you must call enablePackrat before calling psyco.full(). If you do not do this, Python will crash. For best results, call enablePackrat() immediately after importing pyparsing. |
normalizeParseActionArgs(f)Internal method used to decorate parse actions that take fewer than 3 arguments, so that all parse actions can be called as f(s,l,t). |
setDefaultWhitespaceChars(chars)Overrides the default whitespace chars |
Class Variable Details |
---|
DEFAULT_WHITE_CHARS
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Dec 22 02:04:35 2006 | http://epydoc.sf.net |