/* toke.c
*
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
* 2000, 2001, 2002, 2003, 2004, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
*/
/*
* "It all comes from here, the stench and the peril." --Frodo
*/
/*
* This file is the lexer for Perl. It's closely linked to the
* parser, perly.y.
*
* The main routine is yylex(), which returns the next token.
*/
#include "EXTERN.h"
#define PERL_IN_TOKE_C
#include "perl.h"
static void restore_rsfp(pTHX_ void *f);
#ifndef PERL_NO_UTF16_FILTER
#endif
#ifdef USE_UTF8_SCRIPTS
#else
#endif
/* In variables named $^X, these are the legal values for X.
* 1999-02-27 mjd-perl-patch@plover.com */
/* On MacOS, respect nonbreaking spaces */
#ifdef MACOS_TRADITIONAL
#else
#endif
/* LEX_* are values for PL_lex_state, the state of the lexer.
* They are arranged oddly so that the guard on the switch statement
* can get by with a single comparison (if the compiler is smart enough).
*/
/* #define LEX_NOTPARSING 11 is done in perl.h. */
#define LEX_KNOWNEXT 0
#ifdef ff_next
#endif
#ifdef USE_PURE_BISON
# ifndef YYMAXLEVEL
# endif
#endif
#include "keywords.h"
/* CLINE is a macro that ensures PL_copline has a sane value */
#ifdef CLINE
#endif
/*
* Convenience functions to return different tokens and prime the
* lexer for the next token. They all take an argument.
*
* TOKEN : generic token (used for '(', DOLSHARP, etc)
* OPERATOR : generic operator
* AOPERATOR : assignment operator
* PREBLOCK : beginning the block after an if, while, foreach, ...
* PRETERMBLOCK : beginning a non-code-defining {} block (eg, hash ref)
* PREREF : *EXPR where EXPR is not a simple identifier
* TERM : expression term
* LOOPX : loop exiting command (goto, last, dump, etc)
* FTST : file test operator
* FUN0 : zero-argument function
* FUN1 : not used, except for not, which isn't a UNIOP
* BOop : bitwise or or xor
* BAop : bitwise and
* SHop : shift operator
* PWop : power operator
* PMop : pattern-matching operator
* Aop : addition-level operator
* Mop : multiplication-level operator
* Eop : equality-testing operator
* Rop : relational operator <= != gt
*
* Also see LOP and lop() below.
*/
/* Note that REPORT() and REPORT2() will be expressions that supply
* their own trailing comma, not suitable for statements as such. */
#ifdef DEBUGGING /* Serve -DT. */
#else
#endif
#define OPERATOR(retval) return (REPORT2("operator",retval) PL_expect = XTERM, PL_bufptr = s,(int)retval)
#define AOPERATOR(retval) return ao((REPORT2("aop",retval) PL_expect = XTERM, PL_bufptr = s,(int)retval))
#define PREBLOCK(retval) return (REPORT2("preblock",retval) PL_expect = XBLOCK,PL_bufptr = s,(int)retval)
#define PRETERMBLOCK(retval) return (REPORT2("pretermblock",retval) PL_expect = XTERMBLOCK,PL_bufptr = s,(int)retval)
#define TERM(retval) return (CLINE, REPORT2("term",retval) PL_expect = XOPERATOR, PL_bufptr = s,(int)retval)
#define LOOPX(f) return(yylval.ival=f, REPORT("loopx",f) PL_expect = XTERM,PL_bufptr = s,(int)LOOPEX)
#define FUN0(f) return(yylval.ival = f, REPORT("fun0",f) PL_expect = XOPERATOR,PL_bufptr = s,(int)FUNC0)
#define FUN1(f) return(yylval.ival = f, REPORT("fun1",f) PL_expect = XOPERATOR,PL_bufptr = s,(int)FUNC1)
#define BOop(f) return ao((yylval.ival=f, REPORT("bitorop",f) PL_expect = XTERM,PL_bufptr = s,(int)BITOROP))
#define BAop(f) return ao((yylval.ival=f, REPORT("bitandop",f) PL_expect = XTERM,PL_bufptr = s,(int)BITANDOP))
#define SHop(f) return ao((yylval.ival=f, REPORT("shiftop",f) PL_expect = XTERM,PL_bufptr = s,(int)SHIFTOP))
#define PWop(f) return ao((yylval.ival=f, REPORT("powop",f) PL_expect = XTERM,PL_bufptr = s,(int)POWOP))
#define PMop(f) return(yylval.ival=f, REPORT("matchop",f) PL_expect = XTERM,PL_bufptr = s,(int)MATCHOP)
#define Aop(f) return ao((yylval.ival=f, REPORT("add",f) PL_expect = XTERM,PL_bufptr = s,(int)ADDOP))
#define Mop(f) return ao((yylval.ival=f, REPORT("mul",f) PL_expect = XTERM,PL_bufptr = s,(int)MULOP))
/* This bit of chicanery makes a unary function followed by
* a parenthesis into a function with one argument, highest precedence.
*/
REPORT("uni",f) \
PL_bufptr = s, \
PL_last_uni = PL_oldbufptr, \
PL_last_lop_op = f, \
REPORT("uni",f) \
PL_bufptr = s, \
PL_last_uni = PL_oldbufptr, \
/* grandfather return to old style */
#ifdef DEBUGGING
STATIC void
{
DEBUG_T({
if (s - PL_bufptr > 0)
else {
if (PL_oldbufptr && *PL_oldbufptr)
}
});
}
#endif
/*
* S_ao
*
* This subroutine detects &&= and ||= and turns an ANDAND or OROR
* into an OP_ANDASSIGN or OP_ORASSIGN
*/
STATIC int
{
if (*PL_bufptr == '=') {
PL_bufptr++;
}
return toketype;
}
/*
* S_no_op
* When Perl expects an operator and finds something else, no_op
* prints the warning. It always prints "<something> found where
* operator expected. It prints "Missing semicolon on previous line?"
* if the surprise occurs at the start of the line. "do you need to
* predeclare ..." is printed out for code like "sub bar; foo bar $x"
* where the compiler doesn't know if foo is a method call or a function.
* It prints "Missing operator before end of line" if there's nothing
* after the missing operator, or "... before <...>" if there is something
* after the missing operator.
*/
STATIC void
{
if (!s)
s = oldbp;
else
PL_bufptr = s;
if (ckWARN_d(WARN_SYNTAX)) {
if (is_first)
"\t(Missing semicolon on previous line?)\n");
char *t;
"\t(Do you need to predeclare %.*s?)\n",
}
else {
}
}
}
/*
* S_missingterm
* If it's called with (char *)NULL then it cauterizes the line buffer.
* If we're in a delimited string and the delimiter is a control
* character, it's reformatted into a two-char sequence like ^C.
* This is fatal.
*/
STATIC void
{
char q;
if (s) {
if (nl)
*nl = '\0';
}
else if (
#ifdef EBCDIC
#else
#endif
) {
*tmpbuf = '^';
s = "\\n";
s = tmpbuf;
}
else {
*tmpbuf = (char)PL_multi_close;
s = tmpbuf;
}
}
/*
* Perl_deprecate
*/
void
{
if (ckWARN(WARN_DEPRECATED))
}
void
{
/* This function should NOT be called for any new deprecated warnings */
/* Use Perl_deprecate instead */
/* */
/* It is here to maintain backward compatibility with the pre-5.8 */
/* warnings category hierarchy. The "deprecated" category used to */
/* live under the "syntax" category. It is now a top-level category */
/* in its own right. */
"Use of %s is deprecated", s);
}
/*
* depcom
* Deprecate a comma-less variable list.
*/
STATIC void
{
deprecate_old("comma-less variable list");
}
/*
* experimental text filters for win32 carriage-returns, utf16-to-utf8 and
* utf16-to-utf8-reversed.
*/
#ifdef PERL_CR_FILTER
static void
{
/* outer loop optimized to do nothing if there are no CR-LFs */
while (s < e) {
if (*s++ == '\r' && *s == '\n') {
/* hit a CR-LF, need to copy the rest */
register char *d = s - 1;
*d++ = *s++;
while (s < e) {
if (*s == '\r' && s[1] == '\n')
s++;
*d++ = *s++;
}
return;
}
}
}
{
return count;
}
#endif
/*
* Perl_lex_start
* Initialize variables. Uses the Perl save_stack to save its state (for
* recursive calls to the parser).
*/
void
{
char *s;
if (PL_lex_state == LEX_KNOWNEXT) {
while (--toke >= 0) {
}
}
PL_lex_defer = 0;
PL_lex_brackets = 0;
PL_lex_casemods = 0;
*PL_lex_casestack = '\0';
PL_lex_dojoin = 0;
PL_lex_starts = 0;
PL_lex_inpat = 0;
PL_nexttoke = 0;
PL_lex_inwhat = 0;
PL_sublex_info.sub_inwhat = 0;
PL_linestr = line;
if (SvREADONLY(PL_linestr))
}
PL_rsfp = 0;
}
/*
* Perl_lex_end
* Finalizer for lexing operations. Must be called when the parser is
* done with the lexer.
*/
void
{
}
/*
* S_incline
* This subroutine has nothing to do with tilting, whether at windmills
* or pinball tables. Its name is short for "increment line". It
* increments the current line number in CopLINE(PL_curcop) and checks
* to see whether the line starts with a comment of the form
* # line 500 "foo.pm"
* If so, it sets the current line number and file to the values in the comment.
*/
STATIC void
{
char *t;
char *n;
char *e;
char ch;
if (*s++ != '#')
return;
while (SPACE_OR_TAB(*s)) s++;
s += 4;
else
return;
if (SPACE_OR_TAB(*s))
s++;
else
return;
while (SPACE_OR_TAB(*s)) s++;
if (!isDIGIT(*s))
return;
n = s;
while (isDIGIT(*s))
s++;
while (SPACE_OR_TAB(*s))
s++;
s++;
e = t + 1;
}
else {
for (t = s; !isSPACE(*t); t++) ;
e = t;
}
e++;
if (*e != '\n' && *e != '\0')
return; /* false alarm */
ch = *t;
*t = '\0';
if (t - s > 0) {
CopFILE_set(PL_curcop, s);
}
*t = ch;
}
/*
* S_skipspace
* Called to gobble the appropriate amount and type of whitespace.
* Skips comments as well.
*/
STATIC char *
{
while (s < PL_bufend && SPACE_OR_TAB(*s))
s++;
return s;
}
for (;;) {
incline(s);
}
/* comment */
if (s < PL_bufend && *s == '#') {
while (s < PL_bufend && *s != '\n')
s++;
if (s < PL_bufend) {
s++;
if (PL_in_eval && !PL_rsfp) {
incline(s);
continue;
}
}
}
/* only continue to recharge the buffer if we're at the end
* of the buffer, we're not reading from a source filter, and
* we're in normal lexing mode
*/
return s;
/* try to recharge the buffer */
{
/* end of file. Add on the -p or -n magic */
if (PL_minus_n || PL_minus_p) {
";}continue{print or die qq(-p destination: $!\\n)" :
"");
PL_minus_n = PL_minus_p = 0;
}
else
/* reset variables for next time we lex */
= SvPVX(PL_linestr);
/* Close the filehandle. Could be from -P preprocessor,
* STDIN, or a regular file. If we were reading code from
* STDIN (because the commandline held no -e or filename)
* then we don't close it, we reset it so the code can
* read from STDIN too.
*/
if (PL_preprocess && !PL_in_eval)
(void)PerlProc_pclose(PL_rsfp);
else
(void)PerlIO_close(PL_rsfp);
return s;
}
/* not at end of file, so we only read another line */
/* make corresponding updates to old pointers, for yyerror() */
if (PL_last_uni)
if (PL_last_lop)
s = PL_bufptr;
PL_oldbufptr = s + oldprevlen;
PL_oldoldbufptr = s + oldoldprevlen;
if (PL_last_uni)
PL_last_uni = s + oldunilen;
if (PL_last_lop)
PL_last_lop = s + oldloplen;
incline(s);
/* debugger active and we're not compiling the debugger code,
* so store the line into the debugger's array of lines
*/
}
}
}
/*
* S_check_uni
* Check the unary operators to ensure there's no ambiguity in how they're
* used. An ambiguous piece of code would be:
* rand + 5
* This doesn't mean rand() + 5. Because rand() is a unary operator,
* the +5 is its argument.
*/
STATIC void
{
char *s;
char *t;
if (PL_oldoldbufptr != PL_last_uni)
return;
while (isSPACE(*PL_last_uni))
PL_last_uni++;
return;
if (ckWARN_d(WARN_AMBIGUOUS)){
char ch = *s;
*s = '\0';
"Warning: Use of \"%s\" without parentheses is ambiguous",
*s = ch;
}
}
/*
* LOP : macro to build a list operator. Its behaviour has been replaced
* with a subroutine, S_lop() for which LOP is just another name.
*/
/*
* S_lop
* Build a list operator (or something that might be one). The rules:
* - if we have a next token, then it's a list operator [why?]
* - if the next thing is an opening paren, then it's a function
* - else it's a list operator
*/
{
REPORT("lop", f)
PL_expect = x;
PL_bufptr = s;
PL_last_lop_op = (OPCODE)f;
if (PL_nexttoke)
return LSTOP;
if (*s == '(')
return FUNC;
s = skipspace(s);
if (*s == '(')
return FUNC;
else
return LSTOP;
}
/*
* S_force_next
* When the lexer realizes it knows the next token (for instance,
* it is reordering tokens for the parser) then it can call S_force_next
* to know what token to return the next time the lexer is called. Caller
* will need to set PL_nextval[], and possibly PL_expect to ensure the lexer
* handles the token correctly.
*/
STATIC void
{
PL_nexttoke++;
if (PL_lex_state != LEX_KNOWNEXT) {
}
}
/*
* S_force_word
* When the lexer knows the next thing is a word (for instance, it has
* just seen -> and it knows that the next char is a word char, then
* it calls S_force_word to stick the next word into the PL_next lookahead.
*
* Arguments:
* char *start : buffer position (must be within PL_linestr)
* int token : PL_next will be this type of bare word (e.g., METHOD,WORD)
* int check_keyword : if true, Perl checks to make sure the word isn't
* a keyword (do this if the word is a label, e.g. goto FOO)
* int allow_pack : if true, : characters will also be allowed (require,
* use, etc. do this)
* int allow_initial_tick : used by the "sub" lexer only.
*/
STATIC char *
S_force_word(pTHX_ register char *start, int token, int check_keyword, int allow_pack, int allow_initial_tick)
{
register char *s;
s = start;
if (isIDFIRST_lazy_if(s,UTF) ||
(allow_pack && *s == ':') ||
(allow_initial_tick && *s == '\'') )
{
return start;
s = skipspace(s);
if (*s == '(')
else {
}
}
}
return s;
}
/*
* S_force_ident
* Called when the lexer wants $foo *foo &foo etc, but the program
* text only contains the "foo" portion. The first argument is a pointer
* to the "foo", and the second argument is the type symbol to prefix.
* Forces the next token to be a "WORD".
* Creates the symbol if it didn't already exist (via gv_fetchpv()).
*/
STATIC void
{
if (s && *s) {
if (kind) {
o->op_private = OPpCONST_ENTERED;
/* XXX see note in pp_entereval() for why we forgo typo
warnings if the symbol must be introduced in an eval.
GSAR 96-10-12 */
);
}
}
}
{
UV n;
if (utf)
else {
skip = 1;
}
nshift *= 1000;
}
return retval;
}
/*
* S_force_version
* Forces the next token to be a version number.
* If the next token appears to be an invalid version number, (e.g. "v2b"),
* and if "guessing" is TRUE, then no new token is created (and the caller
* must use an alternative parsing method).
*/
STATIC char *
{
char *d;
s = skipspace(s);
d = s;
if (*d == 'v')
d++;
if (isDIGIT(*d)) {
d++;
}
}
else if (guessing)
return s;
}
/* NOTE: The parser sees the package name and the VERSION swapped */
return s;
}
/*
* S_tokeq
* Tokenize a quoted string passed in as an SV. It finds the next
* chunk, up to end of string or a backslash. It may make a new
* SV containing that chunk (if HINT_NEW_STRING is on). It also
* turns \\ into \.
*/
{
register char *s;
register char *send;
register char *d;
goto finish;
goto finish;
while (s < send && *s != '\\')
s++;
if (s == send)
goto finish;
d = s;
if ( PL_hints & HINT_NEW_STRING ) {
}
while (s < send) {
if (*s == '\\') {
s++; /* all that, just for this */
}
*d++ = *s++;
}
*d = '\0';
if ( PL_hints & HINT_NEW_STRING )
return sv;
}
/*
* Now come three functions related to double-quote context,
* S_sublex_start, S_sublex_push, and S_sublex_done. They're used when
* converting things like "\u\Lgnat" into ucfirst(lc("gnat")). They
* interact with PL_lex_state, and create fake ( ... ) argument lists
* to handle functions and concatenation.
* They assume that whoever calls them will be setting up a fake
* join call, because each subthing puts a ',' after it. This lets
* "lower \luPpEr"
* become
* join($, , 'lower ', lcfirst( 'uPpEr', ) ,)
*
* (I'm not sure whether the spurious commas at the end of lcfirst's
* arguments and join's arguments are created or not).
*/
/*
* S_sublex_start
* Assumes that yylval.ival is the op we're creating (e.g. OP_LCFIRST).
*
* Pattern matching will set PL_lex_op to the pattern-matching op to
* make (we return THING if yylval.ival is OP_NULL, PMFUNC otherwise).
*
* OP_CONST and OP_READLINE are easy--just make the new op and return.
*
* Everything else becomes a FUNC.
*
* Sets PL_lex_state to LEX_INTERPPUSH unless (ival was OP_NULL or we
* had an OP_CONST or OP_READLINE). This just sets us up for a
* call to S_sublex_push().
*/
{
return THING;
}
/* Overloaded constants, nothing fancy: Convert to SVt_PV: */
char *p;
}
return THING;
}
if (PL_lex_op) {
return PMFUNC;
}
else
return FUNC;
}
/*
* S_sublex_push
* Create a new scope to save the lexing state. The scope will be
* ended in S_sublex_done. Returns a '(', starting the function arguments
* to the uc, lc, etc. found before.
* Sets PL_lex_state to LEX_INTERPCONCAT.
*/
{
= SvPVX(PL_linestr);
PL_lex_brackets = 0;
PL_lex_casemods = 0;
*PL_lex_casestack = '\0';
PL_lex_starts = 0;
else
return '(';
}
/*
* S_sublex_done
* Restores lexer state after a S_sublex_push.
*/
{
if (!PL_lex_starts++) {
if (SvUTF8(PL_linestr))
return THING;
}
if (PL_lex_casemods) { /* oops, we've got some unbalanced parens */
return yylex();
}
/* Is there a right-hand side to take care of? (s//RHS/ or tr//RHS/) */
PL_lex_inpat = 0;
PL_lex_brackets = 0;
PL_lex_casemods = 0;
*PL_lex_casestack = '\0';
PL_lex_starts = 0;
if (SvEVALED(PL_lex_repl)) {
/* we don't clear PL_lex_repl here, so that we can check later
whether this is an evalled subst; that means we rely on the
logic to ensure sublex_done() is called again only via the
branch (in yylex()) that clears PL_lex_repl, else we'll loop */
}
else {
}
return ',';
}
else {
PL_sublex_info.sub_inwhat = 0;
return ')';
}
}
/*
scan_const
Extracts a pattern, double-quoted string, or transliteration. This
is terrifying code.
It looks at lex_inwhat and PL_lex_inpat to find out whether it's
processing a pattern (PL_lex_inpat is true), a transliteration
(lex_inwhat & OP_TRANS is true), or a double-quoted string.
Returns a pointer to the character scanned up to. Iff this is
advanced from the start pointer supplied (ie if anything was
successfully parsed), will leave an OP for the substring scanned
in yylval. Caller must intuit reason for not parsing further
by looking at the next characters herself.
In patterns:
backslashes:
double-quoted style: \r and \n
regexp special ones: \D \s
constants: \x3
backrefs: \1 (deprecated in substitution replacements)
case and quoting: \U \Q \E
stops on @ and $, but not for $ as tail anchor
In transliterations:
characters are VERY literal, except for - not at the start or end
of the string, which indicates a range. scan_const expands the
range to the full set of intermediate characters.
In double-quoted strings:
backslashes:
double-quoted style: \r and \n
constants: \x3
backrefs: \1 (deprecated)
case and quoting: \U \Q \E
stops on @ and $
scan_const does *not* construct ops to handle interpolated strings.
It stops processing as soon as it finds an embedded $ or @ variable
and leaves it to the caller to work out what's going on.
@ in pattern could be: @foo, @{foo}, @$foo, @'foo, @::foo.
$ in pattern could be $foo or could be tail anchor. Assumption:
it's a tail anchor if $ is the last thing in the string, or if it's
followed by one of ")| \n\t"
\1 (backreferences) are turned into $1
The structure of the code is
while (there's a character to process) {
handle transliteration ranges
skip regexp comments
skip # initiated comments in //x patterns
check for embedded @foo
check for embedded scalars
if (backslash) {
leave intact backslashes from leave (below)
deprecate \1 in strings and sub replacements
handle string-changing backslashes \l \U \Q \E, etc.
switch (what was escaped) {
handle - in a transliteration (becomes a literal -)
handle \132 octal characters
handle 0x15 hex characters
handle \cV (control V)
handle printf backslashes (\f, \r, \n, etc)
} (end switch)
} (end if backslash)
} (end while character to read)
*/
STATIC char *
{
register char *s = start; /* start of the constant */
? "\\.^$@AGZdDwWsSbBpPXC+*?|()-nrtfeaxcz0123456789[{]} \t\n\r\f\v#"
: "";
/* If we are doing a trans and we know we want UTF8 set expectation */
this_utf8 = PL_sublex_info.sub_op->op_private & (PL_lex_repl ? OPpTRANS_FROM_UTF : OPpTRANS_TO_UTF);
}
/* get transliterations out of the way (they're most literal) */
if (PL_lex_inwhat == OP_TRANS) {
/* expand a range A-Z to the full set of characters. AIE! */
if (dorange) {
I32 i; /* current expanded character */
if (has_utf8) {
char *e = d++;
while (e-- > c)
*(e + 1) = *e;
*c = (char)UTF_TO_NATIVE(0xff);
/* mark the range as done, and continue */
continue;
}
d -= 2; /* eat the first char and the - */
"Invalid range \"%c-%c\" in transliteration operator",
}
#ifdef EBCDIC
if (isLOWER(i))
*d++ = NATIVE_TO_NEED(has_utf8,i);
} else {
if (isUPPER(i))
*d++ = NATIVE_TO_NEED(has_utf8,i);
}
}
else
#endif
*d++ = (char)i;
/* mark the range as done, and continue */
continue;
}
/* range begins (ignore - as first or last char) */
if (didrange) {
}
if (has_utf8) {
s++;
continue;
}
s++;
}
else {
}
}
/* if we get here, we're not doing a transliteration */
/* skip for regexp comments /(?#comment)/ and code /(?{code})/,
except for the last char, which will be done separately. */
if (s[2] == '#') {
*d++ = NATIVE_TO_NEED(has_utf8,*s++);
}
|| ((s[2] == 'p' || s[2] == '?') && s[3] == '{'))
{
char c;
regparse++;
else if (c == '{')
count++;
else if (c == '}')
count--;
regparse++;
}
if (*regparse != ')')
regparse--; /* Leave one char for continuation. */
while (s < regparse)
*d++ = NATIVE_TO_NEED(has_utf8,*s++);
}
}
/* likewise skip #-initiated comments in //x patterns */
else if (*s == '#' && PL_lex_inpat &&
*d++ = NATIVE_TO_NEED(has_utf8,*s++);
}
/* check for embedded arrays
(@foo, @::foo, @'foo, @{foo}, @$foo, @+, @-)
*/
else if (*s == '@' && s[1]
break;
/* check for embedded scalars. only stop if we're sure it's a
variable.
*/
else if (*s == '$') {
if (!PL_lex_inpat) /* not a regexp, so $ must be var */
break;
break; /* in regexp, $ might be tail anchor */
}
/* End of else if chain - OP_TRANS rejoin rest */
/* backslashes */
s++;
/* some backslashes we leave behind */
*d++ = NATIVE_TO_NEED(has_utf8,*s++);
continue;
}
/* deprecate \1 in strings and substitution replacements */
{
if (ckWARN(WARN_SYNTAX))
*--s = '$';
break;
}
/* string-change backslash escapes */
--s;
break;
}
/* if we get here, it's either a quoted -, or a digit */
switch (*s) {
/* quoted - in transliterations */
case '-':
if (PL_lex_inwhat == OP_TRANS) {
*d++ = *s++;
continue;
}
/* FALL THROUGH */
default:
{
isALNUM(*s) &&
*s != '_')
"Unrecognized escape \\%c passed through",
*s);
/* default action is to copy the quoted character */
goto default_action;
}
/* \132 indicates an octal constant */
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
{
s += len;
}
goto NUM_ESCAPE_INSERT;
/* \x24 indicates a hex constant */
case 'x':
++s;
if (*s == '{') {
char* e = strchr(s, '}');
++s;
if (!e) {
yyerror("Missing right brace on \\x{}");
continue;
}
len = e - s;
s = e + 1;
}
else {
{
s += len;
}
}
/* Insert oct or hex escaped character.
* There will always enough room in sv since such
* escapes will be longer than any UTF-8 sequence
* they can end up as. */
/* We need to map to chars to ASCII before doing the tests
to cover EBCDIC
*/
/* Might need to recode whatever we have
* accumulated so far if it contains any
* hibit chars.
*
* (Can't we keep track of that and avoid
* this rescan? --jhi)
*/
int hicount = 0;
U8 *c;
if (!NATIVE_IS_INVARIANT(*c)) {
hicount++;
}
}
if (hicount) {
d += hicount;
if (!NATIVE_IS_INVARIANT(*src)) {
}
else {
}
src--;
}
}
}
if (PL_lex_inwhat == OP_TRANS &&
: OPpTRANS_TO_UTF);
}
}
else {
*d++ = (char)uv;
}
}
else {
*d++ = (char) uv;
}
continue;
/* \N{LATIN SMALL LETTER A} is a named character */
case 'N':
++s;
if (*s == '{') {
char* e = strchr(s, '}');
char *str;
if (!e) {
yyerror("Missing right brace on \\N{}");
e = s - 1;
goto cont_scan;
}
if (e > s + 2 && s[1] == 'U' && s[2] == '+') {
/* \N{U+...} */
s += 3;
len = e - s;
s = e + 1;
goto NUM_ESCAPE_INSERT;
}
if (has_utf8)
#ifdef EBCDIC_NEVER_MIND
/* charnames uses pack U and that has been
* recently changed to do the below uni->native
* mapping, so this would be redundant (and wrong,
* the code point would be doubly converted).
* But leave this in just in case the pack U change
* gets revoked, but the semantics is still
* desireable for charnames. --jhi */
{
if (uv < 0x100) {
}
}
#endif
*d = '\0';
/* this just broke our allocation above... */
}
}
d += len;
s = e + 1;
}
else
yyerror("Missing braces on \\N{}");
continue;
/* \c is a control character */
case 'c':
s++;
if (s < send) {
U8 c = *s++;
#ifdef EBCDIC
if (isLOWER(c))
c = toUPPER(c);
#endif
}
else {
yyerror("Missing control char name in \\c");
}
continue;
/* printf-style backslashes, formfeeds, newlines, etc */
case 'b':
break;
case 'n':
break;
case 'r':
break;
case 'f':
break;
case 't':
break;
case 'e':
break;
case 'a':
break;
} /* end switch */
s++;
continue;
} /* end if (backslash) */
/* If we started with encoded form, or already know we want it
and then encode the next character */
s += len;
/* encoded value larger than old, need extra space (NOTE: SvCUR() not set here) */
}
}
else {
*d++ = NATIVE_TO_NEED(has_utf8,*s++);
}
} /* while loop to process each character */
/* terminate the string and set up the sv */
*d = '\0';
if (PL_encoding && !has_utf8) {
}
if (has_utf8) {
}
}
/* shrink the sv if we allocated more than we used */
}
/* return the substring (via yylval) only if we parsed anything */
if (s > PL_bufptr) {
( PL_lex_inwhat == OP_TRANS
? "tr"
? "s"
: "qq")));
} else
return s;
}
/* S_intuit_more
* Returns TRUE if there's more to the expression (e.g., a subscript),
* FALSE otherwise.
*
* It deals with "$foo[3]" and /$foo[3]/ and /$foo[0123456789$]+/
*
* ->[ and ->{ return TRUE
* { and [ outside a pattern are always subscripts, so return TRUE
* if we're outside a pattern and it's not { or [, then return FALSE
* if we're in a pattern and the first char is a {
* {4,5} (any digits around the comma) returns FALSE
* if we're in a pattern and the first char is a [
* [] returns FALSE
* [SOMETHING] has a funky algorithm to decide whether it's a
* character class or not. It has to deal with things like
* /$foo[-3]/ and /$foo[$bar]/ as well as /$foo[$\d]+/
* anything else returns TRUE
*/
/* This is the one truly awful dwimmer necessary to conflate C and sed. */
STATIC int
{
if (PL_lex_brackets)
return TRUE;
if (*s == '-' && s[1] == '>' && (s[2] == '[' || s[2] == '{'))
return TRUE;
if (*s != '{' && *s != '[')
return FALSE;
if (!PL_lex_inpat)
return TRUE;
/* In a pattern, so maybe we have {n,m}. */
if (*s == '{') {
s++;
if (!isDIGIT(*s))
return TRUE;
while (isDIGIT(*s))
s++;
if (*s == ',')
s++;
while (isDIGIT(*s))
s++;
if (*s == '}')
return FALSE;
return TRUE;
}
/* On the other hand, maybe we have a character class */
s++;
if (*s == ']' || *s == '^')
return FALSE;
else {
/* this is terrifying, and it works */
if (!send) /* has to be an expression */
return TRUE;
if (*s == '$')
weight -= 3;
else if (isDIGIT(*s)) {
if (s[1] != ']') {
weight -= 10;
}
else
weight -= 100;
}
for (; s < send; s++) {
un_char = (unsigned char)*s;
switch (*s) {
case '@':
case '&':
case '$':
weight -= 100;
else
weight -= 10;
}
else if (*s == '$' && s[1] &&
weight -= 10;
else
weight -= 1;
}
break;
case '\\':
un_char = 254;
if (s[1]) {
weight += 100;
weight += 1;
weight += 40;
else if (isDIGIT(s[1])) {
weight += 40;
s++;
}
}
else
weight += 100;
break;
case '-':
if (s[1] == '\\')
weight += 50;
weight += 30;
weight += 30;
break;
default:
char *d = tmpbuf;
while (isALPHA(*s))
*d++ = *s++;
*d = '\0';
weight -= 150;
}
weight += 5;
break;
}
}
if (weight >= 0) /* probably a character class */
return FALSE;
}
return TRUE;
}
/*
* S_intuit_method
*
* Does all the checking to disambiguate
* foo bar
* between foo(bar) and bar->foo. Returns 0 if not a method, otherwise
* FUNCMETH (bar->foo(args)) or METHOD (bar->foo args).
*
* First argument is the stuff after the first token, e.g. "bar".
*
* Not a method if bar is a filehandle.
* Not a method if foo is a subroutine prototyped to take a filehandle.
* Not a method if it's really "Foo $bar"
* Method if it's "foo $bar"
* Not a method if it's really "print foo $bar"
* Method if it's really "foo package::" (interpreted as package->foo)
* Not a method if bar is known to be a subroutine ("sub bar; foo bar")
* Not a method if bar is a filehandle or package, but is quoted with
* =>
*/
STATIC int
{
if (gv) {
return 0;
if (proto) {
if (*proto == ';')
proto++;
if (*proto == '*')
return 0;
}
} else
gv = 0;
}
/* start is the beginning of the possible filehandle/object,
* and s is the end of it
* tmpbuf is a copy of it
*/
if (*start == '$') {
return 0;
s = skipspace(s);
}
len -= 2;
goto bare_package;
}
return 0;
/* filehandle or package name makes it a method */
s = skipspace(s);
return 0; /* no assumptions -- "=>" quotes bearword */
PL_bufptr = s;
}
}
return 0;
}
/*
* S_incl_perldb
* Return a string of Perl code to load the debugger. If PERL5DB
* is set, it will return the contents of that, otherwise a
* compile-time require of perl5db.pl.
*/
STATIC char*
{
if (PL_perldb) {
if (pdb)
return pdb;
return "BEGIN { require 'perl5db.pl' }";
}
return "";
}
/* Encoded script support. filter_add() effectively inserts a
* 'pre-processing' function into the current source input stream.
* Note that the filter function only applies to the current source file
* (e.g., it will not affect files 'require'd or 'use'd by this one).
*
* The datasv parameter (which may be NULL) can be used to pass
* private data to this instance of the filter. The filter function
* can recover the SV using the FILTER_DATA macro and use it to
* store private buffers and state information.
*
* The supplied datasv parameter is upgraded to a PVIO type
* and IOf_FAKE_DIRP is enabled on datasv to mark this as such.
* Note that IoTOP_NAME, IoFMT_NAME, IoBOTTOM_NAME, if set for
* private use must be set using malloc'd pointers.
*/
SV *
{
if (!funcp)
return Nullsv;
if (!PL_rsfp_filters)
PL_rsfp_filters = newAV();
if (!datasv)
return(datasv);
}
/* Delete most recently added instance of this filter function. */
void
{
return;
/* if filter is on top of stack (usual case) just pop it off */
return;
}
/* we need to search for the correct entry and clear it */
}
/* Invoke the n'th filter function for the current rsfp. */
/* 0 = read one text line */
{
if (!PL_rsfp_filters)
return -1;
/* Provide a default input filter to make life easy. */
/* Note that we append to the line. This is handy. */
"filter_read %d: from rsfp\n", idx));
if (maxlen) {
/* Want a block */
int len ;
/* ensure buf_sv is large enough */
if (PerlIO_error(PL_rsfp))
return -1; /* error */
else
return 0 ; /* end of file */
}
} else {
/* Want a line */
if (PerlIO_error(PL_rsfp))
return -1; /* error */
else
return 0 ; /* end of file */
}
}
}
/* Skip this filter slot if filter has been deleted */
"filter_read %d: skipped (filter deleted)\n",
idx));
}
/* Get function pointer hidden within datasv */
"filter_read %d: via function %p (%s)\n",
/* Call function. The function is expected to */
/* call "FILTER_READ(idx+1, buf_sv)" first. */
/* Return: <0:error, =0:eof, >0:not eof */
}
STATIC char *
{
#ifdef PERL_CR_FILTER
if (!PL_rsfp_filters) {
}
#endif
if (PL_rsfp_filters) {
if (!append)
if (FILTER_READ(0, sv, 0) > 0)
else
return Nullch ;
}
else
}
{
return PL_curstash;
if (len > 2 &&
{
}
/* use constant CLASS => 'MyClass' */
}
}
}
#ifdef DEBUGGING
static char* exp_name[] =
{ "OPERATOR", "TERM", "REF", "STATE", "BLOCK", "ATTRBLOCK",
"ATTRTERM", "TERMBLOCK"
};
#endif
/*
yylex
Works out what to call the token just pulled out of the input
stream. The yacc parser takes care of taking the ops we return and
stitching them into a tree.
Returns:
PRIVATEREF
Structure:
if read an identifier
if we're in a my declaration
croak if they tried to say my($foo::bar)
build the ops for a my() declaration
if it's an access to a my() variable
are we in a sort block?
croak if my($a); $a <=> $b
build ops for access to a my() variable
if in a dq string, and they've said @foo and we can't find @foo
croak
build ops for a bareword
if we already built the token before, use it.
*/
#ifdef USE_PURE_BISON
int
{
int r;
yyactlevel++;
if (yyactlevel >= YYMAXLEVEL)
r = Perl_yylex(aTHX);
if (yyactlevel > 0)
yyactlevel--;
return r;
}
#endif
#ifdef __SC__
#pragma segment Perl_yylex
#endif
int
{
register char *s;
register char *d;
/* check if there's an identifier for us to look at */
if (PL_pending_ident)
return S_pending_ident(aTHX);
/* no identifier pending identification */
switch (PL_lex_state) {
#ifdef COMMENTARY
case LEX_NORMAL: /* Some compilers will produce faster */
case LEX_INTERPNORMAL: /* code if we comment these out. */
break;
#endif
/* when we've already built the next token, just pull it out of the queue */
case LEX_KNOWNEXT:
PL_nexttoke--;
if (!PL_nexttoke) {
}
return(PL_nexttype[PL_nexttoke]);
/* interpolated case modifiers like \L \U, including \Q and \E.
when we get here, PL_bufptr is at the \
*/
case LEX_INTERPCASEMOD:
#ifdef DEBUGGING
#endif
/* handle \E or end of string */
char oldmod;
/* if at a \E */
if (PL_lex_casemods) {
PL_bufptr += 2;
}
return ')';
}
PL_bufptr += 2;
return yylex();
}
else {
"### Saw case modifier at '%s'\n", PL_bufptr); });
s = PL_bufptr + 1;
if (s[1] == '\\' && s[2] == 'E') {
PL_bufptr = s + 3;
return yylex();
}
else {
if (strchr("LU", *s) &&
return ')';
}
if (PL_lex_casemods > 10)
PL_lex_casestack[PL_lex_casemods++] = *s;
force_next('(');
if (*s == 'l')
else if (*s == 'u')
else if (*s == 'L')
else if (*s == 'U')
else if (*s == 'Q')
else
PL_bufptr = s + 1;
}
if (PL_lex_starts) {
s = PL_bufptr;
PL_lex_starts = 0;
}
else
return yylex();
}
case LEX_INTERPPUSH:
return sublex_push();
case LEX_INTERPSTART:
return sublex_done();
"### Interpolated variable at '%s'\n", PL_bufptr); });
if (PL_lex_dojoin) {
force_next(',');
#ifdef USE_5005THREADS
#else
#endif /* USE_5005THREADS */
force_next('$');
force_next('(');
}
if (PL_lex_starts++) {
s = PL_bufptr;
}
return yylex();
case LEX_INTERPENDMAYBE:
if (intuit_more(PL_bufptr)) {
break;
}
/* FALL THROUGH */
case LEX_INTERPEND:
if (PL_lex_dojoin) {
return ')';
}
&& SvEVALED(PL_lex_repl))
{
}
/* FALLTHROUGH */
case LEX_INTERPCONCAT:
#ifdef DEBUGGING
if (PL_lex_brackets)
#endif
return sublex_done();
if (!PL_lex_inpat)
else if ( PL_hints & HINT_NEW_RE )
s = PL_bufend;
}
else {
s = scan_const(PL_bufptr);
if (*s == '\\')
else
}
if (s != PL_bufptr) {
if (PL_lex_starts++)
else {
PL_bufptr = s;
return yylex();
}
}
return yylex();
case LEX_FORMLINE:
s = scan_formline(PL_bufptr);
if (!PL_lex_formbrack)
goto rightbracket;
OPERATOR(';');
}
s = PL_bufptr;
PL_oldbufptr = s;
DEBUG_T( {
} );
switch (*s) {
default:
if (isIDFIRST_lazy_if(s,UTF))
goto keylookup;
case 4:
case 26:
goto fake_eof; /* emulate EOF on ^D or ^Z */
case 0:
if (!PL_rsfp) {
PL_last_uni = 0;
PL_last_lop = 0;
if (PL_lex_brackets) {
if (PL_lex_formbrack)
yyerror("Format not terminated");
else
yyerror("Missing right curly or square bracket");
}
"### Tokener got EOF\n");
} );
TOKEN(0);
}
if (s++ < PL_bufend)
goto retry; /* ignore stray nulls */
PL_last_uni = 0;
PL_last_lop = 0;
if (!PL_in_eval && !PL_preambled) {
PL_preambled = TRUE;
if (SvCUR(PL_linestr))
if (PL_preambleav){
while(AvFILLp(PL_preambleav) >= 0) {
}
}
if (PL_minus_n || PL_minus_p) {
if (PL_minus_l)
if (PL_minus_a) {
if (PL_minus_F) {
else {
char delim;
s = "'~#\200\1'"; /* surely one char is unused...*/
delim = *s;
for (s = PL_splitstr; *s; s++) {
if (*s == '\\')
}
}
}
else
}
}
}
goto retry;
}
do {
if (PL_rsfp) {
if (PL_preprocess && !PL_in_eval)
(void)PerlProc_pclose(PL_rsfp);
else
(void)PerlIO_close(PL_rsfp);
}
PL_minus_n = PL_minus_p = 0;
goto retry;
}
}
/* If it looks like the start of a BOM or raw UTF-16,
* check if it in fact is. */
else if (bof &&
(*s == 0 ||
*(U8*)s == 0xEF ||
*(U8*)s >= 0xFE ||
s[1] == 0)) {
#ifdef PERLIO_IS_STDIO
# ifdef __GNU_LIBRARY__
# define FTELL_FOR_PIPE_IS_BROKEN
# endif
# else
# ifdef __GLIBC__
# define FTELL_FOR_PIPE_IS_BROKEN
# endif
# endif
# endif
#endif
#ifdef FTELL_FOR_PIPE_IS_BROKEN
/* This loses the possibility to detect the bof
* situation on perl -P when the libc5 is being used.
* Workaround? Maybe attach some extra state to PL_rsfp?
*/
if (!PL_preprocess)
#else
#endif
if (bof) {
s = swallow_bom((U8*)s);
}
}
if (PL_doextract) {
/* Incest with pod. */
}
}
incline(s);
} while (PL_doextract);
}
s++;
if (*s == ':' && s[1] != ':') /* for csh execing sh scripts */
s++;
d = Nullch;
if (!PL_in_eval) {
if (*s == '#' && *(s+1) == '!')
d = s + 2;
#ifdef ALTERNATE_SHEBANG
else {
d = s + (sizeof(as) - 1);
}
#endif /* ALTERNATE_SHEBANG */
}
if (d) {
char *ipath;
char *ipathend;
while (isSPACE(*d))
d++;
ipath = d;
while (*d && !isSPACE(*d))
d++;
ipathend = d;
#ifdef ARG_ZERO_IS_SCRIPT
/*
* HP-UX (at least) sets argv[0] to the script name,
* which makes $^X incorrect. And Digital UNIX and Linux,
* at least, set argv[0] to the basename of the Perl
* interpreter. So, having found "#!", we'll set it right.
*/
SvSETMAGIC(x);
}
else {
SvSETMAGIC(x);
}
}
}
TAINT_NOT; /* $^X is always tainted, but that's OK */
}
#endif /* ARG_ZERO_IS_SCRIPT */
/*
* Look for options.
*/
d = instr(s,"perl -");
if (!d) {
d = instr(s,"perl");
#if defined(DOSISH)
/* avoid getting into infinite loops when shebang
* line contains "Perl" rather than "perl" */
if (!d) {
if ((*d == 'p' || *d == 'P')
{
break;
}
}
if (d < ipath)
d = Nullch;
}
#endif
}
#ifdef ALTERNATE_SHEBANG
/*
* If the ALTERNATE_SHEBANG on this system starts with a
* character that can be part of a Perl expression, then if
* we see it but not "perl", we're probably looking at the
* start of Perl code, not a request to hand off to some
* other interpreter. Similarly, if "perl" is there, but
* not in the first 'word' of the line, we assume the line
* contains the start of the Perl program.
*/
if (d && *s != '#') {
char *c = ipath;
while (*c && !strchr("; \t\r\n\f\v#", *c))
c++;
if (c < d)
d = Nullch; /* "perl" not in first word; ignore */
else
*s = '#'; /* Don't try to parse shebang line */
}
#endif /* ALTERNATE_SHEBANG */
#ifndef MACOS_TRADITIONAL
if (!d &&
*s == '#' &&
!PL_minus_c &&
!instr(s,"indir") &&
{
char **newargv;
*ipathend = '\0';
s = ipathend + 1;
s++;
if (s < PL_bufend) {
newargv[1] = s;
s++;
*s = '\0';
}
else
}
#endif
if (d) {
while (*d && !isSPACE(*d)) d++;
while (SPACE_OR_TAB(*d)) d++;
if (*d++ == '-') {
do {
if (*d == 'M' || *d == 'm') {
char *m = d;
while (*d && !isSPACE(*d)) d++;
(int)(d - m), m);
}
d = moreswitches(d);
} while (d);
if (PL_doswitches && !switches_done) {
do {
}
if ((PERLDB_LINE && !oldpdb) ||
/* if we have already added "LINE: while (<>) {",
we must not do it again */
{
if (PERLDB_LINE)
(void)gv_fetchfile(PL_origfilename);
goto retry;
}
if (PL_doswitches && !switches_done) {
do {
}
}
}
}
}
PL_bufptr = s;
return yylex();
}
goto retry;
case '\r':
#ifdef PERL_STRICT_CR
"\t(Maybe you didn't strip carriage returns after a network transfer?)\n");
#endif
case ' ': case '\t': case '\f': case 013:
#ifdef MACOS_TRADITIONAL
case '\312':
#endif
s++;
goto retry;
case '#':
case '\n':
/* handle eval qq[#line 1 "foo"\n ...] */
incline(s);
}
d = PL_bufend;
while (s < d && *s != '\n')
s++;
if (s < d)
s++;
else if (s > d) /* Found by Ilya: feed random input to Perl. */
incline(s);
PL_bufptr = s;
return yylex();
}
}
else {
*s = '\0';
PL_bufend = s;
}
goto retry;
case '-':
s++;
PL_bufptr = s;
tmp = *s++;
while (s < PL_bufend && SPACE_OR_TAB(*s))
s++;
"### Saw unary minus before =>, forcing word '%s'\n", s);
} );
}
switch (tmp) {
case 'M': case 'A': case 'C':
switch (tmp) {
default: break;
}
break;
default:
break;
}
if (ftst) {
"### Saw file test %c\n", (int)ftst);
} );
}
else {
/* Assume it was a minus followed by a one-letter named
* subroutine call (or a -bareword), then. */
"### '-%c' looked like a file test but was not\n",
tmp);
} );
s = --PL_bufptr;
}
}
tmp = *s++;
if (*s == tmp) {
s++;
else
}
else if (*s == '>') {
s++;
s = skipspace(s);
if (isIDFIRST_lazy_if(s,UTF)) {
}
else if (*s == '$')
else
}
else {
check_uni();
}
case '+':
tmp = *s++;
if (*s == tmp) {
s++;
else
}
else {
check_uni();
OPERATOR('+');
}
case '*':
if (!*PL_tokenbuf)
PREREF('*');
TERM('*');
}
s++;
if (*s == '*') {
s++;
}
case '%':
++s;
}
PL_tokenbuf[0] = '%';
if (!PL_tokenbuf[1]) {
PREREF('%');
}
PL_pending_ident = '%';
TERM('%');
case '^':
s++;
case '[':
/* FALL THROUGH */
case '~':
case ',':
tmp = *s++;
case ':':
if (s[1] == ':') {
len = 0;
goto just_a_word;
}
s++;
switch (PL_expect) {
case XOPERATOR:
break;
PL_bufptr = s; /* update in case we back off */
goto grabattrs;
case XATTRBLOCK:
goto grabattrs;
case XATTRTERM:
s = skipspace(s);
while (isIDFIRST_lazy_if(s,UTF)) {
switch (tmp) {
case KEY_or:
case KEY_and:
case KEY_for:
case KEY_unless:
case KEY_if:
case KEY_while:
case KEY_until:
goto got_attrs;
default:
break;
}
}
if (*d == '(') {
if (!d) {
/* MUST advance bufptr here to avoid bogus
"at end of line" context messages from yyerror().
*/
yyerror("Unterminated attribute parameter in attribute list");
if (attrs)
return 0; /* EOF indicator */
}
}
if (PL_lex_stuff) {
}
else {
#ifdef USE_ITHREADS
#else
; /* skip to avoid loading attributes.pm */
#endif
else
}
/* NOTE: any CV attrs applied here need to be part of
the CVf_BUILTIN_ATTRS define in cv.h! */
/* After we've set the flags, it could be argued that
we don't need to do the attributes.pm-based setting
process, and shouldn't bother appending recognized
flags. To experiment with that, uncomment the
following "else". (Note that's already been
uncommented. That keeps the above-applied built-in
attributes from being intercepted (and possibly
rejected) by a package's attribute routines, but is
justified by the performance win for the common case
of applying only built-in attributes.) */
else
}
s = skipspace(d);
if (*s == ':' && s[1] != ':')
s = skipspace(s+1);
else if (s == d)
break; /* require real whitespace or :'s */
}
char q = ((*s == '\'') ? '"' : '\'');
/* If here for an expression, and parsed no attrs, back off. */
s = PL_bufptr;
break;
}
/* MUST advance bufptr here to avoid bogus "at end of line"
context messages from yyerror().
*/
PL_bufptr = s;
if (!*s)
yyerror("Unterminated attribute list");
else
q, *s, q));
if (attrs)
OPERATOR(':');
}
if (attrs) {
}
}
OPERATOR(':');
case '(':
s++;
else
s = skipspace(s);
TOKEN('(');
case ';':
tmp = *s++;
case ')':
tmp = *s++;
s = skipspace(s);
if (*s == '{')
case ']':
s++;
if (PL_lex_brackets <= 0)
yyerror("Unmatched right square bracket");
else
if (PL_lex_state == LEX_INTERPNORMAL) {
if (PL_lex_brackets == 0) {
if (*s != '[' && *s != '{' && (*s != '-' || s[1] != '>'))
}
}
TERM(']');
case '{':
s++;
if (PL_lex_brackets > 100) {
}
switch (PL_expect) {
case XTERM:
if (PL_lex_formbrack) {
s--;
}
if (PL_oldoldbufptr == PL_last_lop)
else
case XOPERATOR:
while (s < PL_bufend && SPACE_OR_TAB(*s))
s++;
d = s;
PL_tokenbuf[0] = '\0';
if (d < PL_bufend && *d == '-') {
PL_tokenbuf[0] = '-';
d++;
while (d < PL_bufend && SPACE_OR_TAB(*d))
d++;
}
while (d < PL_bufend && SPACE_OR_TAB(*d))
d++;
if (*d == '}') {
if (minus)
force_next('-');
}
}
/* FALL THROUGH */
case XATTRBLOCK:
case XBLOCK:
break;
case XATTRTERM:
case XTERMBLOCK:
break;
default: {
char *t;
if (PL_oldoldbufptr == PL_last_lop)
else
s = skipspace(s);
if (*s == '}') {
/* This hack is to get the ${} in the message. */
PL_bufptr = s+1;
yyerror("syntax error");
break;
}
}
/* This hack serves to disambiguate a pair of curlies
* as being a block or an anon hash. Normally, expectation
* determines that, but in cases where we're not in a
* position to expect anything in particular (like inside
* eval"") we have to resolve the ambiguity. This code
* covers the case where the first term in the curlies is a
* quoted string. Most other cases need to be explicitly
* disambiguated by prepending a `+' before the opening
* curly in order to force resolution as an anon hash.
*
* XXX should probably propagate the outer expectation
* into eval"" to rely less on this hack, but that could
* potentially break current behavior of eval"".
* GSAR 97-07-21
*/
t = s;
if (*s == '\'' || *s == '"' || *s == '`') {
/* common case: get past first string, handling escapes */
for (t++; t < PL_bufend && *t != *s;)
if (*t++ == '\\' && (*t == '\\' || *t == *s))
t++;
t++;
}
else if (*s == 'q') {
if (++t < PL_bufend
&& (!isALNUM(*t)
&& !isALNUM(*t))))
{
/* skip q//-like construct */
char *tmps;
t++;
/* check for q => */
}
term = *t;
for (t++; t < PL_bufend; t++) {
t++;
else if (*t == open)
break;
}
else {
for (t++; t < PL_bufend; t++) {
t++;
break;
else if (*t == open)
brackets++;
}
}
t++;
}
else
/* skip plain q word */
t += UTF8SKIP(t);
}
else if (isALNUM_lazy_if(t,UTF)) {
t += UTF8SKIP(t);
t += UTF8SKIP(t);
}
t++;
/* if comma follows first term, call it an anon hash */
/* XXX it could be a comma expression with loop modifiers */
|| (*t == '=' && t[1] == '>')))
else {
}
}
break;
}
if (isSPACE(*s) || *s == '#')
TOKEN('{');
case '}':
s++;
if (PL_lex_brackets <= 0)
yyerror("Unmatched right curly bracket");
else
PL_lex_formbrack = 0;
if (PL_lex_state == LEX_INTERPNORMAL) {
if (PL_lex_brackets == 0) {
if (PL_expect & XFAKEBRACK) {
PL_bufptr = s;
return yylex(); /* ignore fake brackets */
}
if (*s == '-' && s[1] == '>')
else if (*s != '[' && *s != '{')
}
}
if (PL_expect & XFAKEBRACK) {
PL_bufptr = s;
return yylex(); /* ignore fake brackets */
}
force_next('}');
TOKEN(';');
case '&':
s++;
tmp = *s++;
if (tmp == '&')
s--;
if (ckWARN(WARN_SEMICOLON)
{
}
}
if (*PL_tokenbuf) {
}
else
PREREF('&');
TERM('&');
case '|':
s++;
tmp = *s++;
if (tmp == '|')
s--;
case '=':
s++;
tmp = *s++;
if (tmp == '=')
if (tmp == '>')
OPERATOR(',');
if (tmp == '~')
s--;
{
if (PL_in_eval && !PL_rsfp) {
d = PL_bufend;
while (s < d) {
if (*s++ == '\n') {
incline(s);
s = strchr(s,'\n');
if (s)
s++;
else
s = d;
incline(s);
goto retry;
}
}
}
goto retry;
}
s = PL_bufend;
PL_doextract = TRUE;
goto retry;
}
if (PL_lex_brackets < PL_lex_formbrack) {
char *t;
#ifdef PERL_STRICT_CR
for (t = s; SPACE_OR_TAB(*t); t++) ;
#else
for (t = s; SPACE_OR_TAB(*t) || *t == '\r'; t++) ;
#endif
if (*t == '\n' || *t == '#') {
s--;
goto leftbracket;
}
}
case '!':
s++;
tmp = *s++;
if (tmp == '=')
if (tmp == '~')
s--;
OPERATOR('!');
case '<':
check_uni();
if (s[1] == '<')
s = scan_heredoc(s);
else
s = scan_inputsymbol(s);
TERM(sublex_start());
}
s++;
tmp = *s++;
if (tmp == '<')
if (tmp == '=') {
tmp = *s++;
if (tmp == '>')
s--;
}
s--;
case '>':
s++;
tmp = *s++;
if (tmp == '>')
if (tmp == '=')
s--;
case '$':
depcom();
return ','; /* grandfather non-comma-format format */
}
}
PL_tokenbuf[0] = '@';
no_op("Array length", s);
if (!PL_tokenbuf[1])
PL_pending_ident = '#';
}
PL_tokenbuf[0] = '$';
no_op("Scalar", s);
if (!PL_tokenbuf[1]) {
if (s == PL_bufend)
yyerror("Final $ should be \\$ or $name");
PREREF('$');
}
/* This kludge not intended to be bulletproof. */
}
d = s;
if (PL_lex_state == LEX_NORMAL)
s = skipspace(s);
char *t;
if (*s == '[') {
PL_tokenbuf[0] = '@';
if (ckWARN(WARN_SYNTAX)) {
for(t = s + 1;
t++) ;
if (*t++ == ',') {
while (t < PL_bufend && *t != ']')
t++;
"Multidimensional syntax %.*s not supported",
}
}
}
else if (*s == '{') {
PL_tokenbuf[0] = '%';
{
for (t++; isSPACE(*t); t++) ;
if (isIDFIRST_lazy_if(t,UTF)) {
for (; isSPACE(*t); t++) ;
}
}
}
}
else if (strchr("$@\"'`q", *s))
else if (isIDFIRST_lazy_if(s,UTF)) {
/* binary operators exclude handle interpretations */
switch (tmp) {
case -KEY_x:
case -KEY_eq:
case -KEY_ne:
case -KEY_gt:
case -KEY_lt:
case -KEY_ge:
case -KEY_le:
case -KEY_cmp:
break;
default:
break;
}
}
else {
}
}
else if (isDIGIT(*s))
}
PL_pending_ident = '$';
TOKEN('$');
case '@':
no_op("Array", s);
PL_tokenbuf[0] = '@';
if (!PL_tokenbuf[1]) {
PREREF('@');
}
if (PL_lex_state == LEX_NORMAL)
s = skipspace(s);
if (*s == '{')
PL_tokenbuf[0] = '%';
/* Warn about @ where they meant $. */
if (ckWARN(WARN_SYNTAX)) {
if (*s == '[' || *s == '{') {
char *t = s + 1;
t++;
if (*t == '}' || *t == ']') {
t++;
"Scalar value %.*s better written as $%.*s",
}
}
}
}
PL_pending_ident = '@';
TERM('@');
case '/': /* may either be division or pattern */
case '?': /* may either be conditional or pattern */
/* Disable warning on "study /blah/" */
if (PL_oldoldbufptr == PL_last_uni
check_uni();
TERM(sublex_start());
}
tmp = *s++;
if (tmp == '/')
case '.':
#ifdef PERL_STRICT_CR
&& s[1] == '\n'
#else
&& (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n'))
#endif
{
PL_lex_formbrack = 0;
goto rightbracket;
}
tmp = *s++;
if (*s == tmp) {
s++;
if (*s == tmp) {
s++;
}
else
}
check_uni();
}
/* FALL THROUGH */
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
"### Saw number before '%s'\n", s);
} );
no_op("Number",s);
case '\'':
"### Saw string before '%s'\n", s);
} );
depcom();
return ','; /* grandfather non-comma-format format */
}
else
no_op("String",s);
}
if (!s)
missingterm((char*)0);
TERM(sublex_start());
case '"':
"### Saw string before '%s'\n", s);
} );
depcom();
return ','; /* grandfather non-comma-format format */
}
else
no_op("String",s);
}
if (!s)
missingterm((char*)0);
break;
}
}
TERM(sublex_start());
case '`':
"### Saw backtick string before '%s'\n", s);
} );
no_op("Backticks",s);
if (!s)
missingterm((char*)0);
set_csh();
TERM(sublex_start());
case '\\':
s++;
*s, *s);
no_op("Backslash",s);
case 'v':
char *start = s;
start++;
start++;
start++;
}
/* avoid v123abc() or $h{v1}, allow C<print v10;> */
char c = *start;
*start = '\0';
*start = c;
if (!gv) {
}
}
}
goto keylookup;
case 'x':
s++;
}
goto keylookup;
case '_':
case 'a': case 'A':
case 'b': case 'B':
case 'c': case 'C':
case 'd': case 'D':
case 'e': case 'E':
case 'f': case 'F':
case 'g': case 'G':
case 'h': case 'H':
case 'i': case 'I':
case 'j': case 'J':
case 'k': case 'K':
case 'l': case 'L':
case 'm': case 'M':
case 'n': case 'N':
case 'o': case 'O':
case 'p': case 'P':
case 'q': case 'Q':
case 'r': case 'R':
case 's': case 'S':
case 't': case 'T':
case 'u': case 'U':
case 'V':
case 'w': case 'W':
case 'X':
case 'y': case 'Y':
case 'z': case 'Z':
keylookup: {
orig_keyword = 0;
gvp = 0;
PL_bufptr = s;
/* Some keywords can be followed by any delimiter, including ':' */
(PL_tokenbuf[0] == 'q' &&
/* x::* is just a word, unless x is "CORE" */
goto just_a_word;
d = s;
d++; /* no comments skipped here, or s### is misparsed */
/* Is this a label? */
s = d + 1;
}
/* Check for keywords */
/* Is this a word before a => operator? */
if (*d == '=' && d[1] == '>') {
}
if (tmp < 0) { /* second-class keyword? */
{
if (GvIMPORTED_CV(gv))
}
if (!ogv &&
{
}
}
if (ogv) {
orig_keyword = tmp;
tmp = 0; /* overridden by import or by GLOBAL */
}
{
tmp = 0; /* any sub overrides "weak" keyword */
}
else { /* no override */
"dump() better written as CORE::dump()");
}
gvp = 0;
"Ambiguous call resolved as CORE::%s(), %s",
}
}
switch (tmp) {
default: /* not a keyword */
just_a_word: {
int pkgname = 0;
/* Get the rest if it looks like a package qualifier */
if (*s == '\'' || (*s == ':' && s[1] == ':')) {
if (!morelen)
*s == '\'' ? "'" : "::");
pkgname = 1;
}
if (PL_bufptr == PL_linestart) {
}
else
no_op("Bareword",s);
}
/* Look for a subroutine with this name in current package,
unless name is "Foo::", in which case Foo is a bearword
(and a package name). */
if (len > 2 &&
{
"Bareword \"%s\" refers to nonexistent package",
len -= 2;
gvp = 0;
}
else {
len = 0;
if (!gv)
}
/* if we saw a global override before, get the right name */
if (gvp) {
}
else
/* Presume this is going to be a bareword of some sort. */
/* UTF-8 package name? */
/* And if "Foo::", then that's what it certainly is. */
if (len)
goto safe_bareword;
/* See if it's the indirect object for a list operator. */
if (PL_oldoldbufptr &&
PL_oldoldbufptr < PL_bufptr &&
|| PL_oldoldbufptr == PL_last_uni) &&
/* NO SKIPSPACE BEFORE HERE! */
{
/* (Now we can afford to cross potential line boundary.) */
s = skipspace(s);
/* Two barewords in a row may indicate method call. */
return tmp;
/* If not a declared subroutine, it's an indirect object. */
/* (But it's an indir obj regardless for sort.) */
(PL_last_lop_op != OP_MAPSTART &&
PL_last_lop_op != OP_GREPSTART))))
{
goto bareword;
}
}
s = skipspace(s);
/* Is this a word before a => operator? */
}
/* If followed by a paren, it's certainly a subroutine. */
if (*s == '(') {
for (d = s + 1; SPACE_OR_TAB(*d); d++) ;
s = d + 1;
goto its_constant;
}
}
TOKEN('&');
}
/* If followed by var or block, call it a method (unless sub) */
}
/* If followed by a bareword, see if it looks like indir obj. */
if (!orig_keyword
return tmp;
/* Not a method, so call it a subroutine (if defined) */
"Ambiguous use of -%s resolved as -&%s()",
/* Check for a constant sub */
}
/* Resolve to GV now. */
/* Is there a prototype? */
if (!len)
while (*proto == ';')
proto++;
"__ANON__" : "__ANON__::__ANON__");
}
}
}
/* Call it a bare word */
if (PL_hints & HINT_STRICT_SUBS)
else {
if (ckWARN(WARN_RESERVED)) {
if (lastchar != '-') {
for (d = PL_tokenbuf; *d && isLOWER(*d); d++) ;
}
}
}
"Operator or semicolon missing before %c%s",
"Ambiguous use of %c resolved as operator %c",
}
}
case KEY___FILE__:
case KEY___LINE__:
case KEY___PACKAGE__:
: &PL_sv_undef));
case KEY___DATA__:
case KEY___END__: {
/*SUPPRESS 560*/
GvMULTI_on(gv);
{
}
#endif
/* Mark this internal pseudo-handle as clean */
if (PL_preprocess)
else
#if defined(WIN32) && !defined(PERL_TEXTMODE_SCRIPTS)
/* if the script was opened in binmode, we need to revert
* it to text mode for compatibility; but only iff it has CRs
* XXX this is a questionable hack at best. */
{
(void)PerlIO_seek(PL_rsfp, 0L, 0);
}
#ifdef NETWARE
#else
#endif /* NETWARE */
#ifdef PERLIO_IS_STDIO /* really? */
# if defined(__BORLANDC__)
/* XXX see note in do_binmode() */
# endif
#endif
if (loc > 0)
}
}
#endif
#ifdef PERLIO_LAYERS
if (!IN_BYTES) {
if (UTF)
else if (PL_encoding) {
dSP;
name));
}
}
#endif
}
goto fake_eof;
}
case KEY_AUTOLOAD:
case KEY_DESTROY:
case KEY_BEGIN:
case KEY_CHECK:
case KEY_INIT:
case KEY_END:
s = PL_bufptr;
goto really_sub;
}
goto just_a_word;
case KEY_CORE:
if (*s == ':' && s[1] == ':') {
s += 2;
d = s;
if (tmp < 0)
goto reserved_word;
}
goto just_a_word;
case KEY_abs:
case KEY_alarm:
case KEY_accept:
case KEY_and:
case KEY_atan2:
case KEY_bind:
case KEY_binmode:
case KEY_bless:
case KEY_chop:
case KEY_continue:
case KEY_chdir:
case KEY_close:
case KEY_closedir:
case KEY_cmp:
case KEY_caller:
case KEY_crypt:
#ifdef FCRYPT
if (!PL_cryptseen) {
PL_cryptseen = TRUE;
init_des();
}
#endif
case KEY_chmod:
case KEY_chown:
case KEY_connect:
case KEY_chr:
case KEY_cos:
case KEY_chroot:
case KEY_do:
s = skipspace(s);
if (*s == '{')
if (*s != '\'')
case KEY_die:
case KEY_defined:
case KEY_delete:
case KEY_dbmopen:
case KEY_dbmclose:
case KEY_dump:
case KEY_else:
case KEY_elsif:
case KEY_eq:
case KEY_exists:
case KEY_exit:
case KEY_eval:
s = skipspace(s);
case KEY_eof:
case KEY_exp:
case KEY_each:
case KEY_exec:
set_csh();
case KEY_endhostent:
case KEY_endnetent:
case KEY_endservent:
case KEY_endprotoent:
case KEY_endpwent:
case KEY_endgrent:
case KEY_for:
case KEY_foreach:
s = skipspace(s);
char *p = s;
if ((PL_bufend - p) >= 3 &&
p += 2;
else if ((PL_bufend - p) >= 4 &&
p += 3;
p = skipspace(p);
if (isIDFIRST_lazy_if(p,UTF)) {
p = scan_ident(p, PL_bufend,
p = skipspace(p);
}
if (*p != '$')
}
case KEY_formline:
case KEY_fork:
case KEY_fcntl:
case KEY_fileno:
case KEY_flock:
case KEY_gt:
case KEY_ge:
case KEY_grep:
case KEY_goto:
case KEY_gmtime:
case KEY_getc:
case KEY_getppid:
case KEY_getpgrp:
case KEY_getpriority:
case KEY_getprotobyname:
case KEY_getprotobynumber:
case KEY_getprotoent:
case KEY_getpwent:
case KEY_getpwnam:
case KEY_getpwuid:
case KEY_getpeername:
case KEY_gethostbyname:
case KEY_gethostbyaddr:
case KEY_gethostent:
case KEY_getnetbyname:
case KEY_getnetbyaddr:
case KEY_getnetent:
case KEY_getservbyname:
case KEY_getservbyport:
case KEY_getservent:
case KEY_getsockname:
case KEY_getsockopt:
case KEY_getgrent:
case KEY_getgrnam:
case KEY_getgrgid:
case KEY_getlogin:
case KEY_glob:
set_csh();
case KEY_hex:
case KEY_if:
case KEY_index:
case KEY_int:
case KEY_ioctl:
case KEY_join:
case KEY_keys:
case KEY_kill:
case KEY_last:
case KEY_lc:
case KEY_lcfirst:
case KEY_local:
case KEY_length:
case KEY_lt:
case KEY_le:
case KEY_localtime:
case KEY_log:
case KEY_link:
case KEY_listen:
case KEY_lock:
case KEY_lstat:
case KEY_m:
TERM(sublex_start());
case KEY_map:
case KEY_mkdir:
case KEY_msgctl:
case KEY_msgget:
case KEY_msgrcv:
case KEY_msgsnd:
case KEY_our:
case KEY_my:
s = skipspace(s);
if (isIDFIRST_lazy_if(s,UTF)) {
goto really_sub;
if (!PL_in_my_stash) {
PL_bufptr = s;
}
}
case KEY_next:
case KEY_ne:
case KEY_no:
yyerror("\"no\" not allowed in expression");
s = force_version(s, FALSE);
case KEY_not:
else
case KEY_open:
s = skipspace(s);
if (isIDFIRST_lazy_if(s,UTF)) {
char *t;
for (d = s; isALNUM_lazy_if(d,UTF); d++) ;
for (t=d; *t && isSPACE(*t); t++) ;
/* [perl #16184] */
&& !(t[0] == '=' && t[1] == '>')
) {
"Precedence problem: open %.*s should be open(%.*s)",
d - s, s, d - s, s);
}
}
case KEY_or:
case KEY_ord:
case KEY_oct:
case KEY_opendir:
case KEY_print:
case KEY_printf:
case KEY_prototype:
case KEY_push:
case KEY_pop:
case KEY_pos:
case KEY_pack:
case KEY_package:
case KEY_pipe:
case KEY_q:
if (!s)
missingterm((char*)0);
TERM(sublex_start());
case KEY_quotemeta:
case KEY_qw:
if (!s)
missingterm((char*)0);
force_next(')');
if (SvCUR(PL_lex_stuff)) {
int warned = 0;
while (len) {
if (len) {
char *b = d;
if (*d == ',') {
"Possible attempt to separate words with commas");
++warned;
}
else if (*d == '#') {
"Possible attempt to put comments in qw() list");
++warned;
}
}
}
else {
}
if (DO_UTF8(PL_lex_stuff))
}
}
if (words) {
}
}
if (PL_lex_stuff) {
}
TOKEN('(');
case KEY_qq:
if (!s)
missingterm((char*)0);
TERM(sublex_start());
case KEY_qr:
TERM(sublex_start());
case KEY_qx:
if (!s)
missingterm((char*)0);
set_csh();
TERM(sublex_start());
case KEY_return:
case KEY_require:
s = skipspace(s);
if (isDIGIT(*s)) {
s = force_version(s, FALSE);
}
{
*PL_tokenbuf = '\0';
else if (*s == '<')
yyerror("<> should be quotes");
}
case KEY_reset:
case KEY_redo:
case KEY_rename:
case KEY_rand:
case KEY_rmdir:
case KEY_rindex:
case KEY_read:
case KEY_readdir:
case KEY_readline:
set_csh();
case KEY_readpipe:
set_csh();
case KEY_rewinddir:
case KEY_recv:
case KEY_reverse:
case KEY_readlink:
case KEY_ref:
case KEY_s:
s = scan_subst(s);
TERM(sublex_start());
else
case KEY_chomp:
case KEY_scalar:
case KEY_select:
case KEY_seek:
case KEY_semctl:
case KEY_semget:
case KEY_semop:
case KEY_send:
case KEY_setpgrp:
case KEY_setpriority:
case KEY_sethostent:
case KEY_setnetent:
case KEY_setservent:
case KEY_setprotoent:
case KEY_setpwent:
case KEY_setgrent:
case KEY_seekdir:
case KEY_setsockopt:
case KEY_shift:
case KEY_shmctl:
case KEY_shmget:
case KEY_shmread:
case KEY_shmwrite:
case KEY_shutdown:
case KEY_sin:
case KEY_sleep:
case KEY_socket:
case KEY_socketpair:
case KEY_sort:
s = skipspace(s);
if (*s == ';' || *s == ')') /* probably a close */
case KEY_split:
case KEY_sprintf:
case KEY_splice:
case KEY_sqrt:
case KEY_srand:
case KEY_stat:
case KEY_study:
case KEY_substr:
case KEY_format:
case KEY_sub:
{
s = skipspace(s);
(*s == ':' && s[1] == ':'))
{
/* remember buffer pos'n for later force_word */
tboffset = s - PL_oldbufptr;
else {
}
s = skipspace(d);
}
else {
}
if (key == KEY_format) {
if (*s == '=')
if (have_name)
}
/* Look for a prototype */
if (*s == '(') {
char *p;
if (!s)
/* strip spaces and check for bad characters */
d = SvPVX(PL_lex_stuff);
tmp = 0;
for (p = d; *p; ++p) {
if (!isSPACE(*p)) {
d[tmp++] = *p;
if (!strchr("$@%*;[]&\\", *p))
}
}
d[tmp] = '\0';
PL_subname, d);
have_proto = TRUE;
s = skipspace(s);
}
else
have_proto = FALSE;
if (*s == ':' && s[1] != ':')
if (have_proto) {
}
if (!have_name) {
}
}
case KEY_system:
set_csh();
case KEY_symlink:
case KEY_syscall:
case KEY_sysopen:
case KEY_sysseek:
case KEY_sysread:
case KEY_syswrite:
case KEY_tr:
s = scan_trans(s);
TERM(sublex_start());
case KEY_tell:
case KEY_telldir:
case KEY_tie:
case KEY_tied:
case KEY_time:
case KEY_times:
case KEY_truncate:
case KEY_uc:
case KEY_ucfirst:
case KEY_untie:
case KEY_until:
case KEY_unless:
case KEY_unlink:
case KEY_undef:
case KEY_unpack:
case KEY_utime:
case KEY_umask:
case KEY_unshift:
case KEY_use:
yyerror("\"use\" not allowed in expression");
s = skipspace(s);
s = force_version(s, TRUE);
}
else if (*s == 'v') {
s = force_version(s, FALSE);
}
}
else {
s = force_version(s, FALSE);
}
case KEY_values:
case KEY_vec:
case KEY_while:
case KEY_warn:
case KEY_wait:
case KEY_waitpid:
case KEY_wantarray:
case KEY_write:
#ifdef EBCDIC
{
}
#else
#endif
case KEY_x:
check_uni();
goto just_a_word;
case KEY_xor:
case KEY_y:
s = scan_trans(s);
TERM(sublex_start());
}
}}
}
#ifdef __SC__
#endif
static int
{
register char *d;
/* pit holds the identifier we read and pending_ident is reset */
PL_pending_ident = 0;
"### Tokener saw identifier '%s'\n", PL_tokenbuf); });
/* if we're in a my(), we can't allow dynamics here.
$foo'bar has already been turned into $foo::bar, so
just check for colons.
if it's a legal name, the OP is a PADANY.
*/
if (PL_in_my) {
"variable %s in \"our\"",
PL_tokenbuf));
}
else {
return PRIVATEREF;
}
}
/*
build the ops for accesses to a my() variable.
Deny my($a) or my($b) in a sort block, *if* $a or $b is
then used in a comparison. This catches most, but not
all cases. For instance, it catches
sort { my($a); $a <=> $b }
but not
sort { my($a); $a < $b ? -1 : $a == $b ? 0 : 1; }
(although why you'd do that is anyone's guess).
*/
#ifdef USE_5005THREADS
/* Check for single character per-thread SVs */
{
return PRIVATEREF;
}
#endif /* USE_5005THREADS */
if (!PL_in_my)
if (tmp != NOT_IN_PAD) {
/* might be an "our" variable" */
/* build ops for a bareword */
? (GV_ADDMULTI | GV_ADDINEVAL)
),
: SVt_PVHV));
return WORD;
}
/* if it's a sort block and they're naming $a or $b */
if (PL_last_lop_op == OP_SORT &&
PL_tokenbuf[0] == '$' &&
&& !PL_tokenbuf[2])
{
d < PL_bufend && *d != '\n';
d++)
{
}
}
}
return PRIVATEREF;
}
}
/*
Whine if they've said @foo in a doublequoted string,
and @foo isn't a variable we can find in the symbol
table.
*/
&& ckWARN(WARN_AMBIGUOUS))
{
/* Downgraded from fatal to warning 20000522 mjd */
"Possible unintended interpolation of %s in string",
}
}
/* build ops for a bareword */
: SVt_PVHV));
return WORD;
}
{
switch (*d) {
case '_':
if (d[1] == '_') {
}
break;
case 'A':
break;
case 'a':
switch (len) {
case 3:
break;
case 5:
break;
case 6:
break;
}
break;
case 'B':
break;
case 'b':
break;
case 'C':
break;
case 'c':
switch (len) {
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
}
break;
case 'D':
break;
case 'd':
switch (len) {
case 2:
break;
case 3:
break;
case 4:
break;
case 6:
break;
case 7:
break;
case 8:
break;
}
break;
case 'E':
break;
case 'e':
switch (len) {
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
"elseif should be elsif");
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
break;
}
break;
case 'f':
switch (len) {
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
}
break;
case 'g':
d += 3;
if (*d == 'p') {
switch (len) {
case 7:
break;
case 8:
break;
case 11:
break;
case 14:
break;
case 16:
break;
}
}
else if (*d == 'h') {
}
else if (*d == 'n') {
}
else if (*d == 's') {
}
else if (*d == 'g') {
}
else if (*d == 'l') {
}
break;
}
switch (len) {
case 2:
break;
case 4:
break;
case 6:
break;
}
break;
case 'h':
break;
case 'I':
break;
case 'i':
switch (len) {
case 2:
break;
case 3:
break;
case 5:
break;
}
break;
case 'j':
break;
case 'k':
if (len == 4) {
}
break;
case 'l':
switch (len) {
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 9:
break;
}
break;
case 'm':
switch (len) {
case 1: return KEY_m;
case 2:
break;
case 3:
break;
case 5:
break;
case 6:
break;
}
break;
case 'n':
break;
case 'o':
switch (len) {
case 2:
break;
case 3:
break;
case 4:
break;
case 7:
break;
}
break;
case 'p':
switch (len) {
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 9:
}
break;
case 'q':
if (len <= 2) {
}
break;
case 'r':
switch (len) {
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break;
}
break;
case 's':
switch (d[1]) {
case 0: return KEY_s;
case 'c':
break;
case 'e':
switch (len) {
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
break;
}
break;
case 'h':
switch (len) {
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
}
break;
case 'i':
break;
case 'l':
break;
case 'o':
break;
case 'p':
break;
case 'q':
break;
case 'r':
break;
case 't':
break;
case 'u':
break;
case 'y':
switch (len) {
case 6:
break;
case 7:
break;
case 8:
break;
}
break;
}
break;
case 't':
switch (len) {
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 7:
break;
case 8:
break;
}
break;
case 'u':
switch (len) {
case 2:
break;
case 3:
break;
case 5:
break;
case 6:
break;
case 7:
break;
}
break;
case 'v':
break;
case 'w':
switch (len) {
case 4:
break;
case 5:
break;
case 7:
break;
case 9:
break;
}
break;
case 'x':
break;
case 'y':
break;
case 'z':
break;
}
return 0;
}
STATIC void
{
char *w;
if (*s == ' ' && s[1] == '(') { /* XXX gotta be a better way */
if (ckWARN(WARN_SYNTAX)) {
for (w = s+2; *w && level; w++) {
if (*w == '(')
++level;
else if (*w == ')')
--level;
}
if (*w)
for (; *w && isSPACE(*w); w++) ;
}
}
s++;
if (*s == '(')
s++;
s++;
if (isIDFIRST_lazy_if(s,UTF)) {
w = s++;
while (isALNUM_lazy_if(s,UTF))
s++;
s++;
if (*s == ',') {
int kw;
*s = '\0';
*s = ',';
if (kw)
return;
}
}
}
/* Either returns sv, or mortalizes sv and returns a new SV*.
Best used as sv=new_constant(..., sv, ...).
If s, pv are NULL, calls subroutine with one argument,
and type is used with error messages only. */
const char *type)
{
dSP;
? "(possibly a missing \"use charnames ...\")"
: "";
/* This is convoluted and evil ("goto considered harmful")
* but I do not understand the intricacies of all the different
* failure modes of %^H in here. The goal here is to make
* the most probable error message user-friendly. --jhi */
goto msgdone;
return sv;
}
why1 = "$^H{";
why3 = "} is not defined";
goto report;
}
if (!pv && s)
else
typesv = &PL_sv_undef;
ENTER ;
if (pv)
if (pv)
SPAGAIN ;
/* Check the eval first */
(void)POPs;
}
else {
(void)SvREFCNT_inc(res);
}
PUTBACK ;
FREETMPS ;
LEAVE ;
why1 = "Call to &{$^H{";
why3 = "}} did not return a defined value";
goto report;
}
return res;
}
STATIC char *
{
register char *d = dest;
for (;;) {
if (d >= e)
if (isALNUM(*s)) /* UTF handled below */
*d++ = *s++;
*d++ = ':';
*d++ = ':';
s++;
}
*d++ = *s++;
*d++ = *s++;
}
char *t = s + UTF8SKIP(s);
t += UTF8SKIP(t);
if (d + (t - s) > e)
Copy(s, d, t - s, char);
d += t - s;
s = t;
}
else {
*d = '\0';
return s;
}
}
}
STATIC char *
{
register char *d;
register char *e;
char *bracket = 0;
char funny = *s++;
if (isSPACE(*s))
s = skipspace(s);
d = dest;
if (isDIGIT(*s)) {
while (isDIGIT(*s)) {
if (d >= e)
*d++ = *s++;
}
}
else {
for (;;) {
if (d >= e)
if (isALNUM(*s)) /* UTF handled below */
*d++ = *s++;
*d++ = ':';
*d++ = ':';
s++;
}
else if (*s == ':' && s[1] == ':') {
*d++ = *s++;
*d++ = *s++;
}
char *t = s + UTF8SKIP(s);
t += UTF8SKIP(t);
if (d + (t - s) > e)
Copy(s, d, t - s, char);
d += t - s;
s = t;
}
else
break;
}
}
*d = '\0';
d = dest;
if (*d) {
if (PL_lex_state != LEX_NORMAL)
return s;
}
if (*s == '$' && s[1] &&
{
return s;
}
if (*s == '{') {
bracket = s;
s++;
}
else if (ck_uni)
check_uni();
if (s < send)
*d = *s++;
d[1] = '\0';
if (*d == '^' && *s && isCONTROLVAR(*s)) {
*d = toCTRL(*s);
s++;
}
if (bracket) {
if (isSPACE(s[-1])) {
while (s < send) {
char ch = *s++;
if (!SPACE_OR_TAB(ch)) {
*d = ch;
break;
}
}
}
if (isIDFIRST_lazy_if(d,UTF)) {
d++;
if (UTF) {
e = s;
e += UTF8SKIP(e);
e += UTF8SKIP(e);
}
Copy(s, d, e - s, char);
d += e - s;
s = e;
}
else {
while ((isALNUM(*s) || *s == ':') && d < e)
*d++ = *s++;
if (d >= e)
}
*d = '\0';
while (s < send && SPACE_OR_TAB(*s)) s++;
"Ambiguous use of %c{%s%s} resolved to %c%s%s",
}
bracket++;
return s;
}
}
/* Handle extended ${^Foo} variables
* 1999-02-27 mjd-perl-patch@plover.com */
&& isALNUM(*s))
{
d++;
while (isALNUM(*s) && d < e) {
*d++ = *s++;
}
if (d >= e)
*d = '\0';
}
if (*s == '}') {
s++;
}
if (funny == '#')
funny = '@';
if (PL_lex_state == LEX_NORMAL) {
if (ckWARN(WARN_AMBIGUOUS) &&
{
"Ambiguous use of %c{%s} resolved to %c%s",
}
}
}
else {
s = bracket; /* let the parser handle it */
*dest = '\0';
}
}
return s;
}
void
{
if (ch == 'i')
else if (ch == 'g')
*pmfl |= PMf_GLOBAL;
else if (ch == 'c')
*pmfl |= PMf_CONTINUE;
else if (ch == 'o')
else if (ch == 'm')
*pmfl |= PMf_MULTILINE;
else if (ch == 's')
*pmfl |= PMf_SINGLELINE;
else if (ch == 'x')
*pmfl |= PMf_EXTENDED;
}
STATIC char *
{
char *s;
if (!s)
if (PL_multi_open == '?')
while (*s && strchr("iomsx", *s))
}
else {
while (*s && strchr("iogcmsx", *s))
}
/* issue a warning if /c is specified,but /g is not */
if (ckWARN(WARN_REGEXP) &&
{
}
return s;
}
STATIC char *
{
register char *s;
if (!s)
if (s[-1] == PL_multi_open)
s--;
if (!s) {
if (PL_lex_stuff) {
}
}
while (*s) {
if (*s == 'e') {
s++;
es++;
}
else if (strchr("iogcmsx", *s))
else
break;
}
/* /c is not meaningful with s/// */
{
}
if (es) {
PL_multi_end = 0;
while (es-- > 0)
PL_lex_repl = repl;
}
return s;
}
STATIC char *
{
register char* s;
OP *o;
short *tbl;
if (!s)
if (s[-1] == PL_multi_open)
s--;
if (!s) {
if (PL_lex_stuff) {
}
}
while (strchr("cds", *s)) {
if (*s == 'c')
else if (*s == 'd')
else if (*s == 's')
s++;
}
PL_lex_op = o;
return s;
}
STATIC char *
{
char term;
register char *d;
register char *e;
char *peek;
s += 2;
d = PL_tokenbuf;
if (!outer)
*d++ = '\n';
s = peek;
term = *s++;
d += len;
if (s < PL_bufend)
s++;
}
else {
if (*s == '\\')
s++, term = '\'';
else
term = '"';
if (!isALNUM_lazy_if(s,UTF))
deprecate_old("bare << to mean <<\"\"");
for (; isALNUM_lazy_if(s,UTF); s++) {
if (d < e)
*d++ = *s;
}
}
*d++ = '\n';
*d = '\0';
len = d - PL_tokenbuf;
#ifndef PERL_STRICT_CR
d = strchr(s, '\r');
if (d) {
char *olds = s;
s = d;
while (s < PL_bufend) {
if (*s == '\r') {
*d++ = '\n';
if (*++s == '\n')
s++;
}
else if (*s == '\n' && s[1] == '\r') { /* \015\013 on a mac? */
*d++ = *s++;
s++;
}
else
*d++ = *s++;
}
*d = '\0';
PL_bufend = d;
s = olds;
}
#endif
d = "\n";
else
if (term == '\'') {
}
else if (term == '`') {
}
term = *PL_tokenbuf;
if (!s)
s = bufend;
d = s;
while (s < bufend &&
if (*s++ == '\n')
}
if (s >= bufend) {
}
s += len - 1;
s = olds;
goto retval;
}
else if (!outer) {
d = s;
while (s < PL_bufend &&
if (*s++ == '\n')
}
if (s >= PL_bufend) {
}
s += len - 1;
}
else
while (s >= PL_bufend) { /* multiple line string? */
if (!outer ||
}
#ifndef PERL_STRICT_CR
{
PL_bufend--;
}
}
#endif
}
s = PL_bufend - 1;
*s = ' ';
}
else {
s = PL_bufend;
}
}
s++;
}
if (!IN_BYTES) {
else if (PL_encoding)
}
return s;
}
/* scan_inputsymbol
takes: current position in input buffer
returns: new position in input buffer
side-effects: yylval and lex_op are set.
This code handles:
<> read from ARGV
<FH> read from filehandle
<pkg::FH> read from package qualified filehandle
<pkg'FH> read from package qualified filehandle
<$fh> read from filehandle in $fh
<*.h> filename glob
*/
STATIC char *
{
register char *s = start; /* current position in buffer */
register char *d;
register char *e;
char *end;
d = PL_tokenbuf; /* start of temp holding space */
if (!end)
/* die if we didn't have space for the contents of the <>,
or if it didn't end, or if we see a newline
*/
if (len >= sizeof PL_tokenbuf)
if (s >= end)
s++;
/* check for <$fh>
Remember, only scalar variables are interpreted as filehandles by
this code. Anything more complex (e.g., <$fh{$num}>) will be
treated as a glob() call.
This code makes use of the fact that except for the $ at the front,
a scalar variable and a filehandle look the same.
*/
if (*d == '$' && d[1]) d++;
/* allow <Pkg'VALUE> or <Pkg::VALUE> */
d++;
/* If we've tried to read what we allow filehandles to look like, and
there's still text left, then it must be a glob() and not a getline.
Use scan_str to pull out the stuff between the <> and treat it
as nothing more than a string.
*/
if (d - PL_tokenbuf != len) {
set_csh();
if (!s)
return s;
}
else {
/* we're in a filehandle read situation */
d = PL_tokenbuf;
/* turn <> into <ARGV> */
if (!len)
(void)strcpy(d,"ARGV");
/* Check whether readline() is overriden */
||
/* if <$fh>, create the ops to turn the variable into a
filehandle
*/
if (*d == '$') {
/* try to find it in the pad for this block, otherwise find
add symbol table ops
*/
goto intro_sym;
}
else {
append_elem(OP_LIST, o,
}
}
else {
++d;
gv = gv_fetchpv(d,
? (GV_ADDMULTI | GV_ADDINEVAL)
: GV_ADDMULTI),
SVt_PV);
}
if (!readline_overriden)
/* we created the ops in PL_lex_op, so make yylval.ival a null op */
}
/* If it's none of the above, it must be a literal filehandle
(<Foo::BAR> or <FOO>) so build a simple readline OP */
else {
}
}
return s;
}
/* scan_str
takes: start position in buffer
keep_quoted preserve \ on the embedded delimiter(s)
keep_delims preserve the delimiters around the string
returns: position to continue reading from buffer
side-effects: multi_start, multi_close, lex_repl or lex_stuff, and
updates the read buffer.
This subroutine pulls a string out of the input. It is called for:
q single quotes q(literal text)
' single quotes 'literal text'
qq double quotes qq(interpolate $here please)
" double quotes "interpolate $here please"
qw quote words @EXPORT_OK = qw( func() $spam )
($*@) sub prototypes sub foo ($)
(stuff) sub attr parameters sub foo : attr(stuff)
<> readline or globs <FOO>, <>, <$fh>, or <*.c>
In most of these cases (all but <>, patterns and transliterate)
yylex() calls scan_str(). m// makes yylex() call scan_pat() which
calls scan_str(). s/// makes yylex() call scan_subst() which calls
scan_str(). tr/// and y/// make yylex() call scan_trans() which
calls scan_str().
It skips whitespace before the string starts, and treats the first
character as the delimiter. If the delimiter is one of ([{< then
the corresponding "close" character )]}> is used as the closing
delimiter. It allows quoting of delimiters, and if the string has
balanced delimiters ([{<>}]) it allows nesting.
On success, the SV with the resulting string is put into lex_stuff or,
if that is already non-NULL, into lex_repl. The second case occurs only
when parsing the RHS of the special constructs s/// and tr/// (y///).
For convenience, the terminating delimiter character is stuffed into
SvIVX of the SV.
*/
STATIC char *
{
register char *s = start; /* current position in the buffer */
/* skip space before the delimiter */
if (isSPACE(*s))
s = skipspace(s);
/* mark where we are, in case we need to report errors */
/* after skipping whitespace, the next character is the terminator */
term = *s;
if (!UTF) {
termlen = 1;
}
else {
if (!UTF8_IS_INVARIANT(term))
}
/* mark where we are */
/* find corresponding closing delimiter */
/* create a new SV to hold the contents. 87 is leak category, I'm
assuming. 79 is the SV's initial length. What a random number. */
/* move past delimiter and try to read a complete string */
if (keep_delims)
s += termlen;
for (;;) {
if (PL_encoding && !UTF) {
while (cont) {
for (; s < ns; s++) {
if (*s == '\n' && !PL_rsfp)
}
if (!found)
goto read_more_line;
else {
/* handle quoted delimiters */
char *t;
t--;
if (!keep_quoted) {
*svlast = '\0';
}
continue;
}
}
if (PL_multi_open == PL_multi_close) {
}
else {
char *t, *w;
if (!last)
/* At here, all closes are "was quoted" one,
so we don't check PL_multi_close. */
if (*t == '\\') {
t++;
else
*w++ = *t++;
}
else if (*t == PL_multi_open)
brackets++;
*w = *t;
}
if (w < t) {
*w++ = term;
*w = '\0';
}
last = w;
if (--brackets <= 0)
}
}
}
if (!keep_delims) {
}
break;
}
/* extend sv if need be */
/* set 'to' to the next character in the sv's string */
/* if open delimiter is the close delimiter read unbridle */
if (PL_multi_open == PL_multi_close) {
/* embedded newlines increment the current line number */
if (*s == '\n' && !PL_rsfp)
/* handle quoted delimiters */
s++;
/* any other quotes are simply copied straight through */
else
*to++ = *s++;
}
/* terminate when run out of buffer (the for() condition), or
have found the terminator */
else if (*s == term) {
if (termlen == 1)
break;
break;
}
*to = *s;
}
}
/* if the terminator isn't the same as the start character (e.g.,
matched brackets), we have to allow more in the quoting, and
be prepared for nested brackets.
*/
else {
/* read until we run out of string, or we find the terminator */
/* embedded newlines increment the line count */
if (*s == '\n' && !PL_rsfp)
/* backslashes can escape the open or closing characters */
if (!keep_quoted &&
s++;
else
*to++ = *s++;
}
/* allow nested opens and closes */
else if (*s == PL_multi_close && --brackets <= 0)
break;
else if (*s == PL_multi_open)
brackets++;
*to = *s;
}
}
/* terminate the copied string and update the sv's end-of-string */
*to = '\0';
/*
* this next chunk reads more into the buffer if we're not done yet
*/
if (s < PL_bufend)
break; /* handle case where we are done yet :-) */
#ifndef PERL_STRICT_CR
{
to--;
}
}
#endif
/* if we're out of file, or a read fails, bail and reset the current
line marker so we can report where the unterminated string began
*/
if (!PL_rsfp ||
return Nullch;
}
/* we read a line, so increment our line counter */
/* update debugger info */
}
/* having changed the buffer, we must update PL_bufend */
}
/* at this point, we have successfully read the delimited string */
if (!PL_encoding || UTF) {
if (keep_delims)
s += termlen;
}
if (has_utf8 || PL_encoding)
/* if we allocated too much space, give some back */
}
/* decide whether this is the first or second quoted string we've read
for this op
*/
if (PL_lex_stuff)
PL_lex_repl = sv;
else
PL_lex_stuff = sv;
return s;
}
/*
scan_num
takes: pointer to position in buffer
returns: pointer to new position in buffer
side-effects: builds ops for the constant in yylval.op
Read a number in any of the formats that Perl accepts:
\d(_?\d)*(\.(\d(_?\d)*)?)?[Ee][\+\-]?(\d(_?\d)*) 12 12.34 12.
\.\d(_?\d)*[Ee][\+\-]?(\d(_?\d)*) .34
0b[01](_?[01])*
0[0-7](_?[0-7])*
0x[0-9A-Fa-f](_?[0-9A-Fa-f])*
Like most scan_ routines, it uses the PL_tokenbuf buffer to hold the
thing it reads.
If it reads a number without a decimal point or an exponent, it will
try converting the number to an integer and see if it can do so
without loss of precision.
*/
char *
{
register char *s = start; /* current position in buffer */
register char *d; /* destination in temp buffer */
register char *e; /* end of temp buffer */
/* We use the first character to decide what type of number this is */
switch (*s) {
default:
/* if it starts with a 0, it could be an octal number, a decimal in
0.13 disguise, or a hexadecimal number, or a binary number. */
case '0':
{
/* variables:
u holds the "number so far"
shift the power of 2 of the base
(hex == 4, octal == 3, binary == 1)
overflowed was the number more than we can hold?
Shift is used when we add a digit. It also serves as an "are
when in octal mode.
*/
NV n = 0.0;
UV u = 0;
"hexadecimal" };
"Hexadecimal" };
"0b11111111111111111111111111111111",
"",
"037777777777",
"0xffffffff" };
/* check for hex */
if (s[1] == 'x') {
shift = 4;
s += 2;
} else if (s[1] == 'b') {
shift = 1;
s += 2;
}
/* check for a decimal in disguise */
else if (s[1] == '.' || s[1] == 'e' || s[1] == 'E')
goto decimal;
/* so it must be octal */
else {
shift = 3;
s++;
}
if (*s == '_') {
if (ckWARN(WARN_SYNTAX))
"Misplaced _ in number");
lastub = s++;
}
/* read the rest of the number */
for (;;) {
/* x is used in the overflow test,
b is the digit we're adding on. */
UV x, b;
switch (*s) {
/* if we don't mention it, we're done */
default:
goto out;
/* _ are ignored -- but warned about if consecutive */
case '_':
"Misplaced _ in number");
lastub = s++;
break;
/* 8 and 9 are not octal */
case '8': case '9':
if (shift == 3)
/* FALL THROUGH */
/* octal digits */
case '2': case '3': case '4':
case '5': case '6': case '7':
if (shift == 1)
/* FALL THROUGH */
case '0': case '1':
b = *s++ & 15; /* ASCII digit -> value of digit */
goto digit;
/* hex digits */
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
/* make sure they said 0x */
if (shift != 4)
goto out;
b = (*s++ & 7) + 9;
/* Prepare to put the digit we have onto the end
of the number so far. We check for overflows.
*/
if (!overflowed) {
x = u << shift; /* make room for the digit */
if ((x >> shift) != u
&& !(PL_hints & HINT_NEW_BINARY)) {
overflowed = TRUE;
n = (NV) u;
if (ckWARN_d(WARN_OVERFLOW))
"Integer overflow in %s number",
base);
} else
u = x | b; /* add the digit to the end */
}
if (overflowed) {
/* If an NV has not enough bits in its
* mantissa to represent an UV this summing of
* small low-order numbers is a waste of time
* (because the NV cannot preserve the
* low-order bits anyway): we could just
* remember when did we overflow and in the
* end just multiply n by the right
* amount. */
n += (NV) b;
}
break;
}
}
/* if we get here, we had success: make a scalar value from
the number.
*/
out:
/* final misplaced underbar check */
if (s[-1] == '_') {
if (ckWARN(WARN_SYNTAX))
}
if (overflowed) {
"%s number > %s non-portable",
}
else {
#if UVSIZE > 4
"%s number > %s non-portable",
#endif
}
if (PL_hints & HINT_NEW_BINARY)
}
break;
/*
handle decimal numbers.
we're also sent here when we read a 0 as the first digit
*/
case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9': case '.':
d = PL_tokenbuf;
/* read next group of digits and _ and copy into d */
while (isDIGIT(*s) || *s == '_') {
/* skip underscores, checking for misplaced ones
if -w is on
*/
if (*s == '_') {
"Misplaced _ in number");
lastub = s++;
}
else {
/* check for end of fixed-length buffer */
if (d >= e)
/* if we're ok, copy the character */
*d++ = *s++;
}
}
/* final misplaced underbar check */
if (ckWARN(WARN_SYNTAX))
}
/* read a decimal portion if there is one. avoid
3..5 being interpreted as the number 3. followed
by .5
*/
if (*s == '.' && s[1] != '.') {
*d++ = *s++;
if (*s == '_') {
if (ckWARN(WARN_SYNTAX))
"Misplaced _ in number");
lastub = s;
}
/* copy, ignoring underbars, until we run out of digits.
*/
for (; isDIGIT(*s) || *s == '_'; s++) {
/* fixed length buffer check */
if (d >= e)
if (*s == '_') {
"Misplaced _ in number");
lastub = s;
}
else
*d++ = *s;
}
/* fractional part ending in underbar? */
if (s[-1] == '_') {
if (ckWARN(WARN_SYNTAX))
"Misplaced _ in number");
}
/* oops, it's really a v-string, but without the "v" */
s = start;
goto vstring;
}
}
/* read exponent part, if present */
s++;
/* regardless of whether user said 3E5 or 3e5, use lower 'e' */
*d++ = 'e'; /* At least some Mach atof()s don't grok 'E' */
/* stray preinitial _ */
if (*s == '_') {
if (ckWARN(WARN_SYNTAX))
"Misplaced _ in number");
lastub = s++;
}
/* allow positive or negative exponent */
if (*s == '+' || *s == '-')
*d++ = *s++;
/* stray initial _ */
if (*s == '_') {
if (ckWARN(WARN_SYNTAX))
"Misplaced _ in number");
lastub = s++;
}
/* read digits of exponent */
while (isDIGIT(*s) || *s == '_') {
if (isDIGIT(*s)) {
if (d >= e)
*d++ = *s++;
}
else {
if (ckWARN(WARN_SYNTAX) &&
"Misplaced _ in number");
lastub = s++;
}
}
}
/* make an sv from the string */
/*
We try to do an integer conversion first if no characters
indicating "float" have been found.
*/
if (!floatit) {
if (flags == IS_NUMBER_IN_UV) {
else
else
} else
}
if (floatit) {
/* terminate the string */
*d = '\0';
}
(PL_hints & HINT_NEW_INTEGER) )
break;
/* if it starts with a v, it could be a v-string */
case 'v':
s = scan_vstring(s,sv);
"### Saw v-string before '%s'\n", s);
} );
break;
}
/* make the op for the constant and return */
if (sv)
else
return s;
}
STATIC char *
{
register char *eol;
register char *t;
while (!needargs) {
if (*s == '.') {
/*SUPPRESS 530*/
#ifdef PERL_STRICT_CR
for (t = s+1;SPACE_OR_TAB(*t); t++) ;
#else
#endif
if (*t == '\n' || t == PL_bufend) {
break;
}
}
if (PL_in_eval && !PL_rsfp) {
if (!eol++)
}
else
if (*s != '#') {
for (t = s; t < eol; t++) {
goto enough; /* ~~ must be first line in formline */
}
if (*t == '@' || *t == '^')
}
if (eol > s) {
#ifndef PERL_STRICT_CR
}
#endif
}
else
break;
}
s = eol;
if (PL_rsfp) {
if (!s) {
s = PL_bufptr;
break;
}
}
incline(s);
}
if (needargs) {
force_next(',');
}
else
if (!IN_BYTES) {
else if (PL_encoding)
}
}
else {
if (eofmt)
PL_lex_formbrack = 0;
PL_bufptr = s;
}
return s;
}
STATIC void
{
#ifdef CSH
if (!PL_cshlen)
#endif
}
{
if (PL_compcv) {
}
#ifdef USE_5005THREADS
#endif /* USE_5005THREADS */
return oldsavestack_ix;
}
#ifdef __SC__
#pragma segment Perl_yylex
#endif
int
{
yyerror(s);
PL_in_eval &= ~EVAL_WARNONLY;
return 0;
}
int
{
where = "at EOF";
/*
Only for NetWare:
when the script has error such as not having the closing quotes like:
if ($var eq "value)
Checking of white spaces is anyway done in NetWare code.
*/
#ifndef NETWARE
while (isSPACE(*PL_oldoldbufptr))
#endif
}
PL_oldbufptr != PL_bufptr) {
/*
Only for NetWare:
when the script has error such as not having the closing quotes like:
if ($var eq "value)
Checking of white spaces is anyway done in NetWare code.
*/
#ifndef NETWARE
while (isSPACE(*PL_oldbufptr))
PL_oldbufptr++;
#endif
}
else if (yychar > 255)
where = "next token ???";
#ifdef USE_PURE_BISON
/* GNU Bison sets the value -2 */
else if (yychar == -2) {
#else
#endif
if (PL_lex_state == LEX_NORMAL ||
where = "at end of line";
else if (PL_lex_inpat)
where = "within pattern";
else
where = "within string";
}
else {
if (yychar < 32)
else if (isPRINT_LC(yychar))
else
}
if (context)
else
PL_multi_end = 0;
}
else
if (PL_error_count >= 10) {
else
}
PL_in_my = 0;
return 0;
}
#ifdef __SC__
#endif
STATIC char*
{
switch (s[0]) {
case 0xFF:
if (s[1] == 0xFE) {
/* UTF-16 little-endian? (or UTF32-LE?) */
if (s[2] == 0 && s[3] == 0) /* UTF-32 little-endian */
#ifndef PERL_NO_UTF16_FILTER
if (DEBUG_p_TEST || DEBUG_T_TEST) PerlIO_printf(Perl_debug_log, "UTF16-LE script encoding (BOM)\n");
s += 2;
if (PL_bufend > (char*)s) {
(char*)utf16_to_utf8_reversed(s, news,
PL_bufend - (char*)s - 1,
&newlen);
}
#else
#endif
}
break;
case 0xFE:
if (s[1] == 0xFF) { /* UTF-16 big-endian? */
#ifndef PERL_NO_UTF16_FILTER
if (DEBUG_p_TEST || DEBUG_T_TEST) PerlIO_printf(Perl_debug_log, "UTF-16BE script encoding (BOM)\n");
s += 2;
if (PL_bufend > (char *)s) {
(char*)utf16_to_utf8(s, news,
PL_bufend - (char*)s,
&newlen);
}
#else
#endif
}
break;
case 0xEF:
s += 3; /* UTF-8 */
}
break;
case 0:
if (slen > 3) {
if (s[1] == 0) {
if (s[2] == 0xFE && s[3] == 0xFF) {
/* UTF-32 big-endian */
}
}
else if (s[2] == 0 && s[3] != 0) {
/* Leading bytes
* 00 xx 00 xx
* are a good indicator of UTF-16BE. */
if (DEBUG_p_TEST || DEBUG_T_TEST) PerlIO_printf(Perl_debug_log, "UTF-16BE script encoding (no BOM)\n");
goto utf16be;
}
}
default:
/* Leading bytes
* xx 00 xx 00
* are a good indicator of UTF-16LE. */
if (DEBUG_p_TEST || DEBUG_T_TEST) PerlIO_printf(Perl_debug_log, "UTF-16LE script encoding (no BOM)\n");
goto utf16le;
}
}
return (char*)s;
}
/*
* restore_rsfp
* Restore a source filter.
*/
static void
{
if (PL_rsfp == PerlIO_stdin())
}
#ifndef PERL_NO_UTF16_FILTER
static I32
{
if (count) {
if (!*SvPV_nolen(sv))
/* Game over, but don't feed an odd-length string to utf16_to_utf8 */
return count;
}
return count;
}
static I32
{
if (count) {
if (!*SvPV_nolen(sv))
/* Game over, but don't feed an odd-length string to utf16_to_utf8 */
return count;
}
return count;
}
#endif
/*
Returns a pointer to the next character after the parsed
vstring, as well as updating the passed in sv.
Function must be called like
sv = NEWSV(92,5);
s = scan_vstring(s,sv);
The sv should already be large enough to store the vstring
passed in, for performance reasons.
*/
char *
{
char *pos = s;
char *start = s;
pos++;
if ( *pos != '.') {
/* this may not be a v-string if followed by => */
++next;
/* return string not v-string */
return pos;
}
}
if (*s == 'v') s++; /* get past 'v' */
for (;;) {
rev = 0;
{
/* this is atoi() that tolerates underscores */
while (--end >= s) {
if (*end == '_')
continue;
mult *= 10;
"Integer overflow in decimal number");
}
}
#ifdef EBCDIC
if (rev > 0x7FFFFFFF)
#endif
/* Append native character for the rev point */
s = ++pos;
else {
s = pos;
break;
}
pos++;
}
}
return s;
}