diff --git a/compiler/2014/LabComm.ast b/compiler/2014/LabComm.ast index f1fd5c039f5fbed6070a56dc1287f8ad9dd934c6..a89b9c6f36c1d8a1cd44616971210761fb57f5af 100644 --- a/compiler/2014/LabComm.ast +++ b/compiler/2014/LabComm.ast @@ -2,8 +2,6 @@ Specification ::= Decl*; abstract Decl ::= TypeInstance /Signature/; -TypeInstance ::= DataType <Name:String> Intention*; - TypeDecl : Decl; SampleDecl : Decl; diff --git a/compiler/2014/LabCommParser.parser b/compiler/2014/LabCommParser.parser index 3575ee283662dc35010fe45e0351b8d71aaded3f..f95ca89d5834b04e977f8ba4e02e7e7604af127d 100644 --- a/compiler/2014/LabCommParser.parser +++ b/compiler/2014/LabCommParser.parser @@ -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 = diff --git a/compiler/2014/LabCommScanner.flex b/compiler/2014/LabCommScanner.flex index 6d4f7c1a001a24e179d38c62a10ffc657b8fc791..0b28eff715d85d27ea31a99a2c52957165e2a0c2 100644 --- a/compiler/2014/LabCommScanner.flex +++ b/compiler/2014/LabCommScanner.flex @@ -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 diff --git a/compiler/2014/Signature.jrag b/compiler/2014/Signature.jrag index 89010e75c4971d9efbbf0f05dd16a1c24e3cb108..6cba875085bc30f153644ef9b35b445a89cc5d0b 100644 --- a/compiler/2014/Signature.jrag +++ b/compiler/2014/Signature.jrag @@ -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(); } diff --git a/examples/user_types/test.lc b/examples/user_types/test.lc index a0ad6026cf06eab514cf776c168fae1401035762..05b94c9c2c8e0d9d9ef4c6c7b525d8df41e4909b 100644 --- a/examples/user_types/test.lc +++ b/examples/user_types/test.lc @@ -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;