Better Support For Keysets

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-03-27 01:36:38 -04:00
parent fafc80553e
commit 99804e3053
7 changed files with 476 additions and 51 deletions
+2 -1
View File
@@ -94,7 +94,7 @@ export default grammar({
booleanLiteralExpression: $ => choice($.true, $.false),
selectExpression: $ => seq($.select, '(', $.expression, ')', '{', $.selectBody, '}'), // TODO: Should be expression list and not just a single expression
transitionSelectionExpression: $ => choice($.identifier, $.selectExpression),
keysetExpression: $ => $.expression,
keysetExpression: $ => choice($.expression, $.default_keyset),
binaryOperatorExpression: $ => choice($.binaryEqualOperatorExpression,
$.binaryLessThanOperatorExpression,
$.binaryLessThanEqualOperatorExpression,
@@ -177,6 +177,7 @@ export default grammar({
string_literal: $ => /"[^"]*"/,
integer: $ => /[0-9]+/,
annotation_literal: $ => /@[A-Za-z_]+/,
default_keyset: $=> '_',
double_equal: $=> '==',
less_than: $=> '<',
@@ -87,3 +87,54 @@ parser simple() {
)
)
)
=========================
Simple Transition Statement (To Select Expression With Default)
=========================
parser simple() {
state start {
transition select (se) {
_: next_state;
};
}
};
---
(p4program
(declaration
(parserDeclaration
(parserType
(parser)
(identifier)
)
(parserStates
(parserState
(state)
(identifier)
(parserTransitionStatement
(transition)
(transitionSelectionExpression
(selectExpression
(select)
(expression
(simple_expression
(identifier)
)
)
(selectBody
(selectCase
(keysetExpression
(default_keyset)
)
(colon)
(identifier)
)
)
)
)
)
)
)
)
)
)