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

🖊️ Improved error message for missing colons in level 17 #5465

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

boryanagoncharenko
Copy link
Collaborator

  • Add preprocessing rules which take an argument in order to allow for a rule to turn into an error without copying the old rule definition. For example, error_ifelse<old_rule_to_error ifelse> is used in level 8 to transform the old flat if-else to an error.
  • Add errors for if-else statements, loops and function definitions missing a colon in level 17

Fixes #5222

How to test

  • Automated tests are added for the new preprocessing functionality and for the commands missing colons in level 17.
  • To see the error message, run the following program in level 17 and try removing any of the colons at a time. The message should direct you to the right line.
define function with b:
    i = 1
    while i < b:
        print i
        i = i + 1

b = 10
if b is 1:
    call function with b
elif b is 2:
    call function with b
else:
    call function with b

if b is pressed:
    call function with b
elif c is pressed:
    call function with b
else:
    call function with b

Copy link
Member

@jpelay jpelay left a comment

Choose a reason for hiding this comment

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

Excellent! I love the new grammar merger file.

@@ -10,7 +10,7 @@ change_list_item: var_access _LEFT_SQUARE_BRACKET (INT | var_access) _RIGHT_SQUA
assign_list: var (_IS | _EQUALS) _LEFT_SQUARE_BRACKET ((quoted_text | NUMBER) (_COMMA (quoted_text | NUMBER))*)? _RIGHT_SQUARE_BRACKET
error_assign_list_missing_brackets: var (_IS | _EQUALS) (_LEFT_SQUARE_BRACKET)? ((quoted_text | NUMBER) _COMMA (quoted_text | NUMBER) (_COMMA (quoted_text | NUMBER))*)? (_RIGHT_SQUARE_BRACKET)?

error_list_access_at: var_access _AT (INT | random)
error_list_access_at<old_rule_to_error list_access>
Copy link
Member

Choose a reason for hiding this comment

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

I really like this!

Copy link
Contributor

mergify bot commented Apr 25, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

Copy link
Contributor

mergify bot commented Apr 25, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 74a94fc into main Apr 25, 2024
12 checks passed
@mergify mergify bot deleted the grammar_processor_5222 branch April 25, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

💻 Make a better error message for forgotten colons in level 17
2 participants