- <INTERFACE_CLUSTER> (Interface_cluster(inst))+
-}
-
-void Happens_before(GlobalConstruct inst) :
-{
- ConditionalInterface left, right;
-}
-{
- <HAPPENS_BEFORE>
- (
- left = Conditional_interface() <HB_SYMBOL> right = Conditional_interface()
- { inst.addHBCondition(left, right); }
- )+
-}
-
-InterfaceConstruct Interface() :
-{
- InterfaceConstruct res;
- String interfaceName, condition, idCode, check, postAction,
- postCheck, commitPoint, hbLabel, hbCondition;
- ActionSubConstruct action;
- ArrayList<String> commitPointSet;
- HashMap<String, String> hbConditions;
-}
-{
- {
- res = null;
- action = null;
- condition = "";
- idCode = "";
- check = "";
- postAction = "";
- postCheck = "";
- commitPointSet = new ArrayList<String>();
- hbConditions = new HashMap<String, String>();
- }
- <HEAD>
- <BEGIN>
- <INTERFACE> (interfaceName = <IDENTIFIER>.image)
- <COMMIT_POINT_SET>
- (commitPoint = <IDENTIFIER>.image
- { commitPointSet.add(commitPoint); }
- )
- (<OR>
- (commitPoint = <IDENTIFIER>.image)
- {
- if (commitPointSet.contains(commitPoint)) {
- throw new ParseException(interfaceName + " has" +
- "duplicate commit point labels");
- }
- commitPointSet.add(commitPoint);
- }
- )*
-
- (<CONDITION> (condition = C_CPP_CODE()))?
- (
- <HB_CONDITION>
- (hbLabel = <IDENTIFIER>.image)
- (hbCondition = C_CPP_CODE())
- {
- if (hbConditions.containsKey(hbLabel)) {
- throw new ParseException(interfaceName + " has" +
- "duplicate happens-before condtion labels");
- }
- hbConditions.put(hbLabel, hbCondition);
- }
- )*
- (<ID> (idCode = C_CPP_CODE()))?
- (<CHECK> (check = C_CPP_CODE()))?
- (action = Action())?
- (<POST_ACTION> (postAction = C_CPP_CODE()))?
- (<POST_CHECK> (postCheck = C_CPP_CODE()))?
- <END>
- <TAIL>
- {
- res = new InterfaceConstruct(interfaceName, commitPointSet, condition,
- hbConditions, idCode, check, action, postAction, postCheck);
- return res;
- }
-}
-
-ActionSubConstruct Action() :
-{
- String type, name, expr, defineVarStr, code;
- ArrayList<DefineVar> defineVars;
-}
-{
- {
- defineVars = new ArrayList<DefineVar>();
- code = "";
- }
- <ACTION>
- (
- (
- (<DEFINEVAR> (defineVarStr = C_CPP_CODE())
- {
- int eqIdx = defineVarStr.indexOf('=');
- int typeEnd = defineVarStr.lastIndexOf(' ', eqIdx - 2);
- type = defineVarStr.substring(0, typeEnd);
- name = defineVarStr.substring(typeEnd + 1, eqIdx - 1);
- expr = defineVarStr.substring(eqIdx + 2);
- DefineVar defineVar = new DefineVar(type, name, expr);
- defineVars.add(defineVar);
- })* (<CODE> (code = C_CPP_CODE()))? )
- )
-
- {
- ActionSubConstruct res = new ActionSubConstruct(defineVars, code);
- return res;
- }
-}
-
-PotentialCPDefineConstruct Potential_commit_point_define() :
-{
- PotentialCPDefineConstruct res;
- String label, condition;
-}
-{
-
- { res = null; }
- <HEAD>
- <BEGIN>
- <POTENTIAL_COMMIT_POINT_DEFINE> (condition = C_CPP_CODE())
- <LABEL> (label = <IDENTIFIER>.image)
- <END>
- <TAIL>
- {
- res = new PotentialCPDefineConstruct(label, condition);
- return res;
- }
-}
-
-
-CPDefineConstruct Commit_point_define() :
-{
- CPDefineConstruct res;
- String label, potentialCPLabel, condition;
-}
-{
-
- { res = null; }
- <HEAD>
- <BEGIN>
- <COMMIT_POINT_DEFINE> (condition = C_CPP_CODE())
- <POTENTIAL_COMMIT_POINT_LABEL> (potentialCPLabel = <IDENTIFIER>.image)
- <LABEL> (label = <IDENTIFIER>.image)
- <END>
- <TAIL>
- {
- res = new CPDefineConstruct(label, potentialCPLabel, condition);
- return res;
- }