pydpm_xl 0.1.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. py_dpm/AST/ASTConstructor.py +503 -0
  2. py_dpm/AST/ASTObjects.py +827 -0
  3. py_dpm/AST/ASTTemplate.py +101 -0
  4. py_dpm/AST/ASTVisitor.py +13 -0
  5. py_dpm/AST/MLGeneration.py +588 -0
  6. py_dpm/AST/ModuleAnalyzer.py +79 -0
  7. py_dpm/AST/ModuleDependencies.py +203 -0
  8. py_dpm/AST/WhereClauseChecker.py +12 -0
  9. py_dpm/AST/__init__.py +0 -0
  10. py_dpm/AST/check_operands.py +302 -0
  11. py_dpm/DataTypes/ScalarTypes.py +324 -0
  12. py_dpm/DataTypes/TimeClasses.py +370 -0
  13. py_dpm/DataTypes/TypePromotion.py +195 -0
  14. py_dpm/DataTypes/__init__.py +0 -0
  15. py_dpm/Exceptions/__init__.py +0 -0
  16. py_dpm/Exceptions/exceptions.py +84 -0
  17. py_dpm/Exceptions/messages.py +114 -0
  18. py_dpm/OperationScopes/OperationScopeService.py +247 -0
  19. py_dpm/OperationScopes/__init__.py +0 -0
  20. py_dpm/Operators/AggregateOperators.py +138 -0
  21. py_dpm/Operators/BooleanOperators.py +30 -0
  22. py_dpm/Operators/ClauseOperators.py +159 -0
  23. py_dpm/Operators/ComparisonOperators.py +69 -0
  24. py_dpm/Operators/ConditionalOperators.py +362 -0
  25. py_dpm/Operators/NumericOperators.py +101 -0
  26. py_dpm/Operators/Operator.py +388 -0
  27. py_dpm/Operators/StringOperators.py +27 -0
  28. py_dpm/Operators/TimeOperators.py +53 -0
  29. py_dpm/Operators/__init__.py +0 -0
  30. py_dpm/Utils/ValidationsGenerationUtils.py +429 -0
  31. py_dpm/Utils/__init__.py +0 -0
  32. py_dpm/Utils/operands_mapping.py +73 -0
  33. py_dpm/Utils/operator_mapping.py +89 -0
  34. py_dpm/Utils/tokens.py +172 -0
  35. py_dpm/Utils/utils.py +2 -0
  36. py_dpm/ValidationsGeneration/PropertiesConstraintsProcessor.py +190 -0
  37. py_dpm/ValidationsGeneration/Utils.py +364 -0
  38. py_dpm/ValidationsGeneration/VariantsProcessor.py +265 -0
  39. py_dpm/ValidationsGeneration/__init__.py +0 -0
  40. py_dpm/ValidationsGeneration/auxiliary_functions.py +98 -0
  41. py_dpm/__init__.py +61 -0
  42. py_dpm/api/__init__.py +140 -0
  43. py_dpm/api/ast_generator.py +438 -0
  44. py_dpm/api/complete_ast.py +241 -0
  45. py_dpm/api/data_dictionary_validation.py +577 -0
  46. py_dpm/api/migration.py +77 -0
  47. py_dpm/api/semantic.py +224 -0
  48. py_dpm/api/syntax.py +182 -0
  49. py_dpm/client.py +106 -0
  50. py_dpm/data_handlers.py +99 -0
  51. py_dpm/db_utils.py +117 -0
  52. py_dpm/grammar/__init__.py +0 -0
  53. py_dpm/grammar/dist/__init__.py +0 -0
  54. py_dpm/grammar/dist/dpm_xlLexer.interp +428 -0
  55. py_dpm/grammar/dist/dpm_xlLexer.py +804 -0
  56. py_dpm/grammar/dist/dpm_xlLexer.tokens +106 -0
  57. py_dpm/grammar/dist/dpm_xlParser.interp +249 -0
  58. py_dpm/grammar/dist/dpm_xlParser.py +5224 -0
  59. py_dpm/grammar/dist/dpm_xlParser.tokens +106 -0
  60. py_dpm/grammar/dist/dpm_xlParserListener.py +742 -0
  61. py_dpm/grammar/dist/dpm_xlParserVisitor.py +419 -0
  62. py_dpm/grammar/dist/listeners.py +10 -0
  63. py_dpm/grammar/dpm_xlLexer.g4 +435 -0
  64. py_dpm/grammar/dpm_xlParser.g4 +260 -0
  65. py_dpm/migration.py +282 -0
  66. py_dpm/models.py +2139 -0
  67. py_dpm/semantics/DAG/DAGAnalyzer.py +158 -0
  68. py_dpm/semantics/DAG/__init__.py +0 -0
  69. py_dpm/semantics/SemanticAnalyzer.py +320 -0
  70. py_dpm/semantics/Symbols.py +223 -0
  71. py_dpm/semantics/__init__.py +0 -0
  72. py_dpm/utils/__init__.py +0 -0
  73. py_dpm/utils/ast_serialization.py +481 -0
  74. py_dpm/views/data_types.sql +12 -0
  75. py_dpm/views/datapoints.sql +65 -0
  76. py_dpm/views/hierarchy_operand_reference.sql +11 -0
  77. py_dpm/views/hierarchy_preconditions.sql +13 -0
  78. py_dpm/views/hierarchy_variables.sql +26 -0
  79. py_dpm/views/hierarchy_variables_context.sql +14 -0
  80. py_dpm/views/key_components.sql +18 -0
  81. py_dpm/views/module_from_table.sql +11 -0
  82. py_dpm/views/open_keys.sql +13 -0
  83. py_dpm/views/operation_info.sql +27 -0
  84. py_dpm/views/operation_list.sql +18 -0
  85. py_dpm/views/operations_versions_from_module_version.sql +30 -0
  86. py_dpm/views/precondition_info.sql +17 -0
  87. py_dpm/views/report_type_operand_reference_info.sql +18 -0
  88. py_dpm/views/subcategory_info.sql +17 -0
  89. py_dpm/views/table_info.sql +19 -0
  90. pydpm_xl-0.1.10.dist-info/LICENSE +674 -0
  91. pydpm_xl-0.1.10.dist-info/METADATA +50 -0
  92. pydpm_xl-0.1.10.dist-info/RECORD +94 -0
  93. pydpm_xl-0.1.10.dist-info/WHEEL +4 -0
  94. pydpm_xl-0.1.10.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,435 @@
