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 #42

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions grammar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// <reference types="tree-sitter-cli/dsl" />
// @ts-check

// Aliases that make things easier to read
prec_r = prec.right;
prec_l = prec.left;
Expand Down Expand Up @@ -86,12 +89,10 @@ module.exports = grammar({
seq(
"redef",
"record",
$.id,
"+=",
"{",
repeat($.type_spec),
"}",
optional($.attr_list),
choice(
seq($.id, "+=", "{", repeat($.type_spec), "}", optional($.attr_list)),
seq($.expr, "-=", "{", $.attr_list, "}"),
),
";",
),
type_decl: ($) =>
Expand Down Expand Up @@ -421,14 +422,18 @@ module.exports = grammar({
seq("@ifndef", "(", $.id, ")"),
"@endif",
"@else",
$.pragma,
),

pragma: () =>
seq(token("@pragma"), choice("push", "pop"), /[A-Za-z0-9][A-Za-z0-9\-]*/),

// These directives return strings.
string_directive: ($) => choice("@DIR", "@FILENAME"),

event_hdr: ($) => seq($.id, "(", optional($.expr_list), ")"),

id: () => /(([A-Za-z_][A-Za-z_0-9]*)?::)?[A-Za-z_][A-Za-z_0-9]*/,
id: () => /(::)?([A-Za-z_][A-Za-z_0-9]*)(::[A-Za-z_][A-Za-z_0-9]*)*/,
file: ($) => /[^ \t\r\n]+/,
pattern: ($) => /\/((\\\/)?[^\r\n\/]?)*\/i?/,

Expand Down Expand Up @@ -480,6 +485,8 @@ module.exports = grammar({
nl: ($) => /\r?\n/,
},

conflicts: ($) => [[$.expr, $.redef_record_decl]],

extras: ($) => [
/[ \t]+/,
$.nl,
Expand Down
129 changes: 101 additions & 28 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading