Skip to content

Commit 15402aa

Browse files
author
Psilo
committed
add startswith endswith and repair not-operator with like-operators
bump version
1 parent 8a72c78 commit 15402aa

File tree

16 files changed

+771
-297
lines changed

16 files changed

+771
-297
lines changed

antlr4/.antlr/Rql.interp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ null
88
null
99
null
1010
null
11+
null
1112
'('
1213
')'
1314
null
@@ -19,7 +20,8 @@ token symbolic names:
1920
null
2021
Operator
2122
Like
22-
NLike
23+
StartsWith
24+
EndsWith
2325
Null
2426
Is
2527
Not
@@ -51,9 +53,13 @@ term1
5153
nullOperator1
5254
nullOperator2
5355
nullOperator
56+
nLike
57+
nStartsWith
58+
nEndsWith
59+
negatableOperator
5460
operator
5561
term2
5662

5763

5864
atn:
59-
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 16, 113, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 49, 10, 3, 12, 3, 14, 3, 52, 11, 3, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 58, 10, 4, 12, 4, 14, 4, 61, 11, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 5, 5, 68, 10, 5, 3, 6, 3, 6, 5, 6, 72, 10, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 5, 19, 105, 10, 19, 3, 20, 3, 20, 5, 20, 109, 10, 20, 3, 21, 3, 21, 3, 21, 2, 2, 22, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 2, 3, 4, 2, 6, 6, 15, 15, 2, 98, 2, 42, 3, 2, 2, 2, 4, 44, 3, 2, 2, 2, 6, 53, 3, 2, 2, 2, 8, 67, 3, 2, 2, 2, 10, 71, 3, 2, 2, 2, 12, 73, 3, 2, 2, 2, 14, 75, 3, 2, 2, 2, 16, 77, 3, 2, 2, 2, 18, 79, 3, 2, 2, 2, 20, 81, 3, 2, 2, 2, 22, 85, 3, 2, 2, 2, 24, 87, 3, 2, 2, 2, 26, 89, 3, 2, 2, 2, 28, 91, 3, 2, 2, 2, 30, 95, 3, 2, 2, 2, 32, 97, 3, 2, 2, 2, 34, 99, 3, 2, 2, 2, 36, 104, 3, 2, 2, 2, 38, 108, 3, 2, 2, 2, 40, 110, 3, 2, 2, 2, 42, 43, 5, 4, 3, 2, 43, 3, 3, 2, 2, 2, 44, 50, 5, 6, 4, 2, 45, 46, 5, 14, 8, 2, 46, 47, 5, 6, 4, 2, 47, 49, 3, 2, 2, 2, 48, 45, 3, 2, 2, 2, 49, 52, 3, 2, 2, 2, 50, 48, 3, 2, 2, 2, 50, 51, 3, 2, 2, 2, 51, 5, 3, 2, 2, 2, 52, 50, 3, 2, 2, 2, 53, 59, 5, 8, 5, 2, 54, 55, 5, 12, 7, 2, 55, 56, 5, 8, 5, 2, 56, 58, 3, 2, 2, 2, 57, 54, 3, 2, 2, 2, 58, 61, 3, 2, 2, 2, 59, 57, 3, 2, 2, 2, 59, 60, 3, 2, 2, 2, 60, 7, 3, 2, 2, 2, 61, 59, 3, 2, 2, 2, 62, 68, 5, 10, 6, 2, 63, 64, 5, 16, 9, 2, 64, 65, 5, 4, 3, 2, 65, 66, 5, 18, 10, 2, 66, 68, 3, 2, 2, 2, 67, 62, 3, 2, 2, 2, 67, 63, 3, 2, 2, 2, 68, 9, 3, 2, 2, 2, 69, 72, 5, 20, 11, 2, 70, 72, 5, 28, 15, 2, 71, 69, 3, 2, 2, 2, 71, 70, 3, 2, 2, 2, 72, 11, 3, 2, 2, 2, 73, 74, 7, 9, 2, 2, 74, 13, 3, 2, 2, 2, 75, 76, 7, 10, 2, 2, 76, 15, 3, 2, 2, 2, 77, 78, 7, 11, 2, 2, 78, 17, 3, 2, 2, 2, 79, 80, 7, 12, 2, 2, 80, 19, 3, 2, 2, 2, 81, 82, 5, 22, 12, 2, 82, 83, 5, 24, 13, 2, 83, 84, 5, 26, 14, 2, 84, 21, 3, 2, 2, 2, 85, 86, 7, 14, 2, 2, 86, 23, 3, 2, 2, 2, 87, 88, 7, 3, 2, 2, 88, 25, 3, 2, 2, 2, 89, 90, 7, 15, 2, 2, 90, 27, 3, 2, 2, 2, 91, 92, 5, 30, 16, 2, 92, 93, 5, 38, 20, 2, 93, 94, 5, 40, 21, 2, 94, 29, 3, 2, 2, 2, 95, 96, 7, 13, 2, 2, 96, 31, 3, 2, 2, 2, 97, 98, 7, 7, 2, 2, 98, 33, 3, 2, 2, 2, 99, 100, 7, 7, 2, 2, 100, 101, 7, 8, 2, 2, 101, 35, 3, 2, 2, 2, 102, 105, 5, 32, 17, 2, 103, 105, 5, 34, 18, 2, 104, 102, 3, 2, 2, 2, 104, 103, 3, 2, 2, 2, 105, 37, 3, 2, 2, 2, 106, 109, 5, 36, 19, 2, 107, 109, 7, 3, 2, 2, 108, 106, 3, 2, 2, 2, 108, 107, 3, 2, 2, 2, 109, 39, 3, 2, 2, 2, 110, 111, 9, 2, 2, 2, 111, 41, 3, 2, 2, 2, 8, 50, 59, 67, 71, 104, 108]
65+
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 17, 142, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 57, 10, 3, 12, 3, 14, 3, 60, 11, 3, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 66, 10, 4, 12, 4, 14, 4, 69, 11, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 5, 5, 76, 10, 5, 3, 6, 3, 6, 5, 6, 80, 10, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 5, 13, 99, 10, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 5, 19, 116, 10, 19, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 5, 23, 133, 10, 23, 3, 24, 3, 24, 3, 24, 5, 24, 138, 10, 24, 3, 25, 3, 25, 3, 25, 2, 2, 26, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 2, 3, 4, 2, 7, 7, 16, 16, 2, 131, 2, 50, 3, 2, 2, 2, 4, 52, 3, 2, 2, 2, 6, 61, 3, 2, 2, 2, 8, 75, 3, 2, 2, 2, 10, 79, 3, 2, 2, 2, 12, 81, 3, 2, 2, 2, 14, 83, 3, 2, 2, 2, 16, 85, 3, 2, 2, 2, 18, 87, 3, 2, 2, 2, 20, 89, 3, 2, 2, 2, 22, 93, 3, 2, 2, 2, 24, 98, 3, 2, 2, 2, 26, 100, 3, 2, 2, 2, 28, 102, 3, 2, 2, 2, 30, 106, 3, 2, 2, 2, 32, 108, 3, 2, 2, 2, 34, 110, 3, 2, 2, 2, 36, 115, 3, 2, 2, 2, 38, 117, 3, 2, 2, 2, 40, 120, 3, 2, 2, 2, 42, 123, 3, 2, 2, 2, 44, 132, 3, 2, 2, 2, 46, 137, 3, 2, 2, 2, 48, 139, 3, 2, 2, 2, 50, 51, 5, 4, 3, 2, 51, 3, 3, 2, 2, 2, 52, 58, 5, 6, 4, 2, 53, 54, 5, 14, 8, 2, 54, 55, 5, 6, 4, 2, 55, 57, 3, 2, 2, 2, 56, 53, 3, 2, 2, 2, 57, 60, 3, 2, 2, 2, 58, 56, 3, 2, 2, 2, 58, 59, 3, 2, 2, 2, 59, 5, 3, 2, 2, 2, 60, 58, 3, 2, 2, 2, 61, 67, 5, 8, 5, 2, 62, 63, 5, 12, 7, 2, 63, 64, 5, 8, 5, 2, 64, 66, 3, 2, 2, 2, 65, 62, 3, 2, 2, 2, 66, 69, 3, 2, 2, 2, 67, 65, 3, 2, 2, 2, 67, 68, 3, 2, 2, 2, 68, 7, 3, 2, 2, 2, 69, 67, 3, 2, 2, 2, 70, 76, 5, 10, 6, 2, 71, 72, 5, 16, 9, 2, 72, 73, 5, 4, 3, 2, 73, 74, 5, 18, 10, 2, 74, 76, 3, 2, 2, 2, 75, 70, 3, 2, 2, 2, 75, 71, 3, 2, 2, 2, 76, 9, 3, 2, 2, 2, 77, 80, 5, 20, 11, 2, 78, 80, 5, 28, 15, 2, 79, 77, 3, 2, 2, 2, 79, 78, 3, 2, 2, 2, 80, 11, 3, 2, 2, 2, 81, 82, 7, 10, 2, 2, 82, 13, 3, 2, 2, 2, 83, 84, 7, 11, 2, 2, 84, 15, 3, 2, 2, 2, 85, 86, 7, 12, 2, 2, 86, 17, 3, 2, 2, 2, 87, 88, 7, 13, 2, 2, 88, 19, 3, 2, 2, 2, 89, 90, 5, 22, 12, 2, 90, 91, 5, 24, 13, 2, 91, 92, 5, 26, 14, 2, 92, 21, 3, 2, 2, 2, 93, 94, 7, 15, 2, 2, 94, 23, 3, 2, 2, 2, 95, 99, 5, 36, 19, 2, 96, 99, 5, 44, 23, 2, 97, 99, 7, 3, 2, 2, 98, 95, 3, 2, 2, 2, 98, 96, 3, 2, 2, 2, 98, 97, 3, 2, 2, 2, 99, 25, 3, 2, 2, 2, 100, 101, 7, 16, 2, 2, 101, 27, 3, 2, 2, 2, 102, 103, 5, 30, 16, 2, 103, 104, 5, 46, 24, 2, 104, 105, 5, 48, 25, 2, 105, 29, 3, 2, 2, 2, 106, 107, 7, 14, 2, 2, 107, 31, 3, 2, 2, 2, 108, 109, 7, 8, 2, 2, 109, 33, 3, 2, 2, 2, 110, 111, 7, 8, 2, 2, 111, 112, 7, 9, 2, 2, 112, 35, 3, 2, 2, 2, 113, 116, 5, 32, 17, 2, 114, 116, 5, 34, 18, 2, 115, 113, 3, 2, 2, 2, 115, 114, 3, 2, 2, 2, 116, 37, 3, 2, 2, 2, 117, 118, 7, 9, 2, 2, 118, 119, 7, 4, 2, 2, 119, 39, 3, 2, 2, 2, 120, 121, 7, 9, 2, 2, 121, 122, 7, 5, 2, 2, 122, 41, 3, 2, 2, 2, 123, 124, 7, 9, 2, 2, 124, 125, 7, 6, 2, 2, 125, 43, 3, 2, 2, 2, 126, 133, 7, 4, 2, 2, 127, 133, 5, 38, 20, 2, 128, 133, 7, 5, 2, 2, 129, 133, 5, 40, 21, 2, 130, 133, 7, 6, 2, 2, 131, 133, 5, 42, 22, 2, 132, 126, 3, 2, 2, 2, 132, 127, 3, 2, 2, 2, 132, 128, 3, 2, 2, 2, 132, 129, 3, 2, 2, 2, 132, 130, 3, 2, 2, 2, 132, 131, 3, 2, 2, 2, 133, 45, 3, 2, 2, 2, 134, 138, 5, 36, 19, 2, 135, 138, 5, 44, 23, 2, 136, 138, 7, 3, 2, 2, 137, 134, 3, 2, 2, 2, 137, 135, 3, 2, 2, 2, 137, 136, 3, 2, 2, 2, 138, 47, 3, 2, 2, 2, 139, 140, 9, 2, 2, 2, 140, 49, 3, 2, 2, 2, 10, 58, 67, 75, 79, 98, 115, 132, 137]

