value: Returns the value of a parsing result

Description Usage Value Examples

View source: R/value.R

Description

Returns the value of a parsing result

Usage

1
value(res)

Value

A list containing the values computed

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Select the matching pair of from the alternatives
peg<-new.parser()
peg<-add_rule(peg, "R<-('a'/'c') ('b' / 'd')")
apply_rule(peg, "R", 'ad')->res
value(res)

# double all occurances of all vowels
peg<-new.parser()
peg<-add_rule(peg, "V<-'a' / 'e' / 'i' / 'o' / 'u' ")
peg<-add_rule(peg, "C<-(!V .)")
peg<-add_rule(peg, "A<- (V / C)+" )
peg<-set_action(peg, "V", "c(v[1],v[1])" )
peg<-set_action(peg, "A", "list(paste0(v,collapse=''))" )
apply_rule(peg, "A", "the big bad wolf", exe=TRUE)->res
value(res)[1]

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