From 7cbd8152d8600913827d319b0abe1a232ddf3a65 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Tue, 1 Feb 2022 20:03:19 -0800 Subject: [PATCH 01/18] Add README --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ee1c48f --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# tree-sitter-zeek + +[![Tests](https://github.com/ckreibich/tree-sitter-zeek/actions/workflows/test.yaml/badge.svg)](https://github.com/ckreibich/tree-sitter-zeek/actions/workflows/test.yaml) + +A [Zeek](https://zeek.org) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter). + +## Background + +This grammar parses scripts written in the [Zeek scripting +language](https://docs.zeek.org/en/master/script-reference/index.html). + +The goal of this grammar is to facilitate tooling around Zeek +scripts. For that reason, its structure resembles Zeek's grammar but differs in +a number of ways. For example, it tracks newlines explicitly and relies more +strongly on precedence and associativity to resolve ambiguities. Like Zeek's +parser, this one currently doesn't name symbols deeply: for example, the grammar +features an `expr` rule that covers any kind of expression, but the choices +aren't currently broken down into, say, `addition_expr`, `or_expr`, and +similars. + +## Usage + +To use the generated parser directly (e.g. via any of tree-sitter's +[language bindings](https://tree-sitter.github.io/tree-sitter/#language-bindings)), +clone this repository recursively. We maintain a separate +[git repository](https://github.com/ckreibich/tree-sitter-zeek-src) +to track generated sources. You do not need the tree-sitter CLI to use +those sources. + +## Building the parser + +* Install [tree-sitter](https://tree-sitter.github.io/tree-sitter/creating-parsers#installation) on your machine. +* Generate the parser: run `tree-sitter generate`. + +## Testing + +There's currently no `tree-sitter test` testsuite. Instead, a test driver +clones the Zeek repository and runs on every Zeek script in the distribution. From ebe4dd4f796dca803654559d0b6903bae2269587 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Tue, 1 Feb 2022 20:16:26 -0800 Subject: [PATCH 02/18] Bump generated sources --- src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src b/src index 769680c..e127f2e 160000 --- a/src +++ b/src @@ -1 +1 @@ -Subproject commit 769680ca25fe763b4c05a22f0674f10964a684a6 +Subproject commit e127f2e3490ad61fad2e8806a7220720ea6dbfc3 From a5a8a53023beb7c3836e4af78b09c45e907d210a Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Tue, 1 Feb 2022 20:24:27 -0800 Subject: [PATCH 03/18] Adjust paths to point to github.com/zeek repos --- .gitmodules | 2 +- README.md | 4 ++-- src | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index 53461fb..848f81a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "src"] path = src - url = https://github.com/ckreibich/tree-sitter-zeek-src + url = https://github.com/zeek/tree-sitter-zeek-src diff --git a/README.md b/README.md index ee1c48f..1bf98fc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # tree-sitter-zeek -[![Tests](https://github.com/ckreibich/tree-sitter-zeek/actions/workflows/test.yaml/badge.svg)](https://github.com/ckreibich/tree-sitter-zeek/actions/workflows/test.yaml) +[![Tests](https://github.com/zeek/tree-sitter-zeek/actions/workflows/test.yaml/badge.svg)](https://github.com/zeek/tree-sitter-zeek/actions/workflows/test.yaml) A [Zeek](https://zeek.org) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter). @@ -23,7 +23,7 @@ similars. To use the generated parser directly (e.g. via any of tree-sitter's [language bindings](https://tree-sitter.github.io/tree-sitter/#language-bindings)), clone this repository recursively. We maintain a separate -[git repository](https://github.com/ckreibich/tree-sitter-zeek-src) +[git repository](https://github.com/zeek/tree-sitter-zeek-src) to track generated sources. You do not need the tree-sitter CLI to use those sources. diff --git a/src b/src index e127f2e..7a1531d 160000 --- a/src +++ b/src @@ -1 +1 @@ -Subproject commit e127f2e3490ad61fad2e8806a7220720ea6dbfc3 +Subproject commit 7a1531db78b4849c991512fe5467bc6b53502dfc From 1fef7dd765c9190c3fce029d8cec6d082eb9f2e2 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Tue, 1 Feb 2022 20:44:08 -0800 Subject: [PATCH 04/18] More README tweaks --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1bf98fc..a06104c 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,11 @@ To use the generated parser directly (e.g. via any of tree-sitter's [language bindings](https://tree-sitter.github.io/tree-sitter/#language-bindings)), clone this repository recursively. We maintain a separate [git repository](https://github.com/zeek/tree-sitter-zeek-src) -to track generated sources. You do not need the tree-sitter CLI to use -those sources. +to track generated sources. You do not need the tree-sitter CLI +to use those sources in your tooling, but you'll likely want it +anyway to explore the parser. For example, `tree-sitter parse