I am trying to figure out how to interrupt the repetition of words using a keyword. Example:
class CAQueryLanguage extends JavaTokenParsers {
def expression = ("START" ~ words ~ "END") ^^ { x =>
println("expression: " + x);
x
}
def words = rep(word) ^^ { x =>
println("words: " + x)
x
}
def word = """\w+""".r
}
When i do
val caql = new CAQueryLanguage
caql.parseAll(caql.expression, "START one two END")
It prints words: List(one, two, END), indicating that the parser is wordsconsuming a keyword ENDin my input, preventing the expression parser from being unable to match. I would like it ENDnot to be consistent words, which will make it possible to expressionsuccessfully parse it.
source
share