import java.io.FileInputStream;
import java.io.FileNotFoundException;
- class SpecParser {
+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.CPDefineConstruct;
+import edu.uci.eecs.specCompiler.specExtraction.CPDefineCheckConstruct;
+import edu.uci.eecs.specCompiler.specExtraction.ConditionalInterface;
+
+ public class SpecParser {
public static void main(String[] argvs)
throws ParseException, TokenMgrError {
try {
< #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ >
}
-void Start() :
-{}
+Construct Start() :
+{
+ Construct res;
+}
{
(
- LOOKAHEAD(3) Global_construct() |
- LOOKAHEAD(3) Interface() |
- LOOKAHEAD(3) Potential_commit_point_define() |
- LOOKAHEAD(3) Commit_point_define() |
- LOOKAHEAD(3) Commit_point_define_check()
+ LOOKAHEAD(3) res = Global_construct() |
+ LOOKAHEAD(3) res = Interface() |
+ LOOKAHEAD(3) res = Potential_commit_point_define() |
+ LOOKAHEAD(3) res = Commit_point_define() |
+ LOOKAHEAD(3) res = Commit_point_define_check()
)
<EOF>
+ { return res; }
}
-void Global_construct() :
+GlobalConstruct Global_construct() :
{
+ GlobalConstruct res;
+ String code;
}
{
+ { res = null; }
<HEAD>
<BEGIN>
- Global_define() (Interface_clusters())? (Happens_before())?
+ (code = Global_define())
+ { res = new GlobalConstruct(code); }
+ (Interface_clusters(res))?
+ (Happens_before(res))?
<END>
<TAIL>
+ {
+ res.unfoldInterfaceCluster();
+ System.out.println(res);
+ return res;
+ }
}
String C_CPP_CODE() :
}
)+
{
- System.out.println(text);
+ //System.out.println(text);
return text.toString();
}
}
-void Global_define() :
-{}
+String Global_define() :
+{
+ String code;
+}
{
- <GLOBAL_DEFINE> C_CPP_CODE()
+ <GLOBAL_DEFINE> (code = C_CPP_CODE())
+ {
+ return code;
+ }
}
-void Conditional_interface() :
-{}
+ConditionalInterface Conditional_interface() :
+{
+ String interfaceName, hbConditionLabel;
+}
{
- <IDENTIFIER> (<OPEN_BRACKET> <IDENTIFIER> <CLOSE_BRACKET>)*
+ {
+ hbConditionLabel = "";
+ }
+ interfaceName = <IDENTIFIER>.image (<OPEN_BRACKET> hbConditionLabel =
+ <IDENTIFIER>.image <CLOSE_BRACKET>)?
+ {
+ return new ConditionalInterface(interfaceName, hbConditionLabel);
+ }
}
-void Interface_cluster() :
-{}
+void Interface_cluster(GlobalConstruct inst) :
+{
+ String clusterName;
+ ConditionalInterface condInterface;
+}
{
- <IDENTIFIER> <EQUALS> <OPEN_PAREN>
- Conditional_interface() (<COMMA> Conditional_interface())*
+ (clusterName= <IDENTIFIER>.image)
+ <EQUALS> <OPEN_PAREN>
+ (condInterface = Conditional_interface()
+ { inst.addInterface2Cluster(clusterName, condInterface); }
+ )
+ (<COMMA> condInterface = Conditional_interface()
+ { inst.addInterface2Cluster(clusterName, condInterface); }
+ )*
<CLOSE_PAREN>
}
-void Interface_clusters() :
+void Interface_clusters(GlobalConstruct inst) :
{}
{
- <INTERFACE_CLUSTER> (Interface_cluster())+
+ <INTERFACE_CLUSTER> (Interface_cluster(inst))+
}
-void Happens_before() :
-{}
+void Happens_before(GlobalConstruct inst) :
+{
+ ConditionalInterface left, right;
+}
{
- <HAPPENS_BEFORE> (Conditional_interface() <HB_SYMBOL> Conditional_interface())+
+ <HAPPENS_BEFORE>
+ (
+ left = Conditional_interface() <HB_SYMBOL> right = Conditional_interface()
+ { inst.addHBCondition(left, right); }
+ )+
}
-void Interface() :
-{}
+InterfaceConstruct Interface() :
+{
+ InterfaceConstruct res;
+}
{
+ { res = null; }
<HEAD>
<BEGIN>
<INTERFACE> <IDENTIFIER>
(<POST_CHECK> C_CPP_CODE())?
<END>
<TAIL>
+ { return res; }
}
-void Potential_commit_point_define() :
-{}
+PotentialCPDefineConstruct Potential_commit_point_define() :
{
+ PotentialCPDefineConstruct res;
+}
+{
+
+ { res = null; }
<HEAD>
<BEGIN>
<POTENTIAL_COMMIT_POINT_DEFINE> C_CPP_CODE()
<LABEL> <IDENTIFIER>
<END>
<TAIL>
+ { return res; }
}
-void Commit_point_define() :
-{}
+CPDefineConstruct Commit_point_define() :
+{
+ CPDefineConstruct res;
+}
{
+
+ { res = null; }
<HEAD>
<BEGIN>
<COMMIT_POINT_DEFINE> C_CPP_CODE()
<LABEL> <IDENTIFIER>
<END>
<TAIL>
+ { return res; }
}
-void Commit_point_define_check() :
-{}
+CPDefineCheckConstruct Commit_point_define_check() :
{
+ CPDefineCheckConstruct res;
+}
+{
+
+ { res = null; }
<HEAD>
<BEGIN>
<COMMIT_POINT_DEFINE_CHECK> C_CPP_CODE()
<LABEL> <IDENTIFIER>
<END>
<TAIL>
+ { return res; }
}