@aeriajs/compiler 0.0.14 → 0.0.15
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/dist/ast.d.ts +1 -0
- package/dist/ast.js +1 -0
- package/dist/ast.mjs +2 -1
- package/dist/parser.js +25 -0
- package/dist/parser.mjs +25 -0
- package/dist/token.d.ts +2 -0
- package/dist/token.js +1 -0
- package/dist/token.mjs +1 -0
- package/package.json +1 -1
package/dist/ast.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const PropertyType: {
|
|
|
9
9
|
readonly enum: "enum";
|
|
10
10
|
readonly date: "string";
|
|
11
11
|
readonly datetime: "string";
|
|
12
|
+
readonly const: "const";
|
|
12
13
|
};
|
|
13
14
|
export declare const PropertyModifiers: Record<'Error' | 'Result', ExportSymbol>;
|
|
14
15
|
export type ExportSymbol = {
|
package/dist/ast.js
CHANGED
package/dist/ast.mjs
CHANGED
package/dist/parser.js
CHANGED
|
@@ -179,6 +179,9 @@ const parse = (tokens) => {
|
|
|
179
179
|
array.push(identifier);
|
|
180
180
|
symbols.push(elemSymbol);
|
|
181
181
|
exports.locationMap.set(elemSymbol, location);
|
|
182
|
+
if (match(token_js_1.TokenType.Comma)) {
|
|
183
|
+
consume(token_js_1.TokenType.Comma);
|
|
184
|
+
}
|
|
182
185
|
}
|
|
183
186
|
consume(token_js_1.TokenType.RightBracket);
|
|
184
187
|
return {
|
|
@@ -225,6 +228,22 @@ const parse = (tokens) => {
|
|
|
225
228
|
]).value;
|
|
226
229
|
return;
|
|
227
230
|
}
|
|
231
|
+
if ('const' in property && attributeName === 'value') {
|
|
232
|
+
const token = current();
|
|
233
|
+
advance();
|
|
234
|
+
switch (token.type) {
|
|
235
|
+
case token_js_1.TokenType.Number:
|
|
236
|
+
case token_js_1.TokenType.Boolean:
|
|
237
|
+
case token_js_1.TokenType.Null:
|
|
238
|
+
case token_js_1.TokenType.QuotedString: {
|
|
239
|
+
property.const = token.value;
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
default: {
|
|
243
|
+
throw new diagnostic_js_1.Diagnostic(`const received invalid value: "${token.value}"`, location);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
228
247
|
switch (attributeName) {
|
|
229
248
|
case 'icon': {
|
|
230
249
|
const { value } = consume(token_js_1.TokenType.QuotedString, ICON_NAMES);
|
|
@@ -461,6 +480,12 @@ const parse = (tokens) => {
|
|
|
461
480
|
};
|
|
462
481
|
break;
|
|
463
482
|
}
|
|
483
|
+
case 'const': {
|
|
484
|
+
property = {
|
|
485
|
+
const: null,
|
|
486
|
+
};
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
464
489
|
case 'date': {
|
|
465
490
|
property = {
|
|
466
491
|
type: 'string',
|
package/dist/parser.mjs
CHANGED
|
@@ -141,6 +141,9 @@ export const parse = (tokens) => {
|
|
|
141
141
|
array.push(identifier);
|
|
142
142
|
symbols.push(elemSymbol);
|
|
143
143
|
locationMap.set(elemSymbol, location);
|
|
144
|
+
if (match(TokenType.Comma)) {
|
|
145
|
+
consume(TokenType.Comma);
|
|
146
|
+
}
|
|
144
147
|
}
|
|
145
148
|
consume(TokenType.RightBracket);
|
|
146
149
|
return {
|
|
@@ -184,6 +187,22 @@ export const parse = (tokens) => {
|
|
|
184
187
|
]).value;
|
|
185
188
|
return;
|
|
186
189
|
}
|
|
190
|
+
if ("const" in property && attributeName === "value") {
|
|
191
|
+
const token = current();
|
|
192
|
+
advance();
|
|
193
|
+
switch (token.type) {
|
|
194
|
+
case TokenType.Number:
|
|
195
|
+
case TokenType.Boolean:
|
|
196
|
+
case TokenType.Null:
|
|
197
|
+
case TokenType.QuotedString: {
|
|
198
|
+
property.const = token.value;
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
default: {
|
|
202
|
+
throw new Diagnostic(`const received invalid value: "${token.value}"`, location);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
187
206
|
switch (attributeName) {
|
|
188
207
|
case "icon": {
|
|
189
208
|
const { value } = consume(TokenType.QuotedString, ICON_NAMES);
|
|
@@ -416,6 +435,12 @@ export const parse = (tokens) => {
|
|
|
416
435
|
};
|
|
417
436
|
break;
|
|
418
437
|
}
|
|
438
|
+
case "const": {
|
|
439
|
+
property = {
|
|
440
|
+
const: null
|
|
441
|
+
};
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
419
444
|
case "date": {
|
|
420
445
|
property = {
|
|
421
446
|
type: "string",
|
package/dist/token.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const TokenType: {
|
|
|
12
12
|
readonly Dot: "DOT";
|
|
13
13
|
readonly Number: "NUMBER";
|
|
14
14
|
readonly Boolean: "BOOLEAN";
|
|
15
|
+
readonly Null: "NULL";
|
|
15
16
|
readonly Keyword: "KEYWORD";
|
|
16
17
|
readonly Identifier: "IDENTIFIER";
|
|
17
18
|
readonly QuotedString: "QUOTED_STRING";
|
|
@@ -23,6 +24,7 @@ export type TokenType = typeof TokenType[keyof typeof TokenType];
|
|
|
23
24
|
export type TypeMap = {
|
|
24
25
|
[TokenType.Number]: number;
|
|
25
26
|
[TokenType.Boolean]: boolean;
|
|
27
|
+
[TokenType.Null]: null;
|
|
26
28
|
[TokenType.Range]: readonly [number, number];
|
|
27
29
|
};
|
|
28
30
|
export type Location = {
|
package/dist/token.js
CHANGED
package/dist/token.mjs
CHANGED