Package pyparsing :: Module pyparsing :: Class Optional
[hide private]
[frames] | no frames]

Class Optional

source code

     object --+        
              |        
  ParserElement --+    
                  |    
ParseElementEnhance --+
                      |
                     Optional

Optional matching of the given expression. A default return string can also be specified, if the optional expression is not found.

Instance Methods [hide private]
 
__init__(self, exprs, default=_NullToken())
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
parseImpl(self, instring, loc, doActions=True) source code
 
__str__(self)
str(x)
source code

Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__

    Inherited from ParseElementEnhance
 
checkRecursion(self, parseElementList) source code
 
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.
source code
 
leaveWhitespace(self)
Disables the skipping of whitespace before matching the characters in the ParserElement's defined pattern.
source code
 
streamline(self) source code
 
validate(self, validateTrace=[])
Check defined expressions for valid structure, check for infinite recursive definitions.
source code
    Inherited from ParserElement
 
__add__(self, other)
Implementation of + operator - returns And
source code
 
__and__(self, other)
Implementation of & operator - returns Each
source code
 
__call__(self, name)
Shortcut for setResultsName, with listAllMatches=default:
source code
 
__eq__(self, other) source code
 
__getattr__(self, aname) source code
 
__hash__(self)
hash(x)
source code
 
__invert__(self)
Implementation of ~ operator - returns NotAny
source code
 
__mul__(self, other) source code
 
__ne__(self, other) source code
 
__or__(self, other)
Implementation of | operator - returns MatchFirst
source code
 
__radd__(self, other)
Implementation of + operator when left operand is not a ParserElement
source code
 
__rand__(self, other)
Implementation of & operator when left operand is not a ParserElement
source code
 
__repr__(self)
repr(x)
source code
 
__req__(self, other) source code
 
__rmul__(self, other) source code
 
__rne__(self, other) source code
 
__ror__(self, other)
Implementation of | operator when left operand is not a ParserElement
source code
 
__rsub__(self, other)
Implementation of - operator when left operand is not a ParserElement
source code
 
__rxor__(self, other)
Implementation of ^ operator when left operand is not a ParserElement
source code
 
__sub__(self, other)
Implementation of - operator, returns And with error stop
source code
 
__xor__(self, other)
Implementation of ^ operator - returns Or
source code
 
_parse(self, instring, loc, doActions=True, callPreParse=True) source code
 
_parseCache(self, instring, loc, doActions=True, callPreParse=True) source code
 
_parseNoCache(self, instring, loc, doActions=True, callPreParse=True) source code
 
_skipIgnorables(self, instring, loc) source code
 
addParseAction(self, *fns, **kwargs)
Add parse action to expression's list of parse actions.
source code
 
copy(self)
Make a copy of this ParserElement.
source code
 
getException(self) source code
 
parseFile(self, file_or_filename, parseAll=False)
Execute the parse expression on the given file or filename.
source code
 
parseString(self, instring, parseAll=False)
Execute the parse expression with the given string.
source code
 
parseWithTabs(self)
Overrides default behavior to expand <TAB>s to spaces before parsing the input string.
source code
 
postParse(self, instring, loc, tokenlist) source code
 
preParse(self, instring, loc) source code
 
scanString(self, instring, maxMatches=2147483647)
Scan the input string for expression matches.
source code
 
searchString(self, instring, maxMatches=2147483647)
Another extension to scanString, simplifying the access to the tokens found to match the given parse expression.
source code
 
setBreak(self, breakFlag=True)
Method to invoke the Python pdb debugger when this element is about to be parsed.
source code
 
setDebug(self, flag=True)
Enable display of debugging messages while doing pattern matching.
source code
 
setDebugActions(self, startAction, successAction, exceptionAction)
Enable display of debugging messages while doing pattern matching.
source code
 
setFailAction(self, fn)
Define action to perform if parsing fails at this expression.
source code
 
setName(self, name)
Define name for this expression, for use in debugging.
source code
 
setParseAction(self, *fns, **kwargs)
Define action to perform when successfully matching parse element definition.
source code
 
setResultsName(self, name, listAllMatches=False)
Define name for referencing matching tokens as a nested attribute of the returned parse results.
source code
 
setWhitespaceChars(self, chars)
Overrides the default whitespace chars
source code
 
suppress(self)
Suppresses the output of this ParserElement; useful to keep punctuation from cluttering up returned output.
source code
 
transformString(self, instring)
Extension to scanString, to modify matching text with modified tokens that may be returned from a parse action.
source code
 
tryParse(self, instring, loc) source code
Static Methods [hide private]
    Inherited from ParserElement
 
_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).
source code
 
enablePackrat()
Enables "packrat" parsing, which adds memoizing to the parsing logic.
source code
 
resetCache() source code
 
setDefaultWhitespaceChars(chars)
Overrides the default whitespace chars
source code
Class Variables [hide private]
  __slotnames__ = []
    Inherited from ParserElement
  DEFAULT_WHITE_CHARS = ' \n\t\r'
  _exprArgCache = {}
  _packratEnabled = False
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, exprs, default=_NullToken())
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

parseImpl(self, instring, loc, doActions=True)

source code 
Overrides: ParserElement.parseImpl

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)