I have two packrat parsers in scala:
val symbols : PackratParser[String] =
"{" | "}" | ">"
val keywords : PackratParser[String] =
"BOOL" | "INT"
I want to build a parser that can recognise if a statement is composed of one or more of those two parsers. The way I’d usually do it is:
val statement : PackratParser[String] =
regex( "[symbols | keywords]+".r )
But that wouldn’t work because they’re thinking I want the actual “symbols” or “keywords” token… Can anyone help?
You can’t use a regex this way. However, the whole point of parser combinators is that they can be combined!