antlr4/.antlr/RqlLexer.interp

Lines changed: 6 additions & 3 deletions
Large diffs are not rendered by default.

antlr4/Rql.g4

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,48 @@ grammar Rql;
33
/*
44
* Parser Rules start with lower-case characters.
55
*/
6-
eval : orExpression;
6+
eval : orExpression;
77

8-
orExpression : andExpression (or andExpression)*;
8+
orExpression : andExpression (or andExpression)*;
99

10-
andExpression : atomExpression (and atomExpression)*;
10+
andExpression : atomExpression (and atomExpression)*;
1111

12-
atomExpression : atomTerm | (parOpen orExpression parClose);
12+
atomExpression : atomTerm | (parOpen orExpression parClose);
1313

14-
atomTerm : optTerm | term;
14+
atomTerm : optTerm | term;
1515

16-
and : And;
16+
and : And;
1717

18-
or : Or;
18+
or : Or;
1919

20-
parOpen : ParOpen;
20+
parOpen : ParOpen;
2121

22-
parClose : ParClose;
22+
parClose : ParClose;
2323

24-
optTerm : optTerm1 optOperator optTerm2;
25-
optTerm1 : OptIdentifier;
26-
optOperator : Operator;
27-
optTerm2 : JpqlIdentifier;
24+
optTerm : optTerm1 optOperator optTerm2;
25+
optTerm1 : OptIdentifier;
26+
optOperator : nullOperator | negatableOperator | Operator;
27+
optTerm2 : JpqlIdentifier;
2828

