blob: 86265782e8c8f2351062f3708bf945552a1f6c00 (
plain) (
blame)
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
94
95
96
97
98
99
100
|
#include "Expression.h"
BinaryExpression::BinaryExpression(IPLSharedPtr<Expression> exprLeft, IPLSharedPtr<Expression> exprRight, TokenType op)
: m_Left(exprLeft)
, m_Right(exprRight)
, m_Operator(op)
{}
IPLString BinaryExpression::GetBinaryTypeAsString()
{
// TODO: Implement
return "Binary";
}
void BinaryExpression::Print(std::ostream& os)
{
os << "{ \n";
os << " Expression Type: Binary";
os << " Left expr: ";
m_Left->Print(os);
os << " Right expr:";
m_Right->Print(os);
os << " Operator Type: " << GetBinaryTypeAsString();
os << "\n}\n";
}
UnaryExpression::UnaryExpression(IPLSharedPtr<Expression> expr, TokenType op, bool suffix)
: m_Expr(expr)
, m_Operator(op)
, m_Suffix(suffix)
{
}
void UnaryExpression::Print(std::ostream& os)
{
os << "{ \n";
os << " Expression Type: Unary";
os << " Expr: ";
m_Expr->Print(os);
os << " Operator Type: " << GetBinaryTypeAsString() << std::endl;
os << "\n}\n";
}
IPLString UnaryExpression::GetBinaryTypeAsString()
{
// TODO: Implement
return "Unary";
}
LiteralExpression::LiteralExpression(double v)
:m_Type(LiteralType::Number)
, m_NumValue(v)
{}
LiteralExpression::LiteralExpression(IPLString& v)
: m_Type(LiteralType::String)
, m_StringValue(v)
{}
LiteralExpression::LiteralExpression(bool v)
: m_Type(LiteralType::Boolean)
, m_BooleanValue(v)
{}
LiteralExpression::LiteralExpression(LiteralType type)
: m_Type(type)
{}
void LiteralExpression::Print(std::ostream& os)
{
os << "{ \n";
os << " Literal Type: Unary";
os << " Literal value: ";
switch (m_Type)
{
case LiteralType::Number:
os << m_NumValue;
break;
case LiteralType::String:
os << m_StringValue;
break;
case LiteralType::Boolean:
os << m_BooleanValue;
break;
case LiteralType::Null:
os << "null";
case LiteralType::Undefined:
os << "undefined";
break;
default:
break;
}
os << "\n}\n";
}
|