Mail Archives: djgpp/1998/12/21/02:02:18
%{
/* 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 -