@malloydata/malloy-filter 0.0.350 → 0.0.351
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/README.md +3 -3
- package/dist/clause_utils.d.ts +7 -62
- package/dist/clause_utils.js +0 -14
- package/dist/clause_utils.js.map +1 -1
- package/dist/filter_interface.d.ts +5 -5
- package/dist/filter_interface.js +13 -5
- package/dist/filter_interface.js.map +1 -1
- package/dist/lib/fexpr_number_parser.d.ts +9 -26
- package/dist/lib/fexpr_number_parser.js +1476 -83
- package/dist/lib/fexpr_number_parser.js.map +1 -1
- package/dist/lib/fexpr_string_parser.d.ts +9 -26
- package/dist/lib/fexpr_string_parser.js +709 -50
- package/dist/lib/fexpr_string_parser.js.map +1 -1
- package/dist/lib/ftemporal_parser.d.ts +9 -26
- package/dist/lib/ftemporal_parser.js +4095 -163
- package/dist/lib/ftemporal_parser.js.map +1 -1
- package/dist/number_filter_expression.js +3 -41
- package/dist/number_filter_expression.js.map +1 -1
- package/dist/{nearley_parse.d.ts → peggy_parse.d.ts} +1 -2
- package/dist/peggy_parse.js +40 -0
- package/dist/peggy_parse.js.map +1 -0
- package/dist/string_filter_expression.js +3 -46
- package/dist/string_filter_expression.js.map +1 -1
- package/dist/temporal_filter_expression.js +3 -41
- package/dist/temporal_filter_expression.js.map +1 -1
- package/femto-config.motly +19 -0
- package/package.json +9 -11
- package/src/clause_utils.ts +9 -23
- package/src/filter_interface.ts +14 -8
- package/src/grammars/fexpr_number.peggy +46 -0
- package/src/grammars/fexpr_string.peggy +32 -0
- package/src/grammars/ftemporal.peggy +112 -0
- package/src/lib/fexpr_number_parser.js +1411 -0
- package/src/lib/fexpr_string_parser.js +740 -0
- package/src/lib/ftemporal_parser.js +3641 -0
- package/src/number_filter_expression.ts +3 -7
- package/src/peggy_parse.ts +50 -0
- package/src/string_filter_expression.ts +3 -12
- package/src/temporal_filter_expression.ts +3 -7
- package/tsconfig.json +3 -2
- package/dist/nearley_parse.js +0 -51
- package/dist/nearley_parse.js.map +0 -1
- package/src/lib/fexpr_number_parser.ts +0 -126
- package/src/lib/fexpr_string_parser.ts +0 -84
- package/src/lib/ftemporal_parser.ts +0 -246
- package/src/nearley_parse.ts +0 -53
|
@@ -7,19 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
import type {FilterParserResponse, NumberFilter} from './filter_interface';
|
|
9
9
|
import {isNumberFilter} from './filter_interface';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {run_parser} from './nearley_parse';
|
|
10
|
+
import {parse as peggyNumberParser} from './lib/fexpr_number_parser';
|
|
11
|
+
import {run_parser} from './peggy_parse';
|
|
13
12
|
|
|
14
13
|
export const NumberFilterExpression = {
|
|
15
14
|
parse(src: string): FilterParserResponse<NumberFilter> {
|
|
16
15
|
if (src.match(/^\s*$/)) {
|
|
17
16
|
return {parsed: null, log: []};
|
|
18
17
|
}
|
|
19
|
-
const
|
|
20
|
-
nearley.Grammar.fromCompiled(fnumber_grammar)
|
|
21
|
-
);
|
|
22
|
-
const parse_result = run_parser(src, fnumber_parser);
|
|
18
|
+
const parse_result = run_parser(src, peggyNumberParser);
|
|
23
19
|
if (parse_result.parsed && isNumberFilter(parse_result.parsed)) {
|
|
24
20
|
return {parsed: parse_result.parsed, log: []};
|
|
25
21
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Contributors to the Malloy project
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {FilterExpression, FilterLog} from './filter_interface';
|
|
7
|
+
import {isFilterExpression} from './filter_interface';
|
|
8
|
+
|
|
9
|
+
interface PeggySyntaxError {
|
|
10
|
+
message: string;
|
|
11
|
+
location?: {
|
|
12
|
+
start: {offset: number; column: number};
|
|
13
|
+
end: {offset: number; column: number};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function isPeggySyntaxError(e: unknown): e is PeggySyntaxError {
|
|
18
|
+
return e instanceof Error && 'location' in e;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function run_parser(
|
|
22
|
+
src: string,
|
|
23
|
+
parse: (input: string) => unknown
|
|
24
|
+
): {parsed: FilterExpression | null; log: FilterLog[]} {
|
|
25
|
+
try {
|
|
26
|
+
const expr = parse(src);
|
|
27
|
+
if (isFilterExpression(expr)) {
|
|
28
|
+
return {parsed: expr, log: []};
|
|
29
|
+
}
|
|
30
|
+
return {parsed: null, log: []};
|
|
31
|
+
} catch (e) {
|
|
32
|
+
if (isPeggySyntaxError(e)) {
|
|
33
|
+
const loc = e.location;
|
|
34
|
+
const startIndex = loc ? loc.start.offset : 0;
|
|
35
|
+
const endIndex = loc ? loc.end.offset - 1 : src.length - 1;
|
|
36
|
+
return {
|
|
37
|
+
parsed: null,
|
|
38
|
+
log: [
|
|
39
|
+
{
|
|
40
|
+
message: e.message,
|
|
41
|
+
startIndex,
|
|
42
|
+
endIndex: Math.max(startIndex, endIndex),
|
|
43
|
+
severity: 'error',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -7,25 +7,16 @@
|
|
|
7
7
|
|
|
8
8
|
import type {FilterParserResponse, StringFilter} from './filter_interface';
|
|
9
9
|
import {isStringFilter} from './filter_interface';
|
|
10
|
-
import
|
|
11
|
-
import fstring_grammar from './lib/fexpr_string_parser';
|
|
10
|
+
import {parse as peggyStringParser} from './lib/fexpr_string_parser';
|
|
12
11
|
import {escape} from './clause_utils';
|
|
13
|
-
import {run_parser} from './
|
|
12
|
+
import {run_parser} from './peggy_parse';
|
|
14
13
|
|
|
15
|
-
// This could be mistake, I am replacing the hand coded lexer and parsers
|
|
16
|
-
// which previously existed with nearley/moo -- As the language is still
|
|
17
|
-
// in flux, it is much easier for me to maintain the code if the parser
|
|
18
|
-
// is not hand coded. Full apologies to the original author of the hand
|
|
19
|
-
// coded parsers.
|
|
20
14
|
export const StringFilterExpression = {
|
|
21
15
|
parse(src: string): FilterParserResponse<StringFilter> {
|
|
22
16
|
if (src.match(/^\s*$/)) {
|
|
23
17
|
return {parsed: null, log: []};
|
|
24
18
|
}
|
|
25
|
-
const
|
|
26
|
-
nearley.Grammar.fromCompiled(fstring_grammar)
|
|
27
|
-
);
|
|
28
|
-
const parse_result = run_parser(src, fstring_parser);
|
|
19
|
+
const parse_result = run_parser(src, peggyStringParser);
|
|
29
20
|
if (parse_result.parsed && isStringFilter(parse_result.parsed)) {
|
|
30
21
|
return {parsed: parse_result.parsed, log: []};
|
|
31
22
|
}
|
|
@@ -12,19 +12,15 @@ import type {
|
|
|
12
12
|
Duration,
|
|
13
13
|
} from './filter_interface';
|
|
14
14
|
import {isTemporalFilter} from './filter_interface';
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import {run_parser} from './nearley_parse';
|
|
15
|
+
import {parse as peggyTemporalParser} from './lib/ftemporal_parser';
|
|
16
|
+
import {run_parser} from './peggy_parse';
|
|
18
17
|
|
|
19
18
|
export const TemporalFilterExpression = {
|
|
20
19
|
parse(src: string): FilterParserResponse<TemporalFilter> {
|
|
21
20
|
if (src.match(/^\s*$/)) {
|
|
22
21
|
return {parsed: null, log: []};
|
|
23
22
|
}
|
|
24
|
-
const
|
|
25
|
-
nearley.Grammar.fromCompiled(ftemporal_grammar)
|
|
26
|
-
);
|
|
27
|
-
const parse_result = run_parser(src, ftemporal_parser);
|
|
23
|
+
const parse_result = run_parser(src, peggyTemporalParser);
|
|
28
24
|
if (parse_result.parsed && isTemporalFilter(parse_result.parsed)) {
|
|
29
25
|
return {parsed: parse_result.parsed, log: []};
|
|
30
26
|
}
|
package/tsconfig.json
CHANGED
package/dist/nearley_parse.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.run_parser = run_parser;
|
|
10
|
-
const filter_interface_1 = require("./filter_interface");
|
|
11
|
-
function run_parser(src, parser) {
|
|
12
|
-
try {
|
|
13
|
-
parser.feed(src);
|
|
14
|
-
const results = parser.finish();
|
|
15
|
-
const expr = results[0];
|
|
16
|
-
if ((0, filter_interface_1.isFilterExpression)(expr)) {
|
|
17
|
-
return { parsed: expr, log: [] };
|
|
18
|
-
}
|
|
19
|
-
return { parsed: null, log: [] };
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
let newMessage = e.message;
|
|
23
|
-
let col = 1;
|
|
24
|
-
let len = src.length;
|
|
25
|
-
if (e.token) {
|
|
26
|
-
const token = e.token;
|
|
27
|
-
col = token.col;
|
|
28
|
-
len = token.text.length;
|
|
29
|
-
const message = e.message;
|
|
30
|
-
const expected = message
|
|
31
|
-
.match(/(?<=A ).*(?= based on:)/g)
|
|
32
|
-
.map(s => s.replace(/\s+token/i, ''));
|
|
33
|
-
newMessage = `Unexpected ${token.type} token "${token.value}"`;
|
|
34
|
-
if (expected && expected.length) {
|
|
35
|
-
newMessage += ` Tokens expected: ${[...new Set(expected)]}`;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
parsed: null,
|
|
40
|
-
log: [
|
|
41
|
-
{
|
|
42
|
-
message: newMessage,
|
|
43
|
-
startIndex: col - 1,
|
|
44
|
-
endIndex: col - 1 + len - 1,
|
|
45
|
-
severity: 'error',
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=nearley_parse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nearley_parse.js","sourceRoot":"","sources":["../src/nearley_parse.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAMH,gCAyCC;AA3CD,yDAAsD;AAEtD,SAAgB,UAAU,CACxB,GAAW,EACX,MAAc;IAEd,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,IAAA,qCAAkB,EAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAC,CAAC;QACjC,CAAC;QACD,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAC,CAAC;IACjC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,UAAU,GAAG,CAAC,CAAC,OAAO,CAAC;QAC3B,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;QACrB,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;YACZ,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;YACtB,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;YAChB,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YACxB,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC;YAC1B,MAAM,QAAQ,GAAG,OAAO;iBACrB,KAAK,CAAC,0BAA0B,CAAC;iBACjC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;YACxC,UAAU,GAAG,cAAc,KAAK,CAAC,IAAI,WAAW,KAAK,CAAC,KAAK,GAAG,CAAC;YAC/D,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAChC,UAAU,IAAI,qBAAqB,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YAC9D,CAAC;QACH,CAAC;QACD,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,GAAG,EAAE;gBACH;oBACE,OAAO,EAAE,UAAU;oBACnB,UAAU,EAAE,GAAG,GAAG,CAAC;oBACnB,QAAQ,EAAE,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;oBAC3B,QAAQ,EAAE,OAAO;iBAClB;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// Generated automatically by nearley, version 2.20.1
|
|
2
|
-
// http://github.com/Hardmath123/nearley
|
|
3
|
-
// Bypasses TS6133. Allow declared but unused functions.
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
function id(d: any[]): any { return d[0]; }
|
|
6
|
-
declare var NOT: any;
|
|
7
|
-
declare var NULL_KW: any;
|
|
8
|
-
declare var eq: any;
|
|
9
|
-
declare var ne: any;
|
|
10
|
-
declare var op: any;
|
|
11
|
-
declare var oparen: any;
|
|
12
|
-
declare var cparen: any;
|
|
13
|
-
declare var TO: any;
|
|
14
|
-
declare var comma: any;
|
|
15
|
-
declare var cbrack: any;
|
|
16
|
-
declare var obrack: any;
|
|
17
|
-
declare var float: any;
|
|
18
|
-
declare var numberE: any;
|
|
19
|
-
declare var integer: any;
|
|
20
|
-
declare var OR: any;
|
|
21
|
-
declare var AND: any;
|
|
22
|
-
|
|
23
|
-
import moo from 'moo';
|
|
24
|
-
import {numNot, mkRange, joinNumbers, mkValues} from '../clause_utils';
|
|
25
|
-
|
|
26
|
-
const kwList = moo.keywords({
|
|
27
|
-
'AND': 'and',
|
|
28
|
-
'OR': 'or',
|
|
29
|
-
'NOT': 'not',
|
|
30
|
-
'NULL_KW': 'null',
|
|
31
|
-
'TO': 'to',
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const fnumber_lexer = moo.compile({
|
|
35
|
-
WS: /[ \t]+/,
|
|
36
|
-
id: {
|
|
37
|
-
match: /[a-zA-Z]+/,
|
|
38
|
-
type: kw => kwList(kw.toLowerCase()),
|
|
39
|
-
},
|
|
40
|
-
oparen: '(',
|
|
41
|
-
cparen: ')',
|
|
42
|
-
obrack: '[',
|
|
43
|
-
cbrack: ']',
|
|
44
|
-
comma: ',',
|
|
45
|
-
op: /<=|>=|<|>/,
|
|
46
|
-
ne: '!=',
|
|
47
|
-
eq: '=',
|
|
48
|
-
float: /-?(?:\d+)?\.\d+(?:[Ee][+-]?\d+)?/,
|
|
49
|
-
numberE: /-?\d+[Ee][+-]?\d+/,
|
|
50
|
-
integer: /-?\d+/,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const actual_next = fnumber_lexer.next;
|
|
54
|
-
fnumber_lexer.next = (next => () => {
|
|
55
|
-
for (;;) {
|
|
56
|
-
const token = next.call(fnumber_lexer);
|
|
57
|
-
if (token === undefined || token.type !== 'WS') {
|
|
58
|
-
return token;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
})(actual_next);
|
|
62
|
-
|
|
63
|
-
interface NearleyToken {
|
|
64
|
-
value: any;
|
|
65
|
-
[key: string]: any;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
interface NearleyLexer {
|
|
69
|
-
reset: (chunk: string, info: any) => void;
|
|
70
|
-
next: () => NearleyToken | undefined;
|
|
71
|
-
save: () => any;
|
|
72
|
-
formatError: (token: never) => string;
|
|
73
|
-
has: (tokenType: string) => boolean;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
interface NearleyRule {
|
|
77
|
-
name: string;
|
|
78
|
-
symbols: NearleySymbol[];
|
|
79
|
-
postprocess?: (d: any[], loc?: number, reject?: {}) => any;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
type NearleySymbol = string | { literal: any } | { test: (token: any) => boolean };
|
|
83
|
-
|
|
84
|
-
interface Grammar {
|
|
85
|
-
Lexer: NearleyLexer | undefined;
|
|
86
|
-
ParserRules: NearleyRule[];
|
|
87
|
-
ParserStart: string;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const grammar: Grammar = {
|
|
91
|
-
Lexer: fnumber_lexer,
|
|
92
|
-
ParserRules: [
|
|
93
|
-
{"name": "numberFilter", "symbols": ["numberFilter", "conjunction", "numberUnary"], "postprocess": ([left, cop, right]) => joinNumbers(left, cop[0].text, right)},
|
|
94
|
-
{"name": "numberFilter", "symbols": ["numberUnary"], "postprocess": (data) => data[0]},
|
|
95
|
-
{"name": "numberUnary$ebnf$1", "symbols": [(fnumber_lexer.has("NOT") ? {type: "NOT"} : NOT)], "postprocess": id},
|
|
96
|
-
{"name": "numberUnary$ebnf$1", "symbols": [], "postprocess": () => null},
|
|
97
|
-
{"name": "numberUnary", "symbols": ["numberUnary$ebnf$1", "clause"], "postprocess": ([notToken, clause]) => numNot(clause, notToken)},
|
|
98
|
-
{"name": "clause", "symbols": [(fnumber_lexer.has("NULL_KW") ? {type: "NULL_KW"} : NULL_KW)], "postprocess": () => ({operator: 'null' })},
|
|
99
|
-
{"name": "clause$ebnf$1", "symbols": []},
|
|
100
|
-
{"name": "clause$ebnf$1", "symbols": ["clause$ebnf$1", "numberList"], "postprocess": (d) => d[0].concat([d[1]])},
|
|
101
|
-
{"name": "clause", "symbols": ["N", "clause$ebnf$1"], "postprocess": ([n, nList]) => ({operator: '=', ...mkValues(n, nList)})},
|
|
102
|
-
{"name": "clause$ebnf$2", "symbols": []},
|
|
103
|
-
{"name": "clause$ebnf$2", "symbols": ["clause$ebnf$2", "numberList"], "postprocess": (d) => d[0].concat([d[1]])},
|
|
104
|
-
{"name": "clause", "symbols": [(fnumber_lexer.has("eq") ? {type: "eq"} : eq), "N", "clause$ebnf$2"], "postprocess": ([_, n, nList]) => ({operator: '=', ...mkValues(n, nList)})},
|
|
105
|
-
{"name": "clause$ebnf$3", "symbols": []},
|
|
106
|
-
{"name": "clause$ebnf$3", "symbols": ["clause$ebnf$3", "numberList"], "postprocess": (d) => d[0].concat([d[1]])},
|
|
107
|
-
{"name": "clause", "symbols": [(fnumber_lexer.has("ne") ? {type: "ne"} : ne), "N", "clause$ebnf$3"], "postprocess": ([_, n, nList]) => ({operator: '!=', ...mkValues(n, nList)})},
|
|
108
|
-
{"name": "clause", "symbols": [(fnumber_lexer.has("op") ? {type: "op"} : op), "N"], "postprocess": ([op, n]) => ({operator: op.text, values: [n]})},
|
|
109
|
-
{"name": "clause", "symbols": [(fnumber_lexer.has("oparen") ? {type: "oparen"} : oparen), "numberFilter", (fnumber_lexer.has("cparen") ? {type: "cparen"} : cparen)], "postprocess": ([_1, subFilter, _3]) => ({operator: "()", expr: subFilter})},
|
|
110
|
-
{"name": "clause", "symbols": ["openInterval", "N", (fnumber_lexer.has("TO") ? {type: "TO"} : TO), "N", "closeInterval"], "postprocess": ([l, b, _to, e, r]) => mkRange(l[0].text,b,e,r[0].text)},
|
|
111
|
-
{"name": "numberList", "symbols": [(fnumber_lexer.has("comma") ? {type: "comma"} : comma), "N"], "postprocess": ([_, n]) => n},
|
|
112
|
-
{"name": "closeInterval", "symbols": [(fnumber_lexer.has("cbrack") ? {type: "cbrack"} : cbrack)]},
|
|
113
|
-
{"name": "closeInterval", "symbols": [(fnumber_lexer.has("cparen") ? {type: "cparen"} : cparen)]},
|
|
114
|
-
{"name": "openInterval", "symbols": [(fnumber_lexer.has("obrack") ? {type: "obrack"} : obrack)]},
|
|
115
|
-
{"name": "openInterval", "symbols": [(fnumber_lexer.has("oparen") ? {type: "oparen"} : oparen)]},
|
|
116
|
-
{"name": "N$subexpression$1", "symbols": [(fnumber_lexer.has("float") ? {type: "float"} : float)]},
|
|
117
|
-
{"name": "N$subexpression$1", "symbols": [(fnumber_lexer.has("numberE") ? {type: "numberE"} : numberE)]},
|
|
118
|
-
{"name": "N$subexpression$1", "symbols": [(fnumber_lexer.has("integer") ? {type: "integer"} : integer)]},
|
|
119
|
-
{"name": "N", "symbols": ["N$subexpression$1"], "postprocess": ([nMatch]) => nMatch[0].text},
|
|
120
|
-
{"name": "conjunction", "symbols": [(fnumber_lexer.has("OR") ? {type: "OR"} : OR)]},
|
|
121
|
-
{"name": "conjunction", "symbols": [(fnumber_lexer.has("AND") ? {type: "AND"} : AND)]}
|
|
122
|
-
],
|
|
123
|
-
ParserStart: "numberFilter",
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export default grammar;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// Generated automatically by nearley, version 2.20.1
|
|
2
|
-
// http://github.com/Hardmath123/nearley
|
|
3
|
-
// Bypasses TS6133. Allow declared but unused functions.
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
function id(d: any[]): any { return d[0]; }
|
|
6
|
-
declare var minus: any;
|
|
7
|
-
declare var open: any;
|
|
8
|
-
declare var close: any;
|
|
9
|
-
declare var matchStr: any;
|
|
10
|
-
declare var comma: any;
|
|
11
|
-
declare var semi: any;
|
|
12
|
-
declare var or: any;
|
|
13
|
-
|
|
14
|
-
import moo from 'moo';
|
|
15
|
-
import {conjoin, maybeNot, matchOp} from '../clause_utils';
|
|
16
|
-
|
|
17
|
-
const fstring_lexer = moo.compile({
|
|
18
|
-
WS: /[ \t]+/,
|
|
19
|
-
comma: ',',
|
|
20
|
-
semi: ';',
|
|
21
|
-
or: '|',
|
|
22
|
-
open: '(',
|
|
23
|
-
close: ')',
|
|
24
|
-
minus: '-',
|
|
25
|
-
matchStr: /(?:\\[^\n]|[^\n,;()|])+/,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const actual_next = fstring_lexer.next;
|
|
29
|
-
fstring_lexer.next = (next => () => {
|
|
30
|
-
for (;;) {
|
|
31
|
-
const token = next.call(fstring_lexer);
|
|
32
|
-
if (token == undefined || token.type !== 'WS') {
|
|
33
|
-
return token;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
})(actual_next);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
interface NearleyToken {
|
|
40
|
-
value: any;
|
|
41
|
-
[key: string]: any;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
interface NearleyLexer {
|
|
45
|
-
reset: (chunk: string, info: any) => void;
|
|
46
|
-
next: () => NearleyToken | undefined;
|
|
47
|
-
save: () => any;
|
|
48
|
-
formatError: (token: never) => string;
|
|
49
|
-
has: (tokenType: string) => boolean;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
interface NearleyRule {
|
|
53
|
-
name: string;
|
|
54
|
-
symbols: NearleySymbol[];
|
|
55
|
-
postprocess?: (d: any[], loc?: number, reject?: {}) => any;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
type NearleySymbol = string | { literal: any } | { test: (token: any) => boolean };
|
|
59
|
-
|
|
60
|
-
interface Grammar {
|
|
61
|
-
Lexer: NearleyLexer | undefined;
|
|
62
|
-
ParserRules: NearleyRule[];
|
|
63
|
-
ParserStart: string;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const grammar: Grammar = {
|
|
67
|
-
Lexer: fstring_lexer,
|
|
68
|
-
ParserRules: [
|
|
69
|
-
{"name": "stringFilter", "symbols": ["stringFilter", "conjunction", "sfUnary"], "postprocess": ([left, cop, right]) => conjoin(left, cop[0].text, right)},
|
|
70
|
-
{"name": "stringFilter", "symbols": ["sfUnary"], "postprocess": (data) => data[0]},
|
|
71
|
-
{"name": "sfUnary$ebnf$1", "symbols": [(fstring_lexer.has("minus") ? {type: "minus"} : minus)], "postprocess": id},
|
|
72
|
-
{"name": "sfUnary$ebnf$1", "symbols": [], "postprocess": () => null},
|
|
73
|
-
{"name": "sfUnary", "symbols": ["sfUnary$ebnf$1", "clause"], "postprocess": (data) => maybeNot(data)},
|
|
74
|
-
{"name": "parens", "symbols": [(fstring_lexer.has("open") ? {type: "open"} : open), "stringFilter", (fstring_lexer.has("close") ? {type: "close"} : close)], "postprocess": ([_1, subFilter, _3]) => ({operator: "()", expr: subFilter})},
|
|
75
|
-
{"name": "clause", "symbols": [(fstring_lexer.has("matchStr") ? {type: "matchStr"} : matchStr)], "postprocess": ([withStr]) => matchOp(withStr.text)},
|
|
76
|
-
{"name": "clause", "symbols": ["parens"], "postprocess": (data) => data[0]},
|
|
77
|
-
{"name": "conjunction", "symbols": [(fstring_lexer.has("comma") ? {type: "comma"} : comma)]},
|
|
78
|
-
{"name": "conjunction", "symbols": [(fstring_lexer.has("semi") ? {type: "semi"} : semi)]},
|
|
79
|
-
{"name": "conjunction", "symbols": [(fstring_lexer.has("or") ? {type: "or"} : or)]}
|
|
80
|
-
],
|
|
81
|
-
ParserStart: "stringFilter",
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default grammar;
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
// Generated automatically by nearley, version 2.20.1
|
|
2
|
-
// http://github.com/Hardmath123/nearley
|
|
3
|
-
// Bypasses TS6133. Allow declared but unused functions.
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
function id(d: any[]): any { return d[0]; }
|
|
6
|
-
declare var NOT: any;
|
|
7
|
-
declare var n: any;
|
|
8
|
-
declare var lityear: any;
|
|
9
|
-
declare var SECOND: any;
|
|
10
|
-
declare var MINUTE: any;
|
|
11
|
-
declare var HOUR: any;
|
|
12
|
-
declare var DAY: any;
|
|
13
|
-
declare var WEEK: any;
|
|
14
|
-
declare var MONTH: any;
|
|
15
|
-
declare var QUARTER: any;
|
|
16
|
-
declare var YEAR: any;
|
|
17
|
-
declare var SECONDS: any;
|
|
18
|
-
declare var MINUTES: any;
|
|
19
|
-
declare var HOURS: any;
|
|
20
|
-
declare var DAYS: any;
|
|
21
|
-
declare var WEEKS: any;
|
|
22
|
-
declare var MONTHS: any;
|
|
23
|
-
declare var QUARTERS: any;
|
|
24
|
-
declare var YEARS: any;
|
|
25
|
-
declare var NULL_KW: any;
|
|
26
|
-
declare var BEFORE: any;
|
|
27
|
-
declare var STARTING: any;
|
|
28
|
-
declare var AFTER: any;
|
|
29
|
-
declare var THROUGH: any;
|
|
30
|
-
declare var TO: any;
|
|
31
|
-
declare var FOR: any;
|
|
32
|
-
declare var LAST: any;
|
|
33
|
-
declare var NEXT: any;
|
|
34
|
-
declare var THIS: any;
|
|
35
|
-
declare var NOW: any;
|
|
36
|
-
declare var TODAY: any;
|
|
37
|
-
declare var YESTERDAY: any;
|
|
38
|
-
declare var TOMORROW: any;
|
|
39
|
-
declare var AGO: any;
|
|
40
|
-
declare var FROM: any;
|
|
41
|
-
declare var literal: any;
|
|
42
|
-
declare var lit_day: any;
|
|
43
|
-
declare var lit_min: any;
|
|
44
|
-
declare var lit_hour: any;
|
|
45
|
-
declare var lit_month: any;
|
|
46
|
-
declare var lit_quarter: any;
|
|
47
|
-
declare var lit_week: any;
|
|
48
|
-
declare var lit_year: any;
|
|
49
|
-
declare var MONDAY: any;
|
|
50
|
-
declare var TUESDAY: any;
|
|
51
|
-
declare var WEDNESDAY: any;
|
|
52
|
-
declare var THURSDAY: any;
|
|
53
|
-
declare var FRIDAY: any;
|
|
54
|
-
declare var SATURDAY: any;
|
|
55
|
-
declare var SUNDAY: any;
|
|
56
|
-
declare var oparen: any;
|
|
57
|
-
declare var cparen: any;
|
|
58
|
-
declare var OR: any;
|
|
59
|
-
declare var AND: any;
|
|
60
|
-
|
|
61
|
-
import moo from 'moo';
|
|
62
|
-
import {temporalNot, joinTemporal, timeLiteral, mkUnits} from '../clause_utils';
|
|
63
|
-
|
|
64
|
-
const kwList = moo.keywords(
|
|
65
|
-
{
|
|
66
|
-
'AND': 'and',
|
|
67
|
-
'OR': 'or',
|
|
68
|
-
'NOT': 'not',
|
|
69
|
-
'NULL_KW': 'null',
|
|
70
|
-
'TO': 'to',
|
|
71
|
-
'NOW': 'now',
|
|
72
|
-
'LAST': 'last',
|
|
73
|
-
'THIS': 'this',
|
|
74
|
-
'NEXT': 'next',
|
|
75
|
-
'AGO': 'ago',
|
|
76
|
-
'FROM': 'from',
|
|
77
|
-
'BEFORE': 'before',
|
|
78
|
-
'AFTER': 'after',
|
|
79
|
-
'THROUGH': 'through',
|
|
80
|
-
'STARTING': 'starting',
|
|
81
|
-
'FOR': 'for',
|
|
82
|
-
'TODAY': 'today',
|
|
83
|
-
'YESTERDAY': 'yesterday',
|
|
84
|
-
'TOMORROW': 'tomorrow',
|
|
85
|
-
'SECOND': 'second',
|
|
86
|
-
'MINUTE': 'minute',
|
|
87
|
-
'HOUR': 'hour',
|
|
88
|
-
'DAY': 'day',
|
|
89
|
-
'WEEK': 'week',
|
|
90
|
-
'MONTH': 'month',
|
|
91
|
-
'QUARTER': 'quarter',
|
|
92
|
-
'YEAR': 'year',
|
|
93
|
-
'SECONDS': 'seconds',
|
|
94
|
-
'MINUTES': 'minutes',
|
|
95
|
-
'HOURS': 'hours',
|
|
96
|
-
'DAYS': 'days',
|
|
97
|
-
'WEEKS': 'weeks',
|
|
98
|
-
'MONTHS': 'months',
|
|
99
|
-
'QUARTERS': 'quarters',
|
|
100
|
-
'YEARS': 'years',
|
|
101
|
-
'MONDAY': 'monday',
|
|
102
|
-
'TUESDAY': 'tuesday',
|
|
103
|
-
'WEDNESDAY': 'wednesday',
|
|
104
|
-
'THURSDAY': 'thursday',
|
|
105
|
-
'FRIDAY': 'friday',
|
|
106
|
-
'SATURDAY': 'saturday',
|
|
107
|
-
'SUNDAY': 'sunday',
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
const temporal_lexer = moo.compile({
|
|
112
|
-
WS: /[ \t]+/,
|
|
113
|
-
id: {
|
|
114
|
-
match: /[a-zA-Z]+/,
|
|
115
|
-
type: kw => kwList(kw.toLowerCase()),
|
|
116
|
-
},
|
|
117
|
-
oparen: '(',
|
|
118
|
-
cparen: ')',
|
|
119
|
-
comma: ',',
|
|
120
|
-
literal: /\d\d\d\d-\d\d-\d\d[ Tt]\d\d:\d\d(?::\d\d(?:[.,]\d*)?)/,
|
|
121
|
-
lit_week: /\d\d\d\d-\d\d-\d\d-[Ww][Kk]/,
|
|
122
|
-
lit_quarter: /\d\d\d\d-[qQ][1234]/,
|
|
123
|
-
lit_min: /\d\d\d\d-\d\d-\d\d[ Tt]\d\d:\d\d/,
|
|
124
|
-
lit_hour: /\d\d\d\d-\d\d-\d\d[ Tt]\d\d/,
|
|
125
|
-
lit_day: /\d\d\d\d-\d\d-\d\d/,
|
|
126
|
-
lit_month: /\d\d\d\d-\d\d/,
|
|
127
|
-
lit_year: /\d\d\d\d/,
|
|
128
|
-
n: /\d+/,
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
const actual_next = temporal_lexer.next;
|
|
132
|
-
temporal_lexer.next = (next => () => {
|
|
133
|
-
for (;;) {
|
|
134
|
-
const token = next.call(temporal_lexer);
|
|
135
|
-
if (token === undefined || token.type !== 'WS') {
|
|
136
|
-
return token;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
})(actual_next);
|
|
140
|
-
|
|
141
|
-
interface NearleyToken {
|
|
142
|
-
value: any;
|
|
143
|
-
[key: string]: any;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
interface NearleyLexer {
|
|
147
|
-
reset: (chunk: string, info: any) => void;
|
|
148
|
-
next: () => NearleyToken | undefined;
|
|
149
|
-
save: () => any;
|
|
150
|
-
formatError: (token: never) => string;
|
|
151
|
-
has: (tokenType: string) => boolean;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
interface NearleyRule {
|
|
155
|
-
name: string;
|
|
156
|
-
symbols: NearleySymbol[];
|
|
157
|
-
postprocess?: (d: any[], loc?: number, reject?: {}) => any;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
type NearleySymbol = string | { literal: any } | { test: (token: any) => boolean };
|
|
161
|
-
|
|
162
|
-
interface Grammar {
|
|
163
|
-
Lexer: NearleyLexer | undefined;
|
|
164
|
-
ParserRules: NearleyRule[];
|
|
165
|
-
ParserStart: string;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const grammar: Grammar = {
|
|
169
|
-
Lexer: temporal_lexer,
|
|
170
|
-
ParserRules: [
|
|
171
|
-
{"name": "temporalFilter", "symbols": ["temporalFilter", "conjunction", "temporalUnary"], "postprocess": ([left, cop, right]) => joinTemporal(left, cop[0].text, right)},
|
|
172
|
-
{"name": "temporalFilter", "symbols": ["temporalUnary"], "postprocess": (data) => data[0]},
|
|
173
|
-
{"name": "temporalUnary$ebnf$1", "symbols": [(temporal_lexer.has("NOT") ? {type: "NOT"} : NOT)], "postprocess": id},
|
|
174
|
-
{"name": "temporalUnary$ebnf$1", "symbols": [], "postprocess": () => null},
|
|
175
|
-
{"name": "temporalUnary", "symbols": ["temporalUnary$ebnf$1", "clause"], "postprocess": ([notToken, op]) => temporalNot(op, notToken)},
|
|
176
|
-
{"name": "duration", "symbols": ["number", "unit"], "postprocess": ([n, units]) => ({units, n})},
|
|
177
|
-
{"name": "number", "symbols": [(temporal_lexer.has("n") ? {type: "n"} : n)], "postprocess": ([numToken]) => numToken.text},
|
|
178
|
-
{"name": "number", "symbols": [(temporal_lexer.has("lityear") ? {type: "lityear"} : lityear)], "postprocess": ([yearToken]) => yearToken.text},
|
|
179
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("SECOND") ? {type: "SECOND"} : SECOND)]},
|
|
180
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("MINUTE") ? {type: "MINUTE"} : MINUTE)]},
|
|
181
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("HOUR") ? {type: "HOUR"} : HOUR)]},
|
|
182
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("DAY") ? {type: "DAY"} : DAY)]},
|
|
183
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("WEEK") ? {type: "WEEK"} : WEEK)]},
|
|
184
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("MONTH") ? {type: "MONTH"} : MONTH)]},
|
|
185
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("QUARTER") ? {type: "QUARTER"} : QUARTER)]},
|
|
186
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("YEAR") ? {type: "YEAR"} : YEAR)]},
|
|
187
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("SECONDS") ? {type: "SECONDS"} : SECONDS)]},
|
|
188
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("MINUTES") ? {type: "MINUTES"} : MINUTES)]},
|
|
189
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("HOURS") ? {type: "HOURS"} : HOURS)]},
|
|
190
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("DAYS") ? {type: "DAYS"} : DAYS)]},
|
|
191
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("WEEKS") ? {type: "WEEKS"} : WEEKS)]},
|
|
192
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("MONTHS") ? {type: "MONTHS"} : MONTHS)]},
|
|
193
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("QUARTERS") ? {type: "QUARTERS"} : QUARTERS)]},
|
|
194
|
-
{"name": "unit$subexpression$1", "symbols": [(temporal_lexer.has("YEARS") ? {type: "YEARS"} : YEARS)]},
|
|
195
|
-
{"name": "unit", "symbols": ["unit$subexpression$1"], "postprocess": ([unitToken]) => mkUnits(unitToken[0].text)},
|
|
196
|
-
{"name": "clause", "symbols": [(temporal_lexer.has("NULL_KW") ? {type: "NULL_KW"} : NULL_KW)], "postprocess": () => ({operator: 'null' })},
|
|
197
|
-
{"name": "clause", "symbols": ["parens"], "postprocess": (data) => data[0]},
|
|
198
|
-
{"name": "clause", "symbols": ["duration"], "postprocess": ([duration]) => ({operator: 'in_last', ...duration})},
|
|
199
|
-
{"name": "clause", "symbols": [(temporal_lexer.has("BEFORE") ? {type: "BEFORE"} : BEFORE), "moment"], "postprocess": ([_, moment]) => ({operator: 'before', before: moment })},
|
|
200
|
-
{"name": "clause", "symbols": [(temporal_lexer.has("STARTING") ? {type: "STARTING"} : STARTING), "moment"], "postprocess": ([_, moment]) => ({operator: 'before', before: moment, not: true})},
|
|
201
|
-
{"name": "clause", "symbols": [(temporal_lexer.has("AFTER") ? {type: "AFTER"} : AFTER), "moment"], "postprocess": ([_, moment]) => ({operator: 'after', after: moment })},
|
|
202
|
-
{"name": "clause", "symbols": [(temporal_lexer.has("THROUGH") ? {type: "THROUGH"} : THROUGH), "moment"], "postprocess": ([_, moment]) => ({operator: 'after', after: moment, not: true})},
|
|
203
|
-
{"name": "clause", "symbols": ["moment", (temporal_lexer.has("TO") ? {type: "TO"} : TO), "moment"], "postprocess": ([fromMoment, _, toMoment]) => ({operator: 'to', fromMoment, toMoment})},
|
|
204
|
-
{"name": "clause", "symbols": ["moment", (temporal_lexer.has("FOR") ? {type: "FOR"} : FOR), "duration"], "postprocess": ([moment, _, duration]) => ({...duration, operator: 'for', begin: moment})},
|
|
205
|
-
{"name": "clause$subexpression$1", "symbols": [(temporal_lexer.has("LAST") ? {type: "LAST"} : LAST)]},
|
|
206
|
-
{"name": "clause$subexpression$1", "symbols": [(temporal_lexer.has("NEXT") ? {type: "NEXT"} : NEXT)]},
|
|
207
|
-
{"name": "clause", "symbols": ["clause$subexpression$1", "duration"], "postprocess": ([op, duration]) => ({operator: op[0].text, ...duration})},
|
|
208
|
-
{"name": "clause", "symbols": ["moment"], "postprocess": ([moment]) => ({operator: 'in', in: moment})},
|
|
209
|
-
{"name": "lastNextThis", "symbols": [(temporal_lexer.has("THIS") ? {type: "THIS"} : THIS)], "postprocess": ([token]) => token.text.toLowerCase()},
|
|
210
|
-
{"name": "lastNextThis", "symbols": [(temporal_lexer.has("NEXT") ? {type: "NEXT"} : NEXT)], "postprocess": ([token]) => token.text.toLowerCase()},
|
|
211
|
-
{"name": "lastNextThis", "symbols": [(temporal_lexer.has("LAST") ? {type: "LAST"} : LAST)], "postprocess": ([token]) => token.text.toLowerCase()},
|
|
212
|
-
{"name": "moment", "symbols": [(temporal_lexer.has("NOW") ? {type: "NOW"} : NOW)], "postprocess": () => ({moment: 'now'})},
|
|
213
|
-
{"name": "moment", "symbols": ["lastNextThis", "unit"], "postprocess": ([moment, units]) => ({moment, units})},
|
|
214
|
-
{"name": "moment", "symbols": [(temporal_lexer.has("TODAY") ? {type: "TODAY"} : TODAY)], "postprocess": () => ({moment: 'today'})},
|
|
215
|
-
{"name": "moment", "symbols": [(temporal_lexer.has("YESTERDAY") ? {type: "YESTERDAY"} : YESTERDAY)], "postprocess": () => ({moment: 'yesterday'})},
|
|
216
|
-
{"name": "moment", "symbols": [(temporal_lexer.has("TOMORROW") ? {type: "TOMORROW"} : TOMORROW)], "postprocess": () => ({moment: 'tomorrow'})},
|
|
217
|
-
{"name": "moment", "symbols": ["duration", (temporal_lexer.has("AGO") ? {type: "AGO"} : AGO)], "postprocess": ([duration, _]) => ({moment: 'ago', ...duration})},
|
|
218
|
-
{"name": "moment", "symbols": ["duration", (temporal_lexer.has("FROM") ? {type: "FROM"} : FROM), (temporal_lexer.has("NOW") ? {type: "NOW"} : NOW)], "postprocess": ([duration, _]) => ({moment: 'from_now', ...duration})},
|
|
219
|
-
{"name": "moment", "symbols": [(temporal_lexer.has("NEXT") ? {type: "NEXT"} : NEXT), "weekday"], "postprocess": ([_, dn]) => ({moment: dn.toLowerCase(), which: 'next'})},
|
|
220
|
-
{"name": "moment", "symbols": [(temporal_lexer.has("LAST") ? {type: "LAST"} : LAST), "weekday"], "postprocess": ([_, dn]) => ({moment: dn.toLowerCase(), which: 'last'})},
|
|
221
|
-
{"name": "moment", "symbols": ["weekday"], "postprocess": ([dn]) => ({moment: dn.toLowerCase(), which: 'last'})},
|
|
222
|
-
{"name": "moment", "symbols": ["timeLiteral"], "postprocess": d => d[0]},
|
|
223
|
-
{"name": "timeLiteral", "symbols": [(temporal_lexer.has("literal") ? {type: "literal"} : literal)], "postprocess": ([l]) => timeLiteral(l.text)},
|
|
224
|
-
{"name": "timeLiteral", "symbols": [(temporal_lexer.has("lit_day") ? {type: "lit_day"} : lit_day)], "postprocess": ([l]) => timeLiteral(l.text, 'day')},
|
|
225
|
-
{"name": "timeLiteral", "symbols": [(temporal_lexer.has("lit_min") ? {type: "lit_min"} : lit_min)], "postprocess": ([l]) => timeLiteral(l.text, 'minute')},
|
|
226
|
-
{"name": "timeLiteral", "symbols": [(temporal_lexer.has("lit_hour") ? {type: "lit_hour"} : lit_hour)], "postprocess": ([l]) => timeLiteral(l.text, 'hour')},
|
|
227
|
-
{"name": "timeLiteral", "symbols": [(temporal_lexer.has("lit_month") ? {type: "lit_month"} : lit_month)], "postprocess": ([l]) => timeLiteral(l.text, 'month')},
|
|
228
|
-
{"name": "timeLiteral", "symbols": [(temporal_lexer.has("lit_quarter") ? {type: "lit_quarter"} : lit_quarter)], "postprocess": ([l]) => timeLiteral(l.text, 'quarter')},
|
|
229
|
-
{"name": "timeLiteral", "symbols": [(temporal_lexer.has("lit_week") ? {type: "lit_week"} : lit_week)], "postprocess": ([l]) => timeLiteral(l.text, 'week')},
|
|
230
|
-
{"name": "timeLiteral", "symbols": [(temporal_lexer.has("lit_year") ? {type: "lit_year"} : lit_year)], "postprocess": ([l]) => timeLiteral(l.text, 'year')},
|
|
231
|
-
{"name": "weekday$subexpression$1", "symbols": [(temporal_lexer.has("MONDAY") ? {type: "MONDAY"} : MONDAY)]},
|
|
232
|
-
{"name": "weekday$subexpression$1", "symbols": [(temporal_lexer.has("TUESDAY") ? {type: "TUESDAY"} : TUESDAY)]},
|
|
233
|
-
{"name": "weekday$subexpression$1", "symbols": [(temporal_lexer.has("WEDNESDAY") ? {type: "WEDNESDAY"} : WEDNESDAY)]},
|
|
234
|
-
{"name": "weekday$subexpression$1", "symbols": [(temporal_lexer.has("THURSDAY") ? {type: "THURSDAY"} : THURSDAY)]},
|
|
235
|
-
{"name": "weekday$subexpression$1", "symbols": [(temporal_lexer.has("FRIDAY") ? {type: "FRIDAY"} : FRIDAY)]},
|
|
236
|
-
{"name": "weekday$subexpression$1", "symbols": [(temporal_lexer.has("SATURDAY") ? {type: "SATURDAY"} : SATURDAY)]},
|
|
237
|
-
{"name": "weekday$subexpression$1", "symbols": [(temporal_lexer.has("SUNDAY") ? {type: "SUNDAY"} : SUNDAY)]},
|
|
238
|
-
{"name": "weekday", "symbols": ["weekday$subexpression$1"], "postprocess": ([dayToken]) => dayToken[0].text},
|
|
239
|
-
{"name": "parens", "symbols": [(temporal_lexer.has("oparen") ? {type: "oparen"} : oparen), "temporalFilter", (temporal_lexer.has("cparen") ? {type: "cparen"} : cparen)], "postprocess": ([_1, subFilter, _3]) => ({operator: "()", expr: subFilter})},
|
|
240
|
-
{"name": "conjunction", "symbols": [(temporal_lexer.has("OR") ? {type: "OR"} : OR)]},
|
|
241
|
-
{"name": "conjunction", "symbols": [(temporal_lexer.has("AND") ? {type: "AND"} : AND)]}
|
|
242
|
-
],
|
|
243
|
-
ParserStart: "temporalFilter",
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
export default grammar;
|