diff --git a/compiler/2014/Annotations.jrag b/compiler/2014/Annotations.jrag index 86166045c13cf5aa6e99899e9e665c609ce1d15c..987dad95b26fabf82eff1a42af8cd89f86d2ed47 100644 --- a/compiler/2014/Annotations.jrag +++ b/compiler/2014/Annotations.jrag @@ -1,13 +1,17 @@ aspect Annotations { - syn boolean TypeInstance.hasAnnotations() = getNumAnnotation()>0; + syn boolean TypeInstance.hasAnnotations() = getAnnotations().getNumAnnotation()>0; syn boolean TypeInstance.hasIntentions() = ! intentionSet().isEmpty(); +// syn String Annotations.getName() = new String(lookup("")); +// +// syn byte[] Annotation.lookup(String key) = (getKey().equals(key) ? getValue() : null); + syn boolean Annotation.isIntention() = false; eq Intention.isIntention() = true; inh ASTNode Annotation.parentInstance(); - eq TypeInstance.getAnnotation(int i).parentInstance() = this; - eq Decl.getAnnotation(int i).parentInstance() = this; + eq TypeInstance.getAnnotations().parentInstance() = this; + eq Decl.getAnnotations().parentInstance() = this; coll Set<Intention> TypeInstance.intentionSet() [new HashSet<Intention>()] with add; @@ -59,7 +63,7 @@ aspect SigAnnotations { syn int TypeInstance.fooHash() { - List<Annotation> ints = getAnnotationList(); + List<Annotation> ints = getAnnotations().getAnnotationList(); int result=0; for(Annotation i : ints) { if(i.isIntention()) { @@ -71,7 +75,7 @@ aspect SigAnnotations { syn String TypeInstance.getAnnotationString() { StringBuilder sb = new StringBuilder(); - List<Annotation> ints = getAnnotationList(); + List<Annotation> ints = getAnnotations().getAnnotationList(); for(Annotation i : ints) { sb.append(i.toString()); } diff --git a/compiler/2014/LabComm.ast b/compiler/2014/LabComm.ast index 311cac4308636e11b0fbd97d58d8a7c3dece283b..ad97733084fbd5781b7b654ad827d1d57e06f67a 100644 --- a/compiler/2014/LabComm.ast +++ b/compiler/2014/LabComm.ast @@ -1,9 +1,10 @@ Specification ::= Decl*; -abstract Decl ::= TypeInstance Annotation* /Signature/; +abstract Decl ::= TypeInstance Annotations /Signature/; -TypeInstance ::= DataType <Name:String> Annotation*; +TypeInstance ::= DataType <Name:String> Annotations; +Annotations ::= Annotation*; Annotation ::= <Key:String> <Value:byte[]>; Intention : Annotation; diff --git a/compiler/2014/LabCommParser.parser b/compiler/2014/LabCommParser.parser index 6624635d2d813d63a14b93f47ad575073434572b..8daff77e8c58cd896c49462b948351a5caf0482f 100644 --- a/compiler/2014/LabCommParser.parser +++ b/compiler/2014/LabCommParser.parser @@ -54,9 +54,9 @@ List var_decl_list = | var_decl_list.l var_decl.v {: return l.add(v); :} ; -List annotations = - /* empty list */ {: return new List(); :} - | annotation_list.l {: return l; :} +Annotations annotations = + /* empty list */ {: return new Annotations(); :} + | annotation_list.l {: return new Annotations(l); :} ; List annotation_list = diff --git a/compiler/2014/Refactoring.jrag b/compiler/2014/Refactoring.jrag index 84f3484cae000ba22bd387a8f4e1a907ea5a1611..43bddd296b1d0dd1df6bb5b8988cdc5263dd5817 100644 --- a/compiler/2014/Refactoring.jrag +++ b/compiler/2014/Refactoring.jrag @@ -4,19 +4,22 @@ aspect Refactoring { syn DataType Decl.getDataType() = getTypeInstance().getDataType(); public Field.Field(TypeInstance t) { - this(t.getDataType(), t.getName(), t.getAnnotationList()); + this(t.getDataType(), t.getName(), t.getAnnotations()); } public TypeInstance.TypeInstance(DataType t, String n) { - this(t, n, new List<Annotation>()); + this(t, n, new Annotations()); System.out.println("WARNING! TypeInstance(DataType, String) ignoring intention list"); } public TypeDecl.TypeDecl(TypeInstance t) { - this(t, new List<Annotation>()); + this(t, new Annotations()); System.out.println("WARNING! TypeDecl(TypeInstance) ignoring intention list"); } public SampleDecl.SampleDecl(TypeInstance t) { - this(t, new List<Annotation>()); + this(t, new Annotations()); System.out.println("WARNING! SampleDecl(TypeInstance) ignoring intention list"); } + + syn Annotation Decl.getAnnotation(int i) = getAnnotations().getAnnotation(i); + syn Annotation TypeInstance.getAnnotation(int i) = getAnnotations().getAnnotation(i); }