From 0660eda279acdad9ba39ac55d1179ebc09a19db7 Mon Sep 17 00:00:00 2001 From: Sven Gestegard Robertz <sven.robertz@cs.lth.se> Date: Thu, 30 Apr 2015 11:33:50 +0200 Subject: [PATCH] generalized intention to annotation --- compiler/2014/LabComm.ast | 9 +++++++-- compiler/2014/LabCommParser.parser | 2 +- compiler/2014/Refactoring.jrag | 4 ++-- compiler/2014/Signature.jrag | 26 +++++++++++++------------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/compiler/2014/LabComm.ast b/compiler/2014/LabComm.ast index a8f335b..f1fd5c0 100644 --- a/compiler/2014/LabComm.ast +++ b/compiler/2014/LabComm.ast @@ -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; diff --git a/compiler/2014/LabCommParser.parser b/compiler/2014/LabCommParser.parser index 812e725..3575ee2 100644 --- a/compiler/2014/LabCommParser.parser +++ b/compiler/2014/LabCommParser.parser @@ -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); :} diff --git a/compiler/2014/Refactoring.jrag b/compiler/2014/Refactoring.jrag index 4a2609c..fbe083f 100644 --- a/compiler/2014/Refactoring.jrag +++ b/compiler/2014/Refactoring.jrag @@ -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"); } } diff --git a/compiler/2014/Signature.jrag b/compiler/2014/Signature.jrag index 96231d1..89010e7 100644 --- a/compiler/2014/Signature.jrag +++ b/compiler/2014/Signature.jrag @@ -1,12 +1,12 @@ 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(); -- GitLab