/* Generated By:JavaCC: Do not edit this line. DeploymentParser.java */ /** * This class is part of project that implements Aspectual Components * * Author: Predrag Petkovic, predrag@ccs.neu.edu * Northeastern University * * This parser take as an entry file (or input stream) that contains * Deployment Map of an aspectual component and returns internal representation * of it. */ package edu.neu.ccs.aspects.map; import java.util.Vector; public class DeploymentParser implements DeploymentParserConstants { public static void main(String args[]) { DeploymentParser parser; if (args.length == 0) { System.out.println("Deployment Parser: Reading from standard input . . ."); parser = new DeploymentParser(System.in); } else if (args.length == 1) { System.out.println("Deployment Parser: Reading from file " + args[0] + " . . ."); try { parser = new DeploymentParser(new java.io.FileInputStream(args[0])); } catch (java.io.FileNotFoundException e) { System.out.println("Deployment Parser: File " + args[0] + " not found."); return; } } else { System.out.println("Deployment Parser : Usage is one of:"); System.out.println(" java DeploymentParser < inputfile"); System.out.println("OR"); System.out.println(" java DeploymentParser inputfile"); return; } try { ComponentMap map = parser.Deployment(); System.out.println("Deployment: Deployment parsed successfully."); System.out.println(map); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Deployment Parser : Encountered errors during parse."); } } public static ComponentMap parse(java.io.InputStream input) throws ParseException { DeploymentParser parser = new DeploymentParser(input); return parser.Deployment(); } /***************************************** * THE JAVA LANGUAGE GRAMMAR STARTS HERE * *****************************************/ /* * Program structuring syntax follows. */ static final public ComponentMap Deployment() throws ParseException { ComponentMap Cmap = new ComponentMap(); Cmap.componentName = Component(); Applications(); jj_consume_token(LBRACE); Cmap.participantMaps = ParticipantMaps(); jj_consume_token(RBRACE); jj_consume_token(0); {if (true) return Cmap;} throw new Error("Missing return statement in function"); } static final public String Component() throws ParseException { String s; jj_consume_token(COMPONENT); s = Name(); jj_consume_token(SEMICOLOMN); {if (true) return s;} throw new Error("Missing return statement in function"); } static final public void Applications() throws ParseException { jj_consume_token(APPLICATIONS); Name(); label_1: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[0] = jj_gen; break label_1; } jj_consume_token(COMMA); Name(); } jj_consume_token(SEMICOLOMN); } static final public Vector ParticipantMaps() throws ParseException { Vector maps = new Vector(); ParticipantMap participantMap; label_2: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: ; break; default: jj_la1[1] = jj_gen; break label_2; } participantMap = _ParticipantMap(); maps.add(participantMap); } {if (true) return maps;} throw new Error("Missing return statement in function"); } static final public ParticipantMap _ParticipantMap() throws ParseException { ParticipantMap participantMap = new ParticipantMap(); participantMap.participantName = ParticipantName(); jj_consume_token(ASSIGN); participantMap.applicationClassName = ApplicationNameList(); jj_consume_token(LBRACE); participantMap.methodMaps = MethodMaps(); jj_consume_token(RBRACE); {if (true) return participantMap;} throw new Error("Missing return statement in function"); } static final public Vector MethodMaps() throws ParseException { Vector methodMaps = new Vector(); MethodMap methodMap; label_3: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: ; break; default: jj_la1[2] = jj_gen; break label_3; } methodMap = _MethodMap(); methodMaps.add(methodMap); } {if (true) return methodMaps;} throw new Error("Missing return statement in function"); } static final public MethodMap _MethodMap() throws ParseException { MethodMap methodMap = new MethodMap(); methodMap.participantMethod = ParticipantMethod(); jj_consume_token(ASSIGN); methodMap.applicationMethods = ApplicationMethods(); jj_consume_token(SEMICOLOMN); {if (true) return methodMap;} throw new Error("Missing return statement in function"); } static final public String ParticipantMethod() throws ParseException { Token t; t = jj_consume_token(IDENTIFIER); {if (true) return t.image;} throw new Error("Missing return statement in function"); } static final public Vector ApplicationMethods() throws ParseException { Vector v = new Vector(); ApplicationMethod appM; appM = MappedMethod(); v.add(appM); label_4: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[3] = jj_gen; break label_4; } jj_consume_token(COMMA); appM = MappedMethod(); v.add(appM); } {if (true) return v;} throw new Error("Missing return statement in function"); } static final public ApplicationMethod MappedMethod() throws ParseException { ApplicationMethod appM = new ApplicationMethod(); Token t; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: t = jj_consume_token(IDENTIFIER); appM.name = t.image; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STAR: jj_consume_token(STAR); appM.preffix = true; break; default: jj_la1[4] = jj_gen; ; } {if (true) return appM;} break; case STAR: jj_consume_token(STAR); appM.suffix = true;; t = jj_consume_token(IDENTIFIER); appM.name = t.image; {if (true) return appM;} break; default: jj_la1[5] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } static final public String Name() throws ParseException { String name; Token t; t = jj_consume_token(IDENTIFIER); name = t.image; label_5: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DOT: ; break; default: jj_la1[6] = jj_gen; break label_5; } jj_consume_token(DOT); t = jj_consume_token(IDENTIFIER); name += "." + t.image; } {if (true) return name;} throw new Error("Missing return statement in function"); } static final public String ParticipantName() throws ParseException { Token t; t = jj_consume_token(IDENTIFIER); {if (true) return t.image;} throw new Error("Missing return statement in function"); } static final public Vector ApplicationNameList() throws ParseException { Vector v = new Vector(); String s; s = Name(); v.add(s); label_6: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[7] = jj_gen; break label_6; } jj_consume_token(COMMA); s = Name(); v.add(s); } {if (true) return v;} throw new Error("Missing return statement in function"); } static private boolean jj_initialized_once = false; static public DeploymentParserTokenManager token_source; static ASCII_UCodeESC_CharStream jj_input_stream; static public Token token, jj_nt; static private int jj_ntk; static private int jj_gen; static final private int[] jj_la1 = new int[8]; static final private int[] jj_la1_0 = {0x400000,0x20000,0x20000,0x400000,0x4000000,0x4020000,0x1000000,0x400000,}; public DeploymentParser(java.io.InputStream stream) { if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. You must"); System.out.println(" either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1); token_source = new DeploymentParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 8; i++) jj_la1[i] = -1; } static public void ReInit(java.io.InputStream stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 8; i++) jj_la1[i] = -1; } public DeploymentParser(DeploymentParserTokenManager tm) { if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. You must"); System.out.println(" either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 8; i++) jj_la1[i] = -1; } public void ReInit(DeploymentParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 8; i++) jj_la1[i] = -1; } static final private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; if (token.kind == kind) { jj_gen++; return token; } token = oldToken; jj_kind = kind; throw generateParseException(); } static final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; jj_gen++; return token; } static final public Token getToken(int index) { Token t = token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); } return t; } static final private int jj_ntk() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else return (jj_ntk = jj_nt.kind); } static private java.util.Vector jj_expentries = new java.util.Vector(); static private int[] jj_expentry; static private int jj_kind = -1; static final public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[27]; for (int i = 0; i < 27; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 8; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<