/*
编译原理实验3
B3.L
*/
%{
#include"y.tab.h"
#include<string.h>
extern FILE * yyin;
extern FILE * yyout;
extern int yylineno;
%}
delim [ \t]
ws {delim}+
letter [A-Za-z]
digit [0-9]
id {letter}({letter}|{digit})*
number {digit}+
addop [+-]
mulop [*/]
%%
\r\n {yylineno++;}
{ws} {/*d*/}
while {return WHILE;}
do {return DO;}
if {return IF;}
else {return ELSE;}
for {return FOR;}
int {return INT;}
char {return CHAR;}
void {return VOID;}
return {return RETURN;}
\'[a-zA-Z0-9]\' {strcpy(yylval._ident,yytext);return CONST_CHAR;}
\"[a-zA-Z]+\" {strcpy(yylval._ident,yytext);return STRING;}
{id} {strcpy(yylval._ident,yytext);return ID;}
{number} {strcpy(yylval._ident,yytext);return NUM;}
"[" {return '[';}
"]" {return ']';}
"<" {return LT;}
"=" {return '=';}
">" {return GT;}
"<=" {return LE;}
">=" {return GE;}
"!=" {return NE;}
"==" {return EQ;}
{addop} {yylval._op=yytext[0]; return ADDOP;}
{mulop} {yylval._op=yytext[0]; return MULOP;}
";" {return ';';}
"{" {return '{';}
"}" {return '}';}
"(" {return '(';}
")" {return ')';}
"," {return ',';}
%%
int yywrap(){
return 1;
}