27 lines
672 B
Plaintext
27 lines
672 B
Plaintext
%{
|
||
#include "C:\Users\user\Desktop\УЧЕБА\6_СЕМ\КОМПИЛЯТОРЫ\flex_bison_test\analyzers\polynomials\poly_calc\poly_calc.h"
|
||
#include "polynomials.tab.h"
|
||
|
||
extern FILE *yyin;
|
||
%}
|
||
|
||
%%
|
||
[0-9]+ {
|
||
init_polynomial(&yylval.poly);
|
||
add_term(&yylval.poly, atoi(yytext), 0);
|
||
return NUMBER;
|
||
}
|
||
"x" {
|
||
init_polynomial(&yylval.poly);
|
||
add_term(&yylval.poly, 1, 1);
|
||
return VARIABLE;
|
||
}
|
||
[-+*^()] { return yytext[0]; }
|
||
[ \t] ;
|
||
\n { return 0; }
|
||
. { printf("unknown: %s\n", yytext); exit(0); }
|
||
%%
|
||
|
||
int yywrap() {
|
||
return 1;
|
||
} |