Add Support For Parsing Struct Field Access

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-03-16 08:30:57 -04:00
parent 75f9f68349
commit 8ee20fcf9f
2 changed files with 108 additions and 1 deletions
+3 -1
View File
@@ -88,13 +88,14 @@ export default grammar({
parserTransitionStatement: $ => seq($.transition, $.transitionSelectionExpression, $._semicolon),
// Expressions
expression: $ => choice($.identifier, $.integer, $.booleanLiteralExpression, $.string_literal, $.binaryOperatorExpression, $.arrayAccessExpression), // Very limited.
expression: $ => choice($.identifier, $.integer, $.booleanLiteralExpression, $.string_literal, $.binaryOperatorExpression, $.arrayAccessExpression, $.fieldAccessExpression), // Very limited.
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,
binaryOperatorExpression: $ => choice($.binaryEqualOperatorExpression),
arrayAccessExpression: $=> seq($.expression, $.open_bracket, $.expression, $.close_bracket),
fieldAccessExpression: $=> prec.left(2, seq($.expression, $.field_access, $.identifier)),
// Binary Operations
binaryEqualOperatorExpression: $ => prec.left(2, seq($.expression, $.double_equal, $.expression)),
@@ -155,6 +156,7 @@ export default grammar({
double_equal: $=> '==',
open_bracket: $=> '[',
close_bracket: $=> ']',
field_access: $=> '.',
},
}
);