new.parser: Creates an instance of a new PEG parser.

Description Usage Arguments Value See Also Examples

View source: R/new_parser.R

Description

Creates an instance of a new PEG parser.

Usage

1
new.parser(peg.data.frame = NULL, record.mode = FALSE, action.exe = FALSE)

Arguments

peg.data.frame,

a data frame with rules to populate the parser. (default is NULL) A peg.data.frame consists of the following fields:

  • rule.id (mandatory), The column containing the rule's id. (NA values not allowed)

  • rule.source (mandatory), The column containing the rule's definition (NA values not allowed)

  • rule.description, (optional) The column containing any rules description (may have NA values)

  • action.specification, (optional) The column containing the rule specifiation. May be either a valid inline action or the name of an existing rule (Set to NA if e no action is associated with this rule.)

record.mode,

when set to TRUE, will keep a record to display with tree or plot. (default is FALSE)

action.exe,

when set to TRUE, all actions will be executed unless overridden by command line. (default is FALSE)

Value

Returns a new instance of a PEG parser

See Also

as.data.frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#Create an empty parser
parser<-new.parser()
peg<-add_rule(parser, "Any<-.")
rule_ids(parser)  # returns "Any"

#Create a parser from a data.frame
fn<-function(x){list()}
df<-data.frame(
rule.id=c('A','B'),
rule.source=c("A<-'a'", "B<-'b'"),
rule.description=c("aaa",NA),
action.type=c("Inline","External"),
action.specification=c("list()", "fn"),
stringsAsFactors=FALSE)
peg<-new.parser(df)

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