@intend-it/parser 1.1.5 → 1.2.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/dist/index.js +13 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9263,6 +9263,10 @@ class IntendParser extends CstParser {
|
|
|
9263
9263
|
this.CONSUME3(Identifier, { LABEL: "GenericType" });
|
|
9264
9264
|
this.CONSUME(GreaterThan);
|
|
9265
9265
|
});
|
|
9266
|
+
this.OPTION5(() => {
|
|
9267
|
+
this.CONSUME(LBracket);
|
|
9268
|
+
this.CONSUME(RBracket);
|
|
9269
|
+
});
|
|
9266
9270
|
this.CONSUME(LCurly);
|
|
9267
9271
|
this.SUBRULE(this.body);
|
|
9268
9272
|
this.CONSUME(RCurly);
|
|
@@ -9530,7 +9534,8 @@ class IntendASTVisitor extends BaseIntendVisitor {
|
|
|
9530
9534
|
extractReturnType(ctx) {
|
|
9531
9535
|
const base = ctx.ReturnType[0].image;
|
|
9532
9536
|
const generic = ctx.GenericType ? ctx.GenericType[0].image : undefined;
|
|
9533
|
-
|
|
9537
|
+
const isArray2 = !!(ctx.LBracket && ctx.LBracket.length > 0);
|
|
9538
|
+
return { base, generic, isArray: isArray2 };
|
|
9534
9539
|
}
|
|
9535
9540
|
unquoteString(str) {
|
|
9536
9541
|
return str.slice(1, -1);
|
|
@@ -9554,7 +9559,13 @@ function parse(text) {
|
|
|
9554
9559
|
function parseToAST(text) {
|
|
9555
9560
|
const result = parse(text);
|
|
9556
9561
|
if (result.lexingErrors.length > 0 || result.parsingErrors.length > 0) {
|
|
9557
|
-
|
|
9562
|
+
const errors = [
|
|
9563
|
+
...result.lexingErrors.map((e) => `Lexing Error: ${e.message} at line ${e.line}:${e.column}`),
|
|
9564
|
+
...result.parsingErrors.map((e) => `Parsing Error: ${e.message} at line ${e.token.startLine}:${e.token.startColumn}`)
|
|
9565
|
+
].join(`
|
|
9566
|
+
`);
|
|
9567
|
+
throw new Error(`Cannot generate AST: parsing failed
|
|
9568
|
+
${errors}`);
|
|
9558
9569
|
}
|
|
9559
9570
|
const ast = astVisitor.visit(result.cst);
|
|
9560
9571
|
return {
|