Reputation: 1441
Why does this simple example of a scala combinator parser fail?
def test: Parser[String] = "< " ~> ident <~ " >"
When I provide the following string:
"< a >"
I get this error:
[1.8] failure: ` >' expected but `&' found
< a >
^
Why is it tripping up on the space?
Upvotes: 0
Views: 131
Reputation: 10764
You are probably using RegexParsers
. In documentation, you can find that:
The parsing methods call the method skipWhitespace (defaults to true) and, if true, skip any whitespace before each parser is called.
To change this:
object MyParsers extends RegexParsers {
override def skipWhitespace = false
//your parsers...
}
Upvotes: 2