home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Mail / SaveFromMail1_03 / Source / import_export_mailrc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-12  |  14.9 KB  |  841 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 YYLMAX 200
  10. # define output(c) putc(c,yyout)
  11. # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
  12. # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
  13. # define yymore() (yymorfg=1)
  14. # define ECHO fprintf(yyout, "%s",yytext)
  15. # define REJECT { nstr = yyreject(); goto yyfussy;}
  16. int yyleng; extern char yytext[];
  17. int yymorfg;
  18. extern char *yysptr, yysbuf[];
  19. int yytchar;
  20. FILE *yyin ={stdin}, *yyout ={stdout};
  21. extern int yylineno;
  22. struct yysvf { 
  23.     struct yywork *yystoff;
  24.     struct yysvf *yyother;
  25.     int *yystops;};
  26. struct yysvf *yyestate;
  27. extern struct yysvf yysvec[], *yybgin;
  28. /*
  29.  * import_export_mailrc
  30.  *
  31.  *    This program is used to convert .mailrc mail configuration file to
  32.  *      .mailalias NeXTMail configuration files and back.
  33.  * 
  34.  * Copyright (C) 1991 Roberto Di Cosmo
  35.  *
  36.  * Everyone is granted permission to copy, modify and redistribute
  37.  * this file, as far as this notice is preserved on all copies.
  38.  *
  39.  * Written by:
  40.  *      Roberto Di Cosmo <dicosmo@dmi.ens.fr>
  41.  *      Dipartimento di Informatica     LIENS
  42.  *      Universita' di Pisa             Ecole Normale Superieure
  43.  *      Corso Italia, 40                45, Rue d'Ulm
  44.  *      Pisa ITALY                      Paris FRANCE
  45.  *
  46.  * $Header: /users/formel2/dicosmo/Projects/SAVEFROMMAIL/RCS/import_export_mailrc.l,v 1.2 92/05/06 14:20:25 dicosmo Exp $
  47.  *
  48.  * $Log:    import_export_mailrc.l,v $
  49.  * Revision 1.2  92/05/06  14:20:25  dicosmo
  50.  * Conversion engine il Lex. Common body for command line
  51.  * and NeXTStep application.
  52.  * 
  53.  *
  54.  */
  55.  
  56. int     skipblanks =  1;
  57. char    *aliasname = "";
  58. char    *groupbody = "";
  59. char    *aliasbody = "";
  60. char    *aliases   = "";
  61. char    *tmp       = "";
  62. #define YES 1
  63. #define NO  0
  64. int     is_group    = NO;
  65. int     is_balanced = YES;
  66. int     l;
  67. # define NrmImp 2
  68. # define AName 4
  69. # define Addr0 6
  70. # define Addr1 8
  71. # define Addr2 10
  72. # define Sep 12
  73. # define NrmExp 14
  74. # define Copy 16
  75. # define UserAlias 18
  76. # define UserAddr 20
  77.  
  78. # define YYNEWLINE 10
  79. int yylex(){
  80. int nstr; extern int yyprevious;
  81. while((nstr = yylook()) >= 0)
  82. yyfussy: switch(nstr){
  83. case 0:
  84. if(yywrap()) return(0); break;
  85. case 1:
  86. {BEGIN AName;}
  87. break;
  88. case 2:
  89.                     ;
  90. break;
  91. case 3:
  92.                 {strcpy(aliasname,yytext); BEGIN Addr0;}
  93. break;
  94. case 4:
  95.                 {printf("***Missing alias name ...");}
  96. break;
  97. case 5:
  98.         {strcpy(tmp,"");BEGIN Addr1;}
  99. break;
  100. case 6:
  101.         {BEGIN Addr2;}
  102. break;
  103. case 7:
  104.                 {printf("***Missing body of alias %s\n",aliasname);}
  105. break;
  106. case 8:
  107.                 ;
  108. break;
  109. case 9:
  110.         {strcat(tmp,yytext);}
  111. break;
  112. case 10:
  113.                  {BEGIN Sep;}
  114. break;
  115. case 11:
  116.         {printf("***Address %s of alias %s is not properly balanced ...",aliasbody,aliasname);}
  117. break;
  118. case 12:
  119.                 ;
  120. break;
  121. case 13:
  122.         {strcpy(tmp,yytext); BEGIN Sep;}
  123. break;
  124. case 14:
  125.         {printf("***Missing alias body of %s...",aliasname);}
  126. break;
  127. case 15:
  128.         {if (is_group == YES) {strcat(groupbody,tmp);committ_import_group();is_group = NO;}
  129.                                  else {strcpy(aliasbody,tmp); committ_import_alias();}; BEGIN NrmImp;}
  130. break;
  131. case 16:
  132.         {strcat(groupbody,tmp); is_group = YES; strcat(groupbody,"\, "); strcpy(tmp,"");BEGIN Addr1;}
  133. break;
  134. case 17:
  135.             {strcat(groupbody,tmp); is_group = YES; strcat(groupbody,"\, "); BEGIN Addr2;}
  136. break;
  137. case 18:
  138.                  ;
  139. break;
  140. case 19:
  141.  {BEGIN UserAlias;}
  142. break;
  143. case 20:
  144.                {strncat(aliasname, yytext, yyleng-1); BEGIN Copy;}
  145. break;
  146. case 21:
  147.            {committ_export_alias(); BEGIN NrmExp;}
  148. break;
  149. case 22:
  150.                          {strcat(aliasbody,yytext);}
  151. break;
  152. case 23:
  153.                   {strcat(aliasname,"_");}
  154. break;
  155. case 24:
  156.               {BEGIN UserAddr;}
  157. break;
  158. case 25:
  159.                     {strcat(aliasname,yytext);}
  160. break;
  161. case 26:
  162.                  {printf("***Missing address of alias %s\n",aliasname);}
  163. break;
  164. case 27:
  165.                    ;
  166. break;
  167. case 28:
  168.      {committ_export_alias(); BEGIN NrmExp;}
  169. break;
  170. case 29:
  171.          {committ_export_alias(); BEGIN UserAlias;}
  172. break;
  173. case 30:
  174.                      {strcat(aliasbody,yytext);}
  175. break;
  176. case 31:
  177.                   {printf("***Incomplete %s address in alias %s\n",aliasbody,aliasname);}
  178. break;
  179. case -1:
  180. break;
  181. default:
  182. fprintf(yyout,"bad switch yylook %d",nstr);
  183. } return(0); }
  184. /* end of yylex */
  185.  
  186.  
  187. /*
  188.  * Commit group alias for IMPORT
  189.  */
  190.  
  191. committ_import_group()
  192. {
  193. printf("%s: %s\n", aliasname, groupbody);
  194. resetvars();
  195. }
  196.  
  197.  
  198. /*
  199.  * Commit user alias for IMPORT
  200.  */
  201.  
  202. committ_import_alias()
  203. {
  204. sprintf(tmp, "%s <%s>,", aliasname, aliasbody); 
  205. strcat(aliases, tmp);
  206. resetvars();
  207. }
  208.  
  209. /*
  210.  * Commit alias for EXPORT
  211.  */
  212.  
  213. committ_export_alias()
  214. {
  215. printf("alias %s %s\n", aliasname, aliasbody); 
  216. resetvars();
  217. }
  218.  
  219. /*
  220.  * this are the *REAL* conversion loops, that are exported...
  221.  */
  222.  
  223. void import_mailrc()
  224. {
  225.         allocfields();
  226.     initvars();
  227.         BEGIN NrmImp;
  228.         while (yylex()) {};
  229.         if ((l = strlen(aliases)) > 0) aliases[strlen(aliases)-1]=NULL;
  230.         printf("Private Users: %s\n", aliases);
  231. }
  232.  
  233. void export_mailrc()
  234. {
  235.         allocfields();
  236.     initvars();
  237.         BEGIN NrmExp;
  238.         while (yylex()) {};
  239. }
  240.  
  241. /* main()
  242. {import_mailrc();}
  243. */
  244.  
  245. allocfields()
  246. {       /* allocate memory for parser variables */
  247.         tmp       = malloc(6000);
  248.         aliasname = malloc(80);
  249.         aliasbody = malloc(1000);
  250.         groupbody = malloc(10000);
  251.         aliases   = malloc(50000); /* contains *ALL* the group aliases!!!!! */ 
  252. }
  253.  
  254. initvars()
  255. {
  256.     (void)strcpy(aliases,"");
  257.     resetvars();
  258. }
  259.  
  260. resetvars()
  261. {
  262.         (void)strcpy(tmp,       "" );   
  263.         (void)strcpy(aliasname, "" );   
  264.         (void)strcpy(aliasbody, "" );
  265.         (void)strcpy(groupbody, "" );
  266. }
  267. int yyvstop[] ={
  268. 0,
  269.  
  270. 6,
  271. 0,
  272.  
  273. 6,
  274. 0,
  275.  
  276. 6,
  277. 0,
  278.  
  279. 6,
  280. 0,
  281.  
  282. 6,
  283. 0,
  284.  
  285. 6,
  286. 0,
  287.  
  288. 6,
  289. 0,
  290.  
  291. 6,
  292. 0,
  293.  
  294. 6,
  295. 0,
  296.  
  297. 6,
  298. 0,
  299.  
  300. 6,
  301. 0,
  302.  
  303. 6,
  304. 0,
  305.  
  306. 6,
  307. 0,
  308.  
  309. 6,
  310. 0,
  311.  
  312. 6,
  313. 0,
  314.  
  315. 6,
  316. 0,
  317.  
  318. 6,
  319. 0,
  320.  
  321. 6,
  322. 0,
  323.  
  324. 6,
  325. 0,
  326.  
  327. 6,
  328. 0,
  329.  
  330. 6,
  331. 0,
  332.  
  333. 6,
  334. 0,
  335.  
  336. 2,
  337. 0,
  338.  
  339. 2,
  340. 0,
  341.  
  342. 2,
  343. 0,
  344.  
  345. 3,
  346. 0,
  347.  
  348. 4,
  349. 0,
  350.  
  351. 7,
  352. 0,
  353.  
  354. 6,
  355. 7,
  356. 0,
  357.  
  358. 5,
  359. 7,
  360. 0,
  361.  
  362. 9,
  363. 0,
  364.  
  365. 8,
  366. 0,
  367.  
  368. 11,
  369. 0,
  370.  
  371. 10,
  372. 0,
  373.  
  374. 13,
  375. 0,
  376.  
  377. 12,
  378. 0,
  379.  
  380. 14,
  381. 0,
  382.  
  383. 17,
  384. 0,
  385.  
  386. 15,
  387. 0,
  388.  
  389. 18,
  390. 0,
  391.  
  392. 18,
  393. 0,
  394.  
  395. 22,
  396. 0,
  397.  
  398. 22,
  399. 0,
  400.  
  401. 21,
  402. 0,
  403.  
  404. 25,
  405. 0,
  406.  
  407. 23,
  408. 25,
  409. 0,
  410.  
  411. 26,
  412. 0,
  413.  
  414. 24,
  415. 25,
  416. 0,
  417.  
  418. 30,
  419. 0,
  420.  
  421. 27,
  422. 30,
  423. 0,
  424.  
  425. 31,
  426. 0,
  427.  
  428. 29,
  429. 30,
  430. 0,
  431.  
  432. 6,
  433. 0,
  434.  
  435. 5,
  436. 0,
  437.  
  438. 16,
  439. 0,
  440.  
  441. 20,
  442. 0,
  443.  
  444. 23,
  445. 0,
  446.  
  447. 24,
  448. 0,
  449.  
  450. 27,
  451. 0,
  452.  
  453. 29,
  454. 0,
  455.  
  456. 28,
  457. 0,
  458.  
  459. 1,
  460. 0,
  461.  
  462. 19,
  463. 20,
  464. 0,
  465.  
  466. 19,
  467. 0,
  468. 0};
  469. # define YYTYPE unsigned char
  470. struct yywork { YYTYPE verify, advance; } yycrank[] ={
  471. 0,0,    0,0,    3,23,    0,0,    
  472. 0,0,    0,0,    5,26,    0,0,    
  473. 0,0,    7,28,    3,23,    3,0,    
  474. 4,24,    4,0,    5,0,    5,27,    
  475. 6,0,    7,29,    7,28,    9,31,    
  476. 13,38,    13,39,    11,35,    15,40,    
  477. 24,55,    42,42,    0,0,    9,32,    
  478. 9,33,    0,0,    11,36,    11,37,    
  479. 16,41,    0,0,    0,0,    26,0,    
  480. 26,0,    5,0,    0,0,    6,0,    
  481. 16,42,    16,41,    0,0,    13,38,    
  482. 0,0,    3,23,    15,40,    24,55,    
  483. 17,44,    5,26,    76,77,    10,0,    
  484. 7,28,    0,0,    12,0,    13,38,    
  485. 17,45,    17,46,    26,0,    3,23,    
  486. 0,0,    8,30,    9,0,    5,26,    
  487. 20,50,    11,0,    7,28,    10,0,    
  488. 7,30,    10,34,    12,0,    18,44,    
  489. 12,0,    18,44,    22,54,    16,41,    
  490. 9,31,    19,47,    9,0,    11,35,    
  491. 9,34,    11,0,    38,60,    11,0,    
  492. 21,51,    19,48,    19,49,    82,83,    
  493. 0,0,    16,0,    32,32,    17,45,    
  494. 21,52,    21,53,    36,36,    29,58,    
  495. 31,0,    31,0,    45,63,    45,46,    
  496. 4,25,    48,64,    35,0,    35,0,    
  497. 69,71,    17,44,    52,66,    17,44,    
  498. 57,69,    17,44,    25,57,    16,43,    
  499. 24,56,    32,32,    41,41,    43,62,    
  500. 62,70,    36,36,    29,58,    31,0,    
  501. 19,47,    45,63,    41,41,    41,41,    
  502. 48,64,    35,0,    70,72,    21,51,    
  503. 71,73,    52,66,    72,74,    31,0,    
  504. 74,75,    45,63,    19,47,    73,73,    
  505. 19,50,    35,0,    54,67,    54,68,    
  506. 75,76,    21,51,    77,78,    32,34,    
  507. 78,79,    21,54,    29,59,    31,0,    
  508. 79,80,    31,0,    80,81,    81,82,    
  509. 48,65,    35,0,    83,84,    35,0,    
  510. 0,0,    41,41,    73,73,    0,0,    
  511. 0,0,    54,67,    0,0,    0,0,    
  512. 0,0,    0,0,    0,0,    0,0,    
  513. 0,0,    0,0,    0,0,    41,61,    
  514. 0,0,    54,67,    0,0,    0,0,    
  515. 0,0,    83,84,    0,0,    0,0,    
  516. 0,0};
  517. struct yysvf yysvec[] ={
  518. 0,    0,    0,
  519. yycrank+0,    0,        yyvstop+1,
  520. yycrank+0,    0,        yyvstop+3,
  521. yycrank+-1,    0,        yyvstop+5,
  522. yycrank+-3,    yysvec+3,    yyvstop+7,
  523. yycrank+-5,    0,        yyvstop+9,
  524. yycrank+-7,    yysvec+5,    yyvstop+11,
  525. yycrank+-8,    0,        yyvstop+13,
  526. yycrank+-1,    yysvec+7,    yyvstop+15,
  527. yycrank+-18,    0,        yyvstop+17,
  528. yycrank+-7,    yysvec+9,    yyvstop+19,
  529. yycrank+-21,    0,        yyvstop+21,
  530. yycrank+-10,    yysvec+11,    yyvstop+23,
  531. yycrank+11,    0,        yyvstop+25,
  532. yycrank+0,    yysvec+13,    yyvstop+27,
  533. yycrank+14,    0,        yyvstop+29,
  534. yycrank+-31,    0,        yyvstop+31,
  535. yycrank+-47,    0,        yyvstop+33,
  536. yycrank+-11,    yysvec+17,    yyvstop+35,
  537. yycrank+-76,    0,        yyvstop+37,
  538. yycrank+-4,    yysvec+19,    yyvstop+39,
  539. yycrank+-83,    0,        yyvstop+41,
  540. yycrank+-12,    yysvec+21,    yyvstop+43,
  541. yycrank+0,    0,        yyvstop+45,
  542. yycrank+15,    0,        yyvstop+47,
  543. yycrank+2,    0,        yyvstop+49,
  544. yycrank+-26,    yysvec+5,    yyvstop+51,
  545. yycrank+0,    0,        yyvstop+53,
  546. yycrank+0,    0,        yyvstop+55,
  547. yycrank+86,    0,        yyvstop+57,
  548. yycrank+0,    0,        yyvstop+60,
  549. yycrank+-87,    yysvec+9,    yyvstop+63,
  550. yycrank+81,    0,        yyvstop+65,
  551. yycrank+0,    0,        yyvstop+67,
  552. yycrank+0,    0,        yyvstop+69,
  553. yycrank+-93,    yysvec+11,    yyvstop+71,
  554. yycrank+85,    0,        yyvstop+73,
  555. yycrank+0,    0,        yyvstop+75,
  556. yycrank+22,    yysvec+13,    yyvstop+77,
  557. yycrank+0,    0,        yyvstop+79,
  558. yycrank+0,    yysvec+15,    yyvstop+81,
  559. yycrank+-113,    0,        0,    
  560. yycrank+-16,    yysvec+41,    yyvstop+83,
  561. yycrank+-1,    yysvec+41,    0,    
  562. yycrank+0,    0,        yyvstop+85,
  563. yycrank+89,    0,        yyvstop+87,
  564. yycrank+0,    0,        yyvstop+89,
  565. yycrank+0,    0,        yyvstop+91,
  566. yycrank+92,    0,        yyvstop+93,
  567. yycrank+0,    0,        yyvstop+96,
  568. yycrank+0,    0,        yyvstop+98,
  569. yycrank+0,    0,        yyvstop+101,
  570. yycrank+97,    0,        yyvstop+103,
  571. yycrank+0,    0,        yyvstop+106,
  572. yycrank+129,    0,        yyvstop+108,
  573. yycrank+0,    yysvec+24,    0,    
  574. yycrank+0,    yysvec+25,    0,    
  575. yycrank+3,    0,        0,    
  576. yycrank+0,    yysvec+29,    yyvstop+111,
  577. yycrank+0,    0,        yyvstop+113,
  578. yycrank+0,    0,        yyvstop+115,
  579. yycrank+0,    0,        yyvstop+117,
  580. yycrank+-11,    yysvec+41,    0,    
  581. yycrank+0,    yysvec+45,    0,    
  582. yycrank+0,    yysvec+48,    yyvstop+119,
  583. yycrank+0,    0,        yyvstop+121,
  584. yycrank+0,    yysvec+52,    yyvstop+123,
  585. yycrank+0,    yysvec+54,    yyvstop+125,
  586. yycrank+0,    0,        yyvstop+127,
  587. yycrank+7,    0,        0,    
  588. yycrank+-8,    yysvec+41,    0,    
  589. yycrank+13,    0,        0,    
  590. yycrank+-33,    yysvec+41,    0,    
  591. yycrank+126,    0,        yyvstop+129,
  592. yycrank+-16,    yysvec+41,    0,    
  593. yycrank+-39,    yysvec+41,    0,    
  594. yycrank+-18,    yysvec+41,    0,    
  595. yycrank+-57,    yysvec+41,    0,    
  596. yycrank+-29,    yysvec+41,    0,    
  597. yycrank+-47,    yysvec+41,    0,    
  598. yycrank+-36,    yysvec+41,    0,    
  599. yycrank+-36,    yysvec+41,    0,    
  600. yycrank+-29,    yysvec+41,    0,    
  601. yycrank+145,    0,        yyvstop+131,
  602. yycrank+0,    yysvec+83,    yyvstop+134,
  603. 0,    0,    0};
  604. struct yywork *yytop = yycrank+177;
  605. struct yysvf *yybgin = yysvec+1;
  606. char yymatch[] ={
  607. 00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  608. 01  ,011 ,012 ,01  ,01  ,01  ,01  ,01  ,
  609. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  610. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  611. 011 ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  612. 01  ,01  ,01  ,01  ,',' ,01  ,01  ,01  ,
  613. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  614. 01  ,01  ,':' ,01  ,',' ,01  ,',' ,01  ,
  615. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  616. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  617. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  618. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  619. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  620. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  621. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  622. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  623. 0};
  624. char yyextra[] ={
  625. 0,0,0,0,0,0,0,0,
  626. 0,0,0,0,0,0,0,0,
  627. 0,0,0,0,0,0,0,0,
  628. 0,0,0,0,0,0,0,0,
  629. 0};
  630. /*    ncform    4.1    83/08/11    */
  631.  
  632. int yylineno =1;
  633. # define YYU(x) x
  634. # define NLSTATE yyprevious=YYNEWLINE
  635. char yytext[YYLMAX];
  636. struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
  637. char yysbuf[YYLMAX];
  638. char *yysptr = yysbuf;
  639. int *yyfnd;
  640. extern struct yysvf *yyestate;
  641. int yyprevious = YYNEWLINE;
  642. #if    NeXT
  643. int yylook(){
  644. #else
  645. yylook(){
  646. #endif    NeXT
  647.     register struct yysvf *yystate, **lsp;
  648.     register struct yywork *yyt;
  649.     struct yysvf *yyz;
  650.     int yych;
  651.     struct yywork *yyr;
  652. # ifdef LEXDEBUG
  653.     int debug;
  654. # endif
  655.     char *yylastch;
  656.     /* start off machines */
  657. # ifdef LEXDEBUG
  658.     debug = 0;
  659. # endif
  660.     if (!yymorfg)
  661.         yylastch = yytext;
  662.     else {
  663.         yymorfg=0;
  664.         yylastch = yytext+yyleng;
  665.         }
  666.     for(;;){
  667.         lsp = yylstate;
  668.         yyestate = yystate = yybgin;
  669.         if (yyprevious==YYNEWLINE) yystate++;
  670.         for (;;){
  671. # ifdef LEXDEBUG
  672.             if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
  673. # endif
  674.             yyt = yystate->yystoff;
  675.             if(yyt == yycrank){        /* may not be any transitions */
  676.                 yyz = yystate->yyother;
  677.                 if(yyz == 0)break;
  678.                 if(yyz->yystoff == yycrank)break;
  679.                 }
  680.             *yylastch++ = yych = input();
  681.         tryagain:
  682. # ifdef LEXDEBUG
  683.             if(debug){
  684.                 fprintf(yyout,"char ");
  685.                 allprint(yych);
  686.                 putchar('\n');
  687.                 }
  688. # endif
  689.             yyr = yyt;
  690.             if ( (int)yyt > (int)yycrank){
  691.                 yyt = yyr + yych;
  692.                 if (yyt <= yytop && yyt->verify+yysvec == yystate){
  693.                     if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  694.                         {unput(*--yylastch);break;}
  695.                     *lsp++ = yystate = yyt->advance+yysvec;
  696.                     goto contin;
  697.                     }
  698.                 }
  699. # ifdef YYOPTIM
  700.             else if((int)yyt < (int)yycrank) {        /* r < yycrank */
  701.                 yyt = yyr = yycrank+(yycrank-yyt);
  702. # ifdef LEXDEBUG
  703.                 if(debug)fprintf(yyout,"compressed state\n");
  704. # endif
  705.                 yyt = yyt + yych;
  706.                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  707.                     if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  708.                         {unput(*--yylastch);break;}
  709.                     *lsp++ = yystate = yyt->advance+yysvec;
  710.                     goto contin;
  711.                     }
  712.                 yyt = yyr + YYU(yymatch[yych]);
  713. # ifdef LEXDEBUG
  714.                 if(debug){
  715.                     fprintf(yyout,"try fall back character ");
  716.                     allprint(YYU(yymatch[yych]));
  717.                     putchar('\n');
  718.                     }
  719. # endif
  720.                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  721.                     if(yyt->advance+yysvec == YYLERR)    /* error transition */
  722.                         {unput(*--yylastch);break;}
  723.                     *lsp++ = yystate = yyt->advance+yysvec;
  724.                     goto contin;
  725.                     }
  726.                 }
  727.             if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
  728. # ifdef LEXDEBUG
  729.                 if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
  730. # endif
  731.                 goto tryagain;
  732.                 }
  733. # endif
  734.             else
  735.                 {unput(*--yylastch);break;}
  736.         contin:
  737. # ifdef LEXDEBUG
  738.             if(debug){
  739.                 fprintf(yyout,"state %d char ",yystate-yysvec-1);
  740.                 allprint(yych);
  741.                 putchar('\n');
  742.                 }
  743. # endif
  744.             ;
  745.             }
  746. # ifdef LEXDEBUG
  747.         if(debug){
  748.             fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
  749.             allprint(yych);
  750.             putchar('\n');
  751.             }
  752. # endif
  753.         while (lsp-- > yylstate){
  754.             *yylastch-- = 0;
  755.             if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
  756.                 yyolsp = lsp;
  757.                 if(yyextra[*yyfnd]){        /* must backup */
  758.                     while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
  759.                         lsp--;
  760.                         unput(*yylastch--);
  761.                         }
  762.                     }
  763.                 yyprevious = YYU(*yylastch);
  764.                 yylsp = lsp;
  765.                 yyleng = yylastch-yytext+1;
  766.                 yytext[yyleng] = 0;
  767. # ifdef LEXDEBUG
  768.                 if(debug){
  769.                     fprintf(yyout,"\nmatch ");
  770.                     sprint(yytext);
  771.                     fprintf(yyout," action %d\n",*yyfnd);
  772.                     }
  773. # endif
  774.                 return(*yyfnd++);
  775.                 }
  776.             unput(*yylastch);
  777.             }
  778.         if (yytext[0] == 0  /* && feof(yyin) */)
  779.             {
  780.             yysptr=yysbuf;
  781.             return(0);
  782.             }
  783.         yyprevious = yytext[0] = input();
  784.         if (yyprevious>0)
  785.             output(yyprevious);
  786.         yylastch=yytext;
  787. # ifdef LEXDEBUG
  788.         if(debug)putchar('\n');
  789. # endif
  790.         }
  791.     }
  792. #if    NeXT
  793. int yyback(p, m)
  794.     int *p;
  795.     int m;
  796. #else
  797. yyback(p, m)
  798.     int *p;
  799. #endif    NeXT
  800. {
  801. if (p==0) return(0);
  802. while (*p)
  803.     {
  804.     if (*p++ == m)
  805.         return(1);
  806.     }
  807. return(0);
  808. }
  809.     /* the following are only used in the lex library */
  810. #if    NeXT
  811. int yyinput(){
  812. #else
  813. yyinput(){
  814. #endif    NeXT
  815.     return(input());
  816.     }
  817. #if    NeXT
  818. void yyoutput(c)
  819.     int c; 
  820. {
  821.     output(c);
  822. }
  823. #else
  824. yyoutput(c)
  825.   int c; {
  826.     output(c);
  827.     }
  828. #endif    NeXT
  829. #if    NeXT
  830. void yyunput(c)
  831.     int c; 
  832. {
  833.     unput(c);
  834. }
  835. #else
  836. yyunput(c)
  837.    int c; {
  838.     unput(c);
  839.     }
  840. #endif    NeXT
  841.