@jbrowse/jexl 3.1.0 → 3.2.0
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 +15 -0
- package/dist/Expression.d.ts +3 -1
- package/dist/Expression.js +3 -8
- package/dist/Expression.js.map +1 -1
- package/dist/Lexer.d.ts +0 -1
- package/dist/Lexer.js +5 -8
- package/dist/Lexer.js.map +1 -1
- package/dist/evaluator/compile.js +34 -16
- package/dist/evaluator/compile.js.map +1 -1
- package/dist/grammar.js +8 -8
- package/dist/grammar.js.map +1 -1
- package/dist/parser/Parser.d.ts +2 -1
- package/dist/parser/Parser.js +29 -12
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/handlers.d.ts +8 -2
- package/dist/parser/handlers.js +32 -7
- package/dist/parser/handlers.js.map +1 -1
- package/dist/parser/states.js +19 -20
- package/dist/parser/states.js.map +1 -1
- package/esm/Expression.d.ts +3 -1
- package/esm/Expression.js +3 -8
- package/esm/Expression.js.map +1 -1
- package/esm/Lexer.d.ts +0 -1
- package/esm/Lexer.js +5 -8
- package/esm/Lexer.js.map +1 -1
- package/esm/evaluator/compile.js +34 -16
- package/esm/evaluator/compile.js.map +1 -1
- package/esm/grammar.js +8 -8
- package/esm/grammar.js.map +1 -1
- package/esm/parser/Parser.d.ts +2 -1
- package/esm/parser/Parser.js +29 -12
- package/esm/parser/Parser.js.map +1 -1
- package/esm/parser/handlers.d.ts +8 -2
- package/esm/parser/handlers.js +29 -7
- package/esm/parser/handlers.js.map +1 -1
- package/esm/parser/states.js +19 -20
- package/esm/parser/states.js.map +1 -1
- package/package.json +1 -1
- package/src/Expression.ts +3 -9
- package/src/Lexer.ts +5 -8
- package/src/evaluator/compile.ts +51 -44
- package/src/grammar.ts +8 -9
- package/src/parser/Parser.ts +35 -17
- package/src/parser/handlers.ts +33 -10
- package/src/parser/states.ts +20 -20
package/src/parser/states.ts
CHANGED
|
@@ -22,6 +22,20 @@ interface StateDefinition {
|
|
|
22
22
|
|
|
23
23
|
type States = Record<string, StateDefinition>
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* The tokens that may follow a finished operand: an operator to combine it
|
|
27
|
+
* with, a dot or subscript to keep drilling into it, a question mark opening a
|
|
28
|
+
* ternary, or a semicolon ending the statement. Shared by every state that
|
|
29
|
+
* sits on a complete value, which is also why each of them is completable.
|
|
30
|
+
*/
|
|
31
|
+
const afterOperand: Record<string, TokenTypeOptions> = {
|
|
32
|
+
binaryOp: { toState: 'expectOperand' },
|
|
33
|
+
dot: { toState: 'traverse' },
|
|
34
|
+
openBracket: { toState: 'filter' },
|
|
35
|
+
question: { toState: 'ternaryMid', handler: h.ternaryStart },
|
|
36
|
+
semicolon: { handler: h.semicolon }
|
|
37
|
+
}
|
|
38
|
+
|
|
25
39
|
/**
|
|
26
40
|
* A mapping of all states in the finite state machine to a set of instructions
|
|
27
41
|
* for handling or transitioning into other states. Each state can be handled
|
|
@@ -68,13 +82,7 @@ export const states: States = {
|
|
|
68
82
|
}
|
|
69
83
|
},
|
|
70
84
|
expectBinOp: {
|
|
71
|
-
tokenTypes:
|
|
72
|
-
binaryOp: { toState: 'expectOperand' },
|
|
73
|
-
dot: { toState: 'traverse' },
|
|
74
|
-
openBracket: { toState: 'filter' },
|
|
75
|
-
question: { toState: 'ternaryMid', handler: h.ternaryStart },
|
|
76
|
-
semicolon: { handler: h.semicolon }
|
|
77
|
-
},
|
|
85
|
+
tokenTypes: afterOperand,
|
|
78
86
|
completable: true
|
|
79
87
|
},
|
|
80
88
|
expectObjKey: {
|
|
@@ -90,23 +98,15 @@ export const states: States = {
|
|
|
90
98
|
}
|
|
91
99
|
},
|
|
92
100
|
postArgs: {
|
|
93
|
-
tokenTypes:
|
|
94
|
-
binaryOp: { toState: 'expectOperand' },
|
|
95
|
-
dot: { toState: 'traverse' },
|
|
96
|
-
openBracket: { toState: 'filter' },
|
|
97
|
-
question: { toState: 'ternaryMid', handler: h.ternaryStart },
|
|
98
|
-
semicolon: { handler: h.semicolon }
|
|
99
|
-
},
|
|
101
|
+
tokenTypes: afterOperand,
|
|
100
102
|
completable: true
|
|
101
103
|
},
|
|
102
104
|
identifier: {
|
|
103
105
|
tokenTypes: {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
openParen: { toState: 'argVal', handler: h.functionCall }
|
|
108
|
-
question: { toState: 'ternaryMid', handler: h.ternaryStart },
|
|
109
|
-
semicolon: { handler: h.semicolon }
|
|
106
|
+
...afterOperand,
|
|
107
|
+
// a name is the only operand that can be followed by an argument list,
|
|
108
|
+
// since a function is called by name rather than evaluated as a value
|
|
109
|
+
openParen: { toState: 'argVal', handler: h.functionCall }
|
|
110
110
|
},
|
|
111
111
|
completable: true
|
|
112
112
|
},
|