15. Syntactic predicates
● ANY – matches any character except EOI
● EOI – virtual chararter represents the end of
input
val EOI = 'uFFFF'
You must define EOI at the end of the
main/root rule
16. Syntactic predicates
● anyOf – at least one of the defined chars
● noneOf – everything except those chars
def Digit = rule {
anyOf("1234567890")
}
def Visible = rule {
noneOf(" nt")
}
17. Character ranges
def Digit = rule { '0' - '9' }
def AlphaLower = rule { 'a' - 'z' }
Good, but not flexible
(the main issue of parboiled1)
● Sometimes you don't need ANY character
● You have a range of characters
18. Character predicates
There is set of predifined char predicates:
● CharPredicate.All
● CharPredicate.Digit
● CharPredicate.Digit19
● CharPredicate.HexDigit
Of course you can defien your own
28. Running the parser
val p1 = new MyParser("match")
val p2 = new MyParser("much")
p1.MyStringRule.run() // Success
p2.MyStringRule.run() // Failure
Different delivery schemes are also available
29. Running the parser
val p1 = new MyParser("match")
val p2 = new MyParser("much")
p1.MyStringRule.run() // Success
p2.MyStringRule.run() // Failure
Different delivery schemes are also available
44. Drawbacks
● PEG (absence of lexer)
● No support for left recursive grammars
● No error recovery mechanism
● No IDE support
● No support for indentation based grammars
● Awful non informative error messages