%{ /* Scanner tor Tinyc parser */ #include #include #include #include "lscan.h" extern YYSTYPE yylval; static void scanError(const char *format, int c); %} %Start S COM STR DEF1 DEF2 LETTER [A-Z_a-z] NOLETTER [^A-Z_a-z] DIGIT [0-9] IDENT {LETTER}({LETTER}|{DIGIT})* NUMBER {DIGIT}+ WHISP1 [ \t\r] WHISP ({WHISP1}|\n) %% { BEGIN S; } "\n" { yylval.int_value = ENDL; return ENDL; } {IDENT} { strncpy(yylval.text_value, yytext, NAMEMAX); return( NAME ); } {NUMBER} { yylval.int_value = atoi(yytext); return( ICON ); } "!" { return( LNOT ); } "&&" { return( LAND ); } "||" { return( LOR ); } "<" { yylval.int_value = LT; return( RELOP ); } "<=" { yylval.int_value = LE; return( RELOP ); } ">" { yylval.int_value = GT; return( RELOP ); } ">=" { yylval.int_value = GE; return( RELOP ); } "==" { yylval.int_value = EQ; return( EQUOP ); } "!=" { yylval.int_value = NE; return( EQUOP ); } "(" { return( LP ); } ")" { return( RP ); } {WHISP1}+ { } . { scanError( "Bad character %c\n", yytext[0] ); } %% int yywrap() { return( 1 ); } static void scanError(const char *format, int c) { printf(format, c); }