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

Normalize block delimiters #230

Open
ghost opened this issue May 26, 2017 · 1 comment
Open

Normalize block delimiters #230

ghost opened this issue May 26, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented May 26, 2017

By the end of the preparsing stage, all 'do'-enclosed blocks of the input source code should be converted into bracket-enclosed ones. For instance, the following code snippet:

coll.each do |l|
    puts l
end

Should be transformed into:

coll.each {|l| puts l}

Such transformation would greatly reduce the parser's work while inspecting blocks.

@ghost
Copy link
Author

ghost commented Jun 8, 2017

Since there are optional do's possibly introduced by both 'until' and 'while' keywords, and these do's don't introduce additional 'end' keywords, we need a way to differ between such do's and the ones that do introduce the 'end' keyword - there appears to be no easy way of doing that without context, due to cases such as the following:

until (coll.each do end)
end

This block is semantically equivalent to the one below:

until (coll.each do end) do
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants