@@ -176,6 +176,7 @@ static const char ident_var_zero_multi_digit[] = "Numeric variables with more th
176176/* Bits in the flags parameter of various functions */
177177#define CHECK_KEYWORD (1 << 0)
178178#define ALLOW_PACKAGE (1 << 1)
179+ #define CHECK_DOLLAR (1 << 2)
179180
180181#ifdef DEBUGGING
181182static const char * const lex_state_names [] = {
@@ -5503,8 +5504,7 @@ yyl_sigvar(pTHX_ char *s)
55035504 char * dest = PL_tokenbuf + 1 ;
55045505 /* read var name, including sigil, into PL_tokenbuf */
55055506 PL_tokenbuf [0 ] = sigil ;
5506- parse_ident (& s , & dest , C_ARRAY_END (PL_tokenbuf ),
5507- 0 , cBOOL (UTF ), FALSE);
5507+ parse_ident (& s , & dest , C_ARRAY_END (PL_tokenbuf ), cBOOL (UTF ), 0 );
55085508 * dest = '\0' ;
55095509 assert (PL_tokenbuf [1 ]); /* we have a variable name */
55105510 }
@@ -10538,8 +10538,8 @@ S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, STRLEN keylen,
1053810538}
1053910539
1054010540STATIC void
10541- S_parse_ident (pTHX_ char * * s , char * * d , char * const e , int allow_package ,
10542- bool is_utf8 , bool check_dollar )
10541+ S_parse_ident (pTHX_ char * * s , char * * d , char * const e , bool is_utf8 ,
10542+ U32 flags )
1054310543{
1054410544 PERL_ARGS_ASSERT_PARSE_IDENT ;
1054510545 assert (* s <= PL_bufend );
@@ -10565,10 +10565,12 @@ S_parse_ident(pTHX_ char **s, char **d, char * const e, int allow_package,
1056510565 * variable path. Each iteration of the loop below picks up one segment
1056610566 * of the path. If the apostrophe is allowed as a package separator, it
1056710567 * is converted to "::", so later code doesn't have to concern itself with
10568- * this possibility.
10569- *
10570- * 'check_dollar' is used to look for and stop parsing before the dollar
10568+ * this possibility. */
10569+ const bool allow_package = flags & ALLOW_PACKAGE ;
10570+
10571+ /* 'check_dollar' is used to look for and stop parsing before the dollar
1057110572 * in things like Foo::$bar */
10573+ const bool check_dollar = flags & CHECK_DOLLAR ;
1057210574
1057310575 while (* s < PL_bufend ) {
1057410576 if (* d >= e )
@@ -10642,7 +10644,8 @@ Perl_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STR
1064210644 char * const e = d + destlen - 3 ; /* two-character token, ending NUL */
1064310645 bool is_utf8 = cBOOL (UTF );
1064410646
10645- parse_ident (& s , & d , e , allow_package , is_utf8 , TRUE);
10647+ parse_ident (& s , & d , e , is_utf8 ,
10648+ (CHECK_DOLLAR | ((allow_package ) ? ALLOW_PACKAGE : 0 )));
1064610649 * d = '\0' ;
1064710650 * slp = d - dest ;
1064810651 return s ;
@@ -10683,7 +10686,7 @@ S_scan_ident(pTHX_ char *s, char *dest, char *dest_end, bool chk_unary)
1068310686 croak (ident_var_zero_multi_digit );
1068410687 }
1068510688 else { /* See if it is a "normal" identifier */
10686- parse_ident (& s , & d , e , 1 , is_utf8 , FALSE );
10689+ parse_ident (& s , & d , e , is_utf8 , ALLOW_PACKAGE );
1068710690 }
1068810691 * d = '\0' ;
1068910692 d = dest ;
@@ -10804,7 +10807,8 @@ S_scan_ident(pTHX_ char *s, char *dest, char *dest_end, bool chk_unary)
1080410807 (the later check for } being at the expected point will trap
1080510808 cases where this doesn't pan out.) */
1080610809 d += advance ;
10807- parse_ident (& s , & d , e , 1 , is_utf8 , TRUE);
10810+ parse_ident (& s , & d , e , is_utf8 , ( ALLOW_PACKAGE
10811+ |CHECK_DOLLAR ));
1080810812 * d = '\0' ;
1080910813 }
1081010814 else { /* caret word: ${^Foo} ${^CAPTURE[0]} */
0 commit comments