-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpressionStatement.h
More file actions
68 lines (56 loc) · 1.96 KB
/
ExpressionStatement.h
File metadata and controls
68 lines (56 loc) · 1.96 KB
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
#pragma once
#include "expression.h"
#include "hash_table.h"
typedef enum {
BIN_PLUS, BIN_MINUS, BIN_BY, BIN_DIVIDE, BIN_OR, BIN_AND, BIN_XOR,
BIN_SI, BIN_SII, BIN_LESS, BIN_LESS_EQ, BIN_MORE, BIN_MORE_EQ,
BIN_NOT_EQ, BIN_DOBLE_EQUALS
} BinExpressionKind;
typedef enum {
UN_MINUS
} UnExpressionKind;
typedef enum {
UNARY, BINARY, LITERAL, VARIABLE, ACCESSOR
} ExpressionNarity;
//Resolve circular definition
typedef struct _binexprstatement BinExpressionStatement;
typedef struct _unexprstatement UnExpressionStatement;
typedef union _naryexprstatement NaryExpressionStatement;
typedef struct _exprstatement ExpressionStatement;
typedef struct _binexprstatement{
BinExpressionKind kind;
ExpressionStatement * lhs;
ExpressionStatement * rhs;
} BinExpressionStatement;
typedef struct _unexprstatement{
UnExpressionKind kind;
ExpressionStatement * e;
} UnExpressionStatement;
typedef struct _litexprstatement{
Expression * e;
} LitExpressionStatement;
typedef struct _varexprstatement{
char * name;
} VarExpressionStatement;
typedef struct {
char * name;
ExpressionStatement * accessor;
} ArrayAccessorExpressionStatement;
typedef union _naryexprstatement{
ArrayAccessorExpressionStatement _acc;
VarExpressionStatement _var;
LitExpressionStatement _lit;
BinExpressionStatement _binary;
UnExpressionStatement _unary;
} NaryExpressionStatement;
typedef struct _exprstatement{
NaryExpressionStatement _e;
ExpressionNarity _n;
} ExpressionStatement;
Expression * evaluate(Table table, ExpressionStatement * e);
ExpressionStatement * createBinExpression(BinExpressionKind k, ExpressionStatement * lhs, ExpressionStatement * rhs);
ExpressionStatement * createUnExpression(UnExpressionKind k, ExpressionStatement * e);
ExpressionStatement * createLiteralExpression(Expression * e);
ExpressionStatement * createVariableExpression(char * name);
ExpressionStatement * createArrayAccessorExpression(char * name, ExpressionStatement *accessor);
int const_int_eval(ExpressionStatement * e);