You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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).
acorn.parse
parses statements, but what if you got an expression you want to parse? Such asfunction(){}
? Thenacorn.parse('function(){}')
complains, as expected, but it would be nice if one could writeacorn.parseExpression('function(){}')
. The workaround I'm using now isacorn.parse('(<theArbitraryExpression>)')
to ensure the code is interpreted as an expression statement, but this complicates error messages, and it case<theArbitraryExpression>
is2)*(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.The text was updated successfully, but these errors were encountered: