@aeriajs/compiler 0.0.28 → 0.0.29
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/parser.js +15 -7
- package/dist/parser.mjs +14 -6
- package/dist/semantic.js +8 -0
- package/dist/semantic.mjs +8 -0
- package/package.json +1 -1
package/dist/ast.d.ts
CHANGED
package/dist/parser.js
CHANGED
|
@@ -1088,7 +1088,9 @@ const parse = (tokens) => {
|
|
|
1088
1088
|
const { value: keyword, location: keywordLocation } = consume(token_js_1.TokenType.Keyword, lexer.COLLECTION_FORM_LAYOUT_KEYWORDS);
|
|
1089
1089
|
switch (keyword) {
|
|
1090
1090
|
case 'if': {
|
|
1091
|
-
|
|
1091
|
+
const ifTerms = [];
|
|
1092
|
+
fields[identifier].if = parseCondition(ifTerms);
|
|
1093
|
+
node[AST.LOCATION_SYMBOL].terms = ifTerms;
|
|
1092
1094
|
break;
|
|
1093
1095
|
}
|
|
1094
1096
|
case 'span':
|
|
@@ -1123,13 +1125,13 @@ const parse = (tokens) => {
|
|
|
1123
1125
|
consume(token_js_1.TokenType.RightBracket);
|
|
1124
1126
|
return node;
|
|
1125
1127
|
};
|
|
1126
|
-
const parseCondition = () => {
|
|
1128
|
+
const parseCondition = (symbols = []) => {
|
|
1127
1129
|
if (match(token_js_1.TokenType.LeftParens)) {
|
|
1128
1130
|
consume(token_js_1.TokenType.LeftParens);
|
|
1129
1131
|
let operatorType, newOp = operatorType;
|
|
1130
1132
|
const conditions = [];
|
|
1131
1133
|
while (!match(token_js_1.TokenType.RightParens)) {
|
|
1132
|
-
conditions.push(parseCondition());
|
|
1134
|
+
conditions.push(parseCondition(symbols));
|
|
1133
1135
|
if (match(token_js_1.TokenType.RightParens)) {
|
|
1134
1136
|
break;
|
|
1135
1137
|
}
|
|
@@ -1170,20 +1172,26 @@ const parse = (tokens) => {
|
|
|
1170
1172
|
if (match(token_js_1.TokenType.Operator, '!')) {
|
|
1171
1173
|
consume(token_js_1.TokenType.Operator);
|
|
1172
1174
|
return {
|
|
1173
|
-
not: parseCondition(),
|
|
1175
|
+
not: parseCondition(symbols),
|
|
1174
1176
|
};
|
|
1175
1177
|
}
|
|
1176
|
-
const { value: term1 } = consume(token_js_1.TokenType.Identifier);
|
|
1178
|
+
const { value: term1, location: term1Location } = consume(token_js_1.TokenType.Identifier);
|
|
1179
|
+
const term1Symbol = Symbol();
|
|
1180
|
+
exports.locationMap.set(term1Symbol, term1Location);
|
|
1181
|
+
symbols.push([
|
|
1182
|
+
term1,
|
|
1183
|
+
term1Symbol,
|
|
1184
|
+
]);
|
|
1177
1185
|
if (!match(token_js_1.TokenType.Operator, lexer.FINAL_OPERATORS)) {
|
|
1178
1186
|
return {
|
|
1179
1187
|
operator: 'truthy',
|
|
1180
|
-
term1
|
|
1188
|
+
term1,
|
|
1181
1189
|
};
|
|
1182
1190
|
}
|
|
1183
1191
|
const { value: operatorSymbol, location } = consume(token_js_1.TokenType.Operator);
|
|
1184
1192
|
let term2;
|
|
1185
1193
|
if (match(token_js_1.TokenType.LeftParens)) {
|
|
1186
|
-
term2 = parseCondition();
|
|
1194
|
+
term2 = parseCondition(symbols);
|
|
1187
1195
|
}
|
|
1188
1196
|
else {
|
|
1189
1197
|
term2 = current().value;
|
package/dist/parser.mjs
CHANGED
|
@@ -1027,7 +1027,9 @@ export const parse = (tokens) => {
|
|
|
1027
1027
|
const { value: keyword2, location: keywordLocation2 } = consume(TokenType.Keyword, lexer.COLLECTION_FORM_LAYOUT_KEYWORDS);
|
|
1028
1028
|
switch (keyword2) {
|
|
1029
1029
|
case "if": {
|
|
1030
|
-
|
|
1030
|
+
const ifTerms = [];
|
|
1031
|
+
fields[identifier].if = parseCondition(ifTerms);
|
|
1032
|
+
node[AST.LOCATION_SYMBOL].terms = ifTerms;
|
|
1031
1033
|
break;
|
|
1032
1034
|
}
|
|
1033
1035
|
case "span":
|
|
@@ -1060,13 +1062,13 @@ export const parse = (tokens) => {
|
|
|
1060
1062
|
consume(TokenType.RightBracket);
|
|
1061
1063
|
return node;
|
|
1062
1064
|
};
|
|
1063
|
-
const parseCondition = () => {
|
|
1065
|
+
const parseCondition = (symbols = []) => {
|
|
1064
1066
|
if (match(TokenType.LeftParens)) {
|
|
1065
1067
|
consume(TokenType.LeftParens);
|
|
1066
1068
|
let operatorType, newOp = operatorType;
|
|
1067
1069
|
const conditions = [];
|
|
1068
1070
|
while (!match(TokenType.RightParens)) {
|
|
1069
|
-
conditions.push(parseCondition());
|
|
1071
|
+
conditions.push(parseCondition(symbols));
|
|
1070
1072
|
if (match(TokenType.RightParens)) {
|
|
1071
1073
|
break;
|
|
1072
1074
|
}
|
|
@@ -1107,10 +1109,16 @@ export const parse = (tokens) => {
|
|
|
1107
1109
|
if (match(TokenType.Operator, "!")) {
|
|
1108
1110
|
consume(TokenType.Operator);
|
|
1109
1111
|
return {
|
|
1110
|
-
not: parseCondition()
|
|
1112
|
+
not: parseCondition(symbols)
|
|
1111
1113
|
};
|
|
1112
1114
|
}
|
|
1113
|
-
const { value: term1 } = consume(TokenType.Identifier);
|
|
1115
|
+
const { value: term1, location: term1Location } = consume(TokenType.Identifier);
|
|
1116
|
+
const term1Symbol = Symbol();
|
|
1117
|
+
locationMap.set(term1Symbol, term1Location);
|
|
1118
|
+
symbols.push([
|
|
1119
|
+
term1,
|
|
1120
|
+
term1Symbol
|
|
1121
|
+
]);
|
|
1114
1122
|
if (!match(TokenType.Operator, lexer.FINAL_OPERATORS)) {
|
|
1115
1123
|
return {
|
|
1116
1124
|
operator: "truthy",
|
|
@@ -1120,7 +1128,7 @@ export const parse = (tokens) => {
|
|
|
1120
1128
|
const { value: operatorSymbol, location } = consume(TokenType.Operator);
|
|
1121
1129
|
let term2;
|
|
1122
1130
|
if (match(TokenType.LeftParens)) {
|
|
1123
|
-
term2 = parseCondition();
|
|
1131
|
+
term2 = parseCondition(symbols);
|
|
1124
1132
|
} else {
|
|
1125
1133
|
term2 = current().value;
|
|
1126
1134
|
advance();
|
package/dist/semantic.js
CHANGED
|
@@ -169,6 +169,14 @@ const analyze = async (ast, options, errors = []) => {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
+
if (node.formLayout[AST.LOCATION_SYMBOL].terms) {
|
|
173
|
+
for (const [name, symbol] of node.formLayout[AST.LOCATION_SYMBOL].terms) {
|
|
174
|
+
if (!(name in node.properties)) {
|
|
175
|
+
const location = parser_js_1.locationMap.get(symbol);
|
|
176
|
+
errors.push(new diagnostic_js_1.Diagnostic(`invalid left operand "${name}"`, location));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
182
|
for (const node of ast.contracts) {
|
package/dist/semantic.mjs
CHANGED
|
@@ -131,6 +131,14 @@ export const analyze = async (ast, options, errors = []) => {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
if (node.formLayout[AST.LOCATION_SYMBOL].terms) {
|
|
135
|
+
for (const [name, symbol] of node.formLayout[AST.LOCATION_SYMBOL].terms) {
|
|
136
|
+
if (!(name in node.properties)) {
|
|
137
|
+
const location = locationMap.get(symbol);
|
|
138
|
+
errors.push(new Diagnostic(`invalid left operand "${name}"`, location));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
134
142
|
}
|
|
135
143
|
}
|
|
136
144
|
for (const node of ast.contracts) {
|