Perfecting parser, lexer, and parse-tree handling for policy files; Generating skelet...
authorrtrimana <rtrimana@uci.edu>
Fri, 23 Sep 2016 23:25:41 +0000 (16:25 -0700)
committerrtrimana <rtrimana@uci.edu>
Fri, 23 Sep 2016 23:25:41 +0000 (16:25 -0700)
23 files changed:
config/iotparser/policy.pol [deleted file]
config/iotparser/tree-view.xsl [deleted file]
config/iotparser/tree.xsl [deleted file]
config/iotpolicy/policy.pol [new file with mode: 0644]
config/iotpolicy/tree-view.xsl [new file with mode: 0644]
config/iotpolicy/tree.xsl [new file with mode: 0644]
iotjava/Makefile
iotjava/iotparser/Lexer.java [deleted file]
iotjava/iotparser/Parser.java [deleted file]
iotjava/iotparser/sym.java [deleted file]
iotjava/iotpolicy/IoTStubCompiler.java [new file with mode: 0644]
iotjava/iotpolicy/parser/Lexer.java [new file with mode: 0644]
iotjava/iotpolicy/parser/Parser.java [new file with mode: 0644]
iotjava/iotpolicy/parser/sym.java [new file with mode: 0644]
iotjava/iotpolicy/tree/CapabilityDecl.java [new file with mode: 0644]
iotjava/iotpolicy/tree/InterfaceDecl.java [new file with mode: 0644]
iotjava/iotpolicy/tree/ParseNode.java [new file with mode: 0644]
iotjava/iotpolicy/tree/ParseNodeVector.java [new file with mode: 0644]
iotjava/iotpolicy/tree/ParseTreeHandler.java [new file with mode: 0644]
iotjava/iotpolicy/tree/RequiresDecl.java [new file with mode: 0644]
iotjava/iotpolicy/tree/Walkable.java [new file with mode: 0644]
others/javacup/iotparser.cup
others/jflex/iotparser.jflex

diff --git a/config/iotparser/policy.pol b/config/iotparser/policy.pol
deleted file mode 100644 (file)
index 7bcefcd..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-public interface Camera {
-    public void MethodA(int A, int B);
-    public int MethodB(int C, string D);
-    public string MethodC(string E, int F);
-    public float MethodD(int G, float H);
-    public boolean MethodE(Camera I, boolean J);
-       public void MethodF();
-}
-
-capability Camera.ImageCapture {
-       description = "The quick brown fox jumps over the smart dog";
-       description = "Another description";
-       method = MethodA;
-       method = MethodB;
-}
-
-capability Camera.VideoRecording {
-       description = "The quick brown fox jumps over the cool dog";
-       method = MethodC;
-       method = MethodD;
-}
-
-capability Camera.BackupData {
-       description = "The quick brown fox jumps over the clever dog";
-       method = MethodE;
-}
-
-requires Camera with VideoRecording, ImageCapture as interface CameraWithCaptureAndData;
-
-requires Camera with ImageCapture, VideoRecording as interface CameraWithCaptureAndRecording;
diff --git a/config/iotparser/tree-view.xsl b/config/iotparser/tree-view.xsl
deleted file mode 100644 (file)
index 0a2e141..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-  <xsl:output method="html" 
-             encoding="UTF-8"
-             indent="no"/>
-
-  <xsl:variable name="apos">'</xsl:variable>
-
-  <xsl:template match="/">
-    <html>
-      <head>
-       <meta charset="UTF-8" />
-        <title>Parse-Tree</title>
-        <link type="text/css" rel="stylesheet" href="tree-view.css"/>
-      </head>
-      <body>
-        <h3>Parse-Tree</h3>
-        <xsl:apply-templates select="." mode="render"/>
-      </body>
-    </html>
-  </xsl:template>
-
-  <xsl:template match="/" mode="render">
-    <xsl:apply-templates mode="render"/>
-  </xsl:template>
-
-  <xsl:template match="*" mode="render">
-    <xsl:call-template name="ascii-art-hierarchy"/>
-    <br/>
-    <xsl:call-template name="ascii-art-hierarchy"/>
-    <span class='connector'>___</span>
-    <span class="element"><xsl:value-of select="local-name()"/></span>
-    <xsl:text>&#160;</xsl:text>
-    <br/>
-    <xsl:apply-templates select="@*" mode="render"/>
-    <xsl:apply-templates mode="render"/>
-  </xsl:template>
-
-  <xsl:template match="@*" mode="render">
-    <xsl:call-template name="ascii-art-hierarchy"/>
-    <span class='connector'>&#160;&#160;</span>
-    <span class='connector'>\___</span>
-
-    <xsl:text>&#160;</xsl:text>
-    <span class="name">
-      <xsl:value-of select="local-name()"/>
-    </span>
-    <xsl:text> = </xsl:text>
-    <span class="value">
-      <xsl:call-template name="escape-ws">
-        <xsl:with-param name="text" select="translate(.,' ','&#160;')"/>
-      </xsl:call-template>
-    </span>
-    <br/>
-  </xsl:template>
-
-  <xsl:template match="text()" mode="render">
-    <xsl:call-template name="ascii-art-hierarchy"/>
-    <br/>
-    <xsl:call-template name="ascii-art-hierarchy"/>
-    <span class='connector'>___</span>
-    <xsl:text>&#160;</xsl:text>
-    <span class="value">
-      <xsl:call-template name="escape-ws">
-        <xsl:with-param name="text" select="translate(.,' ','&#160;')"/>
-      </xsl:call-template>
-    </span>
-    <br/>
-  </xsl:template>
-
-  <xsl:template match="comment()" mode="render" />
-  <xsl:template match="processing-instruction()" mode="render" />
-
-
-  <xsl:template name="ascii-art-hierarchy">
-    <xsl:for-each select="ancestor::*">
-      <xsl:choose>
-        <xsl:when test="following-sibling::node()">
-          <span class='connector'>&#160;&#160;</span>|<span class='connector'>&#160;&#160;</span>
-          <xsl:text>&#160;</xsl:text>
-        </xsl:when>
-        <xsl:otherwise>
-          <span class='connector'>&#160;&#160;&#160;&#160;</span>
-          <span class='connector'>&#160;&#160;</span>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:for-each>
-    <xsl:choose>
-      <xsl:when test="parent::node() and ../child::node()">
-        <span class='connector'>&#160;&#160;</span>
-        <xsl:text>|</xsl:text>
-      </xsl:when>
-      <xsl:otherwise>
-        <span class='connector'>&#160;&#160;&#160;</span>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <!-- recursive template to escape linefeeds, tabs -->
-  <xsl:template name="escape-ws">
-    <xsl:param name="text"/>
-    <xsl:choose>
-      <xsl:when test="contains($text, '&#xA;')">
-        <xsl:call-template name="escape-ws">
-          <xsl:with-param name="text" select="substring-before($text, '&#xA;')"/>
-        </xsl:call-template>
-        <span class="escape">\n</span>
-        <xsl:call-template name="escape-ws">
-          <xsl:with-param name="text" select="substring-after($text, '&#xA;')"/>
-        </xsl:call-template>
-      </xsl:when>
-      <xsl:when test="contains($text, '&#x9;')">
-        <xsl:value-of select="substring-before($text, '&#x9;')"/>
-        <span class="escape">\t</span>
-        <xsl:call-template name="escape-ws">
-          <xsl:with-param name="text" select="substring-after($text, '&#x9;')"/>
-        </xsl:call-template>
-      </xsl:when>
-      <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-</xsl:stylesheet>
diff --git a/config/iotparser/tree.xsl b/config/iotparser/tree.xsl
deleted file mode 100644 (file)
index 05e1b27..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet version="1.0" 
-               xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-               xmlns:exsl="http://exslt.org/common"
-               >
-<xsl:output method="xml" version="1.0" encoding="UTF-8" />
-
-<xsl:include href="tree-view.xsl"/>
-
-<xsl:template match="blacklist"  mode="flatten" />
-
-<xsl:template match="document"  mode="flatten">
-      <xsl:apply-templates  mode="flatten" select="parsetree"/>
-</xsl:template>
-
-<xsl:template match="nonterminal" mode="flatten">
-  <xsl:variable name="temp" select="@id" />
-  <xsl:choose>
-    
-    <xsl:when test="count(*)=3 and contains($temp,'expr') and *[contains(@id,'expr')]"> 
-      <xsl:apply-templates  mode="flatten"/>
-    </xsl:when>
-
-    <!-- collapses degenerated trees like lists, conserving the blacklist subtrees-->
-    <xsl:when test="../@id = @id and count(/document/blacklist[1]/symbol[text() = $temp])=0"> 
-      <xsl:apply-templates  mode="flatten"/>
-    </xsl:when>
-
-    <!-- collapses unary productions -->
-    <xsl:when test="count(*)=3 and count(/document/blacklist[1]/symbol[text() = $temp])=0"> 
-      <xsl:apply-templates  mode="flatten"/>
-    </xsl:when>
-
-    <xsl:otherwise>
-      <xsl:element name="{@id}" >
-       <xsl:attribute name="variant"><xsl:value-of select="@variant" /></xsl:attribute>
-       <xsl:apply-templates mode="flatten"/>
-      </xsl:element>
-    </xsl:otherwise>
-
-  </xsl:choose>
-</xsl:template>
-
-<xsl:template match="terminal" mode="flatten">
-  <xsl:element name="{@id}">
-    <xsl:apply-templates  mode="flatten"/>
-  </xsl:element>
-</xsl:template>
-
-<xsl:template match="/">
- <xsl:variable name="flatten">
-     <xsl:apply-templates  mode="flatten"/>
- </xsl:variable>
- <xsl:variable name="rendered">
-    <xsl:apply-templates mode="rendered" select="exsl:node-set($flatten)"/>
- </xsl:variable>
-
- <!--xsl:copy-of select="$rendered" /-->
- <xsl:copy-of select="$flatten" />
-</xsl:template>
-
-
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/config/iotpolicy/policy.pol b/config/iotpolicy/policy.pol
new file mode 100644 (file)
index 0000000..7bcefcd
--- /dev/null
@@ -0,0 +1,30 @@
+public interface Camera {
+    public void MethodA(int A, int B);
+    public int MethodB(int C, string D);
+    public string MethodC(string E, int F);
+    public float MethodD(int G, float H);
+    public boolean MethodE(Camera I, boolean J);
+       public void MethodF();
+}
+
+capability Camera.ImageCapture {
+       description = "The quick brown fox jumps over the smart dog";
+       description = "Another description";
+       method = MethodA;
+       method = MethodB;
+}
+
+capability Camera.VideoRecording {
+       description = "The quick brown fox jumps over the cool dog";
+       method = MethodC;
+       method = MethodD;
+}
+
+capability Camera.BackupData {
+       description = "The quick brown fox jumps over the clever dog";
+       method = MethodE;
+}
+
+requires Camera with VideoRecording, ImageCapture as interface CameraWithCaptureAndData;
+
+requires Camera with ImageCapture, VideoRecording as interface CameraWithCaptureAndRecording;
diff --git a/config/iotpolicy/tree-view.xsl b/config/iotpolicy/tree-view.xsl
new file mode 100644 (file)
index 0000000..0a2e141
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:output method="html" 
+             encoding="UTF-8"
+             indent="no"/>
+
+  <xsl:variable name="apos">'</xsl:variable>
+
+  <xsl:template match="/">
+    <html>
+      <head>
+       <meta charset="UTF-8" />
+        <title>Parse-Tree</title>
+        <link type="text/css" rel="stylesheet" href="tree-view.css"/>
+      </head>
+      <body>
+        <h3>Parse-Tree</h3>
+        <xsl:apply-templates select="." mode="render"/>
+      </body>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="/" mode="render">
+    <xsl:apply-templates mode="render"/>
+  </xsl:template>
+
+  <xsl:template match="*" mode="render">
+    <xsl:call-template name="ascii-art-hierarchy"/>
+    <br/>
+    <xsl:call-template name="ascii-art-hierarchy"/>
+    <span class='connector'>___</span>
+    <span class="element"><xsl:value-of select="local-name()"/></span>
+    <xsl:text>&#160;</xsl:text>
+    <br/>
+    <xsl:apply-templates select="@*" mode="render"/>
+    <xsl:apply-templates mode="render"/>
+  </xsl:template>
+
+  <xsl:template match="@*" mode="render">
+    <xsl:call-template name="ascii-art-hierarchy"/>
+    <span class='connector'>&#160;&#160;</span>
+    <span class='connector'>\___</span>
+
+    <xsl:text>&#160;</xsl:text>
+    <span class="name">
+      <xsl:value-of select="local-name()"/>
+    </span>
+    <xsl:text> = </xsl:text>
+    <span class="value">
+      <xsl:call-template name="escape-ws">
+        <xsl:with-param name="text" select="translate(.,' ','&#160;')"/>
+      </xsl:call-template>
+    </span>
+    <br/>
+  </xsl:template>
+
+  <xsl:template match="text()" mode="render">
+    <xsl:call-template name="ascii-art-hierarchy"/>
+    <br/>
+    <xsl:call-template name="ascii-art-hierarchy"/>
+    <span class='connector'>___</span>
+    <xsl:text>&#160;</xsl:text>
+    <span class="value">
+      <xsl:call-template name="escape-ws">
+        <xsl:with-param name="text" select="translate(.,' ','&#160;')"/>
+      </xsl:call-template>
+    </span>
+    <br/>
+  </xsl:template>
+
+  <xsl:template match="comment()" mode="render" />
+  <xsl:template match="processing-instruction()" mode="render" />
+
+
+  <xsl:template name="ascii-art-hierarchy">
+    <xsl:for-each select="ancestor::*">
+      <xsl:choose>
+        <xsl:when test="following-sibling::node()">
+          <span class='connector'>&#160;&#160;</span>|<span class='connector'>&#160;&#160;</span>
+          <xsl:text>&#160;</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+          <span class='connector'>&#160;&#160;&#160;&#160;</span>
+          <span class='connector'>&#160;&#160;</span>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:for-each>
+    <xsl:choose>
+      <xsl:when test="parent::node() and ../child::node()">
+        <span class='connector'>&#160;&#160;</span>
+        <xsl:text>|</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class='connector'>&#160;&#160;&#160;</span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <!-- recursive template to escape linefeeds, tabs -->
+  <xsl:template name="escape-ws">
+    <xsl:param name="text"/>
+    <xsl:choose>
+      <xsl:when test="contains($text, '&#xA;')">
+        <xsl:call-template name="escape-ws">
+          <xsl:with-param name="text" select="substring-before($text, '&#xA;')"/>
+        </xsl:call-template>
+        <span class="escape">\n</span>
+        <xsl:call-template name="escape-ws">
+          <xsl:with-param name="text" select="substring-after($text, '&#xA;')"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:when test="contains($text, '&#x9;')">
+        <xsl:value-of select="substring-before($text, '&#x9;')"/>
+        <span class="escape">\t</span>
+        <xsl:call-template name="escape-ws">
+          <xsl:with-param name="text" select="substring-after($text, '&#x9;')"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+</xsl:stylesheet>
diff --git a/config/iotpolicy/tree.xsl b/config/iotpolicy/tree.xsl
new file mode 100644 (file)
index 0000000..05e1b27
--- /dev/null
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" 
+               xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+               xmlns:exsl="http://exslt.org/common"
+               >
+<xsl:output method="xml" version="1.0" encoding="UTF-8" />
+
+<xsl:include href="tree-view.xsl"/>
+
+<xsl:template match="blacklist"  mode="flatten" />
+
+<xsl:template match="document"  mode="flatten">
+      <xsl:apply-templates  mode="flatten" select="parsetree"/>
+</xsl:template>
+
+<xsl:template match="nonterminal" mode="flatten">
+  <xsl:variable name="temp" select="@id" />
+  <xsl:choose>
+    
+    <xsl:when test="count(*)=3 and contains($temp,'expr') and *[contains(@id,'expr')]"> 
+      <xsl:apply-templates  mode="flatten"/>
+    </xsl:when>
+
+    <!-- collapses degenerated trees like lists, conserving the blacklist subtrees-->
+    <xsl:when test="../@id = @id and count(/document/blacklist[1]/symbol[text() = $temp])=0"> 
+      <xsl:apply-templates  mode="flatten"/>
+    </xsl:when>
+
+    <!-- collapses unary productions -->
+    <xsl:when test="count(*)=3 and count(/document/blacklist[1]/symbol[text() = $temp])=0"> 
+      <xsl:apply-templates  mode="flatten"/>
+    </xsl:when>
+
+    <xsl:otherwise>
+      <xsl:element name="{@id}" >
+       <xsl:attribute name="variant"><xsl:value-of select="@variant" /></xsl:attribute>
+       <xsl:apply-templates mode="flatten"/>
+      </xsl:element>
+    </xsl:otherwise>
+
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="terminal" mode="flatten">
+  <xsl:element name="{@id}">
+    <xsl:apply-templates  mode="flatten"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="/">
+ <xsl:variable name="flatten">
+     <xsl:apply-templates  mode="flatten"/>
+ </xsl:variable>
+ <xsl:variable name="rendered">
+    <xsl:apply-templates mode="rendered" select="exsl:node-set($flatten)"/>
+ </xsl:variable>
+
+ <!--xsl:copy-of select="$rendered" /-->
+ <xsl:copy-of select="$flatten" />
+</xsl:template>
+
+
+</xsl:stylesheet>
\ No newline at end of file
index fa16fc7d2be3b6f6bd08967eb86f43b00d21ff71..8d92c94553cbc14112e5f64bfa02cdc68b458860 100644 (file)
@@ -2,19 +2,27 @@ BASE := ..
 
 include $(BASE)/common.mk
 
-all: iotparser
+all: iotparsertree iotparser iotcompiler
+
+PHONY += iotparsertree
+iotparsertree:
+       $(JAVAC) -cp .:$(PARSERJARS) -d $(BIN_DIR) iotpolicy/tree/*.java
 
 PHONY += iotparser
 iotparser:
-       $(JAVAC) -cp .:$(PARSERJARS) -d $(BIN_DIR) iotparser/*.java
-       cp ../config/iotparser/* $(BIN_DIR)/iotparser/
+       $(JAVAC) -cp .:$(PARSERJARS) -d $(BIN_DIR) iotpolicy/parser/*.java
+
+PHONY += iotcompiler
+iotcompiler:
+       $(JAVAC) -cp .:$(PARSERJARS) -d $(BIN_DIR) iotpolicy/*.java
+       cp ../config/iotpolicy/*.pol $(BIN_DIR)/iotpolicy/
 
-PHONY += iotparse
-iotparse:
-       cd $(BIN_DIR)/iotparser; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotparser.Parser policy.pol out.xml
+PHONY += iotcompilestub
+iotcompilestub:
+       cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTStubCompiler policy.pol
 
 PHONY += doc
 doc: iotruntime iotinstaller
-       $(JAVADOC) -d $(DOCS_DIR) iotparser/*.java
+       $(JAVADOC) -d $(DOCS_DIR) iotpolicy/*.java
 
 .PHONY: $(PHONY)
diff --git a/iotjava/iotparser/Lexer.java b/iotjava/iotparser/Lexer.java
deleted file mode 100644 (file)
index c527efb..0000000
+++ /dev/null
@@ -1,901 +0,0 @@
-package iotparser;
-
-/* The following code was generated by JFlex 1.6.1 */
-
-// JFlex parser specification written by
-// Rahmadi Trimananda
-// for Sentinel system
-// University of California, Irvine
-
-// Technische Universitaet Muenchen 
-// Fakultaet fuer Informatik 
-
-import java_cup.runtime.Symbol;
-import java_cup.runtime.ComplexSymbolFactory;
-import java_cup.runtime.ComplexSymbolFactory.Location;
-
-
-/**
- * This class is a scanner generated by 
- * <a href="http://www.jflex.de/">JFlex</a> 1.6.1
- * from the specification file <tt>iotparser.jflex</tt>
- */
-public class Lexer implements java_cup.runtime.Scanner, sym {
-
-  /** This character denotes the end of file */
-  public static final int YYEOF = -1;
-
-  /** initial size of the lookahead buffer */
-  private static final int ZZ_BUFFERSIZE = 16384;
-
-  /** lexical states */
-  public static final int YYINITIAL = 0;
-  public static final int STRING = 2;
-
-  /**
-   * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
-   * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
-   *                  at the beginning of a line
-   * l is of the form l = 2*k, k a non negative integer
-   */
-  private static final int ZZ_LEXSTATE[] = { 
-     0,  0,  1, 1
-  };
-
-  /** 
-   * Translates characters to character classes
-   */
-  private static final String ZZ_CMAP_PACKED = 
-    "\11\0\1\6\1\4\1\46\1\6\1\3\22\0\1\6\1\0\1\35"+
-    "\1\0\1\1\3\0\1\40\1\41\2\0\1\36\1\0\1\37\1\0"+
-    "\12\2\1\0\1\5\1\0\1\44\3\0\32\1\1\0\1\45\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\32\1\10\1\14\1\31\1\33\1\15\1\12"+
-    "\1\11\1\26\1\30\1\34\1\1\1\17\1\1\1\42\1\0\1\43"+
-    "\7\0\1\46\u1fa2\0\1\46\1\46\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
-   */
-  private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
-
-  /** 
-   * Translates DFA states to action switch labels.
-   */
-  private static final int [] ZZ_ACTION = zzUnpackAction();
-
-  private static final String ZZ_ACTION_PACKED_0 =
-    "\2\0\1\1\1\2\2\3\1\4\15\2\1\5\1\6"+
-    "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1\16"+
-    "\1\17\1\0\10\2\1\20\10\2\1\21\1\22\1\23"+
-    "\1\24\1\25\24\2\1\26\1\27\3\2\1\30\1\2"+
-    "\1\31\2\2\1\32\2\2\1\33\2\2\1\34\6\2"+
-    "\1\35\2\2\1\36\2\2\1\37\1\40\2\2\1\41"+
-    "\3\2\1\42\2\2\1\43\3\2\1\44\1\45";
-
-  private static int [] zzUnpackAction() {
-    int [] result = new int[120];
-    int offset = 0;
-    offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
-    return result;
-  }
-
-  private static int zzUnpackAction(String packed, int offset, int [] result) {
-    int i = 0;       /* index in packed string  */
-    int j = offset;  /* index in unpacked array */
-    int l = packed.length();
-    while (i < l) {
-      int count = packed.charAt(i++);
-      int value = packed.charAt(i++);
-      do result[j++] = value; while (--count > 0);
-    }
-    return j;
-  }
-
-
-  /** 
-   * Translates a state to a row index in the transition table
-   */
-  private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
-
-  private static final String ZZ_ROWMAP_PACKED_0 =
-    "\0\0\0\47\0\116\0\165\0\234\0\116\0\116\0\303"+
-    "\0\352\0\u0111\0\u0138\0\u015f\0\u0186\0\u01ad\0\u01d4\0\u01fb"+
-    "\0\u0222\0\u0249\0\u0270\0\u0297\0\116\0\116\0\116\0\116"+
-    "\0\116\0\116\0\116\0\116\0\u02be\0\116\0\u02e5\0\u030c"+
-    "\0\u0333\0\u035a\0\u0381\0\u03a8\0\u03cf\0\u03f6\0\u041d\0\u0444"+
-    "\0\165\0\u046b\0\u0492\0\u04b9\0\u04e0\0\u0507\0\u052e\0\u0555"+
-    "\0\u057c\0\116\0\116\0\116\0\116\0\u05a3\0\u05ca\0\u05f1"+
-    "\0\u0618\0\u063f\0\u0666\0\u068d\0\u06b4\0\u06db\0\u0702\0\u0729"+
-    "\0\u0750\0\u0777\0\u079e\0\u07c5\0\u07ec\0\u0813\0\u083a\0\u0861"+
-    "\0\u0888\0\u08af\0\165\0\165\0\u08d6\0\u08fd\0\u0924\0\165"+
-    "\0\u094b\0\165\0\u0972\0\u0999\0\165\0\u09c0\0\u09e7\0\165"+
-    "\0\u0a0e\0\u0a35\0\165\0\u0a5c\0\u0a83\0\u0aaa\0\u0ad1\0\u0af8"+
-    "\0\u0b1f\0\165\0\u0b46\0\u0b6d\0\165\0\u0b94\0\u0bbb\0\165"+
-    "\0\165\0\u0be2\0\u0c09\0\165\0\u0c30\0\u0c57\0\u0c7e\0\165"+
-    "\0\u0ca5\0\u0ccc\0\165\0\u0cf3\0\u0d1a\0\u0d41\0\165\0\165";
-
-  private static int [] zzUnpackRowMap() {
-    int [] result = new int[120];
-    int offset = 0;
-    offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
-    return result;
-  }
-
-  private static int zzUnpackRowMap(String packed, int offset, int [] result) {
-    int i = 0;  /* index in packed string  */
-    int j = offset;  /* index in unpacked array */
-    int l = packed.length();
-    while (i < l) {
-      int high = packed.charAt(i++) << 16;
-      result[j++] = high | packed.charAt(i++);
-    }
-    return j;
-  }
-
-  /** 
-   * The transition table of the DFA
-   */
-  private static final int [] ZZ_TRANS = zzUnpackTrans();
-
-  private static final String ZZ_TRANS_PACKED_0 =
-    "\1\3\1\4\1\3\1\5\1\6\1\7\1\6\1\10"+
-    "\2\4\1\11\2\4\1\12\1\13\2\4\1\14\1\4"+
-    "\1\15\1\16\1\17\1\4\1\20\1\21\1\22\1\23"+
-    "\1\4\1\24\1\25\1\26\1\27\1\30\1\31\1\32"+
-    "\1\33\1\34\1\3\1\0\3\35\1\0\1\3\30\35"+
-    "\1\36\7\35\1\37\1\35\50\0\2\4\4\0\26\4"+
-    "\16\0\1\40\43\0\2\4\4\0\1\4\1\41\24\4"+
-    "\13\0\2\4\4\0\2\4\1\42\1\4\1\43\21\4"+
-    "\13\0\2\4\4\0\11\4\1\44\14\4\13\0\2\4"+
-    "\4\0\5\4\1\45\2\4\1\46\15\4\13\0\2\4"+
-    "\4\0\5\4\1\47\20\4\13\0\2\4\4\0\12\4"+
-    "\1\50\13\4\13\0\2\4\4\0\3\4\1\51\22\4"+
-    "\13\0\2\4\4\0\5\4\1\52\3\4\1\53\14\4"+
-    "\13\0\2\4\4\0\4\4\1\54\10\4\1\55\10\4"+
-    "\13\0\2\4\4\0\5\4\1\56\20\4\13\0\2\4"+
-    "\4\0\17\4\1\57\6\4\13\0\2\4\4\0\11\4"+
-    "\1\60\14\4\13\0\2\4\4\0\1\61\25\4\12\0"+
-    "\3\35\2\0\30\35\1\0\7\35\1\0\1\35\10\0"+
-    "\1\62\1\63\3\0\1\64\17\0\1\65\16\0\1\6"+
-    "\42\0\2\4\4\0\2\4\1\66\23\4\13\0\2\4"+
-    "\4\0\6\4\1\67\17\4\13\0\2\4\4\0\5\4"+
-    "\1\70\20\4\13\0\2\4\4\0\24\4\1\71\1\4"+
-    "\13\0\2\4\4\0\5\4\1\72\20\4\13\0\2\4"+
-    "\4\0\2\4\1\73\23\4\13\0\2\4\4\0\1\4"+
-    "\1\74\24\4\13\0\2\4\4\0\5\4\1\75\20\4"+
-    "\13\0\2\4\4\0\17\4\1\76\6\4\13\0\2\4"+
-    "\4\0\3\4\1\77\22\4\13\0\2\4\4\0\15\4"+
-    "\1\100\10\4\13\0\2\4\4\0\22\4\1\101\3\4"+
-    "\13\0\2\4\4\0\1\102\25\4\13\0\2\4\4\0"+
-    "\7\4\1\103\16\4\13\0\2\4\4\0\2\4\1\104"+
-    "\23\4\13\0\2\4\4\0\2\4\1\105\23\4\13\0"+
-    "\2\4\4\0\11\4\1\106\14\4\13\0\2\4\4\0"+
-    "\1\107\25\4\13\0\2\4\4\0\6\4\1\110\17\4"+
-    "\13\0\2\4\4\0\17\4\1\111\6\4\13\0\2\4"+
-    "\4\0\12\4\1\112\13\4\13\0\2\4\4\0\11\4"+
-    "\1\113\14\4\13\0\2\4\4\0\13\4\1\114\12\4"+
-    "\13\0\2\4\4\0\15\4\1\115\10\4\13\0\2\4"+
-    "\4\0\7\4\1\116\16\4\13\0\2\4\4\0\20\4"+
-    "\1\117\5\4\13\0\2\4\4\0\6\4\1\120\17\4"+
-    "\13\0\2\4\4\0\15\4\1\121\10\4\13\0\2\4"+
-    "\4\0\16\4\1\122\7\4\13\0\2\4\4\0\12\4"+
-    "\1\123\13\4\13\0\2\4\4\0\4\4\1\124\21\4"+
-    "\13\0\2\4\4\0\4\4\1\125\21\4\13\0\2\4"+
-    "\4\0\6\4\1\126\17\4\13\0\2\4\4\0\1\4"+
-    "\1\127\24\4\13\0\2\4\4\0\2\4\1\130\23\4"+
-    "\13\0\2\4\4\0\1\131\25\4\13\0\2\4\4\0"+
-    "\11\4\1\132\14\4\13\0\2\4\4\0\2\4\1\133"+
-    "\23\4\13\0\2\4\4\0\12\4\1\134\13\4\13\0"+
-    "\2\4\4\0\6\4\1\135\17\4\13\0\2\4\4\0"+
-    "\7\4\1\136\16\4\13\0\2\4\4\0\1\137\25\4"+
-    "\13\0\2\4\4\0\5\4\1\140\20\4\13\0\2\4"+
-    "\4\0\14\4\1\141\11\4\13\0\2\4\4\0\13\4"+
-    "\1\142\12\4\13\0\2\4\4\0\6\4\1\143\17\4"+
-    "\13\0\2\4\4\0\15\4\1\144\10\4\13\0\2\4"+
-    "\4\0\11\4\1\145\14\4\13\0\2\4\4\0\1\146"+
-    "\25\4\13\0\2\4\4\0\1\147\25\4\13\0\2\4"+
-    "\4\0\20\4\1\150\5\4\13\0\2\4\4\0\16\4"+
-    "\1\151\7\4\13\0\2\4\4\0\15\4\1\152\10\4"+
-    "\13\0\2\4\4\0\11\4\1\153\14\4\13\0\2\4"+
-    "\4\0\1\4\1\154\24\4\13\0\2\4\4\0\22\4"+
-    "\1\155\3\4\13\0\2\4\4\0\12\4\1\156\13\4"+
-    "\13\0\2\4\4\0\20\4\1\157\5\4\13\0\2\4"+
-    "\4\0\3\4\1\160\22\4\13\0\2\4\4\0\2\4"+
-    "\1\161\23\4\13\0\2\4\4\0\1\162\25\4\13\0"+
-    "\2\4\4\0\11\4\1\163\14\4\13\0\2\4\4\0"+
-    "\1\164\25\4\13\0\2\4\4\0\2\4\1\165\23\4"+
-    "\13\0\2\4\4\0\5\4\1\166\20\4\13\0\2\4"+
-    "\4\0\10\4\1\167\15\4\13\0\2\4\4\0\1\4"+
-    "\1\170\24\4\12\0";
-
-  private static int [] zzUnpackTrans() {
-    int [] result = new int[3432];
-    int offset = 0;
-    offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
-    return result;
-  }
-
-  private static int zzUnpackTrans(String packed, int offset, int [] result) {
-    int i = 0;       /* index in packed string  */
-    int j = offset;  /* index in unpacked array */
-    int l = packed.length();
-    while (i < l) {
-      int count = packed.charAt(i++);
-      int value = packed.charAt(i++);
-      value--;
-      do result[j++] = value; while (--count > 0);
-    }
-    return j;
-  }
-
-
-  /* error codes */
-  private static final int ZZ_UNKNOWN_ERROR = 0;
-  private static final int ZZ_NO_MATCH = 1;
-  private static final int ZZ_PUSHBACK_2BIG = 2;
-
-  /* error messages for the codes above */
-  private static final String ZZ_ERROR_MSG[] = {
-    "Unknown internal scanner error",
-    "Error: could not match input",
-    "Error: pushback value was too large"
-  };
-
-  /**
-   * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
-   */
-  private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
-
-  private static final String ZZ_ATTRIBUTE_PACKED_0 =
-    "\2\0\1\11\2\1\2\11\15\1\10\11\1\1\1\11"+
-    "\1\1\1\0\21\1\4\11\103\1";
-
-  private static int [] zzUnpackAttribute() {
-    int [] result = new int[120];
-    int offset = 0;
-    offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
-    return result;
-  }
-
-  private static int zzUnpackAttribute(String packed, int offset, int [] result) {
-    int i = 0;       /* index in packed string  */
-    int j = offset;  /* index in unpacked array */
-    int l = packed.length();
-    while (i < l) {
-      int count = packed.charAt(i++);
-      int value = packed.charAt(i++);
-      do result[j++] = value; while (--count > 0);
-    }
-    return j;
-  }
-
-  /** the input device */
-  private java.io.Reader zzReader;
-
-  /** the current state of the DFA */
-  private int zzState;
-
-  /** the current lexical state */
-  private int zzLexicalState = YYINITIAL;
-
-  /** this buffer contains the current text to be matched and is
-      the source of the yytext() string */
-  private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
-
-  /** the textposition at the last accepting state */
-  private int zzMarkedPos;
-
-  /** the current text position in the buffer */
-  private int zzCurrentPos;
-
-  /** startRead marks the beginning of the yytext() string in the buffer */
-  private int zzStartRead;
-
-  /** endRead marks the last character in the buffer, that has been read
-      from input */
-  private int zzEndRead;
-
-  /** number of newlines encountered up to the start of the matched text */
-  private int yyline;
-
-  /** the number of characters up to the start of the matched text */
-  private int yychar;
-
-  /**
-   * the number of characters from the last newline up to the start of the 
-   * matched text
-   */
-  private int yycolumn;
-
-  /** 
-   * zzAtBOL == true <=> the scanner is currently at the beginning of a line
-   */
-  private boolean zzAtBOL = true;
-
-  /** zzAtEOF == true <=> the scanner is at the EOF */
-  private boolean zzAtEOF;
-
-  /** denotes if the user-EOF-code has already been executed */
-  private boolean zzEOFDone;
-  
-  /** 
-   * The number of occupied positions in zzBuffer beyond zzEndRead.
-   * When a lead/high surrogate has been read from the input stream
-   * into the final zzBuffer position, this will have a value of 1;
-   * otherwise, it will have a value of 0.
-   */
-  private int zzFinalHighSurrogate = 0;
-
-  /* user code: */
-    StringBuffer string = new StringBuffer();
-    public Lexer(java.io.Reader in, ComplexSymbolFactory sf){
-       this(in);
-       symbolFactory = sf;
-    }
-    ComplexSymbolFactory symbolFactory;
-
-  private Symbol symbol(String name, int sym) {
-      return symbolFactory.newSymbol(name, sym, new Location(yyline+1,yycolumn+1,yychar), new Location(yyline+1,yycolumn+yylength(),yychar+yylength()));
-  }
-  
-  private Symbol symbol(String name, int sym, Object val) {
-      Location left = new Location(yyline+1,yycolumn+1,yychar);
-      Location right= new Location(yyline+1,yycolumn+yylength(), yychar+yylength());
-      return symbolFactory.newSymbol(name, sym, left, right,val);
-  } 
-  private Symbol symbol(String name, int sym, Object val,int buflength) {
-      Location left = new Location(yyline+1,yycolumn+yylength()-buflength,yychar+yylength()-buflength);
-      Location right= new Location(yyline+1,yycolumn+yylength(), yychar+yylength());
-      return symbolFactory.newSymbol(name, sym, left, right,val);
-  }       
-  private void error(String message) {
-    System.out.println("Error at line "+(yyline+1)+", column "+(yycolumn+1)+" : "+message);
-  }
-
-
-  /**
-   * Creates a new scanner
-   *
-   * @param   in  the java.io.Reader to read input from.
-   */
-  public Lexer(java.io.Reader in) {
-    this.zzReader = in;
-  }
-
-
-  /** 
-   * Unpacks the compressed character translation table.
-   *
-   * @param packed   the packed character translation table
-   * @return         the unpacked character translation table
-   */
-  private static char [] zzUnpackCMap(String packed) {
-    char [] map = new char[0x110000];
-    int i = 0;  /* index in packed string  */
-    int j = 0;  /* index in unpacked array */
-    while (i < 164) {
-      int  count = packed.charAt(i++);
-      char value = packed.charAt(i++);
-      do map[j++] = value; while (--count > 0);
-    }
-    return map;
-  }
-
-
-  /**
-   * Refills the input buffer.
-   *
-   * @return      <code>false</code>, iff there was new input.
-   * 
-   * @exception   java.io.IOException  if any I/O-Error occurs
-   */
-  private boolean zzRefill() throws java.io.IOException {
-
-    /* first: make room (if you can) */
-    if (zzStartRead > 0) {
-      zzEndRead += zzFinalHighSurrogate;
-      zzFinalHighSurrogate = 0;
-      System.arraycopy(zzBuffer, zzStartRead,
-                       zzBuffer, 0,
-                       zzEndRead-zzStartRead);
-
-      /* translate stored positions */
-      zzEndRead-= zzStartRead;
-      zzCurrentPos-= zzStartRead;
-      zzMarkedPos-= zzStartRead;
-      zzStartRead = 0;
-    }
-
-    /* is the buffer big enough? */
-    if (zzCurrentPos >= zzBuffer.length - zzFinalHighSurrogate) {
-      /* if not: blow it up */
-      char newBuffer[] = new char[zzBuffer.length*2];
-      System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
-      zzBuffer = newBuffer;
-      zzEndRead += zzFinalHighSurrogate;
-      zzFinalHighSurrogate = 0;
-    }
-
-    /* fill the buffer with new input */
-    int requested = zzBuffer.length - zzEndRead;
-    int numRead = zzReader.read(zzBuffer, zzEndRead, requested);
-
-    /* not supposed to occur according to specification of java.io.Reader */
-    if (numRead == 0) {
-      throw new java.io.IOException("Reader returned 0 characters. See JFlex examples for workaround.");
-    }
-    if (numRead > 0) {
-      zzEndRead += numRead;
-      /* If numRead == requested, we might have requested to few chars to
-         encode a full Unicode character. We assume that a Reader would
-         otherwise never return half characters. */
-      if (numRead == requested) {
-        if (Character.isHighSurrogate(zzBuffer[zzEndRead - 1])) {
-          --zzEndRead;
-          zzFinalHighSurrogate = 1;
-        }
-      }
-      /* potentially more input available */
-      return false;
-    }
-
-    /* numRead < 0 ==> end of stream */
-    return true;
-  }
-
-    
-  /**
-   * Closes the input stream.
-   */
-  public final void yyclose() throws java.io.IOException {
-    zzAtEOF = true;            /* indicate end of file */
-    zzEndRead = zzStartRead;  /* invalidate buffer    */
-
-    if (zzReader != null)
-      zzReader.close();
-  }
-
-
-  /**
-   * Resets the scanner to read from a new input stream.
-   * Does not close the old reader.
-   *
-   * All internal variables are reset, the old input stream 
-   * <b>cannot</b> be reused (internal buffer is discarded and lost).
-   * Lexical state is set to <tt>ZZ_INITIAL</tt>.
-   *
-   * Internal scan buffer is resized down to its initial length, if it has grown.
-   *
-   * @param reader   the new input stream 
-   */
-  public final void yyreset(java.io.Reader reader) {
-    zzReader = reader;
-    zzAtBOL  = true;
-    zzAtEOF  = false;
-    zzEOFDone = false;
-    zzEndRead = zzStartRead = 0;
-    zzCurrentPos = zzMarkedPos = 0;
-    zzFinalHighSurrogate = 0;
-    yyline = yychar = yycolumn = 0;
-    zzLexicalState = YYINITIAL;
-    if (zzBuffer.length > ZZ_BUFFERSIZE)
-      zzBuffer = new char[ZZ_BUFFERSIZE];
-  }
-
-
-  /**
-   * Returns the current lexical state.
-   */
-  public final int yystate() {
-    return zzLexicalState;
-  }
-
-
-  /**
-   * Enters a new lexical state
-   *
-   * @param newState the new lexical state
-   */
-  public final void yybegin(int newState) {
-    zzLexicalState = newState;
-  }
-
-
-  /**
-   * Returns the text matched by the current regular expression.
-   */
-  public final String yytext() {
-    return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
-  }
-
-
-  /**
-   * Returns the character at position <tt>pos</tt> from the 
-   * matched text. 
-   * 
-   * It is equivalent to yytext().charAt(pos), but faster
-   *
-   * @param pos the position of the character to fetch. 
-   *            A value from 0 to yylength()-1.
-   *
-   * @return the character at position pos
-   */
-  public final char yycharat(int pos) {
-    return zzBuffer[zzStartRead+pos];
-  }
-
-
-  /**
-   * Returns the length of the matched text region.
-   */
-  public final int yylength() {
-    return zzMarkedPos-zzStartRead;
-  }
-
-
-  /**
-   * Reports an error that occured while scanning.
-   *
-   * In a wellformed scanner (no or only correct usage of 
-   * yypushback(int) and a match-all fallback rule) this method 
-   * will only be called with things that "Can't Possibly Happen".
-   * If this method is called, something is seriously wrong
-   * (e.g. a JFlex bug producing a faulty scanner etc.).
-   *
-   * Usual syntax/scanner level error handling should be done
-   * in error fallback rules.
-   *
-   * @param   errorCode  the code of the errormessage to display
-   */
-  private void zzScanError(int errorCode) {
-    String message;
-    try {
-      message = ZZ_ERROR_MSG[errorCode];
-    }
-    catch (ArrayIndexOutOfBoundsException e) {
-      message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
-    }
-
-    throw new Error(message);
-  } 
-
-
-  /**
-   * Pushes the specified amount of characters back into the input stream.
-   *
-   * They will be read again by then next call of the scanning method
-   *
-   * @param number  the number of characters to be read again.
-   *                This number must not be greater than yylength()!
-   */
-  public void yypushback(int number)  {
-    if ( number > yylength() )
-      zzScanError(ZZ_PUSHBACK_2BIG);
-
-    zzMarkedPos -= number;
-  }
-
-
-  /**
-   * Contains user EOF-code, which will be executed exactly once,
-   * when the end of file is reached
-   */
-  private void zzDoEOF() throws java.io.IOException {
-    if (!zzEOFDone) {
-      zzEOFDone = true;
-      yyclose();
-    }
-  }
-
-
-  /**
-   * Resumes scanning until the next regular expression is matched,
-   * the end of input is encountered or an I/O-Error occurs.
-   *
-   * @return      the next token
-   * @exception   java.io.IOException  if any I/O-Error occurs
-   */
-  public java_cup.runtime.Symbol next_token() throws java.io.IOException {
-    int zzInput;
-    int zzAction;
-
-    // cached fields:
-    int zzCurrentPosL;
-    int zzMarkedPosL;
-    int zzEndReadL = zzEndRead;
-    char [] zzBufferL = zzBuffer;
-    char [] zzCMapL = ZZ_CMAP;
-
-    int [] zzTransL = ZZ_TRANS;
-    int [] zzRowMapL = ZZ_ROWMAP;
-    int [] zzAttrL = ZZ_ATTRIBUTE;
-
-    while (true) {
-      zzMarkedPosL = zzMarkedPos;
-
-      yychar+= zzMarkedPosL-zzStartRead;
-
-      boolean zzR = false;
-      int zzCh;
-      int zzCharCount;
-      for (zzCurrentPosL = zzStartRead  ;
-           zzCurrentPosL < zzMarkedPosL ;
-           zzCurrentPosL += zzCharCount ) {
-        zzCh = Character.codePointAt(zzBufferL, zzCurrentPosL, zzMarkedPosL);
-        zzCharCount = Character.charCount(zzCh);
-        switch (zzCh) {
-        case '\u000B':
-        case '\u000C':
-        case '\u0085':
-        case '\u2028':
-        case '\u2029':
-          yyline++;
-          yycolumn = 0;
-          zzR = false;
-          break;
-        case '\r':
-          yyline++;
-          yycolumn = 0;
-          zzR = true;
-          break;
-        case '\n':
-          if (zzR)
-            zzR = false;
-          else {
-            yyline++;
-            yycolumn = 0;
-          }
-          break;
-        default:
-          zzR = false;
-          yycolumn += zzCharCount;
-        }
-      }
-
-      if (zzR) {
-        // peek one character ahead if it is \n (if we have counted one line too much)
-        boolean zzPeek;
-        if (zzMarkedPosL < zzEndReadL)
-          zzPeek = zzBufferL[zzMarkedPosL] == '\n';
-        else if (zzAtEOF)
-          zzPeek = false;
-        else {
-          boolean eof = zzRefill();
-          zzEndReadL = zzEndRead;
-          zzMarkedPosL = zzMarkedPos;
-          zzBufferL = zzBuffer;
-          if (eof) 
-            zzPeek = false;
-          else 
-            zzPeek = zzBufferL[zzMarkedPosL] == '\n';
-        }
-        if (zzPeek) yyline--;
-      }
-      zzAction = -1;
-
-      zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
-  
-      zzState = ZZ_LEXSTATE[zzLexicalState];
-
-      // set up zzAction for empty match case:
-      int zzAttributes = zzAttrL[zzState];
-      if ( (zzAttributes & 1) == 1 ) {
-        zzAction = zzState;
-      }
-
-
-      zzForAction: {
-        while (true) {
-    
-          if (zzCurrentPosL < zzEndReadL) {
-            zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
-            zzCurrentPosL += Character.charCount(zzInput);
-          }
-          else if (zzAtEOF) {
-            zzInput = YYEOF;
-            break zzForAction;
-          }
-          else {
-            // store back cached positions
-            zzCurrentPos  = zzCurrentPosL;
-            zzMarkedPos   = zzMarkedPosL;
-            boolean eof = zzRefill();
-            // get translated positions and possibly new buffer
-            zzCurrentPosL  = zzCurrentPos;
-            zzMarkedPosL   = zzMarkedPos;
-            zzBufferL      = zzBuffer;
-            zzEndReadL     = zzEndRead;
-            if (eof) {
-              zzInput = YYEOF;
-              break zzForAction;
-            }
-            else {
-              zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
-              zzCurrentPosL += Character.charCount(zzInput);
-            }
-          }
-          int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
-          if (zzNext == -1) break zzForAction;
-          zzState = zzNext;
-
-          zzAttributes = zzAttrL[zzState];
-          if ( (zzAttributes & 1) == 1 ) {
-            zzAction = zzState;
-            zzMarkedPosL = zzCurrentPosL;
-            if ( (zzAttributes & 8) == 8 ) break zzForAction;
-          }
-
-        }
-      }
-
-      // store back cached position
-      zzMarkedPos = zzMarkedPosL;
-
-      if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
-        zzAtEOF = true;
-            zzDoEOF();
-          {      return symbolFactory.newSymbol("EOF", EOF, new Location(yyline+1,yycolumn+1,yychar), new Location(yyline+1,yycolumn+1,yychar+1));
- }
-      }
-      else {
-        switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
-          case 1: 
-            { /* throw new Error("Illegal character <"+ yytext()+">");*/
-                   error("Illegal character <"+ yytext()+">");
-            }
-          case 38: break;
-          case 2: 
-            { return symbol("Identifier",IDENT, yytext());
-            }
-          case 39: break;
-          case 3: 
-            { /* ignore */
-            }
-          case 40: break;
-          case 4: 
-            { return symbol("semicolon",SEMICOLON);
-            }
-          case 41: break;
-          case 5: 
-            { string.setLength(0); yybegin(STRING);
-            }
-          case 42: break;
-          case 6: 
-            { return symbol("comma",COMMA);
-            }
-          case 43: break;
-          case 7: 
-            { return symbol("dot",DOT);
-            }
-          case 44: break;
-          case 8: 
-            { return symbol("(",LPAR);
-            }
-          case 45: break;
-          case 9: 
-            { return symbol(")",RPAR);
-            }
-          case 46: break;
-          case 10: 
-            { return symbol("{",BEGIN);
-            }
-          case 47: break;
-          case 11: 
-            { return symbol("}",END);
-            }
-          case 48: break;
-          case 12: 
-            { return symbol("=",ASSIGN);
-            }
-          case 49: break;
-          case 13: 
-            { string.append( yytext() );
-            }
-          case 50: break;
-          case 14: 
-            { yybegin(YYINITIAL); 
-      return symbol("StringConst",STRINGCONST,string.toString(),string.length());
-            }
-          case 51: break;
-          case 15: 
-            { string.append('\\');
-            }
-          case 52: break;
-          case 16: 
-            { return symbol("as",AS);
-            }
-          case 53: break;
-          case 17: 
-            { string.append('\n');
-            }
-          case 54: break;
-          case 18: 
-            { string.append('\t');
-            }
-          case 55: break;
-          case 19: 
-            { string.append('\r');
-            }
-          case 56: break;
-          case 20: 
-            { string.append('\"');
-            }
-          case 57: break;
-          case 21: 
-            { return symbol("int",TYPE, "INT" );
-            }
-          case 58: break;
-          case 22: 
-            { return symbol("byte",TYPE, "BYTE" );
-            }
-          case 59: break;
-          case 23: 
-            { return symbol("long",TYPE, "LONG" );
-            }
-          case 60: break;
-          case 24: 
-            { return symbol("char",TYPE, "CHAR" );
-            }
-          case 61: break;
-          case 25: 
-            { return symbol("void",TYPE, "VOID" );
-            }
-          case 62: break;
-          case 26: 
-            { return symbol("with",WITH);
-            }
-          case 63: break;
-          case 27: 
-            { return symbol("short",TYPE, "SHORT" );
-            }
-          case 64: break;
-          case 28: 
-            { return symbol("float",TYPE, "FLOAT" );
-            }
-          case 65: break;
-          case 29: 
-            { return symbol("string",TYPE, "STRING" );
-            }
-          case 66: break;
-          case 30: 
-            { return symbol("double",TYPE, "DOUBLE" );
-            }
-          case 67: break;
-          case 31: 
-            { return symbol("public",PUBLIC);
-            }
-          case 68: break;
-          case 32: 
-            { return symbol("method",METHOD);
-            }
-          case 69: break;
-          case 33: 
-            { return symbol("boolean",TYPE, "BOOL" );
-            }
-          case 70: break;
-          case 34: 
-            { return symbol("requires",REQUIRES);
-            }
-          case 71: break;
-          case 35: 
-            { return symbol("interface",INTERFACE);
-            }
-          case 72: break;
-          case 36: 
-            { return symbol("capability",CAPABILITY);
-            }
-          case 73: break;
-          case 37: 
-            { return symbol("description",DESCRIPTION);
-            }
-          case 74: break;
-          default:
-            zzScanError(ZZ_NO_MATCH);
-        }
-      }
-    }
-  }
-
-
-}
diff --git a/iotjava/iotparser/Parser.java b/iotjava/iotparser/Parser.java
deleted file mode 100644 (file)
index 99b2ae1..0000000
+++ /dev/null
@@ -1,690 +0,0 @@
-package iotparser;
-
-//----------------------------------------------------
-// The following code was generated by CUP v0.11b 20160615 (GIT 4ac7450)
-//----------------------------------------------------
-
-import java_cup.runtime.ComplexSymbolFactory;
-import java_cup.runtime.ScannerBuffer;
-import java_cup.runtime.XMLElement;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-import java.io.*;
-import javax.xml.transform.*;
-import javax.xml.transform.stream.*;
-import java_cup.runtime.ComplexSymbolFactory.Location;
-import java_cup.runtime.XMLElement;
-
-/** CUP v0.11b 20160615 (GIT 4ac7450) generated parser.
-  */
-@SuppressWarnings({"rawtypes"})
-public class Parser extends java_cup.runtime.lr_parser {
-
- public final Class getSymbolContainer() {
-    return sym.class;
-}
-
-  /** Default constructor. */
-  @Deprecated
-  public Parser() {super();}
-
-  /** Constructor which sets the default scanner. */
-  @Deprecated
-  public Parser(java_cup.runtime.Scanner s) {super(s);}
-
-  /** Constructor which sets the default scanner. */
-  public Parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);}
-
-  /** Production table. */
-  protected static final short _production_table[][] = 
-    unpackFromStrings(new String[] {
-    "\000\032\000\002\002\005\000\002\002\004\000\002\003" +
-    "\010\000\002\003\002\000\002\004\004\000\002\004\002" +
-    "\000\002\005\011\000\002\006\004\000\002\006\002\000" +
-    "\002\007\005\000\002\007\004\000\002\007\005\000\002" +
-    "\007\004\000\002\010\004\000\002\010\002\000\002\011" +
-    "\011\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" });
-
-  /** Access to production table. */
-  public short[][] production_table() {return _production_table;}
-
-  /** Parse-action table. */
-  protected static final short[][] _action_table = 
-    unpackFromStrings(new String[] {
-    "\000\070\000\012\002\ufffe\014\005\016\ufffe\021\ufffe\001" +
-    "\002\000\010\002\ufff3\016\ufff3\021\ufff3\001\002\000\004" +
-    "\015\010\001\002\000\004\002\007\001\002\000\004\002" +
-    "\000\001\002\000\004\025\011\001\002\000\004\011\012" +
-    "\001\002\000\006\012\ufffc\014\ufffc\001\002\000\006\012" +
-    "\016\014\015\001\002\000\006\012\ufffd\014\ufffd\001\002" +
-    "\000\004\024\017\001\002\000\010\002\uffff\016\uffff\021" +
-    "\uffff\001\002\000\004\025\020\001\002\000\004\007\021" +
-    "\001\002\000\010\010\ufff9\024\ufff9\025\ufff9\001\002\000" +
-    "\010\010\025\024\026\025\023\001\002\000\004\025\032" +
-    "\001\002\000\010\010\ufffa\024\ufffa\025\ufffa\001\002\000" +
-    "\004\004\031\001\002\000\004\025\027\001\002\000\012" +
-    "\005\030\010\ufff7\024\ufff7\025\ufff7\001\002\000\010\010" +
-    "\ufff8\024\ufff8\025\ufff8\001\002\000\006\012\ufffb\014\ufffb" +
-    "\001\002\000\012\005\033\010\ufff5\024\ufff5\025\ufff5\001" +
-    "\002\000\010\010\ufff6\024\ufff6\025\ufff6\001\002\000\010" +
-    "\002\uffec\016\037\021\uffec\001\002\000\010\002\ufff4\016" +
-    "\ufff4\021\ufff4\001\002\000\006\002\001\021\057\001\002" +
-    "\000\004\025\040\001\002\000\004\006\041\001\002\000" +
-    "\004\025\042\001\002\000\004\011\043\001\002\000\010" +
-    "\012\ufff0\017\ufff0\020\ufff0\001\002\000\010\012\047\017" +
-    "\046\020\050\001\002\000\010\012\ufff1\017\ufff1\020\ufff1" +
-    "\001\002\000\004\013\054\001\002\000\010\002\ufff2\016" +
-    "\ufff2\021\ufff2\001\002\000\004\013\051\001\002\000\004" +
-    "\025\052\001\002\000\004\004\053\001\002\000\010\012" +
-    "\uffee\017\uffee\020\uffee\001\002\000\004\026\055\001\002" +
-    "\000\004\004\056\001\002\000\010\012\uffef\017\uffef\020" +
-    "\uffef\001\002\000\004\025\061\001\002\000\006\002\uffed" +
-    "\021\uffed\001\002\000\004\022\062\001\002\000\010\005" +
-    "\uffe8\023\uffe8\025\063\001\002\000\006\005\uffea\023\uffea" +
-    "\001\002\000\006\005\065\023\066\001\002\000\004\025" +
-    "\072\001\002\000\004\015\067\001\002\000\004\025\070" +
-    "\001\002\000\004\004\071\001\002\000\006\002\uffeb\021" +
-    "\uffeb\001\002\000\006\005\uffe9\023\uffe9\001\002" });
-
-  /** Access to parse-action table. */
-  public short[][] action_table() {return _action_table;}
-
-  /** <code>reduce_goto</code> table. */
-  protected static final short[][] _reduce_table = 
-    unpackFromStrings(new String[] {
-    "\000\070\000\006\002\005\003\003\001\001\000\004\010" +
-    "\033\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" +
-    "\012\001\001\000\004\005\013\001\001\000\002\001\001" +
-    "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
-    "\002\001\001\000\004\006\021\001\001\000\004\007\023" +
-    "\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" +
-    "\006\011\034\014\035\001\001\000\002\001\001\000\004" +
-    "\015\057\001\001\000\002\001\001\000\002\001\001\000" +
-    "\002\001\001\000\002\001\001\000\004\012\043\001\001" +
-    "\000\004\013\044\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\002" +
-    "\001\001\000\002\001\001\000\004\016\063\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" });
-
-  /** Access to <code>reduce_goto</code> table. */
-  public short[][] reduce_table() {return _reduce_table;}
-
-  /** Instance of action encapsulation class. */
-  protected CUP$Parser$actions action_obj;
-
-  /** Action encapsulation object initializer. */
-  protected void init_actions()
-    {
-      action_obj = new CUP$Parser$actions(this);
-    }
-
-  /** Invoke a user supplied parse action. */
-  public java_cup.runtime.Symbol do_action(
-    int                        act_num,
-    java_cup.runtime.lr_parser parser,
-    java.util.Stack            stack,
-    int                        top)
-    throws java.lang.Exception
-  {
-    /* call code in generated class */
-    return action_obj.CUP$Parser$do_action(act_num, parser, stack, top);
-  }
-
-  /** Indicates start state. */
-  public int start_state() {return 0;}
-  /** Indicates start production. */
-  public int start_production() {return 1;}
-
-  /** <code>EOF</code> Symbol index. */
-  public int EOF_sym() {return 0;}
-
-  /** <code>error</code> Symbol index. */
-  public int error_sym() {return 1;}
-
-
-
-  public Parser(Lexer lex, ComplexSymbolFactory sf) {
-    super(lex,sf);
-  }
-  public static void main(String[] args) throws Exception {
-      // initialize the symbol factory
-      ComplexSymbolFactory csf = new ComplexSymbolFactory();
-      // create a buffering scanner wrapper
-      ScannerBuffer lexer = new ScannerBuffer(new Lexer(new BufferedReader(new FileReader(args[0])),csf));
-      // start parsing
-      Parser p = new Parser(lexer,csf);
-      XMLElement e = (XMLElement)p.parse().value;
-      // create XML output file 
-      XMLOutputFactory outFactory = XMLOutputFactory.newInstance();
-      XMLStreamWriter sw = outFactory.createXMLStreamWriter(new FileOutputStream(args[1]), "UTF-8");
-      // dump XML output to the file
-      XMLElement.dump(lexer,sw,e,"expr","stmt");
-
-       // transform the parse tree into an AST and a rendered HTML version
-      Transformer transformer = TransformerFactory.newInstance()
-           .newTransformer(new StreamSource(new File("tree.xsl")));
-      Source text = new StreamSource(new File(args[1]));
-      transformer.transform(text, new StreamResult(new File("output.xml")));
-      transformer = TransformerFactory.newInstance()
-           .newTransformer(new StreamSource(new File("tree-view.xsl")));
-      text = new StreamSource(new File("output.xml"));
-      transformer.transform(text, new StreamResult(new File("ast.html")));
-  }
-
-
-/** Cup generated class to encapsulate user supplied action code.*/
-@SuppressWarnings({"rawtypes", "unchecked", "unused"})
-class CUP$Parser$actions {
-  private final Parser parser;
-
-  /** Constructor */
-  CUP$Parser$actions(Parser parser) {
-    this.parser = parser;
-  }
-
-  /** Method 0 with the actual generated action code for actions 0 to 300. */
-  public final java_cup.runtime.Symbol CUP$Parser$do_action_part00000000(
-    int                        CUP$Parser$act_num,
-    java_cup.runtime.lr_parser CUP$Parser$parser,
-    java.util.Stack            CUP$Parser$stack,
-    int                        CUP$Parser$top)
-    throws java.lang.Exception
-    {
-      /* Symbol object for return from actions */
-      java_cup.runtime.Symbol CUP$Parser$result;
-
-      /* select the action based on the action number */
-      switch (CUP$Parser$act_num)
-        {
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 0: // policy ::= intface capablist reqlist 
-            {
-                XMLElement RESULT;
-               Location inxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xleft;
-               Location inxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xright;
-               Object in = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
-               Location capxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location capxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object cap = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location rlxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location rlxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object rl = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("policy",0,(XMLElement)in,(XMLElement)cap,(XMLElement)rl);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("policy",0, ((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;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 1: // $START ::= policy EOF 
-            {
-                XMLElement RESULT;
-               Location start_valxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location start_valxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object start_val = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location EOF1xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location EOF1xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object EOF1 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("_START",0,(XMLElement)start_val);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
-            }
-          /* ACCEPT */
-          CUP$Parser$parser.done_parsing();
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 2: // intface ::= PUBLIC INTERFACE IDENT BEGIN methlist END 
-            {
-                XMLElement RESULT;
-               Location PUBLIC0xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).xleft;
-               Location PUBLIC0xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).xright;
-               Object PUBLIC0 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-5)).value;
-               Location INTERFACE1xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).xleft;
-               Location INTERFACE1xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).xright;
-               Object INTERFACE1 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-4)).value;
-               Location idintxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xleft;
-               Location idintxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xright;
-               Object idint = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-3)).value;
-               Location BEGIN3xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xleft;
-               Location BEGIN3xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xright;
-               Object BEGIN3 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
-               Location mlxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location mlxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object ml = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location END5xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location END5xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object END5 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("intface",0,new XMLElement.Terminal(idintxleft,"idint",idint,idintxright),(XMLElement)ml);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("intface",1, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 3: // intface ::= 
-            {
-                XMLElement RESULT;
-
-                RESULT = new XMLElement.NonTerminal("intface",1);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("intface",1, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 4: // methlist ::= methlist meth 
-            {
-                XMLElement RESULT;
-               Location mlxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location mlxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object ml = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location mxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location mxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object m = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("methlist",0,(XMLElement)ml,(XMLElement)m);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("methlist",2, ((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;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 5: // methlist ::= 
-            {
-                XMLElement RESULT;
-
-                RESULT = new XMLElement.NonTerminal("methlist",1);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("methlist",2, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 6: // meth ::= PUBLIC TYPE IDENT LPAR paramlist RPAR SEMICOLON 
-            {
-                XMLElement RESULT;
-               Location PUBLIC0xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).xleft;
-               Location PUBLIC0xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).xright;
-               Object PUBLIC0 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-6)).value;
-               Location typemethxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).xleft;
-               Location typemethxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).xright;
-               Object typemeth = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-5)).value;
-               Location idmethxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).xleft;
-               Location idmethxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).xright;
-               Object idmeth = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-4)).value;
-               Location LPAR3xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xleft;
-               Location LPAR3xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xright;
-               Object LPAR3 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-3)).value;
-               Location plxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xleft;
-               Location plxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xright;
-               Object pl = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
-               Location RPAR5xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location RPAR5xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object RPAR5 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location SEMICOLON6xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location SEMICOLON6xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object SEMICOLON6 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("meth",0,new XMLElement.Terminal(typemethxleft,"typemeth",typemeth,typemethxright),new XMLElement.Terminal(idmethxleft,"idmeth",idmeth,idmethxright),(XMLElement)pl);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("meth",3, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 7: // paramlist ::= paramlist param 
-            {
-                XMLElement RESULT;
-               Location plxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location plxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object pl = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location pxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location pxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object p = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("paramlist",0,(XMLElement)pl,(XMLElement)p);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("paramlist",4, ((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;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 8: // paramlist ::= 
-            {
-                XMLElement RESULT;
-
-                RESULT = new XMLElement.NonTerminal("paramlist",1);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("paramlist",4, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 9: // param ::= TYPE IDENT COMMA 
-            {
-                XMLElement RESULT;
-               Location typeprmxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xleft;
-               Location typeprmxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xright;
-               Object typeprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
-               Location idprmxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location idprmxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object idprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location COMMA2xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location COMMA2xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object COMMA2 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("param",0,new XMLElement.Terminal(typeprmxleft,"typeprm",typeprm,typeprmxright),new XMLElement.Terminal(idprmxleft,"idprm",idprm,idprmxright));
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("param",5, ((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;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 10: // param ::= TYPE IDENT 
-            {
-                XMLElement RESULT;
-               Location typeprmxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location typeprmxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object typeprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location idprmxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location idprmxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object idprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("param",1,new XMLElement.Terminal(typeprmxleft,"typeprm",typeprm,typeprmxright),new XMLElement.Terminal(idprmxleft,"idprm",idprm,idprmxright));
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("param",5, ((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;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 11: // param ::= IDENT IDENT COMMA 
-            {
-                XMLElement RESULT;
-               Location clsprmxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xleft;
-               Location clsprmxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xright;
-               Object clsprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
-               Location idprmxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location idprmxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object idprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location COMMA2xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location COMMA2xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object COMMA2 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("param",2,new XMLElement.Terminal(clsprmxleft,"clsprm",clsprm,clsprmxright),new XMLElement.Terminal(idprmxleft,"idprm",idprm,idprmxright));
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("param",5, ((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;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 12: // param ::= IDENT IDENT 
-            {
-                XMLElement RESULT;
-               Location clsprmxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location clsprmxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object clsprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location idprmxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location idprmxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object idprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("param",3,new XMLElement.Terminal(clsprmxleft,"clsprm",clsprm,clsprmxright),new XMLElement.Terminal(idprmxleft,"idprm",idprm,idprmxright));
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("param",5, ((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;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 13: // capablist ::= capablist capab 
-            {
-                XMLElement RESULT;
-               Location clistxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location clistxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object clist = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location capxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location capxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object cap = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("capablist",0,(XMLElement)clist,(XMLElement)cap);
-              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);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 14: // capablist ::= 
-            {
-                XMLElement RESULT;
-
-                RESULT = new XMLElement.NonTerminal("capablist",1);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capablist",6, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 15: // capab ::= CAPABILITY IDENT DOT IDENT BEGIN capabcont END 
-            {
-                XMLElement RESULT;
-               Location CAPABILITY0xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).xleft;
-               Location CAPABILITY0xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).xright;
-               Object CAPABILITY0 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-6)).value;
-               Location idintxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).xleft;
-               Location idintxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).xright;
-               Object idint = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-5)).value;
-               Location DOT2xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).xleft;
-               Location DOT2xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).xright;
-               Object DOT2 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-4)).value;
-               Location idcapxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xleft;
-               Location idcapxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xright;
-               Object idcap = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-3)).value;
-               Location BEGIN4xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xleft;
-               Location BEGIN4xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xright;
-               Object BEGIN4 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
-               Location ccontxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location ccontxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object ccont = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location END6xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location END6xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object END6 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("capab",0,new XMLElement.Terminal(idintxleft,"idint",idint,idintxright),new XMLElement.Terminal(idcapxleft,"idcap",idcap,idcapxright),(XMLElement)ccont);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capab",7, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 16: // capabcont ::= capabcont cont 
-            {
-                XMLElement RESULT;
-               Location ccontxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location ccontxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object ccont = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location cntxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location cntxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object cnt = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("capabcont",0,(XMLElement)ccont,(XMLElement)cnt);
-              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);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 17: // capabcont ::= 
-            {
-                XMLElement RESULT;
-
-                RESULT = new XMLElement.NonTerminal("capabcont",1);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capabcont",8, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 18: // cont ::= DESCRIPTION ASSIGN STRINGCONST SEMICOLON 
-            {
-                XMLElement RESULT;
-               Location dscxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xleft;
-               Location dscxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xright;
-               Object dsc = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-3)).value;
-               Location ASSIGN1xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xleft;
-               Location ASSIGN1xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xright;
-               Object ASSIGN1 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
-               Location STRINGCONST2xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location STRINGCONST2xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object STRINGCONST2 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location SEMICOLON3xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location SEMICOLON3xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object SEMICOLON3 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("cont",0,new XMLElement.Terminal(dscxleft,"dsc",dsc,dscxright));
-              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);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 19: // cont ::= METHOD ASSIGN IDENT SEMICOLON 
-            {
-                XMLElement RESULT;
-               Location mtdxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xleft;
-               Location mtdxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xright;
-               Object mtd = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-3)).value;
-               Location ASSIGN1xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xleft;
-               Location ASSIGN1xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xright;
-               Object ASSIGN1 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
-               Location idmethxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location idmethxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object idmeth = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location SEMICOLON3xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location SEMICOLON3xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object SEMICOLON3 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("cont",1,new XMLElement.Terminal(mtdxleft,"mtd",mtd,mtdxright),new XMLElement.Terminal(idmethxleft,"idmeth",idmeth,idmethxright));
-              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);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 20: // reqlist ::= reqlist require 
-            {
-                XMLElement RESULT;
-               Location rlxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location rlxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object rl = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location reqxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location reqxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object req = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("reqlist",0,(XMLElement)rl,(XMLElement)req);
-              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);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 21: // reqlist ::= 
-            {
-                XMLElement RESULT;
-
-                RESULT = new XMLElement.NonTerminal("reqlist",1);
-              CUP$Parser$result = parser.getSymbolFactory().newSymbol("reqlist",10, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 22: // require ::= REQUIRES IDENT WITH capintlist AS INTERFACE IDENT SEMICOLON 
-            {
-                XMLElement RESULT;
-               Location REQUIRES0xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-7)).xleft;
-               Location REQUIRES0xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-7)).xright;
-               Object REQUIRES0 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-7)).value;
-               Location idintxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).xleft;
-               Location idintxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).xright;
-               Object idint = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-6)).value;
-               Location WITH2xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).xleft;
-               Location WITH2xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).xright;
-               Object WITH2 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-5)).value;
-               Location cilxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).xleft;
-               Location cilxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).xright;
-               Object cil = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-4)).value;
-               Location AS4xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xleft;
-               Location AS4xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).xright;
-               Object AS4 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-3)).value;
-               Location INTERFACE5xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xleft;
-               Location INTERFACE5xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xright;
-               Object INTERFACE5 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
-               Location idnewintxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location idnewintxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object idnewint = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location SEMICOLON7xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location SEMICOLON7xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object SEMICOLON7 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("require",0,new XMLElement.Terminal(idintxleft,"idint",idint,idintxright),(XMLElement)cil,new XMLElement.Terminal(idnewintxleft,"idnewint",idnewint,idnewintxright));
-              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);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 23: // capintlist ::= IDENT 
-            {
-                XMLElement RESULT;
-               Location idcapxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location idcapxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object idcap = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("capintlist",0,new XMLElement.Terminal(idcapxleft,"idcap",idcap,idcapxright));
-              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);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 24: // capintlist ::= capintlist COMMA IDENT 
-            {
-                XMLElement RESULT;
-               Location cilxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xleft;
-               Location cilxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).xright;
-               Object cil = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
-               Location COMMA1xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xleft;
-               Location COMMA1xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).xright;
-               Object COMMA1 = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
-               Location idcapxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xleft;
-               Location idcapxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Parser$stack.peek()).xright;
-               Object idcap = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
-
-                RESULT = new XMLElement.NonTerminal("capintlist",1,(XMLElement)cil,new XMLElement.Terminal(idcapxleft,"idcap",idcap,idcapxright));
-              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);
-            }
-          return CUP$Parser$result;
-
-          /*. . . . . . . . . . . . . . . . . . . .*/
-          case 25: // capintlist ::= 
-            {
-                XMLElement RESULT;
-
-                RESULT = new XMLElement.NonTerminal("capintlist",2);
-              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);
-            }
-          return CUP$Parser$result;
-
-          /* . . . . . .*/
-          default:
-            throw new Exception(
-               "Invalid action number "+CUP$Parser$act_num+"found in internal parse table");
-
-        }
-    } /* end of method */
-
-  /** Method splitting the generated action code into several parts. */
-  public final java_cup.runtime.Symbol CUP$Parser$do_action(
-    int                        CUP$Parser$act_num,
-    java_cup.runtime.lr_parser CUP$Parser$parser,
-    java.util.Stack            CUP$Parser$stack,
-    int                        CUP$Parser$top)
-    throws java.lang.Exception
-    {
-              return CUP$Parser$do_action_part00000000(
-                               CUP$Parser$act_num,
-                               CUP$Parser$parser,
-                               CUP$Parser$stack,
-                               CUP$Parser$top);
-    }
-}
-
-}
diff --git a/iotjava/iotparser/sym.java b/iotjava/iotparser/sym.java
deleted file mode 100644 (file)
index d34e748..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-package iotparser;
-
-//----------------------------------------------------
-// The following code was generated by CUP v0.11b 20160615 (GIT 4ac7450)
-//----------------------------------------------------
-
-/** CUP generated interface containing symbol constants. */
-public interface sym {
-  /* terminals */
-  public static final int IDENT = 19;
-  public static final int SEMICOLON = 2;
-  public static final int STRINGCONST = 20;
-  public static final int REQUIRES = 15;
-  public static final int END = 8;
-  public static final int CAPABILITY = 12;
-  public static final int AS = 17;
-  public static final int WITH = 16;
-  public static final int PUBLIC = 10;
-  public static final int BEGIN = 7;
-  public static final int TYPE = 18;
-  public static final int DESCRIPTION = 13;
-  public static final int COMMA = 3;
-  public static final int EOF = 0;
-  public static final int METHOD = 14;
-  public static final int error = 1;
-  public static final int DOT = 4;
-  public static final int INTERFACE = 11;
-  public static final int ASSIGN = 9;
-  public static final int RPAR = 6;
-  public static final int LPAR = 5;
-  public static final String[] terminalNames = new String[] {
-  "EOF",
-  "error",
-  "SEMICOLON",
-  "COMMA",
-  "DOT",
-  "LPAR",
-  "RPAR",
-  "BEGIN",
-  "END",
-  "ASSIGN",
-  "PUBLIC",
-  "INTERFACE",
-  "CAPABILITY",
-  "DESCRIPTION",
-  "METHOD",
-  "REQUIRES",
-  "WITH",
-  "AS",
-  "TYPE",
-  "IDENT",
-  "STRINGCONST"
-  };
-}
-
diff --git a/iotjava/iotpolicy/IoTStubCompiler.java b/iotjava/iotpolicy/IoTStubCompiler.java
new file mode 100644 (file)
index 0000000..c11d32f
--- /dev/null
@@ -0,0 +1,540 @@
+package iotpolicy;
+
+import java_cup.runtime.ComplexSymbolFactory;
+import java_cup.runtime.ScannerBuffer;
+import java.io.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import iotpolicy.parser.Lexer;
+import iotpolicy.parser.Parser;
+import iotpolicy.tree.ParseNode;
+import iotpolicy.tree.ParseNodeVector;
+import iotpolicy.tree.ParseTreeHandler;
+import iotpolicy.tree.CapabilityDecl;
+import iotpolicy.tree.InterfaceDecl;
+import iotpolicy.tree.RequiresDecl;
+
+/** Class IoTStubCompiler is the main stub compiler for
+ *  stub files generation. This class calls helper classes
+ *  such as Parser, Lexer, InterfaceDecl, CapabilityDecl,
+ *  RequiresDecl, ParseTreeHandler, etc.
+ *
+ * @author      Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
+ * @version     1.0
+ * @since       2016-09-22
+ */
+public final class IoTStubCompiler {
+
+       /**
+        * Class properties
+        */
+       private String origInt;
+       private ParseTreeHandler ptHandler;
+       private InterfaceDecl intDecl;
+       private CapabilityDecl capDecl;
+       private RequiresDecl reqDecl;
+       private Map<String,Set<String>> mapCapabMethods;
+       private PrintWriter pw;
+       private String dir;
+
+       /**
+        * Class constants
+        */
+       private final static String OUTPUT_DIRECTORY = "stubfiles";
+
+       /**
+        * Class constructors
+        */
+       public IoTStubCompiler() {
+
+               origInt = null;
+               ptHandler = new ParseTreeHandler();
+               intDecl = null;
+               capDecl = null;
+               capDecl = null;
+               mapCapabMethods = new HashMap<String,Set<String>>();
+               pw = null;
+               dir = OUTPUT_DIRECTORY;
+       }
+
+
+       public IoTStubCompiler(String _origInt, ParseNode _pn) {
+
+               origInt = _origInt;
+               ptHandler = new ParseTreeHandler(_origInt, _pn);
+               intDecl = null;
+               capDecl = null;
+               reqDecl = null;
+               mapCapabMethods = new HashMap<String,Set<String>>();
+               pw = null;
+               dir = OUTPUT_DIRECTORY;
+       }
+
+
+       /**
+        * parsePolicyFile() parses policy file
+        * <p>
+        * It also generates parse tree and
+        * copies useful information from parse tree into
+        * InterfaceDecl, CapabilityDecl, and RequiresDecl 
+        * data structures.
+        * Additionally, the data structure handles are
+        * returned from tree-parsing for further process.
+        *
+        */
+       public void parsePolicyFile() {
+
+               ptHandler.processInterfaceDecl();
+               intDecl = ptHandler.getInterfaceDecl();
+
+               ptHandler.processCapabilityDecl();
+               capDecl = ptHandler.getCapabilityDecl();
+
+               ptHandler.processRequiresDecl();
+               reqDecl = ptHandler.getRequiresDecl();
+       }
+
+
+       /**
+        * getMethodsForIntface() reads for methods in the data structure
+        * <p>
+        * It is going to give list of methods for a certain interface
+        *              based on the declaration of capabilities.
+        */
+       public void getMethodsForIntface() {
+
+               // Get set of new interfaces, e.g. CameraWithCaptureAndData
+               // Generate this new interface with all the methods it needs
+               //              from different capabilities it declares
+               Set<String> setIntfaces = reqDecl.getInterfaces();
+               for (String strInt : setIntfaces) {
+
+                       // Initialize a set of methods
+                       Set<String> setMethods = new HashSet<String>();
+                       // Get list of capabilities, e.g. ImageCapture, VideoRecording, etc.
+                       List<String> listCapab = reqDecl.getCapabList(strInt);
+                       for (String strCap : listCapab) {
+
+                               // Get list of methods for each capability
+                               List<String> listCapabMeth = capDecl.getMethods(strCap);
+                               for (String strMeth : listCapabMeth) {
+
+                                       // Add methods into setMethods
+                                       // This is to also handle redundancies (say two capabilities
+                                       //              share the same methods)
+                                       setMethods.add(strMeth);
+                               }
+                       }
+                       // Add interface and methods information into map
+                       mapCapabMethods.put(strInt, setMethods);
+               }
+       }
+
+
+       /**
+        * generateJavaInterfaces() generate stub interfaces based on the methods list in Java
+        */
+       public void generateJavaInterfaces() throws IOException {
+
+               // Create a new directory
+               createDirectory(dir);
+               for (Map.Entry<String,Set<String>> intMeth : mapCapabMethods.entrySet()) {
+
+                       // Open a new file to write into
+                       String newIntface = intMeth.getKey();
+                       FileWriter fw = new FileWriter(dir + "/" + newIntface + ".java");
+                       pw = new PrintWriter(new BufferedWriter(fw));
+                       // Write interface header
+                       println("");
+                       println("public interface " + newIntface + " {");
+                       // Write methods
+                       for (String method : intMeth.getValue()) {
+
+                               List<String> methParams = intDecl.getMethodParams(method);
+                               List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
+                               print("public " + intDecl.getMethodType(method) + " " +
+                                       method + "(");
+                               for (int i = 0; i < methParams.size(); i++) {
+                                        print(methPrmTypes.get(i) + " " + methParams.get(i));
+                                       // Check if this is the last element (don't print a comma)
+                                       if (i != methParams.size() - 1) {
+                                               print(", ");
+                                       }
+                               }
+                               println(");");
+                       }
+                       println("}");
+                       pw.close();
+                       System.out.println("IoTStubCompiler: Generated interface " + newIntface + ".java...");
+               }
+       }
+
+
+       /**
+        * generateCPlusInterfaces() generate stub interfaces based on the methods list in C++
+        * <p>
+        * For C++ we use virtual classe as interface
+        */
+       public void generateCPlusInterfaces() throws IOException {
+
+               // Create a new directory
+               createDirectory(dir);
+               for (Map.Entry<String,Set<String>> intMeth : mapCapabMethods.entrySet()) {
+
+                       // Open a new file to write into
+                       String newIntface = intMeth.getKey();
+                       FileWriter fw = new FileWriter(dir + "/" + newIntface + ".hpp");
+                       pw = new PrintWriter(new BufferedWriter(fw));
+                       // Write file headers
+                       println("#include<iostream>");
+                       println("");
+                       println("using namespace std;");
+                       println("");
+                       println("class " + newIntface);
+                       println("{");
+                       println("public:");
+                       // Write methods
+                       for (String method : intMeth.getValue()) {
+
+                               List<String> methParams = intDecl.getMethodParams(method);
+                               List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
+                               print("virtual " + convertType(intDecl.getMethodType(method)) + " " +
+                                       method + "(");
+                               for (int i = 0; i < methParams.size(); i++) {
+                                        print(convertType(methPrmTypes.get(i)) + " " + methParams.get(i));
+                                       // Check if this is the last element (don't print a comma)
+                                       if (i != methParams.size() - 1) {
+                                               print(", ");
+                                       }
+                               }
+                               println(") = 0;");
+                       }
+                       print("}");
+                       println(";");
+                       pw.close();
+                       System.out.println("IoTStubCompiler: Generated interface " + newIntface + ".hpp...");
+               }
+       }
+
+
+       /**
+        * generateJavaStubClasses() generate stubs based on the methods list in Java
+        */
+       public void generateJavaStubClasses() throws IOException {
+
+               // Create a new directory
+               createDirectory(dir);
+               for (Map.Entry<String,Set<String>> intMeth : mapCapabMethods.entrySet()) {
+
+                       // Open a new file to write into
+                       String newIntface = intMeth.getKey();
+                       String newStubClass = newIntface + "_Stub";
+                       FileWriter fw = new FileWriter(dir + "/" + newStubClass + ".java");
+                       pw = new PrintWriter(new BufferedWriter(fw));
+                       // Write interface header
+                       println("");
+                       println("public class " + newStubClass + " implements " + newIntface + " {");
+                       println("");
+                       // Write methods
+                       for (String method : intMeth.getValue()) {
+
+                               List<String> methParams = intDecl.getMethodParams(method);
+                               List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
+                               print("public " + intDecl.getMethodType(method) + " " +
+                                       method + "(");
+                               for (int i = 0; i < methParams.size(); i++) {
+                                        print(methPrmTypes.get(i) + " " + methParams.get(i));
+                                       // Check if this is the last element (don't print a comma)
+                                       if (i != methParams.size() - 1) {
+                                               print(", ");
+                                       }
+                               }
+                               println(") {");
+                               // Check if this is not "void"
+                               if (!intDecl.getMethodType(method).equals("void")) {
+                                       String retStmt = generateReturnStmt(intDecl.getMethodType(method));
+                                       println("return " + retStmt + ";");
+                               }
+                               println("}");
+                               println("");
+                       }
+                       println("}");
+                       pw.close();
+                       System.out.println("IoTStubCompiler: Generated stub class " + newStubClass + ".java...");
+               }
+       }
+
+
+       /**
+        * generateCPlusStubClasses() generate stubs based on the methods list in C++
+        */
+       public void generateCPlusStubClasses() throws IOException {
+
+               // Create a new directory
+               createDirectory(dir);
+               for (Map.Entry<String,Set<String>> intMeth : mapCapabMethods.entrySet()) {
+
+                       // Open a new file to write into
+                       String newIntface = intMeth.getKey();
+                       String newStubClass = newIntface + "_Stub";
+                       FileWriter fw = new FileWriter(dir + "/" + newStubClass + ".hpp");
+                       pw = new PrintWriter(new BufferedWriter(fw));
+                       // Write file headers
+                       println("#include<iostream>");
+                       println("#include \"" + newIntface + ".hpp\""); println("");            
+                       println("using namespace std;"); println("");
+                       println("class " + newStubClass + " : public " + newIntface);
+                       println("{");
+                       println("public:"); println("");
+                       // Add default constructor and destructor
+                       println(newStubClass + "() { }"); println("");
+                       println("~" + newStubClass + "() { }"); println("");            
+                       // Write methods
+                       for (String method : intMeth.getValue()) {
+
+                               List<String> methParams = intDecl.getMethodParams(method);
+                               List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
+                               print(convertType(intDecl.getMethodType(method)) + " " +
+                                       method + "(");
+                               for (int i = 0; i < methParams.size(); i++) {
+                                        print(convertType(methPrmTypes.get(i)) + " " + methParams.get(i));
+                                       // Check if this is the last element (don't print a comma)
+                                       if (i != methParams.size() - 1) {
+                                               print(", ");
+                                       }
+                               }
+                               println(") { ");
+                               // Check if this is not "void"
+                               if (!intDecl.getMethodType(method).equals("void")) {
+                                       String retStmt = generateReturnStmt(intDecl.getMethodType(method));
+                                       if (retStmt.equals("null")) { // null = NULL in C++
+                                               retStmt = "NULL";
+                                       }
+                                       println("return " + retStmt + ";");
+                               }
+                               println("}"); println("");
+                       }
+                       print("}"); println(";");
+                       pw.close();
+                       System.out.println("IoTStubCompiler: Generated stub class " + newIntface + ".hpp...");
+               }
+       }
+
+
+       /**
+        * generateReturnStmt() generate return statement based on methType
+        */
+       public String generateReturnStmt(String methType) {
+
+               // Generate dummy returns for now
+               if (methType.equals("short")||
+                       methType.equals("int")  ||
+                       methType.equals("long") ||
+                       methType.equals("float")||
+                       methType.equals("double")) {
+
+                       return "1";
+               } else if ( methType.equals("String") ||
+                                       methType.equals("byte")) {
+  
+                       return "\"a\"";
+               } else if ( methType.equals("char")) {
+
+                       return "\'a\'";
+               } else if ( methType.equals("boolean")) {
+
+                       return "true";
+               } else {
+                       return "null";
+               }
+       }
+
+
+       /**
+        * setDirectory() set a new directory for stub files
+        */
+       public void setDirectory(String _dir) {
+
+               dir = _dir;
+       }
+
+
+       /**
+        * printUsage() prints the usage of this compiler
+        */
+       public static void printUsage() {
+
+               System.out.println();
+               System.out.println("Sentinel stub compiler version 1.0");
+               System.out.println("Copyright (c) 2015-2016 University of California, Irvine - Programming Language Group.");
+               System.out.println("All rights reserved.");
+               System.out.println("Usage:");
+               System.out.println("\tjava IoTStubCompiler --help\t\t\tDisplay this help texts");
+               System.out.println("\tjava IoTStubCompiler <policy-file>\t\tGenerate both Java and C++ stub files");
+               System.out.println("\tjava IoTStubCompiler <policy-file> [options]");
+               System.out.println("Options:");
+               System.out.println("\t-java\t<directory>\tGenerate Java stub files");
+               System.out.println("\t-cplus\t<directory>\tGenerate C++ stub files");
+               System.out.println();
+       }
+
+
+       /**================================================
+        * Helper functions to write stub codes into files
+        **================================================
+        */
+       boolean newline=true;
+       int tablevel=0;
+
+       private void print(String str) {
+               if (newline) {
+                       int tab=tablevel;
+                       if (str.equals("}"))
+                               tab--;
+                       for(int i=0; i<tab; i++)
+                               pw.print("\t");
+               }
+               pw.print(str);
+               updatetabbing(str);
+               newline=false;
+       }
+
+       /**
+        * This function converts Java to C++ type for compilation
+        */
+       private String convertType(String jType) {
+
+               // Generate dummy returns for now
+               if (jType.equals("short")||
+                       jType.equals("int")  ||
+                       jType.equals("long") ||
+                       jType.equals("char") ||
+                       jType.equals("float")||
+                       jType.equals("double")) {
+
+                       return jType;
+               } else if ( jType.equals("String")) {
+  
+                       return "string";
+               } else if ( jType.equals("byte")) {
+
+                       return "char";
+               } else if ( jType.equals("boolean")) {
+
+                       return "bool";
+               } else {
+                       return jType;
+               }       
+       }
+
+
+       private void println(String str) {
+               if (newline) {
+                       int tab = tablevel;
+                       if (str.equals("}"))
+                               tab--;
+                       for(int i=0; i<tab; i++)
+                               pw.print("\t");
+               }
+               pw.println(str);
+               updatetabbing(str);
+               newline = true;
+       }
+
+
+       private void updatetabbing(String str) {
+               tablevel+=count(str,'{')-count(str,'}');
+       }
+
+
+       private int count(String str, char key) {
+               char[] array = str.toCharArray();
+               int count = 0;
+               for(int i=0; i<array.length; i++) {
+                       if (array[i] == key)
+                               count++;
+               }
+               return count;
+       }
+
+
+       private void createDirectory(String dirName) {
+
+               File file = new File(dirName);
+               if (!file.exists()) {
+                       if (file.mkdir()) {
+                               System.out.println("IoTStubCompiler: Directory " + dirName + "has been created!");
+                       } else {
+                               System.out.println("IoTStubCompiler: Failed to create directory " + dirName + "!");
+                       }
+               } else {
+                       System.out.println("IoTStubCompiler: Directory " + dirName + " exists...");
+               }
+       }
+
+
+       public static void main(String[] args) throws Exception {
+
+               // Runtime options
+               if (args.length != 0) {
+                       // Display help
+                       if (args[0].equals("--help")) {
+                               IoTStubCompiler.printUsage();
+                       } else {
+                               // Initialize the symbol factory
+                               ComplexSymbolFactory csf = new ComplexSymbolFactory();
+                               // Create a buffering scanner wrapper
+                               ScannerBuffer lexer = 
+                                       new ScannerBuffer(new Lexer(new BufferedReader(new FileReader(args[0])),csf));
+                               // Start parsing
+                               Parser p = new Parser(lexer,csf);
+                               ParseNode pn = (ParseNode) p.parse().value;
+                               // Handle parse-tree and process it
+                               String intFace = ParseTreeHandler.getOrigIntface(pn);
+                               //System.out.println("IoTStubCompiler: Original interface: " + intFace);
+                               IoTStubCompiler stubComp = new IoTStubCompiler(intFace, pn);
+                               // Generate all policy files if just policy file is provided
+                               stubComp.parsePolicyFile();
+                               stubComp.getMethodsForIntface();
+                               if (args.length == 1) {
+                                       stubComp.generateJavaInterfaces();
+                                       stubComp.generateJavaStubClasses();
+                                       stubComp.generateCPlusInterfaces();
+                                       stubComp.generateCPlusStubClasses();
+                               } else {
+                               // Check other options
+                                       int i = 1;
+                                       while(i < args.length) {
+                                               // Check whether <directory> is provided
+                                               if ((i + 1) < args.length) {
+                                                       stubComp.setDirectory(args[i+1]);
+                                               } else
+                                                       throw new Error("IoTStubCompiler: ERROR - please provide <directory> after option: " + args[i]);
+                                               if (args[i].equals("-java")) {
+                                                       stubComp.generateJavaInterfaces();
+                                                       stubComp.generateJavaStubClasses();
+                                               } else if (args[i].equals("-cplus")) {
+                                                       stubComp.generateCPlusInterfaces();
+                                                       stubComp.generateCPlusStubClasses();
+                                               } else
+                                                       throw new Error("IoTStubCompiler: ERROR - unrecognized command line option: " + args[i]);
+                                               i = i + 2;
+                                       }
+                               }
+                       }
+
+               } else {
+               // Need at least the policy file name
+                       IoTStubCompiler.printUsage();
+                       throw new Error("IoTStubCompiler: At least one argument (policy file) has to be provided!");
+               }
+       }
+}
+
+
+
+
diff --git a/iotjava/iotpolicy/parser/Lexer.java b/iotjava/iotpolicy/parser/Lexer.java
new file mode 100644 (file)
index 0000000..aa40a6e
--- /dev/null
@@ -0,0 +1,910 @@
+package iotpolicy.parser;
+
+/* The following code was generated by JFlex 1.6.1 */
+
+// JFlex parser specification written by
+// Rahmadi Trimananda
+// for Sentinel system
+// University of California, Irvine
+
+// Technische Universitaet Muenchen 
+// Fakultaet fuer Informatik 
+
+import java_cup.runtime.Symbol;
+import java_cup.runtime.ComplexSymbolFactory;
+import java_cup.runtime.ComplexSymbolFactory.Location;
+
+
+/**
+ * This class is a scanner generated by 
+ * <a href="http://www.jflex.de/">JFlex</a> 1.6.1
+ * from the specification file <tt>iotparser.jflex</tt>
+ */
+public class Lexer implements java_cup.runtime.Scanner, sym {
+
+  /** This character denotes the end of file */
+  public static final int YYEOF = -1;
+
+  /** initial size of the lookahead buffer */
+  private static final int ZZ_BUFFERSIZE = 16384;
+
+  /** lexical states */
+  public static final int YYINITIAL = 0;
+  public static final int STRING = 2;
+
+  /**
+   * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+   * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+   *                  at the beginning of a line
+   * l is of the form l = 2*k, k a non negative integer
+   */
+  private static final int ZZ_LEXSTATE[] = { 
+     0,  0,  1, 1
+  };
+
+  /** 
+   * Translates characters to character classes
+   */
+  private static final String ZZ_CMAP_PACKED = 
+    "\11\0\1\6\1\4\1\47\1\6\1\3\22\0\1\6\1\0\1\36"+
+    "\1\0\1\1\3\0\1\41\1\42\2\0\1\37\1\0\1\40\1\0"+
+    "\12\2\1\0\1\5\1\0\1\45\3\0\22\1\1\30\7\1\1\0"+
+    "\1\46\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\43"+
+    "\1\0\1\44\7\0\1\47\u1fa2\0\1\47\1\47\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
+   */
+  private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+  /** 
+   * Translates DFA states to action switch labels.
+   */
+  private static final int [] ZZ_ACTION = zzUnpackAction();
+
+  private static final String ZZ_ACTION_PACKED_0 =
+    "\2\0\1\1\1\2\2\3\1\4\16\2\1\5\1\6"+
+    "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1\16"+
+    "\1\17\1\0\10\2\1\20\11\2\1\21\1\22\1\23"+
+    "\1\24\1\25\25\2\1\26\1\27\3\2\1\30\2\2"+
+    "\1\31\2\2\1\32\2\2\1\33\2\2\1\34\7\2"+
+    "\1\35\2\2\1\36\2\2\1\37\1\40\1\41\2\2"+
+    "\1\42\3\2\1\43\2\2\1\44\3\2\1\45\1\46";
+
+  private static int [] zzUnpackAction() {
+    int [] result = new int[126];
+    int offset = 0;
+    offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+    return result;
+  }
+
+  private static int zzUnpackAction(String packed, int offset, int [] result) {
+    int i = 0;       /* index in packed string  */
+    int j = offset;  /* index in unpacked array */
+    int l = packed.length();
+    while (i < l) {
+      int count = packed.charAt(i++);
+      int value = packed.charAt(i++);
+      do result[j++] = value; while (--count > 0);
+    }
+    return j;
+  }
+
+
+  /** 
+   * Translates a state to a row index in the transition table
+   */
+  private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
+
+  private static final String ZZ_ROWMAP_PACKED_0 =
+    "\0\0\0\50\0\120\0\170\0\240\0\120\0\120\0\310"+
+    "\0\360\0\u0118\0\u0140\0\u0168\0\u0190\0\u01b8\0\u01e0\0\u0208"+
+    "\0\u0230\0\u0258\0\u0280\0\u02a8\0\u02d0\0\120\0\120\0\120"+
+    "\0\120\0\120\0\120\0\120\0\120\0\u02f8\0\120\0\u0320"+
+    "\0\u0348\0\u0370\0\u0398\0\u03c0\0\u03e8\0\u0410\0\u0438\0\u0460"+
+    "\0\u0488\0\170\0\u04b0\0\u04d8\0\u0500\0\u0528\0\u0550\0\u0578"+
+    "\0\u05a0\0\u05c8\0\u05f0\0\120\0\120\0\120\0\120\0\u0618"+
+    "\0\u0640\0\u0668\0\u0690\0\u06b8\0\u06e0\0\u0708\0\u0730\0\u0758"+
+    "\0\u0780\0\u07a8\0\u07d0\0\u07f8\0\u0820\0\u0848\0\u0870\0\u0898"+
+    "\0\u08c0\0\u08e8\0\u0910\0\u0938\0\u0960\0\170\0\170\0\u0988"+
+    "\0\u09b0\0\u09d8\0\170\0\u0a00\0\u0a28\0\170\0\u0a50\0\u0a78"+
+    "\0\170\0\u0aa0\0\u0ac8\0\170\0\u0af0\0\u0b18\0\170\0\u0b40"+
+    "\0\u0b68\0\u0b90\0\u0bb8\0\u0be0\0\u0c08\0\u0c30\0\170\0\u0c58"+
+    "\0\u0c80\0\170\0\u0ca8\0\u0cd0\0\170\0\170\0\170\0\u0cf8"+
+    "\0\u0d20\0\170\0\u0d48\0\u0d70\0\u0d98\0\170\0\u0dc0\0\u0de8"+
+    "\0\170\0\u0e10\0\u0e38\0\u0e60\0\170\0\170";
+
+  private static int [] zzUnpackRowMap() {
+    int [] result = new int[126];
+    int offset = 0;
+    offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
+    return result;
+  }
+
+  private static int zzUnpackRowMap(String packed, int offset, int [] result) {
+    int i = 0;  /* index in packed string  */
+    int j = offset;  /* index in unpacked array */
+    int l = packed.length();
+    while (i < l) {
+      int high = packed.charAt(i++) << 16;
+      result[j++] = high | packed.charAt(i++);
+    }
+    return j;
+  }
+
+  /** 
+   * The transition table of the DFA
+   */
+  private static final int [] ZZ_TRANS = zzUnpackTrans();
+
+  private static final String ZZ_TRANS_PACKED_0 =
+    "\1\3\1\4\1\3\1\5\1\6\1\7\1\6\1\10"+
+    "\2\4\1\11\2\4\1\12\1\13\2\4\1\14\1\4"+
+    "\1\15\1\16\1\17\1\4\1\20\1\21\1\22\1\23"+
+    "\1\24\1\4\1\25\1\26\1\27\1\30\1\31\1\32"+
+    "\1\33\1\34\1\35\1\3\1\0\3\36\1\0\1\3"+
+    "\31\36\1\37\7\36\1\40\1\36\51\0\2\4\4\0"+
+    "\27\4\16\0\1\41\44\0\2\4\4\0\1\4\1\42"+
+    "\25\4\13\0\2\4\4\0\2\4\1\43\1\4\1\44"+
+    "\22\4\13\0\2\4\4\0\11\4\1\45\15\4\13\0"+
+    "\2\4\4\0\5\4\1\46\2\4\1\47\16\4\13\0"+
+    "\2\4\4\0\5\4\1\50\21\4\13\0\2\4\4\0"+
+    "\12\4\1\51\14\4\13\0\2\4\4\0\3\4\1\52"+
+    "\23\4\13\0\2\4\4\0\5\4\1\53\3\4\1\54"+
+    "\15\4\13\0\2\4\4\0\4\4\1\55\10\4\1\56"+
+    "\11\4\13\0\2\4\4\0\2\4\1\57\24\4\13\0"+
+    "\2\4\4\0\5\4\1\60\21\4\13\0\2\4\4\0"+
+    "\17\4\1\61\7\4\13\0\2\4\4\0\11\4\1\62"+
+    "\15\4\13\0\2\4\4\0\1\63\26\4\12\0\3\36"+
+    "\2\0\31\36\1\0\7\36\1\0\1\36\10\0\1\64"+
+    "\1\65\3\0\1\66\20\0\1\67\16\0\1\6\43\0"+
+    "\2\4\4\0\2\4\1\70\24\4\13\0\2\4\4\0"+
+    "\6\4\1\71\20\4\13\0\2\4\4\0\5\4\1\72"+
+    "\21\4\13\0\2\4\4\0\25\4\1\73\1\4\13\0"+
+    "\2\4\4\0\5\4\1\74\21\4\13\0\2\4\4\0"+
+    "\2\4\1\75\24\4\13\0\2\4\4\0\1\4\1\76"+
+    "\25\4\13\0\2\4\4\0\5\4\1\77\21\4\13\0"+
+    "\2\4\4\0\17\4\1\100\7\4\13\0\2\4\4\0"+
+    "\3\4\1\101\23\4\13\0\2\4\4\0\15\4\1\102"+
+    "\11\4\13\0\2\4\4\0\23\4\1\103\3\4\13\0"+
+    "\2\4\4\0\6\4\1\104\20\4\13\0\2\4\4\0"+
+    "\1\105\26\4\13\0\2\4\4\0\7\4\1\106\17\4"+
+    "\13\0\2\4\4\0\2\4\1\107\24\4\13\0\2\4"+
+    "\4\0\2\4\1\110\24\4\13\0\2\4\4\0\11\4"+
+    "\1\111\15\4\13\0\2\4\4\0\1\112\26\4\13\0"+
+    "\2\4\4\0\6\4\1\113\20\4\13\0\2\4\4\0"+
+    "\17\4\1\114\7\4\13\0\2\4\4\0\12\4\1\115"+
+    "\14\4\13\0\2\4\4\0\11\4\1\116\15\4\13\0"+
+    "\2\4\4\0\13\4\1\117\13\4\13\0\2\4\4\0"+
+    "\15\4\1\120\11\4\13\0\2\4\4\0\7\4\1\121"+
+    "\17\4\13\0\2\4\4\0\20\4\1\122\6\4\13\0"+
+    "\2\4\4\0\6\4\1\123\20\4\13\0\2\4\4\0"+
+    "\15\4\1\124\11\4\13\0\2\4\4\0\1\125\26\4"+
+    "\13\0\2\4\4\0\16\4\1\126\10\4\13\0\2\4"+
+    "\4\0\12\4\1\127\14\4\13\0\2\4\4\0\4\4"+
+    "\1\130\22\4\13\0\2\4\4\0\4\4\1\131\22\4"+
+    "\13\0\2\4\4\0\6\4\1\132\20\4\13\0\2\4"+
+    "\4\0\1\4\1\133\25\4\13\0\2\4\4\0\2\4"+
+    "\1\134\24\4\13\0\2\4\4\0\1\135\26\4\13\0"+
+    "\2\4\4\0\11\4\1\136\15\4\13\0\2\4\4\0"+
+    "\2\4\1\137\24\4\13\0\2\4\4\0\12\4\1\140"+
+    "\14\4\13\0\2\4\4\0\6\4\1\141\20\4\13\0"+
+    "\2\4\4\0\7\4\1\142\17\4\13\0\2\4\4\0"+
+    "\1\4\1\143\25\4\13\0\2\4\4\0\1\144\26\4"+
+    "\13\0\2\4\4\0\5\4\1\145\21\4\13\0\2\4"+
+    "\4\0\14\4\1\146\12\4\13\0\2\4\4\0\13\4"+
+    "\1\147\13\4\13\0\2\4\4\0\6\4\1\150\20\4"+
+    "\13\0\2\4\4\0\15\4\1\151\11\4\13\0\2\4"+
+    "\4\0\11\4\1\152\15\4\13\0\2\4\4\0\1\153"+
+    "\26\4\13\0\2\4\4\0\1\154\26\4\13\0\2\4"+
+    "\4\0\13\4\1\155\13\4\13\0\2\4\4\0\20\4"+
+    "\1\156\6\4\13\0\2\4\4\0\16\4\1\157\10\4"+
+    "\13\0\2\4\4\0\15\4\1\160\11\4\13\0\2\4"+
+    "\4\0\11\4\1\161\15\4\13\0\2\4\4\0\1\4"+
+    "\1\162\25\4\13\0\2\4\4\0\23\4\1\163\3\4"+
+    "\13\0\2\4\4\0\12\4\1\164\14\4\13\0\2\4"+
+    "\4\0\20\4\1\165\6\4\13\0\2\4\4\0\3\4"+
+    "\1\166\23\4\13\0\2\4\4\0\2\4\1\167\24\4"+
+    "\13\0\2\4\4\0\1\170\26\4\13\0\2\4\4\0"+
+    "\11\4\1\171\15\4\13\0\2\4\4\0\1\172\26\4"+
+    "\13\0\2\4\4\0\2\4\1\173\24\4\13\0\2\4"+
+    "\4\0\5\4\1\174\21\4\13\0\2\4\4\0\10\4"+
+    "\1\175\16\4\13\0\2\4\4\0\1\4\1\176\25\4"+
+    "\12\0";
+
+  private static int [] zzUnpackTrans() {
+    int [] result = new int[3720];
+    int offset = 0;
+    offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
+    return result;
+  }
+
+  private static int zzUnpackTrans(String packed, int offset, int [] result) {
+    int i = 0;       /* index in packed string  */
+    int j = offset;  /* index in unpacked array */
+    int l = packed.length();
+    while (i < l) {
+      int count = packed.charAt(i++);
+      int value = packed.charAt(i++);
+      value--;
+      do result[j++] = value; while (--count > 0);
+    }
+    return j;
+  }
+
+
+  /* error codes */
+  private static final int ZZ_UNKNOWN_ERROR = 0;
+  private static final int ZZ_NO_MATCH = 1;
+  private static final int ZZ_PUSHBACK_2BIG = 2;
+
+  /* error messages for the codes above */
+  private static final String ZZ_ERROR_MSG[] = {
+    "Unknown internal scanner error",
+    "Error: could not match input",
+    "Error: pushback value was too large"
+  };
+
+  /**
+   * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
+   */
+  private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+  private static final String ZZ_ATTRIBUTE_PACKED_0 =
+    "\2\0\1\11\2\1\2\11\16\1\10\11\1\1\1\11"+
+    "\1\1\1\0\22\1\4\11\107\1";
+
+  private static int [] zzUnpackAttribute() {
+    int [] result = new int[126];
+    int offset = 0;
+    offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+    return result;
+  }
+
+  private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+    int i = 0;       /* index in packed string  */
+    int j = offset;  /* index in unpacked array */
+    int l = packed.length();
+    while (i < l) {
+      int count = packed.charAt(i++);
+      int value = packed.charAt(i++);
+      do result[j++] = value; while (--count > 0);
+    }
+    return j;
+  }
+
+  /** the input device */
+  private java.io.Reader zzReader;
+
+  /** the current state of the DFA */
+  private int zzState;
+
+  /** the current lexical state */
+  private int zzLexicalState = YYINITIAL;
+
+  /** this buffer contains the current text to be matched and is
+      the source of the yytext() string */
+  private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+  /** the textposition at the last accepting state */
+  private int zzMarkedPos;
+
+  /** the current text position in the buffer */
+  private int zzCurrentPos;
+
+  /** startRead marks the beginning of the yytext() string in the buffer */
+  private int zzStartRead;
+
+  /** endRead marks the last character in the buffer, that has been read
+      from input */
+  private int zzEndRead;
+
+  /** number of newlines encountered up to the start of the matched text */
+  private int yyline;
+
+  /** the number of characters up to the start of the matched text */
+  private int yychar;
+
+  /**
+   * the number of characters from the last newline up to the start of the 
+   * matched text
+   */
+  private int yycolumn;
+
+  /** 
+   * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+   */
+  private boolean zzAtBOL = true;
+
+  /** zzAtEOF == true <=> the scanner is at the EOF */
+  private boolean zzAtEOF;
+
+  /** denotes if the user-EOF-code has already been executed */
+  private boolean zzEOFDone;
+  
+  /** 
+   * The number of occupied positions in zzBuffer beyond zzEndRead.
+   * When a lead/high surrogate has been read from the input stream
+   * into the final zzBuffer position, this will have a value of 1;
+   * otherwise, it will have a value of 0.
+   */
+  private int zzFinalHighSurrogate = 0;
+
+  /* user code: */
+    StringBuffer string = new StringBuffer();
+    public Lexer(java.io.Reader in, ComplexSymbolFactory sf){
+       this(in);
+       symbolFactory = sf;
+    }
+    ComplexSymbolFactory symbolFactory;
+
+  private Symbol symbol(String name, int sym) {
+      return symbolFactory.newSymbol(name, sym, new Location(yyline+1,yycolumn+1,yychar), new Location(yyline+1,yycolumn+yylength(),yychar+yylength()));
+  }
+  
+  private Symbol symbol(String name, int sym, Object val) {
+      Location left = new Location(yyline+1,yycolumn+1,yychar);
+      Location right= new Location(yyline+1,yycolumn+yylength(), yychar+yylength());
+      return symbolFactory.newSymbol(name, sym, left, right,val);
+  } 
+  private Symbol symbol(String name, int sym, Object val,int buflength) {
+      Location left = new Location(yyline+1,yycolumn+yylength()-buflength,yychar+yylength()-buflength);
+      Location right= new Location(yyline+1,yycolumn+yylength(), yychar+yylength());
+      return symbolFactory.newSymbol(name, sym, left, right,val);
+  }       
+  private void error(String message) {
+    System.out.println("Error at line "+(yyline+1)+", column "+(yycolumn+1)+" : "+message);
+  }
+
+
+  /**
+   * Creates a new scanner
+   *
+   * @param   in  the java.io.Reader to read input from.
+   */
+  public Lexer(java.io.Reader in) {
+    this.zzReader = in;
+  }
+
+
+  /** 
+   * Unpacks the compressed character translation table.
+   *
+   * @param packed   the packed character translation table
+   * @return         the unpacked character translation table
+   */
+  private static char [] zzUnpackCMap(String packed) {
+    char [] map = new char[0x110000];
+    int i = 0;  /* index in packed string  */
+    int j = 0;  /* index in unpacked array */
+    while (i < 168) {
+      int  count = packed.charAt(i++);
+      char value = packed.charAt(i++);
+      do map[j++] = value; while (--count > 0);
+    }
+    return map;
+  }
+
+
+  /**
+   * Refills the input buffer.
+   *
+   * @return      <code>false</code>, iff there was new input.
+   * 
+   * @exception   java.io.IOException  if any I/O-Error occurs
+   */
+  private boolean zzRefill() throws java.io.IOException {
+
+    /* first: make room (if you can) */
+    if (zzStartRead > 0) {
+      zzEndRead += zzFinalHighSurrogate;
+      zzFinalHighSurrogate = 0;
+      System.arraycopy(zzBuffer, zzStartRead,
+                       zzBuffer, 0,
+                       zzEndRead-zzStartRead);
+
+      /* translate stored positions */
+      zzEndRead-= zzStartRead;
+      zzCurrentPos-= zzStartRead;
+      zzMarkedPos-= zzStartRead;
+      zzStartRead = 0;
+    }
+
+    /* is the buffer big enough? */
+    if (zzCurrentPos >= zzBuffer.length - zzFinalHighSurrogate) {
+      /* if not: blow it up */
+      char newBuffer[] = new char[zzBuffer.length*2];
+      System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+      zzBuffer = newBuffer;
+      zzEndRead += zzFinalHighSurrogate;
+      zzFinalHighSurrogate = 0;
+    }
+
+    /* fill the buffer with new input */
+    int requested = zzBuffer.length - zzEndRead;
+    int numRead = zzReader.read(zzBuffer, zzEndRead, requested);
+
+    /* not supposed to occur according to specification of java.io.Reader */
+    if (numRead == 0) {
+      throw new java.io.IOException("Reader returned 0 characters. See JFlex examples for workaround.");
+    }
+    if (numRead > 0) {
+      zzEndRead += numRead;
+      /* If numRead == requested, we might have requested to few chars to
+         encode a full Unicode character. We assume that a Reader would
+         otherwise never return half characters. */
+      if (numRead == requested) {
+        if (Character.isHighSurrogate(zzBuffer[zzEndRead - 1])) {
+          --zzEndRead;
+          zzFinalHighSurrogate = 1;
+        }
+      }
+      /* potentially more input available */
+      return false;
+    }
+
+    /* numRead < 0 ==> end of stream */
+    return true;
+  }
+
+    
+  /**
+   * Closes the input stream.
+   */
+  public final void yyclose() throws java.io.IOException {
+    zzAtEOF = true;            /* indicate end of file */
+    zzEndRead = zzStartRead;  /* invalidate buffer    */
+
+    if (zzReader != null)
+      zzReader.close();
+  }
+
+
+  /**
+   * Resets the scanner to read from a new input stream.
+   * Does not close the old reader.
+   *
+   * All internal variables are reset, the old input stream 
+   * <b>cannot</b> be reused (internal buffer is discarded and lost).
+   * Lexical state is set to <tt>ZZ_INITIAL</tt>.
+   *
+   * Internal scan buffer is resized down to its initial length, if it has grown.
+   *
+   * @param reader   the new input stream 
+   */
+  public final void yyreset(java.io.Reader reader) {
+    zzReader = reader;
+    zzAtBOL  = true;
+    zzAtEOF  = false;
+    zzEOFDone = false;
+    zzEndRead = zzStartRead = 0;
+    zzCurrentPos = zzMarkedPos = 0;
+    zzFinalHighSurrogate = 0;
+    yyline = yychar = yycolumn = 0;
+    zzLexicalState = YYINITIAL;
+    if (zzBuffer.length > ZZ_BUFFERSIZE)
+      zzBuffer = new char[ZZ_BUFFERSIZE];
+  }
+
+
+  /**
+   * Returns the current lexical state.
+   */
+  public final int yystate() {
+    return zzLexicalState;
+  }
+
+
+  /**
+   * Enters a new lexical state
+   *
+   * @param newState the new lexical state
+   */
+  public final void yybegin(int newState) {
+    zzLexicalState = newState;
+  }
+
+
+  /**
+   * Returns the text matched by the current regular expression.
+   */
+  public final String yytext() {
+    return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+  }
+
+
+  /**
+   * Returns the character at position <tt>pos</tt> from the 
+   * matched text. 
+   * 
+   * It is equivalent to yytext().charAt(pos), but faster
+   *
+   * @param pos the position of the character to fetch. 
+   *            A value from 0 to yylength()-1.
+   *
+   * @return the character at position pos
+   */
+  public final char yycharat(int pos) {
+    return zzBuffer[zzStartRead+pos];
+  }
+
+
+  /**
+   * Returns the length of the matched text region.
+   */
+  public final int yylength() {
+    return zzMarkedPos-zzStartRead;
+  }
+
+
+  /**
+   * Reports an error that occured while scanning.
+   *
+   * In a wellformed scanner (no or only correct usage of 
+   * yypushback(int) and a match-all fallback rule) this method 
+   * will only be called with things that "Can't Possibly Happen".
+   * If this method is called, something is seriously wrong
+   * (e.g. a JFlex bug producing a faulty scanner etc.).
+   *
+   * Usual syntax/scanner level error handling should be done
+   * in error fallback rules.
+   *
+   * @param   errorCode  the code of the errormessage to display
+   */
+  private void zzScanError(int errorCode) {
+    String message;
+    try {
+      message = ZZ_ERROR_MSG[errorCode];
+    }
+    catch (ArrayIndexOutOfBoundsException e) {
+      message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+    }
+
+    throw new Error(message);
+  } 
+
+
+  /**
+   * Pushes the specified amount of characters back into the input stream.
+   *
+   * They will be read again by then next call of the scanning method
+   *
+   * @param number  the number of characters to be read again.
+   *                This number must not be greater than yylength()!
+   */
+  public void yypushback(int number)  {
+    if ( number > yylength() )
+      zzScanError(ZZ_PUSHBACK_2BIG);
+
+    zzMarkedPos -= number;
+  }
+
+
+  /**
+   * Contains user EOF-code, which will be executed exactly once,
+   * when the end of file is reached
+   */
+  private void zzDoEOF() throws java.io.IOException {
+    if (!zzEOFDone) {
+      zzEOFDone = true;
+      yyclose();
+    }
+  }
+
+
+  /**
+   * Resumes scanning until the next regular expression is matched,
+   * the end of input is encountered or an I/O-Error occurs.
+   *
+   * @return      the next token
+   * @exception   java.io.IOException  if any I/O-Error occurs
+   */
+  public java_cup.runtime.Symbol next_token() throws java.io.IOException {
+    int zzInput;
+    int zzAction;
+
+    // cached fields:
+    int zzCurrentPosL;
+    int zzMarkedPosL;
+    int zzEndReadL = zzEndRead;
+    char [] zzBufferL = zzBuffer;
+    char [] zzCMapL = ZZ_CMAP;
+
+    int [] zzTransL = ZZ_TRANS;
+    int [] zzRowMapL = ZZ_ROWMAP;
+    int [] zzAttrL = ZZ_ATTRIBUTE;
+
+    while (true) {
+      zzMarkedPosL = zzMarkedPos;
+
+      yychar+= zzMarkedPosL-zzStartRead;
+
+      boolean zzR = false;
+      int zzCh;
+      int zzCharCount;
+      for (zzCurrentPosL = zzStartRead  ;
+           zzCurrentPosL < zzMarkedPosL ;
+           zzCurrentPosL += zzCharCount ) {
+        zzCh = Character.codePointAt(zzBufferL, zzCurrentPosL, zzMarkedPosL);
+        zzCharCount = Character.charCount(zzCh);
+        switch (zzCh) {
+        case '\u000B':
+        case '\u000C':
+        case '\u0085':
+        case '\u2028':
+        case '\u2029':
+          yyline++;
+          yycolumn = 0;
+          zzR = false;
+          break;
+        case '\r':
+          yyline++;
+          yycolumn = 0;
+          zzR = true;
+          break;
+        case '\n':
+          if (zzR)
+            zzR = false;
+          else {
+            yyline++;
+            yycolumn = 0;
+          }
+          break;
+        default:
+          zzR = false;
+          yycolumn += zzCharCount;
+        }
+      }
+
+      if (zzR) {
+        // peek one character ahead if it is \n (if we have counted one line too much)
+        boolean zzPeek;
+        if (zzMarkedPosL < zzEndReadL)
+          zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+        else if (zzAtEOF)
+          zzPeek = false;
+        else {
+          boolean eof = zzRefill();
+          zzEndReadL = zzEndRead;
+          zzMarkedPosL = zzMarkedPos;
+          zzBufferL = zzBuffer;
+          if (eof) 
+            zzPeek = false;
+          else 
+            zzPeek = zzBufferL[zzMarkedPosL] == '\n';
+        }
+        if (zzPeek) yyline--;
+      }
+      zzAction = -1;
+
+      zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+  
+      zzState = ZZ_LEXSTATE[zzLexicalState];
+
+      // set up zzAction for empty match case:
+      int zzAttributes = zzAttrL[zzState];
+      if ( (zzAttributes & 1) == 1 ) {
+        zzAction = zzState;
+      }
+
+
+      zzForAction: {
+        while (true) {
+    
+          if (zzCurrentPosL < zzEndReadL) {
+            zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
+            zzCurrentPosL += Character.charCount(zzInput);
+          }
+          else if (zzAtEOF) {
+            zzInput = YYEOF;
+            break zzForAction;
+          }
+          else {
+            // store back cached positions
+            zzCurrentPos  = zzCurrentPosL;
+            zzMarkedPos   = zzMarkedPosL;
+            boolean eof = zzRefill();
+            // get translated positions and possibly new buffer
+            zzCurrentPosL  = zzCurrentPos;
+            zzMarkedPosL   = zzMarkedPos;
+            zzBufferL      = zzBuffer;
+            zzEndReadL     = zzEndRead;
+            if (eof) {
+              zzInput = YYEOF;
+              break zzForAction;
+            }
+            else {
+              zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
+              zzCurrentPosL += Character.charCount(zzInput);
+            }
+          }
+          int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+          if (zzNext == -1) break zzForAction;
+          zzState = zzNext;
+
+          zzAttributes = zzAttrL[zzState];
+          if ( (zzAttributes & 1) == 1 ) {
+            zzAction = zzState;
+            zzMarkedPosL = zzCurrentPosL;
+            if ( (zzAttributes & 8) == 8 ) break zzForAction;
+          }
+
+        }
+      }
+
+      // store back cached position
+      zzMarkedPos = zzMarkedPosL;
+
+      if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+        zzAtEOF = true;
+            zzDoEOF();
+          {      return symbolFactory.newSymbol("EOF", EOF, new Location(yyline+1,yycolumn+1,yychar), new Location(yyline+1,yycolumn+1,yychar+1));
+ }
+      }
+      else {
+        switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+          case 1: 
+            { /* throw new Error("Illegal character <"+ yytext()+">");*/
+                   error("Illegal character <"+ yytext()+">");
+            }
+          case 39: break;
+          case 2: 
+            { return symbol("Identifier",IDENT, yytext());
+            }
+          case 40: break;
+          case 3: 
+            { /* ignore */
+            }
+          case 41: break;
+          case 4: 
+            { return symbol("semicolon",SEMICOLON);
+            }
+          case 42: break;
+          case 5: 
+            { string.setLength(0); yybegin(STRING);
+            }
+          case 43: break;
+          case 6: 
+            { return symbol("comma",COMMA);
+            }
+          case 44: break;
+          case 7: 
+            { return symbol("dot",DOT);
+            }
+          case 45: break;
+          case 8: 
+            { return symbol("(",LPAR);
+            }
+          case 46: break;
+          case 9: 
+            { return symbol(")",RPAR);
+            }
+          case 47: break;
+          case 10: 
+            { return symbol("{",BEGIN);
+            }
+          case 48: break;
+          case 11: 
+            { return symbol("}",END);
+            }
+          case 49: break;
+          case 12: 
+            { return symbol("=",ASSIGN);
+            }
+          case 50: break;
+          case 13: 
+            { string.append( yytext() );
+            }
+          case 51: break;
+          case 14: 
+            { yybegin(YYINITIAL); 
+      return symbol("StringConst",STRINGCONST,string.toString(),string.length());
+            }
+          case 52: break;
+          case 15: 
+            { string.append('\\');
+            }
+          case 53: break;
+          case 16: 
+            { return symbol("as",AS);
+            }
+          case 54: break;
+          case 17: 
+            { string.append('\n');
+            }
+          case 55: break;
+          case 18: 
+            { string.append('\t');
+            }
+          case 56: break;
+          case 19: 
+            { string.append('\r');
+            }
+          case 57: break;
+          case 20: 
+            { string.append('\"');
+            }
+          case 58: break;
+          case 21: 
+            { return symbol("int",TYPE, "int" );
+            }
+          case 59: break;
+          case 22: 
+            { return symbol("byte",TYPE, "byte" );
+            }
+          case 60: break;
+          case 23: 
+            { return symbol("long",TYPE, "long" );
+            }
+          case 61: break;
+          case 24: 
+            { return symbol("char",TYPE, "char" );
+            }
+          case 62: break;
+          case 25: 
+            { return symbol("void",TYPE, "void" );
+            }
+          case 63: break;
+          case 26: 
+            { return symbol("with",WITH);
+            }
+          case 64: break;
+          case 27: 
+            { return symbol("short",TYPE, "short" );
+            }
+          case 65: break;
+          case 28: 
+            { return symbol("float",TYPE, "float" );
+            }
+          case 66: break;
+          case 29: 
+            { return symbol("string",TYPE, "String" );
+            }
+          case 67: break;
+          case 30: 
+            { return symbol("double",TYPE, "double" );
+            }
+          case 68: break;
+          case 31: 
+            { return symbol("String",TYPE, "String" );
+            }
+          case 69: break;
+          case 32: 
+            { return symbol("public",PUBLIC);
+            }
+          case 70: break;
+          case 33: 
+            { return symbol("method",METHOD);
+            }
+          case 71: break;
+          case 34: 
+            { return symbol("boolean",TYPE, "boolean" );
+            }
+          case 72: break;
+          case 35: 
+            { return symbol("requires",REQUIRES);
+            }
+          case 73: break;
+          case 36: 
+            { return symbol("interface",INTERFACE);
+            }
+          case 74: break;
+          case 37: 
+            { return symbol("capability",CAPABILITY);
+            }
+          case 75: break;
+          case 38: 
+            { return symbol("description",DESCRIPTION);
+            }
+          case 76: break;
+          default:
+            zzScanError(ZZ_NO_MATCH);
+        }
+      }
+    }
+  }
+
+
+}
diff --git a/iotjava/iotpolicy/parser/Parser.java b/iotjava/iotpolicy/parser/Parser.java
new file mode 100644 (file)
index 0000000..f06a0b9
--- /dev/null
@@ -0,0 +1,777 @@
+package iotpolicy.parser;
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11b 20160615 (GIT 4ac7450)
+//----------------------------------------------------
+
+import java_cup.runtime.ComplexSymbolFactory;
+import java_cup.runtime.ScannerBuffer;
+import java_cup.runtime.XMLElement;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.*;
+import javax.xml.transform.*;
+import javax.xml.transform.stream.*;
+import java_cup.runtime.XMLElement;
+
+import iotpolicy.tree.ParseNode;
+import iotpolicy.tree.ParseNodeVector;
+
+/** CUP v0.11b 20160615 (GIT 4ac7450) generated parser.
+  */
+@SuppressWarnings({"rawtypes"})
+public class Parser extends java_cup.runtime.lr_parser {
+
+ public final Class getSymbolContainer() {
+    return sym.class;
+}
+
+  /** Default constructor. */
+  @Deprecated
+  public Parser() {super();}
+
+  /** Constructor which sets the default scanner. */
+  @Deprecated
+  public Parser(java_cup.runtime.Scanner s) {super(s);}
+
+  /** Constructor which sets the default scanner. */
+  public Parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);}
+
+  /** Production table. */
+  protected static final short _production_table[][] = 
+    unpackFromStrings(new String[] {
+    "\000\032\000\002\002\005\000\002\002\004\000\002\003" +
+    "\010\000\002\003\002\000\002\004\004\000\002\004\002" +
+    "\000\002\005\011\000\002\006\004\000\002\006\002\000" +
+    "\002\007\005\000\002\007\004\000\002\007\005\000\002" +
+    "\007\004\000\002\010\004\000\002\010\002\000\002\011" +
+    "\011\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" });
+
+  /** Access to production table. */
+  public short[][] production_table() {return _production_table;}
+
+  /** Parse-action table. */
+  protected static final short[][] _action_table = 
+    unpackFromStrings(new String[] {
+    "\000\070\000\012\002\ufffe\014\005\016\ufffe\021\ufffe\001" +
+    "\002\000\010\002\ufff3\016\ufff3\021\ufff3\001\002\000\004" +
+    "\015\010\001\002\000\004\002\007\001\002\000\004\002" +
+    "\000\001\002\000\004\025\011\001\002\000\004\011\012" +
+    "\001\002\000\006\012\ufffc\014\ufffc\001\002\000\006\012" +
+    "\016\014\015\001\002\000\006\012\ufffd\014\ufffd\001\002" +
+    "\000\004\024\017\001\002\000\010\002\uffff\016\uffff\021" +
+    "\uffff\001\002\000\004\025\020\001\002\000\004\007\021" +
+    "\001\002\000\010\010\ufff9\024\ufff9\025\ufff9\001\002\000" +
+    "\010\010\025\024\026\025\023\001\002\000\004\025\032" +
+    "\001\002\000\010\010\ufffa\024\ufffa\025\ufffa\001\002\000" +
+    "\004\004\031\001\002\000\004\025\027\001\002\000\012" +
+    "\005\030\010\ufff7\024\ufff7\025\ufff7\001\002\000\010\010" +
+    "\ufff8\024\ufff8\025\ufff8\001\002\000\006\012\ufffb\014\ufffb" +
+    "\001\002\000\012\005\033\010\ufff5\024\ufff5\025\ufff5\001" +
+    "\002\000\010\010\ufff6\024\ufff6\025\ufff6\001\002\000\010" +
+    "\002\uffec\016\037\021\uffec\001\002\000\010\002\ufff4\016" +
+    "\ufff4\021\ufff4\001\002\000\006\002\001\021\057\001\002" +
+    "\000\004\025\040\001\002\000\004\006\041\001\002\000" +
+    "\004\025\042\001\002\000\004\011\043\001\002\000\010" +
+    "\012\ufff0\017\ufff0\020\ufff0\001\002\000\010\012\047\017" +
+    "\046\020\050\001\002\000\010\012\ufff1\017\ufff1\020\ufff1" +
+    "\001\002\000\004\013\054\001\002\000\010\002\ufff2\016" +
+    "\ufff2\021\ufff2\001\002\000\004\013\051\001\002\000\004" +
+    "\025\052\001\002\000\004\004\053\001\002\000\010\012" +
+    "\uffee\017\uffee\020\uffee\001\002\000\004\026\055\001\002" +
+    "\000\004\004\056\001\002\000\010\012\uffef\017\uffef\020" +
+    "\uffef\001\002\000\004\025\061\001\002\000\006\002\uffed" +
+    "\021\uffed\001\002\000\004\022\062\001\002\000\010\005" +
+    "\uffe8\023\uffe8\025\063\001\002\000\006\005\uffea\023\uffea" +
+    "\001\002\000\006\005\065\023\066\001\002\000\004\025" +
+    "\072\001\002\000\004\015\067\001\002\000\004\025\070" +
+    "\001\002\000\004\004\071\001\002\000\006\002\uffeb\021" +
+    "\uffeb\001\002\000\006\005\uffe9\023\uffe9\001\002" });
+
+  /** Access to parse-action table. */
+  public short[][] action_table() {return _action_table;}
+
+  /** <code>reduce_goto</code> table. */
+  protected static final short[][] _reduce_table = 
+    unpackFromStrings(new String[] {
+    "\000\070\000\006\002\005\003\003\001\001\000\004\010" +
+    "\033\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" +
+    "\012\001\001\000\004\005\013\001\001\000\002\001\001" +
+    "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
+    "\002\001\001\000\004\006\021\001\001\000\004\007\023" +
+    "\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" +
+    "\006\011\034\014\035\001\001\000\002\001\001\000\004" +
+    "\015\057\001\001\000\002\001\001\000\002\001\001\000" +
+    "\002\001\001\000\002\001\001\000\004\012\043\001\001" +
+    "\000\004\013\044\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\002" +
+    "\001\001\000\002\001\001\000\004\016\063\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" });
+
+  /** Access to <code>reduce_goto</code> table. */
+  public short[][] reduce_table() {return _reduce_table;}
+
+  /** Instance of action encapsulation class. */
+  protected CUP$Parser$actions action_obj;
+
+  /** Action encapsulation object initializer. */
+  protected void init_actions()
+    {
+      action_obj = new CUP$Parser$actions(this);
+    }
+
+  /** Invoke a user supplied parse action. */
+  public java_cup.runtime.Symbol do_action(
+    int                        act_num,
+    java_cup.runtime.lr_parser parser,
+    java.util.Stack            stack,
+    int                        top)
+    throws java.lang.Exception
+  {
+    /* call code in generated class */
+    return action_obj.CUP$Parser$do_action(act_num, parser, stack, top);
+  }
+
+  /** Indicates start state. */
+  public int start_state() {return 0;}
+  /** Indicates start production. */
+  public int start_production() {return 1;}
+
+  /** <code>EOF</code> Symbol index. */
+  public int EOF_sym() {return 0;}
+
+  /** <code>error</code> Symbol index. */
+  public int error_sym() {return 1;}
+
+
+
+  public Parser(Lexer lex, ComplexSymbolFactory sf) {
+    super(lex,sf);
+  }
+  public static void main(String[] args) throws Exception {
+      // initialize the symbol factory
+      ComplexSymbolFactory csf = new ComplexSymbolFactory();
+      // create a buffering scanner wrapper
+      ScannerBuffer lexer = new ScannerBuffer(new Lexer(new BufferedReader(new FileReader(args[0])),csf));
+      // start parsing
+      Parser p = new Parser(lexer,csf);
+      ParseNode pn = (ParseNode) p.parse().value;
+
+      //System.out.println("INTERFACE: ");
+      System.out.println(pn);
+      ParseNodeVector pnv = pn.getChildren();
+      /*System.out.println("Children: " + pnv.size());
+      ParseNode pnIntChild = pnv.elementAt(0);
+      System.out.println("Child 1: " + pnIntChild.getLabel());
+      System.out.println("Child 1: " + pnIntChild.getLiteral());
+      System.out.println();
+
+      ParseNodeVector pnIntChildren = pnIntChild.getChildren();
+      System.out.println("Grand children: " + pnIntChildren.size());
+      ParseNode pnIntGrandChild1 = pnIntChildren.elementAt(0);
+      System.out.println("Child 1: " + pnIntGrandChild1.getLabel());
+      System.out.println("Child 1: " + pnIntGrandChild1.getLiteral());
+      System.out.println("Great grand children: " + pnIntGrandChild1.getChildren().size());
+      System.out.println();
+
+      ParseNode pnIntGrandChild2 = pnIntChildren.elementAt(1);
+      System.out.println("Child 2: " + pnIntGrandChild2.getLabel());
+      System.out.println("Child 2: " + pnIntGrandChild2.getLiteral());
+      System.out.println("Great grand children: " + pnIntGrandChild2.getChildren().size());
+      System.out.println();
+      System.out.println();*/
+
+      System.out.println("CAPABILITIES: ");
+      ParseNode pnCapabChild = pnv.elementAt(1);
+      System.out.println("Child 2: " + pnv.elementAt(1).getLabel());
+      System.out.println("Child 2: " + pnv.elementAt(1).getLiteral());
+      ParseNodeVector pnvCap = pnCapabChild.getChildren();
+      System.out.println("Grand children: " + pnvCap.size());
+      ParseNode pnCapGrandChild1 = pnvCap.elementAt(0);
+      System.out.println("Child 1: " + pnCapGrandChild1.getLabel());
+      System.out.println("Child 1: " + pnCapGrandChild1.getLiteral());
+      ParseNodeVector pnvCap2 = pnCapGrandChild1.getChildren();
+      System.out.println("Great grand children: " + pnvCap2.size());
+      ParseNode pnCapGreatGrandChild1 = pnvCap2.elementAt(0);
+      System.out.println("Great grand Child 1: " + pnCapGreatGrandChild1.getLabel());
+      System.out.println("Great grand Child 1: " + pnCapGreatGrandChild1.getLiteral());
+      ParseNode pnCapGreatGrandChild2 = pnvCap2.elementAt(1);
+      System.out.println("Great grand Child 2: " + pnCapGreatGrandChild2.getLabel());
+      System.out.println("Great grand Child 2: " + pnCapGreatGrandChild2.getLiteral());
+      ParseNode pnCapGreatGrandChild3 = pnvCap2.elementAt(2);
+      System.out.println("Great grand Child 3: " + pnCapGreatGrandChild3.getLabel());
+      System.out.println("Great grand Child 3: " + pnCapGreatGrandChild3.getLiteral());
+      ParseNodeVector pnvCap3 = pnCapGreatGrandChild3.getChildren();
+      System.out.println("Great great grand children: " + pnvCap3.size());
+      ParseNode pnCapGreatGreatGrandChild1 = pnvCap3.elementAt(0);
+      System.out.println("Great great grand Child 1: " + pnCapGreatGreatGrandChild1.getLabel());
+      System.out.println("Great great grand Child 1: " + pnCapGreatGreatGrandChild1.getLiteral());
+      ParseNodeVector pnvDesc = pnCapGreatGreatGrandChild1.getChildren();
+      System.out.println("Great great great grand children: " + pnvDesc.size());
+      ParseNode pnDesc = pnvDesc.elementAt(0);
+      System.out.println("Description: " + pnDesc.getLabel());
+      System.out.println("Description: " + pnDesc.getLiteral());
+
+
+      ParseNode pnCapGreatGreatGrandChild2 = pnvCap3.elementAt(1);
+      System.out.println("Great great grand Child 2: " + pnCapGreatGreatGrandChild2.getLabel());
+      System.out.println("Great great grand Child 2: " + pnCapGreatGreatGrandChild2.getLiteral());
+      ParseNode pnCapGreatGreatGrandChild3 = pnvCap3.elementAt(2);
+      System.out.println("Great great grand Child 3: " + pnCapGreatGreatGrandChild3.getLabel());
+      System.out.println("Great great grand Child 3: " + pnCapGreatGreatGrandChild3.getLiteral());
+      ParseNode pnCapGreatGreatGrandChild4 = pnvCap3.elementAt(3);
+      System.out.println("Great great grand Child 4: " + pnCapGreatGreatGrandChild4.getLabel());
+      System.out.println("Great great grand Child 4: " + pnCapGreatGreatGrandChild4.getLiteral());
+
+      System.out.println();
+
+      /*System.out.println("REQUIRES: ");
+      ParseNode pnReqChild = pnv.elementAt(2);
+      System.out.println("Child 3: " + pnv.elementAt(2).getLabel());
+      System.out.println("Child 3: " + pnv.elementAt(2).getLiteral());
+      ParseNodeVector pnvReq = pnReqChild.getChildren();
+      System.out.println("Grand children: " + pnvReq.size());
+      ParseNode pnReqGrandChild = pnvReq.elementAt(0);
+      System.out.println("Grand Child 1: " + pnReqGrandChild.getLabel());
+      System.out.println("Grand Child 1: " + pnReqGrandChild.getLiteral());
+      ParseNodeVector pnvReqGrand = pnReqGrandChild.getChildren();
+      System.out.println("Grand children: " + pnvReqGrand.size());
+      ParseNode pnReqGreatGrandChild = pnvReqGrand.elementAt(0);
+      System.out.println("Great grand Child 1: " + pnReqGreatGrandChild.getLabel());
+      System.out.println("Great grand Child 1: " + pnReqGreatGrandChild.getLiteral());
+      ParseNode pnReqGreatGrandChild2 = pnvReqGrand.elementAt(1);
+      System.out.println("Great grand Child 2: " + pnReqGreatGrandChild2.getLabel());
+      System.out.println("Great grand Child 2: " + pnReqGreatGrandChild2.getLiteral());
+      ParseNodeVector pnvCapList = pnReqGreatGrandChild2.getChildren();
+      System.out.println("Grand children: " + pnvCapList.size());
+      ParseNode pnReqGreatGreatGrandChild2 = pnvCapList.elementAt(0);
+      System.out.println("Great great grand Child 2: " + pnReqGreatGreatGrandChild2.getLabel());
+      System.out.println("Great great grand Child 2: " + pnReqGreatGreatGrandChild2.getLiteral());
+
+      ParseNode pnReqGreatGrandChild3 = pnvReqGrand.elementAt(2);
+      System.out.println("Great grand Child 3: " + pnReqGreatGrandChild3.getLabel());
+      System.out.println("Great grand Child 3: " + pnReqGreatGrandChild3.getLiteral());
+
+
+      //ParseNodeVector pnvReqGreatGrand = pnReqGreatGrandChild2.getChildren();
+      //System.out.println("Grand children: " + pnvReqGreatGrand.size());
+      System.out.println();*/
+
+  }
+
+
+/** Cup generated class to encapsulate user supplied action code.*/
+@SuppressWarnings({"rawtypes", "unchecked", "unused"})
+class CUP$Parser$actions {
+  private final Parser parser;
+
+  /** Constructor */
+  CUP$Parser$actions(Parser parser) {
+    this.parser = parser;
+  }
+
+  /** Method 0 with the actual generated action code for actions 0 to 300. */
+  public final java_cup.runtime.Symbol CUP$Parser$do_action_part00000000(
+    int                        CUP$Parser$act_num,
+    java_cup.runtime.lr_parser CUP$Parser$parser,
+    java.util.Stack            CUP$Parser$stack,
+    int                        CUP$Parser$top)
+    throws java.lang.Exception
+    {
+      /* Symbol object for return from actions */
+      java_cup.runtime.Symbol CUP$Parser$result;
+
+      /* select the action based on the action number */
+      switch (CUP$Parser$act_num)
+        {
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 0: // policy ::= intface capablist reqlist 
+            {
+              ParseNode RESULT =null;
+               int inleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
+               int inright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).right;
+               ParseNode in = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
+               int capleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int capright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               ParseNode cap = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               int rlleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
+               int rlright = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).right;
+               ParseNode rl = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
+               
+               ParseNode pn = new ParseNode("policy");
+               pn.addChild(in);
+               pn.addChild(cap);
+               pn.addChild(rl);
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("policy",0, ((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;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 1: // $START ::= policy EOF 
+            {
+              Object RESULT =null;
+               int start_valleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int start_valright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               ParseNode start_val = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               RESULT = start_val;
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+            }
+          /* ACCEPT */
+          CUP$Parser$parser.done_parsing();
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 2: // intface ::= PUBLIC INTERFACE IDENT BEGIN methlist END 
+            {
+              ParseNode RESULT =null;
+               int idintleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
+               int idintright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).right;
+               Object idint = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-3)).value;
+               int mlleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int mlright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               ParseNode ml = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               
+               ParseNode pn = new ParseNode("interface");
+               pn.addChild("intface_ident").setLiteral(idint);
+               pn.addChild(ml);
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("intface",1, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 3: // intface ::= 
+            {
+              ParseNode RESULT =null;
+               
+               ParseNode pn = new ParseNode("interface");
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("intface",1, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 4: // methlist ::= methlist meth 
+            {
+              ParseNode RESULT =null;
+               int mlleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int mlright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               ParseNode ml = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               int mleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
+               int mright = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).right;
+               ParseNode m = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
+               
+               ml.addChild(m);
+               RESULT = ml;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("methlist",2, ((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;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 5: // methlist ::= 
+            {
+              ParseNode RESULT =null;
+               
+               ParseNode pn = new ParseNode("method_list");
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("methlist",2, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 6: // meth ::= PUBLIC TYPE IDENT LPAR paramlist RPAR SEMICOLON 
+            {
+              ParseNode RESULT =null;
+               int typemethleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).left;
+               int typemethright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).right;
+               Object typemeth = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-5)).value;
+               int idmethleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).left;
+               int idmethright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).right;
+               Object idmeth = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-4)).value;
+               int plleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
+               int plright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).right;
+               ParseNode pl = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
+               
+               ParseNode pn = new ParseNode("method");
+               pn.addChild("method_type").setLiteral(typemeth);
+               pn.addChild("method_ident").setLiteral(idmeth);
+               pn.addChild(pl);
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("meth",3, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 7: // paramlist ::= paramlist param 
+            {
+              ParseNode RESULT =null;
+               int plleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int plright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               ParseNode pl = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               int pleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
+               int pright = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).right;
+               ParseNode p = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
+               
+               pl.addChild(p);
+               RESULT = pl;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("paramlist",4, ((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;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 8: // paramlist ::= 
+            {
+              ParseNode RESULT =null;
+               
+               ParseNode pn = new ParseNode("param_list");
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("paramlist",4, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 9: // param ::= TYPE IDENT COMMA 
+            {
+              ParseNode RESULT =null;
+               int typeprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
+               int typeprmright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).right;
+               Object typeprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
+               int idprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int idprmright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               Object idprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               
+               ParseNode pn = new ParseNode("param");
+               pn.addChild("param_type").setLiteral(typeprm);
+               pn.addChild("param_ident").setLiteral(idprm);
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("param",5, ((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;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 10: // param ::= TYPE IDENT 
+            {
+              ParseNode RESULT =null;
+               int typeprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int typeprmright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               Object typeprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               int idprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
+               int idprmright = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).right;
+               Object idprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
+               
+               ParseNode pn = new ParseNode("param");
+               pn.addChild("param_type").setLiteral(typeprm);
+               pn.addChild("param_ident").setLiteral(idprm);
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("param",5, ((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;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 11: // param ::= IDENT IDENT COMMA 
+            {
+              ParseNode RESULT =null;
+               int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
+               int clsprmright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).right;
+               Object clsprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
+               int idprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int idprmright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               Object idprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               
+               ParseNode pn = new ParseNode("param");
+               pn.addChild("param_class").setLiteral(clsprm);
+               pn.addChild("param_ident").setLiteral(idprm);
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("param",5, ((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;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 12: // param ::= IDENT IDENT 
+            {
+              ParseNode RESULT =null;
+               int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int clsprmright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               Object clsprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               int idprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
+               int idprmright = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).right;
+               Object idprm = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
+               
+               ParseNode pn = new ParseNode("param");
+               pn.addChild("param_class").setLiteral(clsprm);
+               pn.addChild("param_ident").setLiteral(idprm);
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("param",5, ((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;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 13: // capablist ::= capablist capab 
+            {
+              ParseNode RESULT =null;
+               int clistleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int clistright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               ParseNode clist = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               int capleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
+               int capright = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).right;
+               ParseNode cap = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
+               
+               clist.addChild(cap);
+               RESULT = clist;
+       
+              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);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 14: // capablist ::= 
+            {
+              ParseNode RESULT =null;
+               
+               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);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 15: // capab ::= CAPABILITY IDENT DOT IDENT BEGIN capabcont END 
+            {
+              ParseNode RESULT =null;
+               int idintleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).left;
+               int idintright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).right;
+               Object idint = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-5)).value;
+               int idcapleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
+               int idcapright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).right;
+               Object idcap = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-3)).value;
+               int ccontleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int ccontright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               ParseNode ccont = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               
+               ParseNode pn = new ParseNode("capability");
+               pn.addChild("intface_ident").setLiteral(idint);
+               pn.addChild("capab_ident").setLiteral(idcap);
+               pn.addChild(ccont);
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("capab",7, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 16: // capabcont ::= capabcont cont 
+            {
+              ParseNode RESULT =null;
+               int ccontleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int ccontright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               ParseNode ccont = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               int cntleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
+               int cntright = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).right;
+               ParseNode cnt = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
+               
+               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);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 17: // capabcont ::= 
+            {
+              ParseNode RESULT =null;
+               
+               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);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 18: // cont ::= DESCRIPTION ASSIGN STRINGCONST SEMICOLON 
+            {
+              ParseNode RESULT =null;
+               int dscleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
+               int dscright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).right;
+               Object dsc = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-3)).value;
+               int strleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int strright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               Object str = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               
+               ParseNode pn = new ParseNode("capab_content");
+               pn.addChild("capab_desc").setLiteral(str);
+               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);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 19: // cont ::= METHOD ASSIGN IDENT SEMICOLON 
+            {
+              ParseNode RESULT =null;
+               int mtdleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
+               int mtdright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).right;
+               Object mtd = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-3)).value;
+               int idmethleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int idmethright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               Object idmeth = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               
+               ParseNode pn = new ParseNode("capab_content");
+               pn.addChild("capab_ident").setLiteral(idmeth);
+               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);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 20: // reqlist ::= reqlist require 
+            {
+              ParseNode RESULT =null;
+               int rlleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int rlright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               ParseNode rl = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               int reqleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
+               int reqright = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).right;
+               ParseNode req = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
+               
+               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);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 21: // reqlist ::= 
+            {
+              ParseNode RESULT =null;
+               
+               ParseNode pn = new ParseNode("requires_list");
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("reqlist",10, ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 22: // require ::= REQUIRES IDENT WITH capintlist AS INTERFACE IDENT SEMICOLON 
+            {
+              ParseNode RESULT =null;
+               int idintleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).left;
+               int idintright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).right;
+               Object idint = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-6)).value;
+               int cilleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).left;
+               int cilright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).right;
+               ParseNode cil = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-4)).value;
+               int idnewintleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
+               int idnewintright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).right;
+               Object idnewint = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-1)).value;
+               
+               ParseNode pn = new ParseNode("requires");
+               pn.addChild("intface_ident").setLiteral(idint);
+               pn.addChild(cil);
+               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);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 23: // capintlist ::= IDENT 
+            {
+              ParseNode RESULT =null;
+               int idcapleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
+               int idcapright = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).right;
+               Object idcap = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
+               
+               ParseNode pn = new ParseNode("capab_ident_list");
+               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);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 24: // capintlist ::= capintlist COMMA IDENT 
+            {
+              ParseNode RESULT =null;
+               int cilleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
+               int cilright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).right;
+               ParseNode cil = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
+               int idcapleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
+               int idcapright = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).right;
+               Object idcap = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.peek()).value;
+               
+               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);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 25: // capintlist ::= 
+            {
+              ParseNode RESULT =null;
+               
+               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);
+            }
+          return CUP$Parser$result;
+
+          /* . . . . . .*/
+          default:
+            throw new Exception(
+               "Invalid action number "+CUP$Parser$act_num+"found in internal parse table");
+
+        }
+    } /* end of method */
+
+  /** Method splitting the generated action code into several parts. */
+  public final java_cup.runtime.Symbol CUP$Parser$do_action(
+    int                        CUP$Parser$act_num,
+    java_cup.runtime.lr_parser CUP$Parser$parser,
+    java.util.Stack            CUP$Parser$stack,
+    int                        CUP$Parser$top)
+    throws java.lang.Exception
+    {
+              return CUP$Parser$do_action_part00000000(
+                               CUP$Parser$act_num,
+                               CUP$Parser$parser,
+                               CUP$Parser$stack,
+                               CUP$Parser$top);
+    }
+}
+
+}
diff --git a/iotjava/iotpolicy/parser/sym.java b/iotjava/iotpolicy/parser/sym.java
new file mode 100644 (file)
index 0000000..3a5f6dc
--- /dev/null
@@ -0,0 +1,55 @@
+package iotpolicy.parser;
+
+//----------------------------------------------------
+// The following code was generated by CUP v0.11b 20160615 (GIT 4ac7450)
+//----------------------------------------------------
+
+/** CUP generated interface containing symbol constants. */
+public interface sym {
+  /* terminals */
+  public static final int IDENT = 19;
+  public static final int SEMICOLON = 2;
+  public static final int STRINGCONST = 20;
+  public static final int REQUIRES = 15;
+  public static final int END = 8;
+  public static final int CAPABILITY = 12;
+  public static final int AS = 17;
+  public static final int WITH = 16;
+  public static final int PUBLIC = 10;
+  public static final int BEGIN = 7;
+  public static final int TYPE = 18;
+  public static final int DESCRIPTION = 13;
+  public static final int COMMA = 3;
+  public static final int EOF = 0;
+  public static final int METHOD = 14;
+  public static final int error = 1;
+  public static final int DOT = 4;
+  public static final int INTERFACE = 11;
+  public static final int ASSIGN = 9;
+  public static final int RPAR = 6;
+  public static final int LPAR = 5;
+  public static final String[] terminalNames = new String[] {
+  "EOF",
+  "error",
+  "SEMICOLON",
+  "COMMA",
+  "DOT",
+  "LPAR",
+  "RPAR",
+  "BEGIN",
+  "END",
+  "ASSIGN",
+  "PUBLIC",
+  "INTERFACE",
+  "CAPABILITY",
+  "DESCRIPTION",
+  "METHOD",
+  "REQUIRES",
+  "WITH",
+  "AS",
+  "TYPE",
+  "IDENT",
+  "STRINGCONST"
+  };
+}
+
diff --git a/iotjava/iotpolicy/tree/CapabilityDecl.java b/iotjava/iotpolicy/tree/CapabilityDecl.java
new file mode 100644 (file)
index 0000000..71ec2ca
--- /dev/null
@@ -0,0 +1,140 @@
+package iotpolicy.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/** Class CapabilityDecl is a data structure for capability
+ *  declaration section (list of capabilities) in the policy file.
+ *
+ * @author      Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
+ * @version     1.0
+ * @since       2016-09-20
+ */
+public final class CapabilityDecl {
+
+       /**
+        * Class properties
+        */
+       private String origInt;
+
+       /**
+        * A "capability" statement:
+        *              capability Camera.ImageCapture {
+        *                      description = "The quick brown fox jumps over the smart dog";
+        *                      description = "Another description";
+        *                      method = MethodA;
+        *                      method = MethodB;
+        *              }
+        * In this data structure we will record its capability name, i.e. ImageCapture
+        *              and its descriptions and methods.
+        */
+       private List<String> listCapabs;                // list of capabilities
+       private List<List<String>> listDescs;   // list of descriptions
+       private List<List<String>> listMethods; // list of methods
+
+       /**
+        * Class constructors
+        */
+       public CapabilityDecl() {
+
+               origInt = null;
+               listCapabs = new ArrayList<String>();
+               listDescs = new ArrayList<List<String>>();
+               listMethods = new ArrayList<List<String>>();
+       }
+
+
+       public CapabilityDecl(String _origInt) {
+
+               origInt = _origInt;
+               listCapabs = new ArrayList<String>();
+               listDescs = new ArrayList<List<String>>();
+               listMethods = new ArrayList<List<String>>();
+       }
+
+
+       /**
+        * addNewCapability() adds a new capability into the list
+        */
+       public void addNewCapability(String newCap) {
+
+               listCapabs.add(newCap);
+               listDescs.add(new ArrayList<String>());
+               listMethods.add(new ArrayList<String>());
+       }
+
+
+       /**
+        * addNewDescription() adds a new description into the list
+        */
+       public void addNewDescription(String cap, String newDesc) {
+
+               int index = listCapabs.indexOf(cap);
+               List<String> listDesc = listDescs.get(index);
+               listDesc.add(newDesc);
+       }
+
+
+       /**
+        * addNewMethod() adds a new method into the list
+        */
+       public void addNewMethod(String cap, String newMethod) {
+
+               int index = listCapabs.indexOf(cap);
+               List<String> listMethod = listMethods.get(index);
+               listMethod.add(newMethod);
+       }
+
+
+       /**
+        * getCapabilities() gets list of capabilities
+        */
+       public List<String> getCapabilities() {
+
+               return listCapabs;
+       }
+
+
+       /**
+        * getDescriptions() gets list of descriptions
+        */
+       public List<String> getDescriptions(String cap) {
+
+               int index = listCapabs.indexOf(cap);
+               return listDescs.get(index);
+       }
+
+
+       /**
+        * getMethods() gets list of methods
+        */
+       public List<String> getMethods(String cap) {
+
+               int index = listCapabs.indexOf(cap);
+               return listMethods.get(index);
+       }
+
+
+       public static void main(String[] args) {
+
+               CapabilityDecl cd = new CapabilityDecl("Camera");
+               cd.addNewCapability("ImageCapture");
+               cd.addNewDescription("ImageCapture", "The quick brown fox jumps over the smart dog");
+               cd.addNewDescription("ImageCapture", "ImageCapture capability");
+               cd.addNewMethod("ImageCapture", "MethodA");
+               cd.addNewMethod("ImageCapture", "MethodC");
+               cd.addNewMethod("ImageCapture", "MethodD");
+
+               cd.addNewCapability("VideoRecording");
+               cd.addNewDescription("VideoRecording", "The quick brown fox jumps over the smart dog");
+               cd.addNewDescription("VideoRecording", "VideoRecording ");
+               cd.addNewMethod("VideoRecording", "MethodE");
+               cd.addNewMethod("VideoRecording", "MethodF");
+
+               System.out.println("Set of capabilities: " + cd.getCapabilities().toString());
+               System.out.println("Set of descriptions: " + cd.getDescriptions("VideoRecording").toString());
+               System.out.println("Set of methods: " + cd.getMethods("VideoRecording").toString());
+               System.out.println("Set of descriptions: " + cd.getDescriptions("ImageCapture").toString());
+               System.out.println("Set of methods: " + cd.getMethods("ImageCapture").toString());
+       }
+}
diff --git a/iotjava/iotpolicy/tree/InterfaceDecl.java b/iotjava/iotpolicy/tree/InterfaceDecl.java
new file mode 100644 (file)
index 0000000..27e9326
--- /dev/null
@@ -0,0 +1,157 @@
+package iotpolicy.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/** Class InterfaceDecl is a data structure for interface
+ *  declaration section in the policy file.
+ *
+ * @author      Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
+ * @version     1.0
+ * @since       2016-09-20
+ */
+public final class InterfaceDecl {
+
+       /**
+        * Class properties
+        */
+       private String origInt;
+
+       /**
+        * A "interface" statement:
+        *              public interface Camera {
+     *                 public void MethodA(int A, int B);
+     *                 public int MethodB(int C, string D);
+     *                 public string MethodC(string E, int F);
+     *                 public float MethodD(int G, float H);
+     *                 public boolean MethodE(Camera I, boolean J);
+     *                 public void MethodF();
+        *              }
+        * In this data structure we will record its interface name, i.e. Camera
+        *              its method names and the parameters for each method.
+        */
+       private List<String> listMethods;                                       // Method names, e.g. MethodA
+       private List<String> listMethodTypes;                           // Method types, e.g. void
+       private List<List<String>> listMethodParams;            // Method parameter names, e.g. A, B
+       private List<List<String>> listMethodParamTypes;        // Method parameter types, e.g. int, int
+
+       /**
+        * Class constructors
+        */
+       public InterfaceDecl() {
+
+               origInt = null;
+               listMethods = new ArrayList<String>();
+               listMethodTypes = new ArrayList<String>();
+               listMethodParams = new ArrayList<List<String>>();
+               listMethodParamTypes = new ArrayList<List<String>>();
+       }
+
+
+       public InterfaceDecl(String _origInt) {
+
+               origInt = _origInt;
+               listMethods = new ArrayList<String>();
+               listMethodTypes = new ArrayList<String>();
+               listMethodParams = new ArrayList<List<String>>();
+               listMethodParamTypes = new ArrayList<List<String>>();
+       }
+
+
+       /**
+        * addNewMethod() adds a new method name and type into the list
+        */
+       public void addNewMethod(String newMethod, String newMethodType) {
+
+               listMethods.add(newMethod);
+               listMethodTypes.add(newMethodType);
+               listMethodParams.add(new ArrayList<String>());
+               listMethodParamTypes.add(new ArrayList<String>());
+       }
+
+
+       /**
+        * addMethodParam() adds the name and type of a parameter
+        */
+       public void addMethodParam(String method, String paramName, String paramType) {
+
+               int index = listMethods.indexOf(method);
+               List<String> listMethodParam = listMethodParams.get(index);
+               listMethodParam.add(paramName);
+               List<String> listMethodParamType = listMethodParamTypes.get(index);
+               listMethodParamType.add(paramType);
+       }
+
+
+       /**
+        * getMethods() gets list of methods
+        */
+       public List<String> getMethods() {
+
+               return listMethods;
+       }
+       
+       
+       /**
+        * getMethodTypes() gets method types
+        */
+       public List<String> getMethodTypes() {
+
+               return listMethodTypes;
+       }
+
+
+       /**
+        * getMethodType() gets a method type
+        */
+       public String getMethodType(String method) {
+
+               int index = listMethods.indexOf(method);
+               return listMethodTypes.get(index);
+       }
+
+
+       /**
+        * getMethodParams() gets list of method parameters for a method
+        */
+       public List<String> getMethodParams(String method) {
+
+               int index = listMethods.indexOf(method);
+               return listMethodParams.get(index);
+       }
+       
+
+       /**
+        * getMethodParams() gets list of method parameter types for a method
+        */
+       public List<String> getMethodParamTypes(String method) {
+
+               int index = listMethods.indexOf(method);
+               return listMethodParamTypes.get(index);
+       }
+
+
+       public static void main(String[] args) {
+
+               InterfaceDecl id = new InterfaceDecl("Camera");
+               id.addNewMethod("MethodA", "void");
+               id.addNewMethod("MethodB", "int");
+               id.addNewMethod("MethodC", "String");
+               id.addMethodParam("MethodA", "A", "int");
+               id.addMethodParam("MethodA", "B", "int");
+               id.addMethodParam("MethodB", "C", "int");
+               id.addMethodParam("MethodB", "D", "string");
+               id.addMethodParam("MethodC", "E", "string");
+               id.addMethodParam("MethodC", "F", "int");
+
+
+
+               System.out.println("Set of methods: " + id.getMethods().toString());
+               System.out.println("Set of params: " + id.getMethodParams("MethodA").toString());
+               System.out.println("Set of paramtypes: " + id.getMethodParamTypes("MethodA").toString());
+               System.out.println("Set of params: " + id.getMethodParams("MethodB").toString());
+               System.out.println("Set of paramtypes: " + id.getMethodParamTypes("MethodB").toString());
+               System.out.println("Set of params: " + id.getMethodParams("MethodC").toString());
+               System.out.println("Set of paramtypes: " + id.getMethodParamTypes("MethodC").toString());
+       }
+}
diff --git a/iotjava/iotpolicy/tree/ParseNode.java b/iotjava/iotpolicy/tree/ParseNode.java
new file mode 100644 (file)
index 0000000..75ade8e
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+
+   Class: ParseNode
+   Author: Dan Roy
+   Purpose: ParseNode is used to represent a parse production
+
+ */
+
+package iotpolicy.tree;
+
+import java.util.*;
+
+public class ParseNode implements Walkable {
+
+  private String label;
+  private ParseNode parent;
+  private ParseNodeVector children;
+  private int line;
+  private Object literal;
+
+  //private SymbolTable st;
+
+  public ParseNode(String label) {
+    this.label = label;
+    this.line = -1;
+    this.parent = null;
+    this.literal=null;
+    children = new ParseNodeVector();
+  }
+
+  public ParseNode (String label, int line) {
+    this.label = label;
+    this.line = line;
+    this.parent = null;
+    this.literal=null;
+    children = new ParseNodeVector();
+  }
+
+  public void setLabel(String label) {
+    this.label = label;
+  }
+
+  public String getLabel() {
+    return label;
+  }
+
+  public void setLiteral(Object o) {
+    literal=o;
+  }
+
+  public Object getLiteral() {
+    return literal;
+  }
+
+  /*
+     public void setSymbolTable(SymbolTable st) {
+      if (st == null) {
+          throw new IRException("symboltable is null!");
+      }
+      this.st = st;
+     }
+
+     public SymbolTable getSymbolTable() {
+      if (st == null) {
+          if (parent != null) {
+              return parent.getSymbolTable();
+          } else {
+              return null;
+          }
+      } else {
+          return st;
+      }
+     }
+   */
+
+  public int getLine() {
+    if (line >= 0) {
+      return line;
+    } else {
+      if (parent != null) {
+        return parent.getLine();
+      } else {
+        return 0;
+      }
+    }
+  }
+
+  public void setParent(ParseNode parent) {
+    this.parent = parent;
+  }
+
+  public ParseNode getParent() {
+    return parent;
+  }
+
+  public ParseNode insertChild(ParseNode child) {
+    if (child == null) {
+      throw new NullPointerException("Can't add null node to parse tree");
+    }
+
+    children.insertElementAt(child, 0);
+    child.setParent(this);
+    return child;
+  }
+
+  public ParseNode insertChild(String newlabel) {
+    ParseNode child = new ParseNode(newlabel, -1);
+    return insertChild(child);
+  }
+
+  public ParseNode addChild(ParseNode child) {
+
+    if (child == null) {
+      throw new NullPointerException("Can't add null node to parse tree: "+getLabel());
+    }
+
+    children.addElement(child);
+    child.setParent(this);
+    return child;
+  }
+
+  public ParseNode addChild(String newlabel) {
+
+    ParseNode child = new ParseNode(newlabel, -1);
+    children.addElement(child);
+    child.setParent(this);
+    return child;
+  }
+
+  public ParseNode addChild(String newlabel, int line) {
+    ParseNode child = new ParseNode(newlabel, line);
+    children.addElement(child);
+    child.setParent(this);
+    return child;
+  }
+
+  public ParseNodeVector getChildren() {
+    return children;
+  }
+
+  public ParseNode getChild(String label) {
+    int i;
+    ParseNode p;
+
+    for (i = 0; i < children.size(); i++) {
+      p = children.elementAt(i);
+      if (p.getLabel().equals(label)) {
+        return p;
+      }
+    }
+
+    return null;
+  }
+
+  public ParseNode getRoot() {
+    return (parent == null)?this:parent.getRoot();
+  }
+
+  public String getTerminal() {
+    ParseNode pn = children.elementAt(0);
+    if (pn == null) {
+      return null;
+    } else {
+      return pn.getLabel();
+    }
+  }
+
+  public ParseNode getFirstChild() {
+    return children.elementAt(0);
+  }
+
+  public ParseNodeVector getChildren(String label) {
+    int i;
+    ParseNodeVector v = new ParseNodeVector();
+
+    for (i = 0; i < children.size(); i++) {
+      ParseNode pn = children.elementAt(i);
+      if (pn.getLabel().equals(label))
+        v.addElement(pn);
+    }
+
+    return v;
+  }
+
+  public String getNodeName() {
+    return label + " - " + getLine();
+  }
+
+  public int getNeighborCount() {
+    return children.size();
+  }
+
+  public Object getNeighbor(int index) {
+    return children.elementAt(index);
+  }
+
+  public String doIndent(int indent) {
+
+    String output = new String();
+    for(int i=0; i<indent; i++) output += " ";
+    return output;
+  }
+
+  public String PPrint(int indent, boolean recursive) {
+
+    String output = new String();
+
+    if (children.size()==0) {
+      output += doIndent(indent) + "<" + label + "/>\n";
+    } else {
+      output += doIndent(indent) + "<" + label + ">\n";
+      indent += 2;
+
+      if (recursive) {
+        for (int i = 0; i < children.size(); i++) {
+          Walkable w = (Walkable)children.elementAt(i);
+          output += w.PPrint(indent, true);
+        }
+      } else {
+        for (int i = 0; i < children.size(); i++) {
+          Walkable w = (Walkable)children.elementAt(i);
+          output += doIndent(indent) + "<" + w.getNodeName() + "/>\n";
+        }
+      }
+
+      indent -= 2;
+      output += doIndent(indent) + "</" + label + ">\n";
+    }
+
+    return output;
+  }
+
+}
+
diff --git a/iotjava/iotpolicy/tree/ParseNodeVector.java b/iotjava/iotpolicy/tree/ParseNodeVector.java
new file mode 100644 (file)
index 0000000..29c95dc
--- /dev/null
@@ -0,0 +1,27 @@
+package iotpolicy.tree;
+
+import java.util.Vector;
+
+public class ParseNodeVector {
+  private Vector v;
+
+  public ParseNodeVector() {
+    v = new Vector();
+  }
+
+  public void addElement(ParseNode pn) {
+    v.addElement(pn);
+  }
+
+  public void insertElementAt(ParseNode pn, int n) {
+    v.insertElementAt(pn, n);
+  }
+
+  public ParseNode elementAt(int i) {
+    return (ParseNode) v.elementAt(i);
+  }
+
+  public int size() {
+    return v.size();
+  }
+}
diff --git a/iotjava/iotpolicy/tree/ParseTreeHandler.java b/iotjava/iotpolicy/tree/ParseTreeHandler.java
new file mode 100644 (file)
index 0000000..69a36c2
--- /dev/null
@@ -0,0 +1,257 @@
+package iotpolicy.tree;
+
+import java_cup.runtime.ComplexSymbolFactory;
+import java_cup.runtime.ScannerBuffer;
+import java.io.*;
+import iotpolicy.tree.ParseNodeVector;
+import iotpolicy.tree.ParseNode;
+
+/** Class ParseTreeHandler handles the parse tree generated by the 
+ *  parser (and lexer) from the policy file. 
+ *  This class accepts the AST in the form of XMLElement class object.
+ *  It gives interfaces to extract the 3 sections of a policy file:
+ *  1) Interface
+ *  2) Capability list
+ *  3) Generated interface list
+ *
+ * @author      Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
+ * @version     1.0
+ * @since       2016-09-20
+ */
+public final class ParseTreeHandler {
+
+       /**
+        * Class properties
+        */
+       private ParseNode pn;
+       private InterfaceDecl intDecl;
+       private CapabilityDecl capDecl;
+       private RequiresDecl reqDecl;
+
+
+       /**
+        * Class constructors
+        */
+       public ParseTreeHandler() {
+
+               pn = null;
+               intDecl = new InterfaceDecl();
+               capDecl = new CapabilityDecl();
+               reqDecl = new RequiresDecl();
+       }
+
+
+       public ParseTreeHandler(String _intFace, ParseNode _pn) {
+
+               pn = _pn;
+               intDecl = new InterfaceDecl(_intFace);
+               capDecl = new CapabilityDecl(_intFace);
+               reqDecl = new RequiresDecl(_intFace);
+       }
+
+
+       /**
+        * processInterfaceDecl() processes interface declaration part
+        */
+       public void processInterfaceDecl() {
+
+               // Get the root - interface list (element 0)
+               ParseNodeVector pnv = pn.getChildren();
+               ParseNode pnRoot = pnv.elementAt(0);
+               // Get the second child of root for "method_list"
+               ParseNodeVector pnvGen2 = pnRoot.getChildren();
+               if (pnvGen2.size() == 0) {
+                       throw new Error("ParseTreeHandler: Interface declaration is missing! Please check your policy file...");
+               }
+               ParseNode pnGen2 = pnvGen2.elementAt(1);
+               // Get the next level child for methods
+               ParseNodeVector pnvGen3 = pnGen2.getChildren();
+               // Loop and extract methods
+               for(int i = 0; i < pnvGen3.size(); i++) {
+
+                       // Get the level where label is "method"
+                       ParseNode pnGen3 = pnvGen3.elementAt(i);
+                       // Get the next level child - method info
+                       ParseNodeVector pnvGen4 = pnGen3.getChildren();
+                       // Method type
+                       ParseNode pnGen4_type = pnvGen4.elementAt(0);
+                       // Method identifier
+                       ParseNode pnGen4_ident  = pnvGen4.elementAt(1);
+                       // Add a new method (type and identifier)
+                       intDecl.addNewMethod(pnGen4_ident.getLiteral().toString(), 
+                               pnGen4_type.getLiteral().toString());
+                       // Get the next level child - method params
+                       ParseNode pnGen4_params  = pnvGen4.elementAt(2);
+                       ParseNodeVector pnvGen5 = pnGen4_params.getChildren();
+                       for(int j = 0; j < pnvGen5.size(); j++) {
+
+                               ParseNode pnGen5 = pnvGen5.elementAt(j);
+                               ParseNodeVector pnvGen6 = pnGen5.getChildren();
+                               // Param type
+                               ParseNode pnGen6_type = pnvGen6.elementAt(0);
+                               // Param identifier
+                               ParseNode pnGen6_ident = pnvGen6.elementAt(1);
+                               // Add a new method param (type and identifier)
+                               intDecl.addMethodParam(pnGen4_ident.getLiteral().toString(),
+                                       pnGen6_ident.getLiteral().toString(), pnGen6_type.getLiteral().toString());
+                       }
+                       //System.out.println();
+               }
+       }
+
+
+       /**
+        * processCapabilityDecl() processes capability declaration part
+        */
+       public void processCapabilityDecl() {
+
+               // Get the root - capability list (element 1)
+               ParseNodeVector pnv = pn.getChildren();
+               ParseNode pnRoot = pnv.elementAt(1);
+               // Get the second child of root for "capab_list"
+               ParseNodeVector pnvGen2 = pnRoot.getChildren();
+               if (pnvGen2.size() == 0) {
+                       throw new Error("ParseTreeHandler: Capability declaration is missing! Please check your policy file...");
+               }
+               // Iterate over the list of capabilities
+               for(int i = 0; i < pnvGen2.size(); i++) {
+
+                       ParseNode pnGen2 = pnvGen2.elementAt(i);
+                       // Get the next level child for capabilities
+                       ParseNodeVector pnvGen3 = pnGen2.getChildren();
+                       // Get the capability name, e.g. ImageCapture for Camera.ImageCapture
+                       ParseNode pnGen3_capab = pnvGen3.elementAt(1);
+                       // Add new capability
+                       capDecl.addNewCapability(pnGen3_capab.getLiteral().toString());
+                       // Get the capability contents, i.e. descriptions and methods
+                       ParseNode pnGen3_capab_cont = pnvGen3.elementAt(2);
+                       ParseNodeVector pnvGen4 = pnGen3_capab_cont.getChildren();
+                       // Iterate over the list of capability contents
+                       for(int j = 0; j < pnvGen4.size(); j++) {
+
+                               ParseNode pnGen4 = pnvGen4.elementAt(j);
+                               ParseNodeVector pnvGen5 = pnGen4.getChildren();
+                               ParseNode pnGen5 = pnvGen5.elementAt(0);
+                               // Check the label and separate between description (capab_desc)
+                               // and method name (capab_ident)
+                               String label = pnGen5.getLabel().toString();
+                               if (label.equals("capab_desc")) {
+                                       capDecl.addNewDescription(pnGen3_capab.getLiteral().toString(),
+                                               pnGen5.getLiteral().toString());
+                               } else if (label.equals("capab_ident")) {
+                                       capDecl.addNewMethod(pnGen3_capab.getLiteral().toString(),
+                                               pnGen5.getLiteral().toString());                                
+                               } else
+                                       throw new Error("ParseTreeHandler: Unknown label '" + label + "' while operating on parse tree!");
+
+                       }
+               }
+       }
+
+
+       /**
+        * processRequiresDecl() processes "requires" declaration part
+        */
+       public void processRequiresDecl() {
+
+               // Get the root - requires list (element 2)
+               ParseNodeVector pnv = pn.getChildren();
+               ParseNode pnRoot = pnv.elementAt(2);
+               // Get the second child of root for "capab_list"
+               ParseNodeVector pnvGen2 = pnRoot.getChildren();
+               if (pnvGen2.size() == 0) {
+                       throw new Error("ParseTreeHandler: 'Requires' declaration is missing! Please check your policy file...");
+               }
+               // Iterate over the list of requires statements
+               for(int i = 0; i < pnvGen2.size(); i++) {
+
+                       ParseNode pnGen2 = pnvGen2.elementAt(i);
+                       ParseNodeVector pnvGen3 = pnGen2.getChildren();
+                       // Get the new interface that we want to generate
+                       ParseNode pnGen3_intface = pnvGen3.elementAt(2);
+                       reqDecl.addNewIntface(pnGen3_intface.getLiteral().toString());
+                       // Get capability list at element 1
+                       ParseNode pnGen3_capab_list = pnvGen3.elementAt(1);
+                       ParseNodeVector pnvGen4 = pnGen3_capab_list.getChildren();
+                       // Browse through capabilities
+                       for (int j = 0; j < pnvGen4.size(); j++) {
+                               ParseNode pnGen4 = pnvGen4.elementAt(j);
+                               reqDecl.addNewCapability(pnGen3_intface.getLiteral().toString(),
+                                       pnGen4.getLiteral().toString());
+                       }
+               }
+       }
+
+
+       /**
+        * getInterfaceDecl() returns InterfaceDecl object
+        */
+       public InterfaceDecl getInterfaceDecl() {
+
+               return intDecl;
+       }
+
+
+       /**
+        * getCapabilityDecl() returns CapabilityDecl object
+        */
+       public CapabilityDecl getCapabilityDecl() {
+
+               return capDecl;
+       }
+
+
+       /**
+        * getRequiresDecl() returns RequiresDecl object
+        */
+       public RequiresDecl getRequiresDecl() {
+
+               return reqDecl;
+       }
+
+
+       /**
+        * getOrigIntface() returns the original interface in policy, e.g. Camera
+        * <p>
+        * The ParseNode object should be the one returned from <Parser>.parse().value
+        */
+       public static String getOrigIntface(ParseNode pn) {
+
+               // Get the root: just keyword "interface"
+               ParseNodeVector pnv = pn.getChildren();
+               ParseNode pnRoot = pnv.elementAt(0);
+               // Get the child: intface_ident = original interface identifier, e.g. Camera
+               ParseNodeVector pnvGen2 = pnRoot.getChildren();
+               if (pnvGen2.size() == 0) {
+                       throw new Error("ParseTreeHandler: Interface declaration is missing! Please check your policy file...");
+               }
+               ParseNode pnGen2 = pnvGen2.elementAt(0);
+               // Confirm that this is "intface_ident"
+               if (pnGen2.getLabel().equals("intface_ident")) {
+                       if (pnGen2.getLiteral() != null) {
+                               return pnGen2.getLiteral().toString();
+                       } else
+                               throw new Error("ParseTreeHandler: No interface name found! Please fix policy file!");
+               } else
+                       throw new Error("ParseTreeHandler: Label 'intface_ident' is not found! Instead, '" + pnGen2.getLabel() + "' was found...");
+       }
+
+
+/*     public static void main(String[] args) throws Exception {
+
+               // initialize the symbol factory
+               ComplexSymbolFactory csf = new ComplexSymbolFactory();
+               // create a buffering scanner wrapper
+               ScannerBuffer lexer = new ScannerBuffer(new Lexer(new BufferedReader(new FileReader(args[0])),csf));
+               // start parsing
+               Parser p = new Parser(lexer,csf);
+               ParseNode pn = (ParseNode) p.parse().value;
+
+               String intFace = ParseTreeHandler.getOrigIntface(pn);
+               System.out.println("Original interface name: " + intFace);
+               ParseTreeHandler pth = new ParseTreeHandler(intFace, pn);
+               pth.processInterfaceDecl();
+               pth.processCapabilityDecl();
+               pth.processRequiresDecl();
+       }*/
+}
diff --git a/iotjava/iotpolicy/tree/RequiresDecl.java b/iotjava/iotpolicy/tree/RequiresDecl.java
new file mode 100644 (file)
index 0000000..73239e1
--- /dev/null
@@ -0,0 +1,106 @@
+package iotpolicy.tree;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/** Class RequiresDecl is a data structure for "requires"
+ *  declaration section in the policy file.
+ *  This section declares the needed interfaces based on
+ *  different combinations of capabilities.
+ *
+ * @author      Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
+ * @version     1.0
+ * @since       2016-09-20
+ */
+public final class RequiresDecl {
+
+       /**
+        * Class properties
+        */
+       private String origInt;
+
+       /**
+        * A "requires" statement:
+        *              requires Camera with VideoRecording, ImageCapture as interface CameraWithCaptureAndData;
+        *
+        * In this data structure we will record its new interface name, i.e. CameraWithCaptureAndData
+        *              and its required capabilities, i.e. VideoRecording and ImageCapture.
+        */
+       private Map<String,List<String>> mapRequires;
+
+       /**
+        * Class constructors
+        */
+       public RequiresDecl() {
+
+               origInt = null;
+               mapRequires = new HashMap<String,List<String>>();
+       }
+
+
+       public RequiresDecl(String _origInt) {
+
+               origInt = _origInt;
+               mapRequires = new HashMap<String,List<String>>();
+       }
+
+
+       /**
+        * addNewInterface() adds a new interface name into the map
+        */
+       public void addNewIntface(String newInt) {
+
+               mapRequires.put(newInt, new ArrayList<String>());
+       }
+
+
+       /**
+        * addNewCapability() adds a new capability name into the map
+        */
+       public void addNewCapability(String intFace, String newCapab) {
+
+               List<String> listCapab = mapRequires.get(intFace);
+               listCapab.add(newCapab);
+       }
+
+
+       /**
+        * getInterfaces() gets set of interfaces
+        */
+       public Set<String> getInterfaces() {
+
+               return mapRequires.keySet();
+       }
+
+
+       /**
+        * getCapabList() gets list of capabilities
+        */
+       public List<String> getCapabList(String intFace) {
+
+               return mapRequires.get(intFace);
+       }
+
+
+       public static void main(String[] args) {
+
+               RequiresDecl rd = new RequiresDecl("Camera");
+               rd.addNewIntface("CameraWithCaptureAndData");
+               rd.addNewCapability("CameraWithCaptureAndData", "ImageCapture");
+               rd.addNewCapability("CameraWithCaptureAndData", "VideoRecording");
+
+               System.out.println("Set of interfaces: " + rd.getInterfaces().toString());
+               System.out.println("Set of capabilities: " + rd.getCapabList("CameraWithCaptureAndData").toString());
+
+               rd.addNewIntface("CameraWithCaptureAndRecording");
+               rd.addNewCapability("CameraWithCaptureAndRecording", "ImageCapture");
+               rd.addNewCapability("CameraWithCaptureAndRecording", "BackupData");
+
+               System.out.println("Set of interfaces: " + rd.getInterfaces().toString());
+               System.out.println("Set of capabilities: " + rd.getCapabList("CameraWithCaptureAndData").toString());
+               System.out.println("Set of capabilities: " + rd.getCapabList("CameraWithCaptureAndData").toString());
+       }
+}
diff --git a/iotjava/iotpolicy/tree/Walkable.java b/iotjava/iotpolicy/tree/Walkable.java
new file mode 100644 (file)
index 0000000..ea1d55c
--- /dev/null
@@ -0,0 +1,34 @@
+package iotpolicy.tree;
+
+/**
+ * The Walkable interface specifies a set of methods that defines a web.
+ */
+
+public interface Walkable {
+
+  /**
+   * Returns the name of the node
+   */
+  public String getNodeName();
+
+
+  /**
+   * Returns the number of neighbors from this node
+   */
+  public int getNeighborCount();
+
+
+  /**
+   * Returns a specific neighbor
+   */
+  public Object getNeighbor(int index);
+
+  /**
+   * Returns a pretty print of the representation of the node.
+   *
+   * @param indent    number of blank spaces to skip for a new line
+   * @param recursive if true, recursively print children
+   */
+  public String PPrint(int indent, boolean recursive);
+}
+
index ca44aaee65a3635482c38b685e13f26a8b145bcf..22e929a407ed660d3269b904719b59d199810fbc 100644 (file)
@@ -8,6 +8,7 @@ import java.io.*;
 
 import javax.xml.transform.*;
 import javax.xml.transform.stream.*;
+
 parser code {:
   public Parser(Lexer lex, ComplexSymbolFactory sf) {
     super(lex,sf);
@@ -19,7 +20,9 @@ parser code {:
       ScannerBuffer lexer = new ScannerBuffer(new Lexer(new BufferedReader(new FileReader(args[0])),csf));
       // start parsing
       Parser p = new Parser(lexer,csf);
-      XMLElement e = (XMLElement)p.parse().value;
+      ParseNode pn = (ParseNode) p.parse().value;
+
+      /*XMLElement e = (XMLElement)p.parse().value;
       // create XML output file 
       XMLOutputFactory outFactory = XMLOutputFactory.newInstance();
       XMLStreamWriter sw = outFactory.createXMLStreamWriter(new FileOutputStream(args[1]), "UTF-8");
@@ -34,7 +37,7 @@ parser code {:
       transformer = TransformerFactory.newInstance()
            .newTransformer(new StreamSource(new File("tree-view.xsl")));
       text = new StreamSource(new File("output.xml"));
-      transformer.transform(text, new StreamResult(new File("ast.html")));
+      transformer.transform(text, new StreamResult(new File("ast.html")));*/
   }
 :};
 
@@ -43,9 +46,9 @@ terminal PUBLIC, INTERFACE, CAPABILITY, DESCRIPTION, METHOD, REQUIRES, WITH, AS;
 terminal TYPE;
 terminal IDENT, STRINGCONST;
 
-non terminal policy, intface, methlist, meth, paramlist, param;
-non terminal capablist, capab, capabcont, cont;
-non terminal reqlist, require, capintlist;
+non terminal ParseNode policy, intface, methlist, meth, paramlist, param;
+non terminal ParseNode capablist, capab, capabcont, cont;
+non terminal ParseNode reqlist, require, capintlist;
 
 /**
  * A policy file normally consists of 3 parts:
@@ -53,48 +56,174 @@ non terminal reqlist, require, capintlist;
  * 2) List of capabilities and their contents
  * 3) List of interface generation definitions
  */
-policy     ::= intface:in capablist:cap reqlist:rl
+policy     ::= 
+       intface:in capablist:cap reqlist:rl
+       {:
+               ParseNode pn = new ParseNode("policy");
+               pn.addChild(in);
+               pn.addChild(cap);
+               pn.addChild(rl);
+               RESULT = pn;
+       :}
     ;
 
 // Interface class definition
 intface    ::= PUBLIC INTERFACE IDENT:idint BEGIN methlist:ml END
+       {:
+               ParseNode pn = new ParseNode("interface");
+               pn.addChild("intface_ident").setLiteral(idint);
+               pn.addChild(ml);
+               RESULT = pn;
+       :}
     | /* empty */
+       {:
+               ParseNode pn = new ParseNode("interface");
+               RESULT = pn;
+       :}
     ;
 methlist   ::= methlist:ml meth:m
+       {:
+               ml.addChild(m);
+               RESULT = ml;
+       :}
     | /* empty */
+       {:
+               ParseNode pn = new ParseNode("method_list");
+               RESULT = pn;
+       :}
     ;
 meth       ::= PUBLIC TYPE:typemeth IDENT:idmeth LPAR paramlist:pl RPAR SEMICOLON
+       {:
+               ParseNode pn = new ParseNode("method");
+               pn.addChild("method_type").setLiteral(typemeth);
+               pn.addChild("method_ident").setLiteral(idmeth);
+               pn.addChild(pl);
+               RESULT = pn;
+       :}
     ;
 paramlist  ::= paramlist:pl param:p
+       {:
+               pl.addChild(p);
+               RESULT = pl;
+       :}
     | /* empty */
+       {:
+               ParseNode pn = new ParseNode("param_list");
+               RESULT = pn;
+       :}
     ;
 param      ::= TYPE:typeprm IDENT:idprm COMMA
+       {:
+               ParseNode pn = new ParseNode("param");
+               pn.addChild("param_type").setLiteral(typeprm);
+               pn.addChild("param_ident").setLiteral(idprm);
+               RESULT = pn;
+       :}
     | TYPE:typeprm IDENT:idprm
+       {:
+               ParseNode pn = new ParseNode("param");
+               pn.addChild("param_type").setLiteral(typeprm);
+               pn.addChild("param_ident").setLiteral(idprm);
+               RESULT = pn;
+       :}
     | IDENT:clsprm IDENT:idprm COMMA
+       {:
+               ParseNode pn = new ParseNode("param");
+               pn.addChild("param_class").setLiteral(clsprm);
+               pn.addChild("param_ident").setLiteral(idprm);
+               RESULT = pn;
+       :}
     | IDENT:clsprm IDENT:idprm
+       {:
+               ParseNode pn = new ParseNode("param");
+               pn.addChild("param_class").setLiteral(clsprm);
+               pn.addChild("param_ident").setLiteral(idprm);
+               RESULT = pn;
+       :}
     ;
 
 // List of capabilities and their respective contents, i.e. description, method, etc.
 capablist  ::= capablist:clist capab:cap
+       {:
+               clist.addChild(cap);
+               RESULT = clist;
+       :}
        | /* empty */
+       {:
+               ParseNode pn = new ParseNode("capab_list");
+               RESULT = pn;
+       :}
        ;
 capab      ::= CAPABILITY IDENT:idint DOT IDENT:idcap BEGIN capabcont:ccont END
+       {:
+               ParseNode pn = new ParseNode("capability");
+               pn.addChild("intface_ident").setLiteral(idint);
+               pn.addChild("capab_ident").setLiteral(idcap);
+               pn.addChild(ccont);
+               RESULT = pn;
+       :}
     ;
 capabcont  ::= capabcont:ccont cont:cnt
+       {:
+               ccont.addChild(cnt);
+               RESULT = ccont;
+       :}
        | /* empty */
+       {:
+               ParseNode pn = new ParseNode("capab_content");
+               RESULT = pn;
+       :}
        ;
-cont       ::= DESCRIPTION:dsc ASSIGN STRINGCONST SEMICOLON
+cont       ::= DESCRIPTION:dsc ASSIGN STRINGCONST:str SEMICOLON
+       {:
+               ParseNode pn = new ParseNode("capab_content");
+               pn.addChild("capab_desc").setLiteral(str);
+               RESULT = pn;
+       :}
        | METHOD:mtd ASSIGN IDENT:idmeth SEMICOLON
+       {:
+               ParseNode pn = new ParseNode("capab_content");
+               pn.addChild("capab_ident").setLiteral(idmeth);
+               RESULT = pn;
+       :}
        ;
 
 // List of interface generation definitions
 reqlist    ::= reqlist:rl require:req
+       {:
+               rl.addChild(req);
+               RESULT = rl;
+       :}
        | /* empty */
+       {:
+               ParseNode pn = new ParseNode("requires_list");
+               RESULT = pn;
+       :}
        ;
 require    ::= REQUIRES IDENT:idint WITH capintlist:cil AS INTERFACE IDENT:idnewint SEMICOLON
+       {:
+               ParseNode pn = new ParseNode("requires");
+               pn.addChild("intface_ident").setLiteral(idint);
+               pn.addChild(cil);
+               pn.addChild("new_intface_ident").setLiteral(idnewint);
+               RESULT = pn;
+       :}
        ;
 capintlist ::= IDENT:idcap
+       {:
+               ParseNode pn = new ParseNode("capab_ident_list");
+               pn.addChild("capab_ident").setLiteral(idcap);
+               RESULT = pn;
+       :}
        | capintlist:cil COMMA IDENT:idcap
+       {:
+               cil.addChild("capab_ident").setLiteral(idcap);
+               RESULT = cil;
+       :}
        | /* empty */
+       {:
+               ParseNode pn = new ParseNode("capab_ident_list");
+               RESULT = pn;
+       :}
        ;
 
index bad298efff7e36044e4b2b72f929fe7a38778e74..f16ef69374b1ed1788e80e1c39db09bcce3a0a0f 100644 (file)
@@ -64,16 +64,17 @@ white_space = {new_line} | [ \t\f]
 
 <YYINITIAL>{
 /* keywords */
-"int"             { return symbol("int",TYPE, "INT" ); }
-"short"           { return symbol("short",TYPE, "SHORT" ); }
-"byte"            { return symbol("byte",TYPE, "BYTE" ); }
-"long"            { return symbol("long",TYPE, "LONG" ); }
-"float"           { return symbol("float",TYPE, "FLOAT" ); }
-"double"          { return symbol("double",TYPE, "DOUBLE" ); }
-"char"            { return symbol("char",TYPE, "CHAR" ); }
-"string"          { return symbol("string",TYPE, "STRING" ); }
-"boolean"         { return symbol("boolean",TYPE, "BOOL" ); }
-"void"            { return symbol("void",TYPE, "VOID" ); }
+"int"             { return symbol("int",TYPE, "int" ); }
+"short"           { return symbol("short",TYPE, "short" ); }
+"byte"            { return symbol("byte",TYPE, "byte" ); }
+"long"            { return symbol("long",TYPE, "long" ); }
+"float"           { return symbol("float",TYPE, "float" ); }
+"double"          { return symbol("double",TYPE, "double" ); }
+"char"            { return symbol("char",TYPE, "char" ); }
+"string"          { return symbol("string",TYPE, "String" ); }
+"String"          { return symbol("String",TYPE, "String" ); }
+"boolean"         { return symbol("boolean",TYPE, "boolean" ); }
+"void"            { return symbol("void",TYPE, "void" ); }
 "public"          { return symbol("public",PUBLIC); }
 "interface"       { return symbol("interface",INTERFACE); }
 "capability"      { return symbol("capability",CAPABILITY); }