home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsm!cbnewsl!att-out!rutgers!micro-heart-of-gold.mit.edu!uw-beaver!uw-coco!mdisea!mdivax1!van-bc!rwsys!root
- From: root@rwsys.wimsey.bc.ca (Superuser)
- Newsgroups: comp.os.coherent
- Subject: Re: Working lex for v4.0?
- Message-ID: <9212243066@rwsys.wimsey.bc.ca>
- Date: 28 Dec 92 20:53:26 GMT
- References: <1992Dec20.120530.16635@iitmax.iit.edu>
- Organization: RWSYS Exporter BBS system
- Lines: 126
-
- pred@iitmax.iit.edu (Predrag S. Bundalo) writes:
- > Randy Wright's port of flex is even worse (flex is bad, not the port): it
- > creates an ever-growing lex.yy.c file. Sheesh.
- [I deleted the lex code for bandwidth..]
- > Regards,
- >
- > Pred Bundalo
- > --
- > ::: Predrag S. Bundalo Academic Computing Center
- > ::: Illinois Institute of Technology Chicago, Illinois
- > .....................................................................
- > ::: Internet: pred@{iitmax, elof}.iit.edu, syspredrag@minna.iit.edu
- > ::: BITNET : syspredrag@iitvax.BITNET
- >
- Pred, I tried your code. Indeed flex produced >1 megabyte before a stopped
- it. It must have the double-per-cent-sign at the end of the spec (%%) or
- flex will copy infinitely what ever is actually there ( end of file ). I
- think this is a flex bug. At any rate, if you install the "%%", it will
- flex up ok.
-
- I took the liberty of creating a piece of test data and running your
- specification on it. I added a main(), but you don not have to have
- a main(), just the %%. I put this spec in a file called spec.l and
- then my input data in a file called test.data. Then I did this:
-
- flex spec.l
-
- cc lex.yy.c -o hdr
-
- hdr test.data >output
-
- here's the revised files:
- ============file: spec.l===============================
- %S REPLY FROM SUBJECT QUIT GET BINARY ASCII HELP CONNECT
- %%
- <FROM>[^\n]+ printf("FROM: %s\n",yytext);
- <FROM>\n BEGIN 0;
- From:" " BEGIN FROM;
-
- <SUBJECT>[^\n]+ printf("SUBJECT: %s\n",yytext);
- <SUBJECT>\n BEGIN 0;
- Subject:" " BEGIN SUBJECT;
-
- <REPLY>[^\n]+ printf("REPLY: %s\n",yytext);
- <REPLY>\n BEGIN 0;
- [rR][eE][pP][lL][yY]" " BEGIN REPLY;
-
- <QUIT>[^\n]+ printf("QUIT\n");
- <QUIT>\n BEGIN 0;
- [qQ][uU][iI][tT] BEGIN QUIT;
-
- <HELP>[^\n]+ printf("HELP\n");
- <HELP>\n BEGIN 0;
- [hH][Ee][lL][pP] BEGIN HELP;
-
- <GET>[^\n]+ printf("GET: %s\n",yytext);
- <GET>\n BEGIN 0;
- [gG][eE][tT]" " BEGIN GET;
-
- <BINARY>[^\n]+ printf("BINARY\n");
- <BINARY>\n BEGIN 0;
- [bB][iI][nN][aA][rR][yY] BEGIN BINARY;
-
- <ASCII>[^\n]+ printf("ASCII\n");
- <ASCII>\n BEGIN 0;
- [aA][sS][cC][iI][iI] BEGIN ASCII;
-
- <CONNECT>[^\n]+ printf("CONNECT: %s\n",yytext);
- <CONNECT>\n BEGIN 0;
- [cC][oO][nN][nN][Ee][cC][tT]" " BEGIN CONNECT;
- %%
- /* these two %'s must be there or flex will loose it's mind */
-
- main( argc, argv )
- int argc;
- char **argv;
- {
- FILE *infile;
-
- /* should check argc too */
- if( (infile = fopen( argv[1], "r" )) == NULL )
- {
- printf( "can't open %s\n", argv[1] );
- exit( 1 );
- }
-
- yyin = infile;
-
- yylex();
-
- }
-
- ===== here's the input I fed to the above spec. file: test.data ======
- From: root@rwsys.wimsey.bc.ca (Randy Wright)
- Subject: flex stuff..
- reply root@rwsys.wimsey.bc.ca
- quit
- help
- get ./pub/myfile.txt
- Binary
- Ascii
- Connect 256.256.256.256
-
- ====== here's the output from the above input. file: output ============
- FROM: root@rwsys.wimsey.bc.ca (Randy Wright)
- SUBJECT: flex stuff..
- REPLY: root@rwsys.wimsey.bc.ca
- QUIT
- HELP
- GET: ./pub/myfile.txt
- BINARY
- ASCII
- CONNECT: 256.256.256.256
- ==================
- I think this is probably what you are trying to achieve. BTW, very
- interesting code. Looks useful for parsing ftpmail commands and other
- network stuff.
-
- Randy Wright
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- root@rwsys.wimsey.bc.ca (Randy Wright) | Exporter BBS 2400 bps
- or | (604) 581-0518 8N1
- Randy_Wright@Mindlink.bc.ca | uucp ogin: uguest
- | interactive login: guest
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-