-
Notifications
You must be signed in to change notification settings - Fork 1
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
Bring parser up to date with language changes in Zeek #4
Closed
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 grammar previously treated func, event and hook differently than other decls. While all other decls where self-contained, these types leaked an extra header type into the parse tree, and also never had an id accessible under the decl. We now introduce dedicated decls for each of these types.
This node introduces no new data and serves more as a tool for parser writers. Consumers of the parser on the other hand need to always unwrap it at each use. This patch hides the node from consumers.
The grammar previously treated scope-local `local` and `const` declarations differently than `global` or module-level `const` declarations. This introduced correct constrains on where these constructs could appear, but also lead to ambiguities which needed to be worked around by using different matchers for global and local declarations; these differences made especially local declarations hard to work with. This patch completely removes the notion of global decls; instead we now allow declarations everywhere. This makes matching source-level declarations anywhere straightforward, but now also allows to parse invalid inputs (e.g., inputs containing type declarations at function scope). Such inputs should if needed be instead rejected by a dedicated validator pass since the grammar allows them.
In order for users to match nodes of the form r$field r?$field they should be named. This patch introduces them as nodes named `field_access` and `field_check`.
This is a workaround for zeek/tree-sitter-zeek#15.
This works around the issue reported in zeek/zeekscript#69.
(cherry picked from commit e694eba)
Their pattern accidentally allowed newline characters to slip in if they followed right after the "#", i.e., empty comments could accidentally be parsed by swallowing the subsequent line. (cherry picked from commit b492614)
This adds support for "{ ... }-style table/set initializers in assignment expressions (as opposed to declarations, where they already existed), as well as the recently introduced trailing commas. This removes the `init` token since it's now fully covered by expressions. (cherry picked from commit e5ca3ff)
Properties are much more important than comments so are highlighted in a much more obnoxious way. Tone this down by highlighting zeekygen comments as comments.
This follows the approach of existing preprocessor constructs in that we do not allow them everywhere (e.g., by adding them to `extras`), but only if they surround fully parseable constructs like full statements.
Sorry, wrong target repo. |
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.
This is a companion PR for zeek/tree-sitter-zeek#42.