Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative parser #43

Closed
gcazaciuc opened this issue Dec 7, 2016 · 5 comments
Closed

Alternative parser #43

gcazaciuc opened this issue Dec 7, 2016 · 5 comments

Comments

@gcazaciuc
Copy link

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.

@danielstjules
Copy link
Owner

Is the AST produced by the parser identical to acorn?

@gcazaciuc
Copy link
Author

gcazaciuc commented Dec 7, 2016

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

@danielstjules
Copy link
Owner

danielstjules commented Dec 20, 2016

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;

@danielstjules
Copy link
Owner

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});

@danielstjules
Copy link
Owner

Flow support was added in f04c142 :) Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants