Adding square brackets handling for arrays; Adding more policy files
authorrtrimana <rtrimana@uci.edu>
Thu, 29 Sep 2016 21:56:02 +0000 (14:56 -0700)
committerrtrimana <rtrimana@uci.edu>
Thu, 29 Sep 2016 21:56:02 +0000 (14:56 -0700)
config/iotpolicy/camerapolicy.pol [new file with mode: 0644]
config/iotpolicy/camerarequires.pol [new file with mode: 0644]
config/iotpolicy/lightbulbpolicy.pol [new file with mode: 0644]
config/iotpolicy/lightbulbrequires.pol [new file with mode: 0644]
config/iotpolicy/policy.pol [deleted file]
config/iotpolicy/requires.pol [deleted file]
iotjava/Makefile
iotjava/iotpolicy/parser/Lexer.java
iotjava/iotpolicy/parser/Parser.java
others/javacup/iotparser.cup
others/jflex/iotparser.jflex

diff --git a/config/iotpolicy/camerapolicy.pol b/config/iotpolicy/camerapolicy.pol
new file mode 100644 (file)
index 0000000..ac99558
--- /dev/null
@@ -0,0 +1,32 @@
+public interface Camera {
+
+    public void MethodA(int A, int B);
+    public void MethodA(int A, int B, int AB);
+    public int MethodB(int C, String D[]);
+    public String MethodC(String E, Map<String,Integer> F);
+    public float MethodD(Set<String> G, float H);
+    public boolean MethodE(String I, boolean J);
+       public void MethodF(int K);
+
+       capability ImageCapture {
+               description = "The quick brown fox jumps over the smart dog";
+               description = "Another description";
+               method = "MethodA(int A, int B)";
+               method = "MethodB(int C, String D[])";
+               method = "MethodC(String E, Map<String,Integer> F)";
+       }
+
+       capability VideoRecording {
+               description = "The quick brown fox jumps over the cool dog";
+               method = "MethodA(int A, int B)";
+               method = "MethodA(int A, int B, int AB)";
+               method = "MethodD(Set<String> G, float H)";
+       }
+
+       capability BackupData {
+               description = "The quick brown fox jumps over the clever dog";
+               method = "MethodE(String I, boolean J)";
+       }
+}
+
+
diff --git a/config/iotpolicy/camerarequires.pol b/config/iotpolicy/camerarequires.pol
new file mode 100644 (file)
index 0000000..90049de
--- /dev/null
@@ -0,0 +1,3 @@
+
+requires Camera with ImageCapture, BackupData as interface CameraWithCaptureAndData;
+
diff --git a/config/iotpolicy/lightbulbpolicy.pol b/config/iotpolicy/lightbulbpolicy.pol
new file mode 100644 (file)
index 0000000..900089c
--- /dev/null
@@ -0,0 +1,24 @@
+public interface LightBulb {
+
+    public void MethodA(int A, float B);
+    public void MethodA(int A, float B, int AB);
+    public int MethodB(String C, String D);
+    public byte MethodC(String E, Map<String,Integer> F);
+
+       capability Flicker {
+               description = "The quick brown fox jumps over the smart dog";
+               description = "Another description";
+               method = "MethodA(int A, float B)";
+               method = "MethodB(String C, String D)";
+               method = "MethodC(String E, Map<String,Integer> F)";
+       }
+
+       capability AutoOnOff {
+               description = "The quick brown fox jumps over the cool dog";
+               method = "MethodA(int A, float B)";
+               method = "MethodA(int A, float B, int AB)";
+               method = "MethodC(String E, Map<String,Integer> F)";
+       }
+}
+
+
diff --git a/config/iotpolicy/lightbulbrequires.pol b/config/iotpolicy/lightbulbrequires.pol
new file mode 100644 (file)
index 0000000..24a7ca1
--- /dev/null
@@ -0,0 +1,3 @@
+
+requires LightBulb with Flicker as interface LightBulbWithFlicker;
+
diff --git a/config/iotpolicy/policy.pol b/config/iotpolicy/policy.pol
deleted file mode 100644 (file)
index 986f6f9..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-public interface Camera {
-
-    public void MethodA(int A, int B);
-    public void MethodA(int A, int B, int AB);
-    public int MethodB(int C, String D);
-    public String MethodC(String E, Map<String,Integer> F);
-    public float MethodD(Set<String> G, float H);
-    public boolean MethodE(String I, boolean J);
-       public void MethodF(int K);
-
-       capability ImageCapture {
-               description = "The quick brown fox jumps over the smart dog";
-               description = "Another description";
-               method = "MethodA(int A, int B)";
-               method = "MethodB(int C, String D)";
-               method = "MethodC(String E, Map<String,Integer> F)";
-       }
-
-       capability VideoRecording {
-               description = "The quick brown fox jumps over the cool dog";
-               method = "MethodA(int A, int B)";
-               method = "MethodA(int A, int B, int AB)";
-               method = "MethodD(Set<String> G, float H)";
-       }
-
-       capability BackupData {
-               description = "The quick brown fox jumps over the clever dog";
-               method = "MethodE(String I, boolean J)";
-       }
-}
-
-
diff --git a/config/iotpolicy/requires.pol b/config/iotpolicy/requires.pol
deleted file mode 100644 (file)
index 2531e20..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-
-requires Camera with ImageCapture, BackupData as interface CameraWithCaptureAndData;
-requires Camera with ImageCapture, VideoRecording as interface CameraWithCaptureAndRecording;
-
index 6fa12090de8cb240e88e365c24479e46d70ecb4c..6b196776b1cd46df26438af81860881b62dfa6f7 100644 (file)
@@ -19,7 +19,7 @@ compiler:
 
 PHONY += run
 run:
