Add Grammar Support for == And Array Access

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-03-13 08:26:14 -04:00
parent 377f40447f
commit 16692de7b2
+9 -1
View File
@@ -88,11 +88,16 @@ export default grammar({
parserTransitionStatement: $ => seq($.transition, $.transitionSelectionExpression, $._semicolon), parserTransitionStatement: $ => seq($.transition, $.transitionSelectionExpression, $._semicolon),
// Expressions // Expressions
expression: $ => choice($.identifier, $.integer, $.booleanLiteralExpression, $.string_literal), // Very limited. expression: $ => choice($.identifier, $.integer, $.booleanLiteralExpression, $.string_literal, $.binaryOperatorExpression, $.arrayAccessExpression), // Very limited.
booleanLiteralExpression: $ => choice($.true, $.false), booleanLiteralExpression: $ => choice($.true, $.false),
selectExpression: $ => seq($.select, '(', $.expression, ')', '{', $.selectBody, '}'), // TODO: Should be expression list and not just a single expression selectExpression: $ => seq($.select, '(', $.expression, ')', '{', $.selectBody, '}'), // TODO: Should be expression list and not just a single expression
transitionSelectionExpression: $ => choice($.identifier, $.selectExpression), transitionSelectionExpression: $ => choice($.identifier, $.selectExpression),
keysetExpression: $ => $.expression, keysetExpression: $ => $.expression,
binaryOperatorExpression: $ => choice($.binaryEqualOperatorExpression),
arrayAccessExpression: $=> seq($.identifier, $.open_bracket, $.expression, $.close_bracket),
// Binary Operations
binaryEqualOperatorExpression: $ => prec.left(2, seq($.expression, $.double_equal, $.expression)),
// Tokens // Tokens
_semicolon: $ => ";", _semicolon: $ => ";",
@@ -147,6 +152,9 @@ export default grammar({
string_literal: $ => /".*"/, string_literal: $ => /".*"/,
integer: $ => /[0-9]+/, integer: $ => /[0-9]+/,
annotation_literal: $ => /@[a-z_]+/, annotation_literal: $ => /@[a-z_]+/,
double_equal: $=> '==',
open_bracket: $=> '[',
close_bracket: $=> ']',
}, },
} }
); );