Module pyparsing :: Class ParserElement
[frames | no frames]

Class ParserElement

object --+
         |
        ParserElement

Known Subclasses:
ParseElementEnhance, ParseExpression, Token

Abstract base level parser element class.
Method Summary
  __init__(self, savelist)
  __add__(self, other)
  __invert__(self)
  __or__(self, other)
  __radd__(self, other)
  __repr__(self)
  __ror__(self, other)
  __rxor__(self, other)
  __str__(self)
  __xor__(self, other)
  checkRecursion(self, parseElementList)
  getResultsName(self)
  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)
  parse(self, instring, loc, doActions)
  parseImpl(self, instring, loc, doActions)
  parseString(self, instring)
Execute the parse expression with the given string.
  postParse(self, instring, loc, tokenlist)
  preParse(self, instring, loc)
  scanString(self, instring)
  setDebug(self, flag)
Enable display of debugging messages while doing pattern matching.
  setName(self, name)
Define name for this expression, for use in debugging.
  setParseAction(self, fn)
Define action to perform when successfully matching parse element definition.
  setResultsName(self, name)
Define name for referencing matching tokens as a nested attribute of the returned parse results.
  skipIgnorables(self, instring, loc)
  streamline(self)
  suppress(self)
Suppresses the output of this ParseElement; useful to keep punctuation from cluttering up returned output.
  tryParse(self, instring, loc)
  validate(self, validateTrace)
Inherited from object: __delattr__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__
Inherited from type: __new__

Method Details

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.

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.

setDebug(self, flag=True)

Enable display of debugging messages while doing pattern matching.

setName(self, name)

Define name for this expression, for use in debugging.

setParseAction(self, fn)

Define action to perform when successfully matching parse element definition. Parse action fn is a callable method with the arguments (s, loc, toks) where:
  • s = the original string being parsed
  • loc = the location of the matching substring
  • toks = a list of the matched tokens
fn must return toks (although fn may modify the list passed in as an argument)

setResultsName(self, name)

Define name for referencing matching tokens as a nested attribute of the returned parse results. NOTE: this returns a *copy* of the original ParseElement 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.

suppress(self)

Suppresses the output of this ParseElement; useful to keep punctuation from cluttering up returned output.

Generated by Epydoc 2.0 on Sat Mar 20 09:58:33 2004 http://epydoc.sf.net