parser, compiler: Support Table Actions
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user