Error when parsing a native function
ericmorand-emakina opened this issue · 2 comments
ericmorand-emakina commented
Consider the following code:
const parseFunction = require('parse-function');
let app = parseFunction();
console.warn(app.parse(Math.abs));
This throws an exception SyntaxError: Unexpected token, expected , (1:25) coming from babylon:
SyntaxError: Unexpected token, expected , (1:25)
at Parser.raise (/home/ericmorand/Projects/twing/node_modules/babylon/lib/index.js:808:15)
at Parser.unexpected (/home/ericmorand/Projects/twing/node_modules/babylon/lib/index.js:2185:16)
at Parser.expect (/home/ericmorand/Projects/twing/node_modules/babylon/lib/index.js:2171:28)
at Parser.parseExprList (/home/ericmorand/Projects/twing/node_modules/babylon/lib/index.js:3971:14)
at Parser.parseExprAtom (/home/ericmorand/Projects/twing/node_modules/babylon/lib/index.js:3266:30)
at Parser.parseExprSubscripts (/home/ericmorand/Projects/twing/node_modules/babylon/lib/index.js:2945:21)
at Parser.parseMaybeUnary (/home/ericmorand/Projects/twing/node_modules/babylon/lib/index.js:2923:21)
at Parser.parseExprOps (/home/ericmorand/Projects/twing/node_modules/babylon/lib/index.js:2828:21)
at Parser.parseMaybeConditional (/home/ericmorand/Projects/twing/node_modules/babylon/lib/index.js:2798:21)
at Parser.parseMaybeAssign (/home/ericmorand/Projects/twing/node_modules/babylon/lib/index.js:2757:21)
Is this an expected behavior? Is it possible to parse native functions?
tunnckoCore commented
Hey! I assume yes. Please try out just to parse it with babylon and report back.
Actually when thinking it, probably is not possible cuz we read them with toString.
ericmorand commented
Tested with babylon, same problem. You can close.