Skip to content

Commit fb778e3

Browse files
committed
efx-grammar: Add WITH ... COMPUTE syntax for single expressions (TEDEFO-5000)
1 parent 5aea3ad commit fb778e3

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

efx-grammar/Efx.g4

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ options { tokenVocab=EfxLexer;}
4141
* A single-expression is typically used to evaluate a condition.
4242
* If you do not need to process EFX templates, then you can create a full EFX parser that parses these expressions.
4343
* A single-expression contains two parts: a context-declaration and an expression-block.
44-
* Currently we only allow a field-identifier, a node-identifier or an identifier in the context-declaration.
45-
* We may also add support for adding one or more predicates to the context-declaration in the future.
44+
*
45+
* EFX-1 syntax: {context, params} ${expression}
46+
* EFX-2 syntax: WITH context, params COMPUTE expression
4647
*/
47-
singleExpression: StartExpressionBlock context=(FieldId | NodeId | Identifier) (Comma parameterList)? EndBlock expressionBlock EOF;
48+
singleExpression
49+
: StartExpressionBlock context=(FieldId | NodeId | Identifier) (Comma parameterList)? EndBlock expressionBlock EOF // EFX-1
50+
| With context=(FieldId | NodeId | Identifier) (Comma parameterList)? Compute expression EOF // EFX-2
51+
;
4852

4953
/******************************************************************************
5054
Expressions are matched when the lexical analyser is in EXPRESSION mode

efx-grammar/EfxLexer.g4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ Index: INDEX;
326326
By: BY;
327327
Assert: ASSERT;
328328
Report: REPORT;
329+
Compute: COMPUTE;
329330
330331
// Data types ------------------------------------------------------------------------------------------------
331332
@@ -514,6 +515,7 @@ fragment WHEN: ('WHEN' | 'when');
514515
fragment OTHERWISE: ('OTHERWISE' | 'otherwise');
515516
fragment ASSERT: ('ASSERT' | 'assert');
516517
fragment REPORT: ('REPORT' | 'report');
518+
fragment COMPUTE: ('COMPUTE' | 'compute');
517519
fragment STAGE: ('STAGE' | 'stage');
518520
fragment ENDPOINT: ('ENDPOINT' | 'endpoint');
519521
fragment INDEX: ('INDEX' | 'index');

0 commit comments

Comments
 (0)