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

🖊️ Allow -= and > operators to be used independently when merging grammars #5186

Merged
merged 3 commits into from
Feb 29, 2024

Conversation

boryanagoncharenko
Copy link
Collaborator

Fixes #5176

Merging grammar rules was only possible if the += operator was present, which means that the -= and > operators could not be used independently of +=. With this change, all operators could be used independently of each other.

Because the > operator now does not need the context of the += operator, I had to change it to a symbol which does not appear in the lark language (e.g. ->). Please consider whether there is a better candidate than >>, for example >=?

How to test

  • The introduced merging changes are covered with unit tests
  • All existing tests should pass

@Felienne Felienne requested a review from jpelay February 29, 2024 12:12
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.

Hi, Boryana! Awesome job as always!!

@@ -0,0 +1,102 @@
import unittest
Copy link
Member

Choose a reason for hiding this comment

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

Thank you so much for adding tests for this feature!!

remove_arg = op_to_arg.get(REMOVE_GRAMMAR_MERGE_OP, '')
last_arg = op_to_arg.get(LAST_GRAMMAR_MERGE_OP, '')
remaining_commands = get_remaining_rules(prev_definition, remove_arg, last_arg)
ordered_commands = split_rule(remaining_commands, add_arg, last_arg)
Copy link
Member

Choose a reason for hiding this comment

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

A lot better now!

Copy link
Contributor

mergify bot commented Feb 29, 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 831b28c into main Feb 29, 2024
11 checks passed
@mergify mergify bot deleted the grammar_merging_5176 branch February 29, 2024 15:31
Copy link
Contributor

mergify bot commented Feb 29, 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).

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.

🖊️ When merging grammars support > and -= operators independently of the += operator
2 participants