summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2018-02-26 13:50:50 +0000
committerDavid Mitchell <davem@iabyn.com>2018-03-02 13:36:43 +0000
commit86ae8d9a6f56e9e71efc1f3e556f6770dc07566e (patch)
tree01ce23f793f540508a74cfd9a87421266c46a9a5 /toke.c
parent75230cc19006735d29105daf0c6dcaf41880f961 (diff)
downloadperl-86ae8d9a6f56e9e71efc1f3e556f6770dc07566e.tar.gz
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.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c13
1 files changed, 5 insertions, 8 deletions
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 ||