add Commit point clear construct
[cdsspec-compiler.git] / grammer / spec_compiler.jj
index 37749aab497b2b2438959e1c2b9b918ef508234e..43faebf46a2222051b09295db1b19fbc44f3baed 100644 (file)
        @Label: ...
        @End
 
+       // Commit point clear (just as a normal commit point, but it is used to
+       // clear all commit points)
+       @Begin
+       @Commit_point_clear: ...
+       @Label: ...
+       @End
+
        e) Entry point construct
        @Begin
        @Entry_point
@@ -122,6 +129,7 @@ import edu.uci.eecs.specCompiler.specExtraction.InterfaceConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.PotentialCPDefineConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.CPDefineConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.CPDefineCheckConstruct;
+import edu.uci.eecs.specCompiler.specExtraction.CPClearConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.ConditionalInterface;
 import edu.uci.eecs.specCompiler.specExtraction.SequentialDefineSubConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.InterfaceDefineConstruct;
@@ -373,6 +381,8 @@ SKIP : {
        <COMMIT_POINT_DEFINE_CHECK: "@Commit_point_define_check:">
 |
        <COMMIT_POINT_DEFINE: "@Commit_point_define:">
+|
+       <COMMIT_POINT_CLEAR: "@Commit_point_clear:">
 |
        <POTENTIAL_COMMIT_POINT_LABEL: "@Potential_commit_point_label:">
 }
@@ -885,6 +895,7 @@ Construct ParseSpec() :
        LOOKAHEAD(2) res = Potential_commit_point_define() |
        LOOKAHEAD(2) res = Commit_point_define() |
        LOOKAHEAD(2) res = Commit_point_define_check() |
+       LOOKAHEAD(2) res = Commit_point_clear() |
        LOOKAHEAD(2) res = Entry_point() |
        LOOKAHEAD(2) res = Class_begin() |
        LOOKAHEAD(2) res = Class_end() |
@@ -1120,6 +1131,25 @@ CPDefineConstruct Commit_point_define() :
        }
 }
 
+CPClearConstruct Commit_point_clear() :
+{
+       CPClearConstruct res;   
+       String label, condition;
+       ArrayList<String> content;
+}
+{
+
+       { res = null; }
+               <BEGIN> 
+                       <COMMIT_POINT_CLEAR> (content = C_CPP_CODE(null) { condition = stringArray2String(content); })
+                       <LABEL> (label = <IDENTIFIER>.image)
+               <END>
+       {
+               res = new CPClearConstruct(_file, _content.size(), label, condition);
+               return res;
+       }
+}
+
 
 CPDefineCheckConstruct Commit_point_define_check() :
 {