@@ -408,8 +408,14 @@ module.exports = grammar({
408408 optional ( 'async' ) ,
409409 'def' ,
410410 field ( 'name' , $ . identifier ) ,
411+ $ . function_definition_scope ,
412+ ) ,
413+
414+ function_definition_scope : $ => seq (
411415 field ( 'type_parameters' , optional ( $ . type_parameter ) ) ,
412- field ( 'parameters' , $ . parameters ) ,
416+ '(' ,
417+ field ( 'parameters' , optional ( $ . parameters ) ) ,
418+ ')' ,
413419 optional (
414420 seq (
415421 '->' ,
@@ -493,6 +499,9 @@ module.exports = grammar({
493499 class_definition : $ => seq (
494500 'class' ,
495501 field ( 'name' , $ . identifier ) ,
502+ $ . class_definition_scope ,
503+ ) ,
504+ class_definition_scope : $ => seq (
496505 field ( 'type_parameters' , optional ( $ . type_parameter ) ) ,
497506 field ( 'superclasses' , optional ( $ . argument_list ) ) ,
498507 ':' ,
@@ -568,7 +577,13 @@ module.exports = grammar({
568577 ) ,
569578 ) ) ,
570579
571- dotted_name : $ => prec ( 1 , sep1 ( $ . identifier , '.' ) ) ,
580+ dotted_name : $ => prec ( 1 , seq (
581+ $ . identifier ,
582+ repeat ( seq (
583+ '.' ,
584+ alias ( $ . identifier , $ . member_identifier ) ,
585+ ) ) ,
586+ ) ) ,
572587
573588 // Match cases
574589
@@ -896,7 +911,7 @@ module.exports = grammar({
896911 attribute : $ => prec ( PREC . call , seq (
897912 field ( 'object' , $ . primary_expression ) ,
898913 '.' ,
899- field ( 'attribute' , $ . identifier ) ,
914+ field ( 'attribute' , alias ( $ . identifier , $ . member_identifier ) ) ,
900915 ) ) ,
901916
902917 subscript : $ => prec ( PREC . call , seq (
@@ -942,7 +957,7 @@ module.exports = grammar({
942957 ) ) ,
943958 union_type : $ => prec . left ( seq ( $ . type , '|' , $ . type ) ) ,
944959 constrained_type : $ => prec . right ( seq ( $ . type , ':' , $ . type ) ) ,
945- member_type : $ => seq ( $ . type , '.' , $ . identifier ) ,
960+ member_type : $ => seq ( $ . type , '.' , alias ( $ . identifier , $ . member_identifier ) ) ,
946961
947962 keyword_argument : $ => seq (
948963 field ( 'name' , choice ( $ . identifier , $ . keyword_identifier ) ) ,
0 commit comments