Commit 00d6182c authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

added experimental docstring annotation

parent 0660eda2
......@@ -2,8 +2,6 @@ Specification ::= Decl*;
abstract Decl ::= TypeInstance /Signature/;
TypeInstance ::= DataType <Name:String> Intention*;
TypeDecl : Decl;
SampleDecl : Decl;
......
......@@ -54,25 +54,27 @@ List var_decl_list =
| var_decl_list.l var_decl.v {: return l.add(v); :}
;
List intentions =
List annotations =
/* empty list */ {: return new List(); :}
| intention_list.l {: return l; :}
| annotation_list.l {: return l; :}
;
List intention_list =
intention.i {: return new List().add(i); :}
| intention_list.l intention.i {: return l.add(i); :}
List annotation_list =
annotation.i {: return new List().add(i); :}
| annotation_list.l annotation.i {: return l.add(i); :}
;
String key = IDENTIFIER;
String stringliteral = IDENTIFIER;
Annotation intention = LPAREN key.k COLON stringliteral.v RPAREN {: return new Annotation(k,v); :};
Annotation annotation = intention.i | docstring.d;
Annotation intention = LPAREN key.k COLON stringliteral.v RPAREN {: return new Intention(k,v); :};
Annotation docstring = QUOTEDSTRING.s {: return new DocString(s.substring(1,s.length()-1)); :};
TypeInstance type_instance =
intentions.i type.t IDENTIFIER {: return new TypeInstance(t, IDENTIFIER, i); :}
| intentions.i type.t IDENTIFIER dim_list.d
{: return new TypeInstance(new ParseArrayType(t, d), IDENTIFIER, i); :}
annotations.a type.t IDENTIFIER {: return new TypeInstance(t, IDENTIFIER, a); :}
| annotations.a type.t IDENTIFIER dim_list.d
{: return new TypeInstance(new ParseArrayType(t, d), IDENTIFIER, a); :}
;
Field var_decl =
......
......@@ -52,6 +52,8 @@ Digits = {Digit}+
Digit = 0 | {NonZeroDigit}
NonZeroDigit = [1-9]
QuotedString = "\"" {InputCharacter}* "\""
%%
<YYINITIAL> {
......@@ -84,6 +86,7 @@ NonZeroDigit = [1-9]
"," { return sym(Terminals.COMMA); }
{Identifier} { return sym(Terminals.IDENTIFIER); }
{QuotedString} { return sym(Terminals.QUOTEDSTRING); }
}
// fall through errors
......
......@@ -8,6 +8,18 @@ aspect Annotations {
TypeInstance contributes getAnnotationString()
to Decl.allAnnotations()
for parentDecl();
public DocString.DocString(String s) {
super("DOCSTRING", s);
}
public String Intention.toString() {
return("("+getKey()+" : "+getValue()+") ");
}
public String DocString.toString() {
return "\""+getValue()+"\"";
}
}
aspect Signature {
......@@ -41,7 +53,7 @@ aspect Signature {
StringBuilder sb = new StringBuilder();
List<Annotation> ints = getAnnotationList();
for(Annotation i : ints) {
sb.append("("+i.getKey()+" : "+i.getValue()+") ");
sb.append(i.toString());
}
return sb.toString();
}
......
......@@ -7,7 +7,7 @@ typedef int anInt;
typedef void avoid;
sample (function:trigger)(foo:bar) avoid doavoid;
sample (a:b) struct {
sample (a:b) "a struct with an int and a ref" struct {
(c:d)(e:f) int x;
sample reference;
} intAndRef;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment