@opra/common 0.10.0 → 0.10.1
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.
- package/cjs/filter/antlr/OpraFilterLexer.js +225 -302
- package/cjs/filter/antlr/OpraFilterListener.js +11 -0
- package/cjs/filter/antlr/OpraFilterParser.js +1120 -721
- package/cjs/filter/antlr/OpraFilterVisitor.js +12 -1
- package/cjs/filter/ast/terms/date-literal.js +4 -3
- package/cjs/filter/filter-tree-visitor.js +31 -28
- package/cjs/filter/index.js +1 -1
- package/cjs/filter/opra-error-listener.js +15 -0
- package/cjs/filter/parse.js +11 -10
- package/cjs/i18n/i18n.js +13 -14
- package/cjs/schema/decorators/opr-collection-resource.decorator.js +3 -2
- package/cjs/schema/decorators/opr-complex-type.decorator.js +3 -2
- package/cjs/schema/decorators/opr-field.decorator.js +3 -2
- package/cjs/schema/decorators/opr-simple-type.decorator.js +3 -2
- package/cjs/schema/decorators/opr-singleton-resource.decorator.js +3 -2
- package/cjs/schema/implementation/data-type/union-type.js +3 -2
- package/cjs/schema/implementation/document-builder.js +4 -3
- package/cjs/schema/implementation/opra-document.js +3 -2
- package/esm/filter/antlr/OpraFilterLexer.d.ts +11 -12
- package/esm/filter/antlr/OpraFilterLexer.js +224 -299
- package/esm/filter/antlr/OpraFilterListener.d.ts +430 -0
- package/esm/filter/antlr/OpraFilterListener.js +8 -0
- package/esm/filter/antlr/OpraFilterParser.d.ts +183 -111
- package/esm/filter/antlr/OpraFilterParser.js +1052 -652
- package/esm/filter/antlr/OpraFilterVisitor.d.ts +77 -107
- package/esm/filter/antlr/OpraFilterVisitor.js +11 -2
- package/esm/filter/ast/terms/date-literal.js +4 -3
- package/esm/filter/errors.d.ts +4 -6
- package/esm/filter/filter-tree-visitor.d.ts +5 -3
- package/esm/filter/filter-tree-visitor.js +23 -21
- package/esm/filter/index.d.ts +1 -1
- package/esm/filter/index.js +1 -1
- package/esm/filter/opra-error-listener.d.ts +8 -0
- package/esm/filter/opra-error-listener.js +11 -0
- package/esm/filter/parse.d.ts +2 -2
- package/esm/filter/parse.js +8 -8
- package/esm/i18n/i18n.d.ts +1 -1
- package/esm/i18n/i18n.js +9 -10
- package/esm/schema/decorators/opr-collection-resource.decorator.js +1 -1
- package/esm/schema/decorators/opr-complex-type.decorator.js +1 -1
- package/esm/schema/decorators/opr-field.decorator.js +1 -1
- package/esm/schema/decorators/opr-simple-type.decorator.js +1 -1
- package/esm/schema/decorators/opr-singleton-resource.decorator.js +1 -1
- package/esm/schema/implementation/data-type/union-type.js +1 -1
- package/esm/schema/implementation/document-builder.js +3 -3
- package/esm/schema/implementation/opra-document.js +1 -1
- package/package.json +7 -7
- package/cjs/filter/error-listener.js +0 -13
- package/esm/filter/error-listener.d.ts +0 -8
- package/esm/filter/error-listener.js +0 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ParseTreeVisitor } from
|
|
2
|
-
import { ArithmeticExpressionContext, ArrayExpressionContext, ArthOpContext, BooleanContext, BooleanLiteralContext, ComparisonExpressionContext, CompOpContext, DateLiteralContext, DateTimeLiteralContext, DateTimePrecisionContext,
|
|
1
|
+
import { ParseTreeVisitor } from 'antlr4';
|
|
2
|
+
import { ArithmeticExpressionContext, ArrayExpressionContext, ArthOpContext, BooleanContext, BooleanLiteralContext, ComparisonExpressionContext, CompOpContext, DateLiteralContext, DateTimeLiteralContext, DateTimePrecisionContext, ExternalConstantContext, ExternalConstantTermContext, FunctionContext, IdentifierContext, InfinityContext, InfinityLiteralContext, InvocableContext, LiteralTermContext, LogicalExpressionContext, LogOpContext, MemberIndexContext, MemberInvocationContext, NullContext, NullLiteralContext, NumberIndexContext, NumberLiteralContext, ParamListContext, ParenthesizedExpressionContext, PluralDateTimePrecisionContext, PolarityExpressionContext, PolarOpContext, QualifiedIdentifierContext, QualifiedIdentifierTermContext, RootContext, StringLiteralContext, TermExpressionContext, TimeLiteralContext, UnitContext } from "./OpraFilterParser.js";
|
|
3
3
|
/**
|
|
4
4
|
* This interface defines a complete generic visitor for a parse tree produced
|
|
5
5
|
* by `OpraFilterParser`.
|
|
@@ -7,42 +7,13 @@ import { ArithmeticExpressionContext, ArrayExpressionContext, ArthOpContext, Boo
|
|
|
7
7
|
* @param <Result> The return type of the visit operation. Use `void` for
|
|
8
8
|
* operations with no return type.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export default class OpraFilterVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
11
11
|
/**
|
|
12
|
-
* Visit a parse tree produced by
|
|
13
|
-
* labeled alternative in `OpraFilterParser.expression`.
|
|
14
|
-
* @param ctx the parse tree
|
|
15
|
-
* @return the visitor result
|
|
16
|
-
*/
|
|
17
|
-
visitTermExpression?: (ctx: TermExpressionContext) => Result;
|
|
18
|
-
/**
|
|
19
|
-
* Visit a parse tree produced by the `polarityExpression`
|
|
20
|
-
* labeled alternative in `OpraFilterParser.expression`.
|
|
21
|
-
* @param ctx the parse tree
|
|
22
|
-
* @return the visitor result
|
|
23
|
-
*/
|
|
24
|
-
visitPolarityExpression?: (ctx: PolarityExpressionContext) => Result;
|
|
25
|
-
/**
|
|
26
|
-
* Visit a parse tree produced by the `arithmeticExpression`
|
|
27
|
-
* labeled alternative in `OpraFilterParser.expression`.
|
|
28
|
-
* @param ctx the parse tree
|
|
29
|
-
* @return the visitor result
|
|
30
|
-
*/
|
|
31
|
-
visitArithmeticExpression?: (ctx: ArithmeticExpressionContext) => Result;
|
|
32
|
-
/**
|
|
33
|
-
* Visit a parse tree produced by the `comparisonExpression`
|
|
34
|
-
* labeled alternative in `OpraFilterParser.expression`.
|
|
35
|
-
* @param ctx the parse tree
|
|
36
|
-
* @return the visitor result
|
|
37
|
-
*/
|
|
38
|
-
visitComparisonExpression?: (ctx: ComparisonExpressionContext) => Result;
|
|
39
|
-
/**
|
|
40
|
-
* Visit a parse tree produced by the `logicalExpression`
|
|
41
|
-
* labeled alternative in `OpraFilterParser.expression`.
|
|
12
|
+
* Visit a parse tree produced by `OpraFilterParser.root`.
|
|
42
13
|
* @param ctx the parse tree
|
|
43
14
|
* @return the visitor result
|
|
44
15
|
*/
|
|
45
|
-
|
|
16
|
+
visitRoot?: (ctx: RootContext) => Result;
|
|
46
17
|
/**
|
|
47
18
|
* Visit a parse tree produced by the `parenthesizedExpression`
|
|
48
19
|
* labeled alternative in `OpraFilterParser.expression`.
|
|
@@ -58,75 +29,67 @@ export interface OpraFilterVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
58
29
|
*/
|
|
59
30
|
visitArrayExpression?: (ctx: ArrayExpressionContext) => Result;
|
|
60
31
|
/**
|
|
61
|
-
* Visit a parse tree produced by the `
|
|
62
|
-
* labeled alternative in `OpraFilterParser.
|
|
63
|
-
* @param ctx the parse tree
|
|
64
|
-
* @return the visitor result
|
|
65
|
-
*/
|
|
66
|
-
visitMemberIndex?: (ctx: MemberIndexContext) => Result;
|
|
67
|
-
/**
|
|
68
|
-
* Visit a parse tree produced by the `numberIndex`
|
|
69
|
-
* labeled alternative in `OpraFilterParser.indexer`.
|
|
32
|
+
* Visit a parse tree produced by the `polarityExpression`
|
|
33
|
+
* labeled alternative in `OpraFilterParser.expression`.
|
|
70
34
|
* @param ctx the parse tree
|
|
71
35
|
* @return the visitor result
|
|
72
36
|
*/
|
|
73
|
-
|
|
37
|
+
visitPolarityExpression?: (ctx: PolarityExpressionContext) => Result;
|
|
74
38
|
/**
|
|
75
|
-
* Visit a parse tree produced by the `
|
|
76
|
-
* labeled alternative in `OpraFilterParser.
|
|
39
|
+
* Visit a parse tree produced by the `comparisonExpression`
|
|
40
|
+
* labeled alternative in `OpraFilterParser.expression`.
|
|
77
41
|
* @param ctx the parse tree
|
|
78
42
|
* @return the visitor result
|
|
79
43
|
*/
|
|
80
|
-
|
|
44
|
+
visitComparisonExpression?: (ctx: ComparisonExpressionContext) => Result;
|
|
81
45
|
/**
|
|
82
|
-
* Visit a parse tree produced by the `
|
|
83
|
-
* labeled alternative in `OpraFilterParser.
|
|
46
|
+
* Visit a parse tree produced by the `arithmeticExpression`
|
|
47
|
+
* labeled alternative in `OpraFilterParser.expression`.
|
|
84
48
|
* @param ctx the parse tree
|
|
85
49
|
* @return the visitor result
|
|
86
50
|
*/
|
|
87
|
-
|
|
51
|
+
visitArithmeticExpression?: (ctx: ArithmeticExpressionContext) => Result;
|
|
88
52
|
/**
|
|
89
|
-
* Visit a parse tree produced by the `
|
|
90
|
-
* labeled alternative in `OpraFilterParser.
|
|
53
|
+
* Visit a parse tree produced by the `logicalExpression`
|
|
54
|
+
* labeled alternative in `OpraFilterParser.expression`.
|
|
91
55
|
* @param ctx the parse tree
|
|
92
56
|
* @return the visitor result
|
|
93
57
|
*/
|
|
94
|
-
|
|
58
|
+
visitLogicalExpression?: (ctx: LogicalExpressionContext) => Result;
|
|
95
59
|
/**
|
|
96
|
-
* Visit a parse tree produced by the `
|
|
97
|
-
* labeled alternative in `OpraFilterParser.
|
|
60
|
+
* Visit a parse tree produced by the `termExpression`
|
|
61
|
+
* labeled alternative in `OpraFilterParser.expression`.
|
|
98
62
|
* @param ctx the parse tree
|
|
99
63
|
* @return the visitor result
|
|
100
64
|
*/
|
|
101
|
-
|
|
65
|
+
visitTermExpression?: (ctx: TermExpressionContext) => Result;
|
|
102
66
|
/**
|
|
103
|
-
* Visit a parse tree produced by the `
|
|
104
|
-
* labeled alternative in `OpraFilterParser.
|
|
67
|
+
* Visit a parse tree produced by the `literalTerm`
|
|
68
|
+
* labeled alternative in `OpraFilterParser.term`.
|
|
105
69
|
* @param ctx the parse tree
|
|
106
70
|
* @return the visitor result
|
|
107
71
|
*/
|
|
108
|
-
|
|
72
|
+
visitLiteralTerm?: (ctx: LiteralTermContext) => Result;
|
|
109
73
|
/**
|
|
110
|
-
* Visit a parse tree produced by the `
|
|
111
|
-
* labeled alternative in `OpraFilterParser.
|
|
74
|
+
* Visit a parse tree produced by the `qualifiedIdentifierTerm`
|
|
75
|
+
* labeled alternative in `OpraFilterParser.term`.
|
|
112
76
|
* @param ctx the parse tree
|
|
113
77
|
* @return the visitor result
|
|
114
78
|
*/
|
|
115
|
-
|
|
79
|
+
visitQualifiedIdentifierTerm?: (ctx: QualifiedIdentifierTermContext) => Result;
|
|
116
80
|
/**
|
|
117
|
-
* Visit a parse tree produced by the `
|
|
118
|
-
* labeled alternative in `OpraFilterParser.
|
|
81
|
+
* Visit a parse tree produced by the `externalConstantTerm`
|
|
82
|
+
* labeled alternative in `OpraFilterParser.term`.
|
|
119
83
|
* @param ctx the parse tree
|
|
120
84
|
* @return the visitor result
|
|
121
85
|
*/
|
|
122
|
-
|
|
86
|
+
visitExternalConstantTerm?: (ctx: ExternalConstantTermContext) => Result;
|
|
123
87
|
/**
|
|
124
|
-
* Visit a parse tree produced by
|
|
125
|
-
* labeled alternative in `OpraFilterParser.literal`.
|
|
88
|
+
* Visit a parse tree produced by `OpraFilterParser.invocable`.
|
|
126
89
|
* @param ctx the parse tree
|
|
127
90
|
* @return the visitor result
|
|
128
91
|
*/
|
|
129
|
-
|
|
92
|
+
visitInvocable?: (ctx: InvocableContext) => Result;
|
|
130
93
|
/**
|
|
131
94
|
* Visit a parse tree produced by the `memberInvocation`
|
|
132
95
|
* labeled alternative in `OpraFilterParser.invocation`.
|
|
@@ -135,116 +98,123 @@ export interface OpraFilterVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
135
98
|
*/
|
|
136
99
|
visitMemberInvocation?: (ctx: MemberInvocationContext) => Result;
|
|
137
100
|
/**
|
|
138
|
-
* Visit a parse tree produced by the `
|
|
139
|
-
* labeled alternative in `OpraFilterParser.
|
|
101
|
+
* Visit a parse tree produced by the `memberIndex`
|
|
102
|
+
* labeled alternative in `OpraFilterParser.indexer`.
|
|
140
103
|
* @param ctx the parse tree
|
|
141
104
|
* @return the visitor result
|
|
142
105
|
*/
|
|
143
|
-
|
|
106
|
+
visitMemberIndex?: (ctx: MemberIndexContext) => Result;
|
|
144
107
|
/**
|
|
145
|
-
* Visit a parse tree produced by the `
|
|
146
|
-
* labeled alternative in `OpraFilterParser.
|
|
108
|
+
* Visit a parse tree produced by the `numberIndex`
|
|
109
|
+
* labeled alternative in `OpraFilterParser.indexer`.
|
|
147
110
|
* @param ctx the parse tree
|
|
148
111
|
* @return the visitor result
|
|
149
112
|
*/
|
|
150
|
-
|
|
113
|
+
visitNumberIndex?: (ctx: NumberIndexContext) => Result;
|
|
151
114
|
/**
|
|
152
|
-
* Visit a parse tree produced by
|
|
153
|
-
* labeled alternative in `OpraFilterParser.term`.
|
|
115
|
+
* Visit a parse tree produced by `OpraFilterParser.function`.
|
|
154
116
|
* @param ctx the parse tree
|
|
155
117
|
* @return the visitor result
|
|
156
118
|
*/
|
|
157
|
-
|
|
119
|
+
visitFunction?: (ctx: FunctionContext) => Result;
|
|
158
120
|
/**
|
|
159
|
-
* Visit a parse tree produced by `OpraFilterParser.
|
|
121
|
+
* Visit a parse tree produced by `OpraFilterParser.paramList`.
|
|
160
122
|
* @param ctx the parse tree
|
|
161
123
|
* @return the visitor result
|
|
162
124
|
*/
|
|
163
|
-
|
|
125
|
+
visitParamList?: (ctx: ParamListContext) => Result;
|
|
164
126
|
/**
|
|
165
|
-
* Visit a parse tree produced by `OpraFilterParser.
|
|
127
|
+
* Visit a parse tree produced by `OpraFilterParser.unit`.
|
|
166
128
|
* @param ctx the parse tree
|
|
167
129
|
* @return the visitor result
|
|
168
130
|
*/
|
|
169
|
-
|
|
131
|
+
visitUnit?: (ctx: UnitContext) => Result;
|
|
170
132
|
/**
|
|
171
|
-
* Visit a parse tree produced by `OpraFilterParser.
|
|
133
|
+
* Visit a parse tree produced by `OpraFilterParser.dateTimePrecision`.
|
|
172
134
|
* @param ctx the parse tree
|
|
173
135
|
* @return the visitor result
|
|
174
136
|
*/
|
|
175
|
-
|
|
137
|
+
visitDateTimePrecision?: (ctx: DateTimePrecisionContext) => Result;
|
|
176
138
|
/**
|
|
177
|
-
* Visit a parse tree produced by `OpraFilterParser.
|
|
139
|
+
* Visit a parse tree produced by `OpraFilterParser.pluralDateTimePrecision`.
|
|
178
140
|
* @param ctx the parse tree
|
|
179
141
|
* @return the visitor result
|
|
180
142
|
*/
|
|
181
|
-
|
|
143
|
+
visitPluralDateTimePrecision?: (ctx: PluralDateTimePrecisionContext) => Result;
|
|
182
144
|
/**
|
|
183
|
-
* Visit a parse tree produced by `OpraFilterParser.
|
|
145
|
+
* Visit a parse tree produced by `OpraFilterParser.qualifiedIdentifier`.
|
|
184
146
|
* @param ctx the parse tree
|
|
185
147
|
* @return the visitor result
|
|
186
148
|
*/
|
|
187
|
-
|
|
149
|
+
visitQualifiedIdentifier?: (ctx: QualifiedIdentifierContext) => Result;
|
|
188
150
|
/**
|
|
189
|
-
* Visit a parse tree produced by `OpraFilterParser.
|
|
151
|
+
* Visit a parse tree produced by `OpraFilterParser.externalConstant`.
|
|
190
152
|
* @param ctx the parse tree
|
|
191
153
|
* @return the visitor result
|
|
192
154
|
*/
|
|
193
|
-
|
|
155
|
+
visitExternalConstant?: (ctx: ExternalConstantContext) => Result;
|
|
194
156
|
/**
|
|
195
|
-
* Visit a parse tree produced by `OpraFilterParser.
|
|
157
|
+
* Visit a parse tree produced by `OpraFilterParser.identifier`.
|
|
196
158
|
* @param ctx the parse tree
|
|
197
159
|
* @return the visitor result
|
|
198
160
|
*/
|
|
199
|
-
|
|
161
|
+
visitIdentifier?: (ctx: IdentifierContext) => Result;
|
|
200
162
|
/**
|
|
201
|
-
* Visit a parse tree produced by `
|
|
163
|
+
* Visit a parse tree produced by the `numberLiteral`
|
|
164
|
+
* labeled alternative in `OpraFilterParser.literal`.
|
|
202
165
|
* @param ctx the parse tree
|
|
203
166
|
* @return the visitor result
|
|
204
167
|
*/
|
|
205
|
-
|
|
168
|
+
visitNumberLiteral?: (ctx: NumberLiteralContext) => Result;
|
|
206
169
|
/**
|
|
207
|
-
* Visit a parse tree produced by `
|
|
170
|
+
* Visit a parse tree produced by the `infinityLiteral`
|
|
171
|
+
* labeled alternative in `OpraFilterParser.literal`.
|
|
208
172
|
* @param ctx the parse tree
|
|
209
173
|
* @return the visitor result
|
|
210
174
|
*/
|
|
211
|
-
|
|
175
|
+
visitInfinityLiteral?: (ctx: InfinityLiteralContext) => Result;
|
|
212
176
|
/**
|
|
213
|
-
* Visit a parse tree produced by `
|
|
177
|
+
* Visit a parse tree produced by the `booleanLiteral`
|
|
178
|
+
* labeled alternative in `OpraFilterParser.literal`.
|
|
214
179
|
* @param ctx the parse tree
|
|
215
180
|
* @return the visitor result
|
|
216
181
|
*/
|
|
217
|
-
|
|
182
|
+
visitBooleanLiteral?: (ctx: BooleanLiteralContext) => Result;
|
|
218
183
|
/**
|
|
219
|
-
* Visit a parse tree produced by `
|
|
184
|
+
* Visit a parse tree produced by the `nullLiteral`
|
|
185
|
+
* labeled alternative in `OpraFilterParser.literal`.
|
|
220
186
|
* @param ctx the parse tree
|
|
221
187
|
* @return the visitor result
|
|
222
188
|
*/
|
|
223
|
-
|
|
189
|
+
visitNullLiteral?: (ctx: NullLiteralContext) => Result;
|
|
224
190
|
/**
|
|
225
|
-
* Visit a parse tree produced by `
|
|
191
|
+
* Visit a parse tree produced by the `dateLiteral`
|
|
192
|
+
* labeled alternative in `OpraFilterParser.literal`.
|
|
226
193
|
* @param ctx the parse tree
|
|
227
194
|
* @return the visitor result
|
|
228
195
|
*/
|
|
229
|
-
|
|
196
|
+
visitDateLiteral?: (ctx: DateLiteralContext) => Result;
|
|
230
197
|
/**
|
|
231
|
-
* Visit a parse tree produced by `
|
|
198
|
+
* Visit a parse tree produced by the `dateTimeLiteral`
|
|
199
|
+
* labeled alternative in `OpraFilterParser.literal`.
|
|
232
200
|
* @param ctx the parse tree
|
|
233
201
|
* @return the visitor result
|
|
234
202
|
*/
|
|
235
|
-
|
|
203
|
+
visitDateTimeLiteral?: (ctx: DateTimeLiteralContext) => Result;
|
|
236
204
|
/**
|
|
237
|
-
* Visit a parse tree produced by `
|
|
205
|
+
* Visit a parse tree produced by the `timeLiteral`
|
|
206
|
+
* labeled alternative in `OpraFilterParser.literal`.
|
|
238
207
|
* @param ctx the parse tree
|
|
239
208
|
* @return the visitor result
|
|
240
209
|
*/
|
|
241
|
-
|
|
210
|
+
visitTimeLiteral?: (ctx: TimeLiteralContext) => Result;
|
|
242
211
|
/**
|
|
243
|
-
* Visit a parse tree produced by `
|
|
212
|
+
* Visit a parse tree produced by the `stringLiteral`
|
|
213
|
+
* labeled alternative in `OpraFilterParser.literal`.
|
|
244
214
|
* @param ctx the parse tree
|
|
245
215
|
* @return the visitor result
|
|
246
216
|
*/
|
|
247
|
-
|
|
217
|
+
visitStringLiteral?: (ctx: StringLiteralContext) => Result;
|
|
248
218
|
/**
|
|
249
219
|
* Visit a parse tree produced by `OpraFilterParser.compOp`.
|
|
250
220
|
* @param ctx the parse tree
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
// Generated from
|
|
2
|
-
|
|
1
|
+
// Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.11.2-SNAPSHOT
|
|
2
|
+
import { ParseTreeVisitor } from 'antlr4';
|
|
3
|
+
/**
|
|
4
|
+
* This interface defines a complete generic visitor for a parse tree produced
|
|
5
|
+
* by `OpraFilterParser`.
|
|
6
|
+
*
|
|
7
|
+
* @param <Result> The return type of the visit operation. Use `void` for
|
|
8
|
+
* operations with no return type.
|
|
9
|
+
*/
|
|
10
|
+
export default class OpraFilterVisitor extends ParseTreeVisitor {
|
|
11
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toDateDef } from 'putil-varhelpers';
|
|
2
2
|
import { ValidationError } from '../../errors.js';
|
|
3
3
|
import { quoteFilterString } from '../../utils.js';
|
|
4
4
|
import { Literal } from '../abstract/literal.js';
|
|
5
|
-
const DATE_PATTERN = /^(\d{4})-(0[1-9]|1[012])-([123]0|[012][1-9]|31)/;
|
|
5
|
+
// const DATE_PATTERN = /^(\d{4})-(0[1-9]|1[012])-([123]0|[012][1-9]|31)/;
|
|
6
|
+
const NullDate = new Date(0);
|
|
6
7
|
export class DateLiteral extends Literal {
|
|
7
8
|
constructor(value) {
|
|
8
9
|
super('');
|
|
@@ -11,7 +12,7 @@ export class DateLiteral extends Literal {
|
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
14
|
// noinspection SuspiciousTypeOfGuard
|
|
14
|
-
if (typeof value === 'string' &&
|
|
15
|
+
if (typeof value === 'string' && toDateDef(value, NullDate) !== NullDate) {
|
|
15
16
|
this.value = value;
|
|
16
17
|
return;
|
|
17
18
|
}
|
package/esm/filter/errors.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RecognitionException } from 'antlr4';
|
|
2
|
+
import { Recognizer } from 'antlr4/src/antlr4/Recognizer';
|
|
3
3
|
export declare class SyntaxError extends TypeError {
|
|
4
4
|
}
|
|
5
5
|
export declare class ValidationError extends TypeError {
|
|
6
6
|
}
|
|
7
7
|
export declare class FilterParseError extends Error {
|
|
8
|
-
recognizer: Recognizer<any
|
|
8
|
+
recognizer: Recognizer<any>;
|
|
9
9
|
offendingSymbol: any | undefined;
|
|
10
10
|
line: number;
|
|
11
|
-
charPositionInLine: number;
|
|
12
11
|
e: RecognitionException | undefined;
|
|
13
12
|
constructor(message: string, args: {
|
|
14
|
-
recognizer: Recognizer<any
|
|
13
|
+
recognizer: Recognizer<any>;
|
|
15
14
|
offendingSymbol: any | undefined;
|
|
16
15
|
line: number;
|
|
17
|
-
charPositionInLine: number;
|
|
18
16
|
e: RecognitionException | undefined;
|
|
19
17
|
});
|
|
20
18
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ParseTreeVisitor as TParseTreeVisitor } from 'antlr4';
|
|
2
2
|
import { ArithmeticExpressionContext, ArrayExpressionContext, BooleanLiteralContext, ComparisonExpressionContext, DateLiteralContext, DateTimeLiteralContext, ExternalConstantTermContext, IdentifierContext, LogicalExpressionContext, NumberLiteralContext, ParenthesizedExpressionContext, PolarityExpressionContext, QualifiedIdentifierTermContext, RootContext, StringLiteralContext, TimeLiteralContext } from './antlr/OpraFilterParser.js';
|
|
3
|
-
import
|
|
3
|
+
import OpraFilterVisitor from './antlr/OpraFilterVisitor.js';
|
|
4
4
|
import { ArithmeticExpression, ArrayExpression, BooleanLiteral, DateLiteral, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, StringLiteral, TimeLiteral } from './ast/index.js';
|
|
5
5
|
import { ExternalConstant } from './ast/terms/external-constant.js';
|
|
6
|
-
|
|
6
|
+
declare const ParseTreeVisitor: typeof TParseTreeVisitor;
|
|
7
|
+
export declare class FilterTreeVisitor extends ParseTreeVisitor<any> implements OpraFilterVisitor<any> {
|
|
7
8
|
private _timeZone?;
|
|
8
9
|
constructor(options?: {
|
|
9
10
|
timeZone?: string;
|
|
@@ -28,3 +29,4 @@ export declare class FilterTreeVisitor extends AbstractParseTreeVisitor<any> imp
|
|
|
28
29
|
visitLogicalExpression(ctx: LogicalExpressionContext): LogicalExpression;
|
|
29
30
|
visitArithmeticExpression(ctx: ArithmeticExpressionContext): ArithmeticExpression;
|
|
30
31
|
}
|
|
32
|
+
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import antlr4 from 'antlr4';
|
|
2
2
|
import { ArithmeticExpressionContext, LogicalExpressionContext, } from './antlr/OpraFilterParser.js';
|
|
3
3
|
import { ArithmeticExpression, ArrayExpression, BooleanLiteral, ComparisonExpression, DateLiteral, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, StringLiteral, TimeLiteral } from './ast/index.js';
|
|
4
4
|
import { ExternalConstant } from './ast/terms/external-constant.js';
|
|
5
5
|
import { SyntaxError } from './errors.js';
|
|
6
6
|
import { unquoteFilterString } from './utils.js';
|
|
7
|
-
|
|
7
|
+
// Fix: antlr4 d.ts files is invalid
|
|
8
|
+
const ParseTreeVisitor = antlr4.tree.ParseTreeVisitor;
|
|
9
|
+
export class FilterTreeVisitor extends ParseTreeVisitor {
|
|
8
10
|
constructor(options) {
|
|
9
11
|
super();
|
|
10
12
|
this._timeZone = options?.timeZone;
|
|
@@ -16,57 +18,57 @@ export class FilterTreeVisitor extends AbstractParseTreeVisitor {
|
|
|
16
18
|
return this.visit(ctx.expression());
|
|
17
19
|
}
|
|
18
20
|
visitIdentifier(ctx) {
|
|
19
|
-
return ctx.
|
|
21
|
+
return ctx.getText();
|
|
20
22
|
}
|
|
21
23
|
visitNullLiteral() {
|
|
22
24
|
return new NullLiteral();
|
|
23
25
|
}
|
|
24
26
|
visitBooleanLiteral(ctx) {
|
|
25
|
-
return new BooleanLiteral(ctx.
|
|
27
|
+
return new BooleanLiteral(ctx.getText() === 'true');
|
|
26
28
|
}
|
|
27
29
|
visitNumberLiteral(ctx) {
|
|
28
|
-
return new NumberLiteral(ctx.
|
|
30
|
+
return new NumberLiteral(ctx.getText());
|
|
29
31
|
}
|
|
30
32
|
visitStringLiteral(ctx) {
|
|
31
|
-
return new StringLiteral(unquoteFilterString(ctx.
|
|
33
|
+
return new StringLiteral(unquoteFilterString(ctx.getText()));
|
|
32
34
|
}
|
|
33
35
|
visitInfinityLiteral() {
|
|
34
36
|
return new NumberLiteral(Infinity);
|
|
35
37
|
}
|
|
36
38
|
visitDateLiteral(ctx) {
|
|
37
|
-
return new DateLiteral(unquoteFilterString(ctx.
|
|
39
|
+
return new DateLiteral(unquoteFilterString(ctx.getText()));
|
|
38
40
|
}
|
|
39
41
|
visitDateTimeLiteral(ctx) {
|
|
40
|
-
return new DateLiteral(unquoteFilterString(ctx.
|
|
42
|
+
return new DateLiteral(unquoteFilterString(ctx.getText()));
|
|
41
43
|
}
|
|
42
44
|
visitTimeLiteral(ctx) {
|
|
43
|
-
return new TimeLiteral(unquoteFilterString(ctx.
|
|
45
|
+
return new TimeLiteral(unquoteFilterString(ctx.getText()));
|
|
44
46
|
}
|
|
45
47
|
visitQualifiedIdentifierTerm(ctx) {
|
|
46
|
-
return new QualifiedIdentifier(ctx.
|
|
48
|
+
return new QualifiedIdentifier(ctx.getText());
|
|
47
49
|
}
|
|
48
50
|
visitPolarityExpression(ctx) {
|
|
49
51
|
const x = this.visit(ctx.expression());
|
|
50
52
|
if (x.kind === 'NumberLiteral') {
|
|
51
|
-
if (ctx.polarOp().
|
|
53
|
+
if (ctx.polarOp().getText() === '-')
|
|
52
54
|
x.value *= -1;
|
|
53
55
|
return x;
|
|
54
56
|
}
|
|
55
|
-
throw new SyntaxError('Unexpected token "' + ctx.
|
|
57
|
+
throw new SyntaxError('Unexpected token "' + ctx.getText() + '"');
|
|
56
58
|
}
|
|
57
59
|
visitExternalConstantTerm(ctx) {
|
|
58
|
-
return new ExternalConstant(ctx.externalConstant().
|
|
60
|
+
return new ExternalConstant(ctx.externalConstant().getText().substring(1));
|
|
59
61
|
}
|
|
60
62
|
visitParenthesizedExpression(ctx) {
|
|
61
63
|
const expression = this.visit(ctx.expression());
|
|
62
64
|
return new ParenthesesExpression(expression);
|
|
63
65
|
}
|
|
64
66
|
visitArrayExpression(ctx) {
|
|
65
|
-
return new ArrayExpression(ctx.
|
|
67
|
+
return new ArrayExpression(ctx.expression_list().map(child => this.visit(child)));
|
|
66
68
|
}
|
|
67
69
|
visitComparisonExpression(ctx) {
|
|
68
70
|
return new ComparisonExpression({
|
|
69
|
-
op: ctx.compOp().
|
|
71
|
+
op: ctx.compOp().getText(),
|
|
70
72
|
left: this.visit(ctx.expression(0)),
|
|
71
73
|
right: this.visit(ctx.expression(1))
|
|
72
74
|
});
|
|
@@ -75,17 +77,17 @@ export class FilterTreeVisitor extends AbstractParseTreeVisitor {
|
|
|
75
77
|
const items = [];
|
|
76
78
|
const wrapChildren = (arr, op) => {
|
|
77
79
|
for (const c of arr) {
|
|
78
|
-
if (c instanceof LogicalExpressionContext && c.logOp().
|
|
79
|
-
wrapChildren(c.
|
|
80
|
+
if (c instanceof LogicalExpressionContext && c.logOp().getText() === op) {
|
|
81
|
+
wrapChildren(c.expression_list(), c.logOp().getText());
|
|
80
82
|
continue;
|
|
81
83
|
}
|
|
82
84
|
const o = this.visit(c);
|
|
83
85
|
items.push(o);
|
|
84
86
|
}
|
|
85
87
|
};
|
|
86
|
-
wrapChildren(ctx.
|
|
88
|
+
wrapChildren(ctx.expression_list(), ctx.logOp().getText());
|
|
87
89
|
return new LogicalExpression({
|
|
88
|
-
op: ctx.logOp().
|
|
90
|
+
op: ctx.logOp().getText(),
|
|
89
91
|
items
|
|
90
92
|
});
|
|
91
93
|
}
|
|
@@ -95,14 +97,14 @@ export class FilterTreeVisitor extends AbstractParseTreeVisitor {
|
|
|
95
97
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
96
98
|
const child = children[i];
|
|
97
99
|
if (child instanceof ArithmeticExpressionContext) {
|
|
98
|
-
wrapChildren(child.
|
|
100
|
+
wrapChildren(child.expression_list(), child.arthOp().getText());
|
|
99
101
|
continue;
|
|
100
102
|
}
|
|
101
103
|
const value = this.visit(child);
|
|
102
104
|
exp.append(op || '+', value);
|
|
103
105
|
}
|
|
104
106
|
};
|
|
105
|
-
wrapChildren(ctx.
|
|
107
|
+
wrapChildren(ctx.expression_list(), ctx.arthOp().getText());
|
|
106
108
|
return exp;
|
|
107
109
|
}
|
|
108
110
|
}
|
package/esm/filter/index.d.ts
CHANGED
package/esm/filter/index.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ErrorListener, RecognitionException } from 'antlr4';
|
|
2
|
+
import { Recognizer } from 'antlr4/src/antlr4/Recognizer';
|
|
3
|
+
import { FilterParseError } from './errors.js';
|
|
4
|
+
export declare class OpraErrorListener extends ErrorListener<any> {
|
|
5
|
+
errors: FilterParseError[];
|
|
6
|
+
constructor(errors: FilterParseError[]);
|
|
7
|
+
syntaxError(recognizer: Recognizer<any>, offendingSymbol: any, line: number, column: number, msg: string, e: RecognitionException): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ErrorListener } from 'antlr4';
|
|
2
|
+
import { FilterParseError } from './errors.js';
|
|
3
|
+
export class OpraErrorListener extends ErrorListener {
|
|
4
|
+
constructor(errors) {
|
|
5
|
+
super();
|
|
6
|
+
this.errors = errors;
|
|
7
|
+
}
|
|
8
|
+
syntaxError(recognizer, offendingSymbol, line, column, msg, e) {
|
|
9
|
+
this.errors.push(new FilterParseError(msg, { recognizer, offendingSymbol, line, e }));
|
|
10
|
+
}
|
|
11
|
+
}
|
package/esm/filter/parse.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function parseFilter(text: string, visitor?:
|
|
1
|
+
import type { ParseTreeVisitor } from 'antlr4';
|
|
2
|
+
export declare function parseFilter(text: string, visitor?: ParseTreeVisitor<any>): any;
|
package/esm/filter/parse.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { ErrorListener } from './error-listener.js';
|
|
1
|
+
import { CharStream, CommonTokenStream } from 'antlr4';
|
|
2
|
+
import OpraFilterLexer from './antlr/OpraFilterLexer.js';
|
|
3
|
+
import OpraFilterParser from './antlr/OpraFilterParser.js';
|
|
5
4
|
import { SyntaxError } from './errors.js';
|
|
6
5
|
import { FilterTreeVisitor } from './filter-tree-visitor.js';
|
|
6
|
+
import { OpraErrorListener } from './opra-error-listener.js';
|
|
7
7
|
export function parseFilter(text, visitor) {
|
|
8
|
-
const
|
|
9
|
-
const lexer = new OpraFilterLexer(
|
|
8
|
+
const chars = new CharStream(text);
|
|
9
|
+
const lexer = new OpraFilterLexer(chars);
|
|
10
10
|
const tokenStream = new CommonTokenStream(lexer);
|
|
11
11
|
const parser = new OpraFilterParser(tokenStream);
|
|
12
|
-
parser.
|
|
12
|
+
parser.buildParseTrees = true;
|
|
13
13
|
const errors = [];
|
|
14
|
-
const errorListener = new
|
|
14
|
+
const errorListener = new OpraErrorListener(errors);
|
|
15
15
|
lexer.removeErrorListeners();
|
|
16
16
|
lexer.addErrorListener(errorListener);
|
|
17
17
|
parser.removeErrorListeners();
|
package/esm/i18n/i18n.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare type InitCallback = I18next.Callback;
|
|
|
10
10
|
export declare type TranslateFunction = I18nextTFunction;
|
|
11
11
|
export declare type Formatter = I18nextFormatter;
|
|
12
12
|
export declare type LanguageResource = I18nextResource;
|
|
13
|
-
export { FallbackLng };
|
|
13
|
+
export type { FallbackLng };
|
|
14
14
|
export interface InitOptions extends I18nextInitOptions {
|
|
15
15
|
resourceDirs?: string[];
|
|
16
16
|
}
|