-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.l
77 lines (63 loc) · 746 Bytes
/
input.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
%{
#include "Polynom.h"
#define YY_DECL int yylex(Polynom &P)
%}
INTEGER {[0-9]+}
FLOAT {INTEGER"."[0-9]*}
COEFFITIENT {FLOAT}|{INTEGER}
%option noyywrap
%x X
%x Y
%x Z
%x C
%%
%{
monom m;m.x=0;m.y=0;m.z=0;m.constant=0;
%}
<C> "X"|"x""^" {
m.constant=1;
BEGIN(X);
}
"X"|"x""^" {
BEGIN(X);
}
<C> "Y"|"y""^" {
m.constant=1;
BEGIN(Y);
}
"Y"|"y""^" {
BEGIN(Y);
}
<C> "Z"|"z""^" {
m.constant=1;
BEGIN(Z);
}
"Z"|"z""^" {
BEGIN(Z);
}
<C> {FLOAT} {
m.constant=atof(yytext);
}
b
<C> {INTEGER} {
m.constant=atoi(yytext);
}
bb
<X> {INTEGER} {
m.x=atoi(yytext);
}
bbb
<Y> {INTEGER} {
m.y=atoi(yytext);
}
bbbb
<Z> {INTEGER} {
m.z=atoi(yytext);
}
"+" {
P.add(m);
BEGIN(INITIAL);
BEGIN(C);
}
\n return 0;
%%