Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • anders_blomdell/labcomm
  • klaren/labcomm
  • tommyo/labcomm
  • erikj/labcomm
  • sven/labcomm
5 results
Select Git revision
Show changes
Showing
with 643 additions and 242 deletions
...@@ -14,10 +14,9 @@ aspect Signature { ...@@ -14,10 +14,9 @@ aspect Signature {
inh Decl Signature.parentDecl(); inh Decl Signature.parentDecl();
inh Decl SignatureList.parentDecl(); inh Decl SignatureList.parentDecl();
syn nta Signature Decl.getSignature() { syn nta Signature Decl.getSignature() {
SignatureList sl = new SignatureList(); SignatureList sl = new SignatureList();
genSigLineForDecl(sl, true); genSigLineForDecl(sl, true, this);
SignatureList fsl = new SignatureList(); SignatureList fsl = new SignatureList();
flatSignature(fsl); flatSignature(fsl);
Signature sig = new Signature(); Signature sig = new Signature();
...@@ -100,6 +99,29 @@ aspect Signature { ...@@ -100,6 +99,29 @@ aspect Signature {
return getIntBytes(getData(), version); return getIntBytes(getData(), version);
} }
public void SignatureList.addIntentions(Set<Intention> data, String comment) {
//addString(TypeInstance.getIntentionString(data), comment);
//create IntenionSignatureLine
IntentionSignatureLine line = new IntentionSignatureLine(indent, comment, new List());
//TODO: refactor out creation of sorted list of intentions
java.util.ArrayList<Intention> sorted = new ArrayList(data);
java.util.Collections.sort(sorted, TypeInstance.intentionComp);
for(Intention i : sorted) {
line.addIntention(i);
}
addSignatureLine(line);
}
eq IntentionSignatureLine.getData(int version) {
//String tmpString = TypeInstance.getIntentionString(getIntentions());
byte[] bs = TypeInstance.getIntentionBytes(getIntentions());
return bs;
}
public void SignatureList.addString(String data, String comment) { public void SignatureList.addString(String data, String comment) {
addSignatureLine(new StringSignatureLine(indent, comment, data)); addSignatureLine(new StringSignatureLine(indent, comment, data));
} }
...@@ -151,79 +173,200 @@ aspect Signature { ...@@ -151,79 +173,200 @@ aspect Signature {
} }
public void ASTNode.genSigLineForDecl(SignatureList list, boolean decl) { public void ASTNode.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
throw new Error(this.getClass().getName() + throw new Error(this.getClass().getName() +
".genSigLineForDecl(SignatureList list)" + ".genSigLineForDecl(SignatureList list)" +
" not declared"); " not declared");
} }
public void TypeDecl.genSigLineForDecl(SignatureList list, boolean decl) { public String TypeInstance.getIntentionString() {
return getIntentionString(intentions());
}
public static String TypeInstance.getIntentionString(List<Intention> intentions) {
if(intentions==null) return "";
Iterator<Intention> it = intentions.iterator();
return getIntentionString(it);
}
public static String TypeInstance.getIntentionString(Set<Intention> intentions) {
if(intentions==null) return "";
Iterator<Intention> it = intentions.iterator();
return getIntentionString(it);
}
public static String TypeInstance.getIntentionString(Iterator<Intention> it) {
StringBuilder sb = new StringBuilder();
while(it.hasNext()) {
Intention i = it.next();
sb.append(i.toString());
}
return sb.toString();
}
syn byte[] Intention.keyBytes() = getKey().getBytes();
syn byte[] Intention.valBytes() = getValue();
syn byte[] Intention.toByteArray() {
byte[] k = keyBytes();
byte[] v = valBytes();
int klen = Utilities.size_packed32(k.length);
int vlen = Utilities.size_packed32(v.length);
int tlen = k.length + v.length + Utilities.size_packed32(klen) + Utilities.size_packed32(vlen);
//int size = Utilities.size_packed32(tlen)+tlen;
byte result[] = new byte[tlen];
int pos=0;
// pos = Utilities.encodePacked32(tlen, result, pos, Utilities.size_packed32(tlen));
pos = Utilities.encodePacked32(k.length, result, pos, klen);
for(byte kb : k) {
result[pos++] = kb;
}
pos = Utilities.encodePacked32(v.length, result, pos, vlen);
for(byte vb : v) {
result[pos++] = vb;
}
return result;
}
public byte[] TypeInstance.getIntentionBytes() {
return getIntentionBytes(intentions());
}
public static byte[] TypeInstance.getIntentionBytes(List<Intention> intentions) {
if(intentions==null) return new byte[0];
Iterator<Intention> it = intentions.iterator();
return getIntentionBytes(it);
}
public static byte[] TypeInstance.getIntentionBytes(Set<Intention> intentions) {
if(intentions==null) return new byte[0];
Iterator<Intention> it = intentions.iterator();
return getIntentionBytes(it);
}
public static byte[] TypeInstance.getIntentionBytes(Iterator<Intention> it) {
java.util.ArrayList<byte[]> tmp = new java.util.ArrayList<byte[]>();
int tmpLen=0;
int numIntentions=0;
while(it.hasNext()) {
Intention i = it.next();
byte[] bs = i.toByteArray();
tmp.add(bs);
tmpLen+=bs.length;
numIntentions++;
}
byte result[] = new byte[tmpLen + Utilities.size_packed32(numIntentions)];
int pos = 0;
pos = Utilities.encodePacked32(numIntentions, result, 0, Utilities.size_packed32(numIntentions));
for(byte[] bs : tmp) {
for(byte b : bs) {
result[pos++] = b;
}
}
return result;
}
syn Set<Intention> Specification.emptyIntentions() = new HashSet<Intention>();
inh Set<Intention> ASTNode.noIntentions();
eq Specification.getChild(int i).noIntentions() = emptyIntentions();
syn Set<Intention> ASTNode.intentions();
eq ASTNode.intentions() = noIntentions();
eq TypeInstance.intentions() = intentionSet();
public void TypeInstance.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
// debugAnnotations(this.getName());
// list.addString(inst.getIntentionString(), "intention string");
if(addIntentions()) {
list.addIntentions(intentionSet(), "intentions");
}
getDataType().genSigLineForDecl(list, decl, this);
}
public void TypeDecl.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
//TODO intent
if(decl){ if(decl){
getType().genSigLineForDecl(list, decl); getTypeInstance().genSigLineForDecl(list, decl, this);
}else{ }else{
list.addTypeRef(this, "//TODO (from list.addTypeRef)"); list.addTypeRef(this, "//TODO (from list.addTypeRef)");
} }
} }
public void SampleDecl.genSigLineForDecl(SignatureList list, boolean decl) { public void SampleDecl.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
getType().genSigLineForDecl(list, decl); //TODO intent
getTypeInstance().genSigLineForDecl(list, decl, this);
} }
public void VoidType.genSigLineForDecl(SignatureList list, boolean decl) { public void VoidType.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
list.addInt(LABCOMM_STRUCT, "void"); list.addInt(LABCOMM_STRUCT, "void");
list.addInt(0, null); list.addInt(0, null);
} }
// public void SampleRefType.genSigLineForDecl(SignatureList list, boolean decl) { // public void SampleRefType.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
// list.addInt(LABCOMM_SAMPLE_REF, "sample"); // list.addInt(LABCOMM_SAMPLE_REF, "sample");
// } // }
public void PrimType.genSigLineForDecl(SignatureList list, boolean decl) { public void PrimType.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
list.addInt(getToken(), null); list.addInt(getToken(), null);
} }
/* For UserType, the decl parameter is ignored, as a UserType /* For UserType, the decl parameter is ignored, as a UserType
* will always be a TypeRef * will always be a TypeRef
*/ */
public void UserType.genSigLineForDecl(SignatureList list, boolean decl) { public void UserType.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
TypeDecl thet = lookupType(getName()); TypeDecl thet = lookupType(getName());
list.addTypeRef(thet, null); list.addTypeRef(thet, null);
} }
public void ArrayType.genSigLineForDecl(SignatureList list, boolean decl) { public void ArrayType.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
list.addInt(LABCOMM_ARRAY, signatureComment()); list.addInt(LABCOMM_ARRAY, signatureComment());
list.indent(); list.indent();
list.addInt(getNumExp(), null); list.addInt(getNumExp(), null);
for (int i = 0 ; i < getNumExp() ; i++) { for (int i = 0 ; i < getNumExp() ; i++) {
getExp(i).genSigLineForDecl(list, false); getExp(i).genSigLineForDecl(list, false, null);
} }
getType().genSigLineForDecl(list, false); getDataType().genSigLineForDecl(list, false, null);
list.unindent(); list.unindent();
list.add(null, "}"); list.add(null, "}");
} }
public void StructType.genSigLineForDecl(SignatureList list, boolean decl) { public void StructType.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
list.addInt(LABCOMM_STRUCT, "struct { " + getNumField() + " fields"); list.addInt(LABCOMM_STRUCT, "struct { " + getNumField() + " fields");
list.indent(); list.indent();
list.addInt(getNumField(), null); list.addInt(getNumField(), null);
for (int i = 0 ; i < getNumField() ; i++) { for (int i = 0 ; i < getNumField() ; i++) {
getField(i).genSigLineForDecl(list, false); getField(i).genSigLineForDecl(list, false, inst);
} }
list.unindent(); list.unindent();
list.add(null, "}"); list.add(null, "}");
} }
public void Field.genSigLineForDecl(SignatureList list, boolean decl) { // public void Field.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
list.addString(getName(), signatureComment()); // //XXX make intention
getType().genSigLineForDecl(list, decl); // list.addString(getName(), signatureComment());
} // super.genSigLineForDecl(list, decl, inst);
// //TODOintent
// //getDataType().genSigLineForDecl(list, decl, inst);
// }
public void IntegerLiteral.genSigLineForDecl(SignatureList list, boolean decl) { public void IntegerLiteral.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
list.addInt(Integer.parseInt(getValue()), null); list.addInt(Integer.parseInt(getValue()), null);
} }
public void VariableSize.genSigLineForDecl(SignatureList list, boolean decl) { public void VariableSize.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
list.addInt(0, null); list.addInt(0, null);
} }
} }
...@@ -6,31 +6,49 @@ aspect TypeCheck { ...@@ -6,31 +6,49 @@ aspect TypeCheck {
// void is not allowed as a field in a struct or an array element // void is not allowed as a field in a struct or an array element
syn boolean Type.isNull(); syn boolean DataType.isNull();
eq Type.isNull() = false; eq DataType.isNull() = false;
eq VoidType.isNull() = true; eq VoidType.isNull() = true;
eq UserType.isNull() = decl().isNull(); eq UserType.isNull() = decl().isNull();
syn boolean TypeDecl.isNull(); syn boolean TypeDecl.isNull();
eq TypeDecl.isNull() = getType().isNull(); eq TypeDecl.isNull() = getDataType().isNull();
public void ASTNode.nullTypeCheck() {} public void ASTNode.nullTypeCheck() {}
public void Field.nullTypeCheck() { public void Field.nullTypeCheck() {
if(getType().isNull()) { if(getDataType().isNull()) {
error("field " + getName() + " of struct "+ declName()+ " may not be of type void"); error("field " + getName() + " of struct "+ declName()+ " may not be of type void");
} }
} }
public void ParseArrayType.nullTypeCheck() { public void ParseArrayType.nullTypeCheck() {
if(getType().isNull()) { if(getDataType().isNull()) {
error("elements of array "+declName()+" may not be of type void"); error("elements of array "+declName()+" may not be of type void");
} }
} }
public void ArrayType.nullTypeCheck() { public void ArrayType.nullTypeCheck() {
if(getType().isNull()) { if(getDataType().isNull()) {
error("elements of array "+declName()+" may not be of type void"); error("elements of array "+declName()+" may not be of type void");
} }
} }
} }
aspect AnnotationCheck {
refine TypeCheck void ASTNode.typeCheck() {
refined(); // similar to call to super
annotationCheck();
}
public void ASTNode.annotationCheck() {}
public void TypeDecl.annotationCheck() {
Iterator<Intention> it = getTypeInstance().intentions().iterator();;
while(it.hasNext()) {
if(!it.next().getKey().equals("")) {
error("TypeDecl " + getName() + " has intentions. (Not allowed for typedefs)");
}
}
}
}
aspect User_Types { aspect User_Types {
syn String Type.getTypeName(); syn String DataType.getTypeName();
eq Type.getTypeName() = getClass().getName(); eq DataType.getTypeName() = getClass().getName();
eq PrimType.getTypeName() = getName(); eq PrimType.getTypeName() = getName();
eq UserType.getTypeName() = getName(); eq UserType.getTypeName() = getName();
syn boolean Type.isUserType(); syn boolean DataType.isUserType();
eq Type.isUserType() = false; eq DataType.isUserType() = false;
eq UserType.isUserType() = true; eq UserType.isUserType() = true;
} }
...@@ -14,8 +14,8 @@ aspect Type_References { ...@@ -14,8 +14,8 @@ aspect Type_References {
// The dependencies on other type declarations for a Decl. // The dependencies on other type declarations for a Decl.
coll Set<Decl> Decl.type_dependencies() [new HashSet<Decl>()] with add; coll Set<Decl> Decl.type_dependencies() [new HashSet<Decl>()] with add;
Field contributes ((UserType)getType()).decl() Field contributes ((UserType)getDataType()).decl()
when parentDecl() != null && getType().isUserType() when parentDecl() != null && getDataType().isUserType()
to Decl.type_dependencies() to Decl.type_dependencies()
for parentDecl(); for parentDecl();
...@@ -24,8 +24,8 @@ aspect Type_References { ...@@ -24,8 +24,8 @@ aspect Type_References {
to Decl.type_dependencies() to Decl.type_dependencies()
for parentDecl(); for parentDecl();
/* /*
Field contributes getType().decl() Field contributes getDataType().decl()
when parentDecl() != null && getType().isLeafType() when parentDecl() != null && getDataType().isLeafType()
to Decl.type_dependencies() to Decl.type_dependencies()
for parentDecl(); for parentDecl();
*/ */
......
aspect Encoding {
public class Utilities {
/* Size of packed32 variable */
public static int size_packed32(long data)
{
long d = data & 0xffffffff;
int result = 0;
int i;
for (i = 0 ; i == 0 || d != 0; i++, d = (d >>> 7)) {
result++;
}
return result;
}
public static int encodePacked32(long value, byte[] buf, int start, int len) {
int pos = start;
byte[] tmp = new byte[5];
long v = value & 0xffffffff;
int i;
for (i = 0 ; i == 0 || v != 0 ; i++, v = (v >> 7)) {
tmp[i] = (byte)(v & 0x7f);
}
if(i != len) {
throw new Error("wrong length, was: "+i+", expected "+len);
}
for (i = i - 1 ; i >= 0 ; i--) {
buf[pos++] = (byte)(tmp[i] | (i!=0?0x80:0x00));
}
return pos;
}
}
}
aspect PrintEnv {
public abstract class PrintEnv {
protected static class Printer {
private final String indentString = " ";
private boolean newline = true; // last print ended with newline
protected PrintStream out;
private Printer printer;
/** dummy constructor motivated by the FilePrinter subclass */
protected Printer() {
this.out = null;
}
public Printer(PrintStream out) {
this.out = out;
}
public void print(PrintEnv env, String s) {
if (newline) {
newline = false;
for (int i = 0 ; i < env.getIndent() ; i++) {
out.print(indentString);
}
}
out.print(s);
}
public void println(PrintEnv env, String s) {
print(env, s);
out.println();
newline = true;
}
public void println(PrintEnv env) {
out.println();
newline = true;
}
public PrintStream getPrintStream() {
return(out);
}
public void close() throws IOException {
//do nothing
}
}
protected static class FilePrinter extends Printer {
private File file;
private IOException exception;
public FilePrinter(PrintStream out) {
super(out);
}
public FilePrinter(File f) {
file = f;
File parentFile = f.getParentFile();
if(parentFile != null) {
parentFile.mkdirs();
}
}
public void close() throws IOException {
if (out != null) {
out.close();
}
if (exception != null) {
throw exception;
}
}
public void checkOpen() {
if (out == null && exception == null) {
try {
out = new PrintStream(new FileOutputStream(file));
} catch (IOException e) {
exception = e;
}
}
}
public void print(PrintEnv env, String s) {
checkOpen();
super.print(env,s);
}
public void println(PrintEnv env, String s) {
checkOpen();
super.println(env, s);
}
}
public final int version; //labcomm version (2006 or 2014)
public final String verStr; // version suffix to append (currently _2006 and empty string)
private Printer printer;
private int indent;
private int depth;
protected PrintEnv(PrintStream out) {
this(new Printer(out));
}
protected PrintEnv(Printer printer) {
this(printer, 2014);
}
protected PrintEnv(Printer printer, int version) {
this(0, printer, version);
}
protected PrintEnv(int indent, Printer printer, int version) {
this(indent, printer, version, 0);
}
protected PrintEnv(int indent, Printer printer, int version, int depth) {
this.version = version;
this.indent = indent;
this.printer = printer;
this.verStr = LabCommVersion.versionString(version);
this.depth = depth;
}
public void close() throws IOException {
printer.close();
}
public PrintStream getPrintStream() {
return printer.getPrintStream();
}
public void indent(int amount) {
indent += amount;
}
public void indent() {
indent(1);
}
public void unindent(int amount) {
indent -= amount;
if (indent < 0) {
throw new Error("Negative indent level");
}
}
public void unindent() {
unindent(1);
}
public void print(String s) {
printer.print(this, s);
}
public void println(String s) {
printer.println(this, s);
}
public void println() {
printer.println(this, "");
}
public void incDepth() {
depth++;
}
public void decDepth() {
if(depth<=0) {
throw new RuntimeException("decDepth() called when depth = "+depth);
}
depth--;
}
public int getDepth() {
return depth;
}
public int getVersion() {
return version;
}
public int getIndent() {
return indent;
}
public Printer getPrinter() {
return printer;
}
public boolean versionHasMetaData() {
return version != 2006;
}
}
}
...@@ -5,7 +5,14 @@ aspect Version { ...@@ -5,7 +5,14 @@ aspect Version {
*/ */
class LabCommVersion { class LabCommVersion {
public static String versionString(int version) { public static String versionString(int version) {
return (version == 2006) ? "2006" : ""; switch(version) {
case 2006:
return "2006";
case 2014:
return "2014";
default:
throw new Error("no versionString for version "+version);
}
} }
public static boolean versionHasPragma(int version) { public static boolean versionHasPragma(int version) {
......
...@@ -778,22 +778,22 @@ Avro has multiple codecs (for compression of the data): ...@@ -778,22 +778,22 @@ Avro has multiple codecs (for compression of the data):
\subsection{Abstract syntax} \subsection{Abstract syntax}
\begin{verbatim} \begin{verbatim}
Program ::= Decl*; Specification ::= Decl*;
abstract Decl ::= Type <Name:String>; abstract Decl ::= DataType <Name:String>;
TypeDecl : Decl; TypeDecl : Decl;
SampleDecl : Decl; SampleDecl : Decl;
Field ::= Type <Name:String>; Field ::= DataType <Name:String>;
abstract Type; abstract DataType;
VoidType : Type; VoidType : DataType;
SampleRefType : Type; SampleRefType : DataType;
PrimType : Type ::= <Name:String> <Token:int>; PrimType : DataType ::= <Name:String> <Token:int>;
UserType : Type ::= <Name:String>; UserType : DataType ::= <Name:String>;
StructType : Type ::= Field*; StructType : DataType ::= Field*;
ParseArrayType : Type ::= Type Dim*; ParseArrayType : DataType ::= DataType Dim*;
abstract ArrayType : Type ::= Type Exp*; abstract ArrayType : DataType ::= DataType Exp*;
VariableArrayType : ArrayType; VariableArrayType : ArrayType;
FixedArrayType : ArrayType; FixedArrayType : ArrayType;
......
...@@ -17,7 +17,7 @@ ifeq ($(UNAME_S),Darwin) ...@@ -17,7 +17,7 @@ ifeq ($(UNAME_S),Darwin)
else else
cd simple ; sh compile.sh && sh run.sh cd simple ; sh compile.sh && sh run.sh
$(MAKE) -C wiki_example test $(MAKE) -C wiki_example test
$(MAKE) -C user_types test $(MAKE) -C user_types all
endif endif
$(MAKE) -C duck_typing test $(MAKE) -C duck_typing test
$(MAKE) -C twoway test $(MAKE) -C twoway test
......
...@@ -27,7 +27,7 @@ if __name__ == '__main__': ...@@ -27,7 +27,7 @@ if __name__ == '__main__':
while True: while True:
value,decl = decoder.decode() value,decl = decoder.decode()
if value: if value:
print decl.name, 'says', value.says print decl.name, 'says', value
pass pass
pass pass
pass pass
......
...@@ -158,7 +158,7 @@ public class DynamicPart { ...@@ -158,7 +158,7 @@ public class DynamicPart {
} }
public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) { public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) {
Program ast = null; Specification ast = null;
InputStream in = new ByteArrayInputStream(lcDecl.getBytes()); InputStream in = new ByteArrayInputStream(lcDecl.getBytes());
LabCommScanner scanner = new LabCommScanner(in); LabCommScanner scanner = new LabCommScanner(in);
LabCommParser parser = new LabCommParser(); LabCommParser parser = new LabCommParser();
...@@ -166,7 +166,7 @@ public class DynamicPart { ...@@ -166,7 +166,7 @@ public class DynamicPart {
InRAMCompiler irc = null; InRAMCompiler irc = null;
try { try {
Program p = (Program)parser.parse(scanner); Specification p = (Specification)parser.parse(scanner);
p.errorCheck(errors); p.errorCheck(errors);
if (errors.isEmpty()) { if (errors.isEmpty()) {
ast = p; ast = p;
...@@ -197,7 +197,7 @@ public class DynamicPart { ...@@ -197,7 +197,7 @@ public class DynamicPart {
* @param handlers - a map <name, source> of handlers for the types in ast * @param handlers - a map <name, source> of handlers for the types in ast
* @return an InRAMCompiler object containing the generated clases * @return an InRAMCompiler object containing the generated clases
*/ */
private static InRAMCompiler handleAst(Program lcAST, HashMap<String, String> handlers) { private static InRAMCompiler handleAst(Specification lcAST, HashMap<String, String> handlers) {
Map<String, String> genCode = new HashMap<String, String>(); Map<String, String> genCode = new HashMap<String, String>();
try { try {
lcAST.J_gen(genCode, "labcomm.generated", 2014); lcAST.J_gen(genCode, "labcomm.generated", 2014);
......
...@@ -22,7 +22,7 @@ import se.lth.control.labcomm2014.Encoder; ...@@ -22,7 +22,7 @@ import se.lth.control.labcomm2014.Encoder;
import se.lth.control.labcomm2014.EncoderChannel; import se.lth.control.labcomm2014.EncoderChannel;
import AST.Parser; import AST.Parser;
import AST.Scanner; import AST.Scanner;
import AST.Program; import AST.Specification;
import beaver.Parser.Exception; import beaver.Parser.Exception;
...@@ -121,7 +121,7 @@ public class TestCompiler { ...@@ -121,7 +121,7 @@ public class TestCompiler {
} }
public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) { public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) {
Program ast = null; Specification ast = null;
InputStream in = new ByteArrayInputStream(lcDecl.getBytes()); InputStream in = new ByteArrayInputStream(lcDecl.getBytes());
Scanner scanner = new Scanner(in); Scanner scanner = new Scanner(in);
Parser parser = new Parser(); Parser parser = new Parser();
...@@ -129,7 +129,7 @@ public class TestCompiler { ...@@ -129,7 +129,7 @@ public class TestCompiler {
InRAMCompiler irc = null; InRAMCompiler irc = null;
try { try {
Program p = (Program)parser.parse(scanner); Specification p = (Specification)parser.parse(scanner);
p.errorCheck(errors); p.errorCheck(errors);
if (errors.isEmpty()) { if (errors.isEmpty()) {
ast = p; ast = p;
...@@ -207,7 +207,7 @@ public class TestCompiler { ...@@ -207,7 +207,7 @@ public class TestCompiler {
* @param handlers - a map <name, source> of handlers for the types in ast * @param handlers - a map <name, source> of handlers for the types in ast
* @return an InRAMCompiler object containing the generated clases * @return an InRAMCompiler object containing the generated clases
*/ */
private static InRAMCompiler handleAst(Program lcAST, HashMap<String, String> handlers) { private static InRAMCompiler handleAst(Specification lcAST, HashMap<String, String> handlers) {
Map<String, String> genCode = new HashMap<String, String>(); Map<String, String> genCode = new HashMap<String, String>();
try { try {
lcAST.J_gen(genCode, "labcomm.generated", 2013); lcAST.J_gen(genCode, "labcomm.generated", 2013);
......
...@@ -161,7 +161,7 @@ public class TestLabcommGen { ...@@ -161,7 +161,7 @@ public class TestLabcommGen {
} }
public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) { public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) {
Program ast = null; Specification ast = null;
InputStream in = new ByteArrayInputStream(lcDecl.getBytes()); InputStream in = new ByteArrayInputStream(lcDecl.getBytes());
LabCommScanner scanner = new LabCommScanner(in); LabCommScanner scanner = new LabCommScanner(in);
LabCommParser parser = new LabCommParser(); LabCommParser parser = new LabCommParser();
...@@ -169,7 +169,7 @@ public class TestLabcommGen { ...@@ -169,7 +169,7 @@ public class TestLabcommGen {
InRAMCompiler irc = null; InRAMCompiler irc = null;
try { try {
Program p = (Program)parser.parse(scanner); Specification p = (Specification)parser.parse(scanner);
p.errorCheck(errors); p.errorCheck(errors);
if (errors.isEmpty()) { if (errors.isEmpty()) {
ast = p; ast = p;
...@@ -200,7 +200,7 @@ public class TestLabcommGen { ...@@ -200,7 +200,7 @@ public class TestLabcommGen {
* @param handlers - a map <name, source> of handlers for the types in ast * @param handlers - a map <name, source> of handlers for the types in ast
* @return an InRAMCompiler object containing the generated clases * @return an InRAMCompiler object containing the generated clases
*/ */
private static InRAMCompiler handleAst(Program lcAST, HashMap<String, String> handlers) { private static InRAMCompiler handleAst(Specification lcAST, HashMap<String, String> handlers) {
Map<String, String> genCode = new HashMap<String, String>(); Map<String, String> genCode = new HashMap<String, String>();
try { try {
lcAST.J_gen(genCode, "labcomm.generated", 2014); lcAST.J_gen(genCode, "labcomm.generated", 2014);
...@@ -284,7 +284,7 @@ public class TestLabcommGen { ...@@ -284,7 +284,7 @@ public class TestLabcommGen {
* @param handlers - a map <name, source> of handlers for the types in ast * @param handlers - a map <name, source> of handlers for the types in ast
* @return an InRAMCompiler object containing the generated clases * @return an InRAMCompiler object containing the generated clases
*/ */
private static InRAMCompiler handleAstSeparate(Program lcAST, HashMap<String, String> handlers) { private static InRAMCompiler handleAstSeparate(Specification lcAST, HashMap<String, String> handlers) {
Map<String, String> genCode = new HashMap<String, String>(); Map<String, String> genCode = new HashMap<String, String>();
try { try {
lcAST.J_gen(genCode, "labcomm.generated", 2013); lcAST.J_gen(genCode, "labcomm.generated", 2013);
......
...@@ -10,7 +10,7 @@ using System.Threading.Tasks; ...@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace RobotCtrl namespace RobotCtrl
{ {
class Program class Specification
{ {
public static string IP_ADDRESS = "127.0.0.1"; public static string IP_ADDRESS = "127.0.0.1";
...@@ -20,7 +20,7 @@ namespace RobotCtrl ...@@ -20,7 +20,7 @@ namespace RobotCtrl
{ {
jointtarget val = new jointtarget { robax = new jointtarget.struct_robax(), extax = new jointtarget.struct_extax() }; jointtarget val = new jointtarget { robax = new jointtarget.struct_robax(), extax = new jointtarget.struct_extax() };
TcpClient client = new TcpClient(); TcpClient client = new TcpClient();
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Program.IP_ADDRESS), Program.PORT); IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Specification.IP_ADDRESS), Specification.PORT);
try try
{ {
client.Connect(serverEndPoint); client.Connect(serverEndPoint);
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="LCRobot.cs" /> <Compile Include="LCRobot.cs" />
<Compile Include="Program.cs" /> <Compile Include="Specification.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......