class documentation

class _Parser(object):

View In Hierarchy

Internal parser. This class can translate a single rule into an abstract tree of tuples. It implements the following grammar:

condition     = and_condition ('or' and_condition)*
                ('@integer' samples)?
                ('@decimal' samples)?
and_condition = relation ('and' relation)*
relation      = is_relation | in_relation | within_relation
is_relation   = expr 'is' ('not')? value
in_relation   = expr (('not')? 'in' | '=' | '!=') range_list
within_relation = expr ('not')? 'within' range_list
expr          = operand (('mod' | '%') value)?
operand       = 'n' | 'i' | 'f' | 't' | 'v' | 'w'
range_list    = (range | value) (',' range_list)*
value         = digit+
digit         = 0|1|2|3|4|5|6|7|8|9
range         = value'..'value
samples       = sampleRange (',' sampleRange)* (',' ('…'|'...'))?
sampleRange   = decimalValue '~' decimalValue
decimalValue  = value ('.' value)?
  • Whitespace can occur between or around any of the above tokens.
  • Rules should be mutually exclusive; for a given numeric value, only one rule should apply (i.e. the condition should only be true for one of the plural rule elements).
  • The in and within relations can take comma-separated lists, such as: 'n in 3,5,7..15'.
  • Samples are ignored.

The translator parses the expression on instanciation into an attribute called ast.

Method __init__ Undocumented
Method and​_condition Undocumented
Method condition Undocumented
Method expect Undocumented
Method expr Undocumented
Method newfangled​_relation Undocumented
Method range​_list Undocumented
Method range​_or​_value Undocumented
Method relation Undocumented
Method value Undocumented
Instance Variable ast Undocumented
Instance Variable tokens Undocumented
def __init__(self, string):

Undocumented

def and_condition(self):

Undocumented

def condition(self):

Undocumented

def expect(self, type_, value=None, term=None):

Undocumented

def expr(self):

Undocumented

def newfangled_relation(self, left):

Undocumented

def range_list(self):

Undocumented

def range_or_value(self):

Undocumented

def relation(self):

Undocumented

def value(self):

Undocumented

ast =

Undocumented

tokens =

Undocumented