Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Error when parsing a native function #102

Closed
ericmorand-emakina opened this issue Jan 26, 2018 · 2 comments
Closed

Error when parsing a native function #102

ericmorand-emakina opened this issue Jan 26, 2018 · 2 comments
Labels

Comments

@ericmorand-emakina
Copy link

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
Copy link
Owner

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
Copy link
Contributor

Tested with babylon, same problem. You can close.

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

No branches or pull requests

3 participants