plot.PEGResult: Plots the parsing result as a tree.

Description Usage Arguments Note Examples

View source: R/plot.r

Description

Plots a tree representing the result of applying a rule to a text input, when that result was obtained with the record parameter set to TRUE (Either by set_record_status or by as a parameter option in apply_rule)

Usage

1
2
3
4
## S3 method for class 'PEGResult'
plot(res, shadow = TRUE, show = "names",
  bg = ifelse(match(par("bg"), "transparent", 0), "white", par("bg")),
  border = TRUE, xpad = 1, ypad = 2.5, cex = 1, adj = 0.5, ...)

Arguments

res,

a result obtained from parsing with record=TRUE

shadow,

when set to TRUE, renders a shadow for all nodes. The default is TRUE

show,

a vector consisting of any combination of the following:

  • "names" (default), When spefified displays the name (rule id) of the rule at that node(

  • "args", When specified, displays the text consumed at that node

  • "vals", When specified, displays the vaule returned that node

  • "all", Displays all of the above

Note

The default value for show is "names".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
peg<-new.parser()
  peg<-add_rule(peg, "A<-'a'")
  peg<-add_rule(peg, "B<-'b'")
  peg<-add_rule(peg, "D<-'d'")
  peg<-add_rule(peg, "C<-'c'")
  peg<-add_rule(peg,"ROOT<-A B C D")
  apply_rule(peg,"ROOT","abcd", record=TRUE)->res
  plot(res)
  plot(res, show="args")
  plot(res, show="vals")
  plot(res, show=c("names","args"))
  plot(res, show="all")

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