michael.kebe
michael.kebe

Reputation: 11085

Parsing a blank / whitespace with RegexParsers

What is the problem with parsing the blank/whitespace?

scala> object BlankParser extends RegexParsers {
         def blank: Parser[Any] = " "
         def foo: Parser[Any] = "foo"
       }
defined module BlankParser

scala> BlankParser.parseAll(BlankParser.foo, "foo")
res15: BlankParser.ParseResult[Any] = [1.4] parsed: foo

scala> BlankParser.parseAll(BlankParser.blank, " ")
res16: BlankParser.ParseResult[Any] =
[1.2] failure: ` ' expected but ` ' found


 ^

scala>

Upvotes: 3

Views: 1223

Answers (1)

tarrasch
tarrasch

Reputation: 2680

the lexer for scala throws blankspaces away. try override val skipWhitespace = false to avoid this.

the question was already solved so it seems... Scala parser combinators for language embedded in html or text (like php)

Upvotes: 4

Related Questions