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

Bring parser up to date with language changes in Zeek #4

Closed
wants to merge 38 commits into from

Conversation

bbannier
Copy link

This is a companion PR for zeek/tree-sitter-zeek#42.

ckreibich and others added 30 commits February 1, 2022 20:27
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 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.
@bbannier
Copy link
Author

Sorry, wrong target repo.

@bbannier bbannier closed this Nov 24, 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.

4 participants