Skip to content

Move inline decorator to scanner #218

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

Merged
merged 1 commit into from
Apr 27, 2023

Conversation

aspeddro
Copy link
Collaborator

@aspeddro aspeddro commented Apr 16, 2023

Move inline decorator to scanner.

Inline decorator is decorator without arguments.

@@decorator
@decorator

Decorators with arguments can be specified in grammar.js. This was a limitation because TreeSitter could not determine the end of the rule.

Decorators can now be treated as a comment, can appear anywhere.

This PR also removes some conflicts that were introduced due to decorators. We can also remove some tests with decorators.

@nkrkv
Copy link
Collaborator

nkrkv commented Apr 21, 2023

Absolutely great! Thank you. I like that many conflicts are gone now.

Would you rebase the branch, please?

@aspeddro
Copy link
Collaborator Author

Done

@aspeddro
Copy link
Collaborator Author

aspeddro commented Apr 21, 2023

Ops, a small error introduced.

'@'
(source_file [0, 0] - [1, 0]
  (ERROR [0, 0] - [1, 0]
    (string_fragment [0, 1] - [1, 0])))

In main branch it's is parsed.

Edit 1:

The parser look at @ an expect a decorator rule.

Edit 2: Fixed in 233734f

@aspeddro
Copy link
Collaborator Author

aspeddro commented Apr 21, 2023

Highlights updated to not highlight @ in '@' as annotation.
3353315

grammar.js Outdated
@@ -1485,7 +1452,7 @@ module.exports = grammar({

character: $ => seq(
"'",
repeat(choice(/[^\\']/, $.escape_sequence)),
repeat(choice(/[^\\']/, $.escape_sequence, '@')),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a workaround to parse don't look at '@' an expect an decorator inline.

@aspeddro aspeddro force-pushed the move-decorator-to-scan branch from 55d6b56 to e2af3e7 Compare April 21, 2023 22:31
@aspeddro
Copy link
Collaborator Author

aspeddro commented Apr 21, 2023

The last commit e2af3e7 removed the workaround and fixed the error with characher '@'.

@aspeddro
Copy link
Collaborator Author

Now the scanner will parse the start of the decorator: @ or @@.

@nkrkv
Copy link
Collaborator

nkrkv commented Apr 27, 2023

Brilliant! Thank you!

@nkrkv nkrkv merged commit abab0e3 into rescript-lang:main Apr 27, 2023
@aspeddro aspeddro deleted the move-decorator-to-scan branch May 3, 2023 21:57
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.

2 participants