-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpr.h
55 lines (39 loc) · 895 Bytes
/
expr.h
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
#ifndef EXPR_H
#define EXPR_H
#include "expr/types.h"
#include "expr/lexer.h"
#include "expr/symtable.h"
#include "expr/parser.h"
#include "soundlib.h"
class Expr : public Sig{
public:
char vbuff[num_inlets*4];
char* vstrings[num_inlets];
char* ptr = vbuff;
Lexer* lexer;
SymTable symtable;
ShuntingYard* sh;
Expr(std::string str){
init(num_inlets, true);
for(int i = 0; i < num_inlets; i++){
sprintf(ptr, "f%u", i);
vstrings[i] = ptr;
symtable.make_var(vstrings[i], inputs[i]);
ptr += 3;
}
lexer = new Lexer(512);
lexer->load(str.c_str());
if(lexer->scan()){
// lexer.printLexemes();
}
else printf("lexer error\n");
sh = new ShuntingYard(lexer->lexemes, symtable);
sh->load();
// sh->printRPN();
}
void dsp(){
output = sh->evaluate();
}
~Expr(){ delete sh; delete lexer;}
};
#endif