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

Parsing just expressions #97

Closed
PeppeL-G opened this issue May 11, 2014 · 3 comments
Closed

Parsing just expressions #97

PeppeL-G opened this issue May 11, 2014 · 3 comments

Comments

@PeppeL-G
Copy link

acorn.parse parses statements, but what if you got an expression you want to parse? Such as function(){}? Then acorn.parse('function(){}') complains, as expected, but it would be nice if one could write acorn.parseExpression('function(){}'). The workaround I'm using now is acorn.parse('(<theArbitraryExpression>)') to ensure the code is interpreted as an expression statement, but this complicates error messages, and it case <theArbitraryExpression> is 2)*(3, there would be no error!.

If it's not to much work, I would be glad if you could add acorn.parseExpression (a function that parses one expression) to the API.

@marijnh
Copy link
Member

marijnh commented May 28, 2014

Yes, this is a feature I've needed as well, at times. A pull request would be welcome. It'd be great if the interface also supports a way to enable/disable the check for whether the expression takes up the whole string (to easily allow finding the end of an expression, for example when parsing a templating language).

@RReverser
Copy link
Member

Seems to be closed by d0497ab.

@marijnh
Copy link
Member

marijnh commented Sep 24, 2014

Good point.

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

3 participants