29-
term : term1 operator term2;
30-
term1 : Identifier;
31-
nullOperator1 : Is;
32-
nullOperator2 : Is Not;
33-
nullOperator : nullOperator1 | nullOperator2;
34-
operator : nullOperator | Operator;
35-
term2 : Null | JpqlIdentifier;
29+
term : term1 operator term2;
30+
term1 : Identifier;
31+
nullOperator1 : Is;
32+
nullOperator2 : Is Not;
33+
nullOperator : nullOperator1 | nullOperator2;
34+
nLike : Not Like;
35+
nStartsWith : Not StartsWith;
36+
nEndsWith : Not EndsWith;
37+
negatableOperator : Like | nLike | StartsWith | nStartsWith | EndsWith | nEndsWith;
38+
operator : nullOperator | negatableOperator | Operator;
39+
term2 : Null | JpqlIdentifier;
3640

3741
/*
3842
* Lexer Rules start with upper-case characters.
3943
*/
40-
Operator : ST | SEQ | GT | GEQ | EQ | EQAlt | NEQ | NEQAlt | Like | NLike;
44+
Operator : ST | SEQ | GT | GEQ | EQ | EQAlt | NEQ | NEQAlt;
4145
Like : L I K E;
42-
NLike : Not L I K E;
46+
StartsWith : S T A R T S W I T H;
47+
EndsWith : E N D S W I T H;
4348
Null : N U L L;
4449
Is : I S;
4550
Not : N O T;

antlr4/testInput.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
blummi IS NOT NULL AND userId == :userId[long] AND (?timeFrom <= :timeFrom[datetime] OR timeTo > :timeTo[~MyEnum]) OR blubb != :blubb[bool] OR blah <> :blah[int]
1+
blummi IS NOT NULL AND userId == :userId[long] AND (?timeFrom <= :timeFrom[datetime] OR timeTo > :timeTo[~MyEnum]) OR blubb != :blubb[bool] OR blah <> :blah[int] OR wuzi NOT LIKE :wuzi[string] OR zuwi ENDSWITH :zuwi[string] or wasi NOT STARTSWITH :wasi[string]

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717

1818
<modelVersion>4.0.0</modelVersion>
1919
<artifactId>http-server</artifactId>
20-
<version>0.1.18</version>
20+
<version>0.1.19</version>
2121
<name>HttpServer</name>
2222
<packaging>jar</packaging>
2323

2424
<dependencies>
2525
<dependency>
2626
<groupId>info.unterrainer.commons</groupId>
2727
<artifactId>jre-utils</artifactId>
28-
<version>0.1.2</version>
28+
<version>0.1.3</version>
2929
</dependency>
3030
<dependency>
3131
<groupId>info.unterrainer.commons</groupId>

src/main/java/info/unterrainer/commons/httpserver/Information.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
public class Information {
44
public static final String name = "Http-Server";
5-
public static final String buildTime = "2020-12-14T14:13:09Z";
6-
public static final String pomVersion = "0.1.12";
5+
public static final String buildTime = "2021-01-21T17:02:07Z";
6+
public static final String pomVersion = "0.1.19";
77
}

