grammar: Refactor apply Grammar

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-20 02:39:33 -04:00
parent 902dc945fd
commit 95c489ecd7
3 changed files with 15 additions and 10 deletions
+2 -1
View File
@@ -83,7 +83,7 @@ export default grammar({
variableDeclaration: $ => seq(optional($.annotations), $.typeRef, field('variable_name', $.identifier), optional(seq($.assignment, $.expression)), $._semicolon), variableDeclaration: $ => seq(optional($.annotations), $.typeRef, field('variable_name', $.identifier), optional(seq($.assignment, $.expression)), $._semicolon),
// 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, $.statement),
table_declaration: $ => seq($.table, $.identifier, '{', optional($.table_property_list), '}'), table_declaration: $ => seq($.table, $.identifier, '{', optional($.table_property_list), '}'),
@@ -107,6 +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),
// Parser statements // Parser statements
parserStatements: $ => repeat1($.parserStatement), parserStatements: $ => repeat1($.parserStatement),
+5 -3
View File
@@ -49,9 +49,11 @@ control simple() {
) )
) )
) )
(apply) (apply_statement
(statement (apply)
(blockStatement) (statement
(blockStatement)
)
) )
) )
) )
+8 -6
View File
@@ -13,12 +13,14 @@ control T() {
(control) (control)
(identifier) (identifier)
(parameters) (parameters)
(apply) (apply_statement
(statement (apply)
(blockStatement (statement
(statements (blockStatement
(statement (statements
(exit_statement) (statement
(exit_statement)
)
) )
) )
) )