@@ -47,7 +47,7 @@ module.exports = grammar({
4747
4848 extras : $ => [
4949 / \s / ,
50- $ . _comment ,
50+ $ . comment ,
5151 ] ,
5252
5353 rules : {
@@ -159,6 +159,7 @@ module.exports = grammar({
159159 $ . _literal ,
160160 $ . binary_expression ,
161161 $ . function_call_expression ,
162+ $ . struct_expression ,
162163 $ . prefix_unary_expression ,
163164 $ . parenthesized_expression ,
164165 $ . uzumaki_keyword
@@ -189,10 +190,19 @@ module.exports = grammar({
189190 field ( 'function' , $ . _lval_expression ) ,
190191 optional ( field ( 'type_parameters' , alias ( $ . type_argument_list , $ . type_parameters ) ) ) ,
191192 '(' ,
192- optional ( sep1 ( seq ( optional ( seq ( field ( 'argument_name' , $ . _name ) , ':' ) ) , field ( 'argument' , $ . _expression ) ) , ',' ) ) ,
193+ optional ( sep1 ( seq ( optional ( seq ( field ( 'argument_name' , $ . _name ) , $ . _typedef_symbol ) ) , field ( 'argument' , $ . _expression ) ) , ',' ) ) ,
193194 ')' ,
194195 ) ) ,
195196
197+ struct_expression : $ => seq (
198+ field ( 'name' , $ . _name ) ,
199+ $ . _lcb_symbol ,
200+ optional ( sep1 (
201+ seq ( field ( 'field_name' , $ . _name ) , $ . _typedef_symbol , field ( 'field_value' , $ . _expression ) ) ,
202+ $ . _comma_symbol ) ) ,
203+ $ . _rcb_symbol ,
204+ ) ,
205+
196206 expression_statement : $ => seq (
197207 $ . _expression ,
198208 $ . _terminal_symbol
@@ -299,11 +309,11 @@ module.exports = grammar({
299309
300310 struct_definition : $ => seq (
301311 'struct' ,
302- field ( 'struct_name ' , $ . identifier ) ,
312+ field ( 'name ' , $ . identifier ) ,
303313 $ . _lcb_symbol ,
304314 repeat ( choice (
305315 seq ( field ( 'field' , $ . struct_field ) , ';' ) ,
306- field ( 'method ' , $ . function_definition ) ,
316+ field ( 'value ' , $ . function_definition ) ,
307317 ) ) ,
308318 $ . _rcb_symbol ,
309319 ) ,
@@ -485,7 +495,7 @@ module.exports = grammar({
485495
486496 string_literal : $ => seq (
487497 '"' ,
488- $ . _string_literal_content ,
498+ optional ( $ . _string_literal_content ) ,
489499 '"' ,
490500 ) ,
491501
@@ -497,10 +507,10 @@ module.exports = grammar({
497507
498508 array_literal : $ => seq (
499509 '[' ,
500- sep1 (
510+ optional ( sep1 (
501511 $ . _expression ,
502512 ',' ,
503- ) ,
513+ ) ) ,
504514 ']' ,
505515 ) ,
506516
@@ -561,6 +571,7 @@ module.exports = grammar({
561571 $ . _reserved_identifier ,
562572 ) ,
563573
564- _comment : _ => token ( seq ( '///' , / [ ^ \n \r ] * / ) ) ,
574+ // Comments start with '///'
575+ comment : _ => token ( seq ( '///' , / [ ^ \n \r ] * / ) ) ,
565576 } ,
566577} ) ;
0 commit comments