Description Usage Arguments Details Examples
Alternative to add_rule.
1 2  | ## S3 method for class 'pegR'
parser + arg
 | 
parser, | 
 a peg parser produced by new.parser  | 
arg, | 
 a list or vector specififyin a rule:  | 
arg is a list or vector having 1-4 named components:
 rule  (Mandatory) A string containing
the peg rule definition For example:
c(Rule="COLD<-'brrr'"). The 'Rule' label is
optional, but having a rule is mandatory.  
 des
(optional) A a textual string describing the rule.  For
example: c(Rule="COLD<-'brrr'", des="Polar" ) A
comment must be named.   
 act (optional) an action
specification. For example c(Rule="COLD<-'brrr'",
des="Polar", act=function(v){print("brr"); v} ), An action
must be named  
1 2 3 4 5 6 7 8 9  | peg<- new.parser()
peg + "A<-'a'" + "B<-'b'" + "C<-'c'"
#to suppress the output use invisible"
invisible(peg + "A<-'a'" + "B<-'b'" + "C<-'c'")
#now add rule D with action and comment using a named character vector
peg + c("D<-'d'", des="capitalize D", act="list(atom='D')")
#now add rule E with action and comment a unnamed character
peg + c( "E<-'e'", "#double E", "{list('EE')}" )
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.