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

refactor(grammar): simplify grammatical categories #365

Merged
merged 2 commits into from
May 28, 2024

Conversation

anton-trunov
Copy link
Member

@anton-trunov anton-trunov commented May 27, 2024

and introduce some renamings to make it sound more standard

Closes #341

Incidentally, it should fix #332, because we forbid constant and function declarations everywhere except for traits.

  • I have updated CHANGELOG.md
  • I have added tests to demonstrate the contribution is correctly implemented: this usually includes both positive and negative tests, showing the happy path(s) and featuring intentionally broken cases
  • I have run all the tests locally and no test failure was reported
  • I did not do unrelated and/or undiscussed refactorings

and introduce some renamings to make it sound more standard
@anton-trunov anton-trunov added this to the v1.3.1 milestone May 27, 2024
@anton-trunov anton-trunov self-assigned this May 27, 2024
@anton-trunov anton-trunov requested review from Gusarich, novusnota, byakuren-hijiri and rahulyadav-57 and removed request for Gusarich May 27, 2024 13:27
Copy link
Member

@novusnota novusnota left a comment

Choose a reason for hiding this comment

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

Nice changes in structure and naming. Especially the Module = Import* ModuleItem*, which makes imports allowed only at the top-level right in the grammar. Cool!

I'll port some names and structure over to tree-sitter-tact later this week :)

And while we're at it, you may consider adding rule descriptions (in .ohm) to some of the rules, because they directly affect the syntax error messages produced by Ohm. Although adding them may complicate things a little, see: ohmjs/ohm#302

@anton-trunov
Copy link
Member Author

Especially the Module = Import* ModuleItem*, which makes imports allowed only at the top-level right in the grammar.

The change just made this restriction explicit, because before this refactoring it was later done in the parseImports function, which can now be simplified. In a subsequent refactoring we'll most likely make imports a separate field in the module AST (this is out-of-scope for this PR)

And while we're at it, you may consider adding rule descriptions (in .ohm) to some of the rules, because they directly affect the syntax error messages produced by Ohm. Although adding them may complicate things a little, see: ohmjs/ohm#302

Let's try to avoid "while-at-it" changes in the development process and create an issue that explains why this needs to be done and resolve it via a follow-up PR. This is especially important for refactoring PRs that need to be merged asap to not mess with other PRs that add new Tact features

@anton-trunov anton-trunov merged commit 37ff151 into main May 28, 2024
3 checks passed
@anton-trunov anton-trunov deleted the refactor-grammar branch May 28, 2024 13:50
This was referenced May 28, 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

Successfully merging this pull request may close these issues.

Simplify grammar.ohm and grammar.ts Incorrect error message for non-initialized contract constants
2 participants