File tree 6 files changed +8147
-7506
lines changed
6 files changed +8147
-7506
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,21 @@ module.exports = grammar(WGSL, {
19
19
original ,
20
20
) ,
21
21
22
+ function_declaration : ( $ , original ) => choice ( seq (
23
+ optional ( "virtual" ) ,
24
+ original
25
+ ) , seq (
26
+ "override" ,
27
+ repeat ( $ . attribute ) ,
28
+ "fn" ,
29
+ field ( "name" , $ . import_path ) ,
30
+ "(" ,
31
+ field ( "parameters" , optional ( $ . parameter_list ) ) ,
32
+ ")" ,
33
+ field ( "type" , optional ( $ . function_return_type_declaration ) ) ,
34
+ field ( "body" , $ . compound_statement )
35
+ ) ) ,
36
+
22
37
struct_declaration : $ => seq (
23
38
"struct" ,
24
39
field ( "name" , $ . identifier ) ,
Original file line number Diff line number Diff line change 400
400
}
401
401
},
402
402
"function_declaration" : {
403
- "type" : " SEQ " ,
403
+ "type" : " CHOICE " ,
404
404
"members" : [
405
405
{
406
- "type" : " REPEAT" ,
407
- "content" : {
408
- "type" : " SYMBOL" ,
409
- "name" : " attribute"
410
- }
411
- },
412
- {
413
- "type" : " STRING" ,
414
- "value" : " fn"
415
- },
416
- {
417
- "type" : " FIELD" ,
418
- "name" : " name" ,
419
- "content" : {
420
- "type" : " SYMBOL" ,
421
- "name" : " identifier"
422
- }
423
- },
424
- {
425
- "type" : " STRING" ,
426
- "value" : " ("
406
+ "type" : " SEQ" ,
407
+ "members" : [
408
+ {
409
+ "type" : " CHOICE" ,
410
+ "members" : [
411
+ {
412
+ "type" : " STRING" ,
413
+ "value" : " virtual"
414
+ },
415
+ {
416
+ "type" : " BLANK"
417
+ }
418
+ ]
419
+ },
420
+ {
421
+ "type" : " SEQ" ,
422
+ "members" : [
423
+ {
424
+ "type" : " REPEAT" ,
425
+ "content" : {
426
+ "type" : " SYMBOL" ,
427
+ "name" : " attribute"
428
+ }
429
+ },
430
+ {
431
+ "type" : " STRING" ,
432
+ "value" : " fn"
433
+ },
434
+ {
435
+ "type" : " FIELD" ,
436
+ "name" : " name" ,
437
+ "content" : {
438
+ "type" : " SYMBOL" ,
439
+ "name" : " identifier"
440
+ }
441
+ },
442
+ {
443
+ "type" : " STRING" ,
444
+ "value" : " ("
445
+ },
446
+ {
447
+ "type" : " FIELD" ,
448
+ "name" : " parameters" ,
449
+ "content" : {
450
+ "type" : " CHOICE" ,
451
+ "members" : [
452
+ {
453
+ "type" : " SYMBOL" ,
454
+ "name" : " parameter_list"
455
+ },
456
+ {
457
+ "type" : " BLANK"
458
+ }
459
+ ]
460
+ }
461
+ },
462
+ {
463
+ "type" : " STRING" ,
464
+ "value" : " )"
465
+ },
466
+ {
467
+ "type" : " FIELD" ,
468
+ "name" : " type" ,
469
+ "content" : {
470
+ "type" : " CHOICE" ,
471
+ "members" : [
472
+ {
473
+ "type" : " SYMBOL" ,
474
+ "name" : " function_return_type_declaration"
475
+ },
476
+ {
477
+ "type" : " BLANK"
478
+ }
479
+ ]
480
+ }
481
+ },
482
+ {
483
+ "type" : " FIELD" ,
484
+ "name" : " body" ,
485
+ "content" : {
486
+ "type" : " SYMBOL" ,
487
+ "name" : " compound_statement"
488
+ }
489
+ }
490
+ ]
491
+ }
492
+ ]
427
493
},
428
494
{
429
- "type" : " FIELD" ,
430
- "name" : " parameters" ,
431
- "content" : {
432
- "type" : " CHOICE" ,
433
- "members" : [
434
- {
495
+ "type" : " SEQ" ,
496
+ "members" : [
497
+ {
498
+ "type" : " STRING" ,
499
+ "value" : " override"
500
+ },
501
+ {
502
+ "type" : " REPEAT" ,
503
+ "content" : {
435
504
"type" : " SYMBOL" ,
436
- "name" : " parameter_list"
437
- },
438
- {
439
- "type" : " BLANK"
505
+ "name" : " attribute"
440
506
}
441
- ]
442
- }
443
- },
444
- {
445
- "type" : " STRING" ,
446
- "value" : " )"
447
- },
448
- {
449
- "type" : " FIELD" ,
450
- "name" : " type" ,
451
- "content" : {
452
- "type" : " CHOICE" ,
453
- "members" : [
454
- {
507
+ },
508
+ {
509
+ "type" : " STRING" ,
510
+ "value" : " fn"
511
+ },
512
+ {
513
+ "type" : " FIELD" ,
514
+ "name" : " name" ,
515
+ "content" : {
455
516
"type" : " SYMBOL" ,
456
- "name" : " function_return_type_declaration"
457
- },
458
- {
459
- "type" : " BLANK"
517
+ "name" : " import_path"
460
518
}
461
- ]
462
- }
463
- },
464
- {
465
- "type" : " FIELD" ,
466
- "name" : " body" ,
467
- "content" : {
468
- "type" : " SYMBOL" ,
469
- "name" : " compound_statement"
470
- }
519
+ },
520
+ {
521
+ "type" : " STRING" ,
522
+ "value" : " ("
523
+ },
524
+ {
525
+ "type" : " FIELD" ,
526
+ "name" : " parameters" ,
527
+ "content" : {
528
+ "type" : " CHOICE" ,
529
+ "members" : [
530
+ {
531
+ "type" : " SYMBOL" ,
532
+ "name" : " parameter_list"
533
+ },
534
+ {
535
+ "type" : " BLANK"
536
+ }
537
+ ]
538
+ }
539
+ },
540
+ {
541
+ "type" : " STRING" ,
542
+ "value" : " )"
543
+ },
544
+ {
545
+ "type" : " FIELD" ,
546
+ "name" : " type" ,
547
+ "content" : {
548
+ "type" : " CHOICE" ,
549
+ "members" : [
550
+ {
551
+ "type" : " SYMBOL" ,
552
+ "name" : " function_return_type_declaration"
553
+ },
554
+ {
555
+ "type" : " BLANK"
556
+ }
557
+ ]
558
+ }
559
+ },
560
+ {
561
+ "type" : " FIELD" ,
562
+ "name" : " body" ,
563
+ "content" : {
564
+ "type" : " SYMBOL" ,
565
+ "name" : " compound_statement"
566
+ }
567
+ }
568
+ ]
471
569
}
472
570
]
473
571
},
Original file line number Diff line number Diff line change 892
892
{
893
893
"type" : " identifier" ,
894
894
"named" : true
895
+ },
896
+ {
897
+ "type" : " import_path" ,
898
+ "named" : true
895
899
}
896
900
]
897
901
},
2769
2773
"type" : " vec4" ,
2770
2774
"named" : false
2771
2775
},
2776
+ {
2777
+ "type" : " virtual" ,
2778
+ "named" : false
2779
+ },
2772
2780
{
2773
2781
"type" : " while" ,
2774
2782
"named" : false
You can’t perform that action at this time.
0 commit comments