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

fix: update grammar to support user defined imports #27

Merged

Conversation

cronsorcery
Copy link
Contributor

Hi.

I have encountered a few issues while using this parser with experimental features.

Since 0.23.x bicep supports imports of user-defined functionality.
There's also provider syntax suggested by bicep-lsp, which is supposed to behave like import statements.

Using this feature breaks highlighting, since tree-sitter is looking for a version string, and resource declaration looks suspiciously close to it:
2023-12-09-222740_1343x315_scrot

This PR introduces a few tweaks to existing imports to support provider and adds import_user_functionality as described in official documentation:
2023-12-10-151357_1421x815_scrot

Not sure where to find docs for provider, but both LSP and bicep seem to not mind it at all.
Tested on Bicep CLI version 0.23.1 (b02de2da48).

Some additional work for the future:

@cronsorcery cronsorcery force-pushed the update-import-statements branch from e5c43d9 to 52323d6 Compare December 10, 2023 13:35
@amaanq amaanq force-pushed the update-import-statements branch from 52323d6 to 8df12f0 Compare February 1, 2024 07:21
@amaanq
Copy link
Member

amaanq commented Feb 1, 2024

Thanks for the PR!

For the multiline string with unescaped quotes, that will probably need to be parsed in the scanner
For the nullable types, some docs on that would be great

I will try and implement those missing features later on when I get time, but if you'd like to take a stab at it go ahead and I can help out when needed.

Since 0.23.x bicep supports imports of user-defined objects.
`provider` syntax is also equivalent to previous import syntax.
@amaanq amaanq force-pushed the update-import-statements branch from 8df12f0 to 5698d7a Compare February 1, 2024 07:23
@amaanq amaanq force-pushed the update-import-statements branch from 5698d7a to f66a79c Compare February 1, 2024 07:25
@amaanq amaanq merged commit 297e6c5 into tree-sitter-grammars:master Feb 1, 2024
4 checks passed
@amaanq
Copy link
Member

amaanq commented Feb 2, 2024

Alright, I've implemented all those features as well as moving multiline string token parsing to the external scanner. Enjoy and let me know of other issues you run into!

@cronsorcery
Copy link
Contributor Author

Much appreciated, thank you. I'll make sure to do so or see if I can help improve it myself.

@cronsorcery cronsorcery deleted the update-import-statements branch February 4, 2024 20:48
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