diff -urN source-orig/agc1.l source/agc1.l --- source-orig/agc1.l 2004-03-11 20:46:49.000000000 +0100 +++ source/agc1.l 2004-03-11 20:53:25.000000000 +0100 @@ -1,4 +1,5 @@ %start YD YDSI ADECL MH MB LVA ADSL UU CC TRDECL +%option yylineno %{ @@ -69,6 +70,7 @@ #include "outMgr.h" #include "symTrans.h" #include "ctc.h" +#define YY_USER_ACTION ptext=yytext; %} @@ -247,7 +249,7 @@ void beginCC() {BEGIN CC;} -int yyScnState() {return (yybgin-yysvec-1);} +int yyScnState() {return YY_START;} yywrap() { diff -urN source-orig/agc2.l source/agc2.l --- source-orig/agc2.l 2004-03-11 20:46:49.000000000 +0100 +++ source/agc2.l 2004-03-11 20:53:58.000000000 +0100 @@ -1,6 +1,7 @@ %start YR YR1 AA LAAA LAAA1 %start DL CL TT MUI TRAV1 TRVACT TRVCOND -%start EOSFRET +%start EOSFRET SKIP +%option yylineno %{ /* $Header: agc2.l,v 5.10 94/04/16 20:23:56 bischoff Exp $ */ @@ -77,6 +78,7 @@ int startCondTempT; int nLparensT; enum {oCond,dCond,action} travState; +#define YY_USER_ACTION ptext=yytext; %} @@ -92,7 +94,10 @@ IDENT ([a-zA-Z][a-zA-Z0-9]*) %% -x {scanScanInit(); return(EOSF);} +^{OPTWS}%%{OPTWS}$ BEGIN YR; +. | +\n ; +<> {scanScanInit(); return(EOSF);} [ \t\n\f] {flushLAbuffer(LA1,outG); charOut(*yytext,outG);} \/\* {flushLAbuffer(LA1,outG); eatCommentAndEcho(outG,1);} \/\/.*\n {flushLAbuffer(LA1,outG); lexemeOut(outG);} @@ -343,13 +348,14 @@ void scanInit2() - {whichScanner = 2; - yylineno = *plineno; + {whichScanner = 2; + yylineno=0; plineno = &yylineno; ptext = (char *)yytext; pleng = &yyleng; - BEGIN YR; + BEGIN SKIP; yyin = yoxInG; + rewind(yyin); } @@ -357,7 +363,7 @@ void beginAA() {BEGIN AA;} void beginTT() {BEGIN TT;} -int yyScnState() {return (yybgin-yysvec-1);} +int yyScnState() {return YY_START;} yywrap() { @@ -368,7 +374,7 @@ } unput('x'); BEGIN EOSFRET; - return 0; + return 1; err1: rmTempFiles(); diff -urN source-orig/agc3.l source/agc3.l --- source-orig/agc3.l 2004-03-11 20:46:49.000000000 +0100 +++ source/agc3.l 2004-03-11 20:54:48.000000000 +0100 @@ -1,4 +1,5 @@ %start EOSFRET LD LRP LRRE LRRE1 LRA LRAAD LRAAR LRAAR1 LRAAD1 LUS MUI +%option yylineno %{ /* $Header: agc3.l,v 5.10 94/04/16 20:23:59 bischoff Exp $ */ @@ -78,6 +79,7 @@ static int nLparMac; static FILE *tempForTrash; int yyStartCondTemp; +#define YY_USER_ACTION ptext=yytext; %} @@ -92,7 +94,7 @@ IDENT ([a-zA-Z][a-zA-Z0-9]*) %% -x {scanScanInit(); return EOSF;} +<> {scanScanInit(); return EOSF;} ^\%\%(.*) {BEGIN LRP; if (!buildHeaderFile) {fprintf(Lfile[currentLfile].outPtr,"\n%%{\n"); @@ -338,7 +340,7 @@ } -int yyScnState() {return (yybgin-yysvec-1);} +int yyScnState() {return YY_START;} @@ -356,9 +358,8 @@ } if (yyScnState() == LRAAR) yerror("error: identifier expected after \"return\".\n"); - unput('x'); BEGIN EOSFRET; - return 0; + return 1; err1: rmTempFiles(); diff -urN source-orig/agc4.l source/agc4.l --- source-orig/agc4.l 2004-03-11 20:46:49.000000000 +0100 +++ source/agc4.l 2004-03-11 20:54:32.000000000 +0100 @@ -1,5 +1,6 @@ %start GEN ADECL AADECL ADS MAC TRDECL %start LD LRP LRRE LRRE1 LRA LRAAD LUS +%option yylineno %{ /* $Header: agc4.l,v 5.10 94/04/16 20:24:02 bischoff Exp $ */ @@ -68,6 +69,7 @@ #include "opts.hh" #include "opts.h" #include "outMgr.h" +#define YY_USER_ACTION ptext=yytext; %} WS [ \t\f]+ @@ -164,7 +166,7 @@ inFileStr = yoxInFileStrG; } -int yyScnState() {return (yybgin-yysvec-1);} +int yyScnState() {return YY_START;} int yywrap() { diff -urN source-orig/agc5.l source/agc5.l --- source-orig/agc5.l 2004-03-11 20:46:49.000000000 +0100 +++ source/agc5.l 2004-03-11 20:54:41.000000000 +0100 @@ -1,4 +1,5 @@ %start EOSFRET LRA LRAAD LRAAR LRAAR1 LRAAD1 LUS MUI +%option yylineno %{ /* $Header: agc5.l,v 5.10 94/04/16 20:24:04 bischoff Exp $ */ @@ -78,6 +79,7 @@ static int nLparMac; static FILE *tempForTrash; int yyStartCondTemp; +#define YY_USER_ACTION ptext=yytext; %} @@ -92,7 +94,7 @@ IDENT ([a-zA-Z][a-zA-Z0-9]*) %% -x {scanScanInit(); return(EOSF);} +<> {scanScanInit(); return(EOSF);} \/\* eatCommentAndEcho(outL,1); \/\/.*\n lexemeOut(outL); \" eatStringAndEcho(outL); @@ -281,7 +283,7 @@ } -int yyScnState() {return (yybgin-yysvec-1);} +int yyScnState() {return YY_START;} @@ -291,7 +293,7 @@ yerror("error: identifier expected after \"return\".\n"); unput('x'); BEGIN EOSFRET; - return 0; + return 1; err1: rmTempFiles(); diff -urN source-orig/mac.c source/mac.c --- source-orig/mac.c 2004-03-11 20:46:49.000000000 +0100 +++ source/mac.c 2004-03-11 20:43:34.000000000 +0100 @@ -440,7 +440,8 @@ {char c; c = *(macStackTop->nextChar)++; - if (!makeReadyInputFromMacro()) switchInputStreamFromMacro(); + if (!makeReadyInputFromMacro()) switchInputStreamFromMacro(); + if(c=='\n')c='\t'; return c; } diff -urN source-orig/medi.l source/medi.l --- source-orig/medi.l 2004-03-11 20:46:49.000000000 +0100 +++ source/medi.l 2004-03-11 19:34:23.000000000 +0100 @@ -121,10 +121,10 @@ char *substIText[] = { "extern int inFromMac;\n", "extern char inputFromMacro();\n", -"#define input() (inFromMac?((yysptr>yysbuf)?(*--yysptr):\\\n", +"#define myinput() (inFromMac?((yysptr>yysbuf)?(*--yysptr):\\\n", " inputFromMacro()\\\n", " ):\\\n", -" inputM()\\\n", +" getc(yyin)\\\n", " )\n", }; @@ -144,7 +144,7 @@ "#define unput(c) {if (inFromMac) \\\n", " {yytchar= (c);*yysptr++=yytchar;} \\\n", " else \\\n", -" unputM(c) \\\n", +" unputM(c); \\\n", " }\n", }; @@ -170,6 +170,14 @@ if ((outFile = fopen(argv[2],"w")) == (FILE *)NULL) fprintf(stderr,"error when trying to open output file for med\n"); yyout = outFile; +fprintf(outFile,"#include \nchar yytchar,yysbuf[BUFSIZ]={0},*yysptr=&yysbuf[0];\n"); +fprintf(outFile,"#define YY_NO_INPUT\n"); +fprintf(outFile,"#define YY_INPUT(buf,result,max_size) " +" { " +" int c = myinput(); " +" result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); " +" }\n"); +substInputDef(outFile); yylex(); fclose(inFile); fclose(outFile); diff -urN source-orig/medyy.l source/medyy.l --- source-orig/medyy.l 2004-03-11 20:46:49.000000000 +0100 +++ source/medyy.l 2004-03-11 19:34:23.000000000 +0100 @@ -105,6 +105,7 @@ yyout = outFile; modString = argv[3]; yylex(); +fprintf(outFile,"int yy%sinput(){return input();}\n",modString); fclose(inFile); fclose(outFile); erasf(argv[1]); diff -urN source-orig/opts.c source/opts.c --- source-orig/opts.c 2004-03-11 20:46:49.000000000 +0100 +++ source/opts.c 2004-03-11 19:34:23.000000000 +0100 @@ -488,9 +488,9 @@ fclose(yoxOutG); for (i=0;i