From 51b1ccfa6bddf80055e741ad099bcbf70c755a76 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Wed, 13 Dec 2023 17:33:29 +0100 Subject: [PATCH] Compiler: js-parser, support #privateName --- compiler/lib/js_output.ml | 4 ++-- compiler/lib/js_parser.mly | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/lib/js_output.ml b/compiler/lib/js_output.ml index 62945c3604..3f7bad9ddb 100644 --- a/compiler/lib/js_output.ml +++ b/compiler/lib/js_output.ml @@ -886,8 +886,8 @@ struct (* There MUST be a space between the yield and its argument. A line return will not work *))) | EPrivName i -> - PP.string f "#"; - ident f i + PP.string f "#"; + ident f i | CoverCallExpressionAndAsyncArrowHead e | CoverParenthesizedExpressionAndArrowParameterList e -> early_error e diff --git a/compiler/lib/js_parser.mly b/compiler/lib/js_parser.mly index 124305dce5..3e2ad11b4b 100644 --- a/compiler/lib/js_parser.mly +++ b/compiler/lib/js_parser.mly @@ -896,6 +896,8 @@ call_expr(x): | T_SUPER a=arguments { ECall(vartok $startpos($1) T_SUPER,ANormal, a, p $symbolstartpos) } | e=call_expr(x) a=access i=method_name { EDot (e,a,i) } + | e=call_expr(x) a=access T_POUND i=method_name + { EDotPrivate (e,a,i) } new_expr(x): | e=member_expr(x) { e } @@ -915,7 +917,9 @@ member_expr(x): | e1=member_expr(x) T_PLING_PERIOD "[" e2=expr "]" { (EAccess (e1,ANullish, e2)) } | e1=member_expr(x) ak=access i=field_name - { (EDot(e1,ak,i)) } + { (EDot(e1,ak,i)) } + | e1=member_expr(x) a=access T_POUND i=field_name + { (EDotPrivate(e1,a,i)) } | T_NEW e1=member_expr(d1) a=arguments { (ENew(e1, Some a)) } | e=member_expr(x) t=template_literal @@ -926,10 +930,6 @@ member_expr(x): { (EDot(vartok $startpos($1) T_SUPER,ak,i)) } | T_NEW "." T_TARGET { (EDot(vartok $startpos($1) T_NEW,ANormal,Stdlib.Utf8_string.of_string_exn "target")) } - | e1=member_expr(x) "." T_POUND i=field_name - { (EDotPrivate(e1,ANormal,i)) } - | e1=member_expr(x) T_PLING_PERIOD T_POUND i=field_name - { (EDotPrivate(e1,ANullish,i)) } primary_expr(x): | e=primary_expr_no_braces | e=x { e }