Description Usage Arguments Value Examples
Attach an (optional) action to a specified rule
1 | set_action(pegR, rule.id, action)
|
parser, |
a peg parser produced by new.parser |
rule.id, |
a character string naming the rule |
action |
to be attached to the specified rule. The action may be may take three forms:
|
a peg parser with the action attached
1 2 3 4 5 6 7 | #Capitalize all occurances of 'a' using inline actions
peg<-new.parser()
peg<-add_rule(peg, "A<-'a'")
peg<-add_rule(peg, "R<-(A / .)+")
peg<-set_action(peg, "A", "list('A')")
peg<-set_action(peg, "R", "list(paste(v, collapse=''))" )
value(apply_rule(peg, "R", "cat in the hat", exe=T))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.