Skip to content

Parsing indentation cleanup #10861

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

Merged
merged 4 commits into from
Jan 1, 2021
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Dec 19, 2020

  • Eliminate WITHEOL token: Change parsing algorithm so that we do not need a separate WITHEOL token. The grammar remains unaffected.

  • Make indentation significant after throw and ?=>

@odersky odersky marked this pull request as ready for review December 19, 2020 10:06
@odersky odersky requested a review from b-studios December 23, 2020 10:59
@@ -3708,8 +3708,8 @@ object Parsers {

/** with Template, with EOL <indent> interpreted */
Copy link
Contributor

Choose a reason for hiding this comment

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

should this comment be updated? Is this comment a pseudo grammar? Just from the comment it is not clear which "with" is a keyword and whether "," is a token or an informal alternative.

@@ -80,11 +84,15 @@ object Test:

class Test2:
self =>
def foo = 1
def foo(x: Int) =
if x < 0 then throw
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want to allow this? I somehow parse this as:

if x < 0 then { throw();
  val ex = ...
}

Copy link
Contributor Author

@odersky odersky Dec 24, 2020

Choose a reason for hiding this comment

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

For consistency I think it is better to allow it. The given expression abuses indentation rules for sure. It should be formatted like this:

if x < 0 then
   throw
      val ex = ...
      ex

Change parsing algorithm so that we do not need a separate WITHEOL token.
The grammar remains unaffected.
@odersky odersky merged commit c149eeb into scala:master Jan 1, 2021
@odersky odersky deleted the with-templates branch January 1, 2021 14:14
@griggt griggt mentioned this pull request Feb 17, 2021
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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

Successfully merging this pull request may close these issues.

3 participants