src/main/java/info/unterrainer/commons/httpserver/antlr/RqlBaseListener.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,54 @@ public class RqlBaseListener implements RqlListener {
227227
* <p>The default implementation does nothing.</p>
228228
*/
229229
@Override public void exitNullOperator(RqlParser.NullOperatorContext ctx) { }
230+
/**
231+
* {@inheritDoc}
232+
*
233+
* <p>The default implementation does nothing.</p>
234+
*/
235+
@Override public void enterNLike(RqlParser.NLikeContext ctx) { }
236+
/**
237+
* {@inheritDoc}
238+
*
239+
* <p>The default implementation does nothing.</p>
240+
*/
241+
@Override public void exitNLike(RqlParser.NLikeContext ctx) { }
242+
/**
243+
* {@inheritDoc}
244+
*
245+
* <p>The default implementation does nothing.</p>
246+
*/
247+
@Override public void enterNStartsWith(RqlParser.NStartsWithContext ctx) { }
248+
/**
249+
* {@inheritDoc}
250+
*
251+
* <p>The default implementation does nothing.</p>
252+
*/
253+
@Override public void exitNStartsWith(RqlParser.NStartsWithContext ctx) { }
254+
/**
255+
* {@inheritDoc}
256+
*
257+
* <p>The default implementation does nothing.</p>
258+
*/
259+
@Override public void enterNEndsWith(RqlParser.NEndsWithContext ctx) { }
260+
/**
261+
* {@inheritDoc}
262+
*
263+
* <p>The default implementation does nothing.</p>
264+
*/
265+
@Override public void exitNEndsWith(RqlParser.NEndsWithContext ctx) { }
266+
/**
267+
* {@inheritDoc}
268+
*
269+
* <p>The default implementation does nothing.</p>
270+
*/
271+
@Override public void enterNegatableOperator(RqlParser.NegatableOperatorContext ctx) { }
272+
/**
273+
* {@inheritDoc}
274+
*
275+
* <p>The default implementation does nothing.</p>
276+
*/
277+
@Override public void exitNegatableOperator(RqlParser.NegatableOperatorContext ctx) { }
230278
/**
231279
* {@inheritDoc}
232280
*

src/main/java/info/unterrainer/commons/httpserver/antlr/RqlBaseVisitor.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,34 @@ public class RqlBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements Rq
137137
* {@link #visitChildren} on {@code ctx}.</p>
138138
*/
139139
@Override public T visitNullOperator(RqlParser.NullOperatorContext ctx) { return visitChildren(ctx); }
140+
/**
141+
* {@inheritDoc}
142+
*
143+
* <p>The default implementation returns the result of calling
144+
* {@link #visitChildren} on {@code ctx}.</p>
145+
*/
146+
@Override public T visitNLike(RqlParser.NLikeContext ctx) { return visitChildren(ctx); }
147+
/**
148+
* {@inheritDoc}
149+
*
150+
* <p>The default implementation returns the result of calling
151+
* {@link #visitChildren} on {@code ctx}.</p>
152+
*/
153+
@Override public T visitNStartsWith(RqlParser.NStartsWithContext ctx) { return visitChildren(ctx); }
154+
/**
155+
* {@inheritDoc}
156+
*
157+
* <p>The default implementation returns the result of calling
158+
* {@link #visitChildren} on {@code ctx}.</p>
159+
*/
160+
@Override public T visitNEndsWith(RqlParser.NEndsWithContext ctx) { return visitChildren(ctx); }
161+
/**
162+
* {@inheritDoc}
163+
*
164+
* <p>The default implementation returns the result of calling
165+
* {@link #visitChildren} on {@code ctx}.</p>
166+
*/
167+
@Override public T visitNegatableOperator(RqlParser.NegatableOperatorContext ctx) { return visitChildren(ctx); }
140168
/**
141169
* {@inheritDoc}
142170
*

0 commit comments

Comments
 (0)