-       cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler policy.pol requires.pol -java Java -cplus Cplus
+       cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler camerapolicy.pol camerarequires.pol -java Java -cplus Cplus
 
 PHONY += doc
 doc: iotruntime iotinstaller
index 947b4e32b832e749b71de15e5cfbdc924495e620..b3f3fd935d55f35484d236cd364b7afde084bffb 100644 (file)
@@ -47,11 +47,11 @@ public class Lexer implements java_cup.runtime.Scanner, sym {
   private static final String ZZ_CMAP_PACKED = 
     "\11\0\1\6\1\4\1\50\1\6\1\3\22\0\1\6\1\0\1\36"+
     "\1\0\1\1\3\0\1\40\1\41\2\0\1\37\3\0\12\2\1\0"+
-    "\1\5\1\42\1\46\1\43\2\0\22\1\1\30\7\1\1\0\1\47"+
-    "\2\0\1\1\1\0\1\24\1\16\1\27\1\25\1\20\1\23\1\22"+
-    "\1\13\1\7\2\1\1\21\1\33\1\10\1\14\1\32\1\34\1\15"+
-    "\1\12\1\11\1\26\1\31\1\35\1\1\1\17\1\1\1\44\1\0"+
-    "\1\45\7\0\1\50\u1fa2\0\1\50\1\50\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\udfe6\0";
+    "\1\5\1\42\1\46\1\43\2\0\22\1\1\30\7\1\1\2\1\47"+
+    "\1\2\1\0\1\1\1\0\1\24\1\16\1\27\1\25\1\20\1\23"+
+    "\1\22\1\13\1\7\2\1\1\21\1\33\1\10\1\14\1\32\1\34"+
+    "\1\15\1\12\1\11\1\26\1\31\1\35\1\1\1\17\1\1\1\44"+
+    "\1\0\1\45\7\0\1\50\u1fa2\0\1\50\1\50\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\udfe6\0";
 
   /** 
    * Translates characters to character classes
@@ -379,7 +379,7 @@ public class Lexer implements java_cup.runtime.Scanner, sym {
     char [] map = new char[0x110000];
     int i = 0;  /* index in packed string  */
     int j = 0;  /* index in unpacked array */
-    while (i < 166) {
+    while (i < 168) {
       int  count = packed.charAt(i++);
       char value = packed.charAt(i++);
       do map[j++] = value; while (--count > 0);
index 34802a246f58b2387adf88290d6af47d846475fe..5f3158a24323ecd4dc5117bb44e8969b2d9d967c 100644 (file)
@@ -47,11 +47,11 @@ public class Parser extends java_cup.runtime.lr_parser {
     "\007\000\002\007\011\000\002\007\011\000\002\007\011" +
     "\000\002\007\011\000\002\007\010\000\002\007\010\000" +
     "\002\007\012\000\002\007\012\000\002\007\012\000\002" +
-    "\007\012\000\002\010\004\000\002\010\002\000\002\011" +
-    "\007\000\002\012\004\000\002\012\002\000\002\013\006" +
-    "\000\002\013\006\000\002\014\004\000\002\014\002\000" +
-    "\002\015\012\000\002\016\003\000\002\016\005\000\002" +
-    "\016\002" });
+    "\007\012\000\002\011\004\000\002\011\002\000\002\012" +
+    "\007\000\002\013\004\000\002\013\002\000\002\014\006" +
+    "\000\002\014\006\000\002\015\004\000\002\015\002\000" +
+    "\002\016\012\000\002\017\003\000\002\017\005\000\002" +
+    "\017\002" });
 
   /** Access to production table. */
   public short[][] production_table() {return _production_table;}
