@@ -11,6 +11,10 @@ sealed class Expression {
1111 override fun toString (): String = " $op$lhs "
1212 }
1313
14+ class ComparisonOp (val lhs : ExpressionNode , val op : ComparisonOpKind , val rhs : ExpressionNode ) : ExpressionNode {
15+ override fun toString (): String = " $lhs $op $rhs "
16+ }
17+
1418 class IntValue (val value : Int ) : ExpressionNode {
1519 override fun toString () = value.toString()
1620 }
@@ -31,7 +35,8 @@ sealed class Expression {
3135 override fun toString () = " try { $tryBlock } catch { $catchBlock }"
3236 }
3337
34- class IfElse (val condition : ExpressionNode , val thenBlock : ExpressionNode , val elseBlock : ExpressionNode ) : ExpressionNode {
38+ class IfElse (val condition : ExpressionNode , val thenBlock : ExpressionNode , val elseBlock : ExpressionNode ) :
39+ ExpressionNode {
3540 override fun toString () = " if ($condition ) { $thenBlock } else { $elseBlock }"
3641 }
3742
@@ -40,7 +45,8 @@ sealed class Expression {
4045 }
4146
4247 // lhs: identifier, rhs: expression
43- class MethodCall (val functionName : String , val args : Array <ExpressionNode >, val className : String = " " ) : ExpressionNode {
48+ class MethodCall (val functionName : String , val args : Array <ExpressionNode >, val className : String = " " ) :
49+ ExpressionNode {
4450 override fun toString (): String {
4551 return if (className == " " ) {
4652 " $functionName (${args.joinToString(" , " )} )"
@@ -58,8 +64,47 @@ sealed class Expression {
5864 override fun toString () = " [${args.joinToString(" , " )} ]"
5965 }
6066
61- class CustomValueType (val value : ValueType ) : ExpressionNode
67+ class Value (val value : Any ) : ExpressionNode {
68+ override fun toString () = value.toString()
69+ }
70+ }
71+
72+
73+ sealed class ComparisonOpKind {
74+ object Equal : ComparisonOpKind() {
75+ override fun toString () = " =="
76+ }
77+ object NotEqual : ComparisonOpKind() {
78+ override fun toString () = " !="
79+ }
80+
81+ object GreaterThan : ComparisonOpKind() {
82+ override fun toString () = " >"
83+ }
84+
85+ object GreaterThanOrEqual : ComparisonOpKind() {
86+ override fun toString () = " >="
87+ }
6288
89+ object LessThan : ComparisonOpKind() {
90+ override fun toString () = " <"
91+ }
92+
93+ object LessThanOrEqual : ComparisonOpKind() {
94+ override fun toString () = " <="
95+ }
96+
97+ object In : ComparisonOpKind() {
98+ override fun toString () = " in"
99+ }
100+
101+ object NotIn : ComparisonOpKind() {
102+ override fun toString () = " !in"
103+ }
104+
105+ object Is : ComparisonOpKind() {
106+ override fun toString () = " is"
107+ }
63108}
64109
65110sealed class BinOpKind {
@@ -125,10 +170,19 @@ interface ExpressionNode {
125170 }
126171}
127172
128-
129173interface ValueType {
130174 val name: String
131175 val value: Any
132176}
133177
178+ sealed class Typed {
179+ class IntType (val value : Int ) : Typed()
180+ class FloatType (val value : Float ) : Typed()
181+ class StringType (val value : String ) : Typed()
182+ class BoolType (val value : Boolean ) : Typed()
183+ class ArrayType (val value : Array <Typed >) : Typed()
184+ class ObjectType (val value : Any ) : Typed()
185+ class NullType (val value : Any ) : Typed()
186+ }
187+
134188interface Operator : ExpressionNode
0 commit comments