Skip to main content
Sign in
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
  • labcomm2014
  • labcomm2006
  • master
  • python_sig_hash
  • typedefs
  • anders.blomdell
  • typeref
  • pragma
  • compiler-refactoring
  • labcomm2013
  • v2006.0
  • v2013.0
  • v2014.0
  • v2014.1
  • v2014.2
  • v2014.3
  • v2014.4
  • v2014.5
  • v2014.6
  • v2015.0
20 results

Target

Select target project
  • Anders Blomdell / LabComm
  • Anton Klarén / LabComm
  • Tommy Olofsson / LabComm
  • Erik Jansson / LabComm
  • Sven Gestegård Robertz / LabComm
5 results
Select Git revision
  • labcomm2014_tc31
  • labcomm2014
  • master
  • js
  • java_dyn_msg_dec
  • anders.blomdell
  • typeref
  • pragma
  • compiler-refactoring
  • labcomm2013
  • v2013.0
  • v2014.0
  • v2014.1
13 results
Show changes

Commits on Source 278

178 additional commits have been omitted to prevent performance issues.
326 files
+ 15190
7608
Compare changes
  • Side-by-side
  • Inline

Files

.bzrignore

deleted100644 → 0
+0 −41
Original line number Original line Diff line number Diff line
AST
AST/*
LabComm.class
labComm.jar
lib/java/se/lth/control/labcomm/LabComm.class
lib/java/se/lth/control/labcomm/LabCommDecoderChannel.class
lib/java/se/lth/control/labcomm/LabCommDecoder.class
lib/java/se/lth/control/labcomm/LabCommDecoderRegistry.class
lib/java/se/lth/control/labcomm/LabCommDecoderRegistry$Entry.class
lib/java/se/lth/control/labcomm/LabCommDispatcher.class
lib/java/se/lth/control/labcomm/LabCommEncoderChannel.class
lib/java/se/lth/control/labcomm/LabCommEncoder.class
lib/java/se/lth/control/labcomm/LabCommEncoderRegistry.class
lib/java/se/lth/control/labcomm/LabCommEncoderRegistry$Entry.class
lib/java/se/lth/control/labcomm/LabCommHandler.class
lib/java/se/lth/control/labcomm/LabCommReader.class
lib/java/se/lth/control/labcomm/LabCommSample.class
lib/java/se/lth/control/labcomm/LabCommType.class
lib/java/se/lth/control/labcomm/LabCommWriter.class
gen
labcomm.dll
labcomm.jar
example.c
example.h
example.py
examples/wiki_example/example.encoded
example.encoded
examples/simple/*.class
examples/simple/encoded_data
examples/simple/example_decoder
examples/simple/example_encoder
lib/c/test/test_labcomm_basic_type_encoding
lib/c/test/test_labcomm_generated_encoding
lib/java/se/lth/control/labcomm/WriterWrapper.class
lib/c/liblabcomm.so.1
lib/c/test/test_labcomm_pthread_scheduler
lib/c/liblabcomm_plain_c.so.1
lib/c/test/test_signature_plain_c
test/test_signature_numbers
lib/c/test/test_signature_numbers
lib/c/test/test_labcomm
+2 −29
Original line number Original line Diff line number Diff line
*~
*.class
*.class
*.o
*.o
lib/c/liblabcomm.a
lib/c/liblabcomm.so
lib/c/liblabcomm.so.1
lib/c/liblabcomm2006.so.1
lib/c/liblabcomm2006.so
lib/c/liblabcomm2006.a
lib/c/liblabcomm2014.so.1
lib/c/liblabcomm2014.so
lib/c/liblabcomm2014.a
lib/c/test/test_labcomm
lib/c/test/test_labcomm_basic_type_encoding
lib/c/test/test_labcomm_copy
lib/c/test/test_labcomm_generated_encoding
lib/c/test/test_labcomm_pthread_scheduler
lib/c/test/test_signature_numbers
compiler/AST/
compiler/labcomm_compiler.jar
encoded_data
encoded_data06
gen
gen06
*.pyc
*.pyc
examples/twoway/gen/
examples/dynamic/gen
lib/csharp/labcomm.dll
lib/java/gen/
lib/java/labcomm*.jar
examples/simple/example_decoder
examples/simple/example_decoder06
examples/simple/example_encoder
examples/simple/example_encoder06

LICENSE.rationale

0 → 100644
+73 −0
Original line number Original line Diff line number Diff line
Rationale for the licensing choosen for LabComm
===============================================

Primary goal:   the owners of systems with LabComm communication in it, 
                should have the liberty to replace the LabComm parts with 
                any software they see fit.

Secondary goal: it should be possible to release propreitary software
                with LabComm.


Wanted software architecture
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

+------------------------------------------------------------+
| Propreitary software (any license)                         |
+------------------------------------------------------------+
| Labcomm glue (LGPL)                                        |
+--------------+-----+--------------+                        |
|  Generated   |     |  Generated   |                        |
|   encoder/   |     |   encoder/   |                        |
|   decoder    | * * |   decoder    |                        |
| (  GPLv3 +   |     | (  GPLv3 +   |        +---------------+
|  permission) |     |  permission) |        |  Non-system   |
+--------------+-----+--------------+--+     |    library    |
| LabComm library (GPLv3 + permission) |     | (any license) | 
+--------------------------------------+-----+----------+----+
| System library (any license)                          |    |
+-------------------------------------------------------+    |
| OS (any license)                                           |
+------------------------------------------------------------+

License considerations
^^^^^^^^^^^^^^^^^^^^^^

We need to allow linking to the LabComm library from the LGPL glue
(see http://www.gnu.org/licenses/gpl-faq.html#GPLIncompatibleLibs).

We can not set a license on generated code
(http://www.gnu.org/licenses/gpl-faq.html#GPLOutput), 
but when used with the LabComm library we can force it 
to be licensed under GPLv3.


Suggested license for all library files
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Copyright 2013 Anders Blomdell <anders.blomdell@control.lth.se>

This file is part of LabComm.

LabComm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

LabComm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Additional permission under GNU GPL version 3 section 7

If you modify this Program, or any covered work, by directly linking 
any functionality of it, with the the exception of calls denoting the 
boundary of encoded samples and calls encoding primitive datatypes,
with any software licensed under the GNU Lesser General Public License, 
the licensors of this Program grant you additional permission to convey 
the resulting work. 
+25 −25
Original line number Original line Diff line number Diff line
SUBDIRS=compiler lib test examples
SUBDIRS=compiler lib test examples packaging
export LABCOMM_JAR=$(shell pwd)/compiler/labcomm_compiler.jar
export LABCOMM_JAR=$(shell pwd)/compiler/labcomm2014_compiler.jar
export LABCOMM=java -jar $(LABCOMM_JAR) 
export LABCOMM=java -jar $(LABCOMM_JAR) 
export VALGRIND=valgrind --leak-check=full --error-exitcode=1


all: $(SUBDIRS:%=make-%)
UNAME_S=$(shell uname -s)


.PHONY: make-compiler
.PHONY: all
make-compiler:
all: $(SUBDIRS:%=all-%)
	cd compiler ; ant jar


.PHONY: make-%
.PHONY: all-%
make-%:
all-%:
	LD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $* -e 
ifeq ($(UNAME_S),Darwin)
	DYLD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $*
else
	LD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $*
endif


.PHONY: test
.PHONY: test
test: $(SUBDIRS:%=test-%)
test: $(SUBDIRS:%=test-%)


.PHONY: test-compiler
test-compiler:
	$(MAKE) -C test compiler_errors

.PHONY: test-%
.PHONY: test-%
test-%:
test-%:
	LD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $* -e test
ifeq ($(UNAME_S),Darwin)
	DYLD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $* test
else
	LD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $* test
endif


.PHONY: clean
.PHONY: clean
clean: $(SUBDIRS:%=clean-%)
clean: $(SUBDIRS:%=clean-%)


.PHONY: clean-compiler
clean-compiler:
	cd compiler ; ant clean

.PHONY: clean-%
.PHONY: clean-%
clean-%:
clean-%:
	$(MAKE) -C $* -e clean
	$(MAKE) -C $* clean


.PHONY: distclean
.PHONY: distclean
distclean: $(SUBDIRS:%=distclean-%)
distclean: clean $(SUBDIRS:%=distclean-%)

.PHONY: distclean-compiler
distclean-compiler:
	cd compiler ; ant clean


.PHONY: distclean-%
.PHONY: distclean-%
distclean-%:
distclean-%:
	$(MAKE) -C $* -e distclean
	$(MAKE) -C $* distclean

.PHONY: srpm
srpm:
	make -C packaging $@

compiler/.gitignore

0 → 100644
+4 −0
Original line number Original line Diff line number Diff line
gen
labcomm2006_compiler.jar
labcomm2014_compiler.jar
labcomm2014_compiler.jar
+130 −0
Original line number Original line Diff line number Diff line
aspect Annotations {
    syn boolean TypeInstance.hasAnnotations() = getAnnotations().getNumAnnotation()>0;
    syn boolean TypeInstance.hasIntentions() = ! intentionSet().isEmpty();

    syn String Annotations.getName() = new String(lookup(""));

    syn byte[] Annotations.lookup(String key) {
        for(Annotation a: getAnnotations()) {
            byte[] res = a.lookup(key);
            if(res != null) return res;
        }
        return null;
    }

    syn byte[] Annotation.lookup(String key) = (getKey().equals(key) ? getValue() : null);

    syn boolean Annotation.isIntention() = false;
    eq Intention.isIntention() = true;

    inh TypeInstance Annotation.parentInstance();
    eq TypeInstance.getAnnotations().parentInstance() = this;

    coll Set<Intention> TypeInstance.intentionSet() [new HashSet<Intention>()] with add;
    Intention contributes this
        to TypeInstance.intentionSet()
        for parentInstance();

}

aspect SigAnnotations {

   inh Decl TypeInstance.parentDecl();

   coll Set Decl.allAnnotations() [new HashSet()] with add;
   TypeInstance contributes getAnnotationString()
           to Decl.allAnnotations()
           for parentDecl();

   // Helper attribute to get the "outermost" intentions for Decls

   syn byte[] TypeInstance.intentionBytes() = getIntentionBytes(sortedIntentions());
   syn byte[] Decl.getIntentionBytes() = getTypeInstance().intentionBytes();

    static Comparator TypeInstance.intentionComp =
        new Comparator<Intention>() {
            public int compare(Intention i1, Intention i2) {
                    return i1.getKey().compareTo(i2.getKey());
            }
    };

    syn int Decl.getNumIntentions() = getTypeInstance().sortedIntentions().getNumChild();

   syn List<Intention> TypeInstance.sortedIntentions() {
       List<Intention> res = new List<Intention>();

       //TODO: refactor out creation of sorted list of intentions

       java.util.ArrayList<Intention> sorted = new ArrayList(intentionSet());
       java.util.Collections.sort(sorted, intentionComp);
       for(Intention i : sorted) {
           res.add(i);
       }
       return res;
   }


   public DocString.DocString(byte[] bs) {
           super("DOCSTRING", bs);
   }

   public DocString.DocString(String s) {
           super("DOCSTRING", s.getBytes());
   }

   public String Intention.toString() {
       return "("+getKey() + ":"+new String(getValue())+")";
   }
   public String  DocString.toString() {
           return "\""+new String(getValue())+"\"";
   }

    /// TESTING
    syn String Decl.getAnnotationString()  {
            StringBuilder sb = new StringBuilder();
            Iterator<String> iti = allAnnotations().iterator();
            while(iti.hasNext()) {
                    //Annotation i = iti.next();
                    //sb.append("("+i.getKey()+" : "+i.getValue()+") ");
                    String i = iti.next();
                    sb.append(i);
            }
            return sb.toString();
    }


    syn int TypeInstance.fooHash() {
            List<Annotation> ints = getAnnotations().getAnnotationList();
            int result=0;
            for(Annotation i : ints) {
                    if(i.isIntention()) {
                        result += i.toString().hashCode();
                    }
            }
            return result;
    }

    syn String TypeInstance.getAnnotationString() {
            StringBuilder sb = new StringBuilder();
            List<Annotation> ints = getAnnotations().getAnnotationList();
            for(Annotation i : ints) {
                    sb.append(i.toString());
            }
            return sb.toString();
    }

    public void Decl.debugAnnotations() {
            getTypeInstance().debugAnnotations(getName());
    }

    public void TypeInstance.debugAnnotations(String context) {
            if(hasAnnotations()){
                System.out.println(context+".annotations: " + fooHash() + " : " + getAnnotationString());
            } else {
                //System.out.println(context + " : " + fooHash() + " : " + ": NO ANNOTATIONS ");
            }
    }
    //  TESTING END

}
+8 −8
Original line number Original line Diff line number Diff line
@@ -13,29 +13,29 @@ aspect ArrayRewrite {
    when (! getDim(0).isVariable()) 
    when (! getDim(0).isVariable()) 
    to FixedArrayType  { 
    to FixedArrayType  { 
      if (getNumDim() == 1) {
      if (getNumDim() == 1) {
        return new FixedArrayType(getType(), 
        return new FixedArrayType(getDataType(), 
				  getDim(0).getExpList());
				  getDim(0));
      } else {
      } else {
        List l = new List();
        List l = new List();
        for (int i = 1 ; i < getNumDim() ; i++) {
        for (int i = 1 ; i < getNumDim() ; i++) {
	  l.add(getDim(i));
	  l.add(getDim(i));
        }
        }
        return new FixedArrayType(new ParseArrayType(getType(), l), 
        return new FixedArrayType(new ParseArrayType(getDataType(), l), 
				  getDim(0).getExpList());
				  getDim(0));
      }
      }
    }
    }
    when (getDim(0).isVariable()) 
    when (getDim(0).isVariable()) 
    to VariableArrayType  { 
    to VariableArrayType  { 
      if (getNumDim() == 1) {
      if (getNumDim() == 1) {
        return new VariableArrayType(getType(), 
        return new VariableArrayType(getDataType(), 
				     getDim(0).getExpList());
				     getDim(0));
      } else {
      } else {
        List l = new List();
        List l = new List();
        for (int i = 1 ; i < getNumDim() ; i++) {
        for (int i = 1 ; i < getNumDim() ; i++) {
	  l.add(getDim(i));
	  l.add(getDim(i));
        }
        }
        return new VariableArrayType(new ParseArrayType(getType(), l), 
        return new VariableArrayType(new ParseArrayType(getDataType(), l), 
				     getDim(0).getExpList());
				     getDim(0));
      }
      }
    }
    }
  }
  }
+116 −249
Original line number Original line Diff line number Diff line
@@ -6,145 +6,42 @@ aspect CS_CodeGenEnv {
  // Environment wrapper for CS-code generation
  // Environment wrapper for CS-code generation
  // handles indentation, file writing,
  // handles indentation, file writing,


  public class CS_env {
  public class CS_env extends PrintEnv {


    public final int version;
    public final String verStr;
    private int indent;
    private int depth;
    private CS_printer printer;
    private CS_printer printer;
    private HashMap unique = new HashMap();

    final private static class CS_printer {
      
      private boolean newline = true;
      private File file;
      private PrintStream out;
      private IOException exception;
      


    final private static class CS_printer extends PrintEnv.FilePrinter {
     public CS_printer(File f) {
     public CS_printer(File f) {
  	file = f;
        super(f);
        File parentFile = f.getParentFile();
        if(parentFile != null) {
            parentFile.mkdirs();
        }
     }
     }


     public CS_printer(PrintStream out) {
     public CS_printer(PrintStream out) {
        this.out = out;
        super(out);
     }
     }


      public void close() throws IOException {
	if (out != null) {
  	  out.close();
        }
	if (exception != null) {
	  throw exception;
        }
      }

      public PrintStream getPrintStream() {
	return(out);
      }

      public void checkOpen() {
	if (out == null && exception == null) {
          try {
    	    out = new PrintStream(new FileOutputStream(file));
          } catch (IOException e) {
	    exception = e;
          }
        }
      }

      public void print(CS_env env, String s) {
	checkOpen();
        if (newline) {
          newline = false;
          for (int i = 0 ; i < env.indent ; i++) {
            out.print("  ");
          }
        }
        out.print(s);
      }

      public void println(CS_env env, String s) {
	checkOpen();
        print(env, s);
        out.println();
        newline = true;
      }
    }

    private CS_env(int indent, CS_printer printer, int version) {
      this.version = version;
      this.indent = indent;
      this.printer = printer;
      this.verStr = LabCommVersion.versionString(version);
    }
    }


    public CS_env(File f, int version) {
    public CS_env(File f, int version) {
      this(0, new CS_printer(f), version);
      super(0, new CS_printer(f), version);
    }
    }


    public CS_env(PrintStream out, int version) {
    public CS_env(PrintStream out, int version) {
      this(0, new CS_printer(out), version);
      super(0, new CS_printer(out), version);
    }

    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 int getDepth() {
      return depth;
    }


    public String print_for_begin(String limit) {
    public String print_for_begin(String limit) {
      int depth = getDepth();
      print("for (int i_" + depth + " = 0 ; ");
      print("for (int i_" + depth + " = 0 ; ");
      print("i_" + depth + " < " + limit + " ; ");
      print("i_" + depth + " < " + limit + " ; ");
      println("i_" + depth + "++) {");
      println("i_" + depth + "++) {");
      indent();
      indent();
      depth++;
      incDepth();
      return "i_" + (depth - 1);
      return "i_" + (depth);
    }
    }


    public void print_for_end() {
    public void print_for_end() {
      depth--;
      decDepth();
      unindent();
      unindent();
      println("}");
      println("}");
    }
    }
@@ -159,15 +56,6 @@ aspect CS_CodeGenEnv {
      println("}");
      println("}");
    }
    }


    public String getUnique(Object o) {
      String result = (String)unique.get(o);
      if (result == null) {
   	result = "_" + (unique.size() + 1) + "_";
      }
      unique.put(o, result);
      return result;
    }

  }
  }


}
}
@@ -175,12 +63,12 @@ aspect CS_CodeGenEnv {
aspect CS_StructName {
aspect CS_StructName {


  inh int Decl.CS_Depth();
  inh int Decl.CS_Depth();
  inh int Type.CS_Depth();
  inh int DataType.CS_Depth();
  eq Program.getDecl(int i).CS_Depth() = 0;
  eq Specification.getDecl(int i).CS_Depth() = 0;
  eq StructType.getField(int i).CS_Depth() = CS_Depth() + 1;
  eq StructType.getField(int i).CS_Depth() = CS_Depth() + 1;


  inh String Type.CS_structName();
  inh String DataType.CS_structName();
  eq Program.getDecl(int i).CS_structName() = getDecl(i).getName();
  eq Specification.getDecl(int i).CS_structName() = getDecl(i).getName();
  eq StructType.getField(int i).CS_structName() {
  eq StructType.getField(int i).CS_structName() {
    if (CS_Depth() == 0) {
    if (CS_Depth() == 0) {
      return "struct_" + getField(i).getName();
      return "struct_" + getField(i).getName();
@@ -192,16 +80,16 @@ aspect CS_StructName {


aspect CS_Void {
aspect CS_Void {


  syn boolean Decl.CS_isVoid() = getType().CS_isVoid();
  syn boolean Decl.CS_isVoid() = getDataType().CS_isVoid();
  syn boolean UserType.CS_isVoid() = decl().CS_isVoid();
  syn boolean UserType.CS_isVoid() = decl().CS_isVoid();
  syn boolean Type.CS_isVoid() = false;
  syn boolean DataType.CS_isVoid() = false;
  syn boolean VoidType.CS_isVoid() = true;
  syn boolean VoidType.CS_isVoid() = true;


}
}


aspect CS_CodeGen {
aspect CS_CodeGen {


  public void Program.CS_gen(String file, 
  public void Specification.CS_gen(String file,
			     String namespace, int version) throws IOException {
			     String namespace, int version) throws IOException {
    // Registration class
    // Registration class
    CS_env env = new CS_env(new File(file), version);
    CS_env env = new CS_env(new File(file), version);
@@ -210,7 +98,7 @@ aspect CS_CodeGen {
      env.indent();
      env.indent();
    }
    }
    env.println("using System;");
    env.println("using System;");
    env.println("using se.lth.control.labcomm;");
    env.println("using se.lth.control.labcomm2014;");
    for (int i = 0; i < getNumDecl(); i++) {
    for (int i = 0; i < getNumDecl(); i++) {
      Decl d = getDecl(i);
      Decl d = getDecl(i);
      try {
      try {
@@ -230,7 +118,7 @@ aspect CS_CodeGen {


aspect CS_Register {
aspect CS_Register {


  public void Program.CS_emitTypeRegister(CS_env env) {
  public void Specification.CS_emitTypeRegister(CS_env env) {
  }
  }


  public void Decl.CS_emitTypeRegister(CS_env env) {
  public void Decl.CS_emitTypeRegister(CS_env env) {
@@ -273,7 +161,7 @@ aspect CS_Class {
	    Decl t = it.next();
	    Decl t = it.next();


	    t.CS_emitUserTypeDeps(env, t.getName(), outputCode);
	    t.CS_emitUserTypeDeps(env, t.getName(), outputCode);
	    if( outputCode && t.getType().isUserType() ) {
	    if( outputCode && t.getDataType().isUserType() ) {
	       env.println(t.getName()+".register(e);");
	       env.println(t.getName()+".register(e);");
	    } else {  // Just output a comment
	    } else {  // Just output a comment
		String refpath = (via == null) ? "directly" : "indirectly via "+via;
		String refpath = (via == null) ? "directly" : "indirectly via "+via;
@@ -329,7 +217,7 @@ aspect CS_Class {
  }
  }


  public void TypeDecl.CS_emitClass(CS_env env) {
  public void TypeDecl.CS_emitClass(CS_env env) {
    if (getType().CS_needInstance()) {
    if (getDataType().CS_needInstance()) {
      // Hackish prettyprint preamble
      // Hackish prettyprint preamble
      env.println("/* ");
      env.println("/* ");
      pp(env.getPrintStream());
      pp(env.getPrintStream());
@@ -338,7 +226,7 @@ aspect CS_Class {
      env.println("public class " + getName() + " : SampleType {");
      env.println("public class " + getName() + " : SampleType {");
      env.println();
      env.println();
      env.indent();
      env.indent();
      getType().CS_emitInstance(env);
      getDataType().CS_emitInstance(env);
      if( isReferenced()) {
      if( isReferenced()) {
        CS_emitRegisterEncoder(env);
        CS_emitRegisterEncoder(env);
	CS_emitDispatcher(env,false);
	CS_emitDispatcher(env,false);
@@ -359,11 +247,11 @@ aspect CS_Class {
    env.println("public class " + getName() + " : Sample {");
    env.println("public class " + getName() + " : Sample {");
    env.println();
    env.println();
    env.indent();
    env.indent();
    getType().CS_emitInstance(env);
    getDataType().CS_emitInstance(env);
    env.println("public interface Handler : SampleHandler {");
    env.println("public interface Handler : SampleHandler {");
    env.print("  void handle(");
    env.print("  void handle(");
    if (!isVoid()) {
    if (!isVoid()) {
      getType().CS_emitType(env);
      getDataType().CS_emitType(env);
      env.print(" value");
      env.print(" value");
    }
    }
    env.println(");");
    env.println(");");
@@ -377,6 +265,7 @@ aspect CS_Class {
    CS_emitSignature(env);
    CS_emitSignature(env);


    env.println("}");
    env.println("}");
    env.unindent();
  }
  }


  public void Decl.CS_emitSignature(CS_env env) {
  public void Decl.CS_emitSignature(CS_env env) {
@@ -425,12 +314,6 @@ aspect CS_Class {
    env.println("private class Dispatcher : SampleDispatcher {");
    env.println("private class Dispatcher : SampleDispatcher {");
    env.indent();
    env.indent();
    env.println();
    env.println();
    env.println("public Type getSampleClass() {");
    env.indent();
    env.println("return typeof(" + getName() + ");");
    env.unindent();
    env.println("}");
    env.println();
    env.println("public String getName() {");
    env.println("public String getName() {");
    env.indent();
    env.indent();
    env.println("return \"" + getName() + "\";");
    env.println("return \"" + getName() + "\";");
@@ -459,21 +342,6 @@ aspect CS_Class {
    env.unindent();
    env.unindent();
    env.println("}");
    env.println("}");
    env.println();
    env.println();
//    env.println("public void encodeSignature(Encoder e) throws IOException{");
//    env.indent();
//    env.println("emitSignature(e);");
//    env.unindent();
//    env.println("}");
//    env.println();
//  env.println("public void encodeSignatureMetadata(Encoder e, int index){");
//  env.indent();
//  env.println("e.encodePacked32(Constant.TYPE_DEF);");
//  env.println("e.encodePacked32(index);");
//  env.println("e.encodeString(getName());");
//  env.println("emitSignature(e);");
//  env.unindent();
//  env.println("}");
//  env.println();
    env.println("public bool canDecodeAndHandle() {");
    env.println("public bool canDecodeAndHandle() {");
    env.indent();
    env.indent();
    env.println("return "+isSample+";");
    env.println("return "+isSample+";");
@@ -499,19 +367,18 @@ aspect CS_Class {
    env.unindent();
    env.unindent();
    env.println("}");
    env.println("}");
    env.println("");
    env.println("");

 } //TODO, fix above method
 } //TODO, fix above method


  public void TypeDecl.CS_emitEncoder(CS_env env) {
  public void TypeDecl.CS_emitEncoder(CS_env env) {
    env.print("public static void encode(Encoder e");
    env.print("public static void encode(Encoder e");
    if (!isVoid()) {
    if (!isVoid()) {
      env.print(", ");
      env.print(", ");
      getType().CS_emitType(env);
      getDataType().CS_emitType(env);
      env.print(" value");
      env.print(" value");
    }
    }
    env.println(") {");
    env.println(") {");
    env.indent();
    env.indent();
    getType().CS_emitEncoder(env, "value");
    getDataType().CS_emitEncoder(env, "value");
    env.unindent();
    env.unindent();
    env.println("}");
    env.println("}");
    env.println();
    env.println();
@@ -521,20 +388,20 @@ aspect CS_Class {
    env.print("public static void encode(Encoder e");
    env.print("public static void encode(Encoder e");
    if (!isVoid()) {
    if (!isVoid()) {
      env.print(", ");
      env.print(", ");
      getType().CS_emitType(env);
      getDataType().CS_emitType(env);
      env.print(" value");
      env.print(" value");
    }
    }
    env.println(") {");
    env.println(") {");
    env.indent();
    env.indent();
    env.println("e.begin(typeof(" + getName() + "));");
    env.println("e.begin(dispatcher);");
    getType().CS_emitEncoder(env, "value");
    getDataType().CS_emitEncoder(env, "value");
    env.println("e.end(typeof(" + getName() + "));");
    env.println("e.end(dispatcher);");
    env.unindent();
    env.unindent();
    env.println("}");
    env.println("}");
    env.println();
    env.println();
  }
  }


  public void Type.CS_emitEncoder(CS_env env, String name) {
  public void DataType.CS_emitEncoder(CS_env env, String name) {
    throw new Error(this.getClass().getName() +
    throw new Error(this.getClass().getName() +
		    ".CS_emitEncoder(CS_env env, String name)" +
		    ".CS_emitEncoder(CS_env env, String name)" +
		    " not declared");
		    " not declared");
@@ -575,7 +442,7 @@ aspect CS_Class {
        index = index + ", " + env.print_for_begin(limit);
        index = index + ", " + env.print_for_begin(limit);
      }
      }
    }
    }
    getType().CS_emitEncoder(env, name + "[" + index + "]");
    getDataType().CS_emitEncoder(env, name + "[" + index + "]");
    for (int i = 0 ; i < getNumExp() ; i++) {
    for (int i = 0 ; i < getNumExp() ; i++) {
      env.print_for_end();
      env.print_for_end();
    }
    }
@@ -600,7 +467,7 @@ aspect CS_Class {
  public void StructType.CS_emitEncoder(CS_env env, String name) {
  public void StructType.CS_emitEncoder(CS_env env, String name) {
    for (int i = 0 ; i < getNumField() ; i++) {
    for (int i = 0 ; i < getNumField() ; i++) {
      Field f = getField(i);
      Field f = getField(i);
      f.getType().CS_emitEncoder(env, name + "." + f.getName());
      f.getDataType().CS_emitEncoder(env, name + "." + f.getName());
    }
    }
  }
  }


@@ -608,19 +475,19 @@ aspect CS_Class {
    if (CS_needInstance()) {
    if (CS_needInstance()) {
      env.println(getName() + ".encode(e, " + name + ");");
      env.println(getName() + ".encode(e, " + name + ");");
    } else {
    } else {
      decl().getType().CS_emitEncoder(env, name);
      decl().getDataType().CS_emitEncoder(env, name);
    }
    }
  }
  }


  public void Decl.CS_emitDecoder(CS_env env) {
  public void Decl.CS_emitDecoder(CS_env env) {
    env.print("public static ");
    env.print("public static ");
    getType().CS_emitType(env);
    getDataType().CS_emitType(env);
    env.println(" decode(Decoder d) {");
    env.println(" decode(Decoder d) {");
    env.indent();
    env.indent();
    if (!isVoid()) {
    if (!isVoid()) {
      getType().CS_emitType(env);
      getDataType().CS_emitType(env);
      env.println(" result;");
      env.println(" result;");
      getType().CS_emitDecoder(env, "result");
      getDataType().CS_emitDecoder(env, "result");
      env.println("return result;");
      env.println("return result;");
    }
    }
    env.unindent();
    env.unindent();
@@ -628,7 +495,7 @@ aspect CS_Class {
    env.println();
    env.println();
  }
  }


  public void Type.CS_emitDecoder(CS_env env, String name) {
  public void DataType.CS_emitDecoder(CS_env env, String name) {
    throw new Error(this.getClass().getName() +
    throw new Error(this.getClass().getName() +
		    ".CS_emitDecoder(CS_env env, String name)" +
		    ".CS_emitDecoder(CS_env env, String name)" +
		    " not declared");
		    " not declared");
@@ -666,7 +533,7 @@ aspect CS_Class {
      env.println(";");
      env.println(";");
    }
    }
    env.print(name + " = new ");
    env.print(name + " = new ");
    getType().CS_emitTypePrefix(env);
    getDataType().CS_emitTypePrefix(env);
    env.print("[");
    env.print("[");
    for (int i = 0 ; i < getNumExp() ; i++) {
    for (int i = 0 ; i < getNumExp() ; i++) {
      if (i > 0) {
      if (i > 0) {
@@ -675,7 +542,7 @@ aspect CS_Class {
      env.print("i_" + (baseDepth + i) + "_max");
      env.print("i_" + (baseDepth + i) + "_max");
    }
    }
    env.print("]");
    env.print("]");
    getType().CS_emitTypeSuffix(env);
    getDataType().CS_emitTypeSuffix(env);
    env.println(";");
    env.println(";");


    String index = null;
    String index = null;
@@ -687,7 +554,7 @@ aspect CS_Class {
        index = index + ", " + env.print_for_begin(limit);
        index = index + ", " + env.print_for_begin(limit);
      }
      }
    }
    }
    getType().CS_emitDecoder(env, name + "[" + index + "]");
    getDataType().CS_emitDecoder(env, name + "[" + index + "]");
    for (int i = 0 ; i < getNumExp() ; i++) {
    for (int i = 0 ; i < getNumExp() ; i++) {
      env.print_for_end();
      env.print_for_end();
    }
    }
@@ -715,7 +582,7 @@ aspect CS_Class {
    env.println("();");
    env.println("();");
    for (int i = 0 ; i < getNumField() ; i++) {
    for (int i = 0 ; i < getNumField() ; i++) {
      Field f = getField(i);
      Field f = getField(i);
      f.getType().CS_emitDecoder(env, name + "." + f.getName());
      f.getDataType().CS_emitDecoder(env, name + "." + f.getName());
    }
    }
  }
  }


@@ -723,11 +590,11 @@ aspect CS_Class {
    if (CS_needInstance()) {
    if (CS_needInstance()) {
      env.println(name + " = " + getName() + ".decode(d);");
      env.println(name + " = " + getName() + ".decode(d);");
    } else {
    } else {
      decl().getType().CS_emitDecoder(env, name);
      decl().getDataType().CS_emitDecoder(env, name);
    }
    }
  }
  }


  public void Type.CS_emitTypePrefix(CS_env env) {
  public void DataType.CS_emitTypePrefix(CS_env env) {
    throw new Error(this.getClass().getName() +
    throw new Error(this.getClass().getName() +
		    ".CS_emitTypePrefix(CS_env env)" +
		    ".CS_emitTypePrefix(CS_env env)" +
		    " not declared");
		    " not declared");
@@ -736,7 +603,7 @@ aspect CS_Class {
  public void PrimType.CS_emitTypePrefix(CS_env env) {
  public void PrimType.CS_emitTypePrefix(CS_env env) {
    switch (getToken()) {
    switch (getToken()) {
      case LABCOMM_STRING: { env.print("String"); } break;
      case LABCOMM_STRING: { env.print("String"); } break;
      case LABCOMM_SAMPLE: { env.print("Type"); } break;
      case LABCOMM_SAMPLE: { env.print("SampleDispatcher"); } break;
      default: { env.print(getName()); } break;
      default: { env.print(getName()); } break;
    }
    }
  }
  }
@@ -745,24 +612,24 @@ aspect CS_Class {
    if (CS_needInstance()) {
    if (CS_needInstance()) {
      env.print(getName());
      env.print(getName());
    } else {
    } else {
      decl().getType().CS_emitTypePrefix(env);
      decl().getDataType().CS_emitTypePrefix(env);
    }
    }
  }
  }


  public void ArrayType.CS_emitTypePrefix(CS_env env){
  public void ArrayType.CS_emitTypePrefix(CS_env env){
    getType().CS_emitTypePrefix(env);
    getDataType().CS_emitTypePrefix(env);
  }
  }


  public void StructType.CS_emitTypePrefix(CS_env env){
  public void StructType.CS_emitTypePrefix(CS_env env){
    env.print(CS_structName());
    env.print(CS_structName());
  }
  }


  public void Type.CS_emitTypeSuffix(CS_env env) {
  public void DataType.CS_emitTypeSuffix(CS_env env) {
  }
  }


  public void UserType.CS_emitTypeSuffix(CS_env env) {
  public void UserType.CS_emitTypeSuffix(CS_env env) {
    if (! CS_needInstance()) {
    if (! CS_needInstance()) {
      decl().getType().CS_emitTypeSuffix(env);
      decl().getDataType().CS_emitTypeSuffix(env);
    }
    }
  }
  }


@@ -772,10 +639,10 @@ aspect CS_Class {
      env.print(",");
      env.print(",");
    }
    }
    env.print("]");
    env.print("]");
    getType().CS_emitTypeSuffix(env);
    getDataType().CS_emitTypeSuffix(env);
  }
  }


  public boolean Type.CS_needInstance() {
  public boolean DataType.CS_needInstance() {
    throw new Error(this.getClass().getName() +
    throw new Error(this.getClass().getName() +
		    ".CS_needInstance()" +
		    ".CS_needInstance()" +
		    " not declared");
		    " not declared");
@@ -790,7 +657,7 @@ aspect CS_Class {
  }
  }


  public boolean UserType.CS_needInstance() {
  public boolean UserType.CS_needInstance() {
    return decl().getType().CS_needInstance();
    return decl().getDataType().CS_needInstance();
  }
  }


  public boolean StructType.CS_needInstance() {
  public boolean StructType.CS_needInstance() {
@@ -798,10 +665,10 @@ aspect CS_Class {
  }
  }


  public boolean ArrayType.CS_needInstance() {
  public boolean ArrayType.CS_needInstance() {
    return getType().CS_needInstance();
    return getDataType().CS_needInstance();
  }
  }


  public boolean Type.CS_isPrimitive() {
  public boolean DataType.CS_isPrimitive() {
    return false;
    return false;
  }
  }


@@ -809,7 +676,7 @@ aspect CS_Class {
    return true;
    return true;
  }
  }


  public void Type.CS_emitInstance(CS_env env) {
  public void DataType.CS_emitInstance(CS_env env) {
    throw new Error(this.getClass().getName() +
    throw new Error(this.getClass().getName() +
		    ".CS_emitInstance(CS_env env)" +
		    ".CS_emitInstance(CS_env env)" +
		    " not declared");
		    " not declared");
@@ -822,7 +689,7 @@ aspect CS_Class {
  }
  }


  public void ArrayType.CS_emitInstance(CS_env env) {
  public void ArrayType.CS_emitInstance(CS_env env) {
    getType().CS_emitInstance(env);
    getDataType().CS_emitInstance(env);
  }
  }


  public void StructType.CS_emitInstance(CS_env env) {
  public void StructType.CS_emitInstance(CS_env env) {
@@ -831,7 +698,7 @@ aspect CS_Class {
      env.indent();
      env.indent();
    }
    }
    for (int i = 0 ; i < getNumField() ; i++) {
    for (int i = 0 ; i < getNumField() ; i++) {
      getField(i).getType().CS_emitInstance(env);
      getField(i).getDataType().CS_emitInstance(env);
    }
    }
    for (int i = 0 ; i < getNumField() ; i++) {
    for (int i = 0 ; i < getNumField() ; i++) {
      getField(i).CS_emitField(env);
      getField(i).CS_emitField(env);
@@ -848,11 +715,11 @@ aspect CS_Class {


  public void Field.CS_emitField(CS_env env) {
  public void Field.CS_emitField(CS_env env) {
    env.print("public ");
    env.print("public ");
    getType().CS_emitType(env);
    getDataType().CS_emitType(env);
    env.println(" " + getName() + ";");
    env.println(" " + getName() + ";");
  }
  }


  public void Type.CS_emitType(CS_env env) {
  public void DataType.CS_emitType(CS_env env) {
    throw new Error(this.getClass().getName() +
    throw new Error(this.getClass().getName() +
		    ".CS_emitType(CS_env env)" +
		    ".CS_emitType(CS_env env)" +
		    " not declared");
		    " not declared");
@@ -866,23 +733,23 @@ aspect CS_Class {
    switch (getToken()) {
    switch (getToken()) {
      case LABCOMM_STRING: { env.print("String"); } break;
      case LABCOMM_STRING: { env.print("String"); } break;
      case LABCOMM_BOOLEAN: { env.print("bool"); } break;
      case LABCOMM_BOOLEAN: { env.print("bool"); } break;
      case LABCOMM_SAMPLE: { env.print("Type"); } break;
      case LABCOMM_SAMPLE: { env.print("SampleDispatcher"); } break;
      default: { env.print(getName()); } break;
      default: { env.print(getName()); } break;
    }
    }
  }
  }


  public void UserType.CS_emitType(CS_env env) {
  public void UserType.CS_emitType(CS_env env) {
    decl().getType().CS_emitType(env);
    decl().getDataType().CS_emitType(env);
  }
  }


  public void ArrayType.CS_emitType(CS_env env){
  public void ArrayType.CS_emitType(CS_env env){
    getType().CS_emitTypePrefix(env);
    getDataType().CS_emitTypePrefix(env);
    env.print("[");
    env.print("[");
    for (int i = 1 ; i < getNumExp() ; i++) {
    for (int i = 1 ; i < getNumExp() ; i++) {
      env.print(",");
      env.print(",");
    }
    }
    env.print("]");
    env.print("]");
    getType().CS_emitTypeSuffix(env);
    getDataType().CS_emitTypeSuffix(env);
  }
  }


  public void StructType.CS_emitType(CS_env env){
  public void StructType.CS_emitType(CS_env env){
@@ -902,7 +769,7 @@ aspect CS_Signature {


    public void TypeRefSignatureLine.CS_emitSignature(CS_env env, boolean isDecl){
    public void TypeRefSignatureLine.CS_emitSignature(CS_env env, boolean isDecl){
      env.print(getIndentString());
      env.print(getIndentString());
      env.println("e.encodePacked32(e.getTypeId( typeof("+decl.getName()+")));");
      env.println("e.encodePacked32(e.getDataTypeId( typeof("+decl.getName()+")));");
    }
    }


    public void DataSignatureLine.CS_emitSignature(CS_env env, boolean decl){
    public void DataSignatureLine.CS_emitSignature(CS_env env, boolean decl){
@@ -935,7 +802,7 @@ aspect CS_Signature {


aspect CS_Info {
aspect CS_Info {


  public void Program.CS_info(PrintStream out, String namespace, int version) {
  public void Specification.CS_info(PrintStream out, String namespace, int version) {
    CS_env env = new CS_env(out, version);
    CS_env env = new CS_env(out, version);
    if (namespace == null) {
    if (namespace == null) {
      namespace = "";
      namespace = "";
@@ -955,14 +822,14 @@ aspect CS_Info {


  public void TypeDecl.CS_info(CS_env env, String namespace) {
  public void TypeDecl.CS_info(CS_env env, String namespace) {
    env.print(";C#;typedef;" + namespace + getName() + ";");
    env.print(";C#;typedef;" + namespace + getName() + ";");
    getType().CS_emitType(env) ;
    getDataType().CS_emitType(env) ;
    env.print(";not_applicable_for_C#");
    env.print(";not_applicable_for_C#");
    env.println();
    env.println();
  }
  }


  public void SampleDecl.CS_info(CS_env env, String namespace) {
  public void SampleDecl.CS_info(CS_env env, String namespace) {
    env.print(";C#;sample;" + namespace + getName() + ";");
    env.print(";C#;sample;" + namespace + getName() + ";");
    getType().CS_emitType(env);
    getDataType().CS_emitType(env);
    env.print(";not_applicable_for_C#");
    env.print(";not_applicable_for_C#");
    env.println();
    env.println();
  }
  }
+391 −384

File changed and moved.

Preview size limit exceeded, changes collapsed.

+14 −0
Original line number Original line Diff line number Diff line
aspect DeclNames {
	inh String DataType.declName();
	eq Decl.getTypeInstance().declName() = getName();

	inh String Field.declName();
	eq StructType.getField(int i).declName() = declName();

    //TODO: aspect should be renamed to parent-something

    inh Decl DataType.parentDecl();
    inh Decl Field.parentDecl();
    eq Decl.getTypeInstance().parentDecl() = this;
    eq StructType.getField(int i).parentDecl() = parentDecl();
}
+30 −0
Original line number Original line Diff line number Diff line
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);
        }
    }
}
+34 −18
Original line number Original line Diff line number Diff line
import java.util.*;
import java.util.*;


aspect NoIntentionForTypeOrSampledefs {
    inh boolean TypeInstance.addIntentions();
    eq Decl.getTypeInstance().addIntentions() = false;
    eq StructType.getField(int i).addIntentions() = true;
}

aspect FlatSignature {
aspect FlatSignature {


  public SignatureList Decl.flatSignature(int version) {
  public SignatureList Decl.flatSignature(int version) {
@@ -14,15 +20,23 @@ aspect FlatSignature {
  }
  }


  public void TypeDecl.flatSignature(SignatureList list) {
  public void TypeDecl.flatSignature(SignatureList list) {
    getType().flatSignature(list);
    getTypeInstance().flatSignature(list);
  }
  }


  public void SampleDecl.flatSignature(SignatureList list) {
  public void SampleDecl.flatSignature(SignatureList list) {
    getType().flatSignature(list);
    getTypeInstance().flatSignature(list);
  }
  }


  public void SampleRefType.flatSignature(SignatureList list) {
//  public void SampleRefType.flatSignature(SignatureList list) {
    list.addInt(LABCOMM_SAMPLE_REF, "sample");
//    list.addInt(LABCOMM_SAMPLE_REF, "sample");
//  }

  public void TypeInstance.flatSignature(SignatureList list) {
    if(addIntentions()) {
      debugAnnotations(this.getName()+".TypeInstance.flatSignature");
      list.addIntentions(intentions(), "intentions: "+getIntentionString());
    }
    getDataType().flatSignature(list);
  }
  }


  public void VoidType.flatSignature(SignatureList list) {
  public void VoidType.flatSignature(SignatureList list) {
@@ -45,7 +59,7 @@ aspect FlatSignature {
    for (int i = 0 ; i < getNumExp() ; i++) {
    for (int i = 0 ; i < getNumExp() ; i++) {
      getExp(i).flatSignature(list);
      getExp(i).flatSignature(list);
    }
    }
    getType().flatSignature(list);
    getDataType().flatSignature(list);
    list.unindent();
    list.unindent();
    list.add(null, "}");
    list.add(null, "}");
  }
  }
@@ -62,8 +76,10 @@ aspect FlatSignature {
  }
  }


  public void Field.flatSignature(SignatureList list) {
  public void Field.flatSignature(SignatureList list) {
    list.addString(getName(), signatureComment());
    debugAnnotations(this.getName()+".Field.flatSignature");
    getType().flatSignature(list);
    list.addIntentions(intentions(), "Field: "+getIntentionString());
//    list.addString(getName(), signatureComment());
    getDataType().flatSignature(list);
  }
  }


  public void IntegerLiteral.flatSignature(SignatureList list) {
  public void IntegerLiteral.flatSignature(SignatureList list) {
@@ -93,12 +109,12 @@ aspect FlatSignature {
  }
  }


  public String Field.signatureComment() {
  public String Field.signatureComment() {
    return getType().signatureComment() + " '" + getName() +"'";
    return getDataType().signatureComment() + " '" + getName() +"'";
  }
  }


  public String SampleRefType.signatureComment() {
//  public String SampleRefType.signatureComment() {
    return "sample";
//    return "sample";
  }
//  }


  public String PrimType.signatureComment() {
  public String PrimType.signatureComment() {
    return getName();
    return getName();
+36 −0
Original line number Original line Diff line number Diff line
aspect TypeDefGen {

    public void Specification.generateTypedefs(PrintStream out, int ver) {
        for(Decl d : getDecls()) {
            d.generateTypedefs(out);
        }
    }

    public void Decl.generateTypedefs(PrintStream out) {
    }


    public void Decl.generateDepTypedefs(PrintStream out){
        Iterator<Decl> it = type_dependencies().iterator();
        while(it.hasNext()) {
            Decl d = it.next();
            d.generateDepTypedefs(out);
        }
        pp(out);
    }

    public void SampleDecl.generateTypedefs(PrintStream out){

        if(hasDependencies()) {
            out.println("sample "+getName()+"_def {");
            out.println("    sample sample;");
            out.println("    string typedef = <<EOL");
            for(Decl d : type_dependencies()) {
                d.generateDepTypedefs(out);
            }
            pp(out);
            out.println("EOL;");
        }
    }

}
+349 −209

File changed and moved.

Preview size limit exceeded, changes collapsed.

+46 −0
Original line number Original line Diff line number Diff line
Specification ::= Decl*;

abstract Decl ::= TypeInstance /Signature/;

TypeInstance ::= DataType Annotations;

Annotations ::= Annotation*;
Annotation ::= <Key:String> <Value:byte[]>;

Intention : Annotation;
DocString : Annotation;

TypeDecl   : Decl;
SampleDecl : Decl;

//Signatures are in the abstract grammar, so that
//they can be extended and refined by aspects.

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>;
IntentionSignatureLine     : DataSignatureLine ::= Intention* ;
TypeRefSignatureLine       : SignatureLine     ::= Decl;

Field : TypeInstance;

abstract DataType;
VoidType           : DataType;
//SampleRefType      : DataType;
PrimType           : DataType ::= <Name:String> <Token:int>;
UserType           : DataType ::= <Name:String>;
StructType         : DataType ::= Field*;
ParseArrayType     : DataType ::= DataType Dim*;
abstract ArrayType : DataType ::= DataType Dim;
VariableArrayType  : ArrayType;
FixedArrayType     : ArrayType;

Dim ::= Exp*;

abstract Exp;
IntegerLiteral : Exp ::= <Value:String>;
VariableSize   : Exp;
Loading