-
Notifications
You must be signed in to change notification settings - Fork 1
/
plotter.l
37 lines (34 loc) · 807 Bytes
/
plotter.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
%{
#include "y.tab.h"
void yyerror (char *s);
int yylex();
%}
digit [0-9]
digits {digit}+
fract ([\.]{digit}+)?
exp ([eE][\+\-]?{digits})?
num [\+\-]?{digits}{fract}{exp}
letter [a-zA-Z_]
var {letter}({letter}|{digit})*
%%
("print") {return Print;}
("help") {return Help;}
("plot") {return Plot;}
("sin") {return SIN;}
("cos") {return COS;}
("tan") {return TAN;}
("abs") {return ABS;}
("pow") {return POW;}
("log") {return LOG;}
("exp") {return EXP;}
("exit") {return Exit;}
("circle") {return Circle;}
("parabola") {return Parabola;}
("ellipse") {return Ellipse;}
{var} {yylval.id=yytext;return VAR;}
{num} {yylval.number = atof(yytext);return NUM;}
[ \t\n] ;
[\+\-\*\/\(\)\[\]\,\;\=] {return yytext[0];}
. {ECHO;printf("No match found");}
%%
int yywrap(){return 1;}