From 86ae8d9a6f56e9e71efc1f3e556f6770dc07566e Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Mon, 26 Feb 2018 13:50:50 +0000 Subject: subtly change meaning of XATTRBLOCK, XATTRTERM Currently they tell the toker that the next thing will be attributes, followed by an XBLOCK or XTERMBLOCK respectively. This commit subtly changes their meanings so that they indicate that attributes legally *might* follow. This makes the code which initially sets them slightly simpler (no need to check whether the next char is ':'), and the code elsewhere in yylex() which handles XATTR* only triggers if the next char is ':' anyway. Doing it this way will shortly make detection simpler of an attribute illegally following a signature. --- toke.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'toke.c') diff --git a/toke.c b/toke.c index 020a545404..df1d7fe15b 100644 --- a/toke.c +++ b/toke.c @@ -8660,7 +8660,6 @@ Perl_yylex(pTHX) really_sub: { char * const tmpbuf = PL_tokenbuf + 1; - expectation attrful; bool have_name, have_proto; const int key = tmp; SV *format_name = NULL; @@ -8675,8 +8674,7 @@ Perl_yylex(pTHX) || (*s == ':' && s[1] == ':')) { - PL_expect = XBLOCK; - attrful = XATTRBLOCK; + PL_expect = XATTRBLOCK; d = scan_word(s, tmpbuf, sizeof PL_tokenbuf - 1, TRUE, &len); if (key == KEY_format) @@ -8707,8 +8705,7 @@ Perl_yylex(pTHX) Perl_croak(aTHX_ "Missing name in \"%s\"", PL_bufptr); } - PL_expect = XTERMBLOCK; - attrful = XATTRTERM; + PL_expect = XATTRTERM; sv_setpvs(PL_subname,"?"); have_name = FALSE; } @@ -8738,9 +8735,9 @@ Perl_yylex(pTHX) else have_proto = FALSE; - if (*s == ':' && s[1] != ':') - PL_expect = attrful; - else if ((*s != '{' && *s != '(') && key != KEY_format) { + if ( !(*s == ':' && s[1] != ':') + && (*s != '{' && *s != '(') && key != KEY_format) + { assert(key == KEY_sub || key == KEY_AUTOLOAD || key == KEY_DESTROY || key == KEY_BEGIN || key == KEY_UNITCHECK || key == KEY_CHECK || -- cgit v1.2.1