www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/21/02:02:18

From: twidler444 AT aol DOT com (Twidler444)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: FLEX
Lines: 53
NNTP-Posting-Host: ladder01.news.aol.com
X-Admin: news AT aol DOT com
Date: 21 Dec 1998 06:20:12 GMT
Organization: AOL Canada http://www.aol.ca
References: <Pine DOT GSO DOT 3 DOT 96 DOT 981220214620 DOT 13510A-100000 AT expert DOT cc DOT purdue DOT edu>
Message-ID: <19981221012012.10649.00002188@ng42.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

     %{
     /* need this for the call to atof() below */
     #include <math.h>
     %}

     char setroom=50,
          chkroom=51,
          setdest=52,
          chkvar=53,
          setvar=54;


     DIGIT    [0-9]
     
     %%
     
     {DIGIT}+    {
                 if (atoi(yytext)>255)
                     {
                     printf( "%d", atoi( yytext ) );
                     }
                 else
                    {
                    printf("255");
                    printf("%d", atoi( yytext )-255 );
                    }
                 }

     "Set_Room("    printf("%s",setroom);  
     "Chk_Room("    printf("%s",chkroom);  
     "Set_Dest("    printf("%s",setdest);  
     "Chk_Var("     printf("%s",chkvar);   
     "Set_Var("     printf("%s",setvar);   
     ")"           /* skip end barckets */
     [ \t\n]+      /* eat up whitespace */
     
     .           printf( "Unrecognized character: %s\n", yytext );
     
     %%
     
     main( argc, argv )
     int argc;
     char **argv;
         {
         ++argv, --argc;  /* skip over program name */
         if ( argc > 0 )
                 yyin = fopen( argv[0], "r" );
         else
                 yyin = stdin;
     
         yylex();
         }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019