edits
[cdsspec-compiler.git] / grammer / spec_compiler.jj
index f914094a1f249af4838c3aeea860edf07897f742..2a8c779d07e5e34e34f05c2e6eadefa763b5e097 100644 (file)
@@ -9,90 +9,52 @@
        annotation would be considered as normal comments of the source.
        
        a) Global construct
-       @Begin
-       @Options:
-               # If LANG is not define, it's C++ by default. C does not support class
-               # and template, so if it's defined as C, we should also have a explicit
-               # entry point.
-               LANG = C;
-       @Global_define:
-               @DeclareStruct:
-               @DeclareVar:
-               @InitVar:
-               @DefineFunc:
-               ...
-               @DefineFunc:
-       @Interface_cluster:
-               ...
-       @Happens-before:
-               ...
-       @End
+       @DeclareState: C/C++ variable declaration; // Declare the state structure
+       @InitState: C/C++ statements; // Specify how to initialize the state
+       @CopyState: // A function on how to copy an existing state (Not sure if we
+                               // need this because we might be able to auto this
+       @Commutativity: Method1 <-> Method2 (Guard) // Admissibility condition.
+                                                                                               // Allow specify 0-many rules
        
        b) Interface construct
-       @Begin
-       @Interface_decl: ...
-       @Commit_point_set:
-               IDENTIFIER | IDENTIFIER ...
-       @Condition: ... (Optional)
-       @HB_Condition:
-               IDENTIFIER :: <C_CPP_Condition>
-       @HB_Condition: ...
-       @ID: ... (Optional, use default ID)
-       @Check: (Optional)
-               ...
-       @Action: (Optional)
-               ...
-       @Post_action: (Optional)
-       @Post_check: (Optional)
-       @End
-
-       c) Potential commit construct
-       @Begin
-       @Potential_commit_point_define: ...
-       @Label: ...
-       @End
-
-       d) Commit point define construct
-       @Begin
-       @Commit_point_define_check: ...
-       @Label: ...
-       @End
-       
-               OR
-
-       @Begin
-       @Commit_point_define: ...
-       @Potential_commit_point_label: ...
-       @Label: ...
-       @End
-
-       e) Entry point construct
-       @Begin
-       @Entry_point
-       @End
-
-       f) Interface define construct
-       @Begin
-       @Interface_define: <Interface_Name>
-       @End
-
-       g) Interface declare & define construct
-       @Begin
-       @Interface_decl_define: <Interface_Name>
-       @Commit_point_set:
-               IDENTIFIER | IDENTIFIER ...
-       @Condition: ... (Optional)
-       @HB_Condition:
-               IDENTIFIER :: <C_CPP_Condition>
-       @HB_Condition: ...
-       @ID: ... (Optional, use default ID)
-       @Check: (Optional)
-               ...
-       @Action: (Optional)
-               ...
-       @Post_action: (Optional)
-       @Post_check: (Optional)
-       @End
+       @Interface: InterfaceName // Required; a label to represent the interface
+       @LocalState: // Optional; to calculate the accumulative local state before this
+                                // method call in a customized fashion. If not specified here, the
+                                // local state would be default, which is the result of the
+                                // execution on the subset of method calls in the sequential order
+       @PreCondition: // Optional; checking code
+       @LocalSideEffect: // Optional; to calculate the side effect this method call
+                                         // have on the local state in a customized fashion. If this
+                                         // field is not stated, it means we don't care about it.
+       @SideEffect: // Optional; to calculate the side effect on the global state. When
+                       // the "@LocalSideEffect" specification is ommitted, we also impose the
+                       // same side effect on the set of method calls that happen before this
+                       // method call in the sequential order.
+       @PostCondition: // Optional; checking code
+
+
+       c) Ordering point construct
+       @OPDefine: condition    // If the specified condition satisfied, the atomic
+                                                       // operation right before is an ordering point
+
+       @PotentialOP(Label): condition  // If the specified condition satisfied, the
+                                                                       // atomic operation right before is a potential
+                                                                       // ordering point, and we label it with a tag
+
+       @OPCheck(Label): condition      // If the specified condition satisfied, the
+                                                               // potential ordering point defined earlier with the
+                                                               // same tag becomes an ordering point
+
+       @OPClear: condition             // If the specified condition satisfied, all the
+                                                       // ordering points and potential ordering points will be
+                                                       // cleared
+
+       @OPClearDefine: condition       // If the specified condition satisfied, all the
+                                                               // ordering points and potential ordering points will
+                                                               // be cleared, and the atomic operation right before
+                                                               // becomes an ordering point. This is a syntax sugar
+                                                               // as the combination of an "OPClear" and "OPDefine"
+                                                               // statement
 
 */
 
