@steedos/odata-v4-parser 2.2.53-beta.3
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/LICENSE.txt +22 -0
- package/README.md +31 -0
- package/lib/expressions.d.ts +94 -0
- package/lib/expressions.js +942 -0
- package/lib/expressions.js.map +1 -0
- package/lib/json.d.ts +24 -0
- package/lib/json.js +391 -0
- package/lib/json.js.map +1 -0
- package/lib/lexer.d.ts +243 -0
- package/lib/lexer.js +595 -0
- package/lib/lexer.js.map +1 -0
- package/lib/nameOrIdentifier.d.ts +56 -0
- package/lib/nameOrIdentifier.js +850 -0
- package/lib/nameOrIdentifier.js.map +1 -0
- package/lib/odataUri.d.ts +6 -0
- package/lib/odataUri.js +34 -0
- package/lib/odataUri.js.map +1 -0
- package/lib/parser.d.ts +16 -0
- package/lib/parser.js +50 -0
- package/lib/parser.js.map +1 -0
- package/lib/primitiveLiteral.d.ts +63 -0
- package/lib/primitiveLiteral.js +793 -0
- package/lib/primitiveLiteral.js.map +1 -0
- package/lib/query.d.ts +42 -0
- package/lib/query.js +903 -0
- package/lib/query.js.map +1 -0
- package/lib/resourcePath.d.ts +31 -0
- package/lib/resourcePath.js +469 -0
- package/lib/resourcePath.js.map +1 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +37 -0
- package/lib/utils.js.map +1 -0
- package/package.json +24 -0
- package/src/expressions.ts +825 -0
- package/src/json.ts +372 -0
- package/src/lexer.ts +491 -0
- package/src/nameOrIdentifier.ts +749 -0
- package/src/odataUri.ts +37 -0
- package/src/parser.ts +37 -0
- package/src/primitiveLiteral.ts +684 -0
- package/src/query.ts +884 -0
- package/src/resourcePath.ts +461 -0
- package/src/utils.ts +36 -0
- package/tsconfig.json +33 -0
package/src/lexer.ts
ADDED
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import Utils from "./utils";
|
|
2
|
+
|
|
3
|
+
export enum TokenType {
|
|
4
|
+
Literal = "Literal",
|
|
5
|
+
ArrayOrObject = "ArrayOrObject",
|
|
6
|
+
Array = "Array",
|
|
7
|
+
Object = "Object",
|
|
8
|
+
Property = "Property",
|
|
9
|
+
Annotation = "Annotation",
|
|
10
|
+
Enum = "Enum",
|
|
11
|
+
EnumValue = "EnumValue",
|
|
12
|
+
EnumMemberValue = "EnumMemberValue",
|
|
13
|
+
Identifier = "Identifier",
|
|
14
|
+
QualifiedEntityTypeName = "QualifiedEntityTypeName",
|
|
15
|
+
QualifiedComplexTypeName = "QualifiedComplexTypeName",
|
|
16
|
+
ODataIdentifier = "ODataIdentifier",
|
|
17
|
+
Collection = "Collection",
|
|
18
|
+
NamespacePart = "NamespacePart",
|
|
19
|
+
EntitySetName = "EntitySetName",
|
|
20
|
+
SingletonEntity = "SingletonEntity",
|
|
21
|
+
EntityTypeName = "EntityTypeName",
|
|
22
|
+
ComplexTypeName = "ComplexTypeName",
|
|
23
|
+
TypeDefinitionName = "TypeDefinitionName",
|
|
24
|
+
EnumerationTypeName = "EnumerationTypeName",
|
|
25
|
+
EnumerationMember = "EnumerationMember",
|
|
26
|
+
TermName = "TermName",
|
|
27
|
+
PrimitiveProperty = "PrimitiveProperty",
|
|
28
|
+
PrimitiveKeyProperty = "PrimitiveKeyProperty",
|
|
29
|
+
PrimitiveNonKeyProperty = "PrimitiveNonKeyProperty",
|
|
30
|
+
PrimitiveCollectionProperty = "PrimitiveCollectionProperty",
|
|
31
|
+
ComplexProperty = "ComplexProperty",
|
|
32
|
+
ComplexCollectionProperty = "ComplexCollectionProperty",
|
|
33
|
+
StreamProperty = "StreamProperty",
|
|
34
|
+
NavigationProperty = "NavigationProperty",
|
|
35
|
+
EntityNavigationProperty = "EntityNavigationProperty",
|
|
36
|
+
EntityCollectionNavigationProperty = "EntityCollectionNavigationProperty",
|
|
37
|
+
Action = "Action",
|
|
38
|
+
ActionImport = "ActionImport",
|
|
39
|
+
Function = "Function",
|
|
40
|
+
EntityFunction = "EntityFunction",
|
|
41
|
+
EntityCollectionFunction = "EntityCollectionFunction",
|
|
42
|
+
ComplexFunction = "ComplexFunction",
|
|
43
|
+
ComplexCollectionFunction = "ComplexCollectionFunction",
|
|
44
|
+
PrimitiveFunction = "PrimitiveFunction",
|
|
45
|
+
PrimitiveCollectionFunction = "PrimitiveCollectionFunction",
|
|
46
|
+
EntityFunctionImport = "EntityFunctionImport",
|
|
47
|
+
EntityCollectionFunctionImport = "EntityCollectionFunctionImport",
|
|
48
|
+
ComplexFunctionImport = "ComplexFunctionImport",
|
|
49
|
+
ComplexCollectionFunctionImport = "ComplexCollectionFunctionImport",
|
|
50
|
+
PrimitiveFunctionImport = "PrimitiveFunctionImport",
|
|
51
|
+
PrimitiveCollectionFunctionImport = "PrimitiveCollectionFunctionImport",
|
|
52
|
+
CommonExpression = "CommonExpression",
|
|
53
|
+
AndExpression = "AndExpression",
|
|
54
|
+
OrExpression = "OrExpression",
|
|
55
|
+
EqualsExpression = "EqualsExpression",
|
|
56
|
+
NotEqualsExpression = "NotEqualsExpression",
|
|
57
|
+
LesserThanExpression = "LesserThanExpression",
|
|
58
|
+
LesserOrEqualsExpression = "LesserOrEqualsExpression",
|
|
59
|
+
GreaterThanExpression = "GreaterThanExpression",
|
|
60
|
+
GreaterOrEqualsExpression = "GreaterOrEqualsExpression",
|
|
61
|
+
HasExpression = "HasExpression",
|
|
62
|
+
AddExpression = "AddExpression",
|
|
63
|
+
SubExpression = "SubExpression",
|
|
64
|
+
MulExpression = "MulExpression",
|
|
65
|
+
DivExpression = "DivExpression",
|
|
66
|
+
ModExpression = "ModExpression",
|
|
67
|
+
NotExpression = "NotExpression",
|
|
68
|
+
BoolParenExpression = "BoolParenExpression",
|
|
69
|
+
ParenExpression = "ParenExpression",
|
|
70
|
+
MethodCallExpression = "MethodCallExpression",
|
|
71
|
+
IsOfExpression = "IsOfExpression",
|
|
72
|
+
CastExpression = "CastExpression",
|
|
73
|
+
NegateExpression = "NegateExpression",
|
|
74
|
+
FirstMemberExpression = "FirstMemberExpression",
|
|
75
|
+
MemberExpression = "MemberExpression",
|
|
76
|
+
PropertyPathExpression = "PropertyPathExpression",
|
|
77
|
+
ImplicitVariableExpression = "ImplicitVariableExpression",
|
|
78
|
+
LambdaVariable = "LambdaVariable",
|
|
79
|
+
LambdaVariableExpression = "LambdaVariableExpression",
|
|
80
|
+
LambdaPredicateExpression = "LambdaPredicateExpression",
|
|
81
|
+
AnyExpression = "AnyExpression",
|
|
82
|
+
AllExpression = "AllExpression",
|
|
83
|
+
CollectionNavigationExpression = "CollectionNavigationExpression",
|
|
84
|
+
SimpleKey = "SimpleKey",
|
|
85
|
+
CompoundKey = "CompoundKey",
|
|
86
|
+
KeyValuePair = "KeyValuePair",
|
|
87
|
+
KeyPropertyValue = "KeyPropertyValue",
|
|
88
|
+
KeyPropertyAlias = "KeyPropertyAlias",
|
|
89
|
+
SingleNavigationExpression = "SingleNavigationExpression",
|
|
90
|
+
CollectionPathExpression = "CollectionPathExpression",
|
|
91
|
+
ComplexPathExpression = "ComplexPathExpression",
|
|
92
|
+
SinglePathExpression = "SinglePathExpression",
|
|
93
|
+
FunctionExpression = "FunctionExpression",
|
|
94
|
+
FunctionExpressionParameters = "FunctionExpressionParameters",
|
|
95
|
+
FunctionExpressionParameter = "FunctionExpressionParameter",
|
|
96
|
+
ParameterName = "ParameterName",
|
|
97
|
+
ParameterAlias = "ParameterAlias",
|
|
98
|
+
ParameterValue = "ParameterValue",
|
|
99
|
+
CountExpression = "CountExpression",
|
|
100
|
+
RefExpression = "RefExpression",
|
|
101
|
+
ValueExpression = "ValueExpression",
|
|
102
|
+
RootExpression = "RootExpression",
|
|
103
|
+
QueryOptions = "QueryOptions",
|
|
104
|
+
CustomQueryOption = "CustomQueryOption",
|
|
105
|
+
Expand = "Expand",
|
|
106
|
+
ExpandItem = "ExpandItem",
|
|
107
|
+
ExpandPath = "ExpandPath",
|
|
108
|
+
ExpandCountOption = "ExpandCountOption",
|
|
109
|
+
ExpandRefOption = "ExpandRefOption",
|
|
110
|
+
ExpandOption = "ExpandOption",
|
|
111
|
+
Levels = "Levels",
|
|
112
|
+
Search = "Search",
|
|
113
|
+
SearchExpression = "SearchExpression",
|
|
114
|
+
SearchParenExpression = "SearchParenExpression",
|
|
115
|
+
SearchNotExpression = "SearchNotExpression",
|
|
116
|
+
SearchOrExpression = "SearchOrExpression",
|
|
117
|
+
SearchAndExpression = "SearchAndExpression",
|
|
118
|
+
SearchTerm = "SearchTerm",
|
|
119
|
+
SearchPhrase = "SearchPhrase",
|
|
120
|
+
SearchWord = "SearchWord",
|
|
121
|
+
Filter = "Filter",
|
|
122
|
+
OrderBy = "OrderBy",
|
|
123
|
+
OrderByItem = "OrderByItem",
|
|
124
|
+
Skip = "Skip",
|
|
125
|
+
Top = "Top",
|
|
126
|
+
Format = "Format",
|
|
127
|
+
InlineCount = "InlineCount",
|
|
128
|
+
Select = "Select",
|
|
129
|
+
SelectItem = "SelectItem",
|
|
130
|
+
SelectPath = "SelectPath",
|
|
131
|
+
AliasAndValue = "AliasAndValue",
|
|
132
|
+
SkipToken = "SkipToken",
|
|
133
|
+
Id = "Id",
|
|
134
|
+
Crossjoin = "Crossjoin",
|
|
135
|
+
AllResource = "AllResource",
|
|
136
|
+
ActionImportCall = "ActionImportCall",
|
|
137
|
+
FunctionImportCall = "FunctionImportCall",
|
|
138
|
+
EntityCollectionFunctionImportCall = "EntityCollectionFunctionImportCall",
|
|
139
|
+
EntityFunctionImportCall = "EntityFunctionImportCall",
|
|
140
|
+
ComplexCollectionFunctionImportCall = "ComplexCollectionFunctionImportCall",
|
|
141
|
+
ComplexFunctionImportCall = "ComplexFunctionImportCall",
|
|
142
|
+
PrimitiveCollectionFunctionImportCall = "PrimitiveCollectionFunctionImportCall",
|
|
143
|
+
PrimitiveFunctionImportCall = "PrimitiveFunctionImportCall",
|
|
144
|
+
FunctionParameters = "FunctionParameters",
|
|
145
|
+
FunctionParameter = "FunctionParameter",
|
|
146
|
+
ResourcePath = "ResourcePath",
|
|
147
|
+
CollectionNavigation = "CollectionNavigation",
|
|
148
|
+
CollectionNavigationPath = "CollectionNavigationPath",
|
|
149
|
+
SingleNavigation = "SingleNavigation",
|
|
150
|
+
PropertyPath = "PropertyPath",
|
|
151
|
+
ComplexPath = "ComplexPath",
|
|
152
|
+
BoundOperation = "BoundOperation",
|
|
153
|
+
BoundActionCall = "BoundActionCall",
|
|
154
|
+
BoundEntityFunctionCall = "BoundEntityFunctionCall",
|
|
155
|
+
BoundEntityCollectionFunctionCall = "BoundEntityCollectionFunctionCall",
|
|
156
|
+
BoundComplexFunctionCall = "BoundComplexFunctionCall",
|
|
157
|
+
BoundComplexCollectionFunctionCall = "BoundComplexCollectionFunctionCall",
|
|
158
|
+
BoundPrimitiveFunctionCall = "BoundPrimitiveFunctionCall",
|
|
159
|
+
BoundPrimitiveCollectionFunctionCall = "BoundPrimitiveCollectionFunctionCall",
|
|
160
|
+
ODataUri = "ODataUri",
|
|
161
|
+
Batch = "Batch",
|
|
162
|
+
Entity = "Entity",
|
|
163
|
+
Metadata = "Metadata",
|
|
164
|
+
InExpression= "InExpression",
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export const LexerTokenType = TokenType;
|
|
168
|
+
export type LexerTokenType = TokenType;
|
|
169
|
+
|
|
170
|
+
export class Token {
|
|
171
|
+
position: number;
|
|
172
|
+
next: number;
|
|
173
|
+
value: any;
|
|
174
|
+
type: TokenType;
|
|
175
|
+
raw: string;
|
|
176
|
+
metadata: any;
|
|
177
|
+
constructor(token) {
|
|
178
|
+
this.position = token.position;
|
|
179
|
+
this.next = token.next;
|
|
180
|
+
this.value = token.value;
|
|
181
|
+
this.type = token.type;
|
|
182
|
+
this.raw = token.raw;
|
|
183
|
+
if (token.metadata) this.metadata = token.metadata;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export const LexerToken = Token;
|
|
188
|
+
export type LexerToken = Token;
|
|
189
|
+
|
|
190
|
+
export namespace Lexer {
|
|
191
|
+
export type Token = LexerToken;
|
|
192
|
+
export const Token: typeof LexerToken = exports.Token;
|
|
193
|
+
export type TokenType = LexerTokenType;
|
|
194
|
+
export const TokenType: typeof LexerTokenType = exports.TokenType;
|
|
195
|
+
|
|
196
|
+
export function tokenize(value: Utils.SourceArray, index: number, next: number, tokenValue: any, tokenType: TokenType, metadataContextContainer?: Token): Token {
|
|
197
|
+
let token = new exports.Token({
|
|
198
|
+
position: index,
|
|
199
|
+
next: next,
|
|
200
|
+
value: tokenValue,
|
|
201
|
+
type: tokenType,
|
|
202
|
+
raw: Utils.stringify(value, index, next)
|
|
203
|
+
});
|
|
204
|
+
if (metadataContextContainer && metadataContextContainer.metadata) {
|
|
205
|
+
token.metadata = metadataContextContainer.metadata;
|
|
206
|
+
delete metadataContextContainer.metadata;
|
|
207
|
+
}
|
|
208
|
+
return token;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function clone(token): Token {
|
|
212
|
+
return new exports.Token({
|
|
213
|
+
position: token.position,
|
|
214
|
+
next: token.next,
|
|
215
|
+
value: token.value,
|
|
216
|
+
type: token.type,
|
|
217
|
+
raw: token.raw
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// core definitions
|
|
222
|
+
export function ALPHA(value: number): boolean { return (value >= 0x41 && value <= 0x5a) || (value >= 0x61 && value <= 0x7a) || value >= 0x80; }
|
|
223
|
+
export function DIGIT(value: number): boolean { return (value >= 0x30 && value <= 0x39); }
|
|
224
|
+
export function HEXDIG(value: number): boolean { return Lexer.DIGIT(value) || Lexer.AtoF(value); }
|
|
225
|
+
export function AtoF(value: number): boolean { return (value >= 0x41 && value <= 0x46) || (value >= 0x61 && value <= 0x66); }
|
|
226
|
+
export function DQUOTE(value: number): boolean { return value === 0x22; }
|
|
227
|
+
export function SP(value: number): boolean { return value === 0x20; }
|
|
228
|
+
export function HTAB(value: number): boolean { return value === 0x09; }
|
|
229
|
+
export function VCHAR(value: number): boolean { return value >= 0x21 && value <= 0x7e; }
|
|
230
|
+
|
|
231
|
+
// punctuation
|
|
232
|
+
export function whitespaceLength(value, index) {
|
|
233
|
+
if (Utils.equals(value, index, "%20") || Utils.equals(value, index, "%09")) return 3;
|
|
234
|
+
else if (Lexer.SP(value[index]) || Lexer.HTAB(value[index]) || value[index] === 0x20 || value[index] === 0x09) return 1;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function OWS(value: Utils.SourceArray, index: number): number {
|
|
238
|
+
index = index || 0;
|
|
239
|
+
let inc = Lexer.whitespaceLength(value, index);
|
|
240
|
+
while (inc) {
|
|
241
|
+
index += inc;
|
|
242
|
+
inc = Lexer.whitespaceLength(value, index);
|
|
243
|
+
}
|
|
244
|
+
return index;
|
|
245
|
+
}
|
|
246
|
+
export function RWS(value: Utils.SourceArray, index: number): number {
|
|
247
|
+
return Lexer.OWS(value, index);
|
|
248
|
+
}
|
|
249
|
+
export function BWS(value: Utils.SourceArray, index: number): number {
|
|
250
|
+
return Lexer.OWS(value, index);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function AT(value: Utils.SourceArray, index: number): number {
|
|
254
|
+
if (value[index] === 0x40) return index + 1;
|
|
255
|
+
else if (Utils.equals(value, index, "%40")) return index + 3;
|
|
256
|
+
}
|
|
257
|
+
export function COLON(value: Utils.SourceArray, index: number): number {
|
|
258
|
+
if (value[index] === 0x3a) return index + 1;
|
|
259
|
+
else if (Utils.equals(value, index, "%3A")) return index + 3;
|
|
260
|
+
}
|
|
261
|
+
export function COMMA(value: Utils.SourceArray, index: number): number {
|
|
262
|
+
if (value[index] === 0x2c) return index + 1;
|
|
263
|
+
else if (Utils.equals(value, index, "%2C")) return index + 3;
|
|
264
|
+
}
|
|
265
|
+
export function EQ(value: Utils.SourceArray, index: number): number {
|
|
266
|
+
if (value[index] === 0x3d) return index + 1;
|
|
267
|
+
}
|
|
268
|
+
export function SIGN(value: Utils.SourceArray, index: number): number {
|
|
269
|
+
if (value[index] === 0x2b || value[index] === 0x2d) return index + 1;
|
|
270
|
+
else if (Utils.equals(value, index, "%2B")) return index + 3;
|
|
271
|
+
}
|
|
272
|
+
export function SEMI(value: Utils.SourceArray, index: number): number {
|
|
273
|
+
if (value[index] === 0x3b) return index + 1;
|
|
274
|
+
else if (Utils.equals(value, index, "%3B")) return index + 3;
|
|
275
|
+
}
|
|
276
|
+
export function STAR(value: Utils.SourceArray, index: number): number {
|
|
277
|
+
if (value[index] === 0x2a) return index + 1;
|
|
278
|
+
else if (Utils.equals(value, index, "%2A")) return index + 3;
|
|
279
|
+
}
|
|
280
|
+
export function SQUOTE(value: Utils.SourceArray, index: number): number {
|
|
281
|
+
if (value[index] === 0x27) return index + 1;
|
|
282
|
+
else if (Utils.equals(value, index, "%27")) return index + 3;
|
|
283
|
+
}
|
|
284
|
+
export function OPEN(value: Utils.SourceArray, index: number): number {
|
|
285
|
+
if (value[index] === 0x28) return index + 1;
|
|
286
|
+
else if (Utils.equals(value, index, "%28")) return index + 3;
|
|
287
|
+
}
|
|
288
|
+
export function CLOSE(value: Utils.SourceArray, index: number): number {
|
|
289
|
+
if (value[index] === 0x29) return index + 1;
|
|
290
|
+
else if (Utils.equals(value, index, "%29")) return index + 3;
|
|
291
|
+
}
|
|
292
|
+
// unreserved ALPHA / DIGIT / "-" / "." / "_" / "~"
|
|
293
|
+
export function unreserved(value: number): boolean { return Lexer.ALPHA(value) || Lexer.DIGIT(value) || value === 0x2d || value === 0x2e || value === 0x5f || value === 0x7e; }
|
|
294
|
+
// other-delims "!" / "(" / ")" / "*" / "+" / "," / ";"
|
|
295
|
+
export function otherDelims(value: Utils.SourceArray, index: number): number {
|
|
296
|
+
if (value[index] === 0x21 || value[index] === 0x2b) return index + 1;
|
|
297
|
+
else return Lexer.OPEN(value, index) || Lexer.CLOSE(value, index) || Lexer.STAR(value, index) || Lexer.COMMA(value, index) || Lexer.SEMI(value, index);
|
|
298
|
+
}
|
|
299
|
+
// sub-delims = "$" / "&" / "'" / "=" / other-delims
|
|
300
|
+
export function subDelims(value: Utils.SourceArray, index: number): number {
|
|
301
|
+
if (value[index] === 0x24 || value[index] === 0x26) return index + 1;
|
|
302
|
+
else return Lexer.SQUOTE(value, index) || Lexer.EQ(value, index) || Lexer.otherDelims(value, index);
|
|
303
|
+
}
|
|
304
|
+
export function pctEncoded(value: Utils.SourceArray, index: number): number {
|
|
305
|
+
if (value[index] !== 0x25 || !Lexer.HEXDIG(value[index + 1]) || !Lexer.HEXDIG(value[index + 2])) return index;
|
|
306
|
+
return index + 3;
|
|
307
|
+
}
|
|
308
|
+
// pct-encoded-no-SQUOTE = "%" ( "0" / "1" / "3" / "4" / "5" / "6" / "8" / "9" / A-to-F ) HEXDIG
|
|
309
|
+
// / "%" "2" ( "0" / "1" / "2" / "3" / "4" / "5" / "6" / "8" / "9" / A-to-F )
|
|
310
|
+
export function pctEncodedNoSQUOTE(value: Utils.SourceArray, index: number): number {
|
|
311
|
+
if (Utils.equals(value, index, "%27")) return index;
|
|
312
|
+
return Lexer.pctEncoded(value, index);
|
|
313
|
+
}
|
|
314
|
+
export function pctEncodedUnescaped(value: Utils.SourceArray, index: number): number {
|
|
315
|
+
if (Utils.equals(value, index, "%22") ||
|
|
316
|
+
Utils.equals(value, index, "%3") ||
|
|
317
|
+
Utils.equals(value, index, "%4") ||
|
|
318
|
+
Utils.equals(value, index, "%5C")) return index;
|
|
319
|
+
return Lexer.pctEncoded(value, index);
|
|
320
|
+
}
|
|
321
|
+
export function pchar(value: Utils.SourceArray, index: number): number {
|
|
322
|
+
if (Lexer.unreserved(value[index])) return index + 1;
|
|
323
|
+
else return Lexer.subDelims(value, index) || Lexer.COLON(value, index) || Lexer.AT(value, index) || Lexer.pctEncoded(value, index) || index;
|
|
324
|
+
}
|
|
325
|
+
export function pcharNoSQUOTE(value: Utils.SourceArray, index: number): number {
|
|
326
|
+
if (Lexer.unreserved(value[index]) || value[index] === 0x24 || value[index] === 0x26) return index + 1;
|
|
327
|
+
else return Lexer.otherDelims(value, index) || Lexer.EQ(value, index) || Lexer.COLON(value, index) || Lexer.AT(value, index) || Lexer.pctEncodedNoSQUOTE(value, index) || index;
|
|
328
|
+
}
|
|
329
|
+
export function qcharNoAMP(value: Utils.SourceArray, index: number): number {
|
|
330
|
+
if (Lexer.unreserved(value[index]) || value[index] === 0x3a || value[index] === 0x40 || value[index] === 0x2f || value[index] === 0x3f || value[index] === 0x24 || value[index] === 0x27 || value[index] === 0x3d) return index + 1;
|
|
331
|
+
else return Lexer.pctEncoded(value, index) || Lexer.otherDelims(value, index) || index;
|
|
332
|
+
}
|
|
333
|
+
export function qcharNoAMPDQUOTE(value: Utils.SourceArray, index: number): number {
|
|
334
|
+
index = Lexer.BWS(value, index);
|
|
335
|
+
if (Lexer.unreserved(value[index]) || value[index] === 0x3a || value[index] === 0x40 || value[index] === 0x2f || value[index] === 0x3f || value[index] === 0x24 || value[index] === 0x27 || value[index] === 0x3d) return index + 1;
|
|
336
|
+
else return Lexer.otherDelims(value, index) || Lexer.pctEncodedUnescaped(value, index);
|
|
337
|
+
}
|
|
338
|
+
// export function pchar(value:number):boolean { return unreserved(value) || otherDelims(value) || value == 0x24 || value == 0x26 || EQ(value) || COLON(value) || AT(value); }
|
|
339
|
+
export function base64char(value: number): boolean { return Lexer.ALPHA(value) || Lexer.DIGIT(value) || value === 0x2d || value === 0x5f; }
|
|
340
|
+
export function base64b16(value: Utils.SourceArray, index: number): number {
|
|
341
|
+
let start = index;
|
|
342
|
+
if (!Lexer.base64char(value[index]) && !Lexer.base64char(value[index + 1])) return start;
|
|
343
|
+
index += 2;
|
|
344
|
+
|
|
345
|
+
if (!Utils.is(value[index], "AEIMQUYcgkosw048")) return start;
|
|
346
|
+
index++;
|
|
347
|
+
|
|
348
|
+
if (value[index] === 0x3d) index++;
|
|
349
|
+
return index;
|
|
350
|
+
}
|
|
351
|
+
export function base64b8(value: Utils.SourceArray, index: number): number {
|
|
352
|
+
let start = index;
|
|
353
|
+
if (!Lexer.base64char(value[index])) return start;
|
|
354
|
+
index++;
|
|
355
|
+
|
|
356
|
+
if (value[index] !== 0x41 || value[index] !== 0x51 || value[index] !== 0x67 || value[index] !== 0x77) return start;
|
|
357
|
+
index++;
|
|
358
|
+
|
|
359
|
+
if (value[index] === 0x3d && value[index + 1] === 0x3d) index += 2;
|
|
360
|
+
return index;
|
|
361
|
+
}
|
|
362
|
+
export function nanInfinity(value: Utils.SourceArray, index: number): number {
|
|
363
|
+
return Utils.equals(value, index, "NaN") || Utils.equals(value, index, "-INF") || Utils.equals(value, index, "INF");
|
|
364
|
+
}
|
|
365
|
+
export function oneToNine(value: number): boolean { return value !== 0x30 && Lexer.DIGIT(value); }
|
|
366
|
+
export function zeroToFiftyNine(value: Utils.SourceArray, index: number): number {
|
|
367
|
+
if (value[index] >= 0x30 && value[index] <= 0x35 && Lexer.DIGIT(value[index + 1])) return index + 2;
|
|
368
|
+
return index;
|
|
369
|
+
}
|
|
370
|
+
export function year(value: Utils.SourceArray, index: number): number {
|
|
371
|
+
let start = index;
|
|
372
|
+
let end = index;
|
|
373
|
+
if (value[index] === 0x2d) index++;
|
|
374
|
+
if ((value[index] === 0x30 && (end = Utils.required(value, index + 1, Lexer.DIGIT, 3, 3))) ||
|
|
375
|
+
(Lexer.oneToNine(value[index]) && (end = Utils.required(value, index + 1, Lexer.DIGIT, 3)))) return end;
|
|
376
|
+
return start;
|
|
377
|
+
}
|
|
378
|
+
export function month(value: Utils.SourceArray, index: number): number {
|
|
379
|
+
if ((value[index] === 0x30 && Lexer.oneToNine(value[index + 1])) ||
|
|
380
|
+
(value[index] === 0x31 && value[index + 1] >= 0x30 && value[index + 1] <= 0x32)) return index + 2;
|
|
381
|
+
return index;
|
|
382
|
+
}
|
|
383
|
+
export function day(value: Utils.SourceArray, index: number): number {
|
|
384
|
+
if ((value[index] === 0x30 && Lexer.oneToNine(value[index + 1])) ||
|
|
385
|
+
((value[index] === 0x31 || value[index] === 0x32) && Lexer.DIGIT(value[index + 1])) ||
|
|
386
|
+
(value[index] === 0x33 && (value[index + 1] === 0x30 || value[index + 1] === 0x31))) return index + 2;
|
|
387
|
+
return index;
|
|
388
|
+
}
|
|
389
|
+
export function hour(value: Utils.SourceArray, index: number): number {
|
|
390
|
+
if (((value[index] === 0x30 || value[index] === 0x31) && Lexer.DIGIT(value[index + 1])) ||
|
|
391
|
+
(value[index] === 0x32 && (value[index + 1] === 0x30 || value[index + 1] === 0x31 || value[index + 1] === 0x32 || value[index + 1] === 0x33))) return index + 2;
|
|
392
|
+
return index;
|
|
393
|
+
}
|
|
394
|
+
export function minute(value: Utils.SourceArray, index: number): number {
|
|
395
|
+
return Lexer.zeroToFiftyNine(value, index);
|
|
396
|
+
}
|
|
397
|
+
export function second(value: Utils.SourceArray, index: number): number {
|
|
398
|
+
return Lexer.zeroToFiftyNine(value, index);
|
|
399
|
+
}
|
|
400
|
+
export function fractionalSeconds(value: Utils.SourceArray, index: number): number {
|
|
401
|
+
return Utils.required(value, index, DIGIT, 1, 12);
|
|
402
|
+
}
|
|
403
|
+
export function geographyPrefix(value: Utils.SourceArray, index: number): number {
|
|
404
|
+
return Utils.equals(value, index, "geography") ? index + 9 : index;
|
|
405
|
+
}
|
|
406
|
+
export function geometryPrefix(value: Utils.SourceArray, index: number): number {
|
|
407
|
+
return Utils.equals(value, index, "geometry") ? index + 8 : index;
|
|
408
|
+
}
|
|
409
|
+
export function identifierLeadingCharacter(value: number): boolean {
|
|
410
|
+
return Lexer.ALPHA(value) || value === 0x5f;
|
|
411
|
+
}
|
|
412
|
+
export function identifierCharacter(value: number): boolean {
|
|
413
|
+
return Lexer.identifierLeadingCharacter(value) || Lexer.DIGIT(value);
|
|
414
|
+
}
|
|
415
|
+
export function beginObject(value: Utils.SourceArray, index: number): number {
|
|
416
|
+
let bws = Lexer.BWS(value, index);
|
|
417
|
+
let start = index;
|
|
418
|
+
index = bws;
|
|
419
|
+
if (Utils.equals(value, index, "{")) index++;
|
|
420
|
+
else if (Utils.equals(value, index, "%7B")) index += 3;
|
|
421
|
+
if (index === bws) return start;
|
|
422
|
+
|
|
423
|
+
bws = Lexer.BWS(value, index);
|
|
424
|
+
return bws;
|
|
425
|
+
}
|
|
426
|
+
export function endObject(value: Utils.SourceArray, index: number): number {
|
|
427
|
+
let bws = Lexer.BWS(value, index);
|
|
428
|
+
let start = index;
|
|
429
|
+
index = bws;
|
|
430
|
+
if (Utils.equals(value, index, "}")) index++;
|
|
431
|
+
else if (Utils.equals(value, index, "%7D")) index += 3;
|
|
432
|
+
if (index === bws) return start;
|
|
433
|
+
|
|
434
|
+
bws = Lexer.BWS(value, index);
|
|
435
|
+
return bws;
|
|
436
|
+
}
|
|
437
|
+
export function beginArray(value: Utils.SourceArray, index: number): number {
|
|
438
|
+
let bws = Lexer.BWS(value, index);
|
|
439
|
+
let start = index;
|
|
440
|
+
index = bws;
|
|
441
|
+
if (Utils.equals(value, index, "[")) index++;
|
|
442
|
+
else if (Utils.equals(value, index, "%5B")) index += 3;
|
|
443
|
+
if (index === bws) return start;
|
|
444
|
+
|
|
445
|
+
bws = Lexer.BWS(value, index);
|
|
446
|
+
return bws;
|
|
447
|
+
}
|
|
448
|
+
export function endArray(value: Utils.SourceArray, index: number): number {
|
|
449
|
+
let bws = Lexer.BWS(value, index);
|
|
450
|
+
let start = index;
|
|
451
|
+
index = bws;
|
|
452
|
+
if (Utils.equals(value, index, "]")) index++;
|
|
453
|
+
else if (Utils.equals(value, index, "%5D")) index += 3;
|
|
454
|
+
if (index === bws) return start;
|
|
455
|
+
|
|
456
|
+
bws = Lexer.BWS(value, index);
|
|
457
|
+
return bws;
|
|
458
|
+
}
|
|
459
|
+
export function quotationMark(value: Utils.SourceArray, index: number): number {
|
|
460
|
+
if (Lexer.DQUOTE(value[index])) return index + 1;
|
|
461
|
+
if (Utils.equals(value, index, "%22")) return index + 3;
|
|
462
|
+
return index;
|
|
463
|
+
}
|
|
464
|
+
export function nameSeparator(value: Utils.SourceArray, index: number): number {
|
|
465
|
+
let bws = Lexer.BWS(value, index);
|
|
466
|
+
let start = index;
|
|
467
|
+
index = bws;
|
|
468
|
+
let colon = Lexer.COLON(value, index);
|
|
469
|
+
if (!colon) return start;
|
|
470
|
+
index = colon;
|
|
471
|
+
bws = Lexer.BWS(value, index);
|
|
472
|
+
return bws;
|
|
473
|
+
}
|
|
474
|
+
export function valueSeparator(value: Utils.SourceArray, index: number): number {
|
|
475
|
+
let bws = Lexer.BWS(value, index);
|
|
476
|
+
let start = index;
|
|
477
|
+
index = bws;
|
|
478
|
+
let comma = Lexer.COMMA(value, index);
|
|
479
|
+
if (!comma) return start;
|
|
480
|
+
index = comma;
|
|
481
|
+
bws = Lexer.BWS(value, index);
|
|
482
|
+
return bws;
|
|
483
|
+
}
|
|
484
|
+
export function escape(value: Utils.SourceArray, index: number): number {
|
|
485
|
+
if (Utils.equals(value, index, "\\")) return index + 1;
|
|
486
|
+
if (Utils.equals(value, index, "%5C")) return index + 3;
|
|
487
|
+
return index;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export default Lexer;
|