Alternative

class Alternative(terms)[source]

Bases: sexpr.matcher.Matcher

matches(sexp)[source]
pop(sexp)[source]

Multiple

class Multiple(term, lower, higher=None)[source]

Bases: sexpr.matcher.Matcher

matches(sexp)[source]
pop(sexp)[source]

Non-Terminal

class NonTerminal(name, body)[source]

Bases: sexpr.matcher.Matcher

matches(sexp)[source]

Body of a non-terminal is always a Sequence. For an s-expr to match, it must be of the form:

['name'] + [sexpr-0, ..., sexpr-n]

where the first list contains a name of the non-terminal, and the second one matches its body sequence.

pop(sexp)[source]

Assuming s-expr of the form:

[sexpr-0, ..., sexpr-n]

For an sexpr-0 to be popped by a non-terminal, it must match that of required by matches(). If it doesn’t, None is returned.

Reference

class Reference(name, grammar)[source]

Bases: sexpr.matcher.Matcher

matches(sexp)[source]
pop(sexp)[source]
rule

Rule

class Rule(name, body)[source]

Bases: sexpr.matcher.Matcher

matches(sexp)[source]
pop(sexp)[source]

Sequence

class Sequence(terms)[source]

Bases: sexpr.matcher.Matcher

matches(sexp)[source]
pop(sexp)[source]

Notes: Sequence works a bit different than other nodes. This method (like others) expectes a list. However, sequence matches against the list, whereas other nodes try to match against elements of the list.

Terminal

class RegexpTerminal(value)[source]

Bases: sexpr.types.terminal.Terminal

matches(sexp)[source]
class Terminal(value)[source]

Bases: sexpr.matcher.Matcher

pop(sexp)[source]
class TypeTerminal(value, strict)[source]

Bases: sexpr.types.terminal.Terminal

matches(sexp)[source]
class ValueTerminal(value)[source]

Bases: sexpr.types.terminal.Terminal

matches(sexp)[source]