From 902dc945fda3bb53cfc3c5d7d409302e5a6a3e25 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Mon, 20 Apr 2026 02:27:36 -0400 Subject: [PATCH] grammar: Add apply to control declaration Signed-off-by: Will Hawkins --- tree-sitter-p4/grammar.js | 2 +- tree-sitter-p4/test/corpus/control.txt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tree-sitter-p4/grammar.js b/tree-sitter-p4/grammar.js index 787e147..8307220 100644 --- a/tree-sitter-p4/grammar.js +++ b/tree-sitter-p4/grammar.js @@ -83,7 +83,7 @@ export default grammar({ variableDeclaration: $ => seq(optional($.annotations), $.typeRef, field('variable_name', $.identifier), optional(seq($.assignment, $.expression)), $._semicolon), // Control declarations - control_declaration: $ => seq($.control, $.identifier, $.parameters, '{', repeat(choice($.table_declaration, $.action_declaration)), '}'), + control_declaration: $ => seq($.control, $.identifier, $.parameters, '{', repeat(choice($.table_declaration, $.action_declaration)), $.apply, $.statement, '}'), action_declaration: $ => seq($.action, $.identifier, $.parameters, $.statement), table_declaration: $ => seq($.table, $.identifier, '{', optional($.table_property_list), '}'), diff --git a/tree-sitter-p4/test/corpus/control.txt b/tree-sitter-p4/test/corpus/control.txt index af731b2..eb03494 100644 --- a/tree-sitter-p4/test/corpus/control.txt +++ b/tree-sitter-p4/test/corpus/control.txt @@ -9,6 +9,8 @@ control simple() { x: exact; } } + apply { + } }; --- @@ -47,6 +49,10 @@ control simple() { ) ) ) + (apply) + (statement + (blockStatement) + ) ) ) )