Skip to content

Commit

Permalink
Fixed "not" parsing bug + added 2 more related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyCat committed Apr 3, 2019
1 parent 6996086 commit 0221a5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions jvm/src/test/scala/io/kaitai/struct/exprlang/ExpressionsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ class ExpressionsSpec extends FunSpec {
Expressions.parse("note_len") should be (Name(identifier("note_len")))
}

it("parses notnot") {
Expressions.parse("notnot") should be (Name(identifier("notnot")))
}

it("parses not not true") {
Expressions.parse("not not true") should be (
UnaryOp(
Ast.unaryop.Not,
UnaryOp(
Ast.unaryop.Not,
Bool(true)
)
)
)
}

// String literals
it("parses simple string") {
Expressions.parse("\"abc\"") should be (Str("abc"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object Expressions {
case Seq(x) => x
case xs => Ast.expr.BoolOp(Ast.boolop.And, xs)
}
val not_test: P[Ast.expr] = P( ("not" ~ not_test).map(Ast.expr.UnaryOp(Ast.unaryop.Not, _)) | comparison )
val not_test: P[Ast.expr] = P( (kw("not") ~ not_test).map(Ast.expr.UnaryOp(Ast.unaryop.Not, _)) | comparison )
val comparison: P[Ast.expr] = P( expr ~ (comp_op ~ expr).? ).map{
case (lhs, None) => lhs
case (lhs, Some(chunks)) =>
Expand Down

0 comments on commit 0221a5a

Please sign in to comment.