38 lines
932 B
Plaintext
38 lines
932 B
Plaintext
/* Lexical Analysis with Flex (2.6.0) We used some of the code from this manual */
|
|
/* so we placed the citation here. */
|
|
/* definitions */
|
|
%option noyywrap
|
|
%{
|
|
#include "typedefs.h"
|
|
%}
|
|
|
|
DIGIT [0-9]
|
|
%%
|
|
/* rules */
|
|
{DIGIT}+ {printf( "C_INTEGER: %s (%d)\n", yytext, atoi( yytext ) );}
|
|
|
|
"null" {printf( "C_NULL: %s (%d)\n", yytext, atoi( yytext ) );}
|
|
|
|
\'.\'|\'\\[nt]\' {printf( "C_CHARACTER: %s (%d)\n", yytext, atoi( yytext ) );} /*using double \ per documentation to show escaped chars*/
|
|
|
|
"true" {printf( "C_TRUE: %s (%d)\n", yytext, atoi( yytext ) );}
|
|
|
|
"false" {printf( "C_FALSE: %s (%d)\n", yytext, atoi( yytext ) );}
|
|
|
|
"\""[\^{}}\n]*"\"" {printf( "C_STRING: %s (%d)\n", yytext, atoi( yytext ) );}
|
|
|
|
.|\n
|
|
|
|
%%
|
|
/* user code */
|
|
|
|
int main( int argc, char **argv )
|
|
{
|
|
argc--, argv++; /* skip over program name */
|
|
if ( argc > 0 )
|
|
yyin = fopen( argv[0], "r" );
|
|
else
|
|
yyin = stdin;
|
|
yylex();
|
|
}
|