From da39e68253fdb76719573f28eecc23db2ee08dfe Mon Sep 17 00:00:00 2001 From: Peizhao Ou Date: Fri, 11 Oct 2013 16:18:03 -0700 Subject: [PATCH] parsing passed --- grammer/spec-compiler.jj | 112 ++++++++++++++---- .../CPDefineCheckConstruct.java | 16 ++- .../specExtraction/CPDefineConstruct.java | 19 ++- .../specExtraction/GlobalConstruct.java | 6 +- .../specExtraction/InterfaceConstruct.java | 52 ++++++++ .../PotentialCPDefineConstruct.java | 16 ++- 6 files changed, 189 insertions(+), 32 deletions(-) diff --git a/grammer/spec-compiler.jj b/grammer/spec-compiler.jj index a006e7b..ca38b5f 100644 --- a/grammer/spec-compiler.jj +++ b/grammer/spec-compiler.jj @@ -69,6 +69,9 @@ package edu.uci.eecs.specCompiler.grammerParser; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import edu.uci.eecs.specCompiler.specExtraction.Construct; import edu.uci.eecs.specCompiler.specExtraction.GlobalConstruct; @@ -301,7 +304,10 @@ Construct Start() : LOOKAHEAD(3) res = Commit_point_define_check() ) - { return res; } + { + System.out.println(res); + return res; + } } GlobalConstruct Global_construct() : @@ -321,7 +327,6 @@ GlobalConstruct Global_construct() : { res.unfoldInterfaceCluster(); - System.out.println(res); return res; } } @@ -425,73 +430,128 @@ void Happens_before(GlobalConstruct inst) : InterfaceConstruct Interface() : { - InterfaceConstruct res; + InterfaceConstruct res; + String interfaceName, condition, idCode, check, action, postAction, + postCheck, commitPoint, hbLabel, hbCondition; + ArrayList commitPointSet; + HashMap hbConditions; } { - { res = null; } + { + res = null; + condition = ""; + idCode = ""; + check = ""; + action = ""; + postAction = ""; + postCheck = ""; + commitPointSet = new ArrayList(); + hbConditions = new HashMap(); + } - - ( )* - ( C_CPP_CODE())? - ( C_CPP_CODE())* - ( C_CPP_CODE())? - ( C_CPP_CODE())? - ( C_CPP_CODE())? - ( C_CPP_CODE())? - ( C_CPP_CODE())? + (interfaceName = .image) + + (commitPoint = .image + { commitPointSet.add(commitPoint); } + ) + ( + (commitPoint = .image) + { + if (commitPointSet.contains(commitPoint)) { + throw new ParseException(interfaceName + " has" + + "duplicate commit point labels"); + } + commitPointSet.add(commitPoint); + } + )* + + ( (condition = C_CPP_CODE()))? + ( + + (hbLabel = .image) + (hbCondition = C_CPP_CODE()) + { + if (hbConditions.containsKey(hbLabel)) { + throw new ParseException(interfaceName + " has" + + "duplicate happens-before condtion labels"); + } + hbConditions.put(hbLabel, hbCondition); + } + )* + ( (idCode = C_CPP_CODE()))? + ( (check = C_CPP_CODE()))? + ( (action = C_CPP_CODE()))? + ( (postAction = C_CPP_CODE()))? + ( (postCheck = C_CPP_CODE()))? - { return res; } + { + res = new InterfaceConstruct(interfaceName, commitPointSet, condition, + hbConditions, idCode, check, action, postAction, postCheck); + return res; + } } PotentialCPDefineConstruct Potential_commit_point_define() : { - PotentialCPDefineConstruct res; + PotentialCPDefineConstruct res; + String label, condition; } { { res = null; } - C_CPP_CODE() -