Skip to content

Commit d445077

Browse files
committed
EL Grammar improvements
1 parent df3e2fd commit d445077

File tree

3 files changed

+16
-40
lines changed

3 files changed

+16
-40
lines changed

reader_common/src/main/antlr/ElParser.g4

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -181,70 +181,46 @@ elSimpleTerminal:
181181
;
182182

183183
//
184-
// TODO: Can't syntactically distinguish between a local or other variable id
185-
// and a property or constant reference.
184+
// TODO: Can't syntactically distinguish between a local variable
185+
// and a property or constant reference.
186186
//
187187
elValueGenerator:
188-
elBareRef
188+
SYM_SELF
189+
| elBareRef
189190
| elScopedFeatureRef
190-
| typeRef
191191
;
192192

193193
//
194194
// An unscoped reference of some kind
195+
// Will map to EL_WRITABLE_VARIABLE or EL_PROPERTY_REF (unscoped)
195196
//
196197
elBareRef:
197-
elBoundVariableId
198-
| elStaticRef
199-
| elLocalRef
198+
elInstantiableRef
200199
| elFunctionCall
201-
;
202-
203-
//
204-
// Static and constant feature refs, distinguished by the use of
205-
// initial capital in the id.
206-
// Will map to EL_READABLE_VARIABLE or EL_STATIC_REF (unscoped)
207-
//
208-
elStaticRef:
209-
SYM_SELF
210200
| elConstantId
211201
;
212202

213203
//
214-
// Local writable reference, distinguished by use of initial lowercase id
215-
// Will map to EL_WRITABLE_VARIABLE or EL_PROPERTY_REF (unscoped)
204+
// Instantiable feature refs; may be the target of an assignment
216205
//
217-
elLocalRef:
206+
elInstantiableRef:
218207
SYM_RESULT
208+
| elBoundVariableId
219209
| elLocalVariableId
220210
;
221211

212+
222213
//
223-
// scoped feature references.
214+
// Scoped feature references. Has to have at least one scoping element, either a
215+
// class name in {} or else a baseRef name; then any number of bareRefs.
224216
// Will map to any EL_FEATURE_REF (scoped)
225217
//
226-
elScopedFeatureRef: elScoper elFeatureRef ;
218+
elScopedFeatureRef: elScoper elBareRef ;
227219

228-
elScoper: ( typeRef '.' )? ( elBareRef '.' )* ;
229-
230-
typeRef: '{' typeId '}' ;
220+
elScoper: ( '{' typeId '}' | elBareRef ) '.' ( elBareRef '.' )* ;
231221

232222
typeId: UC_ID ( '<' typeId ( ',' typeId )* '>' )? ;
233223

234-
elFeatureRef:
235-
elFunctionCall
236-
| elInstantiableRef
237-
;
238-
239-
//
240-
// Instantiable feature refs
241-
//
242-
elInstantiableRef:
243-
elBoundVariableId
244-
| elLocalVariableId
245-
| elConstantId
246-
;
247-
248224
//
249225
// A variable bound to a data source, lexical form '$xxxx'
250226
// TODO: analyse how a boundVariableId can be created as a built-in feature

reader_common/src/test/resources/bel/fail/date_minimal.el renamed to reader_common/src/test/resources/bel/pass/date_minimal.el

File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
path_systolic: exists /data[id2]/events[id3]/data[id4]/items[id5]/value/magnitude implies exists /data[id2]/events[id3]/data[id4]/items[id6]/value/magnitude
2-
must_exist: every $event in /data[id2]/events[id3] (exists $event/data[id4]/items[id5]/value/magnitude implies exists $event/data[id4]/items[id6]/value/magnitude)
3-
must_set_value: every $event in /data[id2]/events[id3] ($event/data[id4]/items[id5]/value/magnitude > 3 implies $event/data[id4]/items[id6]/value/magnitude = 6)
2+
must_exist: for_all $event in /data[id2]/events[id3] (exists $event/data[id4]/items[id5]/value/magnitude implies exists $event/data[id4]/items[id6]/value/magnitude)
3+
must_set_value: for_all $event in /data[id2]/events[id3] ($event/data[id4]/items[id5]/value/magnitude > 3 implies $event/data[id4]/items[id6]/value/magnitude = 6)

0 commit comments

Comments
 (0)