1
2 package eu.simuline.relana.parser;
3
4 import eu.simuline.relana.model.CClass;
5 import eu.simuline.relana.model.SClass;
6 import eu.simuline.relana.model.CClassLoader;
7 import eu.simuline.relana.model.ClassLocator;
8 import eu.simuline.relana.model.CClassLink;
9 import eu.simuline.relana.model.Package;
10 import eu.simuline.relana.model.ProbDistr;
11 import eu.simuline.relana.model.Deficiency;
12 import eu.simuline.relana.model.MapDecl;
13
14 import eu.simuline.relana.expressions.Type;
15
16 import java.math.BigDecimal;
17
18 import java.io.Reader;
19 import java.io.IOException;
20 import java.io.StringReader;
21 import java.io.InputStream;
22
23 import java.util.List;
24 import java.util.ArrayList;
25 import java.util.Map;
26 import java.util.HashMap;
27 import java.util.TreeMap;
28 import java.util.Set;
29 import java.util.HashSet;
30 import java.util.Collections;
31
32 import org.antlr.v4.runtime.atn.*;
33 import org.antlr.v4.runtime.dfa.DFA;
34 import org.antlr.v4.runtime.*;
35 import org.antlr.v4.runtime.misc.*;
36 import org.antlr.v4.runtime.tree.*;
37 import java.util.List;
38 import java.util.Iterator;
39 import java.util.ArrayList;
40
41 @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
42 public class CClassParser extends Parser {
43 static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }
44
45 protected static final DFA[] _decisionToDFA;
46 protected static final PredictionContextCache _sharedContextCache =
47 new PredictionContextCache();
48 public static final int
49 T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, WS=9,
50 SingleLineComment=10, MultiLineComment=11, PACKAGE=12, CCLASS=13, EXTENDS=14,
51 REDECLARE=15, MAPS=16, MAP=17, MAPSTO=18, IDDOMAIN=19, COMPONENTS=20,
52 EFFECTS=21, INPUT=22, OUTPUT=23, REPLACE=24, INV=25, COV=26, CONT=27,
53 END=28, SEP=29, UNION=30, INTERSECT=31, COMPLEMENT=32, NAME=33, FLOAT=34;
54 public static final int
55 RULE_cClass = 0, RULE_getSuperClass = 1, RULE_getPath = 2, RULE_maps = 3,
56 RULE_addMap = 4, RULE_add2DefMap = 5, RULE_addDef = 6, RULE_addToIdDom = 7,
57 RULE_effects = 8, RULE_effect = 9, RULE_addAccessModifier = 10, RULE_getDistr = 11,
58 RULE_replDistr = 12, RULE_addProbAlloc = 13, RULE_skipFormula = 14, RULE_appendFormula = 15,
59 RULE_appendToken = 16, RULE_appendOp = 17, RULE_components = 18, RULE_component = 19;
60 public static final String[] ruleNames = {
61 "cClass", "getSuperClass", "getPath", "maps", "addMap", "add2DefMap",
62 "addDef", "addToIdDom", "effects", "effect", "addAccessModifier", "getDistr",
63 "replDistr", "addProbAlloc", "skipFormula", "appendFormula", "appendToken",
64 "appendOp", "components", "component"
65 };
66
67 private static final String[] _LITERAL_NAMES = {
68 null, "'{'", "'}'", "':'", "'-->'", "'('", "')'", "'<'", "'>'", null,
69 null, null, "'package'", "'class'", "'extends'", "'redeclare'", "'maps'",
70 "'map'", "'|-->'", "'id:'", "'components'", "'effects'", "'input'", "'output'",
71 "'replace'", "'!'", "','", "'''", "';'", "'.'", "'|'", "'&'", "'~'"
72 };
73 private static final String[] _SYMBOLIC_NAMES = {
74 null, null, null, null, null, null, null, null, null, "WS", "SingleLineComment",
75 "MultiLineComment", "PACKAGE", "CCLASS", "EXTENDS", "REDECLARE", "MAPS",
76 "MAP", "MAPSTO", "IDDOMAIN", "COMPONENTS", "EFFECTS", "INPUT", "OUTPUT",
77 "REPLACE", "INV", "COV", "CONT", "END", "SEP", "UNION", "INTERSECT", "COMPLEMENT",
78 "NAME", "FLOAT"
79 };
80 public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
81
82
83
84
85 @Deprecated
86 public static final String[] tokenNames;
87 static {
88 tokenNames = new String[_SYMBOLIC_NAMES.length];
89 for (int i = 0; i < tokenNames.length; i++) {
90 tokenNames[i] = VOCABULARY.getLiteralName(i);
91 if (tokenNames[i] == null) {
92 tokenNames[i] = VOCABULARY.getSymbolicName(i);
93 }
94
95 if (tokenNames[i] == null) {
96 tokenNames[i] = "<INVALID>";
97 }
98 }
99 }
100
101 @Override
102 @Deprecated
103 public String[] getTokenNames() {
104 return tokenNames;
105 }
106
107 @Override
108
109 public Vocabulary getVocabulary() {
110 return VOCABULARY;
111 }
112
113 @Override
114 public String getGrammarFileName() { return "CClass.g4"; }
115
116 @Override
117 public String[] getRuleNames() { return ruleNames; }
118
119 @Override
120 public String getSerializedATN() { return _serializedATN; }
121
122 @Override
123 public ATN getATN() { return _ATN; }
124
125
126
127
128
129
130
131 private CClassLoader classLoader;
132
133 private ClassLocator loc;
134 private CClass cClass;
135 private boolean exceptionThrown;
136
137
138
139
140
141
142 static class FormulaWrapper {
143 private int lineNumber;
144 private int colnNumber;
145 private String formula;
146
147 FormulaWrapper(int lineNumber,
148 int colnNumber,
149 String formula) {
150 this.lineNumber = lineNumber;
151 this.colnNumber = colnNumber;
152 this.formula = formula;
153 }
154 }
155
156
157
158
159
160 private static CommonTokenStream inputStream2tokenStream(InputStream str)
161 throws IOException {
162 CharStream input = CharStreams.fromStream(str);
163 CClassLexer lexer = new CClassLexer(input);
164 return new CommonTokenStream(lexer);
165 }
166
167 public CClassParser(InputStream str) throws IOException {
168 this(inputStream2tokenStream(str));
169 }
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186 private String getLocation() {
187 StringBuffer result = new StringBuffer();
188 result.append("[" + this.loc + "] ");
189 Token token0 = this.getTokenStream().LT(-1);
190 Token token1 = this.getTokenStream().LT(+1);
191
192
193 result.append("line " + token0.getLine() );
194 result.append(", column " + token0.getCharPositionInLine());
195 result.append(", after \"" + token0);
196 result.append("\": ");
197
198
199
200
201
202
203
204 return result.toString();
205 }
206
207
208
209
210
211
212
213
214
215 private void report(String msg) throws RuntimeException {
216
217 RuntimeException pe = new RuntimeException(msg);
218
219
220 this.exceptionThrown = true;
221 throw pe;
222 }
223
224
225 private void report(Token token,String msg) throws RuntimeException {
226
227 RuntimeException pe = new RuntimeException(msg);
228
229
230 this.exceptionThrown = true;
231 throw pe;
232 }
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249 public void setClassLoader(CClassLoader classLoader) {
250 this.classLoader = classLoader;
251 }
252
253 public CClass getCClass(ClassLocator loc) {
254 return cClass(loc).res;
255 }
256
257
258 public CClassParser(TokenStream input) {
259 super(input);
260 _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
261 }
262 public static class CClassContext extends ParserRuleContext {
263 public ClassLocator loc;
264 public CClass res;
265 public GetPathContext pkgPathC;
266 public Token cClassName;
267 public GetSuperClassContext superClassC;
268 public EffectsContext effectsXC;
269 public MapsContext mapsXC;
270 public ComponentsContext componentsXC;
271 public TerminalNode PACKAGE() { return getToken(CClassParser.PACKAGE, 0); }
272 public TerminalNode END() { return getToken(CClassParser.END, 0); }
273 public TerminalNode CCLASS() { return getToken(CClassParser.CCLASS, 0); }
274 public TerminalNode EOF() { return getToken(CClassParser.EOF, 0); }
275 public GetPathContext getPath() {
276 return getRuleContext(GetPathContext.class,0);
277 }
278 public TerminalNode NAME() { return getToken(CClassParser.NAME, 0); }
279 public GetSuperClassContext getSuperClass() {
280 return getRuleContext(GetSuperClassContext.class,0);
281 }
282 public EffectsContext effects() {
283 return getRuleContext(EffectsContext.class,0);
284 }
285 public MapsContext maps() {
286 return getRuleContext(MapsContext.class,0);
287 }
288 public ComponentsContext components() {
289 return getRuleContext(ComponentsContext.class,0);
290 }
291 public CClassContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
292 public CClassContext(ParserRuleContext parent, int invokingState, ClassLocator loc) {
293 super(parent, invokingState);
294 this.loc = loc;
295 }
296 @Override public int getRuleIndex() { return RULE_cClass; }
297 @Override
298 public void enterRule(ParseTreeListener listener) {
299 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterCClass(this);
300 }
301 @Override
302 public void exitRule(ParseTreeListener listener) {
303 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitCClass(this);
304 }
305 }
306
307 public final CClassContext cClass(ClassLocator loc) throws RecognitionException {
308 CClassContext _localctx = new CClassContext(_ctx, getState(), loc);
309 enterRule(_localctx, 0, RULE_cClass);
310
311
312 this.exceptionThrown = false;
313
314
315
316
317
318
319 this.loc = loc;
320 List<String> pkgPath;
321 CClass superClass;
322 Map<String,CClass.SClassDecl> effectsX;
323 Map<String,MapDecl> mapsX;
324 Map<String,CClassLink> componentsX;
325 Map<String,FormulaWrapper> incompEffects =
326 new HashMap<String,FormulaWrapper>();
327
328 try {
329 enterOuterAlt(_localctx, 1);
330 {
331 {
332 setState(40);
333 match(PACKAGE);
334 setState(41);
335 ((CClassContext)_localctx).pkgPathC = getPath();
336 setState(42);
337 match(END);
338
339 pkgPath = ((GetPathContext)
340 ((CClassContext)_localctx).pkgPathC).res;
341
342 setState(44);
343 match(CCLASS);
344 setState(45);
345 ((CClassContext)_localctx).cClassName = match(NAME);
346 setState(46);
347 ((CClassContext)_localctx).superClassC = getSuperClass();
348 setState(47);
349 match(T__0);
350 setState(48);
351 ((CClassContext)_localctx).effectsXC = effects(incompEffects);
352 setState(49);
353 ((CClassContext)_localctx).mapsXC = maps();
354 setState(50);
355 ((CClassContext)_localctx).componentsXC = components();
356
357 superClass = ((GetSuperClassContext)
358 ((CClassContext)_localctx).superClassC).res;
359 effectsX = ((EffectsContext)
360 ((CClassContext)_localctx).effectsXC).effectsX;
361 mapsX = ((MapsContext)
362 ((CClassContext)_localctx).mapsXC).name2map;
363 componentsX = ((ComponentsContext)
364 ((CClassContext)_localctx).componentsXC).componentsX;
365
366 setState(52);
367 match(T__1);
368 setState(53);
369 match(EOF);
370 }
371
372
373 if (!this.loc.getPackage().getPath().equals(pkgPath)) {
374 report("Expected Package \""
375 + this.loc.getPackage().getPathName()
376 + "\" but found: \""
377 + Package.getPackage(pkgPath).getPathName() + "\". ");
378 }
379
380 if (!this.loc.getName().equals((((CClassContext)_localctx).cClassName!=null?((CClassContext)_localctx).cClassName.getText():null))) {
381 report("Expected Class \"" + this.loc.getName() +
382 "\" but found: \"" + (((CClassContext)_localctx).cClassName!=null?((CClassContext)_localctx).cClassName.getText():null) + "\". ");
383 }
384
385
386
387
388 if (effectsX.size() == 0 && componentsX.size() == 0) {
389
390 report("Class \"" + (((CClassContext)_localctx).cClassName!=null?((CClassContext)_localctx).cClassName.getText():null) + "\" is invalid: " +
391 "Neither components nor effects are defined. ");
392 }
393
394 this.cClass = CClass.getCClass(this.loc.getName(),
395 this.loc.getPackage(),
396 superClass,
397 mapsX,
398 componentsX,
399 effectsX);
400
401
402 if (!incompEffects.isEmpty()) {
403 FormulaParser fParser = null;
404 for (Map.Entry<String,FormulaWrapper> entry :
405 incompEffects.entrySet()) {
406 try {
407 CharStream input = CharStreams
408 .fromString(entry.getValue().formula);
409 FormulaLexer lexer = new FormulaLexer(input);
410 CommonTokenStream tokens = new CommonTokenStream(lexer);
411 fParser = new FormulaParser(tokens);
412
413 fParser.setClassLoader(this.classLoader);
414 fParser.setLocator(this.loc);
415 fParser.setCClass(this.cClass);
416 fParser.setLineColNum(entry.getValue().lineNumber,
417 entry.getValue().colnNumber);
418 CClass.SClassDecl decl = effectsX.get(entry.getKey());
419 decl.setFormula(fParser.getFormulaStart());
420 } catch(IllegalArgumentException iaEx) {
421
422 fParser.report(iaEx.getMessage());
423 }
424 }
425 }
426
427
428
429 if (this.exceptionThrown) {
430 report("Recoverable errors occurred; see above. ");
431 }
432 ((CClassContext)_localctx).res = this.cClass;
433
434 }
435 }
436 catch (RecognitionException re) {
437 _localctx.exception = re;
438 _errHandler.reportError(this, re);
439 _errHandler.recover(this, re);
440 }
441 finally {
442 exitRule();
443 }
444 return _localctx;
445 }
446
447 public static class GetSuperClassContext extends ParserRuleContext {
448 public CClass res;
449 public Token ext;
450 public GetPathContext superPathC;
451 public TerminalNode EXTENDS() { return getToken(CClassParser.EXTENDS, 0); }
452 public GetPathContext getPath() {
453 return getRuleContext(GetPathContext.class,0);
454 }
455 public GetSuperClassContext(ParserRuleContext parent, int invokingState) {
456 super(parent, invokingState);
457 }
458 @Override public int getRuleIndex() { return RULE_getSuperClass; }
459 @Override
460 public void enterRule(ParseTreeListener listener) {
461 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterGetSuperClass(this);
462 }
463 @Override
464 public void exitRule(ParseTreeListener listener) {
465 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitGetSuperClass(this);
466 }
467 }
468
469 public final GetSuperClassContext getSuperClass() throws RecognitionException {
470 GetSuperClassContext _localctx = new GetSuperClassContext(_ctx, getState());
471 enterRule(_localctx, 2, RULE_getSuperClass);
472 int _la;
473 try {
474 enterOuterAlt(_localctx, 1);
475 {
476 setState(61);
477 _errHandler.sync(this);
478 _la = _input.LA(1);
479 if (_la==EXTENDS) {
480 {
481 setState(57);
482 ((GetSuperClassContext)_localctx).ext = match(EXTENDS);
483 setState(58);
484 ((GetSuperClassContext)_localctx).superPathC = getPath();
485 {
486 }
487 }
488 }
489
490
491 List<String> superPath = ((GetSuperClassContext)_localctx).ext == null
492 ? null
493 : ((GetPathContext)
494 ((GetSuperClassContext)_localctx).superPathC).res;
495
496 if (superPath == null ||
497 (superPath.size() == 1 &&
498 superPath.get(0).equals(CClass.COMPONENT.getName()))) {
499
500 ((GetSuperClassContext)_localctx).res = CClass.COMPONENT;
501 } else {
502
503 try {
504 ((GetSuperClassContext)_localctx).res = this.classLoader
505 .loadCClass(ClassLocator.getLocator(superPath),
506 this.loc.getPackage());
507 } catch(IOException ioe) {
508 report(ioe.getMessage());
509 }
510 }
511
512 }
513 }
514 catch (RecognitionException re) {
515 _localctx.exception = re;
516 _errHandler.reportError(this, re);
517 _errHandler.recover(this, re);
518 }
519 finally {
520 exitRule();
521 }
522 return _localctx;
523 }
524
525 public static class GetPathContext extends ParserRuleContext {
526 public List<String> res;
527 public Token first;
528 public Token next;
529 public List<TerminalNode> NAME() { return getTokens(CClassParser.NAME); }
530 public TerminalNode NAME(int i) {
531 return getToken(CClassParser.NAME, i);
532 }
533 public List<TerminalNode> SEP() { return getTokens(CClassParser.SEP); }
534 public TerminalNode SEP(int i) {
535 return getToken(CClassParser.SEP, i);
536 }
537 public GetPathContext(ParserRuleContext parent, int invokingState) {
538 super(parent, invokingState);
539 }
540 @Override public int getRuleIndex() { return RULE_getPath; }
541 @Override
542 public void enterRule(ParseTreeListener listener) {
543 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterGetPath(this);
544 }
545 @Override
546 public void exitRule(ParseTreeListener listener) {
547 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitGetPath(this);
548 }
549 }
550
551 public final GetPathContext getPath() throws RecognitionException {
552 GetPathContext _localctx = new GetPathContext(_ctx, getState());
553 enterRule(_localctx, 4, RULE_getPath);
554 List<String> res0 = new ArrayList<String>();
555 int _la;
556 try {
557 enterOuterAlt(_localctx, 1);
558 {
559 setState(65);
560 ((GetPathContext)_localctx).first = match(NAME);
561 res0.add((((GetPathContext)_localctx).first!=null?((GetPathContext)_localctx).first.getText():null));
562 setState(72);
563 _errHandler.sync(this);
564 _la = _input.LA(1);
565 while (_la==SEP) {
566 {
567 {
568 setState(67);
569 match(SEP);
570 setState(68);
571 ((GetPathContext)_localctx).next = match(NAME);
572 res0.add( (((GetPathContext)_localctx).next!=null?((GetPathContext)_localctx).next.getText():null));
573 }
574 }
575 setState(74);
576 _errHandler.sync(this);
577 _la = _input.LA(1);
578 }
579 }
580 _ctx.stop = _input.LT(-1);
581 ((GetPathContext)_localctx).res = Collections.unmodifiableList(res0);
582 }
583 catch (RecognitionException re) {
584 _localctx.exception = re;
585 _errHandler.reportError(this, re);
586 _errHandler.recover(this, re);
587 }
588 finally {
589 exitRule();
590 }
591 return _localctx;
592 }
593
594 public static class MapsContext extends ParserRuleContext {
595 public Map<String,MapDecl> name2map;
596 public TerminalNode MAPS() { return getToken(CClassParser.MAPS, 0); }
597 public List<AddMapContext> addMap() {
598 return getRuleContexts(AddMapContext.class);
599 }
600 public AddMapContext addMap(int i) {
601 return getRuleContext(AddMapContext.class,i);
602 }
603 public MapsContext(ParserRuleContext parent, int invokingState) {
604 super(parent, invokingState);
605 }
606 @Override public int getRuleIndex() { return RULE_maps; }
607 @Override
608 public void enterRule(ParseTreeListener listener) {
609 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterMaps(this);
610 }
611 @Override
612 public void exitRule(ParseTreeListener listener) {
613 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitMaps(this);
614 }
615 }
616
617 public final MapsContext maps() throws RecognitionException {
618 MapsContext _localctx = new MapsContext(_ctx, getState());
619 enterRule(_localctx, 6, RULE_maps);
620 Map<String,MapDecl> name2map0 = new HashMap<String,MapDecl>();
621 int _la;
622 try {
623 enterOuterAlt(_localctx, 1);
624 {
625 setState(82);
626 _errHandler.sync(this);
627 _la = _input.LA(1);
628 if (_la==MAPS) {
629 {
630 setState(75);
631 match(MAPS);
632 setState(79);
633 _errHandler.sync(this);
634 _la = _input.LA(1);
635 while (_la==REDECLARE || _la==NAME) {
636 {
637 {
638 setState(76);
639 addMap(name2map0);
640 }
641 }
642 setState(81);
643 _errHandler.sync(this);
644 _la = _input.LA(1);
645 }
646 }
647 }
648
649 }
650 _ctx.stop = _input.LT(-1);
651 ((MapsContext)_localctx).name2map = name2map0;
652 }
653 catch (RecognitionException re) {
654 _localctx.exception = re;
655 _errHandler.reportError(this, re);
656 _errHandler.recover(this, re);
657 }
658 finally {
659 exitRule();
660 }
661 return _localctx;
662 }
663
664 public static class AddMapContext extends ParserRuleContext {
665 public Map<String,MapDecl> name2map;
666 public Token redeclare;
667 public Token nameT;
668 public GetPathContext invImgPC;
669 public GetPathContext imgPC;
670 public TerminalNode END() { return getToken(CClassParser.END, 0); }
671 public TerminalNode NAME() { return getToken(CClassParser.NAME, 0); }
672 public List<GetPathContext> getPath() {
673 return getRuleContexts(GetPathContext.class);
674 }
675 public GetPathContext getPath(int i) {
676 return getRuleContext(GetPathContext.class,i);
677 }
678 public List<Add2DefMapContext> add2DefMap() {
679 return getRuleContexts(Add2DefMapContext.class);
680 }
681 public Add2DefMapContext add2DefMap(int i) {
682 return getRuleContext(Add2DefMapContext.class,i);
683 }
684 public AddToIdDomContext addToIdDom() {
685 return getRuleContext(AddToIdDomContext.class,0);
686 }
687 public TerminalNode REDECLARE() { return getToken(CClassParser.REDECLARE, 0); }
688 public AddMapContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
689 public AddMapContext(ParserRuleContext parent, int invokingState, Map<String,MapDecl> name2map) {
690 super(parent, invokingState);
691 this.name2map = name2map;
692 }
693 @Override public int getRuleIndex() { return RULE_addMap; }
694 @Override
695 public void enterRule(ParseTreeListener listener) {
696 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterAddMap(this);
697 }
698 @Override
699 public void exitRule(ParseTreeListener listener) {
700 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitAddMap(this);
701 }
702 }
703
704 public final AddMapContext addMap(Map<String,MapDecl> name2map) throws RecognitionException {
705 AddMapContext _localctx = new AddMapContext(_ctx, getState(), name2map);
706 enterRule(_localctx, 8, RULE_addMap);
707
708 Map<Set<Deficiency>,Deficiency> setOfSrc2targ =
709 new HashMap<Set<Deficiency>,Deficiency>();
710 Set<Deficiency> idDomain = new HashSet<Deficiency>();
711
712 int _la;
713 try {
714 enterOuterAlt(_localctx, 1);
715 {
716 {
717 setState(85);
718 _errHandler.sync(this);
719 _la = _input.LA(1);
720 if (_la==REDECLARE) {
721 {
722 setState(84);
723 ((AddMapContext)_localctx).redeclare = match(REDECLARE);
724 }
725 }
726
727 setState(87);
728 ((AddMapContext)_localctx).nameT = match(NAME);
729 setState(88);
730 match(T__2);
731 setState(89);
732 ((AddMapContext)_localctx).invImgPC = getPath();
733 setState(90);
734 match(T__3);
735 setState(91);
736 ((AddMapContext)_localctx).imgPC = getPath();
737 setState(92);
738 match(T__0);
739 setState(96);
740 _errHandler.sync(this);
741 _la = _input.LA(1);
742 while (_la==T__0) {
743 {
744 {
745 setState(93);
746 add2DefMap(setOfSrc2targ);
747 }
748 }
749 setState(98);
750 _errHandler.sync(this);
751 _la = _input.LA(1);
752 }
753 setState(100);
754 _errHandler.sync(this);
755 _la = _input.LA(1);
756 if (_la==IDDOMAIN) {
757 {
758 setState(99);
759 addToIdDom(idDomain);
760 }
761 }
762
763 setState(102);
764 match(T__1);
765 setState(103);
766 match(END);
767 }
768
769
770 List<String> invImgP = ((GetPathContext)
771 ((AddMapContext)_localctx).invImgPC).res;
772 List<String> imgP = ((GetPathContext)
773 ((AddMapContext)_localctx) .imgPC).res;
774 SClass invImgCls = null;
775 SClass imgCls = null;
776 String mapName = (((AddMapContext)_localctx).nameT!=null?((AddMapContext)_localctx).nameT.getText():null);
777 try {
778 invImgCls = this.classLoader
779 .loadSClass(ClassLocator.getLocator(invImgP),
780 this.loc.getPackage());
781 } catch (IOException ioe) {
782 report("IOException while loading \""
783 + ClassLocator.getLocator(invImgP)
784 + "\" in package this.loc.getPackage(): " + ioe + ". ");
785 }
786
787 try {
788 imgCls = this.classLoader
789 .loadSClass(ClassLocator.getLocator(imgP),
790 this.loc.getPackage());
791 } catch (IOException ioe) {
792 report("IOException while loading \""
793 + ClassLocator.getLocator(imgP) +
794 "\" in package this.loc.getPackage(): " + ioe + ". ");
795 }
796
797 setOfSrc2targ = Collections.unmodifiableMap(setOfSrc2targ);
798 try {
799 MapDecl newMap = new MapDecl(((AddMapContext)_localctx).redeclare != null,
800 mapName,
801 setOfSrc2targ,
802 invImgCls,
803 imgCls,
804 idDomain);
805 MapDecl oldMap = name2map.put(mapName,newMap);
806 if (oldMap != null) {
807 report(((AddMapContext)_localctx).nameT, "Name \"" + mapName +
808 "\" used for two maps: " + oldMap +
809 " and " + newMap + ". ");
810 }
811 } catch(IllegalArgumentException iaEx) {
812
813 report(((AddMapContext)_localctx).nameT, iaEx.getMessage());
814 }
815
816 }
817 }
818 catch (RecognitionException re) {
819 _localctx.exception = re;
820 _errHandler.reportError(this, re);
821 _errHandler.recover(this, re);
822 }
823 finally {
824 exitRule();
825 }
826 return _localctx;
827 }
828
829 public static class Add2DefMapContext extends ParserRuleContext {
830 public Map<Set<Deficiency>,Deficiency> setOfSrc2targ;
831 public Token defT;
832 public TerminalNode MAPSTO() { return getToken(CClassParser.MAPSTO, 0); }
833 public TerminalNode NAME() { return getToken(CClassParser.NAME, 0); }
834 public List<AddDefContext> addDef() {
835 return getRuleContexts(AddDefContext.class);
836 }
837 public AddDefContext addDef(int i) {
838 return getRuleContext(AddDefContext.class,i);
839 }
840 public Add2DefMapContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
841 public Add2DefMapContext(ParserRuleContext parent, int invokingState, Map<Set<Deficiency>,Deficiency> setOfSrc2targ) {
842 super(parent, invokingState);
843 this.setOfSrc2targ = setOfSrc2targ;
844 }
845 @Override public int getRuleIndex() { return RULE_add2DefMap; }
846 @Override
847 public void enterRule(ParseTreeListener listener) {
848 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterAdd2DefMap(this);
849 }
850 @Override
851 public void exitRule(ParseTreeListener listener) {
852 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitAdd2DefMap(this);
853 }
854 }
855
856 public final Add2DefMapContext add2DefMap(Map<Set<Deficiency>,Deficiency> setOfSrc2targ) throws RecognitionException {
857 Add2DefMapContext _localctx = new Add2DefMapContext(_ctx, getState(), setOfSrc2targ);
858 enterRule(_localctx, 10, RULE_add2DefMap);
859
860 Set<Deficiency> invImg = new HashSet<Deficiency>();
861
862 int _la;
863 try {
864 enterOuterAlt(_localctx, 1);
865 {
866 {
867 setState(107);
868 match(T__0);
869 setState(111);
870 _errHandler.sync(this);
871 _la = _input.LA(1);
872 while (_la==NAME) {
873 {
874 {
875 setState(108);
876 addDef(invImg);
877 }
878 }
879 setState(113);
880 _errHandler.sync(this);
881 _la = _input.LA(1);
882 }
883 setState(114);
884 match(T__1);
885 setState(115);
886 match(MAPSTO);
887 setState(116);
888 ((Add2DefMapContext)_localctx).defT = match(NAME);
889 }
890
891 Deficiency newDef = new Deficiency((((Add2DefMapContext)_localctx).defT!=null?((Add2DefMapContext)_localctx).defT.getText():null));
892 invImg = Collections.unmodifiableSet(invImg);
893 Deficiency oldDef = setOfSrc2targ.put(invImg,newDef);
894 if (oldDef != null) {
895 report("Defined image of " + invImg +
896 " twice: is \"" + oldDef +
897 "\" and \"" + newDef + "\". ");
898 }
899
900 }
901 }
902 catch (RecognitionException re) {
903 _localctx.exception = re;
904 _errHandler.reportError(this, re);
905 _errHandler.recover(this, re);
906 }
907 finally {
908 exitRule();
909 }
910 return _localctx;
911 }
912
913 public static class AddDefContext extends ParserRuleContext {
914 public Set<Deficiency> defs;
915 public Token defT;
916 public TerminalNode NAME() { return getToken(CClassParser.NAME, 0); }
917 public AddDefContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
918 public AddDefContext(ParserRuleContext parent, int invokingState, Set<Deficiency> defs) {
919 super(parent, invokingState);
920 this.defs = defs;
921 }
922 @Override public int getRuleIndex() { return RULE_addDef; }
923 @Override
924 public void enterRule(ParseTreeListener listener) {
925 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterAddDef(this);
926 }
927 @Override
928 public void exitRule(ParseTreeListener listener) {
929 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitAddDef(this);
930 }
931 }
932
933 public final AddDefContext addDef(Set<Deficiency> defs) throws RecognitionException {
934 AddDefContext _localctx = new AddDefContext(_ctx, getState(), defs);
935 enterRule(_localctx, 12, RULE_addDef);
936 try {
937 enterOuterAlt(_localctx, 1);
938 {
939 setState(120);
940 ((AddDefContext)_localctx).defT = match(NAME);
941
942 boolean isNew = _localctx.defs.add(new Deficiency((((AddDefContext)_localctx).defT!=null?((AddDefContext)_localctx).defT.getText():null)));
943 if (!isNew) {
944 report("Defined deficiency " + (((AddDefContext)_localctx).defT!=null?((AddDefContext)_localctx).defT.getText():null) + " twice. ");
945 }
946
947 }
948 }
949 catch (RecognitionException re) {
950 _localctx.exception = re;
951 _errHandler.reportError(this, re);
952 _errHandler.recover(this, re);
953 }
954 finally {
955 exitRule();
956 }
957 return _localctx;
958 }
959
960 public static class AddToIdDomContext extends ParserRuleContext {
961 public Set<Deficiency> idDomain;
962 public TerminalNode IDDOMAIN() { return getToken(CClassParser.IDDOMAIN, 0); }
963 public List<AddDefContext> addDef() {
964 return getRuleContexts(AddDefContext.class);
965 }
966 public AddDefContext addDef(int i) {
967 return getRuleContext(AddDefContext.class,i);
968 }
969 public AddToIdDomContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
970 public AddToIdDomContext(ParserRuleContext parent, int invokingState, Set<Deficiency> idDomain) {
971 super(parent, invokingState);
972 this.idDomain = idDomain;
973 }
974 @Override public int getRuleIndex() { return RULE_addToIdDom; }
975 @Override
976 public void enterRule(ParseTreeListener listener) {
977 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterAddToIdDom(this);
978 }
979 @Override
980 public void exitRule(ParseTreeListener listener) {
981 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitAddToIdDom(this);
982 }
983 }
984
985 public final AddToIdDomContext addToIdDom(Set<Deficiency> idDomain) throws RecognitionException {
986 AddToIdDomContext _localctx = new AddToIdDomContext(_ctx, getState(), idDomain);
987 enterRule(_localctx, 14, RULE_addToIdDom);
988 int _la;
989 try {
990 enterOuterAlt(_localctx, 1);
991 {
992 {
993 setState(123);
994 match(IDDOMAIN);
995 setState(124);
996 match(T__0);
997 setState(128);
998 _errHandler.sync(this);
999 _la = _input.LA(1);
1000 while (_la==NAME) {
1001 {
1002 {
1003 setState(125);
1004 addDef(idDomain);
1005 }
1006 }
1007 setState(130);
1008 _errHandler.sync(this);
1009 _la = _input.LA(1);
1010 }
1011 setState(131);
1012 match(T__1);
1013 }
1014 }
1015 }
1016 catch (RecognitionException re) {
1017 _localctx.exception = re;
1018 _errHandler.reportError(this, re);
1019 _errHandler.recover(this, re);
1020 }
1021 finally {
1022 exitRule();
1023 }
1024 return _localctx;
1025 }
1026
1027 public static class EffectsContext extends ParserRuleContext {
1028 public Map<String,FormulaWrapper> incompEffects;
1029 public Map<String,CClass.SClassDecl> effectsX;
1030 public TerminalNode EFFECTS() { return getToken(CClassParser.EFFECTS, 0); }
1031 public List<EffectContext> effect() {
1032 return getRuleContexts(EffectContext.class);
1033 }
1034 public EffectContext effect(int i) {
1035 return getRuleContext(EffectContext.class,i);
1036 }
1037 public EffectsContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
1038 public EffectsContext(ParserRuleContext parent, int invokingState, Map<String,FormulaWrapper> incompEffects) {
1039 super(parent, invokingState);
1040 this.incompEffects = incompEffects;
1041 }
1042 @Override public int getRuleIndex() { return RULE_effects; }
1043 @Override
1044 public void enterRule(ParseTreeListener listener) {
1045 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterEffects(this);
1046 }
1047 @Override
1048 public void exitRule(ParseTreeListener listener) {
1049 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitEffects(this);
1050 }
1051 }
1052
1053 public final EffectsContext effects(Map<String,FormulaWrapper> incompEffects) throws RecognitionException {
1054 EffectsContext _localctx = new EffectsContext(_ctx, getState(), incompEffects);
1055 enterRule(_localctx, 16, RULE_effects);
1056
1057 Map<String,CClass.SClassDecl> effectsX0 =
1058 new TreeMap<String,CClass.SClassDecl>();
1059 int _la;
1060 try {
1061 enterOuterAlt(_localctx, 1);
1062 {
1063 setState(140);
1064 _errHandler.sync(this);
1065 _la = _input.LA(1);
1066 if (_la==EFFECTS) {
1067 {
1068 setState(133);
1069 match(EFFECTS);
1070 setState(137);
1071 _errHandler.sync(this);
1072 _la = _input.LA(1);
1073 while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << REDECLARE) | (1L << INPUT) | (1L << OUTPUT) | (1L << NAME))) != 0)) {
1074 {
1075 {
1076 setState(134);
1077 effect(effectsX0, incompEffects);
1078 }
1079 }
1080 setState(139);
1081 _errHandler.sync(this);
1082 _la = _input.LA(1);
1083 }
1084 }
1085 }
1086
1087 }
1088 _ctx.stop = _input.LT(-1);
1089 ((EffectsContext)_localctx).effectsX = effectsX0;
1090 }
1091 catch (RecognitionException re) {
1092 _localctx.exception = re;
1093 _errHandler.reportError(this, re);
1094 _errHandler.recover(this, re);
1095 }
1096 finally {
1097 exitRule();
1098 }
1099 return _localctx;
1100 }
1101
1102 public static class EffectContext extends ParserRuleContext {
1103 public Map<String,CClass.SClassDecl> effectsMap;
1104 public Map<String,FormulaWrapper> incompEffects;
1105 public Token redeclare;
1106 public GetPathContext pathC;
1107 public Token sNameT;
1108 public GetDistrContext distrC;
1109 public Token formT;
1110 public SkipFormulaContext formC;
1111 public TerminalNode END() { return getToken(CClassParser.END, 0); }
1112 public GetPathContext getPath() {
1113 return getRuleContext(GetPathContext.class,0);
1114 }
1115 public TerminalNode NAME() { return getToken(CClassParser.NAME, 0); }
1116 public List<AddAccessModifierContext> addAccessModifier() {
1117 return getRuleContexts(AddAccessModifierContext.class);
1118 }
1119 public AddAccessModifierContext addAccessModifier(int i) {
1120 return getRuleContext(AddAccessModifierContext.class,i);
1121 }
1122 public TerminalNode REDECLARE() { return getToken(CClassParser.REDECLARE, 0); }
1123 public GetDistrContext getDistr() {
1124 return getRuleContext(GetDistrContext.class,0);
1125 }
1126 public SkipFormulaContext skipFormula() {
1127 return getRuleContext(SkipFormulaContext.class,0);
1128 }
1129 public EffectContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
1130 public EffectContext(ParserRuleContext parent, int invokingState, Map<String,CClass.SClassDecl> effectsMap, Map<String,FormulaWrapper> incompEffects) {
1131 super(parent, invokingState);
1132 this.effectsMap = effectsMap;
1133 this.incompEffects = incompEffects;
1134 }
1135 @Override public int getRuleIndex() { return RULE_effect; }
1136 @Override
1137 public void enterRule(ParseTreeListener listener) {
1138 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterEffect(this);
1139 }
1140 @Override
1141 public void exitRule(ParseTreeListener listener) {
1142 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitEffect(this);
1143 }
1144 }
1145
1146 public final EffectContext effect(Map<String,CClass.SClassDecl> effectsMap,Map<String,FormulaWrapper> incompEffects) throws RecognitionException {
1147 EffectContext _localctx = new EffectContext(_ctx, getState(), effectsMap, incompEffects);
1148 enterRule(_localctx, 18, RULE_effect);
1149
1150 Set<CClass.SClassModifier> accessModifiers =
1151 new HashSet<CClass.SClassModifier>();
1152 SClass sClass = null;
1153
1154 int _la;
1155 try {
1156 enterOuterAlt(_localctx, 1);
1157 {
1158 {
1159 setState(143);
1160 _errHandler.sync(this);
1161 _la = _input.LA(1);
1162 if (_la==REDECLARE) {
1163 {
1164 setState(142);
1165 ((EffectContext)_localctx).redeclare = match(REDECLARE);
1166 }
1167 }
1168
1169 setState(148);
1170 _errHandler.sync(this);
1171 _la = _input.LA(1);
1172 while (_la==INPUT || _la==OUTPUT) {
1173 {
1174 {
1175 setState(145);
1176 addAccessModifier(accessModifiers);
1177 }
1178 }
1179 setState(150);
1180 _errHandler.sync(this);
1181 _la = _input.LA(1);
1182 }
1183 setState(151);
1184 ((EffectContext)_localctx).pathC = getPath();
1185 setState(152);
1186 ((EffectContext)_localctx).sNameT = match(NAME);
1187 }
1188
1189 List<String> path = ((GetPathContext)
1190 ((EffectContext)_localctx).pathC).res;
1191
1192 if (path.size() == 1 &&
1193 path.get(0).equals(SClass.BOOLEAN.getName())) {
1194 sClass = SClass.BOOLEAN;
1195 } else {
1196 try {
1197 sClass = this.classLoader
1198 .loadSClass(ClassLocator.getLocator(path),
1199 this.loc.getPackage());
1200 } catch (IOException ioe) {
1201 report("IOException while loading \""
1202 + ClassLocator.getLocator(path)
1203 + "\" in package this.loc.getPackage(): "
1204 + ioe + ". ");
1205 sClass = null;
1206 }
1207 }
1208 assert sClass != null;
1209
1210
1211
1212 {
1213 setState(160);
1214 _errHandler.sync(this);
1215 switch (_input.LA(1)) {
1216 case T__0:
1217 {
1218 setState(155);
1219 ((EffectContext)_localctx).distrC = getDistr(sClass);
1220 }
1221 break;
1222 case T__4:
1223 {
1224 setState(156);
1225 ((EffectContext)_localctx).formT = match(T__4);
1226 setState(157);
1227 ((EffectContext)_localctx).formC = skipFormula();
1228 setState(158);
1229 match(T__5);
1230 }
1231 break;
1232 case END:
1233 break;
1234 default:
1235 break;
1236 }
1237 setState(162);
1238 match(END);
1239 }
1240
1241 ProbDistr distr = ((EffectContext)_localctx).distrC == null
1242 ? null
1243 : ((GetDistrContext)
1244 ((EffectContext)_localctx).distrC).distr;
1245 String form = ((EffectContext)_localctx).formT == null
1246 ? null
1247 : ((SkipFormulaContext)
1248 ((EffectContext)_localctx).formC).res;
1249
1250
1251 String sName = (((EffectContext)_localctx).sNameT!=null?((EffectContext)_localctx).sNameT.getText():null);
1252 assert sName != null;
1253 CClass.SClassDecl oldDecl = effectsMap
1254 .put(sName,
1255 new CClass.SClassDecl(((EffectContext)_localctx).redeclare != null,
1256 accessModifiers,
1257 sClass,
1258 sName,
1259 distr));
1260
1261 if (oldDecl != null) {
1262 report("Duplicate effect declaration \"" + sName +
1263 "\"; overwrite " + oldDecl + " by " + sClass + ". " );
1264 }
1265
1266
1267 if (form != null) {
1268 assert ((EffectContext)_localctx).formT != null;
1269
1270 int lineNumber = (((EffectContext)_localctx).formT!=null?((EffectContext)_localctx).formT.getLine():0);
1271 int colnNumber = (((EffectContext)_localctx).formT!=null?((EffectContext)_localctx).formT.getCharPositionInLine():0);
1272
1273
1274
1275 incompEffects.put(sName,
1276 new FormulaWrapper(lineNumber,
1277 colnNumber,
1278 form));
1279 }
1280
1281 }
1282 }
1283 catch (RecognitionException re) {
1284 _localctx.exception = re;
1285 _errHandler.reportError(this, re);
1286 _errHandler.recover(this, re);
1287 }
1288 finally {
1289 exitRule();
1290 }
1291 return _localctx;
1292 }
1293
1294 public static class AddAccessModifierContext extends ParserRuleContext {
1295 public Set<CClass.SClassModifier> accessModifiers;
1296 public Token modT;
1297 public TerminalNode INPUT() { return getToken(CClassParser.INPUT, 0); }
1298 public TerminalNode OUTPUT() { return getToken(CClassParser.OUTPUT, 0); }
1299 public AddAccessModifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
1300 public AddAccessModifierContext(ParserRuleContext parent, int invokingState, Set<CClass.SClassModifier> accessModifiers) {
1301 super(parent, invokingState);
1302 this.accessModifiers = accessModifiers;
1303 }
1304 @Override public int getRuleIndex() { return RULE_addAccessModifier; }
1305 @Override
1306 public void enterRule(ParseTreeListener listener) {
1307 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterAddAccessModifier(this);
1308 }
1309 @Override
1310 public void exitRule(ParseTreeListener listener) {
1311 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitAddAccessModifier(this);
1312 }
1313 }
1314
1315 public final AddAccessModifierContext addAccessModifier(Set<CClass.SClassModifier> accessModifiers) throws RecognitionException {
1316 AddAccessModifierContext _localctx = new AddAccessModifierContext(_ctx, getState(), accessModifiers);
1317 enterRule(_localctx, 20, RULE_addAccessModifier);
1318 try {
1319 enterOuterAlt(_localctx, 1);
1320 {
1321 setState(168);
1322 _errHandler.sync(this);
1323 switch (_input.LA(1)) {
1324 case INPUT:
1325 {
1326 setState(166);
1327 ((AddAccessModifierContext)_localctx).modT = match(INPUT);
1328 }
1329 break;
1330 case OUTPUT:
1331 {
1332 setState(167);
1333 ((AddAccessModifierContext)_localctx).modT = match(OUTPUT);
1334 }
1335 break;
1336 default:
1337 throw new NoViableAltException(this);
1338 }
1339
1340
1341 CClass.SClassModifier mod = CClass.SClassModifier.get((((AddAccessModifierContext)_localctx).modT!=null?((AddAccessModifierContext)_localctx).modT.getText():null));
1342
1343 if (!accessModifiers.add(mod)) {
1344
1345 report("Found duplicate access modifier \"" + (((AddAccessModifierContext)_localctx).modT!=null?((AddAccessModifierContext)_localctx).modT.getText():null) + "\". ");
1346 }
1347
1348
1349
1350 }
1351 }
1352 catch (RecognitionException re) {
1353 _localctx.exception = re;
1354 _errHandler.reportError(this, re);
1355 _errHandler.recover(this, re);
1356 }
1357 finally {
1358 exitRule();
1359 }
1360 return _localctx;
1361 }
1362
1363 public static class GetDistrContext extends ParserRuleContext {
1364 public SClass sClass;
1365 public ProbDistr distr;
1366 public List<AddProbAllocContext> addProbAlloc() {
1367 return getRuleContexts(AddProbAllocContext.class);
1368 }
1369 public AddProbAllocContext addProbAlloc(int i) {
1370 return getRuleContext(AddProbAllocContext.class,i);
1371 }
1372 public List<TerminalNode> REPLACE() { return getTokens(CClassParser.REPLACE); }
1373 public TerminalNode REPLACE(int i) {
1374 return getToken(CClassParser.REPLACE, i);
1375 }
1376 public List<ReplDistrContext> replDistr() {
1377 return getRuleContexts(ReplDistrContext.class);
1378 }
1379 public ReplDistrContext replDistr(int i) {
1380 return getRuleContext(ReplDistrContext.class,i);
1381 }
1382 public GetDistrContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
1383 public GetDistrContext(ParserRuleContext parent, int invokingState, SClass sClass) {
1384 super(parent, invokingState);
1385 this.sClass = sClass;
1386 }
1387 @Override public int getRuleIndex() { return RULE_getDistr; }
1388 @Override
1389 public void enterRule(ParseTreeListener listener) {
1390 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterGetDistr(this);
1391 }
1392 @Override
1393 public void exitRule(ParseTreeListener listener) {
1394 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitGetDistr(this);
1395 }
1396 }
1397
1398 public final GetDistrContext getDistr(SClass sClass) throws RecognitionException {
1399 GetDistrContext _localctx = new GetDistrContext(_ctx, getState(), sClass);
1400 enterRule(_localctx, 22, RULE_getDistr);
1401
1402 Map<Deficiency,BigDecimal> def2prob = new HashMap<Deficiency,BigDecimal>();
1403 Map<Deficiency,ProbDistr > def2distr = new HashMap<Deficiency,ProbDistr >();
1404
1405 int _la;
1406 try {
1407 enterOuterAlt(_localctx, 1);
1408 {
1409 setState(172);
1410 match(T__0);
1411 setState(178);
1412 _errHandler.sync(this);
1413 _la = _input.LA(1);
1414 while (_la==REPLACE || _la==NAME) {
1415 {
1416 setState(176);
1417 _errHandler.sync(this);
1418 switch (_input.LA(1)) {
1419 case NAME:
1420 {
1421 setState(173);
1422 addProbAlloc(def2prob);
1423 }
1424 break;
1425 case REPLACE:
1426 {
1427 setState(174);
1428 match(REPLACE);
1429 setState(175);
1430 replDistr(def2distr,sClass);
1431 }
1432 break;
1433 default:
1434 throw new NoViableAltException(this);
1435 }
1436 }
1437 setState(180);
1438 _errHandler.sync(this);
1439 _la = _input.LA(1);
1440 }
1441 setState(181);
1442 match(T__1);
1443
1444
1445 assert sClass.getDeclaredInnerClasses().keySet()
1446 .containsAll(def2distr.keySet());
1447
1448
1449 if (sClass.getDeclaredInnerClasses().keySet().size() !=
1450 def2distr.keySet().size()) {
1451 Set<Deficiency> minus = new HashSet<Deficiency>
1452 (sClass.getDeclaredInnerClasses().keySet());
1453 minus.removeAll(def2distr.keySet());
1454 report("Found no partial probability distribution " +
1455 "for deficiencies " + minus + ". ");
1456 }
1457
1458
1459 Set<Deficiency> inter = new HashSet<Deficiency>(def2prob.keySet());
1460 inter.retainAll(def2distr.keySet());
1461 if (!inter.isEmpty()) {
1462 report("For properties " + inter +
1463 " defined probability and sub-distribution. ");
1464 }
1465
1466
1467 Type type = sClass.getType();
1468 if ((sClass.getSuperClass() == null) || sClass.isInner()) {
1469
1470
1471 if (!type.asSet().equals(def2prob.keySet())) {
1472 report("Type with set " + type.asSet() +
1473 " does not allow distribution " + def2prob + ". ");
1474 }
1475
1476 ((GetDistrContext)_localctx).distr = new ProbDistr(type, def2prob);
1477 } else {
1478 Set<Deficiency> union =
1479 new HashSet<Deficiency>(def2prob.keySet());
1480 union.addAll(def2distr.keySet());
1481 Set<Deficiency> exp = sClass.getSuperClass().getType().asSet();
1482 if (!exp.equals(union)) {
1483 report("Expected properties " + exp +
1484 " but found " + union + ". ");
1485 }
1486 ((GetDistrContext)_localctx).distr = new ProbDistr(type,def2distr,def2prob);
1487 }
1488 try {
1489 _localctx.distr.validate();
1490 } catch(IllegalStateException e) {
1491 report("Probability distribution " + e.getMessage());
1492 }
1493
1494 }
1495 }
1496 catch (RecognitionException re) {
1497 _localctx.exception = re;
1498 _errHandler.reportError(this, re);
1499 _errHandler.recover(this, re);
1500 }
1501 finally {
1502 exitRule();
1503 }
1504 return _localctx;
1505 }
1506
1507 public static class ReplDistrContext extends ParserRuleContext {
1508 public Map<Deficiency,ProbDistr> def2distr;
1509 public SClass sClass;
1510 public Token replDefT;
1511 public GetDistrContext distrInnerC;
1512 public TerminalNode NAME() { return getToken(CClassParser.NAME, 0); }
1513 public GetDistrContext getDistr() {
1514 return getRuleContext(GetDistrContext.class,0);
1515 }
1516 public ReplDistrContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
1517 public ReplDistrContext(ParserRuleContext parent, int invokingState, Map<Deficiency,ProbDistr> def2distr, SClass sClass) {
1518 super(parent, invokingState);
1519 this.def2distr = def2distr;
1520 this.sClass = sClass;
1521 }
1522 @Override public int getRuleIndex() { return RULE_replDistr; }
1523 @Override
1524 public void enterRule(ParseTreeListener listener) {
1525 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterReplDistr(this);
1526 }
1527 @Override
1528 public void exitRule(ParseTreeListener listener) {
1529 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitReplDistr(this);
1530 }
1531 }
1532
1533 public final ReplDistrContext replDistr(Map<Deficiency,ProbDistr> def2distr,SClass sClass) throws RecognitionException {
1534 ReplDistrContext _localctx = new ReplDistrContext(_ctx, getState(), def2distr, sClass);
1535 enterRule(_localctx, 24, RULE_replDistr);
1536
1537 SClass sClassInner = null;
1538 Deficiency repl = null;
1539
1540 try {
1541 enterOuterAlt(_localctx, 1);
1542 {
1543 setState(184);
1544 ((ReplDistrContext)_localctx).replDefT = match(NAME);
1545
1546 repl = new Deficiency((((ReplDistrContext)_localctx).replDefT!=null?((ReplDistrContext)_localctx).replDefT.getText():null));
1547 sClassInner = sClass.getDeclaredInnerClass(repl);
1548 assert sClassInner != null;
1549
1550 setState(186);
1551 ((ReplDistrContext)_localctx).distrInnerC = getDistr(sClassInner);
1552
1553 ProbDistr distrInner = ((GetDistrContext)
1554 ((ReplDistrContext)_localctx).distrInnerC).distr;
1555
1556 ProbDistr old = _localctx.def2distr.put(repl, distrInner);
1557 if (old != null) {
1558 report("Overwritten replacement of property \""
1559 + (((ReplDistrContext)_localctx).replDefT!=null?((ReplDistrContext)_localctx).replDefT.getText():null) + "\". ");
1560 }
1561
1562 }
1563 }
1564 catch (RecognitionException re) {
1565 _localctx.exception = re;
1566 _errHandler.reportError(this, re);
1567 _errHandler.recover(this, re);
1568 }
1569 finally {
1570 exitRule();
1571 }
1572 return _localctx;
1573 }
1574
1575 public static class AddProbAllocContext extends ParserRuleContext {
1576 public Map<Deficiency,BigDecimal> def2prob;
1577 public Token defT;
1578 public Token floatT;
1579 public TerminalNode NAME() { return getToken(CClassParser.NAME, 0); }
1580 public TerminalNode FLOAT() { return getToken(CClassParser.FLOAT, 0); }
1581 public AddProbAllocContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
1582 public AddProbAllocContext(ParserRuleContext parent, int invokingState, Map<Deficiency,BigDecimal> def2prob) {
1583 super(parent, invokingState);
1584 this.def2prob = def2prob;
1585 }
1586 @Override public int getRuleIndex() { return RULE_addProbAlloc; }
1587 @Override
1588 public void enterRule(ParseTreeListener listener) {
1589 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterAddProbAlloc(this);
1590 }
1591 @Override
1592 public void exitRule(ParseTreeListener listener) {
1593 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitAddProbAlloc(this);
1594 }
1595 }
1596
1597 public final AddProbAllocContext addProbAlloc(Map<Deficiency,BigDecimal> def2prob) throws RecognitionException {
1598 AddProbAllocContext _localctx = new AddProbAllocContext(_ctx, getState(), def2prob);
1599 enterRule(_localctx, 26, RULE_addProbAlloc);
1600 try {
1601 enterOuterAlt(_localctx, 1);
1602 {
1603 {
1604 setState(189);
1605 ((AddProbAllocContext)_localctx).defT = match(NAME);
1606 setState(190);
1607 match(T__2);
1608 setState(191);
1609 ((AddProbAllocContext)_localctx).floatT = match(FLOAT);
1610 }
1611
1612 Deficiency def = new Deficiency((((AddProbAllocContext)_localctx).defT!=null?((AddProbAllocContext)_localctx).defT.getText():null));
1613 BigDecimal newProb = new BigDecimal((((AddProbAllocContext)_localctx).floatT!=null?((AddProbAllocContext)_localctx).floatT.getText():null));
1614 if (newProb.compareTo(BigDecimal.ONE ) >= 0 ||
1615 newProb.compareTo(BigDecimal.ZERO) <= 0) {
1616 report("Assigned property \"" + (((AddProbAllocContext)_localctx).defT!=null?((AddProbAllocContext)_localctx).defT.getText():null) +
1617 "\" probability value " + (((AddProbAllocContext)_localctx).floatT!=null?((AddProbAllocContext)_localctx).floatT.getText():null) +
1618 " which is not in (0,1). ");
1619 }
1620 BigDecimal oldProb = def2prob.put(def, newProb);
1621 if (oldProb != null) {
1622
1623 report("Overwritten probability " + oldProb
1624 + " for property \"" + (((AddProbAllocContext)_localctx).defT!=null?((AddProbAllocContext)_localctx).defT.getText():null) +
1625 "\" by new value " + (((AddProbAllocContext)_localctx).floatT!=null?((AddProbAllocContext)_localctx).floatT.getText():null) + ". ");
1626 }
1627
1628 }
1629 }
1630 catch (RecognitionException re) {
1631 _localctx.exception = re;
1632 _errHandler.reportError(this, re);
1633 _errHandler.recover(this, re);
1634 }
1635 finally {
1636 exitRule();
1637 }
1638 return _localctx;
1639 }
1640
1641 public static class SkipFormulaContext extends ParserRuleContext {
1642 public String res;
1643 public AppendFormulaContext appendFormula() {
1644 return getRuleContext(AppendFormulaContext.class,0);
1645 }
1646 public SkipFormulaContext(ParserRuleContext parent, int invokingState) {
1647 super(parent, invokingState);
1648 }
1649 @Override public int getRuleIndex() { return RULE_skipFormula; }
1650 @Override
1651 public void enterRule(ParseTreeListener listener) {
1652 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterSkipFormula(this);
1653 }
1654 @Override
1655 public void exitRule(ParseTreeListener listener) {
1656 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitSkipFormula(this);
1657 }
1658 }
1659
1660 public final SkipFormulaContext skipFormula() throws RecognitionException {
1661 SkipFormulaContext _localctx = new SkipFormulaContext(_ctx, getState());
1662 enterRule(_localctx, 28, RULE_skipFormula);
1663
1664 StringBuffer resB = new StringBuffer();
1665
1666 try {
1667 enterOuterAlt(_localctx, 1);
1668 {
1669 setState(195);
1670 appendFormula("",resB);
1671 ((SkipFormulaContext)_localctx).res = resB.toString();
1672 }
1673 }
1674 catch (RecognitionException re) {
1675 _localctx.exception = re;
1676 _errHandler.reportError(this, re);
1677 _errHandler.recover(this, re);
1678 }
1679 finally {
1680 exitRule();
1681 }
1682 return _localctx;
1683 }
1684
1685 public static class AppendFormulaContext extends ParserRuleContext {
1686 public String pre;
1687 public StringBuffer res;
1688 public Token cls;
1689 public List<AppendTokenContext> appendToken() {
1690 return getRuleContexts(AppendTokenContext.class);
1691 }
1692 public AppendTokenContext appendToken(int i) {
1693 return getRuleContext(AppendTokenContext.class,i);
1694 }
1695 public AppendOpContext appendOp() {
1696 return getRuleContext(AppendOpContext.class,0);
1697 }
1698 public List<AppendFormulaContext> appendFormula() {
1699 return getRuleContexts(AppendFormulaContext.class);
1700 }
1701 public AppendFormulaContext appendFormula(int i) {
1702 return getRuleContext(AppendFormulaContext.class,i);
1703 }
1704 public AppendFormulaContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
1705 public AppendFormulaContext(ParserRuleContext parent, int invokingState, String pre, StringBuffer res) {
1706 super(parent, invokingState);
1707 this.pre = pre;
1708 this.res = res;
1709 }
1710 @Override public int getRuleIndex() { return RULE_appendFormula; }
1711 @Override
1712 public void enterRule(ParseTreeListener listener) {
1713 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterAppendFormula(this);
1714 }
1715 @Override
1716 public void exitRule(ParseTreeListener listener) {
1717 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitAppendFormula(this);
1718 }
1719 }
1720
1721 public final AppendFormulaContext appendFormula(String pre,StringBuffer res) throws RecognitionException {
1722 AppendFormulaContext _localctx = new AppendFormulaContext(_ctx, getState(), pre, res);
1723 enterRule(_localctx, 30, RULE_appendFormula);
1724
1725 _localctx.res.append(_localctx.pre);
1726
1727 int _la;
1728 try {
1729 enterOuterAlt(_localctx, 1);
1730 {
1731 setState(230);
1732 _errHandler.sync(this);
1733 switch ( getInterpreter().adaptivePredict(_input,20,_ctx) ) {
1734 case 1:
1735 {
1736 {
1737 setState(198);
1738 match(T__6);
1739 setState(199);
1740 appendToken("<",res,">{");
1741 setState(200);
1742 match(T__7);
1743 setState(201);
1744 match(T__0);
1745 setState(205);
1746 _errHandler.sync(this);
1747 _la = _input.LA(1);
1748 while (_la==NAME) {
1749 {
1750 {
1751 setState(202);
1752 appendToken("" ,res,"" );
1753 }
1754 }
1755 setState(207);
1756 _errHandler.sync(this);
1757 _la = _input.LA(1);
1758 }
1759 setState(208);
1760 ((AppendFormulaContext)_localctx).cls = match(T__1);
1761 }
1762 }
1763 break;
1764 case 2:
1765 {
1766 {
1767 setState(210);
1768 appendOp(res);
1769 setState(211);
1770 match(T__4);
1771 setState(212);
1772 appendFormula("(",res);
1773 setState(217);
1774 _errHandler.sync(this);
1775 _la = _input.LA(1);
1776 while (_la==COV) {
1777 {
1778 {
1779 setState(213);
1780 match(COV);
1781 setState(214);
1782 appendFormula(",",res);
1783 }
1784 }
1785 setState(219);
1786 _errHandler.sync(this);
1787 _la = _input.LA(1);
1788 }
1789 setState(220);
1790 ((AppendFormulaContext)_localctx).cls = match(T__5);
1791 }
1792 }
1793 break;
1794 case 3:
1795 {
1796 {
1797 setState(222);
1798 appendToken("" ,res,"");
1799 setState(227);
1800 _errHandler.sync(this);
1801 _la = _input.LA(1);
1802 while (_la==SEP) {
1803 {
1804 {
1805 setState(223);
1806 match(SEP);
1807 setState(224);
1808 appendToken(".",res,"");
1809 }
1810 }
1811 setState(229);
1812 _errHandler.sync(this);
1813 _la = _input.LA(1);
1814 }
1815 }
1816 }
1817 break;
1818 }
1819
1820 if (((AppendFormulaContext)_localctx).cls != null) {
1821 _localctx.res.append((((AppendFormulaContext)_localctx).cls!=null?((AppendFormulaContext)_localctx).cls.getText():null));
1822 }
1823
1824 }
1825 }
1826 catch (RecognitionException re) {
1827 _localctx.exception = re;
1828 _errHandler.reportError(this, re);
1829 _errHandler.recover(this, re);
1830 }
1831 finally {
1832 exitRule();
1833 }
1834 return _localctx;
1835 }
1836
1837 public static class AppendTokenContext extends ParserRuleContext {
1838 public String pre;
1839 public StringBuffer buf;
1840 public String post;
1841 public Token name;
1842 public TerminalNode NAME() { return getToken(CClassParser.NAME, 0); }
1843 public AppendTokenContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
1844 public AppendTokenContext(ParserRuleContext parent, int invokingState, String pre, StringBuffer buf, String post) {
1845 super(parent, invokingState);
1846 this.pre = pre;
1847 this.buf = buf;
1848 this.post = post;
1849 }
1850 @Override public int getRuleIndex() { return RULE_appendToken; }
1851 @Override
1852 public void enterRule(ParseTreeListener listener) {
1853 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterAppendToken(this);
1854 }
1855 @Override
1856 public void exitRule(ParseTreeListener listener) {
1857 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitAppendToken(this);
1858 }
1859 }
1860
1861 public final AppendTokenContext appendToken(String pre,StringBuffer buf,String post) throws RecognitionException {
1862 AppendTokenContext _localctx = new AppendTokenContext(_ctx, getState(), pre, buf, post);
1863 enterRule(_localctx, 32, RULE_appendToken);
1864 _localctx.buf.append(_localctx.pre);
1865 try {
1866 enterOuterAlt(_localctx, 1);
1867 {
1868 setState(234);
1869 ((AppendTokenContext)_localctx).name = match(NAME);
1870
1871 buf.append((((AppendTokenContext)_localctx).name!=null?((AppendTokenContext)_localctx).name.getText():null));
1872 buf.append(_localctx.post);
1873
1874 }
1875 }
1876 catch (RecognitionException re) {
1877 _localctx.exception = re;
1878 _errHandler.reportError(this, re);
1879 _errHandler.recover(this, re);
1880 }
1881 finally {
1882 exitRule();
1883 }
1884 return _localctx;
1885 }
1886
1887 public static class AppendOpContext extends ParserRuleContext {
1888 public StringBuffer buf;
1889 public Token funT;
1890 public Token invT;
1891 public Token accT;
1892 public Token opT;
1893 public TerminalNode UNION() { return getToken(CClassParser.UNION, 0); }
1894 public TerminalNode INTERSECT() { return getToken(CClassParser.INTERSECT, 0); }
1895 public TerminalNode COMPLEMENT() { return getToken(CClassParser.COMPLEMENT, 0); }
1896 public TerminalNode NAME() { return getToken(CClassParser.NAME, 0); }
1897 public TerminalNode CONT() { return getToken(CClassParser.CONT, 0); }
1898 public TerminalNode COV() { return getToken(CClassParser.COV, 0); }
1899 public TerminalNode INV() { return getToken(CClassParser.INV, 0); }
1900 public AppendOpContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
1901 public AppendOpContext(ParserRuleContext parent, int invokingState, StringBuffer buf) {
1902 super(parent, invokingState);
1903 this.buf = buf;
1904 }
1905 @Override public int getRuleIndex() { return RULE_appendOp; }
1906 @Override
1907 public void enterRule(ParseTreeListener listener) {
1908 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterAppendOp(this);
1909 }
1910 @Override
1911 public void exitRule(ParseTreeListener listener) {
1912 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitAppendOp(this);
1913 }
1914 }
1915
1916 public final AppendOpContext appendOp(StringBuffer buf) throws RecognitionException {
1917 AppendOpContext _localctx = new AppendOpContext(_ctx, getState(), buf);
1918 enterRule(_localctx, 34, RULE_appendOp);
1919 int _la;
1920 try {
1921 enterOuterAlt(_localctx, 1);
1922 {
1923 setState(248);
1924 _errHandler.sync(this);
1925 switch (_input.LA(1)) {
1926 case NAME:
1927 {
1928 {
1929 setState(237);
1930 ((AppendOpContext)_localctx).funT = match(NAME);
1931 setState(239);
1932 _errHandler.sync(this);
1933 _la = _input.LA(1);
1934 if (_la==INV) {
1935 {
1936 setState(238);
1937 ((AppendOpContext)_localctx).invT = match(INV);
1938 }
1939 }
1940
1941 setState(243);
1942 _errHandler.sync(this);
1943 switch (_input.LA(1)) {
1944 case CONT:
1945 {
1946 setState(241);
1947 ((AppendOpContext)_localctx).accT = match(CONT);
1948 }
1949 break;
1950 case COV:
1951 {
1952 setState(242);
1953 ((AppendOpContext)_localctx).accT = match(COV);
1954 }
1955 break;
1956 default:
1957 throw new NoViableAltException(this);
1958 }
1959 }
1960 }
1961 break;
1962 case UNION:
1963 {
1964 setState(245);
1965 ((AppendOpContext)_localctx).opT = match(UNION);
1966 }
1967 break;
1968 case INTERSECT:
1969 {
1970 setState(246);
1971 ((AppendOpContext)_localctx).opT = match(INTERSECT);
1972 }
1973 break;
1974 case COMPLEMENT:
1975 {
1976 setState(247);
1977 ((AppendOpContext)_localctx).opT = match(COMPLEMENT);
1978 }
1979 break;
1980 default:
1981 throw new NoViableAltException(this);
1982 }
1983
1984 if (((AppendOpContext)_localctx).opT == null) {
1985 assert ((AppendOpContext)_localctx).funT != null && ((AppendOpContext)_localctx).accT != null;
1986 buf.append((((AppendOpContext)_localctx).funT!=null?((AppendOpContext)_localctx).funT.getText():null));
1987 if (((AppendOpContext)_localctx).invT != null) {
1988 buf.append((((AppendOpContext)_localctx).invT!=null?((AppendOpContext)_localctx).invT.getText():null));
1989 }
1990 buf.append((((AppendOpContext)_localctx).accT!=null?((AppendOpContext)_localctx).accT.getText():null));
1991 } else {
1992 assert ((AppendOpContext)_localctx).funT == null && ((AppendOpContext)_localctx).invT == null && ((AppendOpContext)_localctx).accT == null;
1993 buf.append((((AppendOpContext)_localctx).opT!=null?((AppendOpContext)_localctx).opT.getText():null));
1994 }
1995
1996 }
1997 }
1998 catch (RecognitionException re) {
1999 _localctx.exception = re;
2000 _errHandler.reportError(this, re);
2001 _errHandler.recover(this, re);
2002 }
2003 finally {
2004 exitRule();
2005 }
2006 return _localctx;
2007 }
2008
2009 public static class ComponentsContext extends ParserRuleContext {
2010 public Map<String,CClassLink> componentsX;
2011 public TerminalNode COMPONENTS() { return getToken(CClassParser.COMPONENTS, 0); }
2012 public List<ComponentContext> component() {
2013 return getRuleContexts(ComponentContext.class);
2014 }
2015 public ComponentContext component(int i) {
2016 return getRuleContext(ComponentContext.class,i);
2017 }
2018 public ComponentsContext(ParserRuleContext parent, int invokingState) {
2019 super(parent, invokingState);
2020 }
2021 @Override public int getRuleIndex() { return RULE_components; }
2022 @Override
2023 public void enterRule(ParseTreeListener listener) {
2024 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterComponents(this);
2025 }
2026 @Override
2027 public void exitRule(ParseTreeListener listener) {
2028 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitComponents(this);
2029 }
2030 }
2031
2032 public final ComponentsContext components() throws RecognitionException {
2033 ComponentsContext _localctx = new ComponentsContext(_ctx, getState());
2034 enterRule(_localctx, 36, RULE_components);
2035
2036 Map<String,CClassLink> components0 = new TreeMap<String,CClassLink>();
2037
2038 int _la;
2039 try {
2040 enterOuterAlt(_localctx, 1);
2041 {
2042 setState(259);
2043 _errHandler.sync(this);
2044 _la = _input.LA(1);
2045 if (_la==COMPONENTS) {
2046 {
2047 setState(252);
2048 match(COMPONENTS);
2049 setState(256);
2050 _errHandler.sync(this);
2051 _la = _input.LA(1);
2052 while (_la==NAME) {
2053 {
2054 {
2055 setState(253);
2056 component(components0);
2057 }
2058 }
2059 setState(258);
2060 _errHandler.sync(this);
2061 _la = _input.LA(1);
2062 }
2063 }
2064 }
2065
2066 }
2067 _ctx.stop = _input.LT(-1);
2068
2069 ((ComponentsContext)_localctx).componentsX = components0;
2070
2071 }
2072 catch (RecognitionException re) {
2073 _localctx.exception = re;
2074 _errHandler.reportError(this, re);
2075 _errHandler.recover(this, re);
2076 }
2077 finally {
2078 exitRule();
2079 }
2080 return _localctx;
2081 }
2082
2083 public static class ComponentContext extends ParserRuleContext {
2084 public Map<String,CClassLink> componentsX;
2085 public Token cClassX;
2086 public Token cName;
2087 public TerminalNode END() { return getToken(CClassParser.END, 0); }
2088 public List<TerminalNode> NAME() { return getTokens(CClassParser.NAME); }
2089 public TerminalNode NAME(int i) {
2090 return getToken(CClassParser.NAME, i);
2091 }
2092 public ComponentContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
2093 public ComponentContext(ParserRuleContext parent, int invokingState, Map<String,CClassLink> componentsX) {
2094 super(parent, invokingState);
2095 this.componentsX = componentsX;
2096 }
2097 @Override public int getRuleIndex() { return RULE_component; }
2098 @Override
2099 public void enterRule(ParseTreeListener listener) {
2100 if ( listener instanceof CClassListener ) ((CClassListener)listener).enterComponent(this);
2101 }
2102 @Override
2103 public void exitRule(ParseTreeListener listener) {
2104 if ( listener instanceof CClassListener ) ((CClassListener)listener).exitComponent(this);
2105 }
2106 }
2107
2108 public final ComponentContext component(Map<String,CClassLink> componentsX) throws RecognitionException {
2109 ComponentContext _localctx = new ComponentContext(_ctx, getState(), componentsX);
2110 enterRule(_localctx, 38, RULE_component);
2111 try {
2112 enterOuterAlt(_localctx, 1);
2113 {
2114 {
2115 setState(261);
2116 ((ComponentContext)_localctx).cClassX = match(NAME);
2117 setState(262);
2118 ((ComponentContext)_localctx).cName = match(NAME);
2119 setState(263);
2120 match(END);
2121 }
2122
2123 ClassLocator loc =
2124 new ClassLocator((((ComponentContext)_localctx).cClassX!=null?((ComponentContext)_localctx).cClassX.getText():null),this.loc.getPackage());
2125
2126 CClassLink link = this.classLoader
2127 .resolveLocInOcc(loc,this.loc,(((ComponentContext)_localctx).cName!=null?((ComponentContext)_localctx).cName.getText():null));
2128
2129 CClassLink old = componentsX.put((((ComponentContext)_localctx).cName!=null?((ComponentContext)_localctx).cName.getText():null), link);
2130 if (old != null) {
2131 report("Duplicate component \"" + (((ComponentContext)_localctx).cName!=null?((ComponentContext)_localctx).cName.getText():null) +
2132 "\"; overwrite " + old + " by " + (((ComponentContext)_localctx).cClassX!=null?((ComponentContext)_localctx).cClassX.getText():null) + ". " );
2133 }
2134
2135 }
2136 }
2137 catch (RecognitionException re) {
2138 _localctx.exception = re;
2139 _errHandler.reportError(this, re);
2140 _errHandler.recover(this, re);
2141 }
2142 finally {
2143 exitRule();
2144 }
2145 return _localctx;
2146 }
2147
2148 public static final String _serializedATN =
2149 "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3$\u010e\4\2\t\2\4"+
2150 "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+
2151 "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
2152 "\4\23\t\23\4\24\t\24\4\25\t\25\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2"+
2153 "\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\5\3@\n\3\3\3\3\3\3\4\3\4"+
2154 "\3\4\3\4\3\4\7\4I\n\4\f\4\16\4L\13\4\3\5\3\5\7\5P\n\5\f\5\16\5S\13\5\5"+
2155 "\5U\n\5\3\6\5\6X\n\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\7\6a\n\6\f\6\16\6d\13"+
2156 "\6\3\6\5\6g\n\6\3\6\3\6\3\6\3\6\3\6\3\7\3\7\7\7p\n\7\f\7\16\7s\13\7\3"+
2157 "\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\t\7\t\u0081\n\t\f\t\16\t"+
2158 "\u0084\13\t\3\t\3\t\3\n\3\n\7\n\u008a\n\n\f\n\16\n\u008d\13\n\5\n\u008f"+
2159 "\n\n\3\13\5\13\u0092\n\13\3\13\7\13\u0095\n\13\f\13\16\13\u0098\13\13"+
2160 "\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\5\13\u00a3\n\13\3\13\3\13"+
2161 "\3\13\3\13\3\f\3\f\5\f\u00ab\n\f\3\f\3\f\3\r\3\r\3\r\3\r\7\r\u00b3\n\r"+
2162 "\f\r\16\r\u00b6\13\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\17\3\17\3"+
2163 "\17\3\17\3\17\3\17\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\7\21\u00ce"+
2164 "\n\21\f\21\16\21\u00d1\13\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\7\21\u00da"+
2165 "\n\21\f\21\16\21\u00dd\13\21\3\21\3\21\3\21\3\21\3\21\7\21\u00e4\n\21"+
2166 "\f\21\16\21\u00e7\13\21\5\21\u00e9\n\21\3\21\3\21\3\22\3\22\3\22\3\23"+
2167 "\3\23\5\23\u00f2\n\23\3\23\3\23\5\23\u00f6\n\23\3\23\3\23\3\23\5\23\u00fb"+
2168 "\n\23\3\23\3\23\3\24\3\24\7\24\u0101\n\24\f\24\16\24\u0104\13\24\5\24"+
2169 "\u0106\n\24\3\25\3\25\3\25\3\25\3\25\3\25\3\25\2\2\26\2\4\6\b\n\f\16\20"+
2170 "\22\24\26\30\32\34\36 \"$&(\2\2\2\u0117\2*\3\2\2\2\4?\3\2\2\2\6C\3\2\2"+
2171 "\2\bT\3\2\2\2\nW\3\2\2\2\fm\3\2\2\2\16z\3\2\2\2\20}\3\2\2\2\22\u008e\3"+
2172 "\2\2\2\24\u0091\3\2\2\2\26\u00aa\3\2\2\2\30\u00ae\3\2\2\2\32\u00ba\3\2"+
2173 "\2\2\34\u00bf\3\2\2\2\36\u00c5\3\2\2\2 \u00e8\3\2\2\2\"\u00ec\3\2\2\2"+
2174 "$\u00fa\3\2\2\2&\u0105\3\2\2\2(\u0107\3\2\2\2*+\7\16\2\2+,\5\6\4\2,-\7"+
2175 "\36\2\2-.\b\2\1\2./\7\17\2\2/\60\7#\2\2\60\61\5\4\3\2\61\62\7\3\2\2\62"+
2176 "\63\5\22\n\2\63\64\5\b\5\2\64\65\5&\24\2\65\66\b\2\1\2\66\67\7\4\2\2\67"+
2177 "8\7\2\2\389\3\2\2\29:\b\2\1\2:\3\3\2\2\2;<\7\20\2\2<=\5\6\4\2=>\3\2\2"+
2178 "\2>@\3\2\2\2?;\3\2\2\2?@\3\2\2\2@A\3\2\2\2AB\b\3\1\2B\5\3\2\2\2CD\7#\2"+
2179 "\2DJ\b\4\1\2EF\7\37\2\2FG\7#\2\2GI\b\4\1\2HE\3\2\2\2IL\3\2\2\2JH\3\2\2"+
2180 "\2JK\3\2\2\2K\7\3\2\2\2LJ\3\2\2\2MQ\7\22\2\2NP\5\n\6\2ON\3\2\2\2PS\3\2"+
2181 "\2\2QO\3\2\2\2QR\3\2\2\2RU\3\2\2\2SQ\3\2\2\2TM\3\2\2\2TU\3\2\2\2U\t\3"+
2182 "\2\2\2VX\7\21\2\2WV\3\2\2\2WX\3\2\2\2XY\3\2\2\2YZ\7#\2\2Z[\7\5\2\2[\\"+
2183 "\5\6\4\2\\]\7\6\2\2]^\5\6\4\2^b\7\3\2\2_a\5\f\7\2`_\3\2\2\2ad\3\2\2\2"+
2184 "b`\3\2\2\2bc\3\2\2\2cf\3\2\2\2db\3\2\2\2eg\5\20\t\2fe\3\2\2\2fg\3\2\2"+
2185 "\2gh\3\2\2\2hi\7\4\2\2ij\7\36\2\2jk\3\2\2\2kl\b\6\1\2l\13\3\2\2\2mq\7"+
2186 "\3\2\2np\5\16\b\2on\3\2\2\2ps\3\2\2\2qo\3\2\2\2qr\3\2\2\2rt\3\2\2\2sq"+
2187 "\3\2\2\2tu\7\4\2\2uv\7\24\2\2vw\7#\2\2wx\3\2\2\2xy\b\7\1\2y\r\3\2\2\2"+
2188 "z{\7#\2\2{|\b\b\1\2|\17\3\2\2\2}~\7\25\2\2~\u0082\7\3\2\2\177\u0081\5"+
2189 "\16\b\2\u0080\177\3\2\2\2\u0081\u0084\3\2\2\2\u0082\u0080\3\2\2\2\u0082"+
2190 "\u0083\3\2\2\2\u0083\u0085\3\2\2\2\u0084\u0082\3\2\2\2\u0085\u0086\7\4"+
2191 "\2\2\u0086\21\3\2\2\2\u0087\u008b\7\27\2\2\u0088\u008a\5\24\13\2\u0089"+
2192 "\u0088\3\2\2\2\u008a\u008d\3\2\2\2\u008b\u0089\3\2\2\2\u008b\u008c\3\2"+
2193 "\2\2\u008c\u008f\3\2\2\2\u008d\u008b\3\2\2\2\u008e\u0087\3\2\2\2\u008e"+
2194 "\u008f\3\2\2\2\u008f\23\3\2\2\2\u0090\u0092\7\21\2\2\u0091\u0090\3\2\2"+
2195 "\2\u0091\u0092\3\2\2\2\u0092\u0096\3\2\2\2\u0093\u0095\5\26\f\2\u0094"+
2196 "\u0093\3\2\2\2\u0095\u0098\3\2\2\2\u0096\u0094\3\2\2\2\u0096\u0097\3\2"+
2197 "\2\2\u0097\u0099\3\2\2\2\u0098\u0096\3\2\2\2\u0099\u009a\5\6\4\2\u009a"+
2198 "\u009b\7#\2\2\u009b\u009c\3\2\2\2\u009c\u00a2\b\13\1\2\u009d\u00a3\5\30"+
2199 "\r\2\u009e\u009f\7\7\2\2\u009f\u00a0\5\36\20\2\u00a0\u00a1\7\b\2\2\u00a1"+
2200 "\u00a3\3\2\2\2\u00a2\u009d\3\2\2\2\u00a2\u009e\3\2\2\2\u00a2\u00a3\3\2"+
2201 "\2\2\u00a3\u00a4\3\2\2\2\u00a4\u00a5\7\36\2\2\u00a5\u00a6\3\2\2\2\u00a6"+
2202 "\u00a7\b\13\1\2\u00a7\25\3\2\2\2\u00a8\u00ab\7\30\2\2\u00a9\u00ab\7\31"+
2203 "\2\2\u00aa\u00a8\3\2\2\2\u00aa\u00a9\3\2\2\2\u00ab\u00ac\3\2\2\2\u00ac"+
2204 "\u00ad\b\f\1\2\u00ad\27\3\2\2\2\u00ae\u00b4\7\3\2\2\u00af\u00b3\5\34\17"+
2205 "\2\u00b0\u00b1\7\32\2\2\u00b1\u00b3\5\32\16\2\u00b2\u00af\3\2\2\2\u00b2"+
2206 "\u00b0\3\2\2\2\u00b3\u00b6\3\2\2\2\u00b4\u00b2\3\2\2\2\u00b4\u00b5\3\2"+
2207 "\2\2\u00b5\u00b7\3\2\2\2\u00b6\u00b4\3\2\2\2\u00b7\u00b8\7\4\2\2\u00b8"+
2208 "\u00b9\b\r\1\2\u00b9\31\3\2\2\2\u00ba\u00bb\7#\2\2\u00bb\u00bc\b\16\1"+
2209 "\2\u00bc\u00bd\5\30\r\2\u00bd\u00be\b\16\1\2\u00be\33\3\2\2\2\u00bf\u00c0"+
2210 "\7#\2\2\u00c0\u00c1\7\5\2\2\u00c1\u00c2\7$\2\2\u00c2\u00c3\3\2\2\2\u00c3"+
2211 "\u00c4\b\17\1\2\u00c4\35\3\2\2\2\u00c5\u00c6\5 \21\2\u00c6\u00c7\b\20"+
2212 "\1\2\u00c7\37\3\2\2\2\u00c8\u00c9\7\t\2\2\u00c9\u00ca\5\"\22\2\u00ca\u00cb"+
2213 "\7\n\2\2\u00cb\u00cf\7\3\2\2\u00cc\u00ce\5\"\22\2\u00cd\u00cc\3\2\2\2"+
2214 "\u00ce\u00d1\3\2\2\2\u00cf\u00cd\3\2\2\2\u00cf\u00d0\3\2\2\2\u00d0\u00d2"+
2215 "\3\2\2\2\u00d1\u00cf\3\2\2\2\u00d2\u00d3\7\4\2\2\u00d3\u00e9\3\2\2\2\u00d4"+
2216 "\u00d5\5$\23\2\u00d5\u00d6\7\7\2\2\u00d6\u00db\5 \21\2\u00d7\u00d8\7\34"+
2217 "\2\2\u00d8\u00da\5 \21\2\u00d9\u00d7\3\2\2\2\u00da\u00dd\3\2\2\2\u00db"+
2218 "\u00d9\3\2\2\2\u00db\u00dc\3\2\2\2\u00dc\u00de\3\2\2\2\u00dd\u00db\3\2"+
2219 "\2\2\u00de\u00df\7\b\2\2\u00df\u00e9\3\2\2\2\u00e0\u00e5\5\"\22\2\u00e1"+
2220 "\u00e2\7\37\2\2\u00e2\u00e4\5\"\22\2\u00e3\u00e1\3\2\2\2\u00e4\u00e7\3"+
2221 "\2\2\2\u00e5\u00e3\3\2\2\2\u00e5\u00e6\3\2\2\2\u00e6\u00e9\3\2\2\2\u00e7"+
2222 "\u00e5\3\2\2\2\u00e8\u00c8\3\2\2\2\u00e8\u00d4\3\2\2\2\u00e8\u00e0\3\2"+
2223 "\2\2\u00e9\u00ea\3\2\2\2\u00ea\u00eb\b\21\1\2\u00eb!\3\2\2\2\u00ec\u00ed"+
2224 "\7#\2\2\u00ed\u00ee\b\22\1\2\u00ee#\3\2\2\2\u00ef\u00f1\7#\2\2\u00f0\u00f2"+
2225 "\7\33\2\2\u00f1\u00f0\3\2\2\2\u00f1\u00f2\3\2\2\2\u00f2\u00f5\3\2\2\2"+
2226 "\u00f3\u00f6\7\35\2\2\u00f4\u00f6\7\34\2\2\u00f5\u00f3\3\2\2\2\u00f5\u00f4"+
2227 "\3\2\2\2\u00f6\u00fb\3\2\2\2\u00f7\u00fb\7 \2\2\u00f8\u00fb\7!\2\2\u00f9"+
2228 "\u00fb\7\"\2\2\u00fa\u00ef\3\2\2\2\u00fa\u00f7\3\2\2\2\u00fa\u00f8\3\2"+
2229 "\2\2\u00fa\u00f9\3\2\2\2\u00fb\u00fc\3\2\2\2\u00fc\u00fd\b\23\1\2\u00fd"+
2230 "%\3\2\2\2\u00fe\u0102\7\26\2\2\u00ff\u0101\5(\25\2\u0100\u00ff\3\2\2\2"+
2231 "\u0101\u0104\3\2\2\2\u0102\u0100\3\2\2\2\u0102\u0103\3\2\2\2\u0103\u0106"+
2232 "\3\2\2\2\u0104\u0102\3\2\2\2\u0105\u00fe\3\2\2\2\u0105\u0106\3\2\2\2\u0106"+
2233 "\'\3\2\2\2\u0107\u0108\7#\2\2\u0108\u0109\7#\2\2\u0109\u010a\7\36\2\2"+
2234 "\u010a\u010b\3\2\2\2\u010b\u010c\b\25\1\2\u010c)\3\2\2\2\34?JQTWbfq\u0082"+
2235 "\u008b\u008e\u0091\u0096\u00a2\u00aa\u00b2\u00b4\u00cf\u00db\u00e5\u00e8"+
2236 "\u00f1\u00f5\u00fa\u0102\u0105";
2237 public static final ATN _ATN =
2238 new ATNDeserializer().deserialize(_serializedATN.toCharArray());
2239 static {
2240 _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
2241 for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
2242 _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
2243 }
2244 }
2245 }