Closed gcazaciuc closed 7 years ago
Is the AST produced by the parser identical to acorn?
Both produce output conforming to estree spec so i assume yes. Here is a link to the parser i was mentioning: https://www.npmjs.com/package/flow-parser
The Inspector's constructor could perhaps be updated to accepted an optional parse fn, to be used instead of require('acorn/dist/acorn_loose').parse_dammit;
I think the option should accept a plain parsing function to simplify the interface/implementation. E.g.
var parser = require('flow-parser');
var parse = function(str) {
return parser.parse(str, {
esproposal_decorators: true,
types: false,
// etc
});
};
new Inspector({parse, otherOptions});
Flow support was added in https://github.com/danielstjules/jsinspect/commit/f04c1429ecf8b240ef7825032148f42482ae3453 :) Thanks!
I plan in creating a Vscode extension that provides in editor feedback for copy pasted code. The only problem i have is that i need to process code with Flowtype type annotations in it. I have been using flowparser package with great success previously since it produces output compatible with most of the other parsers and also works fine with tools such as Recast, Jscodeshift etc. Wondering if there is an easy way to make the parser configurable via options ? thanks.