1
+ lexer grammar dpm_xlLexer;
2
+
3
+ // ------------ Individual tokens -----------
4
+
5
+ // Boolean
6
+ BOOLEAN_LITERAL:
7
+ 'true'
8
+ | 'false'
9
+ ;
10
+
11
+ AND: 'and';
12
+ OR: 'or';
13
+ XOR: 'xor';
14
+
15
+ NOT: 'not';
16
+
17
+ // Assign
18
+ ASSIGN: ':=';
19
+ PERSISTENT_ASSIGN: '<-';
20
+
21
+ // Comparison
22
+ EQ: '=';
23
+ NE: '!=';
24
+ LT: '<';
25
+ LE: '<=';
26
+ GT: '>';
27
+ GE: '>=';
28
+
29
+ // Matches
30
+ MATCH: 'match';
31
+
32
+ // With
33
+ WITH: 'with';
34
+
35
+ // Arithmetic
36
+ PLUS: '+';
37
+ MINUS: '-';
38
+ MULT: '*';
39
+ DIV: '/';
40
+
41
+ // Aggregate
42
+ MAX_AGGR: 'max_aggr';
43
+ MIN_AGGR: 'min_aggr';
44
+ SUM: 'sum';
45
+ COUNT: 'count';
46
+ AVG: 'avg';
47
+ MEDIAN: 'median';
48
+
49
+ // Grouping
50
+ GROUP_BY: 'group by' -> pushMode(GROUPING_CLAUSE_MODE);
51
+
52
+ // Unary
53
+ ABS: 'abs';
54
+ ISNULL: 'isnull';
55
+ EXP: 'exp';
56
+ LN: 'ln';
57
+ SQRT: 'sqrt';
58
+
59
+ // Binary
60
+ POWER: 'power';
61
+ LOG: 'log';
62
+
63
+ MAX: 'max';
64
+ MIN: 'min';
65
+
66
+ // Belonging
67
+ IN: 'in' -> pushMode(SET_OPERAND_MODE);
68
+
69
+ // Punctuation elements
70
+ COMMA: ',';
71
+ COLON: ':';
72
+
73
+ // Parenthesis
74
+ LPAREN: '(';
75
+ RPAREN: ')';
76
+
77
+
78
+ // Brackets
79
+ CURLY_BRACKET_LEFT: '{' -> pushMode(SELECTION_MODE);
80
+ CURLY_BRACKET_RIGHT: '}';
81
+ SQUARE_BRACKET_LEFT: '[' -> pushMode(CLAUSE_MODE);
82
+ SQUARE_BRACKET_RIGHT: ']';
83
+
84
+
85
+ // Conditional
86
+ IF: 'if';
87
+ ENDIF: 'endif';
88
+ THEN: 'then';
89
+ ELSE: 'else';
90
+ NVL: 'nvl';
91
+
92
+ // Filter
93
+ FILTER: 'filter';
94
+
95
+ // Clause
96
+ WHERE: 'where';
97
+ GET: 'get';
98
+ RENAME: 'rename';
99
+ TO: 'to';
100
+
101
+ // Reference date
102
+ TIME_SHIFT: 'time_shift';
103
+
104
+ // String
105
+ LEN: 'len';
106
+ CONCAT: '&';
107
+
108
+ // Time periods
109
+
110
+ TIME_PERIOD: 'A'
111
+ | 'S'
112
+ | 'Q'
113
+ | 'M'
114
+ | 'W'
115
+ | 'D'
116
+ ;
117
+
118
+ // End of line
119
+ EOL: ';';
120
+
121
+
122
+ // ------------ Literals ---------------
123
+ fragment
124
+ DIGITS0_9: '0'..'9';
125
+ fragment
126
+ DIGITS1_9: '1'..'9';
127
+
128
+ INTEGER_LITERAL: DIGITS0_9+
129
+ | LPAREN MINUS DIGITS0_9+ RPAREN;
130
+ DECIMAL_LITERAL: INTEGER_LITERAL '.' INTEGER_LITERAL;
131
+ PERCENT_LITERAL: INTEGER_LITERAL '%'
132
+ | DECIMAL_LITERAL '%'
133
+ ;
134
+ NULL_LITERAL: 'null';
135
+ STRING_LITERAL: '"' (~'"')+ '"' | '\'' (~'\'')+ '\'';
136
+ EMPTY_LITERAL: '\'\'' | '""';
137
+
138
+ fragment
139
+ YEAR: DIGITS0_9 DIGITS0_9 DIGITS0_9 DIGITS0_9;
140
+
141
+ fragment
142
+ MONTH: '0' DIGITS1_9
143
+ | '1' [0-2]
144
+ ;
145
+
146
+ fragment
147
+ WEEK: '0' DIGITS1_9
148
+ | [1-4] DIGITS0_9
149
+ | '5' [0-2]
150
+ ;
151
+
152
+ fragment
153
+ DAY: [0-2] DIGITS0_9
154
+ | '3' [0-1];
155
+
156
+ fragment
157
+ HOURS: [0-1] DIGITS0_9
158
+ | '2' [0-3]
159
+ ;
160
+
161
+ fragment
162
+ MINUTES: [0-5] DIGITS0_9;
163
+
164
+ fragment
165
+ SECONDS: [0-5] DIGITS0_9;
166
+
167
+ fragment
168
+ DATE_FORMAT: YEAR '-' MONTH '-' DAY ('T' HOURS COLON MINUTES COLON SECONDS)?;
169
+
170
+ fragment
171
+ TIME_PERIOD_FORMAT: YEAR 'A'?
172
+ | YEAR 'D' [0-3] DIGITS0_9 DIGITS0_9
173
+ | YEAR 'W' WEEK
174
+ | YEAR 'M' MONTH
175
+ | YEAR 'Q' [1-4]
176
+ | YEAR 'S' [1-2]
177
+ ;
178
+
179
+ DATE_LITERAL: '#' DATE_FORMAT '#';
180
+
181
+ TIME_INTERVAL_LITERAL: '#' DATE_FORMAT '/' DATE_FORMAT '#';
182
+
183
+ TIME_PERIOD_LITERAL: '#' TIME_PERIOD_FORMAT '#';
184
+
185
+ CODE: [A-Za-z]([A-Za-z0-9_.]*[A-Za-z0-9])*;
186
+
187
+ WS: [ \t\r\n\u000C]+ -> channel(2);
188
+
189
+
190
+ mode SELECTION_MODE;
191
+
192
+ SELECTION_MODE_COMMA: COMMA -> type(COMMA);
193
+ SELECTION_MODE_COLON: COLON -> type(COLON);
194
+
195
+ SELECTION_MODE_LPAREN: LPAREN -> type(LPAREN);
196
+ SELECTION_MODE_RPAREN: RPAREN -> type(RPAREN);
197
+
198
+ SELECTION_MODE_CURLY_BRACKET_RIGHT: CURLY_BRACKET_RIGHT -> popMode, type(CURLY_BRACKET_RIGHT);
199
+
200
+ INTERVAL: 'interval';
201
+ DEFAULT: 'default';
202
+
203
+ SELECTION_MODE_NULL_LITERAL: NULL_LITERAL -> type(NULL_LITERAL);
204
+ SELECTION_MODE_BOOLEAN_LITERAL: BOOLEAN_LITERAL -> type(BOOLEAN_LITERAL);
205
+
206
+ // Prefix
207
+
208
+ fragment
209
+ ROW_PREFIX: 'r';
210
+ fragment
211
+ COL_PREFIX: 'c';
212
+ fragment
213
+ SHEET_PREFIX: 's';
214
+ fragment
215
+ TABLE_PREFIX: 't';
216
+ fragment
217
+ TABLE_GROUP_PREFIX: 'g';
218
+
219
+ fragment
220
+ VAR_REF_PREFIX: 'v';
221
+ fragment
222
+ OPERATION_REF_PREFIX: 'o';
223
+ fragment
224
+ PRECONDITION_PREFIX: 'v_';
225
+
226
+
227
+ // Codes
228
+
229
+ fragment
230
+ TABLE_CODE: [A-Za-z]([A-Za-z0-9_.-]*[A-Za-z0-9])*
231
+ ;
232
+ fragment
233
+ CELL_COMPONENT_CODE: [0-9A-Za-z]+;
234
+ fragment
235
+ CELL_COMPONENT_RANGE: CELL_COMPONENT_CODE [-] CELL_COMPONENT_CODE;
236
+
237
+ fragment
238
+ VAR_CODE: [A-Za-z]([A-Za-z0-9_.]*[A-Za-z0-9])*;
239
+ fragment
240
+ OPERATION_CODE: [A-Za-z]([A-Za-z0-9_.]*[A-Za-z0-9])*;
241
+
242
+ ROW: ROW_PREFIX CELL_COMPONENT_CODE;
243
+ ROW_RANGE: ROW_PREFIX CELL_COMPONENT_RANGE;
244
+ ROW_ALL: ROW_PREFIX [*];
245
+
246
+ COL: COL_PREFIX CELL_COMPONENT_CODE;
247
+ COL_RANGE: COL_PREFIX CELL_COMPONENT_RANGE;
248
+ COL_ALL: COL_PREFIX [*];
249
+
250
+ SHEET: SHEET_PREFIX CELL_COMPONENT_CODE;
251
+ SHEET_RANGE: SHEET_PREFIX CELL_COMPONENT_RANGE;
252
+ SHEET_ALL: SHEET_PREFIX [*];
253
+
254
+ TABLE_REFERENCE: TABLE_PREFIX TABLE_CODE;
255
+ TABLE_GROUP_REFERENCE: TABLE_GROUP_PREFIX TABLE_CODE;
256
+
257
+ VAR_REFERENCE: VAR_REF_PREFIX VAR_CODE;
258
+ OPERATION_REFERENCE: OPERATION_REF_PREFIX OPERATION_CODE;
259
+ PRECONDITION_ELEMENT: PRECONDITION_PREFIX TABLE_CODE;
260
+
261
+ SELECTION_MODE_INTEGER_LITERAL: INTEGER_LITERAL -> type(INTEGER_LITERAL);
262
+ SELECTION_MODE_DECIMAL_LITERAL: DECIMAL_LITERAL -> type(DECIMAL_LITERAL);
263
+ SELECTION_MODE_PERCENT_LITERAL: PERCENT_LITERAL -> type(PERCENT_LITERAL);
264
+
265
+ SELECTION_MODE_STRING_LITERAL: STRING_LITERAL -> type(STRING_LITERAL);
266
+ SELECTION_MODE_EMPTY_LITERAL: EMPTY_LITERAL -> type(EMPTY_LITERAL);
267
+
268
+ SELECTION_MODE_DATE_LITERAL: DATE_LITERAL -> type(DATE_LITERAL);
269
+ SELECTION_MODE_TIME_INTERVAL_LITERAL: TIME_INTERVAL_LITERAL -> type(TIME_INTERVAL_LITERAL);
270
+ SELECTION_MODE_TIME_PERIOD_LITERAL: TIME_PERIOD_LITERAL -> type(TIME_PERIOD_LITERAL);
271
+
272
+ SELECTION_MODE_WS: WS -> channel(2);
273
+
274
+
275
+ mode CLAUSE_MODE;
276
+
277
+ CLAUSE_BOOLEAN_LITERAL: BOOLEAN_LITERAL -> type(BOOLEAN_LITERAL);
278
+
279
+ CLAUSE_AND: 'and' -> type(AND);
280
+ CLAUSE_OR: 'or' -> type(OR);
281
+ CLAUSE_XOR: 'xor' -> type(XOR);
282
+
283
+ CLAUSE_NOT: 'not' -> type(NOT);
284
+
285
+ // Comparison
286
+ CLAUSE_EQ: '=' -> type(EQ);
287
+ CLAUSE_NE: '!=' -> type(NE);
288
+ CLAUSE_LT: '<' -> type(LT);
289
+ CLAUSE_LE: '<=' -> type(LE);
290
+ CLAUSE_GT: '>' -> type(GT);
291
+ CLAUSE_GE: '>=' -> type(GE);
292
+
293
+ // Matches
294
+ CLAUSE_MATCH: 'match' -> type(MATCH);
295
+
296
+ // Arithmetic
297
+ CLAUSE_PLUS: '+' -> type(PLUS);
298
+ CLAUSE_MINUS: '-' -> type(MINUS);
299
+ CLAUSE_MULT: '*' -> type(MULT);
300
+ CLAUSE_DIV: '/' -> type(DIV);
301
+
302
+ // Aggregate
303
+ CLAUSE_MAX_AGGR: 'max_aggr' -> type(MAX_AGGR);
304
+ CLAUSE_MIN_AGGR: 'min_aggr' -> type(MIN_AGGR);
305
+ CLAUSE_SUM: 'sum' -> type(SUM);
306
+ CLAUSE_COUNT: 'count' -> type(COUNT);
307
+ CLAUSE_AVG: 'avg' -> type(AVG);
308
+ CLAUSE_MEDIAN: 'median' -> type(MEDIAN);
309
+
310
+ // Grouping
311
+ CLAUSE_GROUP_BY: 'group by' -> type(GROUP_BY), pushMode(GROUPING_CLAUSE_MODE);
312
+
313
+ // Unary
314
+ CLAUSE_ABS: 'abs' -> type(ABS);
315
+ CLAUSE_ISNULL: 'isnull' -> type(ISNULL);
316
+ CLAUSE_EXP: 'exp' -> type(EXP);
317
+ CLAUSE_LN: 'ln' -> type(LN);
318
+ CLAUSE_SQRT: 'sqrt' -> type(SQRT);
319
+
320
+ // Binary
321
+ CLAUSE_POWER: 'power' -> type(POWER);
322
+ CLAUSE_LOG: 'log' -> type(LOG);
323
+
324
+ CLAUSE_MAX: 'max' -> type(MAX);
325
+ CLAUSE_MIN: 'min' -> type(MIN);
326
+
327
+ // Belonging
328
+ CLAUSE_IN: 'in' -> pushMode(SET_OPERAND_MODE), type(IN);
329
+
330
+ // Punctuation elements
331
+ CLAUSE_COMMA: ',' -> type(COMMA);
332
+ CLAUSE_COLON: ':' -> type(COLON);
333
+
334
+ // Parenthesis
335
+ CLAUSE_LPAREN: '(' -> type(LPAREN);
336
+ CLAUSE_RPAREN: ')' -> type(RPAREN);
337
+
338
+
339
+ // Brackets
340
+ CLAUSE_CURLY_BRACKET_LEFT: '{' -> type(CURLY_BRACKET_LEFT), pushMode(SELECTION_MODE);
341
+ CLAUSE_CURLY_BRACKET_RIGHT: '}' -> type(CURLY_BRACKET_RIGHT);
342
+ CLAUSE_SQUARE_BRACKET_LEFT: '[' -> type(SQUARE_BRACKET_LEFT), pushMode(CLAUSE_MODE);
343
+ CLAUSE_SQUARE_BRACKET_RIGHT: ']' -> type(SQUARE_BRACKET_RIGHT), popMode;
344
+
345
+
346
+ // Conditional
347
+ CLAUSE_IF: 'if' -> type(IF);
348
+ CLAUSE_ENDIF: 'endif' -> type(ENDIF);
349
+ CLAUSE_THEN: 'then' -> type(THEN);
350
+ CLAUSE_ELSE: 'else' -> type(ELSE);
351
+ CLAUSE_NVL: 'nvl' -> type(NVL);
352
+
353
+ // Filter
354
+ CLAUSE_FILTER: 'filter' -> type(FILTER);
355
+
356
+ // Clause
357
+ CLAUSE_WHERE: 'where' -> type(WHERE);
358
+ CLAUSE_GET: 'get' -> type(GET);
359
+ CLAUSE_RENAME: 'rename' -> type(RENAME);
360
+ CLAUSE_TO: 'to' -> type(TO);
361
+
362
+ // Reference date
363
+ CLAUSE_TIME_SHIFT: 'time_shift' -> type(TIME_SHIFT);
364
+
365
+ // String
366
+ CLAUSE_LEN: 'len' -> type(LEN);
367
+ CLAUSE_CONCAT: '&' -> type(CONCAT);
368
+
369
+ // Regex
370
+
371
+ // Prefix
372
+ ROW_COMPONENT: 'r';
373
+ COL_COMPONENT: 'c';
374
+ SHEET_COMPONENT: 's';
375
+
376
+ // Time periods
377
+
378
+ CLAUSE_TIME_PERIOD: TIME_PERIOD -> type(TIME_PERIOD);
379
+
380
+ CLAUSE_INTEGER_LITERAL: INTEGER_LITERAL -> type(INTEGER_LITERAL);
381
+ CLAUSE_DECIMAL_LITERAL: DECIMAL_LITERAL -> type(DECIMAL_LITERAL);
382
+ CLAUSE_PERCENT_LITERAL: PERCENT_LITERAL -> type(PERCENT_LITERAL);
383
+
384
+ CLAUSE_STRING_LITERAL: STRING_LITERAL -> type(STRING_LITERAL);
385
+ CLAUSE_EMPTY_LITERAL: EMPTY_LITERAL -> type(EMPTY_LITERAL);
386
+
387
+ CLAUSE_DATE_LITERAL: '#' DATE_FORMAT '#' -> type(DATE_LITERAL);
388
+
389
+ CLAUSE_TIME_INTERVAL_LITERAL: '#' DATE_FORMAT '/' DATE_FORMAT '#' -> type(TIME_INTERVAL_LITERAL);
390
+
391
+ CLAUSE_TIME_PERIOD_LITERAL: '#' TIME_PERIOD_FORMAT '#' -> type(TIME_PERIOD_LITERAL);
392
+
393
+ ITEM_SIGNATURE: [A-Za-z]([A-Za-z0-9_-]*[:][A-Za-z0-9._-]*[A-Za-z0-9])+;
394
+ PROPERTY_CODE: CODE;
395
+
396
+ CLAUSE_WS: [ \t\r\n\u000C]+ -> channel(2);
397
+
398
+
399
+ mode GROUPING_CLAUSE_MODE;
400
+
401
+ GROUPING_RPAREN: ')' -> type(RPAREN), popMode;
402
+ GROUPING_COMMA: ',' -> type(COMMA);
403
+
404
+ GROUPING_ROW_COMPONENT: 'r' -> type(ROW_COMPONENT);
405
+ GROUPING_COL_COMPONENT: 'c' -> type(COL_COMPONENT);
406
+ GROUPING_SHEET_COMPONENT: 's' -> type(SHEET_COMPONENT);
407
+ GROUPING_PROPERTY_CODE: CODE -> type(PROPERTY_CODE);
408
+
409
+ GROUPING_WS: [ \t\r\n\u000C]+ -> channel(2);
410
+
411
+
412
+ mode SET_OPERAND_MODE;
413
+
414
+ SET_OPERAND_MODE_COMMA: COMMA -> type(COMMA);
415
+
416
+ SET_OPERAND_MODE_CURLY_BRACKET_LEFT: CURLY_BRACKET_LEFT -> type(CURLY_BRACKET_LEFT);
417
+ SET_OPERAND_MODE_CURLY_BRACKET_RIGHT: CURLY_BRACKET_RIGHT -> popMode, type(CURLY_BRACKET_RIGHT);
418
+
419
+ SET_OPERAND_MODE_SQUARE_BRACKET_LEFT: SQUARE_BRACKET_LEFT -> type(SQUARE_BRACKET_LEFT);
420
+ SET_OPERAND_MODE_SQUARE_BRACKET_RIGHT: SQUARE_BRACKET_RIGHT -> type(SQUARE_BRACKET_RIGHT);
421
+
422
+ SET_OPERAND_MODE_ITEM_SIGNATURE: ITEM_SIGNATURE -> type(ITEM_SIGNATURE);
423
+
424
+ SET_OPERAND_MODE_INTEGER_LITERAL: INTEGER_LITERAL -> type(INTEGER_LITERAL);
425
+ SET_OPERAND_MODE_DECIMAL_LITERAL: DECIMAL_LITERAL -> type(DECIMAL_LITERAL);
426
+ SET_OPERAND_MODE_PERCENT_LITERAL: PERCENT_LITERAL -> type(PERCENT_LITERAL);
427
+
428
+ SET_OPERAND_MODE_STRING_LITERAL: STRING_LITERAL -> type(STRING_LITERAL);
429
+ SET_OPERAND_MODE_EMPTY_LITERAL: EMPTY_LITERAL -> type(EMPTY_LITERAL);
430
+
431
+ SET_OPERAND_MODE_DATE_LITERAL: DATE_LITERAL -> type(DATE_LITERAL);
432
+ SET_OPERAND_MODE_TIME_INTERVAL_LITERAL: TIME_INTERVAL_LITERAL -> type(TIME_INTERVAL_LITERAL);
433
+ SET_OPERAND_MODE_TIME_PERIOD_LITERAL: TIME_PERIOD_LITERAL -> type(TIME_PERIOD_LITERAL);
434
+
435
+ SET_OPERAND_MODE_WS: WS -> channel(2);
@@ -0,0 +1,260 @@
1
+ parser grammar dpm_xlParser;
2
+
3
+ options { tokenVocab=dpm_xlLexer ;}
4
+
5
+ // Added rule for expr management and EOF
6
+ start:
7
+ statement ((EOL statements) | EOL?) EOF
8
+ ;
9
+
10
+ statements:
11
+ (statement EOL)+
12
+ ;
13
+
14
+ statement:
15
+ expressionWithoutAssignment #exprWithoutAssignment
16
+ | temporaryAssignmentExpression #assignmentExpr
17
+ ;
18
+
19
+ persistentExpression:
20
+ persistentAssignmentExpression
21
+ | expressionWithoutAssignment
22
+ ;
23
+
24
+ expressionWithoutAssignment:
25
+ expression #exprWithoutPartialSelection
26
+ | WITH partialSelection COLON expression #exprWithSelection
27
+ ;
28
+
29
+ partialSelection:
30
+ CURLY_BRACKET_LEFT cellRef CURLY_BRACKET_RIGHT #partialSelect
31
+ ;
32
+
33
+ temporaryAssignmentExpression:
34
+ temporaryIdentifier ASSIGN persistentExpression
35
+ ;
36
+
37
+ persistentAssignmentExpression:
38
+ varID PERSISTENT_ASSIGN expressionWithoutAssignment
39
+ ;
40
+
41
+ expression:
42
+ LPAREN expression RPAREN #parExpr
43
+ | functions #funcExpr
44
+ | expression SQUARE_BRACKET_LEFT clauseOperators SQUARE_BRACKET_RIGHT #clauseExpr
45
+ | op=(PLUS|MINUS) expression #unaryExpr
46
+ | op=NOT LPAREN expression RPAREN #notExpr
47
+ | left=expression op=(MULT|DIV) right=expression #numericExpr
48
+ | left=expression op=(PLUS|MINUS) right=expression #numericExpr
49
+ | left=expression op=CONCAT right=expression #concatExpr
50
+ | left=expression op=comparisonOperators right=expression #compExpr
51
+ | left=expression op=IN setOperand #inExpr
52
+ | left=expression op=AND right=expression #boolExpr
53
+ | left=expression op=(OR|XOR) right=expression #boolExpr
54
+ | IF conditionalExpr=expression THEN thenExpr=expression (ELSE elseExpr=expression)? ENDIF #ifExpr
55
+ | itemReference #itemReferenceExpr
56
+ | propertyReference #propertyReferenceExpr
57
+ | keyNames #keyNamesExpr
58
+ | literal #literalExpr
59
+ | select #selectExpr
60
+ ;
61
+
62
+ setOperand:
63
+ CURLY_BRACKET_LEFT setElements CURLY_BRACKET_RIGHT
64
+ ;
65
+
66
+ setElements:
67
+ itemReference (COMMA itemReference)*
68
+ | literal (COMMA literal)*
69
+ ;
70
+
71
+ functions:
72
+ aggregateOperators #aggregateFunctions
73
+ | numericOperators #numericFunctions
74
+ | comparisonFunctionOperators #comparisonFunctions
75
+ | filterOperators #filterFunctions
76
+ | conditionalOperators #conditionalFunctions
77
+ | timeOperators #timeFunctions
78
+ | stringOperators #stringFunctions
79
+ ;
80
+
81
+ numericOperators:
82
+ op=(ABS|EXP|LN|SQRT) LPAREN expression RPAREN #unaryNumericFunctions
83
+ | op=(POWER|LOG) LPAREN left=expression COMMA right=expression RPAREN #binaryNumericFunctions
84
+ | op=(MAX|MIN) LPAREN expression (COMMA expression)+ RPAREN #complexNumericFunctions
85
+ ;
86
+
87
+ comparisonFunctionOperators:
88
+ MATCH LPAREN expression COMMA literal RPAREN #matchExpr
89
+ | ISNULL LPAREN expression RPAREN #isnullExpr
90
+ ;
91
+
92
+ filterOperators:
93
+ FILTER LPAREN expression COMMA expression RPAREN
94
+ ;
95
+
96
+ timeOperators:
97
+ TIME_SHIFT LPAREN expression COMMA TIME_PERIOD COMMA INTEGER_LITERAL (COMMA propertyCode)? RPAREN #timeShiftFunction
98
+ ;
99
+
100
+ conditionalOperators:
101
+ NVL LPAREN expression COMMA expression RPAREN #nvlFunction
102
+ ;
103
+
104
+ stringOperators:
105
+ LEN LPAREN expression RPAREN #unaryStringFunction
106
+ ;
107
+
108
+ aggregateOperators:
109
+ op=(MAX_AGGR
110
+ |MIN_AGGR
111
+ |SUM
112
+ |COUNT
113
+ |AVG
114
+ |MEDIAN) LPAREN expression (groupingClause)? RPAREN #commonAggrOp
115
+ ;
116
+
117
+ groupingClause:
118
+ GROUP_BY keyNames (COMMA keyNames)*
119
+ ;
120
+
121
+ // Dimension management and members
122
+ itemSignature: ITEM_SIGNATURE;
123
+ itemReference: SQUARE_BRACKET_LEFT itemSignature SQUARE_BRACKET_RIGHT;
124
+
125
+ // Cell Address and table management
126
+ rowElem:
127
+ ROW
128
+ | ROW_RANGE
129
+ | ROW_ALL
130
+ ;
131
+ colElem:
132
+ COL
133
+ | COL_RANGE
134
+ | COL_ALL
135
+ ;
136
+ sheetElem:
137
+ SHEET
138
+ | SHEET_RANGE
139
+ | SHEET_ALL
140
+ ;
141
+ rowHandler:
142
+ rowElem
143
+ | LPAREN ROW (COMMA ROW)* RPAREN;
144
+
145
+ colHandler:
146
+ colElem
147
+ | LPAREN COL (COMMA COL)* RPAREN;
148
+
149
+ sheetHandler:
150
+ sheetElem
151
+ | LPAREN SHEET (COMMA SHEET)* RPAREN
152
+ ;
153
+
154
+ interval:
155
+ INTERVAL COLON BOOLEAN_LITERAL
156
+ ;
157
+
158
+ default:
159
+ DEFAULT COLON literal
160
+ | DEFAULT COLON NULL_LITERAL
161
+ ;
162
+
163
+ argument:
164
+ rowHandler #rowArg
165
+ | colHandler #colArg
166
+ | sheetHandler #sheetArg
167
+ | interval #intervalArg
168
+ | default #defaultArg
169
+ ;
170
+
171
+ select:
172
+ CURLY_BRACKET_LEFT selectOperand CURLY_BRACKET_RIGHT
173
+ ;
174
+
175
+ selectOperand:
176
+ cellRef
177
+ | varRef
178
+ | operationRef
179
+ | preconditionElem
180
+ ;
181
+
182
+ varID:
183
+ CURLY_BRACKET_LEFT varRef CURLY_BRACKET_RIGHT
184
+ ;
185
+
186
+ cellRef:
187
+ address=cellAddress
188
+ ;
189
+
190
+ preconditionElem:
191
+ PRECONDITION_ELEMENT
192
+ ;
193
+
194
+ varRef:
195
+ VAR_REFERENCE
196
+ ;
197
+
198
+ operationRef:
199
+ OPERATION_REFERENCE
200
+ ;
201
+
202
+ cellAddress:
203
+ tableReference (COMMA argument)* #tableRef
204
+ | argument (COMMA argument)* #compRef;
205
+
206
+ tableReference:
207
+ TABLE_REFERENCE
208
+ | TABLE_GROUP_REFERENCE
209
+ ;
210
+
211
+ clauseOperators:
212
+ WHERE expression #whereExpr
213
+ | GET keyNames #getExpr
214
+ | RENAME renameClause (COMMA renameClause)* #renameExpr
215
+ ;
216
+
217
+ // Always on grammar, not on tokens. Order is important (top ones should be the enclosing ones)
218
+
219
+ renameClause:
220
+ keyNames TO keyNames
221
+ ;
222
+
223
+ comparisonOperators:
224
+ EQ
225
+ |NE
226
+ |GT
227
+ |LT
228
+ |GE
229
+ |LE;
230
+
231
+ literal:
232
+ INTEGER_LITERAL
233
+ | DECIMAL_LITERAL
234
+ | PERCENT_LITERAL
235
+ | STRING_LITERAL
236
+ | BOOLEAN_LITERAL
237
+ | DATE_LITERAL
238
+ | TIME_INTERVAL_LITERAL
239
+ | TIME_PERIOD_LITERAL
240
+ | EMPTY_LITERAL
241
+ ;
242
+
243
+ keyNames:
244
+ ROW_COMPONENT
245
+ | COL_COMPONENT
246
+ | SHEET_COMPONENT
247
+ | PROPERTY_CODE
248
+ ;
249
+
250
+ propertyReference:
251
+ SQUARE_BRACKET_LEFT propertyCode SQUARE_BRACKET_RIGHT;
252
+
253
+ propertyCode:
254
+ PROPERTY_CODE
255
+ | CODE
256
+ ;
257
+
258
+ temporaryIdentifier:
259
+ CODE
260
+ ;