Skip to content
Snippets Groups Projects
Commit 7d7fd2be authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

cleanup and comment

parent 37fb1da8
No related branches found
No related tags found
No related merge requests found
...@@ -15,35 +15,6 @@ import se.lth.control.labcomm.DecoderChannel; ...@@ -15,35 +15,6 @@ import se.lth.control.labcomm.DecoderChannel;
import se.lth.control.labcomm.TypeDef; import se.lth.control.labcomm.TypeDef;
import se.lth.control.labcomm.TypeBinding; import se.lth.control.labcomm.TypeBinding;
// for BinaryScanner
// import beaver.Scanner;
// import beaver.Symbol;
// import se.lth.control.labcomm2014.compiler.LabComm;
// import se.lth.control.labcomm2014.compiler.LabCommParser;
//
// import se.lth.control.labcomm2014.compiler.List;
// import se.lth.control.labcomm2014.compiler.Program;
// import se.lth.control.labcomm2014.compiler.Decl;
// import se.lth.control.labcomm2014.compiler.TypeDecl;
// import se.lth.control.labcomm2014.compiler.SampleDecl;
// import se.lth.control.labcomm2014.compiler.Type;
// //import se.lth.control.labcomm2014.compiler.VoidType;
// //import se.lth.control.labcomm2014.compiler.SampleRefType;
// import se.lth.control.labcomm2014.compiler.PrimType;
// import se.lth.control.labcomm2014.compiler.UserType;
// import se.lth.control.labcomm2014.compiler.StructType;
// import se.lth.control.labcomm2014.compiler.Field;
// import se.lth.control.labcomm2014.compiler.ArrayType;
// import se.lth.control.labcomm2014.compiler.VariableArrayType;
// import se.lth.control.labcomm2014.compiler.FixedArrayType;
// import se.lth.control.labcomm2014.compiler.Dim;
// import se.lth.control.labcomm2014.compiler.Exp;
// import se.lth.control.labcomm2014.compiler.IntegerLiteral;
// import se.lth.control.labcomm2014.compiler.VariableSize;
//
////////////
public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler { public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler {
static class SelfBinding extends TypeDef { static class SelfBinding extends TypeDef {
...@@ -144,13 +115,15 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler { ...@@ -144,13 +115,15 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler {
} }
} }
//* temporary testing method */ private TypeDef getTypeDefForIndex(int sampleIndex) {
public TypeDef getTypeDefForIndex(int sampleIndex) {
return typeDefs.get(typeBindings.get(sampleIndex)); return typeDefs.get(typeBindings.get(sampleIndex));
} }
/** Factory method /** Factory method for use by application programs:
* registers a TypeDefParser for handling TypeDef and TypeBinding
* on the Decoder d.
*
* @return a new TypeDefParser registered on d * @return a new TypeDefParser registered on d
*/ */
public static TypeDefParser registerTypeDefParser(Decoder d) throws java.io.IOException { public static TypeDefParser registerTypeDefParser(Decoder d) throws java.io.IOException {
...@@ -165,12 +138,6 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler { ...@@ -165,12 +138,6 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler {
///// parsing ///// parsing
//
//
// Sketch of result types "unparsed labcomm-file"
//
//
public LinkedList<ParsedSymbol> symbolify() { public LinkedList<ParsedSymbol> symbolify() {
...@@ -206,6 +173,9 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler { ...@@ -206,6 +173,9 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler {
return sb.toString(); return sb.toString();
} }
/* An interface for using Visitor pattern to traverse
* ParsedTypeDefs
*/
public interface ParsedSymbolVisitor { public interface ParsedSymbolVisitor {
void visit(TypeSymbol s); void visit(TypeSymbol s);
void visit(SampleSymbol s); void visit(SampleSymbol s);
...@@ -255,7 +225,6 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler { ...@@ -255,7 +225,6 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler {
} }
public abstract class ParsedType extends ParsedSymbol{ public abstract class ParsedType extends ParsedSymbol{
//public abstract Type makeNode();
} }
public class SampleRefType extends ParsedType { public class SampleRefType extends ParsedType {
...@@ -338,7 +307,7 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler { ...@@ -338,7 +307,7 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler {
} }
public String toString() { public String toString() {
if(isVoid()) { //HERE BE DRAGONS: void type is empty struct if(isVoid()) { //void type is empty struct
return "void"; return "void";
} else { } else {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
......
...@@ -13,10 +13,6 @@ import java.io.EOFException; ...@@ -13,10 +13,6 @@ import java.io.EOFException;
import se.lth.control.labcomm.TypeDef; import se.lth.control.labcomm.TypeDef;
import se.lth.control.labcomm.TypeDefParser; import se.lth.control.labcomm.TypeDefParser;
// for BinaryScanner
import beaver.Scanner;
import beaver.Symbol;
import se.lth.control.labcomm2014.compiler.LabComm; import se.lth.control.labcomm2014.compiler.LabComm;
import se.lth.control.labcomm2014.compiler.LabCommParser; import se.lth.control.labcomm2014.compiler.LabCommParser;
...@@ -40,8 +36,10 @@ import se.lth.control.labcomm2014.compiler.Exp; ...@@ -40,8 +36,10 @@ import se.lth.control.labcomm2014.compiler.Exp;
import se.lth.control.labcomm2014.compiler.IntegerLiteral; import se.lth.control.labcomm2014.compiler.IntegerLiteral;
import se.lth.control.labcomm2014.compiler.VariableSize; import se.lth.control.labcomm2014.compiler.VariableSize;
////////////
/** A class for building a JastAdd AST from the parsed types
* created by a TypeDefParser. This class depends on the LabComm compiler.
*/
public class TypeDefVisitor implements TypeDefParser.ParsedSymbolVisitor { public class TypeDefVisitor implements TypeDefParser.ParsedSymbolVisitor {
///// tree building ///// tree building
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment