Closed shengc closed 9 years ago
Let me suggest you a workaround. You may create a case object NullValue or something alike and push it instead.
case object NullValue
val parser = new Parser(val input: ParserInput) {
val inputLine = ("null" | "NULL") ~ push(NullValue)
}
And then, after your AST is generated replace it with null.
That is how I address this as for now, but I still think this is something Parboiled2 should be able to handle it.
In Scala the commonly accepted convention is that null
is not a legal value for anything, unless specifically described to the contrary. The same is true in pb2. You cannot use null
for anything, as it will usually break lots of things (proper type inference being one example).
on version 2.1.0
val parser = new Parser(val input: ParserInput) { val inputLine = ("null" | "NULL") ~ push(null) }
parser("null").inputLine.run()
it ends up with scala.MatchError: null at org.parboiled2.ValueStack.pushAll(ValueStack.scala:67)