Open BurtHarris opened 8 years ago
I note that the file it's processing (Lexer.js) is effectively an abstract class with a mandatory constructor parameter which sets _input to an instance of another class. At Lexer.js line 240, it's trying to retrieve a property from the object that should have been passed into the constructor (but wasn't).
Thanks for the report. There are some libraries that will throw
on certain property reads (sigh!) so we need to try/catch everywhere when probing fields.
Yea, that's the case for sure. But (in addition to trapping) it seems like there should be a way giving the tool more guidance on how the library is to be used. In the case of ANTLR case there's a few lines of common usage constructor invocation that might helpful to inject into the tool
var input = "your text to parse here"
var chars = new antlr4.InputStream(input);
var lexer = new MyGrammarLexer.MyGrammarLexer(chars); // Derived from antlr4.Lexer
var tokens = new antlr4.CommonTokenStream(lexer);
var parser = new MyGrammarParser.MyGrammarParser(tokens); // Derived from antlr4.Parser
...
Yea, I plan to expose this with a more friendly API as a library so you can just write that code in the node REPL and then write something like require('dts-gen').generate(obj, 'Parser').emit('dts');
First thing I tried generated a crash::
Versions:
Results: