Description Usage Arguments Value Examples
This can be quite useful in getting to know the PEG syntax
1 |
expression, |
a parsing expression (the right hand side of a rule definiton) |
text.input, |
text string to apply expression to. |
record=TRUE, |
By default TRUE, so one can immediately graph (plot) or print (tree) |
PEGResult, an object giving the result
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # A simple choice operator
qp("'a' / 'b'")( "ab")
# A simple sequence operator
qp("'a' 'b'")( "ab")
# A combination of choice and sequence
qp("('a'/'c') ('b' / 'd')")( "ab")
qp("('a'/'c') ('b' / 'd')")( "cd")
# A lookahead not operator
qp("'a' !'b'")( "ab" )
qp("'a' !'b'")( "ac" )
# An lookahead and operator
qp("'a' & 'b'")( "ab")
qp("'a' & 'b'")( "ac")
# An optional operator
qp("'a' 'b'?")( "ab")
qp("'a' 'b'?")( "ac")
qp("'a'? 'b'")( "ab")
qp("'a'? 'b'")( "ba")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.