Description Usage Arguments Value Examples
This only sets the rule definition (source). This
overwrites the old rule definition,leaving rule actions and
descriptions unaffected. To add rules see
add_rule
1 | set_definition(parser, rule.id, rule.definition)
|
parser, |
a peg parser produced by new.parser |
rule, |
a quoted string that defines a rule according to the PEG Grammer |
Status and the rule processed
1 2 3 4 5 6 7 8 9 | peg<-new.parser()
# Add rule A to recognize 'a' and return list('A') as it's value
peg<-add_rule(peg, "A<-'a'", act="list('A')")
value(apply_rule(peg, 'A', 'a', exe=TRUE))
peg<-set_definition(peg, "A<-'b'")
# Now A will only recognize 'b', so it will now fail on input 'a'
status(apply_rule(peg, 'A', 'a', exe=TRUE))
# However, even though Arecognizes b, but the return value is still list('A').
value(apply_rule(peg, 'A', 'b', exe=TRUE))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.