Premier exercice
This commit is contained in:
26
lexical/string.l
Normal file
26
lexical/string.l
Normal file
@ -0,0 +1,26 @@
|
||||
%option noyywrap
|
||||
|
||||
DIG [0-9]
|
||||
|
||||
%%
|
||||
|
||||
{DIG}+ { printf("int(%d) ",atoi(yytext)); }
|
||||
[+*()] { printf("'%c' ",*yytext); }
|
||||
[ \n] { /* ignore */ }
|
||||
|
||||
%%
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
YY_BUFFER_STATE buffer;
|
||||
|
||||
buffer = yy_scan_string("100+5*2");
|
||||
yylex();
|
||||
yy_delete_buffer(buffer);
|
||||
|
||||
buffer = yy_scan_string("20+30");
|
||||
yylex();
|
||||
yy_delete_buffer(buffer);
|
||||
|
||||
puts("");
|
||||
}
|
Reference in New Issue
Block a user