try to generate in-place code
[cdsspec-compiler.git] / grammer / spec-compiler.jj
index 2238268a43ac644a62e490703ea226c6d3060f2f..67769868dcf93af2a1cd16844c68a0b73a71ee31 100644 (file)
@@ -11,6 +11,9 @@
        a) Global construct
        @Begin
        @Global_define:
+               @DeclareVar:
+               @InitVar:
+               @DefineFunc:
                ...
        @Interface_cluster:
                ...
@@ -86,6 +89,7 @@ import edu.uci.eecs.specCompiler.specExtraction.CPDefineCheckConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.ConditionalInterface;
 import edu.uci.eecs.specCompiler.specExtraction.ActionSubConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.ActionSubConstruct.DefineVar;
+import edu.uci.eecs.specCompiler.specExtraction.SequentialDefineSubConstruct;
 
        public class SpecParser {
                public static void main(String[] argvs)
@@ -142,6 +146,12 @@ TOKEN :
        <END: "@End">
 |
        <GLOBAL_DEFINE: "@Global_define:">
+|
+       <DECLARE_VAR: "@DeclareVar:">
+|
+       <INIT_VAR: "@InitVar:">
+|
+       <DEFINE_FUNC: "@DefineFunc:">
 |
        <INTERFACE_CLUSTER: "@Interface_cluster:">
 |
@@ -334,7 +344,7 @@ Construct Parse() :
 GlobalConstruct Global_construct() :
 {
        GlobalConstruct res;
-       String code;
+       SequentialDefineSubConstruct code;
 }
 {
        { res = null; }
@@ -390,14 +400,24 @@ String C_CPP_CODE() :
        }
 }
 
-String Global_define() :
+SequentialDefineSubConstruct Global_define() :
 {
-       String code;    
+       String declareVar, initVar, defineFunc;
 }
 {
-       <GLOBAL_DEFINE> (code = C_CPP_CODE())
        {
-               return code;
+               declareVar = "";
+               initVar = "";
+               defineFunc = "";
+       }
+       <GLOBAL_DEFINE> 
+       (<DECLARE_VAR> (declareVar = C_CPP_CODE()))?
+       (<INIT_VAR> (initVar = C_CPP_CODE()))?
+       (<DEFINE_FUNC> (defineFunc = C_CPP_CODE()))?
+       {
+               SequentialDefineSubConstruct res = new SequentialDefineSubConstruct(declareVar, initVar, defineFunc);
+               //System.out.println(res);
+               return res;
        }
 }