From c2e5f2450bb3c6a707ebf2509adc4497624c435d Mon Sep 17 00:00:00 2001
From: Sven Gestegard Robertz <sven.robertz@cs.lth.se>
Date: Wed, 29 Apr 2015 22:46:12 +0200
Subject: [PATCH] dummy testing of intention parsing

---
 compiler/2014/LabCommScanner.flex |  1 +
 compiler/2014/Signature.jrag      | 38 +++++++++++++++++++++++++++++++
 examples/user_types/test.lc       |  8 +++----
 3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/compiler/2014/LabCommScanner.flex b/compiler/2014/LabCommScanner.flex
index a0e2efa..6d4f7c1 100644
--- a/compiler/2014/LabCommScanner.flex
+++ b/compiler/2014/LabCommScanner.flex
@@ -45,6 +45,7 @@ TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" | "/*" "*"+ [^/*] ~"*/"
 EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
 
 Identifier = [[:letter:]_]([[:letter:]_[:digit:]])*
+StringLiteral = [:jletterdigit:]*
 
 DecimalNumeral = 0 | {NonZeroDigit} {Digits}? 
 Digits = {Digit}+
diff --git a/compiler/2014/Signature.jrag b/compiler/2014/Signature.jrag
index fb911b6..1c1c820 100644
--- a/compiler/2014/Signature.jrag
+++ b/compiler/2014/Signature.jrag
@@ -1,5 +1,15 @@
 import java.util.*;
 
+aspect Intentions {
+
+    inh Decl ConcreteType.parentDecl();
+
+    coll Set Decl.allIntentions() [new HashSet()] with add;
+    ConcreteType contributes getIntentionString()
+        to Decl.allIntentions()
+        for parentDecl();
+}
+
 aspect Signature {
 
   syn boolean Decl.isSampleDecl();
@@ -14,7 +24,35 @@ aspect Signature {
   inh Decl Signature.parentDecl();
   inh Decl SignatureList.parentDecl();
 
+  /// TESTING
+  syn String Decl.getIntentionString()  {
+      StringBuilder sb = new StringBuilder();
+      Iterator<String> iti = allIntentions().iterator();
+      while(iti.hasNext()) {
+          //Intention i = iti.next();
+          //sb.append("("+i.getKey()+" : "+i.getValue()+") ");
+          String i = iti.next();
+          sb.append(i);
+      }
+      return sb.toString();
+  }
+
+  syn String ConcreteType.getIntentionString() {
+      StringBuilder sb = new StringBuilder();
+      List<Intention> ints = getIntentionList();
+      for(Intention i : ints) {
+          sb.append("("+i.getKey()+" : "+i.getValue()+") ");
+      }
+      return sb.toString();
+  }
+
+  public void Decl.debugIntentions() {
+      System.out.println("Decl.intentions: " + getIntentionString());
+  }
+  //  TESTING END
+
   syn nta Signature Decl.getSignature() {
+    debugIntentions();
     SignatureList sl = new SignatureList();
     genSigLineForDecl(sl, true);
     SignatureList fsl = new SignatureList();
diff --git a/examples/user_types/test.lc b/examples/user_types/test.lc
index 75497b4..a0ad602 100644
--- a/examples/user_types/test.lc
+++ b/examples/user_types/test.lc
@@ -1,14 +1,14 @@
 typedef struct {
-  int val;
+  (foo:bar) int val;
 } coord;
 
 typedef int anInt;
 
 typedef void avoid;
-sample avoid doavoid;
+sample (function:trigger)(foo:bar) avoid doavoid;
 
-sample struct {
-  int x;
+sample (a:b) struct {
+  (c:d)(e:f) int x;
   sample reference;
 } intAndRef;
 
-- 
GitLab