Skip to content

Commit e194b71

Browse files
committed
Beautification, better tests
1 parent 06f136d commit e194b71

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/main/scala/de/upb/cs/swt/delphi/querylanguage/Syntax.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ class Syntax(val input : ParserInput) extends Parser {
3434
Parentheses | SingularConditionRule | NotRule
3535
}
3636
def Parentheses = rule { '(' ~ CombinatorialRule ~ ')' }
37-
def NotRule : Rule1[CombinatorialExpr] = rule {
38-
'!' ~ (NotRule | SingularConditionRule | Parentheses) ~> NotExpr
39-
}
37+
def NotRule = rule { '!' ~ Factor ~> NotExpr }
4038

4139
// Singular conditions.
4240
def SingularConditionRule = rule {

src/test/scala/de/upb/cs/swt/delphi/querylanguage/SyntaxTest.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,23 @@ class SyntaxTest extends FlatSpec with Matchers {
117117
}
118118

119119
"Syntax.notConditionSimple" should "be valid" in {
120-
val parseResult = new Syntax("Filter1&&!Filter2").QueryRule.run()
120+
val parseResult = new Syntax("!Filter1&&!(Filter2)").QueryRule.run()
121121
parseResult shouldBe a [Success[_]]
122122
parseResult match {
123123
case Success(ast) => {
124-
ast.toString shouldEqual "AndExpr(TrueExpr(Filter1),NotExpr(TrueExpr(Filter2)))"
124+
ast.toString shouldEqual "AndExpr(NotExpr(TrueExpr(Filter1))," +
125+
"NotExpr(TrueExpr(Filter2)))"
125126
}
126127
}
127128
}
128129

129130
"Syntax.notConditionSimpleParentheses" should "be valid" in {
130-
val parseResult = new Syntax("!(Filter1&&Filter2)").QueryRule.run()
131+
val parseResult = new Syntax("!(Filter1&&!Filter2)").QueryRule.run()
131132
parseResult shouldBe a [Success[_]]
132133
parseResult match {
133134
case Success(ast) => {
134-
ast.toString shouldEqual "NotExpr(AndExpr(TrueExpr(Filter1),TrueExpr(Filter2)))"
135+
ast.toString shouldEqual "NotExpr(AndExpr(TrueExpr(Filter1)," +
136+
"NotExpr(TrueExpr(Filter2))))"
135137
}
136138
}
137139
}

0 commit comments

Comments
 (0)