@@ -121,14 +121,14 @@ public class Parser extends java_cup.runtime.lr_parser {
   /** <code>reduce_goto</code> table. */
   protected static final short[][] _reduce_table = 
     unpackFromStrings(new String[] {
-    "\000\127\000\010\002\006\003\003\014\004\001\001\000" +
-    "\002\001\001\000\004\015\115\001\001\000\002\001\001" +
+    "\000\127\000\010\002\006\003\003\015\004\001\001\000" +
+    "\002\001\001\000\004\016\115\001\001\000\002\001\001" +
     "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
     "\002\001\001\000\004\004\013\001\001\000\006\005\014" +
-    "\010\016\001\001\000\002\001\001\000\002\001\001\000" +
-    "\004\011\017\001\001\000\002\001\001\000\002\001\001" +
-    "\000\002\001\001\000\002\001\001\000\004\012\024\001" +
-    "\001\000\004\013\025\001\001\000\002\001\001\000\002" +
+    "\011\016\001\001\000\002\001\001\000\002\001\001\000" +
+    "\004\012\017\001\001\000\002\001\001\000\002\001\001" +
+    "\000\002\001\001\000\002\001\001\000\004\013\024\001" +
+    "\001\000\004\014\025\001\001\000\002\001\001\000\002" +
     "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
     "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
     "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
@@ -147,7 +147,7 @@ public class Parser extends java_cup.runtime.lr_parser {
     "\002\001\001\000\002\001\001\000\002\001\001\000\004" +
     "\006\112\001\001\000\004\007\046\001\001\000\002\001" +
     "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
-    "\000\002\001\001\000\004\016\122\001\001\000\002\001" +
+    "\000\002\001\001\000\004\017\122\001\001\000\002\001" +
     "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
     "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
     "\002\001\001" });
@@ -807,7 +807,7 @@ class CUP$Parser$actions {
                cl.addChild(cap);
                RESULT = cl;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capablist",6, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capablist",7, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -819,7 +819,7 @@ class CUP$Parser$actions {
                ParseNode pn = new ParseNode("capab_list");
                RESULT = pn;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capablist",6, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capablist",7, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -839,7 +839,7 @@ class CUP$Parser$actions {
                pn.addChild(ccont);
                RESULT = pn;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capab",7, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capab",8, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -857,7 +857,7 @@ class CUP$Parser$actions {
                ccont.addChild(cnt);
                RESULT = ccont;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capabcont",8, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capabcont",9, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -869,7 +869,7 @@ class CUP$Parser$actions {
                ParseNode pn = new ParseNode("capab_content");
                RESULT = pn;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capabcont",8, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capabcont",9, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -888,7 +888,7 @@ class CUP$Parser$actions {
                pn.addChild("capab_desc").setLiteral(strdsc);
                RESULT = pn;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("cont",9, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("cont",10, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -907,7 +907,7 @@ class CUP$Parser$actions {
                pn.addChild("capab_meth").setLiteral(strmeth);
                RESULT = pn;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("cont",9, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("cont",10, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -925,7 +925,7 @@ class CUP$Parser$actions {
                rl.addChild(req);
                RESULT = rl;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("reqlist",10, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("reqlist",11, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -937,7 +937,7 @@ class CUP$Parser$actions {
                ParseNode pn = new ParseNode("reqlist");
                RESULT = pn;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("reqlist",10, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("reqlist",11, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -961,7 +961,7 @@ class CUP$Parser$actions {
                pn.addChild("new_intface_ident").setLiteral(idnewint);
                RESULT = pn;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("require",11, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-7)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("require",12, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-7)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -977,7 +977,7 @@ class CUP$Parser$actions {
                pn.addChild("capab_ident").setLiteral(idcap);
                RESULT = pn;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capintlist",12, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capintlist",13, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -995,7 +995,7 @@ class CUP$Parser$actions {
                cil.addChild("capab_ident").setLiteral(idcap);
                RESULT = cil;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capintlist",12, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capintlist",13, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
@@ -1007,7 +1007,7 @@ class CUP$Parser$actions {
                ParseNode pn = new ParseNode("capab_ident_list");
                RESULT = pn;
        
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capintlist",12, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capintlist",13, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
             }
           return CUP$Parser$result;
 
index c6c9f6dbf9c2da880ff1146d92d412788757fbf2..36dcb7a31f841069d4fad4428950e2b98acd5aa1 100644 (file)
@@ -30,7 +30,7 @@ terminal TYPE;
 terminal IDENT, STRINGCONST;
 
 non terminal ParseNode policy;
-non terminal ParseNode intface, methlist, meth, paramlist, param;
+non terminal ParseNode intface, methlist, meth, paramlist, param, paramtype;
 non terminal ParseNode capablist, capab, capabcont, cont;
 non terminal ParseNode reqlist, require, capintlist;
 
index 239c81dcbba6859e129d59078309a523f0b0d883..8ad50b34cae4240ea677e85ed9e5ff89607cd725 100644 (file)
@@ -52,7 +52,7 @@ import java_cup.runtime.ComplexSymbolFactory.Location;
 %eofval}
 
 
-Ident = [a-zA-Z$_] [a-zA-Z0-9$_]*
+Ident = [a-zA-Z$_] [a-zA-Z0-9$_\[\]]*
 
 new_line = \r|\n|\r\n;