@@ -114,13 +76,16 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Arrays;
 
 import edu.uci.eecs.specCompiler.specExtraction.Construct;
 import edu.uci.eecs.specCompiler.specExtraction.GlobalConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.InterfaceConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.PotentialCPDefineConstruct;
+import edu.uci.eecs.specCompiler.specExtraction.CommutativityRule;
 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;
@@ -141,10 +106,10 @@ import edu.uci.eecs.specCompiler.specExtraction.VariableDeclaration;
                public static void main(String[] argvs)
                throws ParseException, TokenMgrError {
                        try {
-                               File f = new File("./grammer/spec.txt");
+                               File f = new File("./grammer/spec1.txt");
                                FileInputStream fis = new FileInputStream(f);
                                SpecParser parser = new SpecParser(fis);
-                               /*
+                               
                                ArrayList<String> content = new ArrayList<String>();
                                ArrayList<Construct> constructs = new ArrayList<Construct>();
                                ArrayList<String> headers = new ArrayList<String>();
@@ -156,9 +121,9 @@ import edu.uci.eecs.specCompiler.specExtraction.VariableDeclaration;
                                for (int i = 0; i < constructs.size(); i++) {
                                        System.out.println(constructs.get(i));
                                }
-                               */
                                
-                               parser.Test();
+                               
+                               //parser.Test();
                                System.out.println("Parsing finished!");
                        } catch (FileNotFoundException e) {
                                e.printStackTrace();
@@ -181,6 +146,13 @@ import edu.uci.eecs.specCompiler.specExtraction.VariableDeclaration;
                        return null;
                }
 
+
+               private static ArrayList<String> breakLines(String all) {
+                       String lines[] = all.split("[\\r\\n]+");
+                       return new ArrayList<String>(Arrays.asList(lines));
+               }
+
+
                public static ArrayList<VariableDeclaration> getTemplateArg(String line)
                throws ParseException {
                        InputStream input = new ByteArrayInputStream(line.getBytes());
@@ -206,12 +178,61 @@ import edu.uci.eecs.specCompiler.specExtraction.VariableDeclaration;
                        return sb.toString();
                }
 
+               /**
+               boolean spaceSeparator(Token t) {
+                       switch (t.image) {
+                               case "[":
+                               case "]":
+                               case "=":
+                               case "(":
+                               case ")":
+                               case ",":
+                               case ".":
+                               case "*":
+                               case "~":
+                               case "!":
+                               case "&":
+                               case "|":
+                               case "%":
+                               case "+":
+                               case "-":
+                               case "/":
+                               case "<":
+                               case ">":
+                               case "<=":
+                               case ">=":
+                               case "==":
+                               case "!=":
+                               case "&&":
+                               case "||":
+                               case "^":
+                               case "?":
+                               case ":":
+                               case "::":
+                               case "<<":
+                               case ">>":
+                               case ">>>":
+                               case "+=":
+                               case "-=":
+                               case "*=":
+                               case "/=":
+                               case "%=":
+                               case "^=":
+                               case "&=":
+                               case ";":
+                                       return false;
+                               default:
+                                       return true;
+                       }
+               }
+               */
+
        }
 PARSER_END(SpecParser)
 
 
 
