nodejs / repl

REPL rewrite for Node.js ✨🐢🚀✨
MIT License
179 stars 25 forks source link

Support for multilines #15

Closed antsmartian closed 6 years ago

antsmartian commented 6 years ago

Hello,

Looks like the current repl doesn't support multiline expression. I was looking at the source code, guess we are passing the expression to Runtime.evaluate over here : https://github.com/nodejs/repl/blob/master/src/repl.js#L68

Not sure, whether the session's Runtime.evaluate supports multilines. But looking at the protocol from here: https://chromium.googlesource.com/v8/v8/+/master/src/inspector/js_protocol.json, I doubt it has the support.

antsmartian commented 6 years ago

May be we need to buffer the statements and check if the error is recoverable? Like we do at our node currently : https://github.com/nodejs/node/blob/master/lib/repl.js#L1510

devsnek commented 6 years ago

we should probably use acorn or something to determine if the input is invalid or unfinished (> a: 5 } vs > { a: 5), and then we can just drop to the next line waiting for more input

antsmartian commented 6 years ago

Yes I thought about acorn. May, be I can give it a try in my free time and try to raise a PR. Thanks for your input.