-
Notifications
You must be signed in to change notification settings - Fork 141
Completely migrate to prism #1160
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
base: master
Are you sure you want to change the base?
Conversation
7ad0c2f to
4bd3866
Compare
4bd3866 to
9dd75f9
Compare
6165add to
66e7c60
Compare
| # foo | ||
| # bar | ||
| # If it's connected, return the last line string. Otherwise, return false. | ||
| def check_termination_in_prev_line(code, local_variables:) |
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.
The doc expresses the behaviour using "connected" or not, but the method name seems to suggest we're checking the opposite: "terminated" or not. Should we rename the method?
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.
I think the method name termination describes what IRB need to do, compared to connected.
Updated the source code comment to be more clear.
66e7c60 to
3bad250
Compare
Remove remaining ripper dependency in: syntax check, code continue/termination check, show-source, regexp-completion and string-like command arg parse.
3bad250 to
aad5b4d
Compare
Closes #1024
Fixes #75 and #286
Remove remaining Ripper dependency and completely migrate to Prism.
RubyLex#should_continue?Instead of checking Ripper's state bits, check for IGNORED_NEWLINE token.
When code is continued to the next line, there's probably a IGNORED_NEWLINE token.
RubyLex#check_termination_in_prev_lineWhen multiline code is pasted (without bracketed-paste mode), IRB checks if the last line is connected to the previous line.
Before: Heuristic, find DOT token
After: Compare two syntax trees:
parse(lines.join)andparse(lines[...-1].join)RubyLex#check_code_syntaxChecks if the code is
:valid,:unrecoverable_erroror:recoverable_error.Same as before, use syntax error messages and regexp patterns.
Basic rules
meets end of fileend-of-inputunterminatedis likely to be recoverable erroris not allowedunexpectedorinvalidis likely to be unrecoverable errorinvalidorunexpectederror location is near last token position, it may not be unrecoverable errorChecked with many recoverable-error-code collected by
ruby/ruby/**/*.rb"\n"becomes valid