-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
This is a super useful tool. I am trying to generate my grammar to multiple target languages (Typescript/Javascript and Java). Since I have some predicates, I have written a base parser class with the same name in each target language and referring to it with the superClass option. This problem/approach are similar to those described here: https://stackoverflow.com/questions/45196413/ways-of-keeping-antlr4-grammar-target-independent.
When I use antlr4-tool on this grammar I get the following:
Compiling src/json.g4...
evalmachine.<anonymous>:74
jsonParser.prototype = Object.create(BaseParser.prototype);
^
TypeError: Cannot read property 'prototype' of undefined
at evalmachine.<anonymous>:74:49
at Script.runInContext (vm.js:127:20)
at Object.runInContext (vm.js:290:6)
at Object.readParser (/issue/node_modules/antlr4-tool/dist/antlr-core/parser-util.js:34:8)
at AntlrCompiler.compileTypeScript (/issue/node_modules/antlr4-tool/dist/antlr-core/antlr-compiler.js:66:37)
at /issue/node_modules/antlr4-tool/dist/antlr-core/index.js:40:78
at /issue/node_modules/antlr4-tool/dist/antlr-core/index.js:17:23
at arrayEach (/issue/node_modules/lodash/lodash.js:516:11)
at Function.forEach (/issue/node_modules/lodash/lodash.js:9342:14)
at compileWithFunction (/issue/node_modules/antlr4-tool/dist/antlr-core/index.js:9:7)
The Javascript seems to generate OK, it's just the Typescript declarations that fail. I created the simplest base parser class I could in Typescript:
import { CommonTokenStream, Parser } from "antlr4";
export class BaseParser extends Parser {
constructor(input: CommonTokenStream) {
super(input);
}
}
I compiled this code to ES5, then ran antlr4-tool and got the above error.
Metadata
Metadata
Assignees
Labels
No labels