Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(repl): improve support of multi-line statements #1129

Merged
merged 6 commits into from
Nov 7, 2023

Conversation

mvertes
Copy link
Contributor

@mvertes mvertes commented Sep 15, 2023

demo

This is a followup of #978. Instead of starting in multi-line mode prior to submit, the line is parsed, and new inputs are appended to it as long as the statment is not complete, as detected by the Go scanner.

This is simpler and more general than previous attempt. The secondary prompt is "...", different from primary "gno>", similarly to many REPL programs (node, python, bash, ...).

The "/editor" command is removed as not useful anymore. Note also that it is now possible to exit using Ctrl-D.

Related issues: #446 #950

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

This is a followup of gnolang#978. Instead of starting in multi-line mode prior
to submit, the line is parsed, and new inputs are appended to it as long
as the statment is not complete, as detected by the Go scanner.

This is simpler and more general than previous attempt. The secondary
prompt is "...", different from primary "gno>", similarly to many REPL
programs (node, python, bash, ...).

The "/editor" command is removed as not useful anymore. Note also
that it is now possible to exit using Ctrl-D.
@mvertes mvertes requested a review from a team as a code owner September 15, 2023 13:09
@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Sep 15, 2023
Copy link
Member

@moul moul left a comment

Choose a reason for hiding this comment

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

LGTM

gnovm/cmd/gno/repl.go Show resolved Hide resolved
@moul moul added this to the 🌟 main.gno.land (wanted) milestone Sep 16, 2023
@moul moul requested a review from ajnavarro September 18, 2023 16:28
@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Attention: 42 lines in your changes are missing coverage. Please review.

Comparison is base (e10c0c7) 46.98% compared to head (f5cda85) 48.40%.
Report is 26 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1129      +/-   ##
==========================================
+ Coverage   46.98%   48.40%   +1.41%     
==========================================
  Files         365      372       +7     
  Lines       61159    63740    +2581     
==========================================
+ Hits        28737    30851    +2114     
- Misses      30062    30419     +357     
- Partials     2360     2470     +110     
Files Coverage Δ
gnovm/pkg/repl/repl.go 93.25% <100.00%> (ø)
gnovm/cmd/gno/repl.go 40.62% <0.00%> (-2.36%) ⬇️

... and 31 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@harry-hov harry-hov self-requested a review September 21, 2023 15:59
Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

mostly LGTM, definitely better.

one question: since we're generically "catching" scanner errors, this includes "irrecoverable", wrong syntaxes. I think it might thus still make sense if we long-term plan to instead have a system whereby the syntax error is printed if all of the unmatched open {}[]() brackets are <= 0, for instance?

gnovm/cmd/gno/repl.go Outdated Show resolved Hide resolved
gnovm/cmd/gno/repl.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

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

Looks good, but I would argue that the /editor command is still useful when you want to copy chunks of code containing more than one statement, so I would say to keep it.

@mvertes
Copy link
Contributor Author

mvertes commented Oct 19, 2023

@ajnavarro yes, agree to keep /editor after all, done in the last commit.

@thehowl thehowl merged commit 42c0132 into gnolang:master Nov 7, 2023
182 checks passed
gfanton pushed a commit to gfanton/gno that referenced this pull request Nov 9, 2023
![demo](https://github.com/gnolang/gno/assets/5792239/308e61bc-bdf9-498b-9fa7-cd756835f774)

This is a followup of gnolang#978. Instead of starting in multi-line mode prior
to submit, the line is parsed, and new inputs are appended to it as long
as the statment is not complete, as detected by the Go scanner.

This is simpler and more general than previous attempt. The secondary
prompt is "...", different from primary "gno>", similarly to many REPL
programs (node, python, bash, ...).

The "/editor" command is removed as not useful anymore. Note also that
it is now possible to exit using Ctrl-D.

Related issues: gnolang#446 gnolang#950

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
moul added a commit to moul/gno that referenced this pull request Nov 14, 2023
![demo](https://github.com/gnolang/gno/assets/5792239/308e61bc-bdf9-498b-9fa7-cd756835f774)

This is a followup of gnolang#978. Instead of starting in multi-line mode prior
to submit, the line is parsed, and new inputs are appended to it as long
as the statment is not complete, as detected by the Go scanner.

This is simpler and more general than previous attempt. The secondary
prompt is "...", different from primary "gno>", similarly to many REPL
programs (node, python, bash, ...).

The "/editor" command is removed as not useful anymore. Note also that
it is now possible to exit using Ctrl-D.

Related issues: gnolang#446 gnolang#950

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: 🌟 Wanted for Launch
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants