|
63 | 63 | | "(" compound_condition boolean_arithmetic compound_condition ")"
|
64 | 64 | | compound_condition boolean_arithmetic compound_condition
|
65 | 65 |
|
66 |
| -condition : entity_id op entity_id_or_value |
| 66 | +condition : (entity_id | scalar_function) op entity_id_or_value |
| 67 | + | (entity_id | scalar_function) op_list value_list |
67 | 68 | | "not"i condition -> condition_not
|
68 | 69 |
|
69 | 70 | ?entity_id_or_value : entity_id
|
70 | 71 | | value
|
71 |
| - | "NULL"i -> null |
72 |
| - | "TRUE"i -> true |
73 |
| - | "FALSE"i -> false |
| 72 | + | NULL -> null |
| 73 | + | TRUE -> true |
| 74 | + | FALSE -> false |
74 | 75 |
|
75 | 76 | op : "==" -> op_eq
|
76 | 77 | | "=" -> op_eq
|
|
80 | 81 | | ">="-> op_gte
|
81 | 82 | | "<="-> op_lte
|
82 | 83 | | "is"i -> op_is
|
83 |
| - | "in"i -> op_in |
84 | 84 | | "contains"i -> op_contains
|
85 | 85 | | "starts with"i -> op_starts_with
|
86 | 86 | | "ends with"i -> op_ends_with
|
87 | 87 |
|
| 88 | +op_list : "in"i -> op_in |
88 | 89 |
|
89 | 90 |
|
90 | 91 |
|
91 | 92 | return_clause : "return"i distinct_return? return_item ("," return_item)*
|
92 |
| -return_item : (entity_id | aggregation_function | entity_id "." attribute_id) ( "AS"i alias )? |
| 93 | +return_item : (entity_id | aggregation_function | scalar_function | entity_id "." attribute_id) ( "AS"i alias )? |
93 | 94 | alias : CNAME
|
94 | 95 |
|
95 | 96 | aggregation_function : AGGREGATE_FUNC "(" entity_id ( "." attribute_id )? ")"
|
96 | 97 | AGGREGATE_FUNC : "COUNT" | "SUM" | "AVG" | "MAX" | "MIN"
|
97 | 98 | attribute_id : CNAME
|
98 | 99 |
|
| 100 | +scalar_function : "id"i "(" entity_id ")" -> id_function |
| 101 | +
|
99 | 102 | distinct_return : "DISTINCT"i
|
100 | 103 | limit_clause : "limit"i NUMBER
|
101 | 104 | skip_clause : "skip"i NUMBER
|
|
131 | 134 | | LEFT_ANGLE? "-[" CNAME ":" TYPE "*" MIN_HOP "]-" RIGHT_ANGLE?
|
132 | 135 | | LEFT_ANGLE? "-[" CNAME ":" TYPE "*" MIN_HOP ".." MAX_HOP "]-" RIGHT_ANGLE?
|
133 | 136 |
|
| 137 | +value_list : "[" [value ("," value)*] "]" |
134 | 138 | type_list : TYPE ( "|" TYPE )*
|
135 | 139 |
|
136 | 140 | LEFT_ANGLE : "<"
|
|
149 | 153 | key : CNAME
|
150 | 154 | ?value : ESTRING
|
151 | 155 | | NUMBER
|
152 |
| - | "NULL"i -> null |
153 |
| - | "TRUE"i -> true |
154 |
| - | "FALSE"i -> false |
| 156 | + | NULL -> null |
| 157 | + | TRUE -> true |
| 158 | + | FALSE -> false |
| 159 | +
|
| 160 | +NULL.1 : "NULL"i |
| 161 | +TRUE.1 : "TRUE"i |
| 162 | +FALSE.1 : "FALSE"i |
155 | 163 |
|
156 | 164 |
|
157 | 165 | %import common.CNAME -> CNAME
|
@@ -1175,6 +1183,12 @@ def condition_not(self, processed_condition):
|
1175 | 1183 | ESTRING = v_args(inline=True)(eval)
|
1176 | 1184 | NUMBER = v_args(inline=True)(eval)
|
1177 | 1185 |
|
| 1186 | + def id_function(self, entity_id): |
| 1187 | + return entity_id[0].value |
| 1188 | + |
| 1189 | + def value_list(self, items): |
| 1190 | + return list(items) |
| 1191 | + |
1178 | 1192 | def op(self, operator):
|
1179 | 1193 | return operator
|
1180 | 1194 |
|
|
0 commit comments