Parse Struct Declarations

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-03-27 03:33:15 -04:00
parent 5abaac2816
commit cd26d1d22c
14 changed files with 426 additions and 155 deletions
+5 -1
View File
@@ -63,7 +63,11 @@ export default grammar({
instantiation: $ => seq($.typeRef, '(', optional($.parameterList), ')', $.identifier),
// Declarations
declaration: $ => seq(choice($.parserDeclaration, $.parserTypeDeclaration)),
declaration: $ => seq(choice($.parserDeclaration, $.parserTypeDeclaration, $.type_declaration)),
type_declaration: $=> choice($.struct_declaration),
struct_declaration: $ => seq($.struct, $.identifier, '{', optional($.struct_declaration_fields), '}'),
struct_declaration_fields: $=> repeat1(seq($.variableDeclaration)),
// Make separate productions for the parser type and the parser type declaration because the latter can have type parameters.
parserTypeDeclaration: $ => seq(optional($.annotations), $.parser, field('parser_name', $.identifier), optional($.typeParameters), '(', optional($.parameterList), ')'),