3 * Copyright (c) 1991-1994, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * "It all comes from here, the stench and the peril." --Frodo
17 static void check_uni _((void));
18 static void force_next _((I32 type));
19 static char *force_word _((char *start, int token, int check_keyword, int allow_pack, int allow_tick));
20 static SV *q _((SV *sv));
21 static char *scan_const _((char *start));
22 static char *scan_formline _((char *s));
23 static char *scan_heredoc _((char *s));
24 static char *scan_ident _((char *s, char *send, char *dest, I32 ck_uni));
25 static char *scan_inputsymbol _((char *start));
26 static char *scan_pat _((char *start));
27 static char *scan_str _((char *start));
28 static char *scan_subst _((char *start));
29 static char *scan_trans _((char *start));
30 static char *scan_word _((char *s, char *dest, int allow_package, STRLEN *slp));
31 static char *skipspace _((char *s));
32 static void checkcomma _((char *s, char *name, char *what));
33 static void force_ident _((char *s, int kind));
34 static void incline _((char *s));
35 static int intuit_method _((char *s, GV *gv));
36 static int intuit_more _((char *s));
37 static I32 lop _((I32 f, expectation x, char *s));
38 static void missingterm _((char *s));
39 static void no_op _((char *what, char *s));
40 static void set_csh _((void));
41 static I32 sublex_done _((void));
42 static I32 sublex_start _((void));
44 static int uni _((I32 f, char *s));
46 static char * filter_gets _((SV *sv, FILE *fp));
47 static void restore_rsfp _((void *f));
49 /* The following are arranged oddly so that the guard on the switch statement
50 * can get by with a single comparison (if the compiler is smart enough).
54 #define LEX_INTERPNORMAL 8
55 #define LEX_INTERPCASEMOD 7
56 #define LEX_INTERPSTART 6
57 #define LEX_INTERPEND 5
58 #define LEX_INTERPENDMAYBE 4
59 #define LEX_INTERPCONCAT 3
60 #define LEX_INTERPCONST 2
61 #define LEX_FORMLINE 1
62 #define LEX_KNOWNEXT 0
80 #define CLINE (copline = (curcop->cop_line < copline ? curcop->cop_line : copline))
82 #define TOKEN(retval) return (bufptr = s,(int)retval)
83 #define OPERATOR(retval) return (expect = XTERM,bufptr = s,(int)retval)
84 #define AOPERATOR(retval) return ao((expect = XTERM,bufptr = s,(int)retval))
85 #define PREBLOCK(retval) return (expect = XBLOCK,bufptr = s,(int)retval)
86 #define PRETERMBLOCK(retval) return (expect = XTERMBLOCK,bufptr = s,(int)retval)
87 #define PREREF(retval) return (expect = XREF,bufptr = s,(int)retval)
88 #define TERM(retval) return (CLINE, expect = XOPERATOR,bufptr = s,(int)retval)
89 #define LOOPX(f) return(yylval.ival=f,expect = XTERM,bufptr = s,(int)LOOPEX)
90 #define FTST(f) return(yylval.ival=f,expect = XTERM,bufptr = s,(int)UNIOP)
91 #define FUN0(f) return(yylval.ival = f,expect = XOPERATOR,bufptr = s,(int)FUNC0)
92 #define FUN1(f) return(yylval.ival = f,expect = XOPERATOR,bufptr = s,(int)FUNC1)
93 #define BOop(f) return ao((yylval.ival=f,expect = XTERM,bufptr = s,(int)BITOROP))
94 #define BAop(f) return ao((yylval.ival=f,expect = XTERM,bufptr = s,(int)BITANDOP))
95 #define SHop(f) return ao((yylval.ival=f,expect = XTERM,bufptr = s,(int)SHIFTOP))
96 #define PWop(f) return ao((yylval.ival=f,expect = XTERM,bufptr = s,(int)POWOP))
97 #define PMop(f) return(yylval.ival=f,expect = XTERM,bufptr = s,(int)MATCHOP)
98 #define Aop(f) return ao((yylval.ival=f,expect = XTERM,bufptr = s,(int)ADDOP))
99 #define Mop(f) return ao((yylval.ival=f,expect = XTERM,bufptr = s,(int)MULOP))
100 #define Eop(f) return(yylval.ival=f,expect = XTERM,bufptr = s,(int)EQOP)
101 #define Rop(f) return(yylval.ival=f,expect = XTERM,bufptr = s,(int)RELOP)
103 /* This bit of chicanery makes a unary function followed by
104 * a parenthesis into a function with one argument, highest precedence.
106 #define UNI(f) return(yylval.ival = f, \
109 last_uni = oldbufptr, \
111 (*s == '(' || (s = skipspace(s), *s == '(') ? (int)FUNC1 : (int)UNIOP) )
113 #define UNIBRACK(f) return(yylval.ival = f, \
115 last_uni = oldbufptr, \
116 (*s == '(' || (s = skipspace(s), *s == '(') ? (int)FUNC1 : (int)UNIOP) )
118 /* grandfather return to old style */
119 #define OLDLOP(f) return(yylval.ival=f,expect = XTERM,bufptr = s,(int)LSTOP)
125 if (*bufptr == '=') {
127 if (toketype == ANDAND)
128 yylval.ival = OP_ANDASSIGN;
129 else if (toketype == OROR)
130 yylval.ival = OP_ORASSIGN;
142 char *oldbp = bufptr;
143 bool is_first = (oldbufptr == SvPVX(linestr));
145 sprintf(tmpbuf, "%s found where operator expected", what);
148 warn("\t(Missing semicolon on previous line?)\n");
149 else if (oldoldbufptr && isIDFIRST(*oldoldbufptr)) {
151 for (t = oldoldbufptr; *t && (isALNUM(*t) || *t == ':'); t++) ;
152 if (t < bufptr && isSPACE(*t))
153 warn("\t(Do you need to predeclare %.*s?)\n",
154 t - oldoldbufptr, oldoldbufptr);
158 warn("\t(Missing operator before %.*s?)\n", s - oldbp, oldbp);
169 char *nl = strrchr(s,'\n');
173 else if (multi_close < 32 || multi_close == 127) {
175 tmpbuf[1] = multi_close ^ 64;
181 *tmpbuf = multi_close;
185 q = strchr(s,'"') ? '\'' : '"';
186 croak("Can't find string terminator %c%s%c anywhere before EOF",q,s,q);
194 warn("Use of %s is deprecated", s);
200 deprecate("comma-less variable list");
211 SAVEINT(lex_brackets);
212 SAVEINT(lex_fakebrack);
213 SAVEINT(lex_casemods);
218 SAVEINT(curcop->cop_line);
222 SAVEPPTR(oldoldbufptr);
224 SAVEPPTR(lex_brackstack);
225 SAVEPPTR(lex_casestack);
226 SAVEDESTRUCTOR(restore_rsfp, rsfp);
228 lex_state = LEX_NORMAL;
233 New(899, lex_brackstack, 120, char);
234 New(899, lex_casestack, 12, char);
235 SAVEFREEPV(lex_brackstack);
236 SAVEFREEPV(lex_casestack);
238 *lex_casestack = '\0';
242 SvREFCNT_dec(lex_stuff);
245 SvREFCNT_dec(lex_repl);
250 if (SvREADONLY(linestr))
251 linestr = sv_2mortal(newSVsv(linestr));
252 s = SvPV(linestr, len);
253 if (len && s[len-1] != ';') {
254 if (!(SvFLAGS(linestr) & SVs_TEMP))
255 linestr = sv_2mortal(newSVsv(linestr));
256 sv_catpvn(linestr, "\n;", 2);
259 oldoldbufptr = oldbufptr = bufptr = SvPVX(linestr);
260 bufend = bufptr + SvCUR(linestr);
262 rs = newSVpv("\n", 1);
279 else if (rsfp && (rsfp != fp))
296 while (*s == ' ' || *s == '\t') s++;
297 if (strnEQ(s, "line ", 5)) {
306 while (*s == ' ' || *s == '\t')
308 if (*s == '"' && (t = strchr(s+1, '"')))
312 return; /* false alarm */
313 for (t = s; !isSPACE(*t); t++) ;
318 curcop->cop_filegv = gv_fetchfile(s);
320 curcop->cop_filegv = gv_fetchfile(origfilename);
322 curcop->cop_line = atoi(n)-1;
329 if (lex_formbrack && lex_brackets <= lex_formbrack) {
330 while (s < bufend && (*s == ' ' || *s == '\t'))
335 while (s < bufend && isSPACE(*s))
337 if (s < bufend && *s == '#') {
338 while (s < bufend && *s != '\n')
343 if (s < bufend || !rsfp || lex_state != LEX_NORMAL)
345 if ((s = filter_gets(linestr, rsfp)) == Nullch) {
346 if (minus_n || minus_p) {
347 sv_setpv(linestr,minus_p ? ";}continue{print" : "");
348 sv_catpv(linestr,";}");
349 minus_n = minus_p = 0;
352 sv_setpv(linestr,";");
353 oldoldbufptr = oldbufptr = bufptr = s = SvPVX(linestr);
354 bufend = SvPVX(linestr) + SvCUR(linestr);
355 if (preprocess && !in_eval)
356 (void)my_pclose(rsfp);
357 else if ((FILE*)rsfp == stdin)
364 oldoldbufptr = oldbufptr = bufptr = s;
365 bufend = bufptr + SvCUR(linestr);
367 if (perldb && curstash != debstash) {
368 SV *sv = NEWSV(85,0);
370 sv_upgrade(sv, SVt_PVMG);
371 sv_setsv(sv,linestr);
372 av_store(GvAV(curcop->cop_filegv),(I32)curcop->cop_line,sv);
383 if (oldoldbufptr != last_uni)
385 while (isSPACE(*last_uni))
387 for (s = last_uni; isALNUM(*s) || *s == '-'; s++) ;
388 if ((t = strchr(s, '(')) && t < bufptr)
392 warn("Warning: Use of \"%s\" without parens is ambiguous", last_uni);
399 #define UNI(f) return uni(f,s)
409 last_uni = oldbufptr;
420 #endif /* CRIPPLED_CC */
422 #define LOP(f,x) return lop(f,x,s)
434 last_lop = oldbufptr;
451 nexttype[nexttoke] = type;
453 if (lex_state != LEX_KNOWNEXT) {
454 lex_defer = lex_state;
456 lex_state = LEX_KNOWNEXT;
461 force_word(start,token,check_keyword,allow_pack,allow_tick)
462 register char *start;
471 start = skipspace(start);
474 (allow_pack && *s == ':') ||
475 (allow_tick && *s == '\'') )
477 s = scan_word(s, tokenbuf, allow_pack, &len);
478 if (check_keyword && keyword(tokenbuf, len))
480 if (token == METHOD) {
490 nextval[nexttoke].opval = (OP*)newSVOP(OP_CONST,0, newSVpv(tokenbuf,0));
491 nextval[nexttoke].opval->op_private |= OPpCONST_BARE;
503 OP* op = (OP*)newSVOP(OP_CONST, 0, newSVpv(s,0));
504 nextval[nexttoke].opval = op;
507 op->op_private = OPpCONST_ENTERED;
509 kind == '$' ? SVt_PV :
510 kind == '@' ? SVt_PVAV :
511 kind == '%' ? SVt_PVHV :
530 s = SvPV_force(sv, len);
534 while (s < send && *s != '\\')
541 if (s + 1 < send && (s[1] == '\\'))
542 s++; /* all that, just for this */
547 SvCUR_set(sv, d - SvPVX(sv));
555 register I32 op_type = yylval.ival;
557 if (op_type == OP_NULL) {
558 yylval.opval = lex_op;
562 if (op_type == OP_CONST || op_type == OP_READLINE) {
563 yylval.opval = (OP*)newSVOP(op_type, 0, q(lex_stuff));
570 SAVEINT(lex_brackets);
571 SAVEINT(lex_fakebrack);
572 SAVEINT(lex_casemods);
577 SAVEINT(curcop->cop_line);
580 SAVEPPTR(oldoldbufptr);
582 SAVEPPTR(lex_brackstack);
583 SAVEPPTR(lex_casestack);
588 bufend = bufptr = oldbufptr = oldoldbufptr = SvPVX(linestr);
589 bufend += SvCUR(linestr);
595 New(899, lex_brackstack, 120, char);
596 New(899, lex_casestack, 12, char);
597 SAVEFREEPV(lex_brackstack);
598 SAVEFREEPV(lex_casestack);
600 *lex_casestack = '\0';
602 lex_state = LEX_INTERPCONCAT;
603 curcop->cop_line = multi_start;
605 lex_inwhat = op_type;
606 if (op_type == OP_MATCH || op_type == OP_SUBST)
614 yylval.opval = lex_op;
627 yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv("",0));
631 if (lex_casemods) { /* oops, we've got some unbalanced parens */
632 lex_state = LEX_INTERPCASEMOD;
636 /* Is there a right-hand side to take care of? */
637 if (lex_repl && (lex_inwhat == OP_SUBST || lex_inwhat == OP_TRANS)) {
640 bufend = bufptr = oldbufptr = oldoldbufptr = SvPVX(linestr);
641 bufend += SvCUR(linestr);
647 *lex_casestack = '\0';
649 if (SvCOMPILED(lex_repl)) {
650 lex_state = LEX_INTERPNORMAL;
654 lex_state = LEX_INTERPCONCAT;
660 bufend = SvPVX(linestr);
661 bufend += SvCUR(linestr);
671 register char *send = bufend;
672 SV *sv = NEWSV(93, send - start);
673 register char *s = start;
674 register char *d = SvPVX(sv);
675 bool dorange = FALSE;
679 ? "\\.^$@AGZdDwWsSbB+*?|()-nrtfeaxc0123456789[{]} \t\n\r\f\v#"
680 : (lex_inwhat & OP_TRANS)
684 while (s < send || dorange) {
685 if (lex_inwhat == OP_TRANS) {
690 SvGROW(sv, SvLEN(sv) + 256);
694 for (i = (U8)*d; i <= max; i++)
699 else if (*s == '-' && s+1 < send && s != start) {
704 else if (*s == '(' && lex_inpat && s[1] == '?' && s[2] == '#') {
705 while (s < send && *s != ')')
708 else if (*s == '#' && lex_inpat &&
709 ((PMOP*)lex_inpat)->op_pmflags & PMf_EXTENDED) {
710 while (s+1 < send && *s != '\n')
713 else if (*s == '@' && s[1] && (isALNUM(s[1]) || strchr(":'{$", s[1])))
715 else if (*s == '$') {
716 if (!lex_inpat) /* not a regexp, so $ must be var */
718 if (s + 1 < send && !strchr(")| \n\t", s[1]))
719 break; /* in regexp, $ might be tail anchor */
721 if (*s == '\\' && s+1 < send) {
723 if (*s && strchr(leave, *s)) {
728 if (lex_inwhat == OP_SUBST && !lex_inpat &&
729 isDIGIT(*s) && *s != '0' && !isDIGIT(s[1]))
732 warn("\\%c better written as $%c", *s, *s);
736 if (lex_inwhat != OP_TRANS && *s && strchr("lLuUEQ", *s)) {
742 if (lex_inwhat == OP_TRANS) {
750 case '0': case '1': case '2': case '3':
751 case '4': case '5': case '6': case '7':
752 *d++ = scan_oct(s, 3, &len);
756 *d++ = scan_hex(++s, 2, &len);
794 SvCUR_set(sv, d - SvPVX(sv));
797 if (SvCUR(sv) + 5 < SvLEN(sv)) {
798 SvLEN_set(sv, SvCUR(sv) + 1);
799 Renew(SvPVX(sv), SvLEN(sv), char);
802 yylval.opval = (OP*)newSVOP(OP_CONST, 0, sv);
808 /* This is the one truly awful dwimmer necessary to conflate C and sed. */
815 if (*s == '-' && s[1] == '>' && (s[2] == '[' || s[2] == '{'))
817 if (*s != '{' && *s != '[')
822 /* In a pattern, so maybe we have {n,m}. */
839 /* On the other hand, maybe we have a character class */
842 if (*s == ']' || *s == '^')
845 int weight = 2; /* let's weigh the evidence */
847 unsigned char un_char = 0, last_un_char;
848 char *send = strchr(s,']');
851 if (!send) /* has to be an expression */
857 else if (isDIGIT(*s)) {
859 if (isDIGIT(s[1]) && s[2] == ']')
865 for (; s < send; s++) {
866 last_un_char = un_char;
867 un_char = (unsigned char)*s;
872 weight -= seen[un_char] * 10;
874 scan_ident(s,send,tmpbuf,FALSE);
875 if ((int)strlen(tmpbuf) > 1 && gv_fetchpv(tmpbuf,FALSE, SVt_PV))
880 else if (*s == '$' && s[1] &&
881 strchr("[#!%*<>()-=",s[1])) {
882 if (/*{*/ strchr("])} =",s[2]))
891 if (strchr("wds]",s[1]))
893 else if (seen['\''] || seen['"'])
895 else if (strchr("rnftbxcav",s[1]))
897 else if (isDIGIT(s[1])) {
899 while (s[1] && isDIGIT(s[1]))
909 if (strchr("aA01! ",last_un_char))
911 if (strchr("zZ79~",s[1]))
915 if (!isALNUM(last_un_char) && !strchr("$@&",last_un_char) &&
916 isALPHA(*s) && s[1] && isALPHA(s[1])) {
921 if (keyword(tmpbuf, d - tmpbuf))
924 if (un_char == last_un_char + 1)
926 weight -= seen[un_char];
931 if (weight >= 0) /* probably a character class */
939 intuit_method(start,gv)
943 char *s = start + (*start == '$');
954 s = scan_word(s, tmpbuf, TRUE, &len);
956 if (gv || last_lop_op == OP_PRINT || isUPPER(*tokenbuf))
961 return *s == '(' ? FUNCMETH : METHOD;
963 if (!keyword(tmpbuf, len)) {
964 indirgv = gv_fetchpv(tmpbuf,FALSE, SVt_PVCV);
965 if (indirgv && GvCV(indirgv))
967 /* filehandle or package name makes it a method */
968 if (!gv || GvIO(indirgv) || gv_stashpv(tmpbuf, FALSE)) {
970 nextval[nexttoke].opval =
971 (OP*)newSVOP(OP_CONST, 0,
973 nextval[nexttoke].opval->op_private =
978 return *s == '(' ? FUNCMETH : METHOD;
988 char *pdb = getenv("PERL5DB");
992 return "BEGIN { require 'perl5db.pl' }";
998 /* Encoded script support. filter_add() effectively inserts a
999 * 'pre-processing' function into the current source input stream.
1000 * Note that the filter function only applies to the current source file
1001 * (e.g., it will not affect files 'require'd or 'use'd by this one).
1003 * The datasv parameter (which may be NULL) can be used to pass
1004 * private data to this instance of the filter. The filter function
1005 * can recover the SV using the FILTER_DATA macro and use it to
1006 * store private buffers and state information.
1008 * The supplied datasv parameter is upgraded to a PVIO type
1009 * and the IoDIRP field is used to store the function pointer.
1010 * Note that IoTOP_NAME, IoFMT_NAME, IoBOTTOM_NAME, if set for
1011 * private use must be set using malloc'd pointers.
1013 static int filter_debug = 0;
1016 filter_add(funcp, datasv)
1020 if (!funcp){ /* temporary handy debugging hack to be deleted */
1021 filter_debug = atoi((char*)datasv);
1025 rsfp_filters = newAV();
1028 if (!SvUPGRADE(datasv, SVt_PVIO))
1029 die("Can't upgrade filter_add data to SVt_PVIO");
1030 IoDIRP(datasv) = (DIR*)funcp; /* stash funcp into spare field */
1032 warn("filter_add func %lx (%s)", funcp, SvPV(datasv,na));
1033 av_unshift(rsfp_filters, 1);
1034 av_store(rsfp_filters, 0, datasv) ;
1039 /* Delete most recently added instance of this filter function. */
1045 warn("filter_del func %lx", funcp);
1046 if (!rsfp_filters || AvFILL(rsfp_filters)<0)
1048 /* if filter is on top of stack (usual case) just pop it off */
1049 if (IoDIRP(FILTER_DATA(0)) == (void*)funcp){
1050 /* sv_free(av_pop(rsfp_filters)); */
1051 sv_free(av_shift(rsfp_filters));
1055 /* we need to search for the correct entry and clear it */
1056 die("filter_del can only delete in reverse order (currently)");
1060 /* Invoke the n'th filter function for the current rsfp. */
1062 filter_read(idx, buf_sv, maxlen)
1065 int maxlen; /* 0 = read one text line */
1072 if (idx > AvFILL(rsfp_filters)){ /* Any more filters? */
1073 /* Provide a default input filter to make life easy. */
1074 /* Note that we append to the line. This is handy. */
1076 warn("filter_read %d: from rsfp\n", idx);
1080 int old_len = SvCUR(buf_sv) ;
1082 /* ensure buf_sv is large enough */
1083 SvGROW(buf_sv, old_len + maxlen) ;
1084 if ((len = fread(SvPVX(buf_sv) + old_len, 1, maxlen, rsfp)) <= 0){
1086 return -1; /* error */
1088 return 0 ; /* end of file */
1090 SvCUR_set(buf_sv, old_len + len) ;
1093 if (sv_gets(buf_sv, rsfp, SvCUR(buf_sv)) == NULL) {
1095 return -1; /* error */
1097 return 0 ; /* end of file */
1100 return SvCUR(buf_sv);
1102 /* Skip this filter slot if filter has been deleted */
1103 if ( (datasv = FILTER_DATA(idx)) == &sv_undef){
1105 warn("filter_read %d: skipped (filter deleted)\n", idx);
1106 return FILTER_READ(idx+1, buf_sv, maxlen); /* recurse */
1108 /* Get function pointer hidden within datasv */
1109 funcp = (filter_t)IoDIRP(datasv);
1111 warn("filter_read %d: via function %lx (%s)\n",
1112 idx, funcp, SvPV(datasv,na));
1113 /* Call function. The function is expected to */
1114 /* call "FILTER_READ(idx+1, buf_sv)" first. */
1115 /* Return: <0:error, =0:eof, >0:not eof */
1116 return (*funcp)(idx, buf_sv, maxlen);
1126 SvCUR_set(sv, 0); /* start with empty line */
1127 if (FILTER_READ(0, sv, 0) > 0)
1128 return ( SvPVX(sv) ) ;
1133 return (sv_gets(sv, fp, 0)) ;
1139 static char* exp_name[] =
1140 { "OPERATOR", "TERM", "REF", "STATE", "BLOCK", "TERMBLOCK" };
1143 extern int yychar; /* last token */
1153 switch (lex_state) {
1155 case LEX_NORMAL: /* Some compilers will produce faster */
1156 case LEX_INTERPNORMAL: /* code if we comment these out. */
1162 yylval = nextval[nexttoke];
1164 lex_state = lex_defer;
1165 expect = lex_expect;
1166 lex_defer = LEX_NORMAL;
1168 return(nexttype[nexttoke]);
1170 case LEX_INTERPCASEMOD:
1172 if (bufptr != bufend && *bufptr != '\\')
1173 croak("panic: INTERPCASEMOD");
1175 if (bufptr == bufend || bufptr[1] == 'E') {
1178 oldmod = lex_casestack[--lex_casemods];
1179 lex_casestack[lex_casemods] = '\0';
1180 if (bufptr != bufend && strchr("LUQ", oldmod)) {
1182 lex_state = LEX_INTERPCONCAT;
1186 if (bufptr != bufend)
1188 lex_state = LEX_INTERPCONCAT;
1193 if (strnEQ(s, "L\\u", 3) || strnEQ(s, "U\\l", 3))
1194 tmp = *s, *s = s[2], s[2] = tmp; /* misordered... */
1195 if (strchr("LU", *s) &&
1196 (strchr(lex_casestack, 'L') || strchr(lex_casestack, 'U')))
1198 lex_casestack[--lex_casemods] = '\0';
1201 if (lex_casemods > 10) {
1202 char* newlb = (char*)realloc(lex_casestack, lex_casemods + 2);
1203 if (newlb != lex_casestack) {
1205 lex_casestack = newlb;
1208 lex_casestack[lex_casemods++] = *s;
1209 lex_casestack[lex_casemods] = '\0';
1210 lex_state = LEX_INTERPCONCAT;
1211 nextval[nexttoke].ival = 0;
1214 nextval[nexttoke].ival = OP_LCFIRST;
1216 nextval[nexttoke].ival = OP_UCFIRST;
1218 nextval[nexttoke].ival = OP_LC;
1220 nextval[nexttoke].ival = OP_UC;
1222 nextval[nexttoke].ival = OP_QUOTEMETA;
1224 croak("panic: yylex");
1236 case LEX_INTERPSTART:
1237 if (bufptr == bufend)
1238 return sublex_done();
1240 lex_dojoin = (*bufptr == '@');
1241 lex_state = LEX_INTERPNORMAL;
1243 nextval[nexttoke].ival = 0;
1245 force_ident("\"", '$');
1246 nextval[nexttoke].ival = 0;
1248 nextval[nexttoke].ival = 0;
1250 nextval[nexttoke].ival = OP_JOIN; /* emulate join($", ...) */
1261 case LEX_INTERPENDMAYBE:
1262 if (intuit_more(bufptr)) {
1263 lex_state = LEX_INTERPNORMAL; /* false alarm, more expr */
1271 lex_state = LEX_INTERPCONCAT;
1275 case LEX_INTERPCONCAT:
1278 croak("panic: INTERPCONCAT");
1280 if (bufptr == bufend)
1281 return sublex_done();
1283 if (SvIVX(linestr) == '\'') {
1284 SV *sv = newSVsv(linestr);
1287 yylval.opval = (OP*)newSVOP(OP_CONST, 0, sv);
1291 s = scan_const(bufptr);
1293 lex_state = LEX_INTERPCASEMOD;
1295 lex_state = LEX_INTERPSTART;
1299 nextval[nexttoke] = yylval;
1312 lex_state = LEX_NORMAL;
1313 s = scan_formline(bufptr);
1320 oldoldbufptr = oldbufptr;
1323 fprintf(stderr,"### Tokener expecting %s at %s\n", exp_name[expect], s);
1329 warn("Unrecognized character \\%03o ignored", *s++ & 255);
1333 goto fake_eof; /* emulate EOF on ^D or ^Z */
1337 yyerror("Missing right bracket");
1341 goto retry; /* ignore stray nulls */
1344 if (!in_eval && !preambled) {
1346 sv_setpv(linestr,incl_perldb());
1348 sv_catpv(linestr,";");
1350 while(AvFILL(preambleav) >= 0) {
1351 SV *tmpsv = av_shift(preambleav);
1352 sv_catsv(linestr, tmpsv);
1353 sv_catpv(linestr, ";");
1356 sv_free((SV*)preambleav);
1359 if (minus_n || minus_p) {
1360 sv_catpv(linestr, "LINE: while (<>) {");
1362 sv_catpv(linestr,"chomp;");
1366 if ( splitstr[0] == '/' ||
1367 splitstr[0] == '\'' ||
1368 splitstr[0] == '"' )
1369 sprintf( tmpbuf1, "@F=split(%s);", splitstr );
1371 sprintf( tmpbuf1, "@F=split('%s');", splitstr );
1372 sv_catpv(linestr,tmpbuf1);
1375 sv_catpv(linestr,"@F=split(' ');");
1378 sv_catpv(linestr, "\n");
1379 oldoldbufptr = oldbufptr = s = SvPVX(linestr);
1380 bufend = SvPVX(linestr) + SvCUR(linestr);
1381 if (perldb && curstash != debstash) {
1382 SV *sv = NEWSV(85,0);
1384 sv_upgrade(sv, SVt_PVMG);
1385 sv_setsv(sv,linestr);
1386 av_store(GvAV(curcop->cop_filegv),(I32)curcop->cop_line,sv);
1391 if ((s = filter_gets(linestr, rsfp)) == Nullch) {
1394 if (preprocess && !in_eval)
1395 (void)my_pclose(rsfp);
1396 else if ((FILE*)rsfp == stdin)
1402 if (!in_eval && (minus_n || minus_p)) {
1403 sv_setpv(linestr,minus_p ? ";}continue{print" : "");
1404 sv_catpv(linestr,";}");
1405 oldoldbufptr = oldbufptr = s = SvPVX(linestr);
1406 bufend = SvPVX(linestr) + SvCUR(linestr);
1407 minus_n = minus_p = 0;
1410 oldoldbufptr = oldbufptr = s = SvPVX(linestr);
1411 sv_setpv(linestr,"");
1412 TOKEN(';'); /* not infinite loop because rsfp is NULL now */
1415 if (*s == '#' && s[1] == '!' && instr(s,"perl"))
1418 /* Incest with pod. */
1419 if (*s == '=' && strnEQ(s, "=cut", 4)) {
1420 sv_setpv(linestr, "");
1421 oldoldbufptr = oldbufptr = s = SvPVX(linestr);
1422 bufend = SvPVX(linestr) + SvCUR(linestr);
1427 } while (doextract);
1428 oldoldbufptr = oldbufptr = bufptr = s;
1429 if (perldb && curstash != debstash) {
1430 SV *sv = NEWSV(85,0);
1432 sv_upgrade(sv, SVt_PVMG);
1433 sv_setsv(sv,linestr);
1434 av_store(GvAV(curcop->cop_filegv),(I32)curcop->cop_line,sv);
1436 bufend = SvPVX(linestr) + SvCUR(linestr);
1437 if (curcop->cop_line == 1) {
1438 while (s < bufend && isSPACE(*s))
1440 if (*s == ':' && s[1] != ':') /* for csh execing sh scripts */
1442 if (!in_eval && *s == '#' && s[1] == '!') {
1443 d = instr(s,"perl -");
1445 d = instr(s,"perl");
1448 !instr(s,"indir") &&
1449 instr(origargv[0],"perl"))
1458 while (s < bufend && !isSPACE(*s))
1461 while (s < bufend && isSPACE(*s))
1464 Newz(899,newargv,origargc+3,char*);
1466 while (s < bufend && !isSPACE(*s))
1469 Copy(origargv+1, newargv+2, origargc+1, char*);
1475 croak("Can't exec %s", cmd);
1478 int oldpdb = perldb;
1482 while (*d && !isSPACE(*d)) d++;
1483 while (*d == ' ') d++;
1486 while (d = moreswitches(d)) ;
1487 if (perldb && !oldpdb ||
1488 ( minus_n || minus_p ) && !(oldn || oldp) )
1489 /* if we have already added "LINE: while (<>) {",
1490 we must not do it again */
1492 sv_setpv(linestr, "");
1493 oldoldbufptr = oldbufptr = s = SvPVX(linestr);
1494 bufend = SvPVX(linestr) + SvCUR(linestr);
1497 (void)gv_fetchfile(origfilename);
1504 if (lex_formbrack && lex_brackets <= lex_formbrack) {
1506 lex_state = LEX_FORMLINE;
1510 case ' ': case '\t': case '\f': case '\r': case 013:
1515 if (lex_state != LEX_NORMAL || (in_eval && !rsfp)) {
1517 while (s < d && *s != '\n')
1522 if (lex_formbrack && lex_brackets <= lex_formbrack) {
1524 lex_state = LEX_FORMLINE;
1534 if (s[1] && isALPHA(s[1]) && !isALNUM(s[2])) {
1539 while (s < bufend && (*s == ' ' || *s == '\t'))
1542 if (strnEQ(s,"=>",2)) {
1544 warn("Ambiguous use of -%c => resolved to \"-%c\" =>",
1546 s = force_word(bufptr,WORD,FALSE,FALSE,FALSE);
1547 OPERATOR('-'); /* unary minus */
1549 last_uni = oldbufptr;
1550 last_lop_op = OP_FTEREAD; /* good enough */
1552 case 'r': FTST(OP_FTEREAD);
1553 case 'w': FTST(OP_FTEWRITE);
1554 case 'x': FTST(OP_FTEEXEC);
1555 case 'o': FTST(OP_FTEOWNED);
1556 case 'R': FTST(OP_FTRREAD);
1557 case 'W': FTST(OP_FTRWRITE);
1558 case 'X': FTST(OP_FTREXEC);
1559 case 'O': FTST(OP_FTROWNED);
1560 case 'e': FTST(OP_FTIS);
1561 case 'z': FTST(OP_FTZERO);
1562 case 's': FTST(OP_FTSIZE);
1563 case 'f': FTST(OP_FTFILE);
1564 case 'd': FTST(OP_FTDIR);
1565 case 'l': FTST(OP_FTLINK);
1566 case 'p': FTST(OP_FTPIPE);
1567 case 'S': FTST(OP_FTSOCK);
1568 case 'u': FTST(OP_FTSUID);
1569 case 'g': FTST(OP_FTSGID);
1570 case 'k': FTST(OP_FTSVTX);
1571 case 'b': FTST(OP_FTBLK);
1572 case 'c': FTST(OP_FTCHR);
1573 case 't': FTST(OP_FTTTY);
1574 case 'T': FTST(OP_FTTEXT);
1575 case 'B': FTST(OP_FTBINARY);
1576 case 'M': gv_fetchpv("\024",TRUE, SVt_PV); FTST(OP_FTMTIME);
1577 case 'A': gv_fetchpv("\024",TRUE, SVt_PV); FTST(OP_FTATIME);
1578 case 'C': gv_fetchpv("\024",TRUE, SVt_PV); FTST(OP_FTCTIME);
1580 croak("Unrecognized file test: -%c", tmp);
1587 if (expect == XOPERATOR)
1592 else if (*s == '>') {
1595 if (isIDFIRST(*s)) {
1596 s = force_word(s,METHOD,FALSE,TRUE,FALSE);
1604 if (expect == XOPERATOR)
1607 if (isSPACE(*s) || !isSPACE(*bufptr))
1609 OPERATOR('-'); /* unary minus */
1616 if (expect == XOPERATOR)
1621 if (expect == XOPERATOR)
1624 if (isSPACE(*s) || !isSPACE(*bufptr))
1630 if (expect != XOPERATOR) {
1631 s = scan_ident(s, bufend, tokenbuf, TRUE);
1633 force_ident(tokenbuf, '*');
1646 if (expect != XOPERATOR) {
1647 s = scan_ident(s, bufend, tokenbuf + 1, TRUE);
1652 if (strchr(tokenbuf,':'))
1653 croak(no_myglob,tokenbuf);
1654 nextval[nexttoke].opval = newOP(OP_PADANY, 0);
1655 nextval[nexttoke].opval->op_targ = pad_allocmy(tokenbuf);
1656 force_next(PRIVATEREF);
1659 if (!strchr(tokenbuf,':')) {
1660 if (tmp = pad_findmy(tokenbuf)) {
1661 nextval[nexttoke].opval = newOP(OP_PADANY, 0);
1662 nextval[nexttoke].opval->op_targ = tmp;
1663 force_next(PRIVATEREF);
1667 force_ident(tokenbuf + 1, *tokenbuf);
1695 if (last_lop == oldoldbufptr || last_uni == oldoldbufptr)
1696 oldbufptr = oldoldbufptr; /* allow print(STDOUT 123) */
1701 if (curcop->cop_line < copline)
1702 copline = curcop->cop_line;
1713 if (lex_brackets <= 0)
1714 yyerror("Unmatched right bracket");
1717 if (lex_state == LEX_INTERPNORMAL) {
1718 if (lex_brackets == 0) {
1719 if (*s != '[' && *s != '{' && (*s != '-' || s[1] != '>'))
1720 lex_state = LEX_INTERPEND;
1727 if (lex_brackets > 100) {
1728 char* newlb = (char*)realloc(lex_brackstack, lex_brackets + 1);
1729 if (newlb != lex_brackstack) {
1731 lex_brackstack = newlb;
1736 if (lex_formbrack) {
1740 if (oldoldbufptr == last_lop)
1741 lex_brackstack[lex_brackets++] = XTERM;
1743 lex_brackstack[lex_brackets++] = XOPERATOR;
1744 OPERATOR(HASHBRACK);
1747 while (s < bufend && (*s == ' ' || *s == '\t'))
1749 if (s < bufend && isALPHA(*s)) {
1750 d = scan_word(s, tokenbuf, FALSE, &len);
1751 while (d < bufend && (*d == ' ' || *d == '\t'))
1755 (keyword(tokenbuf, len) ||
1756 perl_get_cv(tokenbuf, FALSE) ))
1757 warn("Ambiguous use of {%s} resolved to {\"%s\"}",
1758 tokenbuf, tokenbuf);
1759 s = force_word(s,WORD,FALSE,TRUE,FALSE);
1764 lex_brackstack[lex_brackets++] = XSTATE;
1768 lex_brackstack[lex_brackets++] = XOPERATOR;
1773 if (oldoldbufptr == last_lop)
1774 lex_brackstack[lex_brackets++] = XTERM;
1776 lex_brackstack[lex_brackets++] = XOPERATOR;
1779 OPERATOR(HASHBRACK);
1781 for (t = s; t < bufend && isALNUM(*t); t++) ;
1783 else if (*s == '\'' || *s == '"') {
1790 while (t < bufend && isSPACE(*t))
1792 if ((*t == ',' && !isLOWER(*s)) || (*t == '=' && t[1] == '>'))
1793 OPERATOR(HASHBRACK);
1797 lex_brackstack[lex_brackets-1] = XSTATE;
1803 yylval.ival = curcop->cop_line;
1804 if (isSPACE(*s) || *s == '#')
1805 copline = NOLINE; /* invalidate current command line number */
1810 if (lex_brackets <= 0)
1811 yyerror("Unmatched right bracket");
1813 expect = (expectation)lex_brackstack[--lex_brackets];
1814 if (lex_brackets < lex_formbrack)
1816 if (lex_state == LEX_INTERPNORMAL) {
1817 if (lex_brackets == 0) {
1818 if (lex_fakebrack) {
1819 lex_state = LEX_INTERPEND;
1821 return yylex(); /* ignore fake brackets */
1823 if (*s != '[' && *s != '{' && (*s != '-' || s[1] != '>'))
1824 lex_state = LEX_INTERPEND;
1827 if (lex_brackets < lex_fakebrack) {
1830 return yylex(); /* ignore fake brackets */
1840 if (expect == XOPERATOR) {
1841 if (dowarn && isALPHA(*s) && bufptr == SvPVX(linestr)) {
1849 s = scan_ident(s-1, bufend, tokenbuf, TRUE);
1852 force_ident(tokenbuf, '&');
1856 yylval.ival = (OPpENTERSUB_AMPER<<8);
1875 if (dowarn && tmp && isSPACE(*s) && strchr("+-*/%.^&|<",tmp))
1876 warn("Reversed %c= operator",tmp);
1878 if (expect == XSTATE && isALPHA(tmp) &&
1879 (s == SvPVX(linestr)+1 || s[-2] == '\n') )
1881 if (in_eval && !rsfp) {
1886 if (strnEQ(s,"=cut",4)) {
1903 if (lex_brackets < lex_formbrack) {
1905 for (t = s; *t == ' ' || *t == '\t'; t++) ;
1906 if (*t == '\n' || *t == '#') {
1924 if (expect != XOPERATOR) {
1925 if (s[1] != '<' && !strchr(s,'>'))
1928 s = scan_heredoc(s);
1930 s = scan_inputsymbol(s);
1931 TERM(sublex_start());
1936 SHop(OP_LEFT_SHIFT);
1950 SHop(OP_RIGHT_SHIFT);
1957 if (s[1] == '#' && (isALPHA(s[2]) || strchr("_{$:", s[2]))) {
1958 s = scan_ident(s+1, bufend, tokenbuf+1, FALSE);
1959 if (expect == XOPERATOR) {
1960 if (lex_formbrack && lex_brackets == lex_formbrack) {
1963 return ','; /* grandfather non-comma-format format */
1966 no_op("Array length",s);
1968 else if (!tokenbuf[1])
1970 if (!strchr(tokenbuf+1,':')) {
1972 if (tmp = pad_findmy(tokenbuf)) {
1973 nextval[nexttoke].opval = newOP(OP_PADANY, 0);
1974 nextval[nexttoke].opval->op_targ = tmp;
1976 force_next(PRIVATEREF);
1981 force_ident(tokenbuf+1, *tokenbuf);
1984 s = scan_ident(s, bufend, tokenbuf+1, FALSE);
1985 if (expect == XOPERATOR) {
1986 if (lex_formbrack && lex_brackets == lex_formbrack) {
1989 return ','; /* grandfather non-comma-format format */
1995 expectation oldexpect = expect;
1997 /* This kludge not intended to be bulletproof. */
1998 if (tokenbuf[1] == '[' && !tokenbuf[2]) {
1999 yylval.opval = newSVOP(OP_CONST, 0,
2000 newSViv((IV)compiling.cop_arybase));
2001 yylval.opval->op_private = OPpCONST_ARYBASE;
2007 if (*s == '[' && oldexpect != XREF) {
2008 for (t = s+1; isSPACE(*t) || isALNUM(*t) || *t == '$'; t++) ;
2010 bufptr = skipspace(bufptr);
2011 while (t < bufend && *t != ']') t++;
2012 warn("Multidimensional syntax %.*s not supported",
2013 t-bufptr+1, bufptr);
2016 if (*s == '{' && strEQ(tokenbuf, "$SIG") &&
2017 (t = strchr(s,'}')) && (t = strchr(t,'='))) {
2020 for (t++; isSPACE(*t); t++) ;
2021 if (isIDFIRST(*t)) {
2022 t = scan_word(t, tmpbuf, TRUE, &len);
2023 if (*t != '(' && perl_get_cv(tmpbuf, FALSE))
2024 warn("You need to quote \"%s\"", tmpbuf);
2029 if (lex_state == LEX_NORMAL && isSPACE(*s)) {
2030 bool islop = (last_lop == oldoldbufptr);
2032 if (!islop || last_lop_op == OP_GREPSTART)
2034 else if (strchr("$@\"'`q", *s))
2035 expect = XTERM; /* e.g. print $fh "foo" */
2036 else if (strchr("&*<%", *s) && isIDFIRST(s[1]))
2037 expect = XTERM; /* e.g. print $fh &sub */
2038 else if (isDIGIT(*s))
2039 expect = XTERM; /* e.g. print $fh 3 */
2040 else if (*s == '.' && isDIGIT(s[1]))
2041 expect = XTERM; /* e.g. print $fh .3 */
2042 else if (strchr("/?-+", *s) && !isSPACE(s[1]))
2043 expect = XTERM; /* e.g. print $fh -1 */
2044 else if (*s == '<' && s[1] == '<' && !isSPACE(s[2]))
2045 expect = XTERM; /* print $fh <<"EOF" */
2048 if (strchr(tokenbuf,':'))
2049 croak(no_myglob,tokenbuf);
2050 nextval[nexttoke].opval = newOP(OP_PADANY, 0);
2051 nextval[nexttoke].opval->op_targ = pad_allocmy(tokenbuf);
2052 force_next(PRIVATEREF);
2054 else if (!strchr(tokenbuf,':')) {
2055 if (oldexpect != XREF || oldoldbufptr == last_lop) {
2056 if (intuit_more(s)) {
2063 if (tmp = pad_findmy(tokenbuf)) {
2064 if (!tokenbuf[2] && *tokenbuf =='$' &&
2065 tokenbuf[1] <= 'b' && tokenbuf[1] >= 'a')
2067 for (d = in_eval ? oldoldbufptr : SvPVX(linestr);
2068 d < bufend && *d != '\n';
2071 if (strnEQ(d,"<=>",3) || strnEQ(d,"cmp",3)) {
2072 croak("Can't use \"my %s\" in sort comparison",
2077 nextval[nexttoke].opval = newOP(OP_PADANY, 0);
2078 nextval[nexttoke].opval->op_targ = tmp;
2079 force_next(PRIVATEREF);
2082 force_ident(tokenbuf+1, *tokenbuf);
2085 force_ident(tokenbuf+1, *tokenbuf);
2089 yyerror("Final $ should be \\$ or $name");
2095 s = scan_ident(s, bufend, tokenbuf+1, FALSE);
2096 if (expect == XOPERATOR)
2104 if (strchr(tokenbuf,':'))
2105 croak(no_myglob,tokenbuf);
2106 nextval[nexttoke].opval = newOP(OP_PADANY, 0);
2107 nextval[nexttoke].opval->op_targ = pad_allocmy(tokenbuf);
2108 force_next(PRIVATEREF);
2111 else if (!strchr(tokenbuf,':')) {
2112 if (intuit_more(s)) {
2116 if (tmp = pad_findmy(tokenbuf)) {
2117 nextval[nexttoke].opval = newOP(OP_PADANY, 0);
2118 nextval[nexttoke].opval->op_targ = tmp;
2119 force_next(PRIVATEREF);
2124 /* Force them to make up their mind on "@foo". */
2125 if (lex_state != LEX_NORMAL && !lex_brackets &&
2126 ( !(gv = gv_fetchpv(tokenbuf+1, FALSE, SVt_PVAV)) ||
2132 sprintf(tmpbuf, "Literal @%s now requires backslash",tokenbuf+1);
2136 /* Warn about @ where they meant $. */
2138 if (*s == '[' || *s == '{') {
2140 while (*t && (isALNUM(*t) || strchr(" \t$#+-'\"", *t)))
2142 if (*t == '}' || *t == ']') {
2144 bufptr = skipspace(bufptr);
2145 warn("Scalar value %.*s better written as $%.*s",
2146 t-bufptr, bufptr, t-bufptr-1, bufptr+1);
2150 force_ident(tokenbuf+1, *tokenbuf);
2154 yyerror("Final @ should be \\@ or @name");
2159 case '/': /* may either be division or pattern */
2160 case '?': /* may either be conditional or pattern */
2161 if (expect != XOPERATOR) {
2164 TERM(sublex_start());
2172 if (lex_formbrack && lex_brackets == lex_formbrack && s[1] == '\n' &&
2173 (s == SvPVX(linestr) || s[-1] == '\n') ) {
2178 if (expect == XOPERATOR || !isDIGIT(s[1])) {
2184 yylval.ival = OPf_SPECIAL;
2190 if (expect != XOPERATOR)
2195 case '0': case '1': case '2': case '3': case '4':
2196 case '5': case '6': case '7': case '8': case '9':
2198 if (expect == XOPERATOR)
2204 if (expect == XOPERATOR) {
2205 if (lex_formbrack && lex_brackets == lex_formbrack) {
2208 return ','; /* grandfather non-comma-format format */
2214 missingterm((char*)0);
2215 yylval.ival = OP_CONST;
2216 TERM(sublex_start());
2220 if (expect == XOPERATOR) {
2221 if (lex_formbrack && lex_brackets == lex_formbrack) {
2224 return ','; /* grandfather non-comma-format format */
2230 missingterm((char*)0);
2231 yylval.ival = OP_CONST;
2232 for (d = SvPV(lex_stuff, len); len; len--, d++) {
2233 if (*d == '$' || *d == '@' || *d == '\\') {
2234 yylval.ival = OP_STRINGIFY;
2238 TERM(sublex_start());
2242 if (expect == XOPERATOR)
2243 no_op("Backticks",s);
2245 missingterm((char*)0);
2246 yylval.ival = OP_BACKTICK;
2248 TERM(sublex_start());
2252 if (dowarn && lex_inwhat && isDIGIT(*s))
2253 warn("Can't use \\%c to mean $%c in expression", *s, *s);
2254 if (expect == XOPERATOR)
2255 no_op("Backslash",s);
2259 if (isDIGIT(s[1]) && expect == XOPERATOR) {
2295 s = scan_word(s, tokenbuf, FALSE, &len);
2297 if (*s == ':' && s[1] == ':' && strNE(tokenbuf, "CORE"))
2300 tmp = keyword(tokenbuf, len);
2302 /* Is this a word before a => operator? */
2304 while (d < bufend && (*d == ' ' || *d == '\t'))
2305 d++; /* no comments skipped here, or s### is misparsed */
2306 if (strnEQ(d,"=>",2)) {
2308 if (dowarn && (tmp || perl_get_cv(tokenbuf, FALSE)))
2309 warn("Ambiguous use of %s => resolved to \"%s\" =>",
2310 tokenbuf, tokenbuf);
2311 yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv(tokenbuf,0));
2312 yylval.opval->op_private = OPpCONST_BARE;
2316 if (tmp < 0) { /* second-class keyword? */
2318 if (expect != XOPERATOR &&
2319 (*s != ':' || s[1] != ':') &&
2320 (gv = gv_fetchpv(tokenbuf, FALSE, SVt_PVCV)) &&
2332 default: /* not a keyword */
2335 char lastchar = (bufptr == oldoldbufptr ? 0 : bufptr[-1]);
2337 /* Get the rest if it looks like a package qualifier */
2339 if (*s == '\'' || *s == ':' && s[1] == ':') {
2340 s = scan_word(s, tokenbuf + len, TRUE, &len);
2342 croak("Bad name after %s::", tokenbuf);
2345 /* Do special processing at start of statement. */
2347 if (expect == XSTATE) {
2348 while (isSPACE(*s)) s++;
2349 if (*s == ':') { /* It's a label. */
2350 yylval.pval = savepv(tokenbuf);
2356 else if (expect == XOPERATOR) {
2357 if (bufptr == SvPVX(linestr)) {
2363 no_op("Bare word",s);
2366 /* Look for a subroutine with this name in current package. */
2368 gv = gv_fetchpv(tokenbuf,FALSE, SVt_PVCV);
2370 /* Presume this is going to be a bareword of some sort. */
2373 yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv(tokenbuf,0));
2374 yylval.opval->op_private = OPpCONST_BARE;
2376 /* See if it's the indirect object for a list operator. */
2379 oldoldbufptr < bufptr &&
2380 (oldoldbufptr == last_lop || oldoldbufptr == last_uni) &&
2381 /* NO SKIPSPACE BEFORE HERE! */
2383 (opargs[last_lop_op] >> OASHIFT & 7) == OA_FILEREF) )
2385 bool immediate_paren = *s == '(';
2387 /* (Now we can afford to cross potential line boundary.) */
2390 /* Two barewords in a row may indicate method call. */
2392 if ((isALPHA(*s) || *s == '$') && (tmp=intuit_method(s,gv)))
2395 /* If not a declared subroutine, it's an indirect object. */
2396 /* (But it's an indir obj regardless for sort.) */
2398 if ((last_lop_op == OP_SORT ||
2399 (!immediate_paren && (!gv || !GvCV(gv))) ) &&
2400 (last_lop_op != OP_MAPSTART && last_lop_op != OP_GREPSTART)){
2401 expect = (last_lop == oldoldbufptr) ? XTERM : XOPERATOR;
2406 /* If followed by a paren, it's certainly a subroutine. */
2412 nextval[nexttoke].opval = yylval.opval;
2419 /* If followed by var or block, call it a method (unless sub) */
2421 if ((*s == '$' || *s == '{') && (!gv || !GvCV(gv))) {
2422 last_lop = oldbufptr;
2423 last_lop_op = OP_METHOD;
2427 /* If followed by a bareword, see if it looks like indir obj. */
2429 if ((isALPHA(*s) || *s == '$') && (tmp = intuit_method(s,gv)))
2432 /* Not a method, so call it a subroutine (if defined) */
2434 if (gv && GvCV(gv)) {
2437 nextval[nexttoke].opval = yylval.opval;
2443 if (lastchar == '-')
2444 warn("Ambiguous use of -%s resolved as -&%s()",
2445 tokenbuf, tokenbuf);
2446 last_lop = oldbufptr;
2447 last_lop_op = OP_ENTERSUB;
2448 /* Resolve to GV now. */
2449 op_free(yylval.opval);
2450 yylval.opval = newCVREF(0, newGVOP(OP_GV, 0, gv));
2451 /* Is there a prototype? */
2454 char *proto = SvPV((SV*)cv, len);
2457 if (strEQ(proto, "$"))
2459 if (*proto == '&' && *s == '{') {
2460 sv_setpv(subname,"__ANON__");
2464 nextval[nexttoke].opval = yylval.opval;
2470 if (hints & HINT_STRICT_SUBS &&
2473 last_lop_op != OP_ACCEPT &&
2474 last_lop_op != OP_PIPE_OP &&
2475 last_lop_op != OP_SOCKPAIR)
2478 "Bareword \"%s\" not allowed while \"strict subs\" in use",
2483 /* Call it a bare word */
2487 if (lastchar != '-') {
2488 for (d = tokenbuf; *d && isLOWER(*d); d++) ;
2490 warn(warn_reserved, tokenbuf);
2493 if (lastchar && strchr("*%&", lastchar)) {
2494 warn("Operator or semicolon missing before %c%s",
2495 lastchar, tokenbuf);
2496 warn("Ambiguous use of %c resolved as operator %c",
2497 lastchar, lastchar);
2503 case KEY___FILE__: {
2504 if (tokenbuf[2] == 'L')
2505 (void)sprintf(tokenbuf,"%ld",(long)curcop->cop_line);
2507 strcpy(tokenbuf, SvPVX(GvSV(curcop->cop_filegv)));
2508 yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv(tokenbuf,0));
2517 if (rsfp && (!in_eval || tokenbuf[2] == 'D')) {
2519 char *pname = "main";
2520 if (tokenbuf[2] == 'D')
2521 pname = HvNAME(curstash ? curstash : defstash);
2522 sprintf(dname,"%s::DATA", pname);
2523 gv = gv_fetchpv(dname,TRUE, SVt_PVIO);
2526 GvIOp(gv) = newIO();
2527 IoIFP(GvIOp(gv)) = rsfp;
2528 #if defined(HAS_FCNTL) && defined(F_SETFD)
2530 int fd = fileno(rsfp);
2531 fcntl(fd,F_SETFD,fd >= 3);
2535 IoTYPE(GvIOp(gv)) = '|';
2536 else if ((FILE*)rsfp == stdin)
2537 IoTYPE(GvIOp(gv)) = '-';
2539 IoTYPE(GvIOp(gv)) = '<';
2549 if (expect == XSTATE) {
2556 if (*s == ':' && s[1] == ':') {
2559 s = scan_word(s, tokenbuf, FALSE, &len);
2560 tmp = keyword(tokenbuf, len);
2574 LOP(OP_ACCEPT,XTERM);
2580 LOP(OP_ATAN2,XTERM);
2589 LOP(OP_BLESS,XTERM);
2598 (void)gv_fetchpv("ENV",TRUE, SVt_PVHV); /* may use HOME */
2618 LOP(OP_CRYPT,XTERM);
2622 for (d = s; d < bufend && (isSPACE(*d) || *d == '('); d++) ;
2623 if (*d != '0' && isDIGIT(*d))
2624 yywarn("chmod: mode argument is missing initial 0");
2626 LOP(OP_CHMOD,XTERM);
2629 LOP(OP_CHOWN,XTERM);
2632 LOP(OP_CONNECT,XTERM);
2648 s = force_word(s,WORD,FALSE,TRUE,FALSE);
2652 hints |= HINT_BLOCK_SCOPE;
2662 gv_fetchpv("AnyDBM_File::ISA", GV_ADDMULTI, SVt_PVAV);
2663 LOP(OP_DBMOPEN,XTERM);
2669 s = force_word(s,WORD,TRUE,FALSE,FALSE);
2676 yylval.ival = curcop->cop_line;
2690 expect = (*s == '{') ? XTERMBLOCK : XTERM;
2691 UNIBRACK(OP_ENTEREVAL);
2706 case KEY_endhostent:
2712 case KEY_endservent:
2715 case KEY_endprotoent:
2726 yylval.ival = curcop->cop_line;
2727 while (s < bufend && isSPACE(*s))
2730 croak("Missing $ on loop variable");
2734 LOP(OP_FORMLINE,XTERM);
2740 LOP(OP_FCNTL,XTERM);
2746 LOP(OP_FLOCK,XTERM);
2755 LOP(OP_GREPSTART, *s == '(' ? XTERM : XREF);
2758 s = force_word(s,WORD,TRUE,FALSE,FALSE);
2773 case KEY_getpriority:
2774 LOP(OP_GETPRIORITY,XTERM);
2776 case KEY_getprotobyname:
2779 case KEY_getprotobynumber:
2780 LOP(OP_GPBYNUMBER,XTERM);
2782 case KEY_getprotoent:
2794 case KEY_getpeername:
2795 UNI(OP_GETPEERNAME);
2797 case KEY_gethostbyname:
2800 case KEY_gethostbyaddr:
2801 LOP(OP_GHBYADDR,XTERM);
2803 case KEY_gethostent:
2806 case KEY_getnetbyname:
2809 case KEY_getnetbyaddr:
2810 LOP(OP_GNBYADDR,XTERM);
2815 case KEY_getservbyname:
2816 LOP(OP_GSBYNAME,XTERM);
2818 case KEY_getservbyport:
2819 LOP(OP_GSBYPORT,XTERM);
2821 case KEY_getservent:
2824 case KEY_getsockname:
2825 UNI(OP_GETSOCKNAME);
2827 case KEY_getsockopt:
2828 LOP(OP_GSOCKOPT,XTERM);
2850 yylval.ival = curcop->cop_line;
2854 LOP(OP_INDEX,XTERM);
2860 LOP(OP_IOCTL,XTERM);
2872 s = force_word(s,WORD,TRUE,FALSE,FALSE);
2904 LOP(OP_LISTEN,XTERM);
2911 TERM(sublex_start());
2914 LOP(OP_MAPSTART,XREF);
2917 LOP(OP_MKDIR,XTERM);
2920 LOP(OP_MSGCTL,XTERM);
2923 LOP(OP_MSGGET,XTERM);
2926 LOP(OP_MSGRCV,XTERM);
2929 LOP(OP_MSGSND,XTERM);
2937 s = force_word(s,WORD,TRUE,FALSE,FALSE);
2944 if (expect != XSTATE)
2945 yyerror("\"no\" not allowed in expression");
2946 s = force_word(s,WORD,FALSE,TRUE,FALSE);
2955 if (isIDFIRST(*s)) {
2957 for (d = s; isALNUM(*d); d++) ;
2959 if (strchr("|&*+-=!?:.", *t))
2960 warn("Precedence problem: open %.*s should be open(%.*s)",
2966 yylval.ival = OP_OR;
2976 LOP(OP_OPEN_DIR,XTERM);
2979 checkcomma(s,tokenbuf,"filehandle");
2983 checkcomma(s,tokenbuf,"filehandle");
3002 s = force_word(s,WORD,FALSE,TRUE,FALSE);
3006 LOP(OP_PIPE_OP,XTERM);
3011 missingterm((char*)0);
3012 yylval.ival = OP_CONST;
3013 TERM(sublex_start());
3021 missingterm((char*)0);
3023 nextval[nexttoke].opval = (OP*)newSVOP(OP_CONST, 0, q(lex_stuff));
3027 nextval[nexttoke].opval = (OP*)newSVOP(OP_CONST, 0, newSVpv(" ",1));
3030 yylval.ival = OP_SPLIT;
3034 last_lop = oldbufptr;
3035 last_lop_op = OP_SPLIT;
3041 missingterm((char*)0);
3042 yylval.ival = OP_STRINGIFY;
3043 if (SvIVX(lex_stuff) == '\'')
3044 SvIVX(lex_stuff) = 0; /* qq'$foo' should intepolate */
3045 TERM(sublex_start());
3050 missingterm((char*)0);
3051 yylval.ival = OP_BACKTICK;
3053 TERM(sublex_start());
3060 s = force_word(s,WORD,TRUE,TRUE,FALSE);
3061 if (isIDFIRST(*tokenbuf))
3062 gv_stashpv(tokenbuf, TRUE);
3064 yyerror("<> should be quotes");
3071 s = force_word(s,WORD,TRUE,FALSE,FALSE);
3075 LOP(OP_RENAME,XTERM);
3084 LOP(OP_RINDEX,XTERM);
3107 LOP(OP_REVERSE,XTERM);
3118 TERM(sublex_start());
3120 TOKEN(1); /* force error */
3129 LOP(OP_SELECT,XTERM);
3135 LOP(OP_SEMCTL,XTERM);
3138 LOP(OP_SEMGET,XTERM);
3141 LOP(OP_SEMOP,XTERM);
3147 LOP(OP_SETPGRP,XTERM);
3149 case KEY_setpriority:
3150 LOP(OP_SETPRIORITY,XTERM);
3152 case KEY_sethostent:
3158 case KEY_setservent:
3161 case KEY_setprotoent:
3171 LOP(OP_SEEKDIR,XTERM);
3173 case KEY_setsockopt:
3174 LOP(OP_SSOCKOPT,XTERM);
3180 LOP(OP_SHMCTL,XTERM);
3183 LOP(OP_SHMGET,XTERM);
3186 LOP(OP_SHMREAD,XTERM);
3189 LOP(OP_SHMWRITE,XTERM);
3192 LOP(OP_SHUTDOWN,XTERM);
3201 LOP(OP_SOCKET,XTERM);
3203 case KEY_socketpair:
3204 LOP(OP_SOCKPAIR,XTERM);
3207 checkcomma(s,tokenbuf,"subroutine name");
3209 if (*s == ';' || *s == ')') /* probably a close */
3210 croak("sort is now a reserved word");
3212 s = force_word(s,WORD,TRUE,TRUE,TRUE);
3216 LOP(OP_SPLIT,XTERM);
3219 LOP(OP_SPRINTF,XTERM);
3222 LOP(OP_SPLICE,XTERM);
3238 LOP(OP_SUBSTR,XTERM);
3245 if (isIDFIRST(*s) || *s == '\'' || *s == ':') {
3248 d = scan_word(s, tmpbuf, TRUE, &len);
3249 if (strchr(tmpbuf, ':'))
3250 sv_setpv(subname, tmpbuf);
3252 sv_setsv(subname,curstname);
3253 sv_catpvn(subname,"::",2);
3254 sv_catpvn(subname,tmpbuf,len);
3256 s = force_word(s,WORD,FALSE,TRUE,TRUE);
3260 expect = XTERMBLOCK;
3261 sv_setpv(subname,"?");
3264 if (tmp == KEY_format) {
3267 lex_formbrack = lex_brackets + 1;
3271 /* Look for a prototype */
3276 SvREFCNT_dec(lex_stuff);
3278 croak("Prototype not terminated");
3281 nextval[1] = nextval[0];
3282 nexttype[1] = nexttype[0];
3283 nextval[0].opval = (OP*)newSVOP(OP_CONST, 0, lex_stuff);
3284 nexttype[0] = THING;
3285 if (nexttoke == 1) {
3286 lex_defer = lex_state;
3287 lex_expect = expect;
3288 lex_state = LEX_KNOWNEXT;
3293 if (*SvPV(subname,na) == '?') {
3294 sv_setpv(subname,"__ANON__");
3301 LOP(OP_SYSTEM,XREF);
3304 LOP(OP_SYMLINK,XTERM);
3307 LOP(OP_SYSCALL,XTERM);
3310 LOP(OP_SYSOPEN,XTERM);
3313 LOP(OP_SYSREAD,XTERM);
3316 LOP(OP_SYSWRITE,XTERM);
3320 TERM(sublex_start());
3341 LOP(OP_TRUNCATE,XTERM);
3353 yylval.ival = curcop->cop_line;
3357 yylval.ival = curcop->cop_line;
3361 LOP(OP_UNLINK,XTERM);
3367 LOP(OP_UNPACK,XTERM);
3370 LOP(OP_UTIME,XTERM);
3374 for (d = s; d < bufend && (isSPACE(*d) || *d == '('); d++) ;
3375 if (*d != '0' && isDIGIT(*d))
3376 yywarn("umask: argument is missing initial 0");
3381 LOP(OP_UNSHIFT,XTERM);
3384 if (expect != XSTATE)
3385 yyerror("\"use\" not allowed in expression");
3386 s = force_word(s,WORD,FALSE,TRUE,FALSE);
3398 yylval.ival = curcop->cop_line;
3402 hints |= HINT_BLOCK_SCOPE;
3409 LOP(OP_WAITPID,XTERM);
3415 gv_fetchpv("\f",TRUE, SVt_PV); /* Make sure $^L is defined */
3419 if (expect == XOPERATOR)
3425 yylval.ival = OP_XOR;
3430 TERM(sublex_start());
3443 if (strEQ(d,"__LINE__")) return -KEY___LINE__;
3444 if (strEQ(d,"__FILE__")) return -KEY___FILE__;
3445 if (strEQ(d,"__DATA__")) return KEY___DATA__;
3446 if (strEQ(d,"__END__")) return KEY___END__;
3450 if (strEQ(d,"AUTOLOAD")) return KEY_AUTOLOAD;
3455 if (strEQ(d,"and")) return -KEY_and;
3456 if (strEQ(d,"abs")) return -KEY_abs;
3459 if (strEQ(d,"alarm")) return -KEY_alarm;
3460 if (strEQ(d,"atan2")) return -KEY_atan2;
3463 if (strEQ(d,"accept")) return -KEY_accept;
3468 if (strEQ(d,"BEGIN")) return KEY_BEGIN;
3471 if (strEQ(d,"bless")) return -KEY_bless;
3472 if (strEQ(d,"bind")) return -KEY_bind;
3473 if (strEQ(d,"binmode")) return -KEY_binmode;
3476 if (strEQ(d,"CORE")) return -KEY_CORE;
3481 if (strEQ(d,"cmp")) return -KEY_cmp;
3482 if (strEQ(d,"chr")) return -KEY_chr;
3483 if (strEQ(d,"cos")) return -KEY_cos;
3486 if (strEQ(d,"chop")) return KEY_chop;
3489 if (strEQ(d,"close")) return -KEY_close;
3490 if (strEQ(d,"chdir")) return -KEY_chdir;
3491 if (strEQ(d,"chomp")) return KEY_chomp;
3492 if (strEQ(d,"chmod")) return -KEY_chmod;
3493 if (strEQ(d,"chown")) return -KEY_chown;
3494 if (strEQ(d,"crypt")) return -KEY_crypt;
3497 if (strEQ(d,"chroot")) return -KEY_chroot;
3498 if (strEQ(d,"caller")) return -KEY_caller;
3501 if (strEQ(d,"connect")) return -KEY_connect;
3504 if (strEQ(d,"closedir")) return -KEY_closedir;
3505 if (strEQ(d,"continue")) return -KEY_continue;
3510 if (strEQ(d,"DESTROY")) return KEY_DESTROY;
3515 if (strEQ(d,"do")) return KEY_do;
3518 if (strEQ(d,"die")) return -KEY_die;
3521 if (strEQ(d,"dump")) return -KEY_dump;
3524 if (strEQ(d,"delete")) return KEY_delete;
3527 if (strEQ(d,"defined")) return KEY_defined;
3528 if (strEQ(d,"dbmopen")) return -KEY_dbmopen;
3531 if (strEQ(d,"dbmclose")) return -KEY_dbmclose;
3536 if (strEQ(d,"EQ")) { deprecate(d); return -KEY_eq;}
3537 if (strEQ(d,"END")) return KEY_END;
3542 if (strEQ(d,"eq")) return -KEY_eq;
3545 if (strEQ(d,"eof")) return -KEY_eof;
3546 if (strEQ(d,"exp")) return -KEY_exp;
3549 if (strEQ(d,"else")) return KEY_else;
3550 if (strEQ(d,"exit")) return -KEY_exit;
3551 if (strEQ(d,"eval")) return KEY_eval;
3552 if (strEQ(d,"exec")) return -KEY_exec;
3553 if (strEQ(d,"each")) return KEY_each;
3556 if (strEQ(d,"elsif")) return KEY_elsif;
3559 if (strEQ(d,"exists")) return KEY_exists;
3560 if (strEQ(d,"elseif")) warn("elseif should be elsif");
3563 if (strEQ(d,"endgrent")) return -KEY_endgrent;
3564 if (strEQ(d,"endpwent")) return -KEY_endpwent;
3567 if (strEQ(d,"endnetent")) return -KEY_endnetent;
3570 if (strEQ(d,"endhostent")) return -KEY_endhostent;
3571 if (strEQ(d,"endservent")) return -KEY_endservent;
3574 if (strEQ(d,"endprotoent")) return -KEY_endprotoent;
3581 if (strEQ(d,"for")) return KEY_for;
3584 if (strEQ(d,"fork")) return -KEY_fork;
3587 if (strEQ(d,"fcntl")) return -KEY_fcntl;
3588 if (strEQ(d,"flock")) return -KEY_flock;
3591 if (strEQ(d,"format")) return KEY_format;
3592 if (strEQ(d,"fileno")) return -KEY_fileno;
3595 if (strEQ(d,"foreach")) return KEY_foreach;
3598 if (strEQ(d,"formline")) return -KEY_formline;
3604 if (strEQ(d,"GT")) { deprecate(d); return -KEY_gt;}
3605 if (strEQ(d,"GE")) { deprecate(d); return -KEY_ge;}
3609 if (strnEQ(d,"get",3)) {
3614 if (strEQ(d,"ppid")) return -KEY_getppid;
3615 if (strEQ(d,"pgrp")) return -KEY_getpgrp;
3618 if (strEQ(d,"pwent")) return -KEY_getpwent;
3619 if (strEQ(d,"pwnam")) return -KEY_getpwnam;
3620 if (strEQ(d,"pwuid")) return -KEY_getpwuid;
3623 if (strEQ(d,"peername")) return -KEY_getpeername;
3624 if (strEQ(d,"protoent")) return -KEY_getprotoent;
3625 if (strEQ(d,"priority")) return -KEY_getpriority;
3628 if (strEQ(d,"protobyname")) return -KEY_getprotobyname;
3631 if (strEQ(d,"protobynumber"))return -KEY_getprotobynumber;
3635 else if (*d == 'h') {
3636 if (strEQ(d,"hostbyname")) return -KEY_gethostbyname;
3637 if (strEQ(d,"hostbyaddr")) return -KEY_gethostbyaddr;
3638 if (strEQ(d,"hostent")) return -KEY_gethostent;
3640 else if (*d == 'n') {
3641 if (strEQ(d,"netbyname")) return -KEY_getnetbyname;
3642 if (strEQ(d,"netbyaddr")) return -KEY_getnetbyaddr;
3643 if (strEQ(d,"netent")) return -KEY_getnetent;
3645 else if (*d == 's') {
3646 if (strEQ(d,"servbyname")) return -KEY_getservbyname;
3647 if (strEQ(d,"servbyport")) return -KEY_getservbyport;
3648 if (strEQ(d,"servent")) return -KEY_getservent;
3649 if (strEQ(d,"sockname")) return -KEY_getsockname;
3650 if (strEQ(d,"sockopt")) return -KEY_getsockopt;
3652 else if (*d == 'g') {
3653 if (strEQ(d,"grent")) return -KEY_getgrent;
3654 if (strEQ(d,"grnam")) return -KEY_getgrnam;
3655 if (strEQ(d,"grgid")) return -KEY_getgrgid;
3657 else if (*d == 'l') {
3658 if (strEQ(d,"login")) return -KEY_getlogin;
3660 else if (strEQ(d,"c")) return -KEY_getc;
3665 if (strEQ(d,"gt")) return -KEY_gt;
3666 if (strEQ(d,"ge")) return -KEY_ge;
3669 if (strEQ(d,"grep")) return KEY_grep;
3670 if (strEQ(d,"goto")) return KEY_goto;
3671 if (strEQ(d,"glob")) return -KEY_glob;
3674 if (strEQ(d,"gmtime")) return -KEY_gmtime;
3679 if (strEQ(d,"hex")) return -KEY_hex;
3684 if (strEQ(d,"if")) return KEY_if;
3687 if (strEQ(d,"int")) return -KEY_int;
3690 if (strEQ(d,"index")) return -KEY_index;
3691 if (strEQ(d,"ioctl")) return -KEY_ioctl;
3696 if (strEQ(d,"join")) return -KEY_join;
3700 if (strEQ(d,"keys")) return KEY_keys;
3701 if (strEQ(d,"kill")) return -KEY_kill;
3706 if (strEQ(d,"LT")) { deprecate(d); return -KEY_lt;}
3707 if (strEQ(d,"LE")) { deprecate(d); return -KEY_le;}
3713 if (strEQ(d,"lt")) return -KEY_lt;
3714 if (strEQ(d,"le")) return -KEY_le;
3715 if (strEQ(d,"lc")) return -KEY_lc;
3718 if (strEQ(d,"log")) return -KEY_log;
3721 if (strEQ(d,"last")) return KEY_last;
3722 if (strEQ(d,"link")) return -KEY_link;
3725 if (strEQ(d,"local")) return KEY_local;
3726 if (strEQ(d,"lstat")) return -KEY_lstat;
3729 if (strEQ(d,"length")) return -KEY_length;
3730 if (strEQ(d,"listen")) return -KEY_listen;
3733 if (strEQ(d,"lcfirst")) return -KEY_lcfirst;
3736 if (strEQ(d,"localtime")) return -KEY_localtime;
3742 case 1: return KEY_m;
3744 if (strEQ(d,"my")) return KEY_my;
3747 if (strEQ(d,"map")) return KEY_map;
3750 if (strEQ(d,"mkdir")) return -KEY_mkdir;
3753 if (strEQ(d,"msgctl")) return -KEY_msgctl;
3754 if (strEQ(d,"msgget")) return -KEY_msgget;
3755 if (strEQ(d,"msgrcv")) return -KEY_msgrcv;
3756 if (strEQ(d,"msgsnd")) return -KEY_msgsnd;
3761 if (strEQ(d,"NE")) { deprecate(d); return -KEY_ne;}
3764 if (strEQ(d,"next")) return KEY_next;
3765 if (strEQ(d,"ne")) return -KEY_ne;
3766 if (strEQ(d,"not")) return -KEY_not;
3767 if (strEQ(d,"no")) return KEY_no;
3772 if (strEQ(d,"or")) return -KEY_or;
3775 if (strEQ(d,"ord")) return -KEY_ord;
3776 if (strEQ(d,"oct")) return -KEY_oct;
3779 if (strEQ(d,"open")) return -KEY_open;
3782 if (strEQ(d,"opendir")) return -KEY_opendir;
3789 if (strEQ(d,"pop")) return KEY_pop;
3790 if (strEQ(d,"pos")) return KEY_pos;
3793 if (strEQ(d,"push")) return KEY_push;
3794 if (strEQ(d,"pack")) return -KEY_pack;
3795 if (strEQ(d,"pipe")) return -KEY_pipe;
3798 if (strEQ(d,"print")) return KEY_print;
3801 if (strEQ(d,"printf")) return KEY_printf;
3804 if (strEQ(d,"package")) return KEY_package;
3807 if (strEQ(d,"prototype")) return KEY_prototype;
3812 if (strEQ(d,"q")) return KEY_q;
3813 if (strEQ(d,"qq")) return KEY_qq;
3814 if (strEQ(d,"qw")) return KEY_qw;
3815 if (strEQ(d,"qx")) return KEY_qx;
3817 else if (strEQ(d,"quotemeta")) return -KEY_quotemeta;
3822 if (strEQ(d,"ref")) return -KEY_ref;
3825 if (strEQ(d,"read")) return -KEY_read;
3826 if (strEQ(d,"rand")) return -KEY_rand;
3827 if (strEQ(d,"recv")) return -KEY_recv;
3828 if (strEQ(d,"redo")) return KEY_redo;
3831 if (strEQ(d,"rmdir")) return -KEY_rmdir;
3832 if (strEQ(d,"reset")) return -KEY_reset;
3835 if (strEQ(d,"return")) return KEY_return;
3836 if (strEQ(d,"rename")) return -KEY_rename;
3837 if (strEQ(d,"rindex")) return -KEY_rindex;
3840 if (strEQ(d,"require")) return -KEY_require;
3841 if (strEQ(d,"reverse")) return -KEY_reverse;
3842 if (strEQ(d,"readdir")) return -KEY_readdir;
3845 if (strEQ(d,"readlink")) return -KEY_readlink;
3846 if (strEQ(d,"readline")) return -KEY_readline;
3847 if (strEQ(d,"readpipe")) return -KEY_readpipe;
3850 if (strEQ(d,"rewinddir")) return -KEY_rewinddir;
3856 case 0: return KEY_s;
3858 if (strEQ(d,"scalar")) return KEY_scalar;
3863 if (strEQ(d,"seek")) return -KEY_seek;
3864 if (strEQ(d,"send")) return -KEY_send;
3867 if (strEQ(d,"semop")) return -KEY_semop;
3870 if (strEQ(d,"select")) return -KEY_select;
3871 if (strEQ(d,"semctl")) return -KEY_semctl;
3872 if (strEQ(d,"semget")) return -KEY_semget;
3875 if (strEQ(d,"setpgrp")) return -KEY_setpgrp;
3876 if (strEQ(d,"seekdir")) return -KEY_seekdir;
3879 if (strEQ(d,"setpwent")) return -KEY_setpwent;
3880 if (strEQ(d,"setgrent")) return -KEY_setgrent;
3883 if (strEQ(d,"setnetent")) return -KEY_setnetent;
3886 if (strEQ(d,"setsockopt")) return -KEY_setsockopt;
3887 if (strEQ(d,"sethostent")) return -KEY_sethostent;
3888 if (strEQ(d,"setservent")) return -KEY_setservent;
3891 if (strEQ(d,"setpriority")) return -KEY_setpriority;
3892 if (strEQ(d,"setprotoent")) return -KEY_setprotoent;
3899 if (strEQ(d,"shift")) return KEY_shift;
3902 if (strEQ(d,"shmctl")) return -KEY_shmctl;
3903 if (strEQ(d,"shmget")) return -KEY_shmget;
3906 if (strEQ(d,"shmread")) return -KEY_shmread;
3909 if (strEQ(d,"shmwrite")) return -KEY_shmwrite;
3910 if (strEQ(d,"shutdown")) return -KEY_shutdown;
3915 if (strEQ(d,"sin")) return -KEY_sin;
3918 if (strEQ(d,"sleep")) return -KEY_sleep;
3921 if (strEQ(d,"sort")) return KEY_sort;
3922 if (strEQ(d,"socket")) return -KEY_socket;
3923 if (strEQ(d,"socketpair")) return -KEY_socketpair;
3926 if (strEQ(d,"split")) return KEY_split;
3927 if (strEQ(d,"sprintf")) return -KEY_sprintf;
3928 if (strEQ(d,"splice")) return KEY_splice;
3931 if (strEQ(d,"sqrt")) return -KEY_sqrt;
3934 if (strEQ(d,"srand")) return -KEY_srand;
3937 if (strEQ(d,"stat")) return -KEY_stat;
3938 if (strEQ(d,"study")) return KEY_study;
3941 if (strEQ(d,"substr")) return -KEY_substr;
3942 if (strEQ(d,"sub")) return KEY_sub;
3947 if (strEQ(d,"system")) return -KEY_system;
3950 if (strEQ(d,"sysopen")) return -KEY_sysopen;
3951 if (strEQ(d,"sysread")) return -KEY_sysread;
3952 if (strEQ(d,"symlink")) return -KEY_symlink;
3953 if (strEQ(d,"syscall")) return -KEY_syscall;
3956 if (strEQ(d,"syswrite")) return -KEY_syswrite;
3965 if (strEQ(d,"tr")) return KEY_tr;
3968 if (strEQ(d,"tie")) return KEY_tie;
3971 if (strEQ(d,"tell")) return -KEY_tell;
3972 if (strEQ(d,"tied")) return KEY_tied;
3973 if (strEQ(d,"time")) return -KEY_time;
3976 if (strEQ(d,"times")) return -KEY_times;
3979 if (strEQ(d,"telldir")) return -KEY_telldir;
3982 if (strEQ(d,"truncate")) return -KEY_truncate;
3989 if (strEQ(d,"uc")) return -KEY_uc;
3992 if (strEQ(d,"use")) return KEY_use;
3995 if (strEQ(d,"undef")) return KEY_undef;
3996 if (strEQ(d,"until")) return KEY_until;
3997 if (strEQ(d,"untie")) return KEY_untie;
3998 if (strEQ(d,"utime")) return -KEY_utime;
3999 if (strEQ(d,"umask")) return -KEY_umask;
4002 if (strEQ(d,"unless")) return KEY_unless;
4003 if (strEQ(d,"unpack")) return -KEY_unpack;
4004 if (strEQ(d,"unlink")) return -KEY_unlink;
4007 if (strEQ(d,"unshift")) return KEY_unshift;
4008 if (strEQ(d,"ucfirst")) return -KEY_ucfirst;
4013 if (strEQ(d,"values")) return -KEY_values;
4014 if (strEQ(d,"vec")) return -KEY_vec;
4019 if (strEQ(d,"warn")) return -KEY_warn;
4020 if (strEQ(d,"wait")) return -KEY_wait;
4023 if (strEQ(d,"while")) return KEY_while;
4024 if (strEQ(d,"write")) return -KEY_write;
4027 if (strEQ(d,"waitpid")) return -KEY_waitpid;
4030 if (strEQ(d,"wantarray")) return -KEY_wantarray;
4035 if (len == 1) return -KEY_x;
4036 if (strEQ(d,"xor")) return -KEY_xor;
4039 if (len == 1) return KEY_y;
4048 checkcomma(s,name,what)
4055 if (dowarn && *s == ' ' && s[1] == '(') { /* XXX gotta be a better way */
4057 for (w = s+2; *w && level; w++) {
4064 for (; *w && isSPACE(*w); w++) ;
4065 if (!*w || !strchr(";|})]oa!=", *w)) /* an advisory hack only... */
4066 warn("%s (...) interpreted as function",name);
4068 while (s < bufend && isSPACE(*s))
4072 while (s < bufend && isSPACE(*s))
4074 if (isIDFIRST(*s)) {
4078 while (s < bufend && isSPACE(*s))
4083 kw = keyword(w, s - w) || perl_get_cv(w, FALSE) != 0;
4087 croak("No comma allowed after %s", what);
4093 scan_word(s, dest, allow_package, slp)
4099 register char *d = dest;
4103 else if (*s == '\'' && allow_package && isIDFIRST(s[1])) {
4108 else if (*s == ':' && s[1] == ':' && allow_package && isIDFIRST(s[2])) {
4121 scan_ident(s,send,dest,ck_uni)
4123 register char *send;
4131 if (lex_brackets == 0)
4144 else if (*s == '\'' && isIDFIRST(s[1])) {
4149 else if (*s == ':' && s[1] == ':') {
4160 if (lex_state != LEX_NORMAL)
4161 lex_state = LEX_INTERPENDMAYBE;
4164 if (*s == '$' && s[1] &&
4165 (isALPHA(s[1]) || strchr("$_{", s[1]) || strnEQ(s+1,"::",2)) )
4176 if (*d == '^' && *s && (isUPPER(*s) || strchr("[\\]^_?", *s))) {
4180 if (isSPACE(s[-1])) {
4181 while (s < send && (*s == ' ' || *s == '\t')) s++;
4184 if (isALPHA(*d) || *d == '_') {
4186 while (isALNUM(*s) || *s == ':')
4189 while (s < send && (*s == ' ' || *s == '\t')) s++;
4190 if ((*s == '[' || *s == '{')) {
4191 if (dowarn && keyword(dest, d - dest)) {
4192 char *brack = *s == '[' ? "[...]" : "{...}";
4193 warn("Ambiguous use of %c{%s%s} resolved to %c%s%s",
4194 funny, dest, brack, funny, dest, brack);
4196 lex_fakebrack = lex_brackets+1;
4198 lex_brackstack[lex_brackets++] = XOPERATOR;
4204 if (lex_state == LEX_INTERPNORMAL && !lex_brackets)
4205 lex_state = LEX_INTERPEND;
4209 (keyword(dest, d - dest) || perl_get_cv(dest, FALSE)))
4210 warn("Ambiguous use of %c{%s} resolved to %c%s",
4211 funny, dest, funny, dest);
4214 s = bracket; /* let the parser handle it */
4218 else if (lex_state == LEX_INTERPNORMAL && !lex_brackets && !intuit_more(s))
4219 lex_state = LEX_INTERPEND;
4223 void pmflag(pmfl,ch)
4232 *pmfl |= PMf_GLOBAL;
4236 *pmfl |= PMf_MULTILINE;
4238 *pmfl |= PMf_SINGLELINE;
4240 *pmfl |= PMf_EXTENDED;
4250 s = scan_str(start);
4253 SvREFCNT_dec(lex_stuff);
4255 croak("Search pattern not terminated");
4257 pm = (PMOP*)newPMOP(OP_MATCH, 0);
4258 if (multi_open == '?')
4259 pm->op_pmflags |= PMf_ONCE;
4261 while (*s && strchr("iogmsx", *s))
4262 pmflag(&pm->op_pmflags,*s++);
4264 pm->op_pmpermflags = pm->op_pmflags;
4266 yylval.ival = OP_MATCH;
4278 yylval.ival = OP_NULL;
4280 s = scan_str(start);
4284 SvREFCNT_dec(lex_stuff);
4286 croak("Substitution pattern not terminated");
4289 if (s[-1] == multi_open)
4295 SvREFCNT_dec(lex_stuff);
4298 SvREFCNT_dec(lex_repl);
4300 croak("Substitution replacement not terminated");
4303 pm = (PMOP*)newPMOP(OP_SUBST, 0);
4304 while (*s && strchr("iogmsex", *s)) {
4310 pmflag(&pm->op_pmflags,*s++);
4315 pm->op_pmflags |= PMf_EVAL;
4316 repl = newSVpv("",0);
4318 sv_catpv(repl, es ? "eval " : "do ");
4319 sv_catpvn(repl, "{ ", 2);
4320 sv_catsv(repl, lex_repl);
4321 sv_catpvn(repl, " };", 2);
4322 SvCOMPILED_on(repl);
4323 SvREFCNT_dec(lex_repl);
4327 pm->op_pmpermflags = pm->op_pmflags;
4329 yylval.ival = OP_SUBST;
4337 if (!pm->op_pmshort && pm->op_pmregexp->regstart &&
4338 (!pm->op_pmregexp->regmust || pm->op_pmregexp->reganch & ROPT_ANCH)
4340 if (!(pm->op_pmregexp->reganch & ROPT_ANCH))
4341 pm->op_pmflags |= PMf_SCANFIRST;
4342 else if (pm->op_pmflags & PMf_FOLD)
4344 pm->op_pmshort = SvREFCNT_inc(pm->op_pmregexp->regstart);
4345 pm->op_pmslen = SvCUR(pm->op_pmshort);
4347 else if (pm->op_pmregexp->regmust) {/* is there a better short-circuit? */
4348 if (pm->op_pmshort &&
4349 sv_eq(pm->op_pmshort,pm->op_pmregexp->regmust))
4351 if (pm->op_pmflags & PMf_SCANFIRST) {
4352 SvREFCNT_dec(pm->op_pmshort);
4353 pm->op_pmshort = Nullsv;
4356 SvREFCNT_dec(pm->op_pmregexp->regmust);
4357 pm->op_pmregexp->regmust = Nullsv;
4361 if (!pm->op_pmshort || /* promote the better string */
4362 ((pm->op_pmflags & PMf_SCANFIRST) &&
4363 (SvCUR(pm->op_pmshort) < SvCUR(pm->op_pmregexp->regmust)) )){
4364 SvREFCNT_dec(pm->op_pmshort); /* ok if null */
4365 pm->op_pmshort = pm->op_pmregexp->regmust;
4366 pm->op_pmslen = SvCUR(pm->op_pmshort);
4367 pm->op_pmregexp->regmust = Nullsv;
4368 pm->op_pmflags |= PMf_SCANFIRST;
4384 yylval.ival = OP_NULL;
4386 s = scan_str(start);
4389 SvREFCNT_dec(lex_stuff);
4391 croak("Translation pattern not terminated");
4393 if (s[-1] == multi_open)
4399 SvREFCNT_dec(lex_stuff);
4402 SvREFCNT_dec(lex_repl);
4404 croak("Translation replacement not terminated");
4407 New(803,tbl,256,short);
4408 op = newPVOP(OP_TRANS, 0, (char*)tbl);
4410 complement = delete = squash = 0;
4411 while (*s == 'c' || *s == 'd' || *s == 's') {
4413 complement = OPpTRANS_COMPLEMENT;
4415 delete = OPpTRANS_DELETE;
4417 squash = OPpTRANS_SQUASH;
4420 op->op_private = delete|squash|complement;
4423 yylval.ival = OP_TRANS;
4432 I32 op_type = OP_SCALAR;
4443 for (peek = s; *peek == ' ' || *peek == '\t'; peek++) ;
4444 if (*peek && strchr("`'\"",*peek)) {
4447 s = cpytill(d,s,bufend,term,&len);
4458 deprecate("bare << to mean <<\"\"");
4461 } /* assuming tokenbuf won't clobber */
4466 if (rsfp || !(d=ninstr(s,bufend,d,d+1)))
4467 herewas = newSVpv(s,bufend-s);
4469 s--, herewas = newSVpv(s,d-s);
4470 s += SvCUR(herewas);
4472 tmpstr = NEWSV(87,80);
4473 sv_upgrade(tmpstr, SVt_PVIV);
4478 else if (term == '`') {
4479 op_type = OP_BACKTICK;
4480 SvIVX(tmpstr) = '\\';
4484 multi_start = curcop->cop_line;
4485 multi_open = multi_close = '<';
4489 while (s < bufend &&
4490 (*s != term || bcmp(s,tokenbuf,len) != 0) ) {
4495 curcop->cop_line = multi_start;
4496 missingterm(tokenbuf);
4498 sv_setpvn(tmpstr,d+1,s-d);
4500 sv_catpvn(herewas,s,bufend-s);
4501 sv_setsv(linestr,herewas);
4502 oldoldbufptr = oldbufptr = bufptr = s = SvPVX(linestr);
4503 bufend = SvPVX(linestr) + SvCUR(linestr);
4506 sv_setpvn(tmpstr,"",0); /* avoid "uninitialized" warning */
4507 while (s >= bufend) { /* multiple line string? */
4509 !(oldoldbufptr = oldbufptr = s = filter_gets(linestr, rsfp))) {
4510 curcop->cop_line = multi_start;
4511 missingterm(tokenbuf);
4514 if (perldb && curstash != debstash) {
4515 SV *sv = NEWSV(88,0);
4517 sv_upgrade(sv, SVt_PVMG);
4518 sv_setsv(sv,linestr);
4519 av_store(GvAV(curcop->cop_filegv),
4520 (I32)curcop->cop_line,sv);
4522 bufend = SvPVX(linestr) + SvCUR(linestr);
4523 if (*s == term && bcmp(s,tokenbuf,len) == 0) {
4526 sv_catsv(linestr,herewas);
4527 bufend = SvPVX(linestr) + SvCUR(linestr);
4531 sv_catsv(tmpstr,linestr);
4534 multi_end = curcop->cop_line;
4536 if (SvCUR(tmpstr) + 5 < SvLEN(tmpstr)) {
4537 SvLEN_set(tmpstr, SvCUR(tmpstr) + 1);
4538 Renew(SvPVX(tmpstr), SvLEN(tmpstr), char);
4540 SvREFCNT_dec(herewas);
4542 yylval.ival = op_type;
4547 scan_inputsymbol(start)
4550 register char *s = start;
4555 s = cpytill(d, s+1, bufend, '>', &len);
4559 croak("Unterminated <> operator");
4561 if (*d == '$' && d[1]) d++;
4562 while (*d && (isALNUM(*d) || *d == '\'' || *d == ':'))
4564 if (d - tokenbuf != len) {
4565 yylval.ival = OP_GLOB;
4567 s = scan_str(start);
4569 croak("Glob not terminated");
4575 (void)strcpy(d,"ARGV");
4578 if (tmp = pad_findmy(d)) {
4579 OP *op = newOP(OP_PADSV, 0);
4581 lex_op = (OP*)newUNOP(OP_READLINE, 0, newUNOP(OP_RV2GV, 0, op));
4584 GV *gv = gv_fetchpv(d+1,TRUE, SVt_PV);
4585 lex_op = (OP*)newUNOP(OP_READLINE, 0,
4586 newUNOP(OP_RV2GV, 0,
4587 newUNOP(OP_RV2SV, 0,
4588 newGVOP(OP_GV, 0, gv))));
4590 yylval.ival = OP_NULL;
4593 GV *gv = gv_fetchpv(d,TRUE, SVt_PVIO);
4594 lex_op = (OP*)newUNOP(OP_READLINE, 0, newGVOP(OP_GV, 0, gv));
4595 yylval.ival = OP_NULL;
4607 register char *s = start;
4616 multi_start = curcop->cop_line;
4618 if (term && (tmps = strchr("([{< )]}> )]}>",term)))
4623 sv_upgrade(sv, SVt_PVIV);
4625 (void)SvPOK_only(sv); /* validate pointer */
4628 SvGROW(sv, SvCUR(sv) + (bufend - s) + 1);
4629 to = SvPVX(sv)+SvCUR(sv);
4630 if (multi_open == multi_close) {
4631 for (; s < bufend; s++,to++) {
4632 if (*s == '\n' && !rsfp)
4634 if (*s == '\\' && s+1 < bufend && term != '\\') {
4640 else if (*s == term)
4646 for (; s < bufend; s++,to++) {
4647 if (*s == '\n' && !rsfp)
4649 if (*s == '\\' && s+1 < bufend && term != '\\') {
4655 else if (*s == term && --brackets <= 0)
4657 else if (*s == multi_open)
4663 SvCUR_set(sv, to - SvPVX(sv));
4665 if (s < bufend) break; /* string ends on this line? */
4668 !(oldoldbufptr = oldbufptr = s = filter_gets(linestr, rsfp))) {
4670 curcop->cop_line = multi_start;
4674 if (perldb && curstash != debstash) {
4675 SV *sv = NEWSV(88,0);
4677 sv_upgrade(sv, SVt_PVMG);
4678 sv_setsv(sv,linestr);
4679 av_store(GvAV(curcop->cop_filegv),
4680 (I32)curcop->cop_line, sv);
4682 bufend = SvPVX(linestr) + SvCUR(linestr);
4684 multi_end = curcop->cop_line;
4686 if (SvCUR(sv) + 5 < SvLEN(sv)) {
4687 SvLEN_set(sv, SvCUR(sv) + 1);
4688 Renew(SvPVX(sv), SvLEN(sv), char);
4701 register char *s = start;
4711 croak("panic: scan_num");
4721 else if (s[1] == '.')
4735 yyerror("Illegal octal digit");
4737 case '0': case '1': case '2': case '3': case '4':
4738 case '5': case '6': case '7':
4742 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
4743 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
4747 i += (*s++ & 7) + 9;
4754 if (tryi32 == i && tryi32 >= 0)
4755 sv_setiv(sv,tryi32);
4757 sv_setnv(sv,(double)i);
4760 case '1': case '2': case '3': case '4': case '5':
4761 case '6': case '7': case '8': case '9': case '.':
4765 while (isDIGIT(*s) || *s == '_') {
4767 if (dowarn && lastub && s - lastub != 3)
4768 warn("Misplaced _ in number");
4774 if (dowarn && lastub && s - lastub != 3)
4775 warn("Misplaced _ in number");
4776 if (*s == '.' && s[1] != '.') {
4779 while (isDIGIT(*s) || *s == '_') {
4786 if (*s && strchr("eE",*s) && strchr("+-0123456789",s[1])) {
4789 *d++ = 'e'; /* At least some Mach atof()s don't grok 'E' */
4790 if (*s == '+' || *s == '-')
4797 value = atof(tokenbuf);
4798 tryi32 = I_32(value);
4799 if (!floatit && (double)tryi32 == value)
4800 sv_setiv(sv,tryi32);
4806 yylval.opval = newSVOP(OP_CONST, 0, sv);
4817 SV *stuff = newSVpv("",0);
4818 bool needargs = FALSE;
4821 if (*s == '.' || *s == '}') {
4823 for (t = s+1; *t == ' ' || *t == '\t'; t++) ;
4827 if (in_eval && !rsfp) {
4828 eol = strchr(s,'\n');
4833 eol = bufend = SvPVX(linestr) + SvCUR(linestr);
4835 for (t = s; t < eol; t++) {
4836 if (*t == '~' && t[1] == '~' && SvCUR(stuff)) {
4838 goto enough; /* ~~ must be first line in formline */
4840 if (*t == '@' || *t == '^')
4843 sv_catpvn(stuff, s, eol-s);
4847 s = filter_gets(linestr, rsfp);
4848 oldoldbufptr = oldbufptr = bufptr = SvPVX(linestr);
4849 bufend = bufptr + SvCUR(linestr);
4852 yyerror("Format not terminated");
4862 lex_state = LEX_NORMAL;
4863 nextval[nexttoke].ival = 0;
4867 lex_state = LEX_FORMLINE;
4868 nextval[nexttoke].opval = (OP*)newSVOP(OP_CONST, 0, stuff);
4870 nextval[nexttoke].ival = OP_FORMLINE;
4874 SvREFCNT_dec(stuff);
4886 cshlen = strlen(cshname);
4893 int oldsavestack_ix = savestack_ix;
4894 CV* outsidecv = compcv;
4898 assert(SvTYPE(compcv) == SVt_PVCV);
4905 SAVESPTR(comppad_name);
4907 SAVEINT(comppad_name_fill);
4908 SAVEINT(min_intro_pending);
4909 SAVEINT(max_intro_pending);
4910 SAVEINT(pad_reset_pending);
4912 compcv = (CV*)NEWSV(1104,0);
4913 sv_upgrade((SV *)compcv, SVt_PVCV);
4916 comppad_name = newAV();
4917 comppad_name_fill = 0;
4918 min_intro_pending = 0;
4919 av_push(comppad, Nullsv);
4920 curpad = AvARRAY(comppad);
4922 subline = curcop->cop_line;
4924 comppadlist = newAV();
4925 AvREAL_off(comppadlist);
4926 av_store(comppadlist, 0, (SV*)comppad_name);
4927 av_store(comppadlist, 1, (SV*)comppad);
4929 CvPADLIST(compcv) = comppadlist;
4930 CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc((SV*)outsidecv);
4932 return oldsavestack_ix;
4951 char *tname = tmpbuf;
4953 if (bufptr > oldoldbufptr && bufptr - oldoldbufptr < 200 &&
4954 oldoldbufptr != oldbufptr && oldbufptr != bufptr) {
4955 while (isSPACE(*oldoldbufptr))
4957 sprintf(tname,"near \"%.*s\"",bufptr - oldoldbufptr, oldoldbufptr);
4959 else if (bufptr > oldbufptr && bufptr - oldbufptr < 200 &&
4960 oldbufptr != bufptr) {
4961 while (isSPACE(*oldbufptr))
4963 sprintf(tname,"near \"%.*s\"",bufptr - oldbufptr, oldbufptr);
4965 else if (yychar > 255)
4966 tname = "next token ???";
4967 else if (!yychar || (yychar == ';' && !rsfp))
4968 (void)strcpy(tname,"at EOF");
4969 else if ((yychar & 127) == 127) {
4970 if (lex_state == LEX_NORMAL ||
4971 (lex_state == LEX_KNOWNEXT && lex_defer == LEX_NORMAL))
4972 (void)strcpy(tname,"at end of line");
4974 (void)strcpy(tname,"within pattern");
4976 (void)strcpy(tname,"within string");
4978 else if (yychar < 32)
4979 (void)sprintf(tname,"next char ^%c",yychar+64);
4981 (void)sprintf(tname,"next char %c",yychar);
4982 (void)sprintf(buf, "%s at %s line %d, %s\n",
4983 s,SvPVX(GvSV(curcop->cop_filegv)),curcop->cop_line,tname);
4984 if (curcop->cop_line == multi_end && multi_start < multi_end) {
4985 sprintf(buf+strlen(buf),
4986 " (Might be a runaway multi-line %c%c string starting on line %ld)\n",
4987 multi_open,multi_close,(long)multi_start);
4993 sv_catpv(GvSV(errgv),buf);
4996 if (++error_count >= 10)
4997 croak("%s has too many errors.\n",
4998 SvPVX(GvSV(curcop->cop_filegv)));