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

Scanner, grammar and parser changes for Switch expressions 2.0 #3264

Conversation

srikanth-sankaran
Copy link
Contributor

@srikanth-sankaran srikanth-sankaran commented Nov 7, 2024

  • Restructure switch expressions grammar aligning it with JLS terminology; Eliminate unnecessary calls outs from the automaton (-> instead of ::=); fold multiple consume rules into one by parameterizing; delete dangling non-terminals (ThrowExpression ...); deduplicate unnecessary distinct non-terminals (e.g SwitchLabelExpr vs SwitchLabel ...)
  • Replace the pair of tokens, first the synthetic BeginCaseExpr followed by '->' in switch rules with a single synthetic CaseArrow. The scanner will disambiguate whether a token '->' is TokenNameARROW used in lambdas or is a CaseArrow used in switch rules by checking if the automaton will shift CaseArrow or not.
  • DiagnoseParser's repair of a misclassified '->' will allow it to recover perfectly! Just suppressing the message will do.
  • Get rid of code engaging VanguardParser in reconnaissance missions for yield and '->' disambiguation.
  • Eliminate feedback from Parser to Scanner on co-ordinates of the case statement
  • Eliminate feedforward from Parser to SwitchStatement on whether it contains patterns, nulls etc; Let Switch discover it's self by itself :)
  • Declutter SwitchStatement.resolve() by simplifying control flow; streamline management of secrets;
  • Delete SelectionParserTest12.java as it is fully duplicated by SelectionParserTest13.java; Rename the latter to SelectionParserTest14.java and ensure it runs in the right compliance mode. Hook up this dangling junit to a parent
  • Tweak a failing test case in PrimitiveInPatternsTestSH.java to work around a bug elsewhere that was masked so far. [Primitive Patterns] Wrong duplicate case error  #3265 raised as follow up.
  • Adjust a few tests that result in altered diagnostics due to grammar refactoring
  • Adjust test in FormatterRegressionTests.java and ResolveTests12To15.java to run at the right compliance levels

@srikanth-sankaran srikanth-sankaran self-assigned this Nov 7, 2024
@srikanth-sankaran srikanth-sankaran changed the title Scanner and Parser support for Switch expressions 2.0 Scanner, grammar and parser changes for Switch expressions 2.0 Nov 7, 2024
@srikanth-sankaran srikanth-sankaran added this to the 4.34 M3 milestone Nov 7, 2024
@srikanth-sankaran srikanth-sankaran force-pushed the scanner-and-parser-changes-for-switch-expressions branch 4 times, most recently from bfdd394 to 75d38fb Compare November 7, 2024 23:38
@srikanth-sankaran srikanth-sankaran force-pushed the scanner-and-parser-changes-for-switch-expressions branch 3 times, most recently from 2a60d24 to 1e4b3bc Compare November 8, 2024 09:19
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.

1 participant