|
def | __str__ (self) |
|
def | __init__ (self, expr, stopOn=None) |
|
def | stopOn (self, ender) |
|
def | parseImpl (self, instring, loc, doActions=True) |
|
def | leaveWhitespace (self) |
|
def | ignore (self, other) |
|
def | streamline (self) |
|
def | checkRecursion (self, parseElementList) |
|
def | validate (self, validateTrace=None) |
|
def | __init__ (self, savelist=False) |
|
def | copy (self) |
|
def | setName (self, name) |
|
def | setResultsName (self, name, listAllMatches=False) |
|
def | setBreak (self, breakFlag=True) |
|
def | setParseAction (self, *fns, **kwargs) |
|
def | addParseAction (self, *fns, **kwargs) |
|
def | addCondition (self, *fns, **kwargs) |
|
def | setFailAction (self, fn) |
|
def | preParse (self, instring, loc) |
|
def | postParse (self, instring, loc, tokenlist) |
|
def | tryParse (self, instring, loc) |
|
def | canParseNext (self, instring, loc) |
|
def | parseString (self, instring, parseAll=False) |
|
def | scanString (self, instring, maxMatches=_MAX_INT, overlap=False) |
|
def | transformString (self, instring) |
|
def | searchString (self, instring, maxMatches=_MAX_INT) |
|
def | split (self, instring, maxsplit=_MAX_INT, includeSeparators=False) |
|
def | __add__ (self, other) |
|
def | __radd__ (self, other) |
|
def | __sub__ (self, other) |
|
def | __rsub__ (self, other) |
|
def | __mul__ (self, other) |
|
def | __rmul__ (self, other) |
|
def | __or__ (self, other) |
|
def | __ror__ (self, other) |
|
def | __xor__ (self, other) |
|
def | __rxor__ (self, other) |
|
def | __and__ (self, other) |
|
def | __rand__ (self, other) |
|
def | __invert__ (self) |
|
def | __iter__ (self) |
|
def | __getitem__ (self, key) |
|
def | __call__ (self, name=None) |
|
def | suppress (self) |
|
def | setWhitespaceChars (self, chars) |
|
def | parseWithTabs (self) |
|
def | setDebugActions (self, startAction, successAction, exceptionAction) |
|
def | setDebug (self, flag=True) |
|
def | __repr__ (self) |
|
def | parseFile (self, file_or_filename, parseAll=False) |
|
def | __eq__ (self, other) |
|
def | __ne__ (self, other) |
|
def | __hash__ (self) |
|
def | __req__ (self, other) |
|
def | __rne__ (self, other) |
|
def | matches (self, testString, parseAll=True) |
|
def | runTests (self, tests, parseAll=True, comment='#', fullDump=True, printResults=True, failureTests=False, postParse=None, file=None) |
|
Repetition of one or more of the given expression.
Parameters:
- expr - expression that must match one or more times
- stopOn - (default= ``None``) - expression for a terminating sentinel
(only required if the sentinel would ordinarily match the repetition
expression)
Example::
data_word = Word(alphas)
label = data_word + FollowedBy(':')
attr_expr = Group(label + Suppress(':') + OneOrMore(data_word).setParseAction(' '.join))
text = "shape: SQUARE posn: upper left color: BLACK"
OneOrMore(attr_expr).parseString(text).pprint() # Fail! read 'color' as data instead of next label -> [['shape', 'SQUARE color']]
# use stopOn attribute for OneOrMore to avoid reading label string as part of the data
attr_expr = Group(label + Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join))
OneOrMore(attr_expr).parseString(text).pprint() # Better -> [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'BLACK']]
# could also be written as
(attr_expr * (1,)).parseString(text).pprint()