OpenQuizz
Une application de gestion des contenus pédagogiques
ParseExpression Class Reference
Inheritance diagram for ParseExpression:
Collaboration diagram for ParseExpression:

Public Member Functions

def __init__ (self, exprs, savelist=False)
 
def __getitem__ (self, i)
 
def append (self, other)
 
def leaveWhitespace (self)
 
def ignore (self, other)
 
def __str__ (self)
 
def streamline (self)
 
def setResultsName (self, name, listAllMatches=False)
 
def validate (self, validateTrace=[])
 
def copy (self)
 
- Public Member Functions inherited from ParserElement
def __init__ (self, savelist=False)
 
def setName (self, name)
 
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 parseImpl (self, instring, loc, doActions=True)
 
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 __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 checkRecursion (self, parseElementList)
 
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)
 

Data Fields

 exprs
 
 callPreparse
 
 strRepr
 
 skipWhitespace
 
 errmsg
 
- Data Fields inherited from ParserElement
 parseAction
 
 failAction
 
 strRepr
 
 resultsName
 
 saveAsList
 
 skipWhitespace
 
 whiteChars
 
 copyDefaultWhiteChars
 
 mayReturnEmpty
 
 keepTabs
 
 ignoreExprs
 
 debug
 
 streamlined
 
 mayIndexError
 
 errmsg
 
 modalResults
 
 debugActions
 
 re
 
 callPreparse
 
 callDuringTry
 
 name
 

Additional Inherited Members

- Static Public Member Functions inherited from ParserElement
def setDefaultWhitespaceChars (chars)
 
def inlineLiteralsUsing (cls)
 
def resetCache ()
 
def enablePackrat (cache_size_limit=128)
 
- Static Public Attributes inherited from ParserElement
 DEFAULT_WHITE_CHARS
 
 verbose_stacktrace
 
 packrat_cache
 
 packrat_cache_lock
 
 packrat_cache_stats
 

Detailed Description

Abstract subclass of ParserElement, for combining and post-processing parsed tokens.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  exprs,
  savelist = False 
)

Reimplemented in Each, And, MatchFirst, and Or.

Member Function Documentation

◆ __getitem__()

def __getitem__ (   self,
  i 
)

◆ __str__()

def __str__ (   self)

Reimplemented from ParserElement.

Reimplemented in Each, MatchFirst, Or, and And.

◆ append()

def append (   self,
  other 
)

◆ copy()

def copy (   self)
Make a copy of this C{ParserElement}.  Useful for defining different parse actions
for the same parsing pattern, using copies of the original parse element.

Example::
    integer = Word(nums).setParseAction(lambda toks: int(toks[0]))
    integerK = integer.copy().addParseAction(lambda toks: toks[0]*1024) + Suppress("K")
    integerM = integer.copy().addParseAction(lambda toks: toks[0]*1024*1024) + Suppress("M")
    
    print(OneOrMore(integerK | integerM | integer).parseString("5K 100 640K 256M"))
prints::
    [5120, 100, 655360, 268435456]
Equivalent form of C{expr.copy()} is just C{expr()}::
    integerM = integer().addParseAction(lambda toks: toks[0]*1024*1024) + Suppress("M")

Reimplemented from ParserElement.

◆ ignore()

def 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.

Example::
    patt = OneOrMore(Word(alphas))
    patt.parseString('ablaj /* comment */ lskjd') # -> ['ablaj']
    
    patt.ignore(cStyleComment)
    patt.parseString('ablaj /* comment */ lskjd') # -> ['ablaj', 'lskjd']

Reimplemented from ParserElement.

◆ leaveWhitespace()

def leaveWhitespace (   self)
Extends C{leaveWhitespace} defined in base class, and also invokes C{leaveWhitespace} on
   all contained expressions.

Reimplemented from ParserElement.

◆ setResultsName()

def 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 C{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.

You can also set results names using the abbreviated syntax,
C{expr("name")} in place of C{expr.setResultsName("name")} - 
see L{I{__call__}<__call__>}.

Example::
    date_str = (integer.setResultsName("year") + '/' 
        + integer.setResultsName("month") + '/' 
        + integer.setResultsName("day"))

    # equivalent form:
    date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

Reimplemented from ParserElement.

◆ streamline()

def streamline (   self)

Reimplemented from ParserElement.

◆ validate()

def validate (   self,
  validateTrace = [] 
)
Check defined expressions for valid structure, check for infinite recursive definitions.

Reimplemented from ParserElement.

Field Documentation

◆ callPreparse

callPreparse

◆ errmsg

errmsg

◆ exprs

exprs

◆ skipWhitespace

skipWhitespace

◆ strRepr

strRepr

The documentation for this class was generated from the following file: