Functors primitives: Module parsing.functors

class pyrser.parsing.functors.Functor[source]

Bases: object

Dummy Base class for all parse tree classes.

common property:
pt if contain a Functor ptlist if contain a list of Functor
do_call(self, parser: BasicParser) → Node[source]
__call__(self, parser: BasicParser) → Node[source]
class pyrser.parsing.functors.Directive2(name, param: [(<class 'object'>, <class 'type'>)], pt: pyrser.parsing.functors.Functor)[source]

Bases: pyrser.parsing.functors.Functor

__init__(self, name, param, pt: Functor)[source]
do_call(self, parser: BasicParser) → bool[source]
class pyrser.parsing.functors.RewritingRules(name: str='')[source]

Bases: pyrser.parsing.functors.Functor

Allow to write rewriting rules that transform the AST before code generation/interpretation.

__init__(self, name: str= '')[source]
class pyrser.parsing.functors.SkipIgnore(convention: str='')[source]

Bases: pyrser.parsing.functors.Functor

Call Ignore Convention primitive functor.

__init__(self, convention: str= '')[source]

TODO: Could be better to implement Directive thru functors???

do_call(self, parser: BasicParser) → bool[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Leaf[source]

Bases: object

class pyrser.parsing.functors.PeekChar(c: str)[source]

Bases: pyrser.parsing.functors.Functor, pyrser.parsing.functors.Leaf

!!’A’ bnf primitive functor.

__init__(self, c: str)[source]
do_call(self, parser: BasicParser) → bool[source]
class pyrser.parsing.functors.PeekText(c: str)[source]

Bases: pyrser.parsing.functors.Functor, pyrser.parsing.functors.Leaf

!!”TXT” bnf primitive functor.

__init__(self, c: str)[source]
do_call(self, parser: BasicParser) → bool[source]
class pyrser.parsing.functors.Text(txt: str)[source]

Bases: pyrser.parsing.functors.Functor, pyrser.parsing.functors.Leaf

“TXT” bnf primitive functor.

__init__(self, txt: str)[source]
do_call(self, parser: BasicParser) → bool[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Char(c: str)[source]

Bases: pyrser.parsing.functors.Functor, pyrser.parsing.functors.Leaf

‘A’ bnf primitive functor.

__init__(self, c: str)[source]
do_call(self, parser: BasicParser) → bool[source]
class pyrser.parsing.functors.Range(begin: str, end: str)[source]

Bases: pyrser.parsing.functors.Functor, pyrser.parsing.functors.Leaf

‘A’..’Z’ bnf primitive functor.

__init__(self, begin: str, end: str)[source]
do_call(self, parser: BasicParser) → bool[source]
class pyrser.parsing.functors.UntilChar(c: str)[source]

Bases: pyrser.parsing.functors.Functor, pyrser.parsing.functors.Leaf

->’A’ bnf primitive functor.

__init__(self, c: str)[source]
do_call(self, parser: BasicParser) → bool[source]
class pyrser.parsing.functors.Seq(*ptlist: pyrser.parsing.functors.Functor)[source]

Bases: pyrser.parsing.functors.Functor

A B C bnf primitive as a functor.

__init__(self, ptlist: Functor)[source]
__getitem__(self, idx) → Functor[source]

Hide SkipIgnore object from outside

do_call(self, parser: BasicParser) → bool[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Scope(begin: pyrser.parsing.functors.Seq, end: pyrser.parsing.functors.Seq, pt: pyrser.parsing.functors.Seq)[source]

Bases: pyrser.parsing.functors.Functor

functor to wrap SCOPE/rule directive or just [].

__init__(self, begin: Seq, end: Seq, pt: Seq)[source]
do_call(self, parser: BasicParser) → Node[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.LookAhead(pt: pyrser.parsing.functors.Functor)[source]

Bases: pyrser.parsing.functors.Functor

!!A bnf primitive as a functor.

__init__(self, pt: Functor)[source]
do_call(self, parser: BasicParser) → bool[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Neg(pt: pyrser.parsing.functors.Functor)[source]

Bases: pyrser.parsing.functors.Functor

!A bnf primitive as a functor.

__init__(self, pt: Functor)[source]
do_call(self, parser: BasicParser)[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Complement(pt: pyrser.parsing.functors.Functor)[source]

Bases: pyrser.parsing.functors.Functor

~A bnf primitive as a functor.

__init__(self, pt: Functor)[source]
do_call(self, parser: BasicParser) → bool[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Until(pt: pyrser.parsing.functors.Functor)[source]

Bases: pyrser.parsing.functors.Functor

->A bnf primitive as a functor.

__init__(self, pt: Functor)[source]
do_call(self, parser: BasicParser) → bool[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Call(callObject, *params)[source]

Bases: pyrser.parsing.functors.Functor

Functor wrapping a BasicParser method call in a BNF clause.

__init__(self, callObject, params)[source]
do_call(self, parser: BasicParser) → Node[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.CallTrue(callObject, *params)[source]

Bases: pyrser.parsing.functors.Call

Functor to wrap arbitrary callable object in BNF clause.

do_call(self, parser: BasicParser) → Node[source]
class pyrser.parsing.functors.Capture(tagname: str, pt: pyrser.parsing.functors.Functor)[source]

Bases: pyrser.parsing.functors.Functor

Functor to handle capture nodes.

__init__(self, tagname: str, pt: Functor)[source]
do_call(self, parser: BasicParser) → Node[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.DeclNode(tagname: str)[source]

Bases: pyrser.parsing.functors.Functor

Functor to handle node declaration with __scope__:N.

__init__(self, tagname: str)[source]
do_call(self, parser: BasicParser) → Node[source]
class pyrser.parsing.functors.Bind(tagname: str, pt: pyrser.parsing.functors.Functor)[source]

Bases: pyrser.parsing.functors.Functor

Functor to handle the binding of a resulting nodes to an existing name.

__init__(self, tagname: str, pt: Functor)[source]
do_call(self, parser: BasicParser) → Node[source]
class pyrser.parsing.functors.Alt(*ptlist: pyrser.parsing.functors.Seq)[source]

Bases: pyrser.parsing.functors.Functor

A | B bnf primitive as a functor.

__init__(self, ptlist: Seq)[source]
__getitem__(self, idx) → Functor[source]
do_call(self, parser: BasicParser) → Node[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.RepOptional(pt: pyrser.parsing.functors.Seq)[source]

Bases: pyrser.parsing.functors.Functor

[]? bnf primitive as a functor.

__init__(self, pt: Seq)[source]
do_call(self, parser: BasicParser) → bool[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Rep0N(pt: pyrser.parsing.functors.Seq)[source]

Bases: pyrser.parsing.functors.Functor

[]* bnf primitive as a functor.

__init__(self, pt: Seq)[source]
do_call(self, parser: BasicParser) → bool[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Rep1N(pt: pyrser.parsing.functors.Seq)[source]

Bases: pyrser.parsing.functors.Functor

[]+ bnf primitive as a functor.

__init__(self, pt: Seq)[source]
do_call(self, parser: BasicParser) → bool[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Error(msg: str, **kwargs)[source]

Bases: pyrser.parsing.functors.Functor

Raise an error.

__init__(self, msg: str, kwargs)[source]
do_call(self, parser: BasicParser) → bool[source]
class pyrser.parsing.functors.Rule(name: str)[source]

Bases: pyrser.parsing.functors.Functor, pyrser.parsing.functors.Leaf

Call a rule by its name.

__init__(self, name: str)[source]
do_call(self, parser: BasicParser) → Node[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.Hook(name: str, param: [(<class 'object'>, <class 'type'>)])[source]

Bases: pyrser.parsing.functors.Functor, pyrser.parsing.functors.Leaf

Call a hook by his name.

__init__(self, name: str, param)[source]
do_call(self, parser: BasicParser) → bool[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.MetaDirectiveWrapper[source]

Bases: type

metaclass of all DirectiveWrapper subclasses. ensure that begin and end exists in subclasses as method

static __new__(metacls, name, bases, namespace)[source]
class pyrser.parsing.functors.DirectiveWrapper[source]

Bases: pyrser.parsing.functors.Functor

functor to wrap begin/end directive

__init__(self)[source]
checkParam(self, params: list)[source]
begin(self)[source]
end(self)[source]
class pyrser.parsing.functors.Directive(directive: pyrser.parsing.functors.DirectiveWrapper, param: [(<class 'object'>, <class 'type'>)], pt: pyrser.parsing.functors.Functor)[source]

Bases: pyrser.parsing.functors.Functor

functor to wrap directive HOOKS

__init__(self, directive: DirectiveWrapper, param, pt: Functor)[source]
do_call(self, parser: BasicParser) → Node[source]
to_dsl(self, level= 0)
class pyrser.parsing.functors.MetaDecoratorWrapper[source]

Bases: type

metaclass of all DecoratorWrapper subclasses. ensure that begin and end exists in subclasses as method

static __new__(metacls, name, bases, namespace)[source]
class pyrser.parsing.functors.DecoratorWrapper[source]

Bases: pyrser.parsing.functors.Functor

begin(self)[source]
end(self)[source]
class pyrser.parsing.functors.Decorator(decoratorClass: type, param: [(<class 'object'>, <class 'type'>)], pt: pyrser.parsing.functors.Functor)[source]

Bases: pyrser.parsing.functors.Functor

__init__(self, decoratorClass: type, param, pt: Functor)[source]
checkParam(self, the_class: type, params: list) → bool[source]
do_call(self, parser: BasicParser) → Node[source]

The Decorator call is the one that actually pushes/pops the decorator in the active decorators list (parsing._decorators)