home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / TOP / USR / SRC / scpp.t.Z / scpp.t / lex.c < prev    next >
C/C++ Source or Header  |  2009-11-06  |  19KB  |  786 lines

  1. #include <stdio.h>
  2. #define U(x) (x)
  3. #define NLSTATE yyprevious=YYNEWLINE
  4. #define BEGIN yybgin = yysvec + 1 +
  5. #define INITIAL 0
  6. #define YYLERR yysvec
  7. #define YYSTATE (yyestate-yysvec-1)
  8. #define YYOPTIM 1
  9. #define LEXDEBUG 1
  10. #define YYLMAX 200
  11. #define output(c) putc(c,yyout)
  12. #define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==13?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
  13. #define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
  14. #define yymore() (yymorfg=1)
  15. #define ECHO fprintf(yyout, "%s",yytext)
  16. #define REJECT { nstr = yyreject(); goto yyfussy;}
  17. int yyleng; extern char yytext[];
  18. int yymorfg;
  19. extern char *yysptr, yysbuf[];
  20. int yytchar;
  21. FILE *yyin = {stdin}, *yyout = {stdout};
  22. extern int yylineno;
  23. struct yysvf { 
  24.     struct yywork *yystoff;
  25.     struct yysvf *yyother;
  26.     int *yystops;};
  27. struct yysvf *yyestate;
  28. extern struct yysvf yysvec[], *yybgin;
  29. /*
  30.  * scpp - selective C preprocessor
  31.  *  Lexical scanner
  32.  *
  33.  * Copyright (c) 1985 by
  34.  * Tektronix, Incorporated Beaverton, Oregon 97077
  35.  * All rights reserved.
  36.  *
  37.  * Permission is hereby granted for personal, non-commercial
  38.  * reproduction and use of this program, provided that this
  39.  * notice and all copyright notices are included in any copy.
  40.  */
  41.  
  42. # include <stdio.h>
  43.  
  44. # undef input
  45. # undef unput
  46. # define input() (*nxtin == ATTN ? nxtc() : *nxtin++)
  47. # define unput(c) unc(c)
  48.  
  49. # include "scpp.h"
  50. # include "y.tab.h"
  51.  
  52. int lasttok = NL;    /* used to detect ^# when lex can't    */
  53. # define yield(t) lasttok = t; questr(yytext, yyleng); return(t)
  54.  
  55. /*
  56.  * All input to higher levels of scpp is provided exclusively by this
  57.  *  lexical analyzer, xxlex().
  58.  * This routine is called xxlex() rather than xxlex() because the "#if"
  59.  *  expression parser uses a slightly different lexical analyzer (which
  60.  *  calls xxlex()).
  61.  */
  62.  
  63. #define YYNEWLINE 13
  64. xxlex(){
  65. int nstr; extern int yyprevious;
  66. while((nstr = yylook()) >= 0)
  67. yyfussy: switch(nstr){
  68. case 0:
  69. if(yywrap()) return(0); break;
  70. case 1:
  71. {yield(LT);}
  72. break;
  73. case 2:
  74. {yield(LE);}
  75. break;
  76. case 3:
  77. {yield(GT);}
  78. break;
  79. case 4:
  80. {yield(GE);}
  81. break;
  82. case 5:
  83. {yield(CM);}
  84. break;
  85. case 6:
  86. {yield(DIV);}
  87. break;
  88. case 7:
  89. {yield(MOD);}
  90. break;
  91. case 8:
  92. {yield(PLUS);}
  93. break;
  94. case 9:
  95. {yield(MINUS);}
  96. break;
  97. case 10:
  98. {yield(LS);}
  99. break;
  100. case 11:
  101. {yield(RS);}
  102. break;
  103. case 12:
  104. {yield(MUL);}
  105. break;
  106. case 13:
  107. {yield(EQ);}
  108. break;
  109. case 14:
  110. {yield(NE);}
  111. break;
  112. case 15:
  113. {yield(AND);}
  114. break;
  115. case 16:
  116. {yield(OR);}
  117. break;
  118. case 17:
  119. {yield(ER);}
  120. break;
  121. case 18:
  122. {yield(ANDAND);}
  123. break;
  124. case 19:
  125. {yield(OROR);}
  126. break;
  127. case 20:
  128. {yield(QUEST);}
  129. break;
  130. case 21:
  131. {yield(COLON);}
  132. break;
  133. case 22:
  134. {yield(NOT);}
  135. break;
  136. case 23:
  137. {yield(COMPL);}
  138. break;
  139. case 24:
  140. {yield(LP);}
  141. break;
  142. case 25:
  143. {yield(RP);}
  144. break;
  145. case 26:
  146. {yield(CM);}
  147. break;
  148. case 27:
  149. {yield(WHITE);    /* whitespace */}
  150. break;
  151. case 28:
  152. {/* escaped newline */
  153.         if (curfile->af_raw) {
  154.             curfile->af_line++;
  155.         }
  156.         yield(QNL);
  157.     }
  158. break;
  159. case 29:
  160. {/* unescaped newline */
  161.         if (curfile->af_raw) {
  162.             curfile->af_line++;
  163.         }
  164.         yield(NL);
  165.     }
  166. break;
  167. case 30:
  168. {yield(INT); /* hex constant */}
  169. break;
  170. case 31:
  171.     {yield(INT); /* decimal or octal constant */}
  172. break;
  173. case 32:
  174.     case 33:
  175. case 34:
  176. {yield(FLOAT); /* floating constant */}
  177. break;
  178. case 35:
  179. {yield(IDENT); /* identifier */}
  180. break;
  181. case 36:
  182. {yield(QUOTE);}
  183. break;
  184. case 37:
  185. {yield(DQUOTE);}
  186. break;
  187. case 38:
  188. {yield(BACKS);}
  189. break;
  190. case 39:
  191. {yield(OPENC); /* start (open) comment */}
  192. break;
  193. case 40:
  194. {yield(CLOSEC);/* finish (close) comment */}
  195. break;
  196. case 41:
  197. {/*
  198.       * a control line if preceeded immediately by a newline,
  199.       *  even if that newline was the result of macro interpretation.
  200.       */
  201.         if (lasttok == NL) {
  202.             yield(POUNDLINE);
  203.         }
  204.         yield(OTHER);
  205.     }
  206. break;
  207. case 42:
  208. {yield(OTHER);}
  209. break;
  210. case -1:
  211. break;
  212. default:
  213. fprintf(yyout,"bad switch yylook %d",nstr);
  214. } return(0); }
  215. /* end of xxlex */
  216. int yyvstop[] = {
  217. 0,
  218. /* actions for state 2 */
  219. 42,
  220. 0,
  221. /* actions for state 3 */
  222. 27,
  223. 42,
  224. 0,
  225. /* actions for state 4 */
  226. 29,
  227. 0,
  228. /* actions for state 5 */
  229. 22,
  230. 42,
  231. 0,
  232. /* actions for state 6 */
  233. 37,
  234. 42,
  235. 0,
  236. /* actions for state 7 */
  237. 41,
  238. 42,
  239. 0,
  240. /* actions for state 8 */
  241. 7,
  242. 42,
  243. 0,
  244. /* actions for state 9 */
  245. 15,
  246. 42,
  247. 0,
  248. /* actions for state 10 */
  249. 36,
  250. 42,
  251. 0,
  252. /* actions for state 11 */
  253. 24,
  254. 42,
  255. 0,
  256. /* actions for state 12 */
  257. 25,
  258. 42,
  259. 0,
  260. /* actions for state 13 */
  261. 12,
  262. 42,
  263. 0,
  264. /* actions for state 14 */
  265. 8,
  266. 42,
  267. 0,
  268. /* actions for state 15 */
  269. 5,
  270. 26,
  271. 42,
  272. 0,
  273. /* actions for state 16 */
  274. 9,
  275. 42,
  276. 0,
  277. /* actions for state 17 */
  278. 42,
  279. 0,
  280. /* actions for state 18 */
  281. 6,
  282. 42,
  283. 0,
  284. /* actions for state 19 */
  285. 31,
  286. 42,
  287. 0,
  288. /* actions for state 20 */
  289. 31,
  290. 42,
  291. 0,
  292. /* actions for state 21 */
  293. 21,
  294. 42,
  295. 0,
  296. /* actions for state 22 */
  297. 1,
  298. 42,
  299. 0,
  300. /* actions for state 23 */
  301. 42,
  302. 0,
  303. /* actions for state 24 */
  304. 3,
  305. 42,
  306. 0,
  307. /* actions for state 25 */
  308. 20,
  309. 42,
  310. 0,
  311. /* actions for state 26 */
  312. 35,
  313. 42,
  314. 0,
  315. /* actions for state 27 */
  316. 38,
  317. 42,
  318. 0,
  319. /* actions for state 28 */
  320. 17,
  321. 42,
  322. 0,
  323. /* actions for state 29 */
  324. 16,
  325. 42,
  326. 0,
  327. /* actions for state 30 */
  328. 23,
  329. 42,
  330. 0,
  331. /* actions for state 31 */
  332. 27,
  333. 0,
  334. /* actions for state 32 */
  335. 14,
  336. 0,
  337. /* actions for state 33 */
  338. 18,
  339. 0,
  340. /* actions for state 34 */
  341. 40,
  342. 0,
  343. /* actions for state 35 */
  344. 33,
  345. 0,
  346. /* actions for state 36 */
  347. 39,
  348. 0,
  349. /* actions for state 37 */
  350. 34,
  351. 0,
  352. /* actions for state 38 */
  353. 31,
  354. 0,
  355. /* actions for state 39 */
  356. 32,
  357. 0,
  358. /* actions for state 40 */
  359. 31,
  360. 0,
  361. /* actions for state 42 */
  362. 10,
  363. 0,
  364. /* actions for state 43 */
  365. 2,
  366. 0,
  367. /* actions for state 44 */
  368. 13,
  369. 0,
  370. /* actions for state 45 */
  371. 4,
  372. 0,
  373. /* actions for state 46 */
  374. 11,
  375. 0,
  376. /* actions for state 47 */
  377. 35,
  378. 0,
  379. /* actions for state 48 */
  380. 28,
  381. 0,
  382. /* actions for state 49 */
  383. 19,
  384. 0,
  385. /* actions for state 50 */
  386. 33,
  387. 0,
  388. /* actions for state 51 */
  389. 34,
  390. 0,
  391. /* actions for state 53 */
  392. 32,
  393. 0,
  394. /* actions for state 54 */
  395. 30,
  396. 0,
  397. /* actions for state 56 */
  398. 33,
  399. 0,
  400. /* actions for state 58 */
  401. 34,
  402. 0,
  403. /* actions for state 59 */
  404. 30,
  405. 0,
  406. 0};
  407. #define YYTYPE char
  408. struct yywork { YYTYPE verify, advance; } yycrank[] = {
  409. 0,0,    0,0,    1,3,    0,0,    
  410. 0,0,    0,0,    0,0,    0,0,    
  411. 0,0,    0,0,    1,4,    0,0,    
  412. 0,0,    0,0,    1,5,    0,0,    
  413. 0,0,    0,0,    0,0,    0,0,    
  414. 0,0,    0,0,    0,0,    0,0,    
  415. 0,0,    0,0,    0,0,    0,0,    
  416. 0,0,    28,49,    0,0,    0,0,    
  417. 0,0,    0,0,    1,6,    1,7,    
  418. 1,8,    4,32,    1,9,    1,10,    
  419. 1,11,    1,12,    1,13,    1,14,    
  420. 1,15,    1,16,    1,17,    1,18,    
  421. 1,19,    1,20,    1,21,    1,21,    
  422. 1,21,    1,21,    1,21,    1,21,    
  423. 1,21,    1,21,    1,21,    1,22,    
  424. 4,32,    1,23,    1,24,    1,25,    
  425. 1,26,    6,33,    1,27,    10,34,    
  426. 14,35,    19,37,    1,27,    0,0,    
  427. 1,27,    0,0,    0,0,    0,0,    
  428. 0,0,    1,27,    18,36,    18,36,    
  429. 18,36,    18,36,    18,36,    18,36,    
  430. 18,36,    18,36,    18,36,    18,36,    
  431. 23,43,    23,44,    24,45,    25,46,    
  432. 25,47,    1,28,    0,0,    1,29,    
  433. 53,54,    53,54,    53,54,    53,54,    
  434. 53,54,    53,54,    53,54,    53,54,    
  435. 53,54,    53,54,    0,0,    0,0,    
  436. 20,38,    0,0,    20,39,    20,39,    
  437. 20,39,    20,39,    20,39,    20,39,    
  438. 20,39,    20,39,    20,39,    20,39,    
  439. 0,0,    0,0,    36,51,    0,0,    
  440. 0,0,    1,30,    0,0,    1,31,    
  441. 2,6,    2,7,    2,8,    20,40,    
  442. 2,9,    2,10,    2,11,    2,12,    
  443. 2,13,    2,14,    20,41,    2,16,    
  444. 2,17,    2,18,    2,19,    30,50,    
  445. 2,21,    2,21,    2,21,    2,21,    
  446. 2,21,    2,21,    2,21,    2,21,    
  447. 2,21,    2,22,    36,51,    2,23,    
  448. 2,24,    2,25,    2,26,    55,60,    
  449. 0,0,    0,0,    0,0,    20,40,    
  450. 0,0,    0,0,    0,0,    0,0,    
  451. 0,0,    21,38,    20,41,    21,39,    
  452. 21,39,    21,39,    21,39,    21,39,    
  453. 21,39,    21,39,    21,39,    21,39,    
  454. 21,39,    0,0,    20,42,    0,0,    
  455. 0,0,    0,0,    0,0,    2,28,    
  456. 0,0,    2,29,    0,0,    55,60,    
  457. 21,40,    0,0,    0,0,    40,53,    
  458. 0,0,    40,53,    0,0,    21,41,    
  459. 40,54,    40,54,    40,54,    40,54,    
  460. 40,54,    40,54,    40,54,    40,54,    
  461. 40,54,    40,54,    0,0,    0,0,    
  462. 0,0,    0,0,    0,0,    0,0,    
  463. 0,0,    0,0,    0,0,    2,30,    
  464. 0,0,    2,31,    0,0,    0,0,    
  465. 21,40,    0,0,    0,0,    0,0,    
  466. 0,0,    0,0,    0,0,    21,41,    
  467. 27,48,    27,48,    27,48,    27,48,    
  468. 27,48,    27,48,    27,48,    27,48,    
  469. 27,48,    27,48,    0,0,    0,0,    
  470. 0,0,    0,0,    0,0,    0,0,    
  471. 0,0,    27,48,    27,48,    27,48,    
  472. 27,48,    27,48,    27,48,    27,48,    
  473. 27,48,    27,48,    27,48,    27,48,    
  474. 27,48,    27,48,    27,48,    27,48,    
  475. 27,48,    27,48,    27,48,    27,48,    
  476. 27,48,    27,48,    27,48,    27,48,    
  477. 27,48,    27,48,    27,48,    0,0,    
  478. 0,0,    0,0,    0,0,    27,48,    
  479. 0,0,    27,48,    27,48,    27,48,    
  480. 27,48,    27,48,    27,48,    27,48,    
  481. 27,48,    27,48,    27,48,    27,48,    
  482. 27,48,    27,48,    27,48,    27,48,    
  483. 27,48,    27,48,    27,48,    27,48,    
  484. 27,48,    27,48,    27,48,    27,48,    
  485. 27,48,    27,48,    27,48,    38,38,    
  486. 38,38,    38,38,    38,38,    38,38,    
  487. 38,38,    38,38,    38,38,    38,38,    
  488. 38,38,    42,55,    42,55,    42,55,    
  489. 42,55,    42,55,    42,55,    42,55,    
  490. 42,55,    42,55,    42,55,    0,0,    
  491. 38,52,    0,0,    0,0,    0,0,    
  492. 0,0,    0,0,    42,55,    42,55,    
  493. 42,55,    42,55,    42,55,    42,55,    
  494. 51,56,    0,0,    51,56,    0,0,    
  495. 0,0,    51,57,    51,57,    51,57,    
  496. 51,57,    51,57,    51,57,    51,57,    
  497. 51,57,    51,57,    51,57,    0,0,    
  498. 0,0,    0,0,    0,0,    0,0,    
  499. 38,52,    0,0,    0,0,    0,0,    
  500. 0,0,    0,0,    42,55,    42,55,    
  501. 42,55,    42,55,    42,55,    42,55,    
  502. 52,58,    0,0,    52,58,    0,0,    
  503. 0,0,    52,59,    52,59,    52,59,    
  504. 52,59,    52,59,    52,59,    52,59,    
  505. 52,59,    52,59,    52,59,    56,57,    
  506. 56,57,    56,57,    56,57,    56,57,    
  507. 56,57,    56,57,    56,57,    56,57,    
  508. 56,57,    58,59,    58,59,    58,59,    
  509. 58,59,    58,59,    58,59,    58,59,    
  510. 58,59,    58,59,    58,59,    0,0,    
  511. 0,0};
  512. struct yysvf yysvec[] = {
  513. 0,    0,    0,
  514. yycrank+-1,    0,        0,            /* state 0 */
  515. yycrank+-95,    yysvec+1,    0,            /* state 1 */
  516. yycrank+0,    0,        yyvstop+1,        /* state 2 */
  517. yycrank+28,    0,        yyvstop+3,        /* state 3 */
  518. yycrank+0,    0,        yyvstop+6,        /* state 4 */
  519. yycrank+4,    0,        yyvstop+8,        /* state 5 */
  520. yycrank+0,    0,        yyvstop+11,        /* state 6 */
  521. yycrank+0,    0,        yyvstop+14,        /* state 7 */
  522. yycrank+0,    0,        yyvstop+17,        /* state 8 */
  523. yycrank+29,    0,        yyvstop+20,        /* state 9 */
  524. yycrank+0,    0,        yyvstop+23,        /* state 10 */
  525. yycrank+0,    0,        yyvstop+26,        /* state 11 */
  526. yycrank+0,    0,        yyvstop+29,        /* state 12 */
  527. yycrank+21,    0,        yyvstop+32,        /* state 13 */
  528. yycrank+0,    0,        yyvstop+35,        /* state 14 */
  529. yycrank+0,    0,        yyvstop+38,        /* state 15 */
  530. yycrank+0,    0,        yyvstop+42,        /* state 16 */
  531. yycrank+30,    0,        yyvstop+45,        /* state 17 */
  532. yycrank+27,    0,        yyvstop+47,        /* state 18 */
  533. yycrank+62,    0,        yyvstop+50,        /* state 19 */
  534. yycrank+123,    0,        yyvstop+53,        /* state 20 */
  535. yycrank+0,    0,        yyvstop+56,        /* state 21 */
  536. yycrank+28,    0,        yyvstop+59,        /* state 22 */
  537. yycrank+29,    0,        yyvstop+62,        /* state 23 */
  538. yycrank+30,    0,        yyvstop+64,        /* state 24 */
  539. yycrank+0,    0,        yyvstop+67,        /* state 25 */
  540. yycrank+184,    0,        yyvstop+70,        /* state 26 */
  541. yycrank+16,    0,        yyvstop+73,        /* state 27 */
  542. yycrank+0,    0,        yyvstop+76,        /* state 28 */
  543. yycrank+19,    0,        yyvstop+79,        /* state 29 */
  544. yycrank+0,    0,        yyvstop+82,        /* state 30 */
  545. yycrank+0,    yysvec+4,    yyvstop+85,        /* state 31 */
  546. yycrank+0,    0,        yyvstop+87,        /* state 32 */
  547. yycrank+0,    0,        yyvstop+89,        /* state 33 */
  548. yycrank+0,    0,        yyvstop+91,        /* state 34 */
  549. yycrank+53,    yysvec+18,    yyvstop+93,        /* state 35 */
  550. yycrank+0,    0,        yyvstop+95,        /* state 36 */
  551. yycrank+259,    0,        yyvstop+97,        /* state 37 */
  552. yycrank+0,    yysvec+21,    yyvstop+99,        /* state 38 */
  553. yycrank+152,    0,        yyvstop+101,        /* state 39 */
  554. yycrank+0,    0,        yyvstop+103,        /* state 40 */
  555. yycrank+269,    0,        0,            /* state 41 */
  556. yycrank+0,    0,        yyvstop+105,        /* state 42 */
  557. yycrank+0,    0,        yyvstop+107,        /* state 43 */
  558. yycrank+0,    0,        yyvstop+109,        /* state 44 */
  559. yycrank+0,    0,        yyvstop+111,        /* state 45 */
  560. yycrank+0,    0,        yyvstop+113,        /* state 46 */
  561. yycrank+0,    yysvec+27,    yyvstop+115,        /* state 47 */
  562. yycrank+0,    0,        yyvstop+117,        /* state 48 */
  563. yycrank+0,    0,        yyvstop+119,        /* state 49 */
  564. yycrank+297,    0,        yyvstop+121,        /* state 50 */
  565. yycrank+329,    0,        yyvstop+123,        /* state 51 */
  566. yycrank+48,    0,        0,            /* state 52 */
  567. yycrank+0,    yysvec+53,    yyvstop+125,        /* state 53 */
  568. yycrank+83,    yysvec+42,    yyvstop+127,        /* state 54 */
  569. yycrank+339,    0,        0,            /* state 55 */
  570. yycrank+0,    yysvec+56,    yyvstop+129,        /* state 56 */
  571. yycrank+349,    0,        0,            /* state 57 */
  572. yycrank+0,    yysvec+58,    yyvstop+131,        /* state 58 */
  573. yycrank+0,    0,        yyvstop+133,        /* state 59 */
  574. 0,    0,    0};
  575. struct yywork *yytop = yycrank+406;
  576. struct yysvf *yybgin = yysvec+1;
  577. char yymatch[] = {
  578. 00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  579. 01  ,011 ,01  ,01  ,01  ,015 ,01  ,01  ,
  580. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  581. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  582. 011 ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  583. 01  ,01  ,01  ,'+' ,01  ,'+' ,01  ,01  ,
  584. '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
  585. '0' ,'0' ,01  ,01  ,01  ,01  ,01  ,01  ,
  586. 01  ,'A' ,'A' ,'A' ,'A' ,'E' ,'A' ,'G' ,
  587. 'G' ,'G' ,'G' ,'G' ,'L' ,'G' ,'G' ,'G' ,
  588. 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
  589. 'G' ,'G' ,'G' ,01  ,01  ,01  ,01  ,'G' ,
  590. 01  ,'A' ,'A' ,'A' ,'A' ,'E' ,'A' ,'G' ,
  591. 'G' ,'G' ,'G' ,'G' ,'L' ,'G' ,'G' ,'G' ,
  592. 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
  593. 'G' ,'G' ,'G' ,01  ,01  ,01  ,01  ,01  ,
  594. 0};
  595. char yyextra[] = {
  596. 0,0,0,0,0,0,0,0,
  597. 0,0,0,0,0,0,0,0,
  598. 0,0,0,0,0,0,0,0,
  599. 0,0,0,0,0,0,0,0,
  600. 0,0,0,0,0,0,0,0,
  601. 0,0,0,0,0,0,0,0,
  602. 0};
  603.  
  604. /*      @(#)    1.1     */
  605. int yylineno =1;
  606. # define YYU(x) x
  607. # define NLSTATE yyprevious=YYNEWLINE
  608. char yytext[YYLMAX];
  609. struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
  610. char yysbuf[YYLMAX];
  611. char *yysptr = yysbuf;
  612. int *yyfnd;
  613. extern struct yysvf *yyestate;
  614. int yyprevious = YYNEWLINE;
  615. yylook(){
  616.         register struct yysvf *yystate, **lsp;
  617.         register struct yywork *yyt;
  618.         struct yysvf *yyz;
  619.         int yych, yyfirst;
  620.         struct yywork *yyr;
  621. # ifdef LEXDEBUG
  622.         int debug;
  623. # endif
  624.         char *yylastch;
  625.         /* start off machines */
  626. # ifdef LEXDEBUG
  627.         debug = 0;
  628. # endif
  629.         yyfirst=1;
  630.         if (!yymorfg)
  631.                 yylastch = yytext;
  632.         else {
  633.                 yymorfg=0;
  634.                 yylastch = yytext+yyleng;
  635.                 }
  636.         for(;;){
  637.                 lsp = yylstate;
  638.                 yyestate = yystate = yybgin;
  639.                 if (yyprevious==YYNEWLINE) yystate++;
  640.                 for (;;){
  641. # ifdef LEXDEBUG
  642.                         if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
  643. # endif
  644.                         yyt = yystate->yystoff;
  645.                         if(yyt == yycrank && !yyfirst){  /* may not be any transitions */
  646.                                 yyz = yystate->yyother;
  647.                                 if(yyz == 0)break;
  648.                                 if(yyz->yystoff == yycrank)break;
  649.                                 }
  650.                         *yylastch++ = yych = input();
  651.                         yyfirst=0;
  652.                 tryagain:
  653. # ifdef LEXDEBUG
  654.                         if(debug){
  655.                                 fprintf(yyout,"char ");
  656.                                 allprint(yych);
  657.                                 putchar('\n');
  658.                                 }
  659. # endif
  660.                         yyr = yyt;
  661.                         if ( (int)yyt > (int)yycrank){
  662.                                 yyt = yyr + yych;
  663.                                 if (yyt <= yytop && yyt->verify+yysvec == yystate){
  664.                                         if(yyt->advance+yysvec == YYLERR)       /* error transitions */
  665.                                                 {unput(*--yylastch);break;}
  666.                                         *lsp++ = yystate = yyt->advance+yysvec;
  667.                                         goto contin;
  668.                                         }
  669.                                 }
  670. # ifdef YYOPTIM
  671.                         else if((int)yyt < (int)yycrank) {              /* r < yycrank */
  672.                                 yyt = yyr = yycrank+(yycrank-yyt);
  673. # ifdef LEXDEBUG
  674.                                 if(debug)fprintf(yyout,"compressed state\n");
  675. # endif
  676.                                 yyt = yyt + yych;
  677.                                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  678.                                         if(yyt->advance+yysvec == YYLERR)       /* error transitions */
  679.                                                 {unput(*--yylastch);break;}
  680.                                         *lsp++ = yystate = yyt->advance+yysvec;
  681.                                         goto contin;
  682.                                         }
  683.                                 yyt = yyr + YYU(yymatch[yych]);
  684. # ifdef LEXDEBUG
  685.                                 if(debug){
  686.                                         fprintf(yyout,"try fall back character ");
  687.                                         allprint(YYU(yymatch[yych]));
  688.                                         putchar('\n');
  689.                                         }
  690. # endif
  691.                                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  692.                                         if(yyt->advance+yysvec == YYLERR)       /* error transition */
  693.                                                 {unput(*--yylastch);break;}
  694.                                         *lsp++ = yystate = yyt->advance+yysvec;
  695.                                         goto contin;
  696.                                         }
  697.                                 }
  698.                         if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
  699. # ifdef LEXDEBUG
  700.                                 if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
  701. # endif
  702.                                 goto tryagain;
  703.                                 }
  704. # endif
  705.                         else
  706.                                 {unput(*--yylastch);break;}
  707.                 contin:
  708. # ifdef LEXDEBUG
  709.                         if(debug){
  710.                                 fprintf(yyout,"state %d char ",yystate-yysvec-1);
  711.                                 allprint(yych);
  712.                                 putchar('\n');
  713.                                 }
  714. # endif
  715.                         ;
  716.                         }
  717. # ifdef LEXDEBUG
  718.                 if(debug){
  719.                         fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
  720.                         allprint(yych);
  721.                         putchar('\n');
  722.                         }
  723. # endif
  724.                 while (lsp-- > yylstate){
  725.                         *yylastch-- = 0;
  726.                         if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
  727.                                 yyolsp = lsp;
  728.                                 if(yyextra[*yyfnd]){            /* must backup */
  729.                                         while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
  730.                                                 lsp--;
  731.                                                 unput(*yylastch--);
  732.                                                 }
  733.                                         }
  734.                                 yyprevious = YYU(*yylastch);
  735.                                 yylsp = lsp;
  736.                                 yyleng = yylastch-yytext+1;
  737.                                 yytext[yyleng] = 0;
  738. # ifdef LEXDEBUG
  739.                                 if(debug){
  740.                                         fprintf(yyout,"\nmatch ");
  741.                                         sprint(yytext);
  742.                                         fprintf(yyout," action %d\n",*yyfnd);
  743.                                         }
  744. # endif
  745.                                 return(*yyfnd++);
  746.                                 }
  747.                         unput(*yylastch);
  748.                         }
  749.                 if (yytext[0] == 0  /* && feof(yyin) */)
  750.                         {
  751.                         yysptr=yysbuf;
  752.                         return(0);
  753.                         }
  754.                 yyprevious = yytext[0] = input();
  755.                 if (yyprevious>0)
  756.                         output(yyprevious);
  757.                 yylastch=yytext;
  758. # ifdef LEXDEBUG
  759.                 if(debug)putchar('\n');
  760. # endif
  761.                 }
  762.         }
  763. yyback(p, m)
  764.         int *p;
  765. {
  766. if (p==0) return(0);
  767. while (*p)
  768.         {
  769.         if (*p++ == m)
  770.                 return(1);
  771.         }
  772. return(0);
  773. }
  774.         /* the following are only used in the lex library */
  775. yyinput(){
  776.         return(input());
  777.         }
  778. yyoutput(c)
  779.   int c; {
  780.         output(c);
  781.         }
  782. yyunput(c)
  783.    int c; {
  784.         unput(c);
  785.         }
  786.