@aeriajs/compiler 0.0.23 → 0.0.25
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 +9 -1
- package/dist/codegen/generateJSCollections.js +3 -0
- package/dist/codegen/generateJSCollections.mjs +3 -0
- package/dist/lexer.d.ts +4 -2
- package/dist/lexer.js +47 -11
- package/dist/lexer.mjs +47 -8
- package/dist/parser.js +73 -0
- package/dist/parser.mjs +73 -1
- package/dist/semantic.js +22 -1
- package/dist/semantic.mjs +21 -1
- package/package.json +3 -3
package/dist/ast.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Property, AccessCondition, CollectionActions, SearchOptions, DescriptionPreset, Icon, OwnershipMode } from '@aeriajs/types';
|
|
1
|
+
import type { Property, AccessCondition, CollectionActions, SearchOptions, DescriptionPreset, Icon, OwnershipMode, Layout, LayoutOptions } from '@aeriajs/types';
|
|
2
2
|
import type { ArrayProperties } from './utils.js';
|
|
3
3
|
export declare const LOCATION_SYMBOL: unique symbol;
|
|
4
4
|
export declare const PropertyType: {
|
|
@@ -19,6 +19,13 @@ export type ExportSymbol = {
|
|
|
19
19
|
export type NodeBase<TType> = {
|
|
20
20
|
kind: TType;
|
|
21
21
|
};
|
|
22
|
+
export type LayoutNode = NodeBase<'layout'> & Layout & {
|
|
23
|
+
[LOCATION_SYMBOL]: {
|
|
24
|
+
options: {
|
|
25
|
+
[P in keyof LayoutOptions]?: readonly string[] extends LayoutOptions[P] ? symbol | symbol[] : symbol;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
22
29
|
export type PropertyNode = NodeBase<'property'> & {
|
|
23
30
|
modifier?: keyof typeof PropertyModifiers;
|
|
24
31
|
property: Property & {
|
|
@@ -53,6 +60,7 @@ export type CollectionNode = NodeBase<'collection'> & {
|
|
|
53
60
|
table?: string[];
|
|
54
61
|
filters?: string[];
|
|
55
62
|
search?: SearchOptions<any>;
|
|
63
|
+
layout?: LayoutNode;
|
|
56
64
|
[LOCATION_SYMBOL]: {
|
|
57
65
|
arrays: {
|
|
58
66
|
[P in ArrayProperties<CollectionNode>]?: symbol[];
|
|
@@ -77,6 +77,9 @@ const makeJSCollectionSchema = (collectionNode, collectionId) => {
|
|
|
77
77
|
case 'search':
|
|
78
78
|
collectionSchema.description[key] = collectionNode[key];
|
|
79
79
|
break;
|
|
80
|
+
case 'layout':
|
|
81
|
+
collectionSchema.description[key] = collectionNode[key];
|
|
82
|
+
break;
|
|
80
83
|
case 'required':
|
|
81
84
|
collectionSchema.description[key] = collectionNode[key];
|
|
82
85
|
break;
|
|
@@ -70,6 +70,9 @@ const makeJSCollectionSchema = (collectionNode, collectionId) => {
|
|
|
70
70
|
case "search":
|
|
71
71
|
collectionSchema.description[key] = collectionNode[key];
|
|
72
72
|
break;
|
|
73
|
+
case "layout":
|
|
74
|
+
collectionSchema.description[key] = collectionNode[key];
|
|
75
|
+
break;
|
|
73
76
|
case "required":
|
|
74
77
|
collectionSchema.description[key] = collectionNode[key];
|
|
75
78
|
break;
|
package/dist/lexer.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { type Token } from './token.js';
|
|
2
2
|
import { Diagnostic } from './diagnostic.js';
|
|
3
|
-
export
|
|
4
|
-
export declare const COLLECTION_KEYWORDS: readonly ["actions", "additionalProperties", "filters", "form", "functions", "icon", "indexes", "individualActions", "owned", "presets", "properties", "required", "search", "table"];
|
|
3
|
+
export declare const COLLECTION_KEYWORDS: readonly ["actions", "additionalProperties", "filters", "form", "functions", "icon", "indexes", "individualActions", "layout", "owned", "presets", "properties", "required", "search", "table"];
|
|
5
4
|
export declare const COLLECTION_ACTIONS_KEYWORDS: readonly ["ask", "button", "clearItem", "effect", "event", "fetchItem", "function", "icon", "label", "params", "query", "requires", "roles", "route", "selection", "setItem", "translate"];
|
|
6
5
|
export declare const COLLECTION_SEARCH_KEYWORDS: readonly ["indexes", "placeholder", "exactMatches"];
|
|
6
|
+
export declare const COLLECTION_LAYOUT_KEYWORDS: readonly ["name", "options"];
|
|
7
|
+
export declare const COLLECTION_LAYOUT_OPTIONS_KEYWORDS: readonly ["title", "picture", "badge", "information", "active", "translateBadge"];
|
|
7
8
|
export declare const CONTRACT_KEYWORDS: readonly ["roles", "payload", "query", "response"];
|
|
8
9
|
export declare const TOPLEVEL_KEYWORDS: readonly ["collection", "contract", "functionset"];
|
|
9
10
|
export declare const MISC_KEYWORDS: readonly ["extends"];
|
|
11
|
+
export type Keyword = typeof COLLECTION_KEYWORDS[number] | typeof COLLECTION_ACTIONS_KEYWORDS[number] | typeof COLLECTION_SEARCH_KEYWORDS[number] | typeof COLLECTION_LAYOUT_KEYWORDS[number] | typeof COLLECTION_LAYOUT_OPTIONS_KEYWORDS[number] | typeof CONTRACT_KEYWORDS[number] | typeof TOPLEVEL_KEYWORDS[number] | typeof MISC_KEYWORDS[number];
|
|
10
12
|
export declare const KEYWORDS: Keyword[];
|
|
11
13
|
export declare const tokenize: (rawInput: string) => {
|
|
12
14
|
tokens: Token[];
|
package/dist/lexer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tokenize = exports.KEYWORDS = exports.MISC_KEYWORDS = exports.TOPLEVEL_KEYWORDS = exports.CONTRACT_KEYWORDS = exports.COLLECTION_SEARCH_KEYWORDS = exports.COLLECTION_ACTIONS_KEYWORDS = exports.COLLECTION_KEYWORDS = void 0;
|
|
3
|
+
exports.tokenize = exports.KEYWORDS = exports.MISC_KEYWORDS = exports.TOPLEVEL_KEYWORDS = exports.CONTRACT_KEYWORDS = exports.COLLECTION_LAYOUT_OPTIONS_KEYWORDS = exports.COLLECTION_LAYOUT_KEYWORDS = exports.COLLECTION_SEARCH_KEYWORDS = exports.COLLECTION_ACTIONS_KEYWORDS = exports.COLLECTION_KEYWORDS = void 0;
|
|
4
4
|
const token_js_1 = require("./token.js");
|
|
5
5
|
const diagnostic_js_1 = require("./diagnostic.js");
|
|
6
6
|
exports.COLLECTION_KEYWORDS = [
|
|
@@ -12,6 +12,7 @@ exports.COLLECTION_KEYWORDS = [
|
|
|
12
12
|
'icon',
|
|
13
13
|
'indexes',
|
|
14
14
|
'individualActions',
|
|
15
|
+
'layout',
|
|
15
16
|
'owned',
|
|
16
17
|
'presets',
|
|
17
18
|
'properties',
|
|
@@ -43,6 +44,18 @@ exports.COLLECTION_SEARCH_KEYWORDS = [
|
|
|
43
44
|
'placeholder',
|
|
44
45
|
'exactMatches',
|
|
45
46
|
];
|
|
47
|
+
exports.COLLECTION_LAYOUT_KEYWORDS = [
|
|
48
|
+
'name',
|
|
49
|
+
'options',
|
|
50
|
+
];
|
|
51
|
+
exports.COLLECTION_LAYOUT_OPTIONS_KEYWORDS = [
|
|
52
|
+
'title',
|
|
53
|
+
'picture',
|
|
54
|
+
'badge',
|
|
55
|
+
'information',
|
|
56
|
+
'active',
|
|
57
|
+
'translateBadge',
|
|
58
|
+
];
|
|
46
59
|
exports.CONTRACT_KEYWORDS = [
|
|
47
60
|
'roles',
|
|
48
61
|
'payload',
|
|
@@ -55,7 +68,7 @@ exports.TOPLEVEL_KEYWORDS = [
|
|
|
55
68
|
'functionset',
|
|
56
69
|
];
|
|
57
70
|
exports.MISC_KEYWORDS = ['extends'];
|
|
58
|
-
exports.KEYWORDS = [].concat(exports.COLLECTION_KEYWORDS, exports.COLLECTION_ACTIONS_KEYWORDS, exports.COLLECTION_SEARCH_KEYWORDS, exports.CONTRACT_KEYWORDS, exports.TOPLEVEL_KEYWORDS, exports.MISC_KEYWORDS);
|
|
71
|
+
exports.KEYWORDS = [].concat(exports.COLLECTION_KEYWORDS, exports.COLLECTION_ACTIONS_KEYWORDS, exports.COLLECTION_SEARCH_KEYWORDS, exports.COLLECTION_LAYOUT_KEYWORDS, exports.COLLECTION_LAYOUT_OPTIONS_KEYWORDS, exports.CONTRACT_KEYWORDS, exports.TOPLEVEL_KEYWORDS, exports.MISC_KEYWORDS);
|
|
59
72
|
const keywordsSet = new Set();
|
|
60
73
|
for (const keyword of exports.KEYWORDS) {
|
|
61
74
|
keywordsSet.add(keyword);
|
|
@@ -136,7 +149,20 @@ const TOKENS = [
|
|
|
136
149
|
{
|
|
137
150
|
type: token_js_1.TokenType.Keyword,
|
|
138
151
|
matcher: Array.from(keywordsSet),
|
|
139
|
-
condition: (state) =>
|
|
152
|
+
condition: (state, lastToken) => {
|
|
153
|
+
if (state.inPropertiesStack.at(-1)) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (lastToken && lastToken.type === token_js_1.TokenType.Keyword) {
|
|
157
|
+
switch (lastToken.value) {
|
|
158
|
+
case 'badge':
|
|
159
|
+
case 'title': {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
},
|
|
140
166
|
},
|
|
141
167
|
{
|
|
142
168
|
type: token_js_1.TokenType.MacroName,
|
|
@@ -171,8 +197,9 @@ const tokenize = function (rawInput) {
|
|
|
171
197
|
for (const { type, matcher, valueExtractor, construct, condition } of TOKENS) {
|
|
172
198
|
let value;
|
|
173
199
|
let token;
|
|
200
|
+
const lastToken = tokens.at(-1);
|
|
174
201
|
if (condition) {
|
|
175
|
-
if (!condition(state)) {
|
|
202
|
+
if (!condition(state, lastToken)) {
|
|
176
203
|
continue;
|
|
177
204
|
}
|
|
178
205
|
}
|
|
@@ -233,13 +260,22 @@ const tokenize = function (rawInput) {
|
|
|
233
260
|
};
|
|
234
261
|
switch (type) {
|
|
235
262
|
case token_js_1.TokenType.LeftBracket: {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
263
|
+
if (lastToken && lastToken.type === token_js_1.TokenType.Keyword) {
|
|
264
|
+
switch (lastToken.value) {
|
|
265
|
+
case 'information':
|
|
266
|
+
case 'form':
|
|
267
|
+
case 'table':
|
|
268
|
+
case 'indexes':
|
|
269
|
+
case 'filters':
|
|
270
|
+
case 'writable':
|
|
271
|
+
case 'required':
|
|
272
|
+
case 'properties': {
|
|
273
|
+
state.inPropertiesStack.push(true);
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
default: {
|
|
277
|
+
state.inPropertiesStack.push(false);
|
|
278
|
+
}
|
|
243
279
|
}
|
|
244
280
|
}
|
|
245
281
|
break;
|
package/dist/lexer.mjs
CHANGED
|
@@ -10,6 +10,7 @@ export const COLLECTION_KEYWORDS = [
|
|
|
10
10
|
"icon",
|
|
11
11
|
"indexes",
|
|
12
12
|
"individualActions",
|
|
13
|
+
"layout",
|
|
13
14
|
"owned",
|
|
14
15
|
"presets",
|
|
15
16
|
"properties",
|
|
@@ -41,6 +42,18 @@ export const COLLECTION_SEARCH_KEYWORDS = [
|
|
|
41
42
|
"placeholder",
|
|
42
43
|
"exactMatches"
|
|
43
44
|
];
|
|
45
|
+
export const COLLECTION_LAYOUT_KEYWORDS = [
|
|
46
|
+
"name",
|
|
47
|
+
"options"
|
|
48
|
+
];
|
|
49
|
+
export const COLLECTION_LAYOUT_OPTIONS_KEYWORDS = [
|
|
50
|
+
"title",
|
|
51
|
+
"picture",
|
|
52
|
+
"badge",
|
|
53
|
+
"information",
|
|
54
|
+
"active",
|
|
55
|
+
"translateBadge"
|
|
56
|
+
];
|
|
44
57
|
export const CONTRACT_KEYWORDS = [
|
|
45
58
|
"roles",
|
|
46
59
|
"payload",
|
|
@@ -57,6 +70,8 @@ export const KEYWORDS = [].concat(
|
|
|
57
70
|
COLLECTION_KEYWORDS,
|
|
58
71
|
COLLECTION_ACTIONS_KEYWORDS,
|
|
59
72
|
COLLECTION_SEARCH_KEYWORDS,
|
|
73
|
+
COLLECTION_LAYOUT_KEYWORDS,
|
|
74
|
+
COLLECTION_LAYOUT_OPTIONS_KEYWORDS,
|
|
60
75
|
CONTRACT_KEYWORDS,
|
|
61
76
|
TOPLEVEL_KEYWORDS,
|
|
62
77
|
MISC_KEYWORDS
|
|
@@ -141,7 +156,20 @@ const TOKENS = [
|
|
|
141
156
|
{
|
|
142
157
|
type: TokenType.Keyword,
|
|
143
158
|
matcher: Array.from(keywordsSet),
|
|
144
|
-
condition: (state) =>
|
|
159
|
+
condition: (state, lastToken) => {
|
|
160
|
+
if (state.inPropertiesStack.at(-1)) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
if (lastToken && lastToken.type === TokenType.Keyword) {
|
|
164
|
+
switch (lastToken.value) {
|
|
165
|
+
case "badge":
|
|
166
|
+
case "title": {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
145
173
|
},
|
|
146
174
|
{
|
|
147
175
|
type: TokenType.MacroName,
|
|
@@ -176,8 +204,9 @@ export const tokenize = function(rawInput) {
|
|
|
176
204
|
for (const { type, matcher, valueExtractor, construct, condition } of TOKENS) {
|
|
177
205
|
let value;
|
|
178
206
|
let token;
|
|
207
|
+
const lastToken = tokens.at(-1);
|
|
179
208
|
if (condition) {
|
|
180
|
-
if (!condition(state)) {
|
|
209
|
+
if (!condition(state, lastToken)) {
|
|
181
210
|
continue;
|
|
182
211
|
}
|
|
183
212
|
}
|
|
@@ -233,12 +262,22 @@ export const tokenize = function(rawInput) {
|
|
|
233
262
|
};
|
|
234
263
|
switch (type) {
|
|
235
264
|
case TokenType.LeftBracket: {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
265
|
+
if (lastToken && lastToken.type === TokenType.Keyword) {
|
|
266
|
+
switch (lastToken.value) {
|
|
267
|
+
case "information":
|
|
268
|
+
case "form":
|
|
269
|
+
case "table":
|
|
270
|
+
case "indexes":
|
|
271
|
+
case "filters":
|
|
272
|
+
case "writable":
|
|
273
|
+
case "required":
|
|
274
|
+
case "properties": {
|
|
275
|
+
state.inPropertiesStack.push(true);
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
default: {
|
|
279
|
+
state.inPropertiesStack.push(false);
|
|
280
|
+
}
|
|
242
281
|
}
|
|
243
282
|
}
|
|
244
283
|
break;
|
package/dist/parser.js
CHANGED
|
@@ -727,6 +727,10 @@ const parse = (tokens) => {
|
|
|
727
727
|
node[keyword] = parseSearchBlock();
|
|
728
728
|
break;
|
|
729
729
|
}
|
|
730
|
+
case 'layout': {
|
|
731
|
+
node[keyword] = parseLayoutBlock();
|
|
732
|
+
break;
|
|
733
|
+
}
|
|
730
734
|
}
|
|
731
735
|
}
|
|
732
736
|
catch (err) {
|
|
@@ -978,6 +982,75 @@ const parse = (tokens) => {
|
|
|
978
982
|
indexes,
|
|
979
983
|
};
|
|
980
984
|
};
|
|
985
|
+
const parseLayoutBlock = () => {
|
|
986
|
+
let name;
|
|
987
|
+
const options = {};
|
|
988
|
+
const optionsSymbols = {};
|
|
989
|
+
const { location } = consume(token_js_1.TokenType.LeftBracket);
|
|
990
|
+
while (!match(token_js_1.TokenType.RightBracket)) {
|
|
991
|
+
const { value: keyword } = consume(token_js_1.TokenType.Keyword, lexer.COLLECTION_LAYOUT_KEYWORDS);
|
|
992
|
+
switch (keyword) {
|
|
993
|
+
case 'name': {
|
|
994
|
+
name = consume(token_js_1.TokenType.QuotedString, types_1.LAYOUT_NAMES).value;
|
|
995
|
+
break;
|
|
996
|
+
}
|
|
997
|
+
case 'options':
|
|
998
|
+
{
|
|
999
|
+
consume(token_js_1.TokenType.LeftBracket);
|
|
1000
|
+
while (!match(token_js_1.TokenType.RightBracket)) {
|
|
1001
|
+
const { value: optionsKeyword } = consume(token_js_1.TokenType.Keyword, lexer.COLLECTION_LAYOUT_OPTIONS_KEYWORDS);
|
|
1002
|
+
switch (optionsKeyword) {
|
|
1003
|
+
case 'active':
|
|
1004
|
+
case 'title':
|
|
1005
|
+
case 'picture':
|
|
1006
|
+
case 'badge': {
|
|
1007
|
+
const { value, location } = consume(token_js_1.TokenType.Identifier);
|
|
1008
|
+
const symbol = Symbol();
|
|
1009
|
+
options[optionsKeyword] = value;
|
|
1010
|
+
optionsSymbols[optionsKeyword] = symbol;
|
|
1011
|
+
exports.locationMap.set(symbol, location);
|
|
1012
|
+
break;
|
|
1013
|
+
}
|
|
1014
|
+
case 'information': {
|
|
1015
|
+
if (match(token_js_1.TokenType.LeftBracket)) {
|
|
1016
|
+
const { value, symbols } = parseArrayBlock();
|
|
1017
|
+
options[optionsKeyword] = value;
|
|
1018
|
+
optionsSymbols[optionsKeyword] = symbols;
|
|
1019
|
+
}
|
|
1020
|
+
else {
|
|
1021
|
+
const { value, location } = consume(token_js_1.TokenType.Identifier);
|
|
1022
|
+
const symbol = Symbol();
|
|
1023
|
+
options[optionsKeyword] = value;
|
|
1024
|
+
optionsSymbols[optionsKeyword] = symbol;
|
|
1025
|
+
exports.locationMap.set(symbol, location);
|
|
1026
|
+
}
|
|
1027
|
+
break;
|
|
1028
|
+
}
|
|
1029
|
+
case 'translateBadge': {
|
|
1030
|
+
const { value } = consume(token_js_1.TokenType.Boolean);
|
|
1031
|
+
options[optionsKeyword] = value;
|
|
1032
|
+
break;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
consume(token_js_1.TokenType.RightBracket);
|
|
1038
|
+
break;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
if (!name) {
|
|
1042
|
+
throw new diagnostic_js_1.Diagnostic('layout must have a "name" property', location);
|
|
1043
|
+
}
|
|
1044
|
+
consume(token_js_1.TokenType.RightBracket);
|
|
1045
|
+
return {
|
|
1046
|
+
kind: 'layout',
|
|
1047
|
+
name,
|
|
1048
|
+
options,
|
|
1049
|
+
[AST.LOCATION_SYMBOL]: {
|
|
1050
|
+
options: optionsSymbols,
|
|
1051
|
+
},
|
|
1052
|
+
};
|
|
1053
|
+
};
|
|
981
1054
|
while (index < tokens.length) {
|
|
982
1055
|
const { value: declType, location } = current();
|
|
983
1056
|
try {
|
package/dist/parser.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { TokenType } from "./token.mjs";
|
|
3
|
-
import { DESCRIPTION_PRESETS, PROPERTY_ARRAY_ELEMENTS, PROPERTY_FORMATS, PROPERTY_INPUT_ELEMENTS, PROPERTY_INPUT_TYPES } from "@aeriajs/types";
|
|
3
|
+
import { DESCRIPTION_PRESETS, LAYOUT_NAMES, PROPERTY_ARRAY_ELEMENTS, PROPERTY_FORMATS, PROPERTY_INPUT_ELEMENTS, PROPERTY_INPUT_TYPES } from "@aeriajs/types";
|
|
4
4
|
import { icons } from "@phosphor-icons/core";
|
|
5
5
|
import { Diagnostic } from "./diagnostic.mjs";
|
|
6
6
|
import * as AST from "./ast.mjs";
|
|
@@ -672,6 +672,10 @@ export const parse = (tokens) => {
|
|
|
672
672
|
node[keyword] = parseSearchBlock();
|
|
673
673
|
break;
|
|
674
674
|
}
|
|
675
|
+
case "layout": {
|
|
676
|
+
node[keyword] = parseLayoutBlock();
|
|
677
|
+
break;
|
|
678
|
+
}
|
|
675
679
|
}
|
|
676
680
|
} catch (err) {
|
|
677
681
|
if (err instanceof Diagnostic) {
|
|
@@ -919,6 +923,74 @@ export const parse = (tokens) => {
|
|
|
919
923
|
indexes
|
|
920
924
|
};
|
|
921
925
|
};
|
|
926
|
+
const parseLayoutBlock = () => {
|
|
927
|
+
let name;
|
|
928
|
+
const options = {};
|
|
929
|
+
const optionsSymbols = {};
|
|
930
|
+
const { location } = consume(TokenType.LeftBracket);
|
|
931
|
+
while (!match(TokenType.RightBracket)) {
|
|
932
|
+
const { value: keyword } = consume(TokenType.Keyword, lexer.COLLECTION_LAYOUT_KEYWORDS);
|
|
933
|
+
switch (keyword) {
|
|
934
|
+
case "name": {
|
|
935
|
+
name = consume(TokenType.QuotedString, LAYOUT_NAMES).value;
|
|
936
|
+
break;
|
|
937
|
+
}
|
|
938
|
+
case "options":
|
|
939
|
+
{
|
|
940
|
+
consume(TokenType.LeftBracket);
|
|
941
|
+
while (!match(TokenType.RightBracket)) {
|
|
942
|
+
const { value: optionsKeyword } = consume(TokenType.Keyword, lexer.COLLECTION_LAYOUT_OPTIONS_KEYWORDS);
|
|
943
|
+
switch (optionsKeyword) {
|
|
944
|
+
case "active":
|
|
945
|
+
case "title":
|
|
946
|
+
case "picture":
|
|
947
|
+
case "badge": {
|
|
948
|
+
const { value, location: location2 } = consume(TokenType.Identifier);
|
|
949
|
+
const symbol = Symbol();
|
|
950
|
+
options[optionsKeyword] = value;
|
|
951
|
+
optionsSymbols[optionsKeyword] = symbol;
|
|
952
|
+
locationMap.set(symbol, location2);
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
955
|
+
case "information": {
|
|
956
|
+
if (match(TokenType.LeftBracket)) {
|
|
957
|
+
const { value, symbols } = parseArrayBlock();
|
|
958
|
+
options[optionsKeyword] = value;
|
|
959
|
+
optionsSymbols[optionsKeyword] = symbols;
|
|
960
|
+
} else {
|
|
961
|
+
const { value, location: location2 } = consume(TokenType.Identifier);
|
|
962
|
+
const symbol = Symbol();
|
|
963
|
+
options[optionsKeyword] = value;
|
|
964
|
+
optionsSymbols[optionsKeyword] = symbol;
|
|
965
|
+
locationMap.set(symbol, location2);
|
|
966
|
+
}
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
case "translateBadge": {
|
|
970
|
+
const { value } = consume(TokenType.Boolean);
|
|
971
|
+
options[optionsKeyword] = value;
|
|
972
|
+
break;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
consume(TokenType.RightBracket);
|
|
978
|
+
break;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
if (!name) {
|
|
982
|
+
throw new Diagnostic('layout must have a "name" property', location);
|
|
983
|
+
}
|
|
984
|
+
consume(TokenType.RightBracket);
|
|
985
|
+
return {
|
|
986
|
+
kind: "layout",
|
|
987
|
+
name,
|
|
988
|
+
options,
|
|
989
|
+
[AST.LOCATION_SYMBOL]: {
|
|
990
|
+
options: optionsSymbols
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
};
|
|
922
994
|
while (index < tokens.length) {
|
|
923
995
|
const { value: declType, location } = current();
|
|
924
996
|
try {
|
package/dist/semantic.js
CHANGED
|
@@ -92,7 +92,7 @@ const analyze = async (ast, options, errors = []) => {
|
|
|
92
92
|
const symbol = node.property[AST.LOCATION_SYMBOL].arrays[attributeName][index];
|
|
93
93
|
if (!(propName in node.property.properties)) {
|
|
94
94
|
const location = parser_js_1.locationMap.get(symbol);
|
|
95
|
-
errors.push(new diagnostic_js_1.Diagnostic(`object
|
|
95
|
+
errors.push(new diagnostic_js_1.Diagnostic(`object hasn't such property "${propName}"`, location));
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
};
|
|
@@ -139,6 +139,27 @@ const analyze = async (ast, options, errors = []) => {
|
|
|
139
139
|
const subNode = node.properties[propName];
|
|
140
140
|
await recurseProperty(subNode);
|
|
141
141
|
}
|
|
142
|
+
if (node.layout) {
|
|
143
|
+
if (node.layout.options) {
|
|
144
|
+
for (const [name, value] of Object.entries(node.layout[AST.LOCATION_SYMBOL].options)) {
|
|
145
|
+
const option = node.layout.options[name];
|
|
146
|
+
if (Array.isArray(option)) {
|
|
147
|
+
for (const [i, propName] of option.entries()) {
|
|
148
|
+
if (!(propName in node.properties)) {
|
|
149
|
+
const location = parser_js_1.locationMap.get(value[i]);
|
|
150
|
+
errors.push(new diagnostic_js_1.Diagnostic(`invalid property "${propName}"`, location));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
if (!(option in node.properties)) {
|
|
156
|
+
const location = parser_js_1.locationMap.get(value);
|
|
157
|
+
errors.push(new diagnostic_js_1.Diagnostic(`invalid property "${option}"`, location));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
142
163
|
}
|
|
143
164
|
for (const node of ast.contracts) {
|
|
144
165
|
if (node.payload) {
|
package/dist/semantic.mjs
CHANGED
|
@@ -57,7 +57,7 @@ export const analyze = async (ast, options, errors = []) => {
|
|
|
57
57
|
const symbol = node.property[AST.LOCATION_SYMBOL].arrays[attributeName][index];
|
|
58
58
|
if (!(propName in node.property.properties)) {
|
|
59
59
|
const location = locationMap.get(symbol);
|
|
60
|
-
errors.push(new Diagnostic(`object
|
|
60
|
+
errors.push(new Diagnostic(`object hasn't such property "${propName}"`, location));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
};
|
|
@@ -102,6 +102,26 @@ export const analyze = async (ast, options, errors = []) => {
|
|
|
102
102
|
const subNode = node.properties[propName];
|
|
103
103
|
await recurseProperty(subNode);
|
|
104
104
|
}
|
|
105
|
+
if (node.layout) {
|
|
106
|
+
if (node.layout.options) {
|
|
107
|
+
for (const [name, value] of Object.entries(node.layout[AST.LOCATION_SYMBOL].options)) {
|
|
108
|
+
const option = node.layout.options[name];
|
|
109
|
+
if (Array.isArray(option)) {
|
|
110
|
+
for (const [i, propName] of option.entries()) {
|
|
111
|
+
if (!(propName in node.properties)) {
|
|
112
|
+
const location = locationMap.get(value[i]);
|
|
113
|
+
errors.push(new Diagnostic(`invalid property "${propName}"`, location));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
if (!(option in node.properties)) {
|
|
118
|
+
const location = locationMap.get(value);
|
|
119
|
+
errors.push(new Diagnostic(`invalid property "${option}"`, location));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
105
125
|
}
|
|
106
126
|
for (const node of ast.contracts) {
|
|
107
127
|
if (node.payload) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/compiler",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@aeriajs/common": "^0.0.
|
|
25
|
-
"@aeriajs/types": "^0.0.
|
|
24
|
+
"@aeriajs/common": "^0.0.141",
|
|
25
|
+
"@aeriajs/types": "^0.0.123"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@aeriajs/common": "link:../common",
|