diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-26 18:23:59 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-26 18:23:59 -0600 |
commit | 289a419681bfde1edd91a695ca97116a57d62433 (patch) | |
tree | 2eb1c3918e6f3da4249bbf31d4abd0b31018b008 | |
parent | 7c6c79a437a4c1e7cf85964d005a3cdeb59809f1 (diff) |
Implemented some basic HeatVisitor rules
-rw-r--r-- | Typecheck.java | 2 | ||||
-rw-r--r-- | heat/HeatVisitor.java | 218 | ||||
-rw-r--r-- | heat/TypeBundle.java | 33 | ||||
-rw-r--r-- | st/SymTableVars.java | 4 | ||||
-rw-r--r-- | st/TypeEnum.java | 2 |
5 files changed, 139 insertions, 120 deletions
diff --git a/Typecheck.java b/Typecheck.java index d153f7a..098defe 100644 --- a/Typecheck.java +++ b/Typecheck.java @@ -38,6 +38,8 @@ public class Typecheck { System.out.println("Program type checked successfully"); } catch (TypecheckException e) { System.out.println("Type error"); + MinimalLogger.severe(String.format("Reason: %s", + e.toString())); } } diff --git a/heat/HeatVisitor.java b/heat/HeatVisitor.java index 746166c..fdc71ad 100644 --- a/heat/HeatVisitor.java +++ b/heat/HeatVisitor.java @@ -113,24 +113,9 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { this.symt.setActive(TypeEnum.classname, symt.getClass(id)); this.symt.setActive(TypeEnum.method, symt.getMethod(n.f6.tokenImage)); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); n.f1.accept(this, argu); - n.f2.accept(this, argu); - n.f3.accept(this, argu); - n.f4.accept(this, argu); - n.f5.accept(this, argu); - n.f6.accept(this, argu); - n.f7.accept(this, argu); - n.f8.accept(this, argu); - n.f9.accept(this, argu); - n.f10.accept(this, argu); - n.f11.accept(this, argu); - n.f12.accept(this, argu); - n.f13.accept(this, argu); n.f14.accept(this, argu); n.f15.accept(this, argu); - n.f16.accept(this, argu); - n.f17.accept(this, argu); /////////////////////////////////////////////////////////////// this.symt.removeActive(TypeEnum.method); this.symt.removeActive(TypeEnum.classname); @@ -173,12 +158,9 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { id)); this.symt.setActive(TypeEnum.classname, symt.getClass(id)); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); n.f1.accept(this, argu); - n.f2.accept(this, argu); n.f3.accept(this, argu); n.f4.accept(this, argu); - n.f5.accept(this, argu); /////////////////////////////////////////////////////////////// this.symt.removeActive(TypeEnum.classname); MinimalLogger.info(String.format("<- %s (%s)", @@ -205,14 +187,10 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { id)); this.symt.setActive(TypeEnum.classname, symt.getClass(id)); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); n.f1.accept(this, argu); - n.f2.accept(this, argu); n.f3.accept(this, argu); - n.f4.accept(this, argu); n.f5.accept(this, argu); n.f6.accept(this, argu); - n.f7.accept(this, argu); /////////////////////////////////////////////////////////////// this.symt.removeActive(TypeEnum.classname); MinimalLogger.info(String.format("<- %s (%s)", @@ -235,7 +213,6 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { /////////////////////////////////////////////////////////////// n.f0.accept(this, argu); n.f1.accept(this, argu); - n.f2.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s (%s)", n.getClass().getSimpleName(), @@ -266,19 +243,12 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { id)); this.symt.setActive(TypeEnum.method, symt.getMethod(id)); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); n.f1.accept(this, argu); n.f2.accept(this, argu); - n.f3.accept(this, argu); n.f4.accept(this, argu); - n.f5.accept(this, argu); - n.f6.accept(this, argu); n.f7.accept(this, argu); n.f8.accept(this, argu); - n.f9.accept(this, argu); n.f10.accept(this, argu); - n.f11.accept(this, argu); - n.f12.accept(this, argu); /////////////////////////////////////////////////////////////// this.symt.removeActive(TypeEnum.method); MinimalLogger.info(String.format("<- %s (%s)", @@ -335,7 +305,6 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); n.f1.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", @@ -373,9 +342,6 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -391,7 +357,6 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -407,7 +372,6 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -446,9 +410,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); n.f1.accept(this, argu); - n.f2.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -469,9 +431,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// n.f0.accept(this, argu); - n.f1.accept(this, argu); n.f2.accept(this, argu); - n.f3.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -494,12 +454,8 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// n.f0.accept(this, argu); - n.f1.accept(this, argu); n.f2.accept(this, argu); - n.f3.accept(this, argu); - n.f4.accept(this, argu); n.f5.accept(this, argu); - n.f6.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -521,12 +477,8 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); n.f2.accept(this, argu); - n.f3.accept(this, argu); n.f4.accept(this, argu); - n.f5.accept(this, argu); n.f6.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", @@ -547,10 +499,10 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); - n.f3.accept(this, argu); + _ret = n.f2.accept(this, argu); + if (!_ret.isBool()) + throw new TypecheckException(String.format("%s called on non-bool conditional!", + n.getClass().getSimpleName())); n.f4.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", @@ -571,11 +523,10 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); - n.f3.accept(this, argu); - n.f4.accept(this, argu); + _ret = n.f2.accept(this, argu); + if (!_ret.isInt()) + throw new TypecheckException(String.format("%s called on a non-integer!", + n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -599,7 +550,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); + _ret = n.f0.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -617,9 +568,11 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); + TypeBundle tb = n.f0.accept(this, argu); + _ret = n.f2.accept(this, argu); + if (!tb.isBool() || _ret.isBool()) + throw new TypecheckException(String.format("%s tried with something other than an Boolean!", + n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -637,9 +590,12 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); + TypeBundle tb = n.f0.accept(this, argu); + _ret = n.f2.accept(this, argu); + if (!tb.isInt() || _ret.isInt()) + throw new TypecheckException(String.format("%s tried with something other than an integer!", + n.getClass().getSimpleName())); + _ret = new TypeBundle(TypeEnum.bool, null); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -657,9 +613,11 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); + TypeBundle tb = n.f0.accept(this, argu); + _ret = n.f2.accept(this, argu); + if (!tb.isInt() || _ret.isInt()) + throw new TypecheckException(String.format("%s tried with something other than an integer!", + n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -677,9 +635,15 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); + TypeBundle tb = n.f0.accept(this, argu); + _ret = n.f2.accept(this, argu); + if (!tb.isInt() || _ret.isInt()) + throw new TypecheckException(String.format("%s tried with something other than an integer!", + n.getClass().getSimpleName())); + /////////////////////////////////////////////////////////////// + MinimalLogger.info(String.format("<- %s with %s", + n.getClass().getSimpleName(), + _ret)); return _ret; } @@ -693,9 +657,11 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); + TypeBundle tb = n.f0.accept(this, argu); + _ret = n.f2.accept(this, argu); + if (!tb.isInt() || _ret.isInt()) + throw new TypecheckException(String.format("%s tried with something other than an integer!", + n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -714,10 +680,11 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); - n.f3.accept(this, argu); + TypeBundle tb = n.f0.accept(this, argu); + _ret = n.f2.accept(this, argu); + if (!tb.isArray() || !_ret.isInt()) + throw new TypecheckException(String.format("%s tried on a non-array, or with a non-int index!", + n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -735,9 +702,12 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); + _ret = n.f0.accept(this, argu); + if (_ret.isArray()) + _ret = new TypeBundle(TypeEnum.integer, null); + else + throw new TypecheckException(String.format("%s tried on a non-array!", + n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -758,12 +728,53 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); - n.f3.accept(this, argu); + TypeInstance t; + switch (n.f0.f0.which) { + case 3: + MinimalLogger.info(String.format("Message send found IDENTIFIER")); + t = this.symt.getType(((Identifier) n.f0.f0.choice).f0.tokenImage); + break; + case 4: + MinimalLogger.info(String.format("Message send found THIS")); + t = new TypeInstance("null",null,null,null); + t.addClassInstance((ClassInstance) this.symt.getActive(TypeEnum.classname)); + break; + case 6: + MinimalLogger.info(String.format("Message send found ANONYMOUS")); + t = new TypeInstance("null",null,null,null); + break; + case 8: + MinimalLogger.info(String.format("Message send found BRACKET")); + t = new TypeInstance("null",null,null,null); + break; + default: + MinimalLogger.info(String.format("Message send found UNKNOWN %s", + n.f0.f0.choice.toString())); + t = null; + } + + if (t == null || t.getClassInstance() == null) + throw new TypecheckException(String.format("%s called on a missing/non class variable!", + n.getClass().getSimpleName())); + + MethodInstance m = this.symt.getMethod(n.f2.f0.tokenImage, t.getClassInstance()); + + if (m == null) + throw new TypecheckException(String.format("%s called a method not part of %s!", + n.getClass().getSimpleName(), + t.getName())); + + // FIXME Evaluate parameters! n.f4.accept(this, argu); - n.f5.accept(this, argu); + String ret = m.getReturn().getName(); + if (ret.equals("intarray")) + _ret = new TypeBundle(TypeEnum.intarray, null); + else if (ret.equals("bool")) + _ret = new TypeBundle(TypeEnum.bool, null); + else if (ret.equals("int")) + _ret = new TypeBundle(TypeEnum.integer, null); + else + _ret = new TypeBundle(TypeEnum.classname, null); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -781,7 +792,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// n.f0.accept(this, argu); - n.f1.accept(this, argu); + _ret = n.f1.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -798,8 +809,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); + _ret = n.f1.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -823,7 +833,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); + _ret = n.f0.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -839,7 +849,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); + _ret = new TypeBundle(TypeEnum.integer, null); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -855,7 +865,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); + _ret = new TypeBundle(TypeEnum.bool, null); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -871,7 +881,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); + _ret = new TypeBundle(TypeEnum.bool, null); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -887,6 +897,8 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// + if (true) + throw new TypecheckException("Identifier says: stop calling me!"); n.f0.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", @@ -903,7 +915,6 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -923,11 +934,12 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); - n.f3.accept(this, argu); - n.f4.accept(this, argu); + _ret = n.f3.accept(this, argu); + if (_ret.isInt()) + _ret = new TypeBundle(TypeEnum.intarray, null); + else + throw new TypecheckException(String.format("%s tried with a non-integer!", + n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -946,10 +958,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); n.f1.accept(this, argu); - n.f2.accept(this, argu); - n.f3.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -966,8 +975,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); + _ret = n.f1.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), @@ -985,9 +993,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> { MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); + _ret = n.f1.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), diff --git a/heat/TypeBundle.java b/heat/TypeBundle.java index d5f8121..44e3749 100644 --- a/heat/TypeBundle.java +++ b/heat/TypeBundle.java @@ -18,24 +18,35 @@ class TypeBundle { } @Override public String toString() { - return String.format("%s (%s)", - type, - instance); + String cls = (this.instance != null) ? String.format(" (%s)", this.instance) : ""; + return String.format("%s%s", + this.type, + cls); } @Override public boolean equals(Object other) { - /** - * We can say two types are equal, as - * long as they are not equal on a - * type error! - */ return (other instanceof TypeBundle) && - this.hasChecked() && ((TypeBundle) other).type == this.type; } - public boolean hasChecked() { - return type != TypeEnum.ERROR; + public boolean isClass() { + return this.type == TypeEnum.classname; + } + + public boolean isMethod() { + return this.type == TypeEnum.method; + } + + public boolean isArray() { + return this.type == TypeEnum.intarray; + } + + public boolean isBool() { + return this.type == TypeEnum.bool; + } + + public boolean isInt() { + return this.type == TypeEnum.integer; } } diff --git a/st/SymTableVars.java b/st/SymTableVars.java index 37747dc..014beb1 100644 --- a/st/SymTableVars.java +++ b/st/SymTableVars.java @@ -121,7 +121,7 @@ public class SymTableVars<R> extends GJDepthFirst<R,SymbolTable> { TokenKey id = new TokenKey(n.f1.f0.tokenImage, (ClassInstance) symt.getActive(TypeEnum.classname), (MethodInstance) symt.getActive(TypeEnum.method)); - TypeEnum rtrn = TypeEnum.ERROR; + TypeEnum rtrn = null; String cls = null; switch (n.f0.f0.which) { case 0: @@ -194,7 +194,7 @@ public class SymTableVars<R> extends GJDepthFirst<R,SymbolTable> { (ClassInstance) symt.getActive(TypeEnum.classname), (MethodInstance) symt.getActive(TypeEnum.method)); - TypeEnum rtrn = TypeEnum.ERROR; + TypeEnum rtrn = null; switch (n.f0.f0.which) { case 0: rtrn = TypeEnum.intarray; break; diff --git a/st/TypeEnum.java b/st/TypeEnum.java index f6fc6ae..e469828 100644 --- a/st/TypeEnum.java +++ b/st/TypeEnum.java @@ -1,5 +1,5 @@ package st; public enum TypeEnum { - classname, method, intarray, bool, integer, CHECK, ERROR + classname, method, intarray, bool, integer } |