@@ -41,6 +41,21 @@ module.exports = function defineGrammar(dialect) {
4141 ] ) ,
4242
4343 conflicts : ( $ , previous ) => previous . concat ( [
44+ [ $ . _expression , $ . call_expression ] ,
45+ [ $ . _expression , $ . arrow_function , $ . call_expression ] ,
46+ [ $ . _property_name , $ . arrow_function , $ . call_expression ] ,
47+ [ $ . _property_name , $ . _expression , $ . arrow_function , $ . call_expression ] ,
48+ [ $ . _property_name , $ . call_expression ] ,
49+ [ $ . _expression , $ . _property_name , $ . call_expression ] ,
50+ [ $ . _expression , $ . call_expression , $ . new_expression , $ . member_expression , $ . subscript_expression ] ,
51+ [ $ . _expression , $ . call_expression , $ . generic_type ] ,
52+
53+ [ $ . _expression , $ . call_expression , $ . new_expression ] ,
54+ [ $ . _expression , $ . new_expression ] ,
55+ [ $ . _expression , $ . arrow_function , $ . call_expression , $ . new_expression ] ,
56+ [ $ . call_expression , $ . new_expression ] ,
57+ [ $ . arrow_function , $ . new_expression , $ . call_expression ] ,
58+
4459 [ $ . call_expression , $ . binary_expression ] ,
4560 [ $ . call_expression , $ . binary_expression , $ . unary_expression ] ,
4661
@@ -104,25 +119,14 @@ module.exports = function defineGrammar(dialect) {
104119 optional ( $ . _initializer )
105120 ) ,
106121
107- call_expression : ( $ , previous ) => choice (
108- prec ( PREC . CALL , seq (
109- field ( 'function' , $ . _expression ) ,
110- field ( 'type_arguments' , optional ( $ . type_arguments ) ) ,
111- field ( 'arguments' , choice ( $ . arguments , $ . template_string ) )
112- ) ) ,
113- prec ( PREC . MEMBER , seq (
114- field ( 'function' , $ . _primary_expression ) ,
115- '?.' ,
116- field ( 'type_arguments' , optional ( $ . type_arguments ) ) ,
117- field ( 'arguments' , $ . arguments )
118- ) )
122+ call_expression : $ => choice (
123+ callExpression ( $ ) ( PREC . CALL ) ,
124+ callExpression ( $ ) ( PREC . MEMBER , '?.' ) ,
119125 ) ,
120126
121- new_expression : $ => prec . right ( PREC . NEW , seq (
127+ new_expression : $ => prec . dynamic ( PREC . NEW , seq (
122128 'new' ,
123- field ( 'constructor' , $ . _primary_expression ) ,
124- field ( 'type_arguments' , optional ( $ . type_arguments ) ) ,
125- field ( 'arguments' , optional ( $ . arguments ) )
129+ callExpression ( $ ) ( PREC . NEW )
126130 ) ) ,
127131
128132 _augmented_assignment_lhs : ( $ , previous ) => choice ( previous , $ . non_null_expression ) ,
@@ -792,6 +796,19 @@ module.exports = function defineGrammar(dialect) {
792796 } ) ;
793797}
794798
799+ function callExpression ( $ ) {
800+ return function ( precedence , punctuation ) {
801+ return seq (
802+ ...[
803+ field ( 'function' , $ . _primary_expression ) ,
804+ ...( punctuation ? [ punctuation ] : [ ] ) ,
805+ field ( 'type_arguments' , prec . dynamic ( precedence , optional ( $ . type_arguments ) ) ) ,
806+ field ( 'arguments' , choice ( $ . arguments , $ . template_string ) )
807+ ]
808+ )
809+ }
810+ }
811+
795812function commaSep1 ( rule ) {
796813 return sepBy1 ( ',' , rule ) ;
797814}
0 commit comments