Rewrote grammar, implemented two visitors

This commit is contained in:
Marvin Kaiser
2019-10-29 09:51:43 +01:00
parent ea248733d0
commit 64c41122d0
11 changed files with 539 additions and 103 deletions

View File

@@ -0,0 +1,55 @@
package de.hsrm.compiler.Klang;
public class Value {
public static Value VOID = new Value(new Object());
final Object value;
public Value(Object value) {
this.value = value;
}
public Integer asInteger() {
return (Integer)value;
}
public String asString() {
return String.valueOf(value);
}
public boolean isDouble() {
return value instanceof Double;
}
@Override
public int hashCode() {
if(value == null) {
return 0;
}
return this.value.hashCode();
}
@Override
public boolean equals(Object o) {
if(value == o) {
return true;
}
if(value == null || o == null || o.getClass() != value.getClass()) {
return false;
}
Value that = (Value)o;
return this.value.equals(that.value);
}
@Override
public String toString() {
return String.valueOf(value);
}
}