grammar: Make apply statements have block bodies

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-20 03:25:07 -04:00
parent 95c489ecd7
commit a3a06efdb4
3 changed files with 8 additions and 14 deletions
+2 -2
View File
@@ -84,7 +84,7 @@ export default grammar({
// Control declarations // Control declarations
control_declaration: $ => seq($.control, $.identifier, $.parameters, '{', repeat(choice($.table_declaration, $.action_declaration)), $.apply_statement, '}'), control_declaration: $ => seq($.control, $.identifier, $.parameters, '{', repeat(choice($.table_declaration, $.action_declaration)), $.apply_statement, '}'),
action_declaration: $ => seq($.action, $.identifier, $.parameters, $.statement), action_declaration: $ => seq($.action, $.identifier, $.parameters, $.blockStatement),
table_declaration: $ => seq($.table, $.identifier, '{', optional($.table_property_list), '}'), table_declaration: $ => seq($.table, $.identifier, '{', optional($.table_property_list), '}'),
// Table property list // Table property list
@@ -107,7 +107,7 @@ export default grammar({
assignmentStatement: $=> seq($.expression, $.assignment, $.expression, $._semicolon), assignmentStatement: $=> seq($.expression, $.assignment, $.expression, $._semicolon),
return_statement: $=> seq($._return, $.expression, $._semicolon), return_statement: $=> seq($._return, $.expression, $._semicolon),
exit_statement: $=> seq($._exit, $._semicolon), exit_statement: $=> seq($._exit, $._semicolon),
apply_statement: $=> seq($.apply, $.statement), apply_statement: $=> seq($.apply, $.blockStatement),
// Parser statements // Parser statements
parserStatements: $ => repeat1($.parserStatement), parserStatements: $ => repeat1($.parserStatement),
+2 -6
View File
@@ -24,9 +24,7 @@ control simple() {
(action) (action)
(identifier) (identifier)
(parameters) (parameters)
(statement (blockStatement)
(blockStatement)
)
) )
(table_declaration (table_declaration
(table) (table)
@@ -51,9 +49,7 @@ control simple() {
) )
(apply_statement (apply_statement
(apply) (apply)
(statement (blockStatement)
(blockStatement)
)
) )
) )
) )
+4 -6
View File
@@ -15,12 +15,10 @@ control T() {
(parameters) (parameters)
(apply_statement (apply_statement
(apply) (apply)
(statement (blockStatement
(blockStatement (statements
(statements (statement
(statement (exit_statement)
(exit_statement)
)
) )
) )
) )