-
Notifications
You must be signed in to change notification settings - Fork 8
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
Broad grammar improvements #8
Open
thomaspurchas
wants to merge
15
commits into
apple:main
Choose a base branch
from
thomaspurchas:pkl-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The tree-sitter-cli expects all tests to be in a test dir within the project root.
These tests broke at some point and were never updated. As the new output doesn't seem incorrect, I'm just updating the expected output to match what the grammar currently produces.
tree-sitter language repos have a specific layout and package.json which is defined by the tree-sitter project, and enforced by the tree-sitter-cli. Most of the changes in package.json are from the tree-sitter-cli updating it to conformance
Updating tree-sitter has resulting in output changes due to improved error handling in the tree-sitter parse. The new output is much more informative when parsing errors occur compared to previous versions.
It useful to be able to query for actual string fragments between string deliminator. The (stringFragment) now makes it possible to break down strings into their different fragments and interpolations.
There's no need to use a regex to detect types, we can detect using just the syntax tree. Using a regex results in unnecessary false-positive matches.
tree-sitter doesn't like it when you use non-static functions as they may collide with function names in other grammars. There's no reason not to make this function static as it not used anywhere else.
Fields make it much easier to write smart queries using the grammar, as things like detection of default values can be included in the grammar via field, removing the need for queries to handle those detections themselves.
Co-authored-by: Kushal Pisavadia <[email protected]> Fix license metadata
Using grammar from here: tree-sitter/tree-sitter#2094 (comment)
bioball
added a commit
to bioball/tree-sitter-pkl
that referenced
this pull request
Sep 30, 2024
Ports many of the fixes previously introduced in apple#8 1. Add support for else body in when generator 2. Remove legacy syntax in for and when generators 3. Add support for shebang comments 4. Add field names to various nodes throughout the grammar 5. Add missing "module" type
Thanks for the PR! Sorry it took so long to address this. This PR is a little large, but, I'm going to pick of some of these improvements into smaller PRs that can be merged separately. The first is here: #21 |
bioball
added a commit
to bioball/tree-sitter-pkl
that referenced
this pull request
Sep 30, 2024
Ports many of the fixes previously introduced in apple#8 1. Add support for else body in when generator 2. Remove legacy syntax in for and when generators 3. Add support for shebang comments 4. Add field names to various nodes throughout the grammar 5. Add missing "module" type
bioball
added a commit
to bioball/tree-sitter-pkl
that referenced
this pull request
Sep 30, 2024
Ports many of the fixes previously introduced in apple#8 1. Add support for else body in when generator 2. Remove legacy syntax in for and when generators 3. Add support for shebang comments 4. Add field names to various nodes throughout the grammar 5. Add missing "module" type
bioball
added a commit
that referenced
this pull request
Sep 30, 2024
Ports many of the fixes previously introduced in #8 1. Add support for else body in when generator 2. Remove legacy syntax in for and when generators 3. Add support for shebang comments 4. Add field names to various nodes throughout the grammar 5. Add missing "module" type
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There's a few changes in the PR but each of them isn't very substantial, but together do change a few things.
ERROR
nodes which are more descriptiveelse
branch of awhen
generatorstringFragment
rule to allow the easy extraction of strings from within string literalstree-sitter
cli complaintsThe vast majority of the change are just updating the test to include the
stringFragment
node, which slightly modified almost every test file.Strongly recommend working through PR on commit-by-commit basis.