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
Loading items

Target

Select target project
  • anders_blomdell/labcomm
  • klaren/labcomm
  • tommyo/labcomm
  • erikj/labcomm
  • sven/labcomm
5 results
Select Git revision
  • anders.blomdell
  • compiler-refactoring
  • java_dyn_msg_dec
  • js
  • labcomm2013
  • labcomm2014
  • labcomm2014_tc31
  • master
  • pragma
  • typeref
  • v2013.0
  • v2014.0
  • v2014.1
13 results
Show changes
Showing
with 1201 additions and 507 deletions
......@@ -6,7 +6,7 @@ aspect PPIndentation {
inh String Field.pp_indent();
inh String StructType.pp_indent();
eq StructType.getField(int index).pp_indent() = pp_indent() + " ";
eq Program.getDecl(int index).pp_indent() = "";
eq Specification.getDecl(int index).pp_indent() = "";
}
......@@ -18,7 +18,7 @@ aspect PrettyPrint {
" not declared");
}
public void Program.pp(PrintStream out) {
public void Specification.pp(PrintStream out) {
for(int i = 0; i < getNumDecl(); i++) {
getDecl(i).pp(out);
}
......@@ -27,24 +27,24 @@ aspect PrettyPrint {
// Pretty print declarations
public void TypeDecl.pp(PrintStream out) {
out.print("typedef ");
getType().ppIdentifier(out, getName());
getDataType().ppIdentifier(out, getName());
out.println(";");
}
public void SampleDecl.pp(PrintStream out) {
out.print("sample ");
getType().ppIdentifier(out, getName());
getDataType().ppIdentifier(out, getName());
out.println(";");
}
public void Field.pp(PrintStream out) {
out.print(pp_indent());
getType().ppIdentifier(out, getName());
getDataType().ppIdentifier(out, getName());
out.println(";");
}
// Pretty print variable of a given type
public void Type.ppIdentifier(PrintStream out, String id) {
public void DataType.ppIdentifier(PrintStream out, String id) {
ppPrefix(out);
out.print(" ");
out.print(id);
......@@ -58,7 +58,7 @@ aspect PrettyPrint {
}
// PrettyPrint prefix type info
public void Type.ppPrefix(PrintStream out) {
public void DataType.ppPrefix(PrintStream out) {
throw new Error(this.getClass().getName() +
".ppPrefix(PrintStream out)" +
" not declared");
......@@ -68,9 +68,9 @@ aspect PrettyPrint {
out.print("void");
}
public String PrimType.toString() {
return getName();
}
// public void SampleRefType.ppPrefix(PrintStream out) {
// out.print("sample");
// }
public void PrimType.ppPrefix(PrintStream out) {
out.print(getName());
......@@ -81,7 +81,7 @@ aspect PrettyPrint {
}
public void ArrayType.ppPrefix(PrintStream out) {
getType().ppPrefix(out);
getDataType().ppPrefix(out);
}
public void StructType.ppPrefix(PrintStream out) {
......@@ -94,7 +94,7 @@ aspect PrettyPrint {
}
// PrettyPrint suffix type info (array dimensions)
public void Type.ppSuffix(PrintStream out) { }
public void DataType.ppSuffix(PrintStream out) { }
public void ArrayType.ppSuffix(PrintStream out) {
out.print("[");
......@@ -103,7 +103,7 @@ aspect PrettyPrint {
getExp(i).pp(out);
}
out.print("]");
getType().ppSuffix(out);
getDataType().ppSuffix(out);
}
public void IntegerLiteral.pp(PrintStream out) {
......
......@@ -4,149 +4,122 @@ aspect Python_CodeGenEnv {
// handles qualid nesting, indentation, file writing and
// prefix propagation
public class Python_env {
final private class Python_printer {
private boolean newline = true;
private PrintStream out;
public Python_printer(PrintStream out) {
this.out = out;
}
public void print(Python_env env, String s) {
if (newline) {
newline = false;
for (int i = 0 ; i < env.indent ; i++) {
out.print(" ");
}
}
out.print(s);
}
public void println(Python_env env, String s) {
print(env, s);
out.println();
newline = true;
}
public void println(Python_env env) {
out.println();
newline = true;
}
public class Python_env extends PrintEnv {
final private class Python_printer extends PrintEnv.Printer {
// public C_printer(PrintStream out) {
// super(out, " ");
// }
}
private int indent;
private Python_printer printer;
public Python_env(PrintStream out) {
this.indent = 0;
this.printer = new Python_printer(out);
}
public void indent() {
indent++;
}
public void unindent() {
indent--;
}
public void print(String s) {
printer.print(this, s);
}
public void println(String s) {
printer.println(this, s);
}
public void println() {
printer.println(this);
super(out);
}
}
}
aspect Python_CodeGen {
public void Program.Python_gen(PrintStream out, String baseName, int version) {
// Remove when Blomdell has verified that it is OK to ignore version
// when generating python code.
System.err.println("*** Warning! Python_gen ignores version: "+version);
public void Specification.Python_gen(PrintStream out, String baseName, int version) {
Python_env env = new Python_env(out);
env.println("#!/usr/bin/python");
env.println("# Auto generated " + baseName);
env.println();
env.println("import labcomm");
env.println("import StringIO");
env.println("import labcomm2014");
env.println();
Python_genTypes(env);
//env.println("typedef = [");
//env.indent();
//for (int i = 0 ; i < getNumDecl() ; i++) {
// getDecl(i).Python_genTypedefListEntry(env);
//}
//env.unindent();
//env.println("]");
env.println("sample = [");
env.println("typedef = tuple([");
env.indent();
for (int i = 0 ; i < getNumDecl() ; i++) {
getDecl(i).Python_genTypedefListEntry(env);
}
env.unindent();
env.println("])");
env.println("sample = tuple([");
env.indent();
for (int i = 0 ; i < getNumDecl() ; i++) {
getDecl(i).Python_genSampleListEntry(env);
}
env.unindent();
env.println("]");
env.println("])");
}
}
aspect PythonTypes {
public void Program.Python_genTypes(Python_env env) {
public void Specification.Python_genTypes(Python_env env) {
for (int i = 0 ; i < getNumDecl() ; i++) {
getDecl(i).Python_genSignature(env);
getDecl(i).Python_genSignatureAndTypedef(env);
}
}
public void Decl.Python_genSignature(Python_env env) {
public void Decl.Python_genSignatureAndTypedef(Python_env env) {
throw new Error(this.getClass().getName() +
".Python_genSignature(Python_env env)" +
".Python_genSignatureAndTypedef(Python_env env)" +
" not declared");
}
public void TypeDecl.Python_genSignature(Python_env env) {
/*
public void TypeDecl.Python_genSignatureAndTypedef(Python_env env) {
env.println("class " + getName() + "(object):");
env.indent();
env.println("signature = labcomm.typedef('" + getName() + "',");
env.print("typedef = labcomm2014.typedef(");
Python_genIntentions(env);
env.println(",");
env.indent();
getType().Python_genSignature(env);
getTypeInstance().Python_genTypedef(env);
env.unindent();
env.println(")");
env.unindent();
env.println();
*/
}
public void SampleDecl.Python_genSignature(Python_env env) {
public void SampleDecl.Python_genSignatureAndTypedef(Python_env env) {
env.println("class " + getName() + "(object):");
env.indent();
env.println("signature = labcomm.sample('" + getName() + "', ");
env.print("signature = labcomm2014.sample(");
Python_genIntentions(env);
env.println(",");
env.indent();
getType().Python_genSignature(env);
getDataType().Python_genSignature(env);
env.unindent();
env.println(")");
env.print("typedef = labcomm2014.sample(");
Python_genIntentions(env);
env.println(",");
env.indent();
getTypeInstance().Python_genTypedef(env);
env.unindent();
env.println(")");
env.unindent();
env.println();
}
public void Decl.Python_genIntentions(Python_env env) {
getTypeInstance().Python_genIntentions(env);
}
public void TypeInstance.Python_genIntentions(Python_env env) {
// env.print("{");
// for(Intention i : sortedIntentions()) {
// env.print("'"+i.getKey()+"':'"+new String(i.getValue())+"', ");
// }
// env.print("}");
env.print("tuple((");
for(Intention i : sortedIntentions()) {
env.print("('"+i.getKey()+"','"+new String(i.getValue())+"'), ");
}
env.print("))");
}
public void TypeInstance.Python_genTypedef(Python_env env) {
getDataType().Python_genTypedef(env);
}
public void UserType.Python_genSignature(Python_env env) {
lookupType(getName()).getType().Python_genSignature(env);
lookupType(getName()).getDataType().Python_genSignature(env);
}
public void Type.Python_genSignature(Python_env env) {
public void DataType.Python_genSignature(Python_env env) {
throw new Error(this.getClass().getName() +
".Python_genSignature(Python_env env)" +
" not declared");
......@@ -154,32 +127,33 @@ aspect PythonTypes {
public void PrimType.Python_genSignature(Python_env env) {
switch (getToken()) {
case LABCOMM_BOOLEAN: { env.print("labcomm.BOOLEAN()"); } break;
case LABCOMM_BYTE: { env.print("labcomm.BYTE()"); } break;
case LABCOMM_SHORT: { env.print("labcomm.SHORT()"); } break;
case LABCOMM_INT: { env.print("labcomm.INTEGER()"); } break;
case LABCOMM_LONG: { env.print("labcomm.LONG()"); } break;
case LABCOMM_FLOAT: { env.print("labcomm.FLOAT()"); } break;
case LABCOMM_DOUBLE: { env.print("labcomm.DOUBLE()"); } break;
case LABCOMM_STRING: { env.print("labcomm.STRING()"); } break;
case LABCOMM_BOOLEAN: { env.print("labcomm2014.BOOLEAN()"); } break;
case LABCOMM_BYTE: { env.print("labcomm2014.BYTE()"); } break;
case LABCOMM_SHORT: { env.print("labcomm2014.SHORT()"); } break;
case LABCOMM_INT: { env.print("labcomm2014.INTEGER()"); } break;
case LABCOMM_LONG: { env.print("labcomm2014.LONG()"); } break;
case LABCOMM_FLOAT: { env.print("labcomm2014.FLOAT()"); } break;
case LABCOMM_DOUBLE: { env.print("labcomm2014.DOUBLE()"); } break;
case LABCOMM_STRING: { env.print("labcomm2014.STRING()"); } break;
case LABCOMM_SAMPLE: { env.print("labcomm2014.SAMPLE()"); } break;
}
}
public void ArrayType.Python_genSignature(Python_env env) {
env.print("labcomm.array([");
env.print("labcomm2014.array([");
for (int i = 0 ; i < getNumExp() ; i++) {
if (i > 0) { env.print(", "); }
env.print(getExp(i).Python_getValue());
}
env.println("],");
env.indent();
getType().Python_genSignature(env);
getDataType().Python_genSignature(env);
env.print(")");
env.unindent();
}
public void StructType.Python_genSignature(Python_env env) {
env.println("labcomm.struct([");
env.println("labcomm2014.struct([");
env.indent();
for (int i = 0 ; i < getNumField() ; i++) {
if (i > 0) { env.println(","); }
......@@ -190,12 +164,74 @@ aspect PythonTypes {
}
public void VoidType.Python_genSignature(Python_env env) {
env.println("labcomm.struct([])");
env.println("labcomm2014.struct([])");
}
public void Field.Python_genSignature(Python_env env) {
env.print("('" + getName() + "', ");
getType().Python_genSignature(env);
env.print("(");
Python_genIntentions(env);
env.print(", ");
getDataType().Python_genSignature(env);
env.print(")");
}
public void UserType.Python_genTypedef(Python_env env) {
env.println(getName() + ".typedef");
}
public void DataType.Python_genTypedef(Python_env env) {
throw new Error(this.getClass().getName() +
".Python_genTypedef(Python_env env)" +
" not declared");
}
public void PrimType.Python_genTypedef(Python_env env) {
switch (getToken()) {
case LABCOMM_BOOLEAN: { env.print("labcomm2014.BOOLEAN()"); } break;
case LABCOMM_BYTE: { env.print("labcomm2014.BYTE()"); } break;
case LABCOMM_SHORT: { env.print("labcomm2014.SHORT()"); } break;
case LABCOMM_INT: { env.print("labcomm2014.INTEGER()"); } break;
case LABCOMM_LONG: { env.print("labcomm2014.LONG()"); } break;
case LABCOMM_FLOAT: { env.print("labcomm2014.FLOAT()"); } break;
case LABCOMM_DOUBLE: { env.print("labcomm2014.DOUBLE()"); } break;
case LABCOMM_STRING: { env.print("labcomm2014.STRING()"); } break;
case LABCOMM_SAMPLE: { env.print("labcomm2014.SAMPLE()"); } break;
}
}
public void ArrayType.Python_genTypedef(Python_env env) {
env.print("labcomm2014.array([");
for (int i = 0 ; i < getNumExp() ; i++) {
if (i > 0) { env.print(", "); }
env.print(getExp(i).Python_getValue());
}
env.println("],");
env.indent();
getDataType().Python_genTypedef(env);
env.print(")");
env.unindent();
}
public void StructType.Python_genTypedef(Python_env env) {
env.println("labcomm2014.struct([");
env.indent();
for (int i = 0 ; i < getNumField() ; i++) {
if (i > 0) { env.println(","); }
getField(i).Python_genTypedef(env);
}
env.print("])");
env.unindent();
}
public void VoidType.Python_genTypedef(Python_env env) {
env.println("labcomm2014.struct([])");
}
public void Field.Python_genTypedef(Python_env env) {
env.print("(");
Python_genIntentions(env);
env.print(", ");
getDataType().Python_genTypedef(env);
env.print(")");
}
......@@ -203,14 +239,14 @@ aspect PythonTypes {
}
public void TypeDecl.Python_genTypedefListEntry(Python_env env) {
env.println("('" + getName() + "', " + getName() + ".signature),");
env.println(getName() + ",");
}
public void Decl.Python_genSampleListEntry(Python_env env) {
}
public void SampleDecl.Python_genSampleListEntry(Python_env env) {
env.println("('" + getName() + "', " + getName() + ".signature),");
env.println(getName()+ ",");
}
public String Exp.Python_getValue() {
......
......@@ -77,7 +77,7 @@ aspect RAPID_CodeGen {
throw new UnsupportedOperationException();
}
public void Program.RAPID_gen(String file, String prefix, int version)
public void Specification.RAPID_gen(String file, String prefix, int version)
throws IOException
{
PrintStream ps = new PrintStream(new FileOutputStream(new File(file)));
......@@ -85,7 +85,7 @@ aspect RAPID_CodeGen {
RAPID_gen(env);
}
public void Program.RAPID_gen(RAPID_env env)
public void Specification.RAPID_gen(RAPID_env env)
{
for (int i = 0; i < getNumDecl(); i++) {
getDecl(i).RAPID_gen(env);
......@@ -126,7 +126,7 @@ aspect RAPID_CodeGen {
public void SampleDecl.RAPID_gen(RAPID_env env) {
// Add type declarations
String fullName = getType().RAPID_AddType(env, getName());
String fullName = getDataType().RAPID_AddType(env, getName());
// Add signature constants
String sig_len_name = "signature_len_" + getName();
String sig_name = "signature_" + getName();
......@@ -167,7 +167,7 @@ aspect RAPID_CodeGen {
params.add("VAR LabComm_Stream st");
params.add("VAR LabComm_Decoder_Sample s");
stmts.add("VAR " + fullName + " tmp;");
getType().RAPID_AddDecodeInstr(env, stmts, "tmp", "st");
getDataType().RAPID_AddDecodeInstr(env, stmts, "tmp", "st");
stmts.add("% s.handler % tmp;");
env.addProc("Decode_And_Handle_" + getName(), params, stmts);
......@@ -201,11 +201,11 @@ aspect RAPID_CodeGen {
params.add("VAR LabComm_Encoder_Sample s");
params.add("VAR " + fullName + " val");
stmts.add("Encode_Packed st, s.user_id;");
getType().RAPID_AddEncodeInstr(env, stmts, "val", "st");
getDataType().RAPID_AddEncodeInstr(env, stmts, "val", "st");
env.addProc("Encode_" + getName(), params, stmts);
}
public String Type.RAPID_AddType(RAPID_env env, String name) {
public String DataType.RAPID_AddType(RAPID_env env, String name) {
throw new UnsupportedOperationException("RAPID code generation does (currently) not support "+getClass().getSimpleName());
}
......@@ -214,7 +214,7 @@ aspect RAPID_CodeGen {
for (int i = 0; i < getNumField(); i++) {
Field f = getField(i);
components.add(
f.getType().RAPID_AddType(env, name + "_" + f.getName()) +
f.getDataType().RAPID_AddType(env, name + "_" + f.getName()) +
" " + f.getName() + ";");
}
String typeName = env.addRecord(name, components);
......@@ -222,7 +222,7 @@ aspect RAPID_CodeGen {
}
public String FixedArrayType.RAPID_AddType(RAPID_env env, String name) {
String typeName = getType().RAPID_AddType(env, name + "_e");
String typeName = getDataType().RAPID_AddType(env, name + "_e");
if (getNumExp() > 1) {
throw new UnsupportedOperationException("RAPID generation only (currently) supports one-dimensional arrays");
}
......@@ -251,7 +251,7 @@ aspect RAPID_CodeGen {
throw new UnsupportedOperationException("RAPID code generation does not (currently) support "+getName());
}
public void Type.RAPID_AddDecodeInstr(RAPID_env env,
public void DataType.RAPID_AddDecodeInstr(RAPID_env env,
java.util.List<String> instrs,
String var_name, String stream_name) {
throw new UnsupportedOperationException("RAPID code generation does not (currently) support "+getClass().getSimpleName());
......@@ -261,7 +261,7 @@ aspect RAPID_CodeGen {
java.util.List<String> instrs,
String var_name, String stream_name) {
for (int i = 0; i < getNumField(); i++) {
getField(i).getType().RAPID_AddDecodeInstr(env, instrs,
getField(i).getDataType().RAPID_AddDecodeInstr(env, instrs,
var_name + "." + getField(i).getName(), stream_name);
}
}
......@@ -270,7 +270,7 @@ aspect RAPID_CodeGen {
java.util.List<String> instrs,
String var_name, String stream_name) {
for (int i = 1; i <= getExp(0).RAPID_getValue(); i++) {
getType().RAPID_AddDecodeInstr(env, instrs,
getDataType().RAPID_AddDecodeInstr(env, instrs,
var_name + ".e" + i, stream_name);
}
}
......@@ -305,7 +305,7 @@ aspect RAPID_CodeGen {
}
}
public void Type.RAPID_AddEncodeInstr(RAPID_env env,
public void DataType.RAPID_AddEncodeInstr(RAPID_env env,
java.util.List<String> instrs,
String var_name, String stream_name) {
throw new UnsupportedOperationException("RAPID code generation does not (currently) support "+getClass().getSimpleName());
......@@ -315,7 +315,7 @@ aspect RAPID_CodeGen {
java.util.List<String> instrs,
String var_name, String stream_name) {
for (int i = 0; i < getNumField(); i++) {
getField(i).getType().RAPID_AddEncodeInstr(env, instrs,
getField(i).getDataType().RAPID_AddEncodeInstr(env, instrs,
var_name + "." + getField(i).getName(), stream_name);
}
}
......@@ -324,7 +324,7 @@ aspect RAPID_CodeGen {
java.util.List<String> instrs,
String var_name, String stream_name) {
for (int i = 1; i <= getExp(0).RAPID_getValue(); i++) {
getType().RAPID_AddEncodeInstr(env, instrs,
getDataType().RAPID_AddEncodeInstr(env, instrs,
var_name + ".e" + i, stream_name);
}
}
......
/* Temporary aspect with forwarding methods */
aspect Refactoring {
syn int ArrayType.getNumExp() = getDim().getNumExp();
syn Exp ArrayType.getExp(int i) = getDim().getExp(i);
syn String Decl.getName() = getTypeInstance().getName();
syn DataType Decl.getDataType() = getTypeInstance().getDataType();
syn String TypeInstance.getName() = getAnnotations().getName();
public Annotations Annotations.addName(String n) {
//XXX TODO: check if name already exists
addAnnotation(new Intention("",n.getBytes()));
return this;
}
public Field.Field(TypeInstance t) {
this(t.getDataType(), t.getAnnotations());
}
public TypeInstance.TypeInstance(DataType t, String n, Annotations a) {
this(t, a.addName(n));
}
public TypeInstance.TypeInstance(DataType t, String n) {
this(t, new Annotations().addName(n));
System.out.println("WARNING! TypeInstance(DataType, String) ignoring intention list");
}
syn Annotation TypeInstance.getAnnotation(int i) = getAnnotations().getAnnotation(i);
}
This diff is collapsed.
......@@ -6,31 +6,49 @@ aspect TypeCheck {
// void is not allowed as a field in a struct or an array element
syn boolean Type.isNull();
eq Type.isNull() = false;
syn boolean DataType.isNull();
eq DataType.isNull() = false;
eq VoidType.isNull() = true;
eq UserType.isNull() = decl().isNull();
syn boolean TypeDecl.isNull();
eq TypeDecl.isNull() = getType().isNull();
eq TypeDecl.isNull() = getDataType().isNull();
public void ASTNode.nullTypeCheck() {}
public void Field.nullTypeCheck() {
if(getType().isNull()) {
if(getDataType().isNull()) {
error("field " + getName() + " of struct "+ declName()+ " may not be of type void");
}
}
public void ParseArrayType.nullTypeCheck() {
if(getType().isNull()) {
if(getDataType().isNull()) {
error("elements of array "+declName()+" may not be of type void");
}
}
public void ArrayType.nullTypeCheck() {
if(getType().isNull()) {
if(getDataType().isNull()) {
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 {
syn String Type.getTypeName();
eq Type.getTypeName() = getClass().getName();
syn String DataType.getTypeName();
eq DataType.getTypeName() = getClass().getName();
eq PrimType.getTypeName() = getName();
eq UserType.getTypeName() = getName();
syn boolean Type.isUserType();
eq Type.isUserType() = false;
syn boolean DataType.isUserType();
eq DataType.isUserType() = false;
eq UserType.isUserType() = true;
}
......@@ -14,8 +14,8 @@ aspect Type_References {
// The dependencies on other type declarations for a Decl.
coll Set<Decl> Decl.type_dependencies() [new HashSet<Decl>()] with add;
Field contributes ((UserType)getType()).decl()
when parentDecl() != null && getType().isUserType()
Field contributes ((UserType)getDataType()).decl()
when parentDecl() != null && getDataType().isUserType()
to Decl.type_dependencies()
for parentDecl();
......@@ -24,8 +24,8 @@ aspect Type_References {
to Decl.type_dependencies()
for parentDecl();
/*
Field contributes getType().decl()
when parentDecl() != null && getType().isLeafType()
Field contributes getDataType().decl()
when parentDecl() != null && getDataType().isLeafType()
to Decl.type_dependencies()
for parentDecl();
*/
......
This diff is collapsed.
aspect Version {
/* An auxilliary class for handling naming and prefixes connected
* to the LabComm version
*/
class LabCommVersion {
public static String versionString(int version) {
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) {
return version != 2006;
}
}
}
aspect DeclNames {
inh String Type.declName();
eq Decl.getType().declName() = getName();
inh String Field.declName();
eq StructType.getField(int i).declName() = declName();
//TODO: aspect should be renamed to parent-something
inh Decl Type.parentDecl();
inh Decl Field.parentDecl();
eq Decl.getType().parentDecl() = this;
eq StructType.getField(int i).parentDecl() = parentDecl();
}
import java.util.Collection;
aspect ErrorCheck {
syn int ASTNode.lineNumber() = getLine(getStart());
protected String ASTNode.errors = null;
protected void ASTNode.error(String s) {
s = "Error at " + lineNumber() + ": " + s;
if(errors == null) {
errors = s;
} else {
errors = errors + "\n" + s;
}
}
protected boolean ASTNode.hasErrors() {
return errors != null;
}
public void ASTNode.errorCheck(Collection collection) {
nameCheck();
typeCheck();
if(hasErrors())
collection.add(errors);
for(int i = 0; i < getNumChild(); i++) {
getChild(i).errorCheck(collection);
}
}
}
Program ::= Decl*;
//TODO: Add signatures to the abstract grammar, so that
//they can be extended and refined by more than one aspect.
//sketch:
Signature ::= SignatureList FlatSignatureList:SignatureList;
SignatureList ::= SignatureLine*;
abstract SignatureLine ::= <Indent:int> <Comment:String>;
abstract DataSignatureLine : SignatureLine;
ByteArraySignatureLine : DataSignatureLine ::= <Data:byte[]>;
IntSignatureLine : DataSignatureLine ::= <Data:int>;
StringSignatureLine : DataSignatureLine ::= <Data:String>;
TypeRefSignatureLine : SignatureLine ::= Decl;
//abstract Decl ::= Type <Name:String>;
// the signature list be defined as a non-terminal attribute:
abstract Decl ::= Type <Name:String> /Signature/;
TypeDecl : Decl;
SampleDecl : Decl;
Field ::= Type <Name:String>;
abstract Type;
VoidType : Type;
PrimType : Type ::= <Name:String> <Token:int>;
UserType : Type ::= <Name:String>;
StructType : Type ::= Field*;
ParseArrayType : Type ::= Type Dim*;
abstract ArrayType :Type ::= Type Exp*;
VariableArrayType : ArrayType;
FixedArrayType : ArrayType;
Dim ::= Exp*;
abstract Exp;
IntegerLiteral : Exp ::= <Value:String>;
VariableSize : Exp;
.PHONY: all
all: ant-all
.PHONY: test
test: ant-test
.PHONY: clean
clean: ant-clean
rm -f *~
.PHONY: distclean
distclean: clean ant-distclean
.PHONY: ant-%
ant-%:
ant $*
This diff is collapsed.
This diff is collapsed.
*** CS_CodeGen.old 2010-06-03 13:46:00.000000000 +0200
--- CS_CodeGen.jrag 2010-06-03 14:05:00.000000000 +0200
***************
*** 419,424 ****
--- 419,426 ----
for (int i = 0 ; i < getNumExp() ; i++) {
String limit = getExp(i).CS_emitEncoder(env,
name + ".GetLength(" + i + ")");
+ env.println("{");
+ env.indent();
env.println("int i_" + (baseDepth + i) + "_max = " + limit + ";");
}
String index = null;
***************
*** 434,439 ****
--- 436,443 ----
for (int i = 0 ; i < getNumExp() ; i++) {
env.print_for_end();
}
+ env.unindent();
+ env.println("}");
}
public String Exp.CS_emitEncoder(CS_env env, String name) {
***************
*** 725,730 ****
--- 729,735 ----
public void PrimType.CS_emitType(CS_env env) {
switch (getToken()) {
case LABCOMM_STRING: { env.print("String"); } break;
+ case LABCOMM_BOOLEAN: { env.print("bool"); } break;
default: { env.print(getName()); } break;
}
}
This diff is collapsed.
#!/bin/sh
java -jar /lib/labcomm2014_compiler.jar "$@"
File added
File added