From 36aa13b179b865261e0838c2e60c1f70ce2ed509 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 8 Jun 2025 02:04:07 -0400 Subject: [PATCH 1/3] fix: Fix nested packages **Problem** packages are treated to be top-level only, so the nested ones aren't parsed correctly. **Solution** This moves packages into definition so they can be nested. --- grammar.js | 4 ++-- test/corpus/definitions.txt | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/grammar.js b/grammar.js index 876e924..a3bf808 100644 --- a/grammar.js +++ b/grammar.js @@ -126,8 +126,6 @@ module.exports = grammar({ _top_level_definition: $ => choice( - $.package_clause, - $.package_object, $._definition, $._end_marker, $.expression, @@ -150,6 +148,8 @@ module.exports = grammar({ $.type_definition, $.function_definition, $.function_declaration, + $.package_clause, + $.package_object, ), enum_definition: $ => diff --git a/test/corpus/definitions.txt b/test/corpus/definitions.txt index 98477d8..fa37076 100644 --- a/test/corpus/definitions.txt +++ b/test/corpus/definitions.txt @@ -141,6 +141,11 @@ package a.b package c { object A } +package d { + package e { + object B + } +} -------------------------------------------------------------------------------- @@ -154,7 +159,17 @@ package c { (identifier)) (template_body (object_definition - (identifier))))) + (identifier)))) + (package_clause + (package_identifier + (identifier)) + (template_body + (package_clause + (package_identifier + (identifier)) + (template_body + (object_definition + (identifier))))))) ================================================================================ Package with comma @@ -210,6 +225,12 @@ package object d extends A { val hello: String = "there" } +package object p1 { + package object p2 { + val a = 1 + } +} + -------------------------------------------------------------------------------- (compilation_unit @@ -221,7 +242,16 @@ package object d extends A { (val_definition (identifier) (type_identifier) - (string))))) + (string)))) + (package_object + (identifier) + (template_body + (package_object + (identifier) + (template_body + (val_definition + (identifier) + (integer_literal))))))) ================================================================================ Imports From 51c11bca42f69f06ac0b285906c939deef25ca24 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 8 Jun 2025 02:26:50 -0400 Subject: [PATCH 2/3] Opt out of parser diff --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec4f5e9..60248d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,6 +85,7 @@ jobs: - name: Run parser and binding tests uses: tree-sitter/parser-test-action@v2 with: + generate: false test-rust: true test-node: true test-python: true From 595ac311d719fc4923292049c79484a5600ef9d6 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 8 Jun 2025 02:45:56 -0400 Subject: [PATCH 3/3] Opt out of Swift testing --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60248d2..23d6c84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,7 @@ jobs: test-node: true test-python: true test-go: true - test-swift: true + test-swift: false - name: Parse sample files uses: tree-sitter/parse-action@v4