Description Usage Arguments Value See Also Examples
Adds a rule to the parser, if the rule exists, it is overwritten, getting a new definition, a new (possibly empty) description, and a new (possibly empty) action.
1 |
parser, |
a peg parser produced by new.parser |
rule, |
the rule description, a quoted string that defines a rule according to the PEG Grammer |
des, |
(optional: NULL by default) sets a rule description for this rule |
act, |
(optional: NULL by default) sets an action, to be executed by this rule. This NULL by default. |
Status and the rule processed
For a description of actions see set_action
and appy_rule
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | peg<-new.parser()
peg<-add_rule(peg, "X<-x", des="A bad rule (I forgot quotes)")
# Next we inspect the rule
inspect_rule(peg, "X")
# Inspect rule returns the following
# Rule: X
# Def: X<-x
# Com: A bad rule (needs quotes)
# Act:
# Now we replace the rule by overwriting
peg<-add_rule(peg, "X<-'x'", act="list('X')")
# When again inspect, we see
# the definition was fixed (x now is quoted), the description was removed, an action was added.
inspect_rule(peg,"X")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.