summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2010-04-19 20:37:25 +0100
committerDavid Golden <dagolden@cpan.org>2010-05-20 18:56:11 -0400
commit4e4da3acc11d96d134ed1dc0effd641e7bedb0ca (patch)
treece3ff5f214a7e854b3065056f8cb48208ba47e30 /toke.c
parent39f3f7f442aed93239540238d19a15f6020da747 (diff)
downloadperl-4e4da3acc11d96d134ed1dc0effd641e7bedb0ca.tar.gz
support "package Foo { ... }"
Package block syntax limits the scope of the package declaration to the attached block. It's cleaner than requiring the declaration to come inside the block.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/toke.c b/toke.c
index dea52743ed..eac007e2da 100644
--- a/toke.c
+++ b/toke.c
@@ -2098,7 +2098,7 @@ S_force_version(pTHX_ char *s, int guessing)
curmad('X', newSVpvn(s,d-s));
}
#endif
- if (*d == ';' || isSPACE(*d) || *d == '}' || !*d) {
+ if (*d == ';' || isSPACE(*d) || *d == '{' || *d == '}' || !*d) {
SV *ver;
#ifdef USE_LOCALE_NUMERIC
char *loc = setlocale(LC_NUMERIC, "C");
@@ -2167,7 +2167,9 @@ S_force_strict_version(pTHX_ char *s)
s = (char *)scan_version(s, ver, 0);
version = newSVOP(OP_CONST, 0, ver);
}
- else if ( (*s != ';' && *s != '}' ) && (s = SKIPSPACE1(s), (*s != ';' && *s !='}' ))) {
+ else if ( (*s != ';' && *s != '{' && *s != '}' ) &&
+ (s = SKIPSPACE1(s), (*s != ';' && *s != '{' && *s != '}' )))
+ {
PL_bufptr = s;
if (errstr)
yyerror(errstr); /* version required */
@@ -7271,6 +7273,7 @@ Perl_yylex(pTHX)
s = force_word(s,WORD,FALSE,TRUE,FALSE);
s = SKIPSPACE1(s);
s = force_strict_version(s);
+ PL_lex_expect = XBLOCK;
OPERATOR(PACKAGE);
case KEY_pipe: