-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathluaizer.i
94 lines (71 loc) · 1.58 KB
/
luaizer.i
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
%module luaizer
%include "std_string.i"
%{
#include "lua_driver.hh"
#include "wrapper_func.hh"
%}
%include "std_vector.i"
namespace std {
%template(NodesVector) vector<Node *>;
}
class lua_driver
{
public:
lua_driver() {};
virtual ~lua_driver();
int result;
// Run the parser. Return 0 on success.
int parse (const std::string& f);
const std::vector<Node *> getNodes() const;
const std::vector<Node *> getExpressionNodes() const;
Node *getRootNode();
};
class Node {
public:
virtual std::string toString() = 0;
int lineNo;
};
class Comment : public Node {
public:
virtual std::string getText() = 0;
};
class LineCommentToken : public Comment {
};
class BlockCommentToken : public Comment {
};
class IfBlock : public Node {
public:
Node *getExpr();
Node *getBody();
Node *getElseIfBlock();
Node *getElseBlock();
};
class IfToken : public Node {
public:
IfBlock* getBlock();
};
class Expression : public Node {
};
class BinExpression : public Expression {
public:
Node *getOp();
Node *getLeft();
Node *getRight();
};
class Function: public Node {
public:
FunctionBody *getBody();
};
bool isComment(const Node *const n);
bool isIfBlock(const Node *const n);
bool isBinExpression(const Node *const n);
bool isFunction(const Node *const n);
Comment * asComment(Node *n);
IfBlock * asIfBlock(Node *n);
IfToken * asIfToken(Node *n);
BinExpression * asBinExpression(Node *n);
Function * asFunction(Node *n);
bool isIfToken(const Node *const n);
bool isBinExpression(const Node *const n);
bool isIfBlock(const Node *const n);
bool isFunction(const Node *const n);