parser, compiler: Support Table Actions
Continuous Integration / Grammar Tests (push) Has been cancelled
Continuous Integration / Library Tests (push) Has been cancelled
Continuous Integration / Library Format Tests (push) Has been cancelled

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-30 05:38:29 -04:00
parent 833979a5c9
commit b97aa1af72
6 changed files with 342 additions and 17 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ export default grammar({
table_property_list: $ => repeat1(choice($.table_keys, $.table_actions)),
table_keys: $=> seq($.key, '=', '{', repeat($.table_key_entry), '}'),
table_key_entry: $=> seq($.keysetExpression, ':', $.table_key_match_type, $._semicolon),
table_actions: $=> seq($.actions, '=', '{', optional(repeat1($.identifier)), '}'),
table_actions: $=> seq($.actions, '=', '{', optional(repeat1(seq($.identifier, $._semicolon))), '}'),
// match types
table_key_match_type: $ => choice($.exact), // support exact only for now.
+73
View File
@@ -54,4 +54,77 @@ control simple() {
)
)
)
=========================
Simple Control Declaration With Actions
=========================
control simple() {
action a() {
}
action b() {
}
table t {
key = {
x: exact;
}
actions = {
a;
b;
}
}
apply {
}
};
---
(p4program
(declaration
(control_declaration
(control)
(identifier)
(parameters)
(action_declaration
(action)
(identifier)
(parameters)
(blockStatement)
)
(action_declaration
(action)
(identifier)
(parameters)
(blockStatement)
)
(table_declaration
(table)
(identifier)
(table_property_list
(table_keys
(key)
(table_key_entry
(keysetExpression
(expression
(simple_expression
(identifier)
)
)
)
(table_key_match_type
(exact)
)
)
)
(table_actions
(actions)
(identifier)
(identifier)
)
)
)
(apply_statement
(apply)
(blockStatement)
)
)
)
)