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),
+2
View File
@@ -49,11 +49,13 @@ control simple() {
) )
) )
) )
(apply_statement
(apply) (apply)
(statement (statement
(blockStatement) (blockStatement)
) )
) )
) )
)
) )
@@ -13,6 +13,7 @@ control T() {
(control) (control)
(identifier) (identifier)
(parameters) (parameters)
(apply_statement
(apply) (apply)
(statement (statement
(blockStatement (blockStatement
@@ -25,6 +26,7 @@ control T() {
) )
) )
) )
)
) )
========================= =========================
Return Statement Return Statement