001: // This file is part of KeY - Integrated Deductive Software Design
002: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003: // Universitaet Koblenz-Landau, Germany
004: // Chalmers University of Technology, Sweden
005: //
006: // The KeY system is protected by the GNU General Public License.
007: // See LICENSE.TXT for details.
008: //
009: //
010: /* Generated By:JavaCC: Do not edit this line. MyParser.java */
011: package de.uka.ilkd.key.casetool.together.patterns.HelperClasses.MyParser;
012:
013: import java.util.Vector;
014:
015: import com.togethersoft.openapi.util.propertyMap.PropertyMapEvent;
016: import com.togethersoft.openapi.util.propertyMap.PropertyMapListener;
017:
018: import de.uka.ilkd.key.casetool.together.patterns.HelperClasses.MyPatternBase.MyClassPatternBase;
019:
020: public class MyParser extends MyClassPatternBase implements
021: MyParserConstants {
022:
023: // private PropertyMap properties;
024: private String oclSchemeName;
025: private final static String SubclassesOf = "Subclasses of ";
026: private final static String nameOfMethod = "Name of method ";
027: private final static String nameOfClassAttribute = "Name of class-attribute ";
028: private final static String inClass = " in class ";
029: private Vector additionalProperties = new Vector();
030: // the format of an entry in mappingVector is: OCL-Scheme , Scheme-Name, Name of field containing the real name
031: private Vector mappingVector = new Vector();
032: private Vector constraintVector = new Vector();
033: private String commentString = "";
034: private String headerString = "";
035: private String constraint = "";
036: private Vector itemVector = new Vector();
037: private Vector placeVector = new Vector();
038: private Vector helpVector = new Vector();
039: private Vector idVector = new Vector();
040: private int id = 0;
041:
042: private static int counter = 0;
043:
044: public Vector getAdditionalPropertiesVector() {
045: return additionalProperties;
046: }
047:
048: public Vector getConstraintVector() {
049: return constraintVector;
050: }
051:
052: public Vector getMappingVector() {
053: return mappingVector;
054: }
055:
056: public Vector getPlaceVector() {
057: return placeVector;
058: }
059:
060: public String getCommentString() {
061: return commentString;
062: }
063:
064: public void parse(String oclName) throws ParseException {
065:
066: oclSchemeName = oclName;
067:
068: mappingVector.addElement(oclSchemeName);
069: mappingVector.addElement("selectedMethod");
070: mappingVector.addElement("");
071:
072: mappingVector.addElement(oclSchemeName);
073: mappingVector.addElement("selectedClass");
074: mappingVector.addElement("");
075:
076: mappingVector.addElement(oclSchemeName);
077: mappingVector.addElement("selectedParameter");
078: mappingVector.addElement("");
079:
080: mappingVector.addElement(oclSchemeName);
081: mappingVector.addElement("selectedAttribute");
082: mappingVector.addElement("");
083:
084: id = 0;
085:
086: start();
087:
088: }
089:
090: public final void start() throws ParseException {
091: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
092: case PATTERNMOD:
093: patternModifications();
094: break;
095: default:
096: jj_la1[0] = jj_gen;
097: }
098: label_1: while (true) {
099: schema();
100: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
101: case POSTCONDITION:
102: case PRECONDITION:
103: case PREPOSTCONDITION:
104: case INVARIANT:
105: break;
106: default:
107: jj_la1[1] = jj_gen;
108: break label_1;
109: }
110: }
111: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
112: case COMMENT:
113: comment();
114: break;
115: default:
116: jj_la1[2] = jj_gen;
117: }
118: jj_consume_token(0);
119: }
120:
121: public final void patternModifications() throws ParseException {
122: jj_consume_token(PATTERNMOD);
123: label_2: while (true) {
124: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
125: case MAPPINGS:
126: case SEVERALSUBCLASSES:
127: case MULTIINSTANCES:
128: case ADDSTRINGFIELD:
129: case ADDCLASSATTRIBUTE:
130: case ADDPARAMETER:
131: case ADDMETHOD:
132: break;
133: default:
134: jj_la1[3] = jj_gen;
135: break label_2;
136: }
137: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
138: case SEVERALSUBCLASSES:
139: jj_consume_token(SEVERALSUBCLASSES);
140: jj_consume_token(STRING1);
141: // create a multiple StringField
142: addClassPropertyItem(SubclassesOf + token.image, false,
143: true);
144: setMultiple(SubclassesOf + token.image, true);
145: // initially invisible
146: showItem(SubclassesOf + token.image, false);
147: // create an entry in the global vector, that contains the additional parsed classes and properties
148: additionalProperties.addElement(new Entry(
149: oclSchemeName, "canHaveSeveralSubclasses#",
150: token.image, SubclassesOf + token.image));
151: // add a propertyListener to do something, when the checkboxes change
152: // add this stringfield to the vector, which contains all fields etc. for this OCL-Schema
153: final String fieldName1 = token.image;
154: itemVector.addElement(oclSchemeName);
155: itemVector.addElement("visible");
156: itemVector.addElement(SubclassesOf + fieldName1);
157: addPropertyMapListener(oclSchemeName,
158: new PropertyMapListener() {
159: boolean on = false;
160:
161: public void propertiesChanged(
162: PropertyMapEvent event) {
163: //IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Event: "+event.toString());
164: if (on) {
165: on = false;
166: showItemVector(itemVector,
167: oclSchemeName, false);
168: } else {
169: on = true;
170: showItemVector(itemVector,
171: oclSchemeName, true);
172: }
173: }
174: });
175: break;
176: case MULTIINSTANCES:
177: jj_consume_token(MULTIINSTANCES);
178: jj_consume_token(STRING1);
179: // create an entry in the global vector, that contains the additional parsed classes and properties
180: additionalProperties.addElement(new Entry(
181: oclSchemeName, "canHaveMultipleInstances#",
182: token.image, ""));
183:
184: final String fieldName2 = token.image;
185: itemVector.addElement(oclSchemeName);
186: itemVector.addElement("multiple");
187: itemVector.addElement(fieldName2);
188: addPropertyMapListener(oclSchemeName,
189: new PropertyMapListener() {
190: boolean on = false;
191:
192: public void propertiesChanged(
193: PropertyMapEvent event) {
194: //IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Event: "+event.toString());
195: if (on) {
196: counter -= 1;
197: on = false;
198: if (counter == 0)
199: showItemVector(itemVector,
200: oclSchemeName, false);
201: } else {
202: counter += 1;
203: on = true;
204: if (counter > 0)
205: showItemVector(itemVector,
206: oclSchemeName, true);
207: }
208: }
209: });
210: break;
211: case ADDMETHOD:
212: jj_consume_token(ADDMETHOD);
213: jj_consume_token(STRING1);
214: String methodName = token.image;
215: jj_consume_token(24);
216: jj_consume_token(STRING1);
217: // add a stringfield to enter the name of the new method
218: addStringFieldItem(nameOfMethod + methodName + inClass
219: + token.image);
220: showItem(nameOfMethod + methodName + inClass
221: + token.image, false);
222: additionalProperties.addElement(new Entry(
223: oclSchemeName, "addMethod#", token.image,
224: nameOfMethod + methodName + inClass
225: + token.image));
226: // add a listener to turn the stringfield on (if OCL-constraint is selected) and off
227: final String fieldName3 = methodName;
228: final String fieldName4 = token.image;
229: itemVector.addElement(oclSchemeName);
230: itemVector.addElement("visible");
231: itemVector.addElement(nameOfMethod + fieldName3
232: + inClass + fieldName4);
233: addPropertyMapListener(oclSchemeName,
234: new PropertyMapListener() {
235: boolean on = false;
236:
237: public void propertiesChanged(
238: PropertyMapEvent event) {
239: //IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Event: "+event.toString());
240: if (on) {
241: on = false;
242: showItemVector(itemVector,
243: oclSchemeName, false);
244: } else {
245: on = true;
246: showItemVector(itemVector,
247: oclSchemeName, true);
248: }
249: }
250: });
251: break;
252: case ADDSTRINGFIELD:
253: jj_consume_token(ADDSTRINGFIELD);
254: jj_consume_token(25);
255: jj_consume_token(STRING1);
256: String stringFieldName = token.image;
257: jj_consume_token(25);
258: // add a stringfield to enter the name of the new attribute
259: addStringFieldItem(stringFieldName);
260: showItem(stringFieldName, false);
261: additionalProperties.addElement(new Entry(
262: oclSchemeName, "addStringField#", "",
263: stringFieldName));
264: // add a listener to turn the stringfield on (if OCL-constraint is selected) and off
265: final String fieldName13 = stringFieldName;
266: itemVector.addElement(oclSchemeName);
267: itemVector.addElement("visible");
268: itemVector.addElement(fieldName13);
269: addPropertyMapListener(oclSchemeName,
270: new PropertyMapListener() {
271: boolean on = false;
272:
273: public void propertiesChanged(
274: PropertyMapEvent event) {
275: //IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Event: "+event.toString());
276: if (on) {
277: on = false;
278: showItemVector(itemVector,
279: oclSchemeName, false);
280: } else {
281: on = true;
282: showItemVector(itemVector,
283: oclSchemeName, true);
284: }
285: }
286: });
287: break;
288: case ADDPARAMETER:
289: jj_consume_token(ADDPARAMETER);
290: jj_consume_token(STRING1);
291: String name = token.image;
292: Vector values = new Vector();
293: jj_consume_token(24);
294: jj_consume_token(STRING1);
295: String type = "";
296: if (token.image.equals("ComboBox"))
297: type = "ComboBox";
298: label_3: while (true) {
299: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
300: case 24:
301: break;
302: default:
303: jj_la1[4] = jj_gen;
304: break label_3;
305: }
306: jj_consume_token(24);
307: jj_consume_token(25);
308: jj_consume_token(STRING1);
309: values.addElement(token.image);
310: jj_consume_token(25);
311: }
312: if (type.equals("ComboBox")) {
313: addComboboxFieldItem(name, values, values
314: .elementAt(0).toString());
315: showItem(name, false);
316: itemVector.addElement(oclSchemeName);
317: itemVector.addElement("visible");
318: itemVector.addElement(name);
319: addPropertyMapListener(oclSchemeName,
320: new PropertyMapListener() {
321: boolean on = false;
322:
323: public void propertiesChanged(
324: PropertyMapEvent event) {
325: //IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Event: "+event.toString());
326: if (on) {
327: on = false;
328: showItemVector(itemVector,
329: oclSchemeName, false);
330: } else {
331: on = true;
332: showItemVector(itemVector,
333: oclSchemeName, true);
334: }
335: }
336: });
337: }
338: break;
339: case ADDCLASSATTRIBUTE:
340: jj_consume_token(ADDCLASSATTRIBUTE);
341: jj_consume_token(STRING1);
342: String className = token.image;
343: jj_consume_token(24);
344: jj_consume_token(STRING1);
345: String attrName = token.image;
346: jj_consume_token(24);
347: jj_consume_token(STRING1);
348: additionalProperties.addElement(new Entry(
349: oclSchemeName, "addClassAttribute#", className
350: + "#" + token.image,
351: nameOfClassAttribute + attrName + inClass
352: + className));
353:
354: // add a stringfield to enter the name of the new attribute
355: addStringFieldItem(nameOfClassAttribute + attrName
356: + inClass + className);
357: showItem(nameOfClassAttribute + attrName + inClass
358: + className, false);
359: // add a listener to turn the stringfield on (if OCL-constraint is selected) and off
360: final String fieldName10 = attrName;
361: final String fieldName11 = className;
362: itemVector.addElement(oclSchemeName);
363: itemVector.addElement("visible");
364: itemVector.addElement(nameOfClassAttribute
365: + fieldName10 + inClass + fieldName11);
366: addPropertyMapListener(oclSchemeName,
367: new PropertyMapListener() {
368: boolean on = false;
369:
370: public void propertiesChanged(
371: PropertyMapEvent event) {
372: //IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Event: "+event.toString());
373: if (on) {
374: on = false;
375: showItemVector(itemVector,
376: oclSchemeName, false);
377: } else {
378: on = true;
379: showItemVector(itemVector,
380: oclSchemeName, true);
381: }
382: }
383: });
384: break;
385: case MAPPINGS:
386: jj_consume_token(MAPPINGS);
387: jj_consume_token(STRING1);
388: mappingVector.addElement(oclSchemeName);
389: mappingVector.addElement(token.image);
390: String helper = "";
391: jj_consume_token(24);
392: jj_consume_token(25);
393: jj_consume_token(STRING1);
394: helper += token.image;
395: jj_consume_token(25);
396: mappingVector.addElement(helper);
397: break;
398: default:
399: jj_la1[5] = jj_gen;
400: jj_consume_token(-1);
401: throw new ParseException();
402: }
403: }
404: }
405:
406: public final void schema() throws ParseException {
407: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
408: case POSTCONDITION:
409: case PRECONDITION:
410: case INVARIANT:
411: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
412: case POSTCONDITION:
413: jj_consume_token(POSTCONDITION);
414: break;
415: case PRECONDITION:
416: jj_consume_token(PRECONDITION);
417: break;
418: case INVARIANT:
419: jj_consume_token(INVARIANT);
420: break;
421: default:
422: jj_la1[6] = jj_gen;
423: jj_consume_token(-1);
424: throw new ParseException();
425: }
426: placeVector.addElement(oclSchemeName);
427: String prepost = token.image;
428: placeVector.addElement(prepost);
429: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
430: case 26:
431: jj_consume_token(26);
432: jj_consume_token(STRING1);
433: placeVector.addElement("method");
434: placeVector.addElement(token.image);
435: jj_consume_token(24);
436: jj_consume_token(STRING1);
437: placeVector.addElement(token.image);
438: placeVector.addElement((new Integer(id)).toString());
439: break;
440: case 27:
441: jj_consume_token(27);
442: jj_consume_token(STRING1);
443: placeVector.addElement("class");
444: placeVector.addElement(token.image);
445: // dummy-element to keep the same length
446: placeVector.addElement("");
447: placeVector.addElement((new Integer(id)).toString());
448: break;
449: default:
450: jj_la1[7] = jj_gen;
451: jj_consume_token(-1);
452: throw new ParseException();
453: }
454: jj_consume_token(SCHEMA);
455: constraint = "";
456: label_4: while (true) {
457: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
458: case STRING1:
459: break;
460: default:
461: jj_la1[8] = jj_gen;
462: break label_4;
463: }
464: jj_consume_token(STRING1);
465: constraint = constraint + token.image + "\n";
466:
467: if (headerString.equals("")) {
468: headerString = "<h3>" + oclSchemeName + "</h3>";
469: if (prepost.equals("precondition#"))
470: headerString = headerString
471: + "<h4>Precondition</h4>";
472: if (prepost.equals("postcondition#"))
473: headerString = headerString
474: + "<h4>Postcondition</h4>";
475: if (prepost.equals("invariant#"))
476: headerString = headerString
477: + "<h4>Invariant</h4>";
478: }
479: commentString = commentString + "<br>" + token.image
480: + "\n";
481: }
482: constraintVector.addElement(constraint);
483: constraintVector.addElement((new Integer(id)).toString());
484: id++;
485: break;
486: case PREPOSTCONDITION:
487: jj_consume_token(PREPOSTCONDITION);
488: placeVector.addElement(oclSchemeName);
489: helpVector.removeAllElements();
490: helpVector.addElement(oclSchemeName);
491: String s = "";
492: helpVector.addElement("postcondition#");
493: placeVector.addElement("precondition#");
494: jj_consume_token(26);
495: jj_consume_token(STRING1);
496: placeVector.addElement("method");
497: helpVector.addElement("method");
498: s = token.image;
499: placeVector.addElement(s);
500: helpVector.addElement(s);
501: jj_consume_token(24);
502: jj_consume_token(STRING1);
503: s = token.image;
504: placeVector.addElement(s);
505: placeVector.addElement((new Integer(id)).toString());
506: helpVector.addElement(s);
507: for (int i = 0; i < helpVector.size(); i++)
508: placeVector.addElement(helpVector.elementAt(i));
509: placeVector.addElement((new Integer((id + 1))).toString());
510: jj_consume_token(SCHEMA);
511: constraint = "";
512: label_5: while (true) {
513: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
514: case STRING1:
515: break;
516: default:
517: jj_la1[9] = jj_gen;
518: break label_5;
519: }
520: jj_consume_token(STRING1);
521: constraint = constraint + token.image + "\n";
522:
523: if (headerString.equals("")) {
524: headerString = "<h3>" + oclSchemeName
525: + "</h3><h4>Precondition</h4>";
526: }
527: commentString = commentString + "<br>" + token.image
528: + "\n";
529: }
530: constraintVector.addElement(constraint);
531: constraintVector.addElement((new Integer(id)).toString());
532: id++;
533: jj_consume_token(SCHEMA);
534: constraint = "";
535: label_6: while (true) {
536: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
537: case STRING1:
538: break;
539: default:
540: jj_la1[10] = jj_gen;
541: break label_6;
542: }
543: jj_consume_token(STRING1);
544: constraint = constraint + token.image + "\n";
545:
546: if (headerString.equals("")) {
547: headerString = "<h3>" + oclSchemeName
548: + "</h3><h4>Postcondition</h4>";
549: }
550: commentString = commentString + "<br>" + token.image
551: + "\n";
552: }
553: constraintVector.addElement(constraint);
554: constraintVector.addElement((new Integer(id)).toString());
555: id++;
556: break;
557: default:
558: jj_la1[11] = jj_gen;
559: jj_consume_token(-1);
560: throw new ParseException();
561: }
562: }
563:
564: public final void comment() throws ParseException {
565: jj_consume_token(COMMENT);
566: label_7: while (true) {
567: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
568: case STRING1:
569: break;
570: default:
571: jj_la1[12] = jj_gen;
572: break label_7;
573: }
574: jj_consume_token(STRING1);
575: commentString = "<p>" + headerString + "</p>" + "<p>"
576: + token.image + "</p>" + "<p>" + commentString
577: + "</p>";
578: }
579: }
580:
581: public MyParserTokenManager token_source;
582: ASCII_CharStream jj_input_stream;
583: public Token token, jj_nt;
584: private int jj_ntk;
585: private int jj_gen;
586: private final int[] jj_la1 = new int[13];
587: private final static int[] jj_la1_0 = { 0x20, 0x78000, 0x80,
588: 0x7f00, 0x1000000, 0x7f00, 0x58000, 0xc000000, 0x800000,
589: 0x800000, 0x800000, 0x78000, 0x800000, };
590:
591: public MyParser(java.io.InputStream stream) {
592: jj_input_stream = new ASCII_CharStream(stream, 1, 1);
593: token_source = new MyParserTokenManager(jj_input_stream);
594: token = new Token();
595: jj_ntk = -1;
596: jj_gen = 0;
597: for (int i = 0; i < 13; i++)
598: jj_la1[i] = -1;
599: }
600:
601: public void ReInit(java.io.InputStream stream) {
602: jj_input_stream.ReInit(stream, 1, 1);
603: token_source.ReInit(jj_input_stream);
604: token = new Token();
605: jj_ntk = -1;
606: jj_gen = 0;
607: for (int i = 0; i < 13; i++)
608: jj_la1[i] = -1;
609: }
610:
611: public MyParser(java.io.Reader stream) {
612: jj_input_stream = new ASCII_CharStream(stream, 1, 1);
613: token_source = new MyParserTokenManager(jj_input_stream);
614: token = new Token();
615: jj_ntk = -1;
616: jj_gen = 0;
617: for (int i = 0; i < 13; i++)
618: jj_la1[i] = -1;
619: }
620:
621: public void ReInit(java.io.Reader stream) {
622: jj_input_stream.ReInit(stream, 1, 1);
623: token_source.ReInit(jj_input_stream);
624: token = new Token();
625: jj_ntk = -1;
626: jj_gen = 0;
627: for (int i = 0; i < 13; i++)
628: jj_la1[i] = -1;
629: }
630:
631: public MyParser(MyParserTokenManager tm) {
632: token_source = tm;
633: token = new Token();
634: jj_ntk = -1;
635: jj_gen = 0;
636: for (int i = 0; i < 13; i++)
637: jj_la1[i] = -1;
638: }
639:
640: public void ReInit(MyParserTokenManager tm) {
641: token_source = tm;
642: token = new Token();
643: jj_ntk = -1;
644: jj_gen = 0;
645: for (int i = 0; i < 13; i++)
646: jj_la1[i] = -1;
647: }
648:
649: private final Token jj_consume_token(int kind)
650: throws ParseException {
651: Token oldToken;
652: if ((oldToken = token).next != null)
653: token = token.next;
654: else
655: token = token.next = token_source.getNextToken();
656: jj_ntk = -1;
657: if (token.kind == kind) {
658: jj_gen++;
659: return token;
660: }
661: token = oldToken;
662: jj_kind = kind;
663: throw generateParseException();
664: }
665:
666: public final Token getNextToken() {
667: if (token.next != null)
668: token = token.next;
669: else
670: token = token.next = token_source.getNextToken();
671: jj_ntk = -1;
672: jj_gen++;
673: return token;
674: }
675:
676: public final Token getToken(int index) {
677: Token t = token;
678: for (int i = 0; i < index; i++) {
679: if (t.next != null)
680: t = t.next;
681: else
682: t = t.next = token_source.getNextToken();
683: }
684: return t;
685: }
686:
687: private final int jj_ntk() {
688: if ((jj_nt = token.next) == null)
689: return (jj_ntk = (token.next = token_source.getNextToken()).kind);
690: else
691: return (jj_ntk = jj_nt.kind);
692: }
693:
694: private java.util.Vector jj_expentries = new java.util.Vector();
695: private int[] jj_expentry;
696: private int jj_kind = -1;
697:
698: public final ParseException generateParseException() {
699: jj_expentries.removeAllElements();
700: boolean[] la1tokens = new boolean[28];
701: for (int i = 0; i < 28; i++) {
702: la1tokens[i] = false;
703: }
704: if (jj_kind >= 0) {
705: la1tokens[jj_kind] = true;
706: jj_kind = -1;
707: }
708: for (int i = 0; i < 13; i++) {
709: if (jj_la1[i] == jj_gen) {
710: for (int j = 0; j < 32; j++) {
711: if ((jj_la1_0[i] & (1 << j)) != 0) {
712: la1tokens[j] = true;
713: }
714: }
715: }
716: }
717: for (int i = 0; i < 28; i++) {
718: if (la1tokens[i]) {
719: jj_expentry = new int[1];
720: jj_expentry[0] = i;
721: jj_expentries.addElement(jj_expentry);
722: }
723: }
724: int[][] exptokseq = new int[jj_expentries.size()][];
725: for (int i = 0; i < jj_expentries.size(); i++) {
726: exptokseq[i] = (int[]) jj_expentries.elementAt(i);
727: }
728: return new ParseException(token, exptokseq, tokenImage);
729: }
730:
731: public final void enable_tracing() {
732: }
733:
734: public final void disable_tracing() {
735: }
736:
737: }
|