GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — repl: support mult-line string-keyed objects by rubys · Pull Request #21775 · nodejs/node

Conversation

@rubys

@rubys rubys commented Jul 12, 2018

Copy link
Copy Markdown
Member

fixes #21657

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot nodejs-github-bot added the repl Issues and PRs related to the REPL subsystem. label Jul 12, 2018
@jasnell
jasnell requested review from BridgeAR and addaleax July 12, 2018 04:50
antsmartian
antsmartian reviewed Jul 12, 2018
View reviewed changes
Comment thread lib/repl.js Outdated

@antsmartian antsmartian Jul 12, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In version v8.11.3, without this particular check, things works. I'm wondering, now with this code in place, we are sort of re-doing the check (may be?). May be I'm wrong here.

Actually as discussed in the issue, this change broken the partial JSON stuff. The diff is over here:
ebfa8b1#diff-293fefe850253c8c28e2481c0b7f76e2L647

As seen in the comments of PR, looks like partial template literal also broken in latest version. For example:

`io.js ${a
... }`

works in v8/9. But broken in v10x.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Trott

Trott commented Jul 12, 2018

Copy link
Copy Markdown
Member

@nodejs/repl

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR

BridgeAR commented Jul 13, 2018

Copy link
Copy Markdown
Member

@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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rubys

rubys commented Jul 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@devsnek

devsnek commented Jul 13, 2018

Copy link
Copy Markdown
Member

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rubys

rubys commented Jul 13, 2018

Copy link
Copy Markdown
Member Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax
addaleax reviewed Jul 13, 2018
View reviewed changes
Comment thread lib/repl.js Outdated

@addaleax addaleax Jul 13, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rubys

rubys commented Jul 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rubys rubys closed this Jul 13, 2018
@rubys
rubys force-pushed the repl-json branch from 525b654 to a478259 Compare July 13, 2018 22:44
@rubys

rubys commented Jul 13, 2018

Copy link
Copy Markdown
Member Author

See #21805 for an acorn based implementation.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@addaleax addaleax addaleax left review comments
@BridgeAR BridgeAR Awaiting requested review from BridgeAR
+1 more reviewer
@antsmartian antsmartian antsmartian left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

repl Issues and PRs related to the REPL subsystem.

Projects

None yet

Milestone

No milestone

Development

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)

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@rubys @Trott @BridgeAR @devsnek @addaleax @antsmartian @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.