Setting Hooks: Module hooks
¶
This provide some default hooks.
-
pyrser.hooks.echo.
echo_nodes
(self, rest)[source]¶ Print nodes.
example:
R = [ In : node #echo("coucou", 12, node) ]
-
pyrser.hooks.set.
set_node
(self, dst, src)[source]¶ Basically copy one node to another. usefull to transmit a node from a terminal rule as result of the current rule.
example:
R = [ In : node #set(_, node) ]
here the node return by the rule In is also the node return by the rule R
-
pyrser.hooks.set.
set_node_as_int
(self, dst, src)[source]¶ Set a int literal to a node
example:
R = [ In : node #setint(node, 12) ]
-
pyrser.hooks.set.
set_node_as_str
(self, dst, src)[source]¶ Set a str literal to a node
example:
R = [ In : node #setstr(node, "toto") ]
-
pyrser.hooks.set.
get_subnode
(self, dst, ast, expr)[source]¶ get the value of subnode
example:
R = [ __scope__:big getsomethingbig:>big #get(_, big, '.val') // copy big.val into _ ]
-
pyrser.hooks.vars.
vars_nodes
(self, rest)[source]¶ Vars one node instance.
example:
R = [ In : node #vars(node) ]
-
pyrser.hooks.dump_nodes.
dump_nodes
(self)[source]¶ Dump tag,rule,id and value cache. For debug.
example:
R = [ #dump_nodes ]
-
pyrser.hooks.predicate.
pred_false
(self)[source]¶ False in parser. Go to alternative...
example:
R = [ #false | R2 ]
-
pyrser.hooks.predicate.
pred_true
(self)[source]¶ True in parser. Do nothing
example:
R = [ R2 | #true ]