# 2.11BSD#431 - /usr/src/ucb/pascal/pxp/yylex.c

##### Functions

    setuflg           X
    unyylex           X
    yylex             X
    yyset             X

##### Variables

    Yla               X
    yylacnt           X

##### Macros

    YYLASIZ           X

       1: #
       2: /*
       3:  * pi - Pascal interpreter code translator
       4:  *
       5:  * Charles Haley, Bill Joy UCB
       6:  * Version 1.2 January 1979
       7:  *
       8:  *
       9:  * pxp - Pascal execution profiler
      10:  *
      11:  * Bill Joy UCB
      12:  * Version 1.2 January 1979
      13:  */
      14:
      15: #include "0.h"
      16: #include "yy.h"
      17:
      18: /*
      19:  * Scanner
      20:  */
      21: int yylacnt;
      22:
      23: #define YYLASIZ 10
      24:
      25: struct  yytok Yla[YYLASIZ];
      26:
      27: unyylex(y)
      28:     struct yylex *y;
      29: {
      30:
      31:     if (yylacnt == YYLASIZ)
      32:         panic("unyylex");
      33:     copy(&Yla[yylacnt], y, sizeof Yla[0]);
      34:     yylacnt++;
      35:
      36: }
      37:
      38: yylex()
      39: {
      40:     register c;
      41:     register **ip;
      42:     register char *cp;
      43:     int f;
      44:     char delim;
      45:
      46:     if (yylacnt != 0) {
      47:         yylacnt--;
      48:         copy(&Y, &Yla[yylacnt], sizeof Y);
      49:         return (yychar);
      50:     }
      51:     if (c = yysavc)
      52:         yysavc = 0;
      53:     else
      54:         c = getchar();
      55: #ifdef PXP
      56:     yytokcnt++;
      57: #endif
      58:
      59: next:
      60:     /*
      61: 	 * skip white space
      62: 	 */
      63: #ifdef PXP
      64:     yywhcnt = 0;
      65: #endif
      66:     while (c == ' ' || c == '\t') {
      67: #ifdef PXP
      68:         if (c == '\t')
      69:             yywhcnt++;
      70:         yywhcnt++;
      71: #endif
      72:         c = getchar();
      73:     }
      74:     yyecol = yycol;
      75:     yyeline = yyline;
      76:     yyefile = filename;
      77:     yyeseqid = yyseqid;
      78:     yyseekp = yylinpt;
      79:     cp = token;
      80:     yylval = yyline;
      81:     switch (c) {
      82:         case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
      83:         case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
      84:         case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
      85:         case 'v': case 'w': case 'x': case 'y': case 'z':
      86:         case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
      87:         case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
      88:         case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
      89:         case 'V': case 'W': case 'X': case 'Y': case 'Z':
      90:             do {
      91:                 *cp++ = c;
      92:                 c = getchar();
      93:             } while (alph(c) || digit(c));
      94:             *cp = 0;
      95:             if (opt('s'))
      96:                 for (cp = token; *cp; cp++)
      97:                     if (*cp >= 'A' && *cp <= 'Z') {
      98:                         *cp |= ' ';
      99:                     }
     100:             yysavc = c;
     101:             ip = hash(0, 1);
     102:             if (*ip < yykey || *ip >= lastkey) {
     103:                 yylval = *ip;
     104:                 return (YID);
     105:             }
     106:             yylval = yyline;
     107:             /*
     108: 			 * For keywords
     109: 			 * the lexical token
     110: 			 * is magically retrieved
     111: 			 * from the keyword table.
     112: 			 */
     113:             return ((*ip)[1]);
     114:         case '0': case '1': case '2': case '3': case '4':
     115:         case '5': case '6': case '7': case '8': case '9':
     116:             f = 0;
     117:             do {
     118:                 *cp++ = c;
     119:                 c = getchar();
     120:             } while (digit(c));
     121:             if (c == 'b' || c == 'B') {
     122:                 /*
     123: 				 * nonstandard - octal constants
     124: 				 */
     125:                 if (opt('s')) {
     126:                     standard();
     127:                     yerror("Octal constants are non-standard");
     128:                 }
     129:                 *cp = 0;
     130:                 yylval = copystr(token);
     131:                 return (YBINT);
     132:             }
     133:             if (c == '.') {
     134:                 c = getchar();
     135:                 if (c == '.') {
     136:                     *cp = 0;
     137:                     yysavc = YDOTDOT;
     138:                     yylval = copystr(token);
     139:                     return (YINT);
     140:                 }
     141: infpnumb:
     142:                 f++;
     143:                 *cp++ = '.';
     144:                 if (!digit(c)) {
     145:                     yyset();
     146:                     recovered();
     147:                     yerror("Digits required after decimal point");
     148:                     *cp++ = '0';
     149:                 } else
     150:                     while (digit(c)) {
     151:                         *cp++ = c;
     152:                         c = getchar();
     153:                     }
     154:             }
     155:             if (c == 'e' || c == 'E') {
     156:                 f++;
     157:                 *cp++ = c;
     158:                 if ((c = yysavc) == 0)
     159:                     c = getchar();
     160:                 if (c == '+' || c == '-') {
     161:                     *cp++ = c;
     162:                     c = getchar();
     163:                 }
     164:                 if (!digit(c)) {
     165:                     yyset();
     166:                     yerror("Digits required in exponent");
     167:                     *cp++ = '0';
     168:                 } else
     169:                     while (digit(c)) {
     170:                         *cp++ = c;
     171:                         c = getchar();
     172:                     }
     173:             }
     174:             *cp = 0;
     175:             yysavc = c;
     176:             yylval = copystr(token);
     177:             if (f)
     178:                 return (YNUMB);
     179:             return (YINT);
     180:         case '"':
     181:         case '`':
     182:             if (!any(bufp + 1, c))
     183:                 goto illch;
     184:             if (!dquote) {
     185:                 recovered();
     186:                 dquote++;
     187:                 yerror("Character/string delimiter is '");
     188:             }
     189:         case '\'':
     190:         case '#':
     191:             delim = c;
     192:             do {
     193:                 do {
     194:                     c = getchar();
     195:                     if (c == '\n') {
     196:                         yerror("Unmatched %c for string", delim);
     197:                         if (cp == token)
     198:                             *cp++ = ' ', cp++;
     199:                         break;
     200:                     }
     201:                     *cp++ = c;
     202:                 } while (c != delim);
     203:                 c = getchar();
     204:             } while (c == delim);
     205:             *--cp = 0;
     206:             if (cp == token) {
     207:                 yerror("Null string not allowed");
     208:                 *cp++ = ' ';
     209:                 *cp++ = 0;
     210:             }
     211:             yysavc = c;
     212:             yylval = copystr(token);
     213:             return (YSTRING);
     214:         case '.':
     215:             c = getchar();
     216:             if (c == '.')
     217:                 return (YDOTDOT);
     218:             if (digit(c)) {
     219:                 recovered();
     220:                 yerror("Digits required before decimal point");
     221:                 *cp++ = '0';
     222:                 goto infpnumb;
     223:             }
     224:             yysavc = c;
     225:             return ('.');
     226:         case '{':
     227:             /*
     228: 			 * { ... } comment
     229: 			 */
     230: #ifdef PXP
     231:             getcm(c);
     232: #endif
     233: #ifdef PI
     234:             c = options();
     235:             while (c != '}') {
     236:                 if (c <= 0)
     237:                     goto nonterm;
     238:                 if (c == '{') {
     239:                     warning();
     240:                     yyset();
     241:                     yerror("{ in a { ... } comment");
     242:                 }
     243:                 c = getchar();
     244:             }
     245: #endif
     246:             c = getchar();
     247:             goto next;
     248:         case '(':
     249:             if ((c = getchar()) == '*') {
     250:                 /*
     251: 				 * (* ... *) comment
     252: 				 */
     253: #ifdef PXP
     254:                 getcm(c);
     255:                 c = getchar();
     256:                 goto next;
     257: #endif
     258: #ifdef PI
     259:                 c = options();
     260:                 for (;;) {
     261:                     if (c < 0) {
     262: nonterm:
     263:                         yerror("Comment does not terminate - QUIT");
     264:                         pexit(ERRS);
     265:                     }
     266:                     if (c == '(' && (c = getchar()) == '*') {
     267:                         warning();
     268:                         yyset();
     269:                         yerror("(* in a (* ... *) comment");
     270:                     }
     271:                     if (c == '*') {
     272:                         if ((c = getchar()) != ')')
     273:                             continue;
     274:                         c = getchar();
     275:                         goto next;
     276:                     }
     277:                     c = getchar();
     278:                 }
     279: #endif
     280:             }
     281:             yysavc = c;
     282:             c = '(';
     283:         case ';':
     284:         case ',':
     285:         case ':':
     286:         case '=':
     287:         case '*':
     288:         case '+':
     289:         case '/':
     290:         case '-':
     291:         case '|':
     292:         case '&':
     293:         case ')':
     294:         case '[':
     295:         case ']':
     296:         case '<':
     297:         case '>':
     298:         case '~':
     299:         case '^':
     300:             return (c);
     301:         default:
     302:             switch (c) {
     303:                 case YDOTDOT:
     304:                     return (c);
     305:                 case '\n':
     306:                     c = getchar();
     307: #ifdef PXP
     308:                     yytokcnt++;
     309: #endif
     310:                     goto next;
     311:                 case '\f':
     312:                     c = getchar();
     313:                     goto next;
     314:             }
     315:             if (c <= 0)
     316:                 return (YEOF);
     317: illch:
     318:             do
     319:                 yysavc = getchar();
     320:             while (yysavc == c);
     321:             yylval = c;
     322:             return (YILLCH);
     323:     }
     324: }
     325:
     326: yyset()
     327: {
     328:
     329:     yyecol = yycol;
     330:     yyeline = yyline;
     331:     yyefile = filename;
     332:     yyseekp = yylinpt;
     333: }
     334:
     335: /*
     336:  * Setuflg trims the current
     337:  * input line to at most 72 chars
     338:  * for the u option.
     339:  */
     340: setuflg()
     341: {
     342:
     343:     if (charbuf[71] != '\n') {
     344:         charbuf[72] = '\n';
     345:         charbuf[73] = 0;
     346:     }
     347: }

#### Defined functions

setuflg defined in line 340; used 1 times

- in /usr/src/ucb/pascal/pxp/yyget.c line 166

unyylex defined in line 27; used 5 times

- in /usr/src/ucb/pascal/pxp/yypanic.c line 85, 135, 152
- in /usr/src/ucb/pascal/pxp/yyrecover.c line 482-484(2)

yylex defined in line 38; used 13 times

- in /usr/src/ucb/pascal/pxp/pas.y line 502-507(2)
- in /usr/src/ucb/pascal/pxp/yypanic.c line 45-46(2), 59, 93, 138
- in /usr/src/ucb/pascal/pxp/yyparse.c line 54, 93, 120
- in /usr/src/ucb/pascal/pxp/yyrecover.c line 221, 233, 489

yyset defined in line 326; used 4 times

- in line 145, 165, 240, 268

#### Defined variables

Yla defined in line 25; used 3 times

- in line 33(2), 48

yylacnt defined in line 21; used 7 times

- in line 31-34(3), 46-48(3)
- in /usr/src/ucb/pascal/pxp/tree.c line 150

#### Defined macros

YYLASIZ defined in line 23; used 2 times

- in line 25, 31

Last modified: 1986-06-01 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1201 |