-<*> SKIP :
+<IN_POTENTIAL_SPEC, IN_SPEC> SKIP :
 {
        " "
 |
@@ -240,6 +261,10 @@ SKIP : {
        "/*": IN_COMMENT
 }
 
+<DEFAULT> TOKEN: {
+       <ANY: ~[]>
+}
+
 <*> SKIP : {
        // "//" comment for the specification
        <"//" (~["\n", "\r"])* (["\n", "\r"])>
@@ -270,12 +295,16 @@ SKIP : {
        <DECLARE_VAR: "@DeclareVar:">
 |
        <INIT_VAR: "@InitVar:">
+|
+       <CLEANUP: "@Finalize:">
 |
        <DEFINE_FUNC: "@DefineFunc:">
 |
        <INTERFACE_CLUSTER: "@Interface_cluster:">
 |
        <HAPPENS_BEFORE: "@Happens_before:">
+|
+       <COMMUTATIVITY: "@Commutativity:">
 |
        <INTERFACE: "@Interface:">
 |
@@ -306,18 +335,28 @@ SKIP : {
        <POST_CHECK: "@Post_check:">
 |
        <POTENTIAL_COMMIT_POINT_DEFINE: "@Potential_commit_point_define:">
+|
+       <POTENTIAL_ADDITIONAL_ORDERING_POINT_DEFINE: "@Potential_additional_ordering_point_define:">
 |
        <LABEL: "@Label:">
 |
        <COMMIT_POINT_DEFINE_CHECK: "@Commit_point_define_check:">
+|
+       <ADDITIONAL_ORDERING_POINT_DEFINE_CHECK: "@Additional_ordering_point_define_check:">
 |
        <COMMIT_POINT_DEFINE: "@Commit_point_define:">
+|
+       <ADDITIONAL_ORDERING_POINT_DEFINE: "@Additional_ordering_point_define:">
+|
+       <COMMIT_POINT_CLEAR: "@Commit_point_clear:">
 |
        <POTENTIAL_COMMIT_POINT_LABEL: "@Potential_commit_point_label:">
+|
+       <POTENTIAL_ADDITIONAL_ORDERING_POINT_LABEL: "@Potential_additional_ordering_point_label:">
 }
 
 
-<IN_SPEC, DEFAULT> TOKEN :
+<IN_SPEC> TOKEN :
 {
 /*   Specification & C/C++ shared tokens   */
 // Reserved keywords
@@ -334,6 +373,8 @@ SKIP : {
        <INLINE: "inline">
 |
        <STATIC: "static">
+|
+       <FOR: "for">
 |
        <#DIGIT: ["0"-"9"]>
 |
@@ -358,11 +399,15 @@ SKIP : {
        <CLOSE_BRACE: "}">
 |
        <HB_SYMBOL: "->">
+|
+       <COMMUTATIVITY_SYMBOL: "<->">
 |
        <COMMA: ",">
 |
 /*   C/C++ only token*/
        <DOT: ".">
+|
+       <DOLLAR: "$">
 |
        <STAR: "*">
 |
@@ -509,7 +554,7 @@ String Type() :
 }
 {
        { type = ""; }
-       ("const"
+       (<CONST>
        { type = "const"; }
        )?
        (((str = <STRUCT>.image | str = <CLASS>.image | str = <UNSIGNED>.image) { type = type + " " + str; })? 
@@ -521,7 +566,7 @@ String Type() :
                        type = name.fullName;
        })
        )
-       ((str = "const".image {
+       ((str = <CONST>.image {
                if (!type.equals(""))
                        type = type + " " + str;
                else
@@ -545,24 +590,6 @@ String Type() :
        }
 }
 
-void Test() :
-{
-       String str;     
-       FunctionHeader func;
-}
-{
-       /*
-       str = Type()
-       {
-               System.out.println(str);
-       }
-       */
-       func = FuncDecl() 
-       {
-               System.out.println(func);
-       }
-       
-}
 
 String ParameterizedName() :
 {
@@ -571,8 +598,8 @@ String ParameterizedName() :
 }
 {
        (str = <IDENTIFIER>.image {res = str;})
-       ("<" str = Type() { res = res + "<" + str; }
-       ("," str = Type() { res = res + ", " + str; })* ">"
+       (<OPEN_BRACKET> str = Type() { res = res + "<" + str; }
+       (<COMMA> str = Type() { res = res + ", " + str; })* <CLOSE_BRACKET>
        { res = res + ">"; }
        )?
        {
@@ -625,7 +652,7 @@ ArrayList<VariableDeclaration> TemplateParamList() :
                params = new ArrayList<VariableDeclaration>();
        }
        <TEMPLATE>
-       "<"
+       <OPEN_BRACKET>
        (type = <IDENTIFIER>.image 
        name = <IDENTIFIER>.image
        {
@@ -633,13 +660,13 @@ ArrayList<VariableDeclaration> TemplateParamList() :
        }
        )
 
-       ("," type = <IDENTIFIER>.image 
+       (<COMMA> type = <IDENTIFIER>.image 
        name = <IDENTIFIER>.image
        {
                params.add(new VariableDeclaration(type, name));
        }
        )*
-       ">"
+       <CLOSE_BRACKET>
        {
                //System.out.println(params);
                return params;
@@ -655,10 +682,10 @@ ArrayList<VariableDeclaration > FormalParamList() :
        {
                typeParams = new ArrayList<VariableDeclaration >();
        }
-       "("
+       <OPEN_PAREN>
        ((varDecl = TypeParam() {typeParams.add(varDecl);})
        ((<COMMA> varDecl = TypeParam() {typeParams.add(varDecl);}))*)?
-       ")"
+       <CLOSE_PAREN>
        {
                return typeParams;
        }
@@ -675,12 +702,16 @@ VariableDeclaration TypeParam() :
        }
 }
 
+
+
 ArrayList<String> C_CPP_CODE(ArrayList<String> headers) :
 {
        String text;
        Token t;
        boolean newLine = false;
+       boolean newSpace = true;
        boolean inTemplate = false;
+       boolean inForLoop = false;
        ArrayList<String> content;
        String header;
 }
@@ -696,6 +727,7 @@ ArrayList<String> C_CPP_CODE(ArrayList<String> headers) :
        t = <CONST> | t = <STRUCT> | t = <CLASS> | t = <UNSIGNED> |
        (t = <TEMPLATE> { inTemplate = true;  })|
        t = <STATIC> | t = <INLINE> |
+       (t = <FOR> { inForLoop = true; })|
        (t = <INCLUDE>
        {
                header = t.image;
@@ -706,11 +738,11 @@ ArrayList<String> C_CPP_CODE(ArrayList<String> headers) :
        })
        | t = <IDENTIFIER> | t = <POUND> |
        (t = <OPEN_BRACE>  { newLine = true; } ) |
-       (t = <CLOSE_BRACE>  { newLine = true; } ) | 
+       (t = <CLOSE_BRACE>  { newLine = true; inForLoop = false;} ) | 
        t = <EQUALS> | t = <OPEN_PAREN> | t = <CLOSE_PAREN> | 
        t = <OPEN_BRACKET> | t = <CLOSE_BRACKET>
        | t = <HB_SYMBOL> | t = <COMMA> |
-       t = <DOT> | t = <STAR> | t = <NEGATE> | t = <EXCLAMATION> | t = <AND> | t = <OR> | t = <MOD> | t = <PLUS> |
+       t = <DOT> | t = <STAR> | t = <DOLLAR> | t = <NEGATE> | t = <EXCLAMATION> | t = <AND> | t = <OR> | t = <MOD> | t = <PLUS> |
        t = <PLUSPLUS> | t = <MINUS> | t = <MINUSMINUS> | t = <DIVIDE> | t = <BACKSLASH> |
        t = <LESS_THAN> |
        (t = <GREATER_THAN> { if (inTemplate) newLine = true; }) |
@@ -730,7 +762,7 @@ ArrayList<String> C_CPP_CODE(ArrayList<String> headers) :
        t = <OR_EQUALS> |
        t = <AND_EQUALS> |
 
-       (t = <SEMI_COLON> { newLine = true; } )
+       (t = <SEMI_COLON> { if (!inForLoop) newLine = true; } )
        | t = <STRING_LITERAL> | t = <CHARACTER_LITERAL> |
        t = <INTEGER_LITERAL> | t = <FLOATING_POINT_LITERAL> |
        (t = <DEFINE> { newLine = true; } )
@@ -738,8 +770,17 @@ ArrayList<String> C_CPP_CODE(ArrayList<String> headers) :
        {
                if (text.equals("")) {
                        text = t.image;
+                       newSpace = true;
                } else {
                        text = text + " " + t.image;
+                       /*
+                       if (newSpace && spaceSeparator(t)) {
+                               text = text + " " + t.image;
+                       } else {
+                               text = text + t.image;
+                               if (spaceSeparator(t))
+                                       newSpace = true;
+                       }*/
                }
                if (newLine) {
                        content.add(text);
@@ -762,17 +803,55 @@ ArrayList<String> C_CPP_CODE(ArrayList<String> headers) :
 void Parse(File f, ArrayList<String> content, ArrayList<Construct> constructs, ArrayList<String> headers) :
 {
        Construct inst;
-       ArrayList<String> code;
+       StringBuilder sb;
+       boolean flushSB;
 }
 {
        {
                _file = f;
                _content = content;
                _constructs = constructs;
+               sb = new StringBuilder();
+       }
+       (
+       (inst = ParseSpec()
+       {
+               _constructs.add(inst);
+       }
+       ) |
+       //((code = C_CPP_CODE(headers)) { _content.addAll(code); })
+       (
+       flushSB = OriginalCode(sb)
+       {
+               if (flushSB) {
+                       sb = new StringBuilder();
+               }
+       }
+       )
+       )* 
+       // For the last piece of code
+       {
+               _content.add(sb.toString());
+       }
+       <EOF>
+}
+
+// If true, there's a new line and sb should be flushed
+boolean OriginalCode(StringBuilder sb) :
+{
+       String str;
+}
+{
+       str = <ANY>.image
+       {
+               if (!str.equals("\n")) {
+                       sb.append(str);
+                       return false;
+               } else {
+                       _content.add(sb.toString());
+                       return true;
+               }
        }
-       ((inst = ParseSpec() { _constructs.add(inst); }) |
-       ((code = C_CPP_CODE(headers)) { _content.addAll(code); })
-       )* <EOF>
 }
 
 Construct ParseSpec() :
@@ -786,6 +865,10 @@ 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 = Potential_additional_ordering_point_define() |
+       LOOKAHEAD(2) res = Additional_ordering_point_define() |
+       LOOKAHEAD(2) res = Additional_ordering_point_define_check() |
+       LOOKAHEAD(2) res = Commit_point_clear() |
        LOOKAHEAD(2) res = Entry_point() |
        LOOKAHEAD(2) res = Class_begin() |
        LOOKAHEAD(2) res = Class_end() |
@@ -827,6 +910,7 @@ GlobalConstruct Global_construct() :
                        { res = new GlobalConstruct(_file, _content.size(), code, options); }
                        (Interface_clusters(res))?
                        (Happens_before(res))?
+                       (Commutativity(res))?
                <END>
        {
                res.unfoldInterfaceCluster();
@@ -836,7 +920,7 @@ GlobalConstruct Global_construct() :
 
 SequentialDefineSubConstruct Global_define() :
 {
-       ArrayList<String> initVar, defineFunc, code, declareStruct;
+       ArrayList<String> initVar, cleanup, defineFunc, code, declareStruct;
        ArrayList<ArrayList<String>> defineFuncs;
        ArrayList<VariableDeclaration> declareVars;
        ArrayList<ArrayList<String>> declareStructs;
@@ -846,20 +930,22 @@ SequentialDefineSubConstruct Global_define() :
 {
        {
                declareVars = new ArrayList<VariableDeclaration>();
-               initVar = null;
+               initVar = new ArrayList<String>();
+               cleanup = new ArrayList<String>();
                defineFuncs = new ArrayList<ArrayList<String>>();
                declareStructs = new ArrayList<ArrayList<String>>();
        }
        <GLOBAL_DEFINE>
        (<DECLARE_STRUCT> (declareStruct = C_CPP_CODE(null) {
                declareStructs.add(declareStruct); }))*
-               (<DECLARE_VAR> ((declareVar = TypeParam() ";" {
+               (<DECLARE_VAR> ((declareVar = TypeParam() <SEMI_COLON> {
                        declareVars.add(declareVar); } )*))?
        (<INIT_VAR> (code = C_CPP_CODE(null) { initVar = code; } ))?
+       (<CLEANUP> (code = C_CPP_CODE(null) { cleanup = code; } ))?
        (<DEFINE_FUNC> (defineFunc = C_CPP_CODE(null) { defineFuncs.add(defineFunc); }))*
        {
                SequentialDefineSubConstruct res = new
-                       SequentialDefineSubConstruct(declareStructs, declareVars, initVar, defineFuncs);
+                       SequentialDefineSubConstruct(declareStructs, declareVars, initVar, cleanup, defineFuncs);
                //System.out.println(res);
                return res;
        }
@@ -915,6 +1001,29 @@ void Happens_before(GlobalConstruct inst) :
        )+
 }
 
+void Commutativity(GlobalConstruct inst) :
+{
+       String method1, method2, condition;
+       ArrayList<String> content;
+}
+{
+       {
+               content = new ArrayList<String>();
+       }
+
+       (
+       <COMMUTATIVITY>
+       method1 = <IDENTIFIER>.image  <COMMUTATIVITY_SYMBOL>
+       method2 = <IDENTIFIER>.image
+       <COLON>
+       content = C_CPP_CODE(null)
+       { condition = stringArray2String(content); }
+       {
+               inst.addCommutativityRule(method1, method2, condition);
+       }
+       )+
+}
+
 InterfaceConstruct Interface() :
 {
        InterfaceConstruct res;
@@ -1000,6 +1109,26 @@ PotentialCPDefineConstruct Potential_commit_point_define() :
        }
 }
 
+PotentialCPDefineConstruct Potential_additional_ordering_point_define() :
+{
+       PotentialCPDefineConstruct res;
+       String label, condition;
+       ArrayList<String> content;
+}
+{
+
+       { res = null; }
+               <BEGIN>
+                       <POTENTIAL_ADDITIONAL_ORDERING_POINT_DEFINE> (content = C_CPP_CODE(null) { condition = stringArray2String(content); })
+                       <LABEL> (label = <IDENTIFIER>.image)
+               <END>
+       {
+               // Set the boolean flag isAdditionalOrderingPoint to be true
+               res = new PotentialCPDefineConstruct(_file, _content.size(), true, label, condition); 
+               return res;
+       }
+}
+
 
 CPDefineConstruct Commit_point_define() :
 {
@@ -1016,7 +1145,47 @@ CPDefineConstruct Commit_point_define() :
                        <LABEL> (label = <IDENTIFIER>.image)
                <END>
        {
-               res = new CPDefineConstruct(_file, _content.size(), label, potentialCPLabel, condition);
+               res = new CPDefineConstruct(_file, _content.size(), false, label, potentialCPLabel, condition);
+               return res;
+       }
+}
+
+CPDefineConstruct Additional_ordering_point_define() :
+{
+       CPDefineConstruct res;
+       String label, potentialCPLabel, condition;
+       ArrayList<String> content;
+}
+{
+
+       { res = null; }
+               <BEGIN>
+                       <ADDITIONAL_ORDERING_POINT_DEFINE> (content = C_CPP_CODE(null) { condition = stringArray2String(content); })
+                       <POTENTIAL_ADDITIONAL_ORDERING_POINT_LABEL> (potentialCPLabel = <IDENTIFIER>.image)
+                       <LABEL> (label = <IDENTIFIER>.image)
+               <END>
+       {
+               // Set the boolean flag isAdditionalOrderingPoint to be true
+               res = new CPDefineConstruct(_file, _content.size(), true, label, potentialCPLabel, condition);
+               return res;
+       }
+}
+
+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;
        }
 }
@@ -1036,7 +1205,27 @@ CPDefineCheckConstruct Commit_point_define_check() :
                        <LABEL> (label = <IDENTIFIER>.image)
                <END>
        {
-               res = new CPDefineCheckConstruct(_file, _content.size(), label, condition);
+               res = new CPDefineCheckConstruct(_file, _content.size(), false, label, condition);
+               return res;
+       }
+}
+
+CPDefineCheckConstruct Additional_ordering_point_define_check() :
+{
+       CPDefineCheckConstruct res;     
+       String label, condition;
+       ArrayList<String> content;
+}
+{
+
+       { res = null; }
+               <BEGIN> 
+                       <ADDITIONAL_ORDERING_POINT_DEFINE_CHECK> (content = C_CPP_CODE(null) { condition = stringArray2String(content); })
+                       <LABEL> (label = <IDENTIFIER>.image)
+               <END>
+       {
+               // Set the boolean flag isAdditionalOrderingPoint to be true
+               res = new CPDefineCheckConstruct(_file, _content.size(), true, label, condition);
                return res;
        }
 }