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

generalized intention to annotation

parent 745c09a5
No related branches found
No related tags found
No related merge requests found
......@@ -4,8 +4,6 @@ abstract Decl ::= TypeInstance /Signature/;
TypeInstance ::= DataType <Name:String> Intention*;
Intention ::= <Key:String> <Value:String>;
TypeDecl : Decl;
SampleDecl : Decl;
......@@ -21,6 +19,13 @@ IntSignatureLine : DataSignatureLine ::= <Data:int>;
StringSignatureLine : DataSignatureLine ::= <Data:String>;
TypeRefSignatureLine : SignatureLine ::= Decl;
Annotation ::= <Key:String> <Value:String>;
Intention : Annotation;
DocString : Annotation;
TypeInstance ::= DataType <Name:String> Annotation*;
Field : TypeInstance;
abstract DataType;
......
......@@ -67,7 +67,7 @@ List intention_list =
String key = IDENTIFIER;
String stringliteral = IDENTIFIER;
Intention intention = LPAREN key.k COLON stringliteral.v RPAREN {: return new Intention(k,v); :};
Annotation intention = LPAREN key.k COLON stringliteral.v RPAREN {: return new Annotation(k,v); :};
TypeInstance type_instance =
intentions.i type.t IDENTIFIER {: return new TypeInstance(t, IDENTIFIER, i); :}
......
......@@ -4,11 +4,11 @@ aspect Refactoring {
syn DataType Decl.getDataType() = getTypeInstance().getDataType();
public Field.Field(TypeInstance t) {
this(t.getDataType(), t.getName(), t.getIntentionList());
this(t.getDataType(), t.getName(), t.getAnnotationList());
}
public TypeInstance.TypeInstance(DataType t, String n) {
this(t, n, new List<Intention>());
this(t, n, new List<Annotation>());
System.out.println("WARNING! TypeInstance(DataType, String) ignoring intention list");
}
}
import java.util.*;
aspect Intentions {
aspect Annotations {
inh Decl TypeInstance.parentDecl();
coll Set Decl.allIntentions() [new HashSet()] with add;
TypeInstance contributes getIntentionString()
to Decl.allIntentions()
coll Set Decl.allAnnotations() [new HashSet()] with add;
TypeInstance contributes getAnnotationString()
to Decl.allAnnotations()
for parentDecl();
}
......@@ -25,11 +25,11 @@ aspect Signature {
inh Decl SignatureList.parentDecl();
/// TESTING
syn String Decl.getIntentionString() {
syn String Decl.getAnnotationString() {
StringBuilder sb = new StringBuilder();
Iterator<String> iti = allIntentions().iterator();
Iterator<String> iti = allAnnotations().iterator();
while(iti.hasNext()) {
//Intention i = iti.next();
//Annotation i = iti.next();
//sb.append("("+i.getKey()+" : "+i.getValue()+") ");
String i = iti.next();
sb.append(i);
......@@ -37,22 +37,22 @@ aspect Signature {
return sb.toString();
}
syn String TypeInstance.getIntentionString() {
syn String TypeInstance.getAnnotationString() {
StringBuilder sb = new StringBuilder();
List<Intention> ints = getIntentionList();
for(Intention i : ints) {
List<Annotation> ints = getAnnotationList();
for(Annotation i : ints) {
sb.append("("+i.getKey()+" : "+i.getValue()+") ");
}
return sb.toString();
}
public void Decl.debugIntentions() {
System.out.println("Decl.intentions: " + getIntentionString());
public void Decl.debugAnnotations() {
System.out.println("Decl.annotations: " + getAnnotationString());
}
// TESTING END
syn nta Signature Decl.getSignature() {
debugIntentions();
debugAnnotations();
SignatureList sl = new SignatureList();
genSigLineForDecl(sl, true);
SignatureList fsl = new SignatureList();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment