Adding config file for sharing.
[iot2.git] / others / javacup / iotparser.cup
index 00db795902a1743a441e2d75014cff7563fdbd4c..8106d34e0152278796bfc405206c79efe297beea 100644 (file)
@@ -33,8 +33,8 @@ non terminal ParseNode policy;
 non terminal ParseNode intface, methlist, meth, paramlist, param, paramtype;
 non terminal ParseNode capablist, capab, capabcont, cont;
 non terminal ParseNode reqlist, require, capintlist;
-non terminal ParseNode enumdec, enumlist, enummem;
-non terminal ParseNode structdec, structlist, structmem;
+non terminal ParseNode enumdeclist, enumdec, enumlist, enummem;
+non terminal ParseNode structdeclist, structdec, structlist, structmem;
 
 
 /**
@@ -65,18 +65,6 @@ policy     ::= intface:in
                pn.addChild(rl);
                RESULT = pn;
        :}
-       | enumdec:en
-       {:
-               ParseNode pn = new ParseNode("policy");
-               pn.addChild(en);
-               RESULT = pn;
-       :}
-       | structdec:st
-       {:
-               ParseNode pn = new ParseNode("policy");
-               pn.addChild(st);
-               RESULT = pn;
-       :}
     ;
 
 //1) Interface class definition
@@ -85,12 +73,14 @@ policy     ::= intface:in
 // 3) Driver list
 
 // Interface
-intface    ::= PUBLIC INTERFACE IDENT:idint BEGIN methlist:ml capablist:cl END
+intface    ::= PUBLIC INTERFACE IDENT:idint BEGIN methlist:ml capablist:cl enumdeclist:el structdeclist:sl END
        {:
                ParseNode pn = new ParseNode("interface");
                pn.addChild("intface_ident").setLiteral(idint);
                pn.addChild(ml);
                pn.addChild(cl);
+               pn.addChild(el);
+               pn.addChild(sl);
                RESULT = pn;
        :}
     ;
@@ -295,7 +285,18 @@ capintlist ::= IDENT:idcap
        :}
        ;
 
-//4) Enumeration declaration
+//4) Enumeration declaration list
+enumdeclist  ::= enumdeclist:el enumdec:ed
+       {:
+               el.addChild(ed);
+               RESULT = el;
+       :}
+       | /* empty */
+       {:
+               ParseNode pn = new ParseNode("enum_dec_list");
+               RESULT = pn;
+       :}
+       ;
 enumdec                ::= ENUM IDENT:idenumdec BEGIN enumlist:el END
        {:
                ParseNode pn = new ParseNode("enum_dec");
@@ -303,7 +304,7 @@ enumdec             ::= ENUM IDENT:idenumdec BEGIN enumlist:el END
                pn.addChild(el);
                RESULT = pn;
        :}
-    ;
+       ;
 enumlist       ::= enumlist:el enummem:e
        {:
                el.addChild(e);
@@ -329,7 +330,18 @@ enummem            ::= IDENT:idenum COMMA
        :}
     ;
 
-//5) Struct declaration
+//5) Struct declaration list
+structdeclist  ::= structdeclist:sl structdec:sd
+       {:
+               sl.addChild(sd);
+               RESULT = sl;
+       :}
+       | /* empty */
+       {:
+               ParseNode pn = new ParseNode("struct_dec_list");
+               RESULT = pn;
+       :}
+       ;
 structdec      ::= STRUCT IDENT:idstructdec BEGIN structlist:sl END
        {:
                ParseNode pn = new ParseNode("struct_dec");
@@ -345,7 +357,7 @@ structlist  ::= structlist:sl structmem:s
        :}
     | /* empty */
        {:
-               ParseNode pn = new ParseNode("enum_list");
+               ParseNode pn = new ParseNode("struct_list");
                RESULT = pn;
        :}
     ;