@libreflare/worker-runtime 0.7.0 → 0.8.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 +235 -13
- package/dist/rule-evaluator/accept-encoding.d.ts +2 -2
- package/dist/rule-evaluator/accept-encoding.d.ts.map +1 -1
- package/dist/rule-evaluator/accept-encoding.js +62 -15
- package/dist/rule-evaluator/accept-encoding.js.map +1 -1
- package/dist/rule-evaluator/access-values.d.ts +77 -14
- package/dist/rule-evaluator/access-values.d.ts.map +1 -1
- package/dist/rule-evaluator/access-values.js +149 -17
- package/dist/rule-evaluator/access-values.js.map +1 -1
- package/dist/rule-evaluator/analysis.d.ts +43 -8
- package/dist/rule-evaluator/analysis.d.ts.map +1 -1
- package/dist/rule-evaluator/analysis.js +72 -29
- package/dist/rule-evaluator/analysis.js.map +1 -1
- package/dist/rule-evaluator/ast.d.ts +145 -11
- package/dist/rule-evaluator/ast.d.ts.map +1 -1
- package/dist/rule-evaluator/ast.js +102 -4
- package/dist/rule-evaluator/ast.js.map +1 -1
- package/dist/rule-evaluator/byte-strings.d.ts +23 -0
- package/dist/rule-evaluator/byte-strings.d.ts.map +1 -0
- package/dist/rule-evaluator/byte-strings.js +150 -0
- package/dist/rule-evaluator/byte-strings.js.map +1 -0
- package/dist/rule-evaluator/constants.d.ts +1 -1
- package/dist/rule-evaluator/constants.d.ts.map +1 -1
- package/dist/rule-evaluator/constants.js +1 -0
- package/dist/rule-evaluator/constants.js.map +1 -1
- package/dist/rule-evaluator/country-codes.generated.js +1 -1
- package/dist/rule-evaluator/custom-lists.d.ts +9 -0
- package/dist/rule-evaluator/custom-lists.d.ts.map +1 -1
- package/dist/rule-evaluator/custom-lists.js +43 -0
- package/dist/rule-evaluator/custom-lists.js.map +1 -1
- package/dist/rule-evaluator/diagnostics.d.ts +1 -3
- package/dist/rule-evaluator/diagnostics.d.ts.map +1 -1
- package/dist/rule-evaluator/diagnostics.js +10 -53
- package/dist/rule-evaluator/diagnostics.js.map +1 -1
- package/dist/rule-evaluator/engine-observations.d.ts +37 -0
- package/dist/rule-evaluator/engine-observations.d.ts.map +1 -0
- package/dist/rule-evaluator/engine-observations.generated.d.ts +991 -0
- package/dist/rule-evaluator/engine-observations.generated.d.ts.map +1 -0
- package/dist/rule-evaluator/engine-observations.generated.js +292 -0
- package/dist/rule-evaluator/engine-observations.generated.js.map +1 -0
- package/dist/rule-evaluator/engine-observations.js +13 -0
- package/dist/rule-evaluator/engine-observations.js.map +1 -0
- package/dist/rule-evaluator/evaluator.d.ts +1 -1
- package/dist/rule-evaluator/evaluator.d.ts.map +1 -1
- package/dist/rule-evaluator/evaluator.js +16 -15
- package/dist/rule-evaluator/evaluator.js.map +1 -1
- package/dist/rule-evaluator/explain.d.ts.map +1 -1
- package/dist/rule-evaluator/explain.js +35 -20
- package/dist/rule-evaluator/explain.js.map +1 -1
- package/dist/rule-evaluator/field-availability.d.ts +11 -10
- package/dist/rule-evaluator/field-availability.d.ts.map +1 -1
- package/dist/rule-evaluator/field-availability.js +136 -97
- package/dist/rule-evaluator/field-availability.js.map +1 -1
- package/dist/rule-evaluator/field-descriptions.generated.d.ts +1 -1
- package/dist/rule-evaluator/field-descriptions.generated.js +1 -1
- package/dist/rule-evaluator/field-descriptions.generated.js.map +1 -1
- package/dist/rule-evaluator/field-value-domains.d.ts.map +1 -1
- package/dist/rule-evaluator/field-value-domains.js +2 -4
- package/dist/rule-evaluator/field-value-domains.js.map +1 -1
- package/dist/rule-evaluator/fields.d.ts +25 -2
- package/dist/rule-evaluator/fields.d.ts.map +1 -1
- package/dist/rule-evaluator/fields.js +276 -119
- package/dist/rule-evaluator/fields.js.map +1 -1
- package/dist/rule-evaluator/function-availability.d.ts +16 -0
- package/dist/rule-evaluator/function-availability.d.ts.map +1 -0
- package/dist/rule-evaluator/function-availability.js +28 -0
- package/dist/rule-evaluator/function-availability.js.map +1 -0
- package/dist/rule-evaluator/function-descriptions.d.ts +15 -1
- package/dist/rule-evaluator/function-descriptions.d.ts.map +1 -1
- package/dist/rule-evaluator/function-descriptions.generated.d.ts +50 -7
- package/dist/rule-evaluator/function-descriptions.generated.d.ts.map +1 -1
- package/dist/rule-evaluator/function-descriptions.generated.js +98 -12
- package/dist/rule-evaluator/function-descriptions.generated.js.map +1 -1
- package/dist/rule-evaluator/function-descriptions.js +11 -2
- package/dist/rule-evaluator/function-descriptions.js.map +1 -1
- package/dist/rule-evaluator/function-signature-validation.d.ts +26 -2
- package/dist/rule-evaluator/function-signature-validation.d.ts.map +1 -1
- package/dist/rule-evaluator/function-signature-validation.js +311 -181
- package/dist/rule-evaluator/function-signature-validation.js.map +1 -1
- package/dist/rule-evaluator/functions.d.ts +24 -5
- package/dist/rule-evaluator/functions.d.ts.map +1 -1
- package/dist/rule-evaluator/functions.js +353 -190
- package/dist/rule-evaluator/functions.js.map +1 -1
- package/dist/rule-evaluator/hash-in-range.d.ts +33 -0
- package/dist/rule-evaluator/hash-in-range.d.ts.map +1 -0
- package/dist/rule-evaluator/hash-in-range.js +72 -0
- package/dist/rule-evaluator/hash-in-range.js.map +1 -0
- package/dist/rule-evaluator/log-sample.d.ts.map +1 -1
- package/dist/rule-evaluator/log-sample.js +14 -6
- package/dist/rule-evaluator/log-sample.js.map +1 -1
- package/dist/rule-evaluator/match-chain.d.ts +3 -3
- package/dist/rule-evaluator/match-chain.d.ts.map +1 -1
- package/dist/rule-evaluator/match-chain.js +19 -13
- package/dist/rule-evaluator/match-chain.js.map +1 -1
- package/dist/rule-evaluator/minifier.d.ts.map +1 -1
- package/dist/rule-evaluator/minifier.js +16 -20
- package/dist/rule-evaluator/minifier.js.map +1 -1
- package/dist/rule-evaluator/normalizer.d.ts.map +1 -1
- package/dist/rule-evaluator/normalizer.js +6 -6
- package/dist/rule-evaluator/normalizer.js.map +1 -1
- package/dist/rule-evaluator/operators.d.ts +11 -4
- package/dist/rule-evaluator/operators.d.ts.map +1 -1
- package/dist/rule-evaluator/operators.js +62 -35
- package/dist/rule-evaluator/operators.js.map +1 -1
- package/dist/rule-evaluator/outcome.d.ts +2 -0
- package/dist/rule-evaluator/outcome.d.ts.map +1 -1
- package/dist/rule-evaluator/outcome.js +4 -0
- package/dist/rule-evaluator/outcome.js.map +1 -1
- package/dist/rule-evaluator/parse-cache.d.ts +3 -3
- package/dist/rule-evaluator/parse-cache.d.ts.map +1 -1
- package/dist/rule-evaluator/parse-cache.js +5 -13
- package/dist/rule-evaluator/parse-cache.js.map +1 -1
- package/dist/rule-evaluator/parser.d.ts +318 -11
- package/dist/rule-evaluator/parser.d.ts.map +1 -1
- package/dist/rule-evaluator/parser.js +1314 -333
- package/dist/rule-evaluator/parser.js.map +1 -1
- package/dist/rule-evaluator/quantifier.d.ts +1 -1
- package/dist/rule-evaluator/quantifier.d.ts.map +1 -1
- package/dist/rule-evaluator/quantifier.js +1 -16
- package/dist/rule-evaluator/quantifier.js.map +1 -1
- package/dist/rule-evaluator/request-headers.d.ts +101 -0
- package/dist/rule-evaluator/request-headers.d.ts.map +1 -0
- package/dist/rule-evaluator/request-headers.js +344 -0
- package/dist/rule-evaluator/request-headers.js.map +1 -0
- package/dist/rule-evaluator/rule-language-types.d.ts +80 -21
- package/dist/rule-evaluator/rule-language-types.d.ts.map +1 -1
- package/dist/rule-evaluator/rule-language-types.js +228 -67
- package/dist/rule-evaluator/rule-language-types.js.map +1 -1
- package/dist/rule-evaluator/tokenizer.d.ts +14 -4
- package/dist/rule-evaluator/tokenizer.d.ts.map +1 -1
- package/dist/rule-evaluator/tokenizer.js +24 -11
- package/dist/rule-evaluator/tokenizer.js.map +1 -1
- package/dist/rule-evaluator/transformation.d.ts.map +1 -1
- package/dist/rule-evaluator/transformation.js +10 -6
- package/dist/rule-evaluator/transformation.js.map +1 -1
- package/dist/rule-evaluator/url-decode.d.ts +8 -0
- package/dist/rule-evaluator/url-decode.d.ts.map +1 -0
- package/dist/rule-evaluator/url-decode.js +126 -0
- package/dist/rule-evaluator/url-decode.js.map +1 -0
- package/dist/rule-evaluator/validation.d.ts.map +1 -1
- package/dist/rule-evaluator/validation.js +405 -235
- package/dist/rule-evaluator/validation.js.map +1 -1
- package/dist/rule-evaluator.d.ts +2 -2
- package/dist/rule-evaluator.d.ts.map +1 -1
- package/dist/rule-evaluator.js.map +1 -1
- package/package.json +5 -2
- package/dist/rule-evaluator/comparison.d.ts +0 -16
- package/dist/rule-evaluator/comparison.d.ts.map +0 -1
- package/dist/rule-evaluator/comparison.js +0 -43
- package/dist/rule-evaluator/comparison.js.map +0 -1
- package/dist/rule-evaluator/custom-security-rule-analysis.d.ts +0 -36
- package/dist/rule-evaluator/custom-security-rule-analysis.d.ts.map +0 -1
- package/dist/rule-evaluator/custom-security-rule-analysis.js +0 -382
- package/dist/rule-evaluator/custom-security-rule-analysis.js.map +0 -1
- package/dist/rule-evaluator/values.d.ts +0 -26
- package/dist/rule-evaluator/values.d.ts.map +0 -1
- package/dist/rule-evaluator/values.js +0 -55
- package/dist/rule-evaluator/values.js.map +0 -1
- package/dist/rule-evaluator/warnings.d.ts +0 -2
- package/dist/rule-evaluator/warnings.d.ts.map +0 -1
- package/dist/rule-evaluator/warnings.js +0 -5
- package/dist/rule-evaluator/warnings.js.map +0 -1
|
@@ -1,51 +1,358 @@
|
|
|
1
1
|
import { type ExprNode } from './ast.js';
|
|
2
2
|
import { type RuleExpressionDiagnosticDetail } from './diagnostics.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type Token } from './tokenizer.js';
|
|
4
4
|
export declare class Parser {
|
|
5
|
-
private tokens;
|
|
6
5
|
private source;
|
|
7
|
-
private warnings;
|
|
8
6
|
private diagnostics?;
|
|
9
7
|
private pos;
|
|
10
|
-
|
|
8
|
+
/** Each delimiter's partner; see pairDelimiters(). */
|
|
9
|
+
private readonly partners;
|
|
10
|
+
/** The constructs that enclose the current token, innermost last. */
|
|
11
|
+
private readonly constructs;
|
|
12
|
+
/** The depth of each construct in `constructs` that has a closer, by its closer's token index. */
|
|
13
|
+
private readonly closerDepths;
|
|
14
|
+
/** The index of the last token the parser read, where a node's span ends. Recovery skips tokens without reading them. */
|
|
15
|
+
private lastRead;
|
|
16
|
+
/** The closers the last token may hide that no construct has taken; see takeHiddenCloser(). */
|
|
17
|
+
private readonly hiddenClosers;
|
|
18
|
+
private readonly tokens;
|
|
19
|
+
/** The unknown characters that may stand for an operator; see readTokens(). */
|
|
20
|
+
private readonly operatorCharacters;
|
|
21
|
+
/**
|
|
22
|
+
* The access paths where recovery in an access without its `]` skipped
|
|
23
|
+
* past the token with the error. What it skipped may hold the `]` and a
|
|
24
|
+
* comparison operator, which would make the field or call before the path
|
|
25
|
+
* a comparison's left side; see InvalidNode.operand. fieldCondition() and
|
|
26
|
+
* functionCondition() look up the path of the node they get, so the mark
|
|
27
|
+
* reaches them however the node does, as a function argument too.
|
|
28
|
+
*/
|
|
29
|
+
private readonly cutShortAccessPaths;
|
|
30
|
+
constructor(tokens: Token[], source: string, diagnostics?: RuleExpressionDiagnosticDetail[] | undefined);
|
|
11
31
|
parse(): ExprNode;
|
|
12
32
|
private peek;
|
|
33
|
+
private tokenAt;
|
|
34
|
+
/** The token at an offset, not counting closers that pair with no opener; see skipStrayClosers(). */
|
|
35
|
+
private peekPastStrayClosers;
|
|
36
|
+
/** The index of the token at an offset, not counting closers that pair with no opener. */
|
|
37
|
+
private indexPastStrayClosers;
|
|
13
38
|
private consume;
|
|
39
|
+
/**
|
|
40
|
+
* The text of the token that ends the input when it lacks its closing
|
|
41
|
+
* delimiter, or '' for any other. What was meant to follow such a token
|
|
42
|
+
* may be in it, but only where its text holds it: in
|
|
43
|
+
* `coalesce(http.host eq "x, ssl)` the string holds the `)`, and in
|
|
44
|
+
* `lower(http.host eq "ab` it holds nothing. A string without its `"` ends
|
|
45
|
+
* at the end of its line, and the tokens after it are read as usual. It
|
|
46
|
+
* reads the tokenizer's tokens, since an unknown character that the
|
|
47
|
+
* parser reads past still follows the string, on a later line.
|
|
48
|
+
*/
|
|
49
|
+
private hiddenText;
|
|
14
50
|
private rawSpan;
|
|
15
51
|
private parseOr;
|
|
16
52
|
private parseXor;
|
|
17
53
|
private parseAnd;
|
|
18
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Combines the operands of one operator, or returns the only one. An
|
|
56
|
+
* operand that combines with the same operator, such as a group, is
|
|
57
|
+
* flattened into it. The node is built once, so a long chain stays linear.
|
|
58
|
+
*/
|
|
59
|
+
private logicalNode;
|
|
19
60
|
private parseNot;
|
|
20
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Reports and skips each closer that pairs with no opener before a
|
|
63
|
+
* condition. In place of a condition, with none after it, one is the
|
|
64
|
+
* condition, invalid; see invalidCondition().
|
|
65
|
+
*/
|
|
66
|
+
private skipBeforeCondition;
|
|
67
|
+
/** Where the condition at the current token starts, past the closers skipBeforeCondition() skips. */
|
|
68
|
+
private conditionStart;
|
|
21
69
|
private parsePrimary;
|
|
70
|
+
/**
|
|
71
|
+
* Reports a token that cannot start a condition, and puts an InvalidNode
|
|
72
|
+
* in place of the condition. A token that an enclosing construct resumes
|
|
73
|
+
* at stays for it to read, and leaves the condition empty; any other is
|
|
74
|
+
* the condition, invalid, and recovery starts there.
|
|
75
|
+
*/
|
|
76
|
+
private invalidCondition;
|
|
77
|
+
/**
|
|
78
|
+
* Reports a token that cannot start an argument, and puts an InvalidNode
|
|
79
|
+
* in place of the argument. A token that an enclosing construct resumes at
|
|
80
|
+
* leaves the argument empty; any other is the argument, invalid, and so is
|
|
81
|
+
* a logical operator, which has nothing to combine. A comparison operator
|
|
82
|
+
* that the call ends at gets the call's missing `)` instead, and what is
|
|
83
|
+
* around the call reads it; see endsAtComparison(). An unknown character
|
|
84
|
+
* starts recovery, since the name, number, or string touching it may
|
|
85
|
+
* belong to it, and that value takes the slot. So does a `[` with an
|
|
86
|
+
* argument in it, a value, a group, or `not`, which may be the argument in
|
|
87
|
+
* brackets. After a comma, a `[` with anything in it, as `[*]`, may
|
|
88
|
+
* instead be an access that a stray comma split off from the argument
|
|
89
|
+
* before it, and no argument at all, as a token after a missing comma may
|
|
90
|
+
* be, so that argument and the ones after it are uncertain. Any other
|
|
91
|
+
* token, and an unterminated comment, holds no value there, and may be
|
|
92
|
+
* what a stray comma left; see InvalidNode.empty.
|
|
93
|
+
*/
|
|
94
|
+
private invalidArgument;
|
|
95
|
+
/**
|
|
96
|
+
* An InvalidNode for the tokens with the error, from the current one (see
|
|
97
|
+
* errorTokenCount()), or an opener with everything up to its closer, as
|
|
98
|
+
* skipInvalidValue() consumes it, which the parser reads as invalid
|
|
99
|
+
* without moving past them, so that the nodes around it span them before
|
|
100
|
+
* recovery skips them.
|
|
101
|
+
*/
|
|
102
|
+
private readInvalid;
|
|
103
|
+
/** An InvalidNode with nothing in it, right after the last token read, before a token that belongs to something else. */
|
|
104
|
+
private emptyInvalid;
|
|
105
|
+
/** Reports a call's `)` missing, at the current token, or over a span. */
|
|
106
|
+
private reportMissingCallCloser;
|
|
107
|
+
/** Reports a token that cannot appear where it is. */
|
|
108
|
+
private reportUnexpectedToken;
|
|
109
|
+
/** Stands in for invalid syntax after its error is reported, over the source text it spans; see InvalidNode. */
|
|
110
|
+
private invalidNode;
|
|
22
111
|
private parseFieldOrComparison;
|
|
112
|
+
/**
|
|
113
|
+
* A field without a comparison: a Boolean field, or an InvalidNode that
|
|
114
|
+
* keeps it when it has an access path. One that recovery cuts short, after
|
|
115
|
+
* it or in an access without its `]`, may be a comparison's left side
|
|
116
|
+
* instead, so it is kept the same way, and its access path gets no error,
|
|
117
|
+
* unless it is a Boolean, which Cloudflare never compares; see
|
|
118
|
+
* InvalidNode.operand.
|
|
119
|
+
*/
|
|
120
|
+
private fieldCondition;
|
|
23
121
|
private parseFieldRef;
|
|
24
122
|
private parseAccessPath;
|
|
123
|
+
/**
|
|
124
|
+
* The value of an access, or null when it is not a valid one, after
|
|
125
|
+
* reporting it. A number or string touching an unknown character is the
|
|
126
|
+
* value, as a list keeps its member; see readTokens().
|
|
127
|
+
*/
|
|
128
|
+
private parseAccessValue;
|
|
25
129
|
private parseComparisonValue;
|
|
26
130
|
private tryParseDynamicValue;
|
|
27
131
|
private isMissingComparisonValueBoundary;
|
|
28
132
|
private previousTokenEnd;
|
|
29
133
|
private fieldLength;
|
|
134
|
+
/** Reads the comparison operator at the current token, if one starts there; see isComparisonStart(). */
|
|
30
135
|
private tryParseCompOp;
|
|
136
|
+
/** A literal value, or an InvalidNode for one that is not valid, such as an unquoted name, after reporting it. */
|
|
31
137
|
private parseValue;
|
|
138
|
+
/**
|
|
139
|
+
* Consumes an invalid value: one token, or an opener with everything up to
|
|
140
|
+
* its closer. An opener without its closer may hold everything after it,
|
|
141
|
+
* so recovery skips what it holds; see recoveryIndexAfter(). In a list,
|
|
142
|
+
* which holds only values, it holds nothing, and the members after it stay.
|
|
143
|
+
*/
|
|
144
|
+
private skipInvalidValue;
|
|
145
|
+
/** A number literal, with its exact `integer` value, or an InvalidNode for one that is not a valid integer. */
|
|
146
|
+
private numberLiteral;
|
|
32
147
|
private parseSetLiteral;
|
|
148
|
+
/** A list member that is not a valid element, from its token to the last token read. */
|
|
149
|
+
private invalidMember;
|
|
33
150
|
private parseFuncCall;
|
|
151
|
+
/** A function call as a value; the caller has checked that `(` follows its name. */
|
|
34
152
|
private parseFunctionValue;
|
|
153
|
+
private funcNode;
|
|
154
|
+
/**
|
|
155
|
+
* Parses a call's argument list, from its `(` through its `)`, with the
|
|
156
|
+
* index from which the arguments are uncertain, and whether some may be
|
|
157
|
+
* another call's or not arguments at all (see FuncNode). When recovery in
|
|
158
|
+
* an argument skipped a token after the one with the error, that argument
|
|
159
|
+
* may have gone on, and the ones after it may have shifted. Without its
|
|
160
|
+
* `)`, the call may have more. The written ones keep their positions,
|
|
161
|
+
* unless a call around it takes commas and its `)` is missing, rather than
|
|
162
|
+
* hidden in a token that runs to the end: it may then be missing before
|
|
163
|
+
* any of them.
|
|
164
|
+
*/
|
|
165
|
+
private parseArguments;
|
|
166
|
+
/** What parseArguments() returns; its own method, so that the frame each nested call adds stays small. */
|
|
167
|
+
private parsedArguments;
|
|
35
168
|
private parseFunctionArgs;
|
|
169
|
+
/**
|
|
170
|
+
* Parses a function argument as Cloudflare does. One that starts with
|
|
171
|
+
* `(`, `not`, any() or all() is a whole logical expression, so `and`, `or`
|
|
172
|
+
* and `xor` can follow, and a lone function call there is a condition too.
|
|
173
|
+
* Any other is a value, or a comparison of one, as in
|
|
174
|
+
* `coalesce(has_value(...), http.host eq "x")`.
|
|
175
|
+
*/
|
|
36
176
|
private parseFunctionArg;
|
|
177
|
+
/**
|
|
178
|
+
* Reports and skips each token that stands for nothing before what
|
|
179
|
+
* `starts` accepts, when that follows them: before an argument, see
|
|
180
|
+
* isNoiseBeforeArgument(), or a comparison value, see
|
|
181
|
+
* isNoiseBeforeComparisonValue(). In its place, with nothing after them,
|
|
182
|
+
* one is that argument or value, invalid; see invalidArgument() and
|
|
183
|
+
* parseComparisonValue(). Its own method, so that the frame each nested
|
|
184
|
+
* call adds stays small.
|
|
185
|
+
*/
|
|
186
|
+
private skipNoise;
|
|
187
|
+
/**
|
|
188
|
+
* Skips the tokens that stand for nothing before an argument; see
|
|
189
|
+
* skipNoise(). A comparison operator among them may have lost its left
|
|
190
|
+
* side, which would make the argument a comparison, so that argument and
|
|
191
|
+
* the ones after it are uncertain.
|
|
192
|
+
*/
|
|
193
|
+
private skipNoiseBeforeArgument;
|
|
194
|
+
/** Leaves the argument the innermost call reads, and the ones after it, uncertain; see FuncNode.uncertainFrom. */
|
|
195
|
+
private leaveArgumentUncertain;
|
|
196
|
+
/**
|
|
197
|
+
* Whether a token stands for nothing before an argument: a logical
|
|
198
|
+
* operator, which has nothing to combine, or one that stands for nothing
|
|
199
|
+
* before anything an argument can start with; see standsForNothing().
|
|
200
|
+
*/
|
|
201
|
+
private isNoiseBeforeArgument;
|
|
202
|
+
/**
|
|
203
|
+
* Whether a token stands for nothing before a comparison value; see
|
|
204
|
+
* standsForNothing(). An operator does not: after the comparison operator,
|
|
205
|
+
* it belongs to something else, as a second operator or one after a
|
|
206
|
+
* missing value does, so the value is missing.
|
|
207
|
+
*/
|
|
208
|
+
private isNoiseBeforeComparisonValue;
|
|
209
|
+
/**
|
|
210
|
+
* Whether a token stands for nothing before one that `starts` accepts:
|
|
211
|
+
* it can start nothing there and no open construct resumes at it, as a
|
|
212
|
+
* closer that pairs with no opener, or a `*`. An opener holds what is up
|
|
213
|
+
* to its closer, and a malformed token has its own rule.
|
|
214
|
+
*/
|
|
215
|
+
private standsForNothing;
|
|
216
|
+
/** An argument that is a value, or a comparison of one. */
|
|
217
|
+
private parseValueArgument;
|
|
218
|
+
/**
|
|
219
|
+
* The field or function value an argument starts with. An unknown name
|
|
220
|
+
* that a comparison, an access, or a logical operator follows is a field,
|
|
221
|
+
* as at the top level. One alone is more likely an unquoted string.
|
|
222
|
+
*/
|
|
223
|
+
private tryParseArgumentValue;
|
|
224
|
+
/**
|
|
225
|
+
* An argument read as the first of several combined conditions. A literal
|
|
226
|
+
* cannot be one, and the missing parentheses already make it invalid.
|
|
227
|
+
* Invalid syntax stays invalid. `cutShort` marks a field or call that
|
|
228
|
+
* recovery cut short; see InvalidNode.operand.
|
|
229
|
+
*/
|
|
230
|
+
private asCondition;
|
|
231
|
+
/** Enters the construct that the opener at the current token starts. */
|
|
232
|
+
private open;
|
|
233
|
+
/**
|
|
234
|
+
* Leaves the innermost construct, consuming its closer. A construct with
|
|
235
|
+
* its closer ends only there, since it owns every token up to it. One
|
|
236
|
+
* without ends where an enclosing construct resumes, and its closer is
|
|
237
|
+
* reported missing, since pairing found none, unless the input ends in a
|
|
238
|
+
* token that may hide it; see takeHiddenCloser(). Returns whether the closer
|
|
239
|
+
* was read, hidden in that token, or missing.
|
|
240
|
+
*/
|
|
241
|
+
private close;
|
|
242
|
+
/**
|
|
243
|
+
* Takes a closer of a construct from the token the input ends in, when the
|
|
244
|
+
* parser is at the end of the input and that token's text holds one that
|
|
245
|
+
* no construct inside this one took. Returns whether it took one. The
|
|
246
|
+
* innermost take them first, as the closers would if the token had ended
|
|
247
|
+
* before them.
|
|
248
|
+
*/
|
|
249
|
+
private takeHiddenCloser;
|
|
250
|
+
/**
|
|
251
|
+
* The open construct that resumes at a token: its index in `constructs`,
|
|
252
|
+
* -1 for the top level, or null when none does. A construct with its
|
|
253
|
+
* closer owns every token up to it, so none outside it resumes there. With
|
|
254
|
+
* `argumentStarts`, a call also takes a token that can start an argument,
|
|
255
|
+
* as the next argument after a missing comma.
|
|
256
|
+
*/
|
|
257
|
+
private handlerOf;
|
|
258
|
+
/**
|
|
259
|
+
* Whether the innermost construct ends at a comparison operator: an access
|
|
260
|
+
* without its `]`, or a call without its `)` that reads a value argument
|
|
261
|
+
* the comparison cannot be; see takesComparison(). A construct outside it
|
|
262
|
+
* does not: the comparison belongs to the innermost one, or to what that
|
|
263
|
+
* one holds, such as a condition.
|
|
264
|
+
*/
|
|
265
|
+
private endsAtComparison;
|
|
266
|
+
/** Whether a construct outside the one at `depth` resumes at the current token. */
|
|
267
|
+
private resumesOutside;
|
|
268
|
+
private isStrayCloser;
|
|
269
|
+
/** Reports each closer at the current token that pairs with no opener, and skips it alone. */
|
|
270
|
+
private skipStrayClosers;
|
|
271
|
+
/**
|
|
272
|
+
* Checks the token after a complete operand, argument, or access value. A
|
|
273
|
+
* closer that pairs with no opener is skipped alone. A token that no open
|
|
274
|
+
* construct takes starts recovery, and gets an error unless it is an
|
|
275
|
+
* unknown character or an unterminated comment, which has its own. Returns
|
|
276
|
+
* whether recovery skipped a token after the one with the error, which
|
|
277
|
+
* may then stand for a comparison operator; see InvalidNode.operand.
|
|
278
|
+
*/
|
|
279
|
+
private finishOperand;
|
|
280
|
+
/**
|
|
281
|
+
* Skips tokens, each opener with everything up to its closer (see
|
|
282
|
+
* recoveryIndexAfter()), until one that an open construct resumes at (see
|
|
283
|
+
* handlerOf()). When recovery skips a token after the one with the error,
|
|
284
|
+
* it marks the argument it is in as uncertain, in the construct it resumes
|
|
285
|
+
* in and in each it leaves.
|
|
286
|
+
*/
|
|
287
|
+
private recover;
|
|
288
|
+
/**
|
|
289
|
+
* How many tokens the error at a token covers: an unknown character goes
|
|
290
|
+
* with the name, number, or string touching it, which may belong to it,
|
|
291
|
+
* unless the character stands between two operands; see readTokens(). Any
|
|
292
|
+
* other error, including an opener's, is that token alone.
|
|
293
|
+
*/
|
|
294
|
+
private errorTokenCount;
|
|
295
|
+
/**
|
|
296
|
+
* Where recovery from a token stops, and whether it skips more than the
|
|
297
|
+
* tokens with the error; see errorTokenCount(). What an opener holds up to
|
|
298
|
+
* its closer is past it, and may hold a comparison operator.
|
|
299
|
+
*/
|
|
300
|
+
private recoveryEnd;
|
|
301
|
+
/**
|
|
302
|
+
* Whether recovery starts after the operand just read and skips past the
|
|
303
|
+
* token with the error. That token may stand for a comparison operator,
|
|
304
|
+
* so the operand may be a comparison's left side; see
|
|
305
|
+
* InvalidNode.operand.
|
|
306
|
+
*/
|
|
307
|
+
private cutsShort;
|
|
308
|
+
/**
|
|
309
|
+
* The index recovery goes on from after a token. An opener without its
|
|
310
|
+
* closer holds everything up to the closer of the construct around it
|
|
311
|
+
* that has one, or to the end, so recovery does not resume inside it.
|
|
312
|
+
*/
|
|
313
|
+
private recoveryIndexAfter;
|
|
314
|
+
/** The index after a token, or after the closer of an opener. */
|
|
315
|
+
private indexAfter;
|
|
316
|
+
private startsLogicalArgument;
|
|
317
|
+
/**
|
|
318
|
+
* The comparison an argument value starts, or null when the argument ends
|
|
319
|
+
* before the comparison operator. In a call without its `)`, the operator
|
|
320
|
+
* ends the argument, and the call with it, unless the comparison can be
|
|
321
|
+
* the argument, as coalesce()'s first can: `lower(http.host eq "x"` more
|
|
322
|
+
* likely misses the `)` after `http.host`, and the comparison then
|
|
323
|
+
* compares the call's result. The parser decides this at the operator,
|
|
324
|
+
* from what it has read, so it never reads a comparison it would have to
|
|
325
|
+
* undo; see takesComparison(). Any other comparison is the argument; see
|
|
326
|
+
* parseFunctionArg() for a logical operator after it.
|
|
327
|
+
*/
|
|
328
|
+
private parseArgumentComparison;
|
|
329
|
+
/** The comparison that follows a value, or null when no comparison operator does. */
|
|
330
|
+
private parseComparisonRest;
|
|
37
331
|
private isKnownFieldName;
|
|
38
|
-
|
|
332
|
+
/**
|
|
333
|
+
* A call where a condition belongs, with the comparison after it, if any.
|
|
334
|
+
* No comparison is read after starts_with() or ends_with(). Its own
|
|
335
|
+
* method, so that the frame each nested call adds stays small.
|
|
336
|
+
*/
|
|
39
337
|
private parseScalarFunctionComparison;
|
|
338
|
+
/** A call without a comparison, as a condition; see fieldCondition(). */
|
|
339
|
+
private functionCondition;
|
|
40
340
|
private parseAnyAll;
|
|
341
|
+
/**
|
|
342
|
+
* Reads an integer literal, reporting one Cloudflare rejects: one with a
|
|
343
|
+
* fraction, an octal one with the digit 8 or 9, or one outside the 64-bit
|
|
344
|
+
* range. Null means it reported an error.
|
|
345
|
+
*/
|
|
346
|
+
private readInteger;
|
|
41
347
|
/**
|
|
42
348
|
* Reports a Cloudflare hex byte literal, such as 65:78:61, which this
|
|
43
349
|
* package does not decode. Text that is also an IPv6 address stays an address.
|
|
44
350
|
*/
|
|
45
351
|
private reportHexBytesLiteral;
|
|
46
|
-
private
|
|
47
|
-
private
|
|
48
|
-
private
|
|
49
|
-
private
|
|
352
|
+
private reportAtCurrent;
|
|
353
|
+
private reportUnquotedName;
|
|
354
|
+
private reportAtToken;
|
|
355
|
+
private reportAtSpan;
|
|
356
|
+
private report;
|
|
50
357
|
}
|
|
51
358
|
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/rule-evaluator/parser.ts"],"names":[],"mappings":"AAIA,OAAO,EASN,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/rule-evaluator/parser.ts"],"names":[],"mappings":"AAIA,OAAO,EASN,KAAK,QAAQ,EAYb,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,KAAK,8BA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