From 944b6af217212532a88e314df52a4cf5a99ed36a Mon Sep 17 00:00:00 2001 From: Peizhao Ou Date: Fri, 11 Oct 2013 00:44:27 -0700 Subject: [PATCH] add more, GlobalConstruct parsed --- grammer/spec-compiler.jj | 138 +++++++++++++----- .../CPDefineCheckConstruct.java | 5 + .../specExtraction/CPDefineConstruct.java | 5 + .../specExtraction/ConditionalInterface.java | 30 ++++ .../specExtraction/Construct.java | 11 ++ .../specExtraction/GlobalConstruct.java | 83 +++++++++++ .../specExtraction/InterfaceConstruct.java | 5 + .../PotentialCPDefineConstruct.java | 5 + 8 files changed, 248 insertions(+), 34 deletions(-) create mode 100644 src/edu/uci/eecs/specCompiler/specExtraction/CPDefineCheckConstruct.java create mode 100644 src/edu/uci/eecs/specCompiler/specExtraction/CPDefineConstruct.java create mode 100644 src/edu/uci/eecs/specCompiler/specExtraction/ConditionalInterface.java create mode 100644 src/edu/uci/eecs/specCompiler/specExtraction/Construct.java create mode 100644 src/edu/uci/eecs/specCompiler/specExtraction/GlobalConstruct.java create mode 100644 src/edu/uci/eecs/specCompiler/specExtraction/InterfaceConstruct.java create mode 100644 src/edu/uci/eecs/specCompiler/specExtraction/PotentialCPDefineConstruct.java diff --git a/grammer/spec-compiler.jj b/grammer/spec-compiler.jj index 4a7d11a..a006e7b 100644 --- a/grammer/spec-compiler.jj +++ b/grammer/spec-compiler.jj @@ -70,7 +70,15 @@ package edu.uci.eecs.specCompiler.grammerParser; 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 { @@ -280,28 +288,42 @@ TOKEN : < #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() ) + { return res; } } -void Global_construct() : +GlobalConstruct Global_construct() : { + GlobalConstruct res; + String code; } { + { res = null; } - Global_define() (Interface_clusters())? (Happens_before())? + (code = Global_define()) + { res = new GlobalConstruct(code); } + (Interface_clusters(res))? + (Happens_before(res))? + { + res.unfoldInterfaceCluster(); + System.out.println(res); + return res; + } } String C_CPP_CODE() : @@ -335,46 +357,78 @@ String C_CPP_CODE() : } )+ { - System.out.println(text); + //System.out.println(text); return text.toString(); } } -void Global_define() : -{} +String Global_define() : +{ + String code; +} { - C_CPP_CODE() + (code = C_CPP_CODE()) + { + return code; + } } -void Conditional_interface() : -{} +ConditionalInterface Conditional_interface() : +{ + String interfaceName, hbConditionLabel; +} { - ( )* + { + hbConditionLabel = ""; + } + interfaceName = .image ( hbConditionLabel = + .image )? + { + return new ConditionalInterface(interfaceName, hbConditionLabel); + } } -void Interface_cluster() : -{} +void Interface_cluster(GlobalConstruct inst) : +{ + String clusterName; + ConditionalInterface condInterface; +} { - - Conditional_interface() ( Conditional_interface())* + (clusterName= .image) + + (condInterface = Conditional_interface() + { inst.addInterface2Cluster(clusterName, condInterface); } + ) + ( condInterface = Conditional_interface() + { inst.addInterface2Cluster(clusterName, condInterface); } + )* } -void Interface_clusters() : +void Interface_clusters(GlobalConstruct inst) : {} { - (Interface_cluster())+ + (Interface_cluster(inst))+ } -void Happens_before() : -{} +void Happens_before(GlobalConstruct inst) : +{ + ConditionalInterface left, right; +} { - (Conditional_interface() Conditional_interface())+ + + ( + left = Conditional_interface() right = Conditional_interface() + { inst.addHBCondition(left, right); } + )+ } -void Interface() : -{} +InterfaceConstruct Interface() : +{ + InterfaceConstruct res; +} { + { res = null; } @@ -388,23 +442,33 @@ void Interface() : ( C_CPP_CODE())? + { return res; } } -void Potential_commit_point_define() : -{} +PotentialCPDefineConstruct Potential_commit_point_define() : { + PotentialCPDefineConstruct res; +} +{ + + { res = null; } C_CPP_CODE()