} else if (isNode(decl, "static_block")) {
parseStaticBlockDecl(cn, decl.getChild("static_block_declaration"));
} else if (isNode(decl,"block")) {
- } else if (isNode(decl,"location_order_declaration")) {
- parseLocationOrder(cn,decl.getChild("location_order_list"));
} else throw new Error();
}
}
}
- private void parseLocationOrder(ClassDescriptor cd, ParseNode pn) {
- ParseNodeVector pnv = pn.getChildren();
- Lattice<String> locOrder =
- new Lattice<String>("_top_","_bottom_");
- Set<String> spinLocSet=new HashSet<String>();
- String thisLoc=null;
- for (int i = 0; i < pnv.size(); i++) {
- ParseNode loc = pnv.elementAt(i);
- if(isNode(loc,"location_property")) {
- if(loc.getFirstChild().getLabel().equals("location_multi")){
- String spinLoc=loc.getFirstChild().getFirstChild().getLabel();
- spinLocSet.add(spinLoc);
- }else{
- thisLoc=loc.getFirstChild().getFirstChild().getLabel();
- }
- } else {
- if(loc.getChildren().size()==1){
- String locIentifier=loc.getChildren().elementAt(0).getLabel();
- locOrder.put(locIentifier);
- }else{
- String lowerLoc=loc.getChildren().elementAt(0).getLabel();
- String higherLoc= loc.getChildren().elementAt(1).getLabel();
- locOrder.put(higherLoc, lowerLoc);
- if (locOrder.isIntroducingCycle(higherLoc)) {
- throw new Error("Error: the order relation " + lowerLoc + " < " + higherLoc
- + " introduces a cycle.");
- }
- }
- }
- }
- if(spinLocSet.size()>0) {
- //checking if location is actually defined in the hierarchy
- for (Iterator iterator = spinLocSet.iterator(); iterator.hasNext(); ) {
- String locID = (String) iterator.next();
- if(!locOrder.containsKey(locID)) {
- throw new Error("Error: The spinning location '"+
- locID + "' is not defined in the hierarchy of the class '"+cd +"'.");
- }
- }
- state.addLocationProperty(new Pair(cd,"spin"), spinLocSet);
- }
- if(thisLoc!=null){
- state.addLocationProperty(new Pair(cd,"this"), thisLoc);
- }
- state.addLocationOrder(cd, locOrder);
- }
-
private void parseClassMember(ClassDescriptor cn, ParseNode pn) {
ParseNode fieldnode=pn.getChild("field");
if (fieldnode!=null) {
non terminal ParseNode constructor_declaration, constructor_declarator;
non terminal ParseNode constructor_body;
non terminal ParseNode explicit_constructor_invocation;
-// 19.8.6) Location Hierarchy Declarations
-non terminal ParseNode location_order_declaration, location_order_list, location_order;
// 19.9.1) Interface Declarations
non terminal ParseNode interface_declaration;
//non terminal ParseNode normal_interface_declaration
| block:block {:
RESULT=(new ParseNode("block",parser.lexer.line_num)).addChild(block).getRoot();
:}
- | location_order_declaration:lod {:
- RESULT=(new ParseNode("location_order_declaration",parser.lexer.line_num)).addChild(lod).getRoot();
- :}
;
class_member_declaration ::=
//failure aware computation
// | primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
;
-// 19.8.6) Location Hierarchy Declarations
-location_order_declaration ::= LOCDEF LBRACE location_order_list:lol RBRACE {:
- RESULT=lol;
- :}
- ;
-location_order_list ::=
- location_order:lo {:
- ParseNode pn=new ParseNode("location_order_list",parser.lexer.line_num);
- pn.addChild(lo);
- RESULT=pn;
- :}
- | location_order_list:lol COMMA location_order:lo {:
- lol.addChild(lo);
- RESULT=lol;
- :}
- ;
-location_order ::=
- IDENTIFIER:loc1 LT IDENTIFIER:loc2{:
- ParseNode pn=new ParseNode("location_order",parser.lexer.line_num);
- pn.addChild(loc1);
- pn.addChild(loc2);
- RESULT=pn;
- :}
- | IDENTIFIER:loc MULT{:
- ParseNode pn=new ParseNode("location_property",parser.lexer.line_num);
- pn.addChild("location_multi").addChild(loc);
- RESULT=pn;
- :}
- | IDENTIFIER:loc {:
- ParseNode pn=new ParseNode("location_order",parser.lexer.line_num);
- pn.addChild(loc);
- RESULT=pn;
- :}
- | THIS COLON IDENTIFIER:loc {:
- ParseNode pn=new ParseNode("location_property",parser.lexer.line_num);
- pn.addChild("location_this").addChild(loc);
- RESULT=pn;
- :}
- ;
-
// 19.9) Interfaces
// 19.9.1) Interface Declarations