GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing github.com — repl: support mult-line string-keyed objects by rubys · Pull Request #21775 · nodejs/node Conversation
Member
fixes #21657 Checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
antsmartian
reviewed
|
|
@nodejs/repl |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@rubys In general, the idea is great. Because this is going in a direction where the code is starting to be properly parsed. I am not sure though if this is the right approach in the current state of the repl. The reason is that the repl itself has so many hacks that it's a nightmare. It would be really awesome if you would be able to use acorn instead. I am not sure if that would help in this specific moment but I'll have a look into that tomorrow and maybe you could also check that? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@BridegeAR: you are being too kind. It clearly is a hack. Ideally, V8 would be implemented as a streaming parser, but that isn't required for the browser. As Acorn isn't a streaming parser, it isn't likely to be able to help us here. The root problem is that the JavaScript grammar is ambiguous (at least at the tokenization level), and backtracking is sometimes needed. Examples of valid JavaScript: a=1 {a*2} {a, a} {a, a*2} label: {a, a} Only one of the lines above is an object literal. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@rubys btw we're working on rewriting the REPL from scratch: https://github.com/nodejs/repl it might be a good place to experiment with different ways of consuming input, as its still fairly small. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I may have been too quick to discount acorn; it will probably need a patch to be landed to support this use case, but it looks doable. I'm traveling for the next four days, so it may not be until next week that I can take a look at this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we split this out into a separate file in lib/internal/repl/?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Update: played with acorn on the first flight leg on this trip. Everything needed can be done with a plugin. Will create a separate pull request either later today or this weekend. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
See #21805 for an acorn based implementation. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Node REPL says "SyntaxError: unexpected symbol :" when parsing multi-line string-keyed objects (e.g. JSON)
There was an error while loading. Please reload this page.