Module yeanpypa
[show private | hide private]
[frames | no frames]

Module yeanpypa

Parsing framework in Python, similar to pyparsing and boost::spirit

Author: Markus Brueckner (dev@slash-me.net)

License: This code is in the public domain

FAQ: What's 'yeanpypa' anyway?

YEt ANother PYthon PArser framework. Virtually perfectly creative acronym...
Classes
AndRule Two or more rules matching directly after each other.
AnyOf A class to match chars from a charset.
CallbackParser A class calling a function for the next input character to determine a match.
Combine Pseudo rule that recursivly combines all of it's children into one token.
EndOfStringException Exception used internally by the InputReader to signal the end of the input string.
IgnoreWhite A pseudo-rule to tell the parser to temporary ignore whitespaces.
InputReader The InputReader serves as an abstraction to read chars from a string with a state.
Literal Rule matching a certain string.
MatchWhite A pseudo-rule to tell the parser to temporary match whitespaces.
NoneOf Match if the next character is NOT in the given set.
OneOrMore Match a rule once or more.
Optional This rule matches its subrule optionally once.
OrRule A set of alternative rules.
ParseException An exception thrown on parser error.
ParseResult The class representing the result of a parser run.
Rule The basic entity of a grammar: the rule.
ZeroOrMore Match a rule ad infinitum.

Function Summary
  parse(parser, string, ignore_white)
The main parse function.
  Word(param)
a shortcut for Combine(MatchWhite(OneOrMore(AnyOf(string)))) or Combine(MatchWhite(OneOrMore(param))) (depending on the type of param).

Variable Summary
CallbackParser alpha = <yeanpypa.CallbackParser instance at 0xb7d67b6c>
CallbackParser digit = <yeanpypa.CallbackParser instance at 0xb7d67aec>

Function Details

parse(parser, string, ignore_white=True)

The main parse function. Call this function to parse an input string with a given grammar. The parse function will save you from setting up the appropriate input reader and parse result.
Parameters:
parser - The entry point to the grammar defined by Rule objects as provided by the framework.
           (type=Rule)
string - The input string to parse.
           (type=str)
ignore_white - The ignore state of the input reader. True if the input reader should ignore whitespaces, False otherwise.
           (type=boolean)
Returns:
A ParseResult object containing the results of the parsing of the input string.

Word(param)

a shortcut for Combine(MatchWhite(OneOrMore(AnyOf(string)))) or Combine(MatchWhite(OneOrMore(param))) (depending on the type of param). See there for further details.

Variable Details

alpha

Type:
CallbackParser
Value:
<yeanpypa.CallbackParser instance at 0xb7d67b6c>                       

digit

Type:
CallbackParser
Value:
<yeanpypa.CallbackParser instance at 0xb7d67aec>                       

Generated by Epydoc 2.1 on Sat Feb 10 16:11:43 2007 http://epydoc.sf.net