-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmathLib.l
40 lines (34 loc) · 1.39 KB
/
mathLib.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
%{
#include "y.tab.h"
void yyerror (char *s);
int yylex();
%}
%%
"/*".*"*/" {;}
"@" {return func;}
"evalExp" {return evaluateExpression;}
"evalFun" {return evaluateFunction;}
"typeof" {return type_of;}
"evalDiff" {return evaluateDifferentiation;}
"diff" {return differentiate;}
"show" {return show;}
"pop" {return pop;}
"root" {return root;}
"over" {return exit_command;}
"append" {return append;}
"exponent" {return exponent;}
"log" {return logarithm;}
[a-zA-Z] {yylval.id = yytext[0]; return variable;}
([1-9][0-9]+|[0-9]) {
yylval.num = (float)atof(yytext);
return digits;
}
([1-9][0-9]+|[0-9])?\.[0-9]+ {
yylval.num = (float)atof(yytext);
return digits;
}
[ \t\n] ;
[-+=;!*(/){}^<>@_.,] {return yytext[0];}
. {ECHO; yyerror ("Invalid Input\n");}
%%
int yywrap (void) {return 1;}