set_definition: Reset rule.definition in the parser

Description Usage Arguments Value Examples

View source: R/set_rule.R

Description

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

Usage

1
set_definition(parser, rule.id, rule.definition)

Arguments

parser,

a peg parser produced by new.parser

rule,

a quoted string that defines a rule according to the PEG Grammer

Value

Status and the rule processed

Examples

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))

mslegrand/pegr documentation built on May 23, 2019, 7:53 a.m.