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

Parse error recovery #38

Open
18 of 19 tasks
obiwan87 opened this issue May 14, 2024 · 1 comment
Open
18 of 19 tasks

Parse error recovery #38

obiwan87 opened this issue May 14, 2024 · 1 comment

Comments

@obiwan87
Copy link
Owner

obiwan87 commented May 14, 2024

When typing code, it is normal that the syntax/grammar enters a non-correct state. For example, think of the following snippets

  • selecting an identifier x.<missing>
  • writing an if block "if "
  • etc.

In IntellIJ, when a parse error is encountered, the parser stops and the rest of the text will not be parsed. This leads to

  • semantic highlighting not working or flickering colors
  • errors being reported in an unexpected location
  • pollution of Psi-Tree makes with DUMMY-Block + Error

It is therefore necessary to define rules for the parser, that tell it how to recover from incomplete statements and expressions, such that the error will be contained in a small region of the code.

Write recover rules for the following statements, expressions and types:

  • package declaration statement
  • variable declaration statement
  • variable initialization statement
  • assignment statement
  • if statement
  • switch statement
  • case-clauses
  • struct fields
  • for statement (probably need to merge rules for "for" and "for ... in ..."
  • binary expressions
  • selector expression
  • argument list
  • parameter list
  • proc, enum, struct, union, bit_field, ...
  • where-clause
  • unclosed blocks (consume unclosed block until beginning of next block owner, I guess)
  • statement list (when statement list breaks, error is wrongly shown before the begin of the block)
  • list of procedures inside procedure group (use list with recovery)
  • when statement
    ...
@obiwan87 obiwan87 self-assigned this Aug 25, 2024
@obiwan87 obiwan87 modified the milestone: 0.7.0 Oct 2, 2024
@obiwan87
Copy link
Owner Author

Check for null after recover rules is introduced, as mandatory elements could become optional

@obiwan87 obiwan87 changed the title Craft recoverWhile rules for each statement, expression, type Parse error recovery Oct 17, 2024
@obiwan87 obiwan87 removed their assignment Dec 29, 2024
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

1 participant