@@ -15,8 +15,12 @@ module.exports = grammar({
1515    $ . _automatic_semicolon , 
1616    $ . _template_chars , 
1717    $ . _ternary_qmark , 
18+     $ . _shorthand_arrow , 
1819    $ . html_comment , 
20+     // we use these just as signaling to the ASI scanner 
1921    '||' , 
22+     '(' , 
23+     '[' , 
2024    // We use escape sequence and regex pattern to tell the scanner if we're currently inside a string or template string, in which case 
2125    // it should NOT parse html comments. 
2226    $ . escape_sequence , 
@@ -58,7 +62,6 @@ module.exports = grammar({
5862  precedences : $  =>  [ 
5963    [ 
6064      'member' , 
61-       'template_call' , 
6265      'call' , 
6366      $ . update_expression , 
6467      'unary_void' , 
@@ -78,8 +81,9 @@ module.exports = grammar({
7881      $ . sequence_expression , 
7982      $ . arrow_function , 
8083    ] , 
84+     [ 'new' ,  $ . primary_expression ] , 
8185    [ 'assign' ,  $ . primary_expression ] , 
82-     [ 'member' ,  'template_call ' ,  'new ' ,  'call ' ,  $ . expression ] , 
86+     [ 'member' ,  'new_args ' ,  'call ' ,  'new_no_args ' ,  $ . expression ] , 
8387    [ 'declaration' ,  'literal' ] , 
8488    [ $ . primary_expression ,  $ . statement_block ,  'object' ] , 
8589    [ $ . meta_property ,  $ . import ] , 
@@ -488,12 +492,14 @@ module.exports = grammar({
488492      $ . binary_expression , 
489493      $ . ternary_expression , 
490494      $ . update_expression , 
491-       $ . new_expression , 
492495      $ . yield_expression , 
496+       $ . arrow_function , 
493497    ) , 
494498
499+     // Note: this is similar to MemberExpression from the ecmascript spec 
495500    primary_expression : $  =>  choice ( 
496501      $ . subscript_expression , 
502+       $ . new_expression , 
497503      $ . member_expression , 
498504      $ . parenthesized_expression , 
499505      $ . _identifier , 
@@ -510,7 +516,6 @@ module.exports = grammar({
510516      $ . object , 
511517      $ . array , 
512518      $ . function_expression , 
513-       $ . arrow_function , 
514519      $ . generator_function , 
515520      $ . class , 
516521      $ . meta_property , 
@@ -768,11 +773,10 @@ module.exports = grammar({
768773        ) ) , 
769774        $ . _call_signature , 
770775      ) , 
771-       '=>' , 
772-       field ( 'body' ,  choice ( 
773-         $ . expression , 
774-         $ . statement_block , 
775-       ) ) , 
776+       choice ( 
777+         seq ( $ . _shorthand_arrow ,  field ( 'body' ,  $ . expression ) ) , 
778+         seq ( choice ( '=>' ,  $ . _shorthand_arrow ) ,  field ( 'body' ,  $ . statement_block ) ) , 
779+       ) , 
776780    ) , 
777781
778782    // Override 
@@ -783,12 +787,8 @@ module.exports = grammar({
783787
784788    call_expression : $  =>  choice ( 
785789      prec ( 'call' ,  seq ( 
786-         field ( 'function' ,  choice ( $ . expression ,  $ . import ) ) , 
787-         field ( 'arguments' ,  $ . arguments ) , 
788-       ) ) , 
789-       prec ( 'template_call' ,  seq ( 
790-         field ( 'function' ,  choice ( $ . primary_expression ,  $ . new_expression ) ) , 
791-         field ( 'arguments' ,  $ . template_string ) , 
790+         field ( 'function' ,  choice ( $ . primary_expression ,  $ . import ) ) , 
791+         field ( 'arguments' ,  choice ( $ . arguments ,  $ . template_string ) ) , 
792792      ) ) , 
793793      prec ( 'member' ,  seq ( 
794794        field ( 'function' ,  $ . primary_expression ) , 
@@ -797,11 +797,17 @@ module.exports = grammar({
797797      ) ) , 
798798    ) , 
799799
800-     new_expression : $  =>  prec . right ( 'new' ,  seq ( 
801-       'new' , 
802-       field ( 'constructor' ,  choice ( $ . primary_expression ,  $ . new_expression ) ) , 
803-       field ( 'arguments' ,  optional ( prec . dynamic ( 1 ,  $ . arguments ) ) ) , 
804-     ) ) , 
800+     new_expression : $  =>  choice ( 
801+       prec ( 'new_args' ,  seq ( 
802+         'new' , 
803+         field ( 'constructor' ,  $ . primary_expression ) , 
804+         field ( 'arguments' ,  $ . arguments ) , 
805+       ) ) , 
806+       prec ( 'new_no_args' ,  seq ( 
807+         'new' , 
808+         field ( 'constructor' ,  $ . primary_expression ) , 
809+       ) ) , 
810+     ) , 
805811
806812    await_expression : $  =>  prec ( 'unary_void' ,  seq ( 
807813      'await' , 
0 commit comments