Code Duplication    Length = 186-186 lines in 2 locations

src/main/java/it/cnr/istc/pst/platinum/ai/lang/ddl/v3/parser/ddl3Parser.java 2 locations

@@ 5065-5250 (lines=186) @@
5062
5063
	// $ANTLR start "singleton_state_variable_component_type"
5064
	// /home/alessandro/opt/antlr/ddl3/ddl3.g:111:1: singleton_state_variable_component_type : 'COMP_TYPE' 'SingletonStateVariable' ID '(' singleton_state_variable_component_decision_type ( ',' singleton_state_variable_component_decision_type )* ')' '{' ( singleton_state_variable_transition_constraint )* '}' -> ^( ID ( singleton_state_variable_component_decision_type )+ ( singleton_state_variable_transition_constraint )* ) ;
5065
	public final ddl3Parser.singleton_state_variable_component_type_return singleton_state_variable_component_type() throws RecognitionException {
5066
		ddl3Parser.singleton_state_variable_component_type_return retval = new ddl3Parser.singleton_state_variable_component_type_return();
5067
		retval.start = input.LT(1);
5068
		int singleton_state_variable_component_type_StartIndex = input.index();
5069
5070
		Object root_0 = null;
5071
5072
		Token string_literal164=null;
5073
		Token string_literal165=null;
5074
		Token ID166=null;
5075
		Token char_literal167=null;
5076
		Token char_literal169=null;
5077
		Token char_literal171=null;
5078
		Token char_literal172=null;
5079
		Token char_literal174=null;
5080
		ParserRuleReturnScope singleton_state_variable_component_decision_type168 =null;
5081
		ParserRuleReturnScope singleton_state_variable_component_decision_type170 =null;
5082
		ParserRuleReturnScope singleton_state_variable_transition_constraint173 =null;
5083
5084
		Object string_literal164_tree=null;
5085
		Object string_literal165_tree=null;
5086
		Object ID166_tree=null;
5087
		Object char_literal167_tree=null;
5088
		Object char_literal169_tree=null;
5089
		Object char_literal171_tree=null;
5090
		Object char_literal172_tree=null;
5091
		Object char_literal174_tree=null;
5092
		RewriteRuleTokenStream stream_11=new RewriteRuleTokenStream(adaptor,"token 11");
5093
		RewriteRuleTokenStream stream_12=new RewriteRuleTokenStream(adaptor,"token 12");
5094
		RewriteRuleTokenStream stream_35=new RewriteRuleTokenStream(adaptor,"token 35");
5095
		RewriteRuleTokenStream stream_15=new RewriteRuleTokenStream(adaptor,"token 15");
5096
		RewriteRuleTokenStream stream_80=new RewriteRuleTokenStream(adaptor,"token 80");
5097
		RewriteRuleTokenStream stream_81=new RewriteRuleTokenStream(adaptor,"token 81");
5098
		RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
5099
		RewriteRuleTokenStream stream_73=new RewriteRuleTokenStream(adaptor,"token 73");
5100
		RewriteRuleSubtreeStream stream_singleton_state_variable_component_decision_type=new RewriteRuleSubtreeStream(adaptor,"rule singleton_state_variable_component_decision_type");
5101
		RewriteRuleSubtreeStream stream_singleton_state_variable_transition_constraint=new RewriteRuleSubtreeStream(adaptor,"rule singleton_state_variable_transition_constraint");
5102
5103
		try {
5104
			if ( state.backtracking>0 && alreadyParsedRule(input, 23) ) { return retval; }
5105
5106
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:112:2: ( 'COMP_TYPE' 'SingletonStateVariable' ID '(' singleton_state_variable_component_decision_type ( ',' singleton_state_variable_component_decision_type )* ')' '{' ( singleton_state_variable_transition_constraint )* '}' -> ^( ID ( singleton_state_variable_component_decision_type )+ ( singleton_state_variable_transition_constraint )* ) )
5107
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:112:4: 'COMP_TYPE' 'SingletonStateVariable' ID '(' singleton_state_variable_component_decision_type ( ',' singleton_state_variable_component_decision_type )* ')' '{' ( singleton_state_variable_transition_constraint )* '}'
5108
			{
5109
			string_literal164=(Token)match(input,35,FOLLOW_35_in_singleton_state_variable_component_type1158); if (state.failed) return retval; 
5110
			if ( state.backtracking==0 ) stream_35.add(string_literal164);
5111
5112
			string_literal165=(Token)match(input,73,FOLLOW_73_in_singleton_state_variable_component_type1160); if (state.failed) return retval; 
5113
			if ( state.backtracking==0 ) stream_73.add(string_literal165);
5114
5115
			ID166=(Token)match(input,ID,FOLLOW_ID_in_singleton_state_variable_component_type1162); if (state.failed) return retval; 
5116
			if ( state.backtracking==0 ) stream_ID.add(ID166);
5117
5118
			char_literal167=(Token)match(input,11,FOLLOW_11_in_singleton_state_variable_component_type1164); if (state.failed) return retval; 
5119
			if ( state.backtracking==0 ) stream_11.add(char_literal167);
5120
5121
			pushFollow(FOLLOW_singleton_state_variable_component_decision_type_in_singleton_state_variable_component_type1166);
5122
			singleton_state_variable_component_decision_type168=singleton_state_variable_component_decision_type();
5123
			state._fsp--;
5124
			if (state.failed) return retval;
5125
			if ( state.backtracking==0 ) stream_singleton_state_variable_component_decision_type.add(singleton_state_variable_component_decision_type168.getTree());
5126
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:112:97: ( ',' singleton_state_variable_component_decision_type )*
5127
			loop20:
5128
			while (true) {
5129
				int alt20=2;
5130
				int LA20_0 = input.LA(1);
5131
				if ( (LA20_0==15) ) {
5132
					alt20=1;
5133
				}
5134
5135
				switch (alt20) {
5136
				case 1 :
5137
					// /home/alessandro/opt/antlr/ddl3/ddl3.g:112:98: ',' singleton_state_variable_component_decision_type
5138
					{
5139
					char_literal169=(Token)match(input,15,FOLLOW_15_in_singleton_state_variable_component_type1169); if (state.failed) return retval; 
5140
					if ( state.backtracking==0 ) stream_15.add(char_literal169);
5141
5142
					pushFollow(FOLLOW_singleton_state_variable_component_decision_type_in_singleton_state_variable_component_type1171);
5143
					singleton_state_variable_component_decision_type170=singleton_state_variable_component_decision_type();
5144
					state._fsp--;
5145
					if (state.failed) return retval;
5146
					if ( state.backtracking==0 ) stream_singleton_state_variable_component_decision_type.add(singleton_state_variable_component_decision_type170.getTree());
5147
					}
5148
					break;
5149
5150
				default :
5151
					break loop20;
5152
				}
5153
			}
5154
5155
			char_literal171=(Token)match(input,12,FOLLOW_12_in_singleton_state_variable_component_type1175); if (state.failed) return retval; 
5156
			if ( state.backtracking==0 ) stream_12.add(char_literal171);
5157
5158
			char_literal172=(Token)match(input,80,FOLLOW_80_in_singleton_state_variable_component_type1177); if (state.failed) return retval; 
5159
			if ( state.backtracking==0 ) stream_80.add(char_literal172);
5160
5161
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:112:161: ( singleton_state_variable_transition_constraint )*
5162
			loop21:
5163
			while (true) {
5164
				int alt21=2;
5165
				int LA21_0 = input.LA(1);
5166
				if ( (LA21_0==75) ) {
5167
					alt21=1;
5168
				}
5169
5170
				switch (alt21) {
5171
				case 1 :
5172
					// /home/alessandro/opt/antlr/ddl3/ddl3.g:112:162: singleton_state_variable_transition_constraint
5173
					{
5174
					pushFollow(FOLLOW_singleton_state_variable_transition_constraint_in_singleton_state_variable_component_type1180);
5175
					singleton_state_variable_transition_constraint173=singleton_state_variable_transition_constraint();
5176
					state._fsp--;
5177
					if (state.failed) return retval;
5178
					if ( state.backtracking==0 ) stream_singleton_state_variable_transition_constraint.add(singleton_state_variable_transition_constraint173.getTree());
5179
					}
5180
					break;
5181
5182
				default :
5183
					break loop21;
5184
				}
5185
			}
5186
5187
			char_literal174=(Token)match(input,81,FOLLOW_81_in_singleton_state_variable_component_type1184); if (state.failed) return retval; 
5188
			if ( state.backtracking==0 ) stream_81.add(char_literal174);
5189
5190
			// AST REWRITE
5191
			// elements: ID, singleton_state_variable_component_decision_type, singleton_state_variable_transition_constraint
5192
			// token labels: 
5193
			// rule labels: retval
5194
			// token list labels: 
5195
			// rule list labels: 
5196
			// wildcard labels: 
5197
			if ( state.backtracking==0 ) {
5198
			retval.tree = root_0;
5199
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null);
5200
5201
			root_0 = (Object)adaptor.nil();
5202
			// 112:215: -> ^( ID ( singleton_state_variable_component_decision_type )+ ( singleton_state_variable_transition_constraint )* )
5203
			{
5204
				// /home/alessandro/opt/antlr/ddl3/ddl3.g:112:217: ^( ID ( singleton_state_variable_component_decision_type )+ ( singleton_state_variable_transition_constraint )* )
5205
				{
5206
				Object root_1 = (Object)adaptor.nil();
5207
				root_1 = (Object)adaptor.becomeRoot(new DDLSingletonStateVariableComponentType(stream_ID.nextToken()), root_1);
5208
				if ( !(stream_singleton_state_variable_component_decision_type.hasNext()) ) {
5209
					throw new RewriteEarlyExitException();
5210
				}
5211
				while ( stream_singleton_state_variable_component_decision_type.hasNext() ) {
5212
					adaptor.addChild(root_1, stream_singleton_state_variable_component_decision_type.nextTree());
5213
				}
5214
				stream_singleton_state_variable_component_decision_type.reset();
5215
5216
				// /home/alessandro/opt/antlr/ddl3/ddl3.g:112:314: ( singleton_state_variable_transition_constraint )*
5217
				while ( stream_singleton_state_variable_transition_constraint.hasNext() ) {
5218
					adaptor.addChild(root_1, stream_singleton_state_variable_transition_constraint.nextTree());
5219
				}
5220
				stream_singleton_state_variable_transition_constraint.reset();
5221
5222
				adaptor.addChild(root_0, root_1);
5223
				}
5224
5225
			}
5226
5227
5228
			retval.tree = root_0;
5229
			}
5230
5231
			}
5232
5233
			retval.stop = input.LT(-1);
5234
5235
			if ( state.backtracking==0 ) {
5236
			retval.tree = (Object)adaptor.rulePostProcessing(root_0);
5237
			adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
5238
			}
5239
		}
5240
		catch (RecognitionException re) {
5241
			reportError(re);
5242
			recover(input,re);
5243
			retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
5244
		}
5245
		finally {
5246
			// do for sure before leaving
5247
			if ( state.backtracking>0 ) { memoize(input, 23, singleton_state_variable_component_type_StartIndex); }
5248
5249
		}
5250
		return retval;
5251
	}
5252
	// $ANTLR end "singleton_state_variable_component_type"
5253
@@ 4545-4730 (lines=186) @@
4542
4543
	// $ANTLR start "simple_ground_state_variable_component_type"
4544
	// /home/alessandro/opt/antlr/ddl3/ddl3.g:98:1: simple_ground_state_variable_component_type : 'COMP_TYPE' 'SimpleGroundStateVariable' ID '(' simple_ground_state_variable_component_decision_type ( ',' simple_ground_state_variable_component_decision_type )* ')' '{' ( simple_ground_state_variable_transition_constraint )* '}' -> ^( ID ( simple_ground_state_variable_component_decision_type )+ ( simple_ground_state_variable_transition_constraint )* ) ;
4545
	public final ddl3Parser.simple_ground_state_variable_component_type_return simple_ground_state_variable_component_type() throws RecognitionException {
4546
		ddl3Parser.simple_ground_state_variable_component_type_return retval = new ddl3Parser.simple_ground_state_variable_component_type_return();
4547
		retval.start = input.LT(1);
4548
		int simple_ground_state_variable_component_type_StartIndex = input.index();
4549
4550
		Object root_0 = null;
4551
4552
		Token string_literal141=null;
4553
		Token string_literal142=null;
4554
		Token ID143=null;
4555
		Token char_literal144=null;
4556
		Token char_literal146=null;
4557
		Token char_literal148=null;
4558
		Token char_literal149=null;
4559
		Token char_literal151=null;
4560
		ParserRuleReturnScope simple_ground_state_variable_component_decision_type145 =null;
4561
		ParserRuleReturnScope simple_ground_state_variable_component_decision_type147 =null;
4562
		ParserRuleReturnScope simple_ground_state_variable_transition_constraint150 =null;
4563
4564
		Object string_literal141_tree=null;
4565
		Object string_literal142_tree=null;
4566
		Object ID143_tree=null;
4567
		Object char_literal144_tree=null;
4568
		Object char_literal146_tree=null;
4569
		Object char_literal148_tree=null;
4570
		Object char_literal149_tree=null;
4571
		Object char_literal151_tree=null;
4572
		RewriteRuleTokenStream stream_11=new RewriteRuleTokenStream(adaptor,"token 11");
4573
		RewriteRuleTokenStream stream_12=new RewriteRuleTokenStream(adaptor,"token 12");
4574
		RewriteRuleTokenStream stream_35=new RewriteRuleTokenStream(adaptor,"token 35");
4575
		RewriteRuleTokenStream stream_15=new RewriteRuleTokenStream(adaptor,"token 15");
4576
		RewriteRuleTokenStream stream_80=new RewriteRuleTokenStream(adaptor,"token 80");
4577
		RewriteRuleTokenStream stream_81=new RewriteRuleTokenStream(adaptor,"token 81");
4578
		RewriteRuleTokenStream stream_72=new RewriteRuleTokenStream(adaptor,"token 72");
4579
		RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
4580
		RewriteRuleSubtreeStream stream_simple_ground_state_variable_component_decision_type=new RewriteRuleSubtreeStream(adaptor,"rule simple_ground_state_variable_component_decision_type");
4581
		RewriteRuleSubtreeStream stream_simple_ground_state_variable_transition_constraint=new RewriteRuleSubtreeStream(adaptor,"rule simple_ground_state_variable_transition_constraint");
4582
4583
		try {
4584
			if ( state.backtracking>0 && alreadyParsedRule(input, 19) ) { return retval; }
4585
4586
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:99:2: ( 'COMP_TYPE' 'SimpleGroundStateVariable' ID '(' simple_ground_state_variable_component_decision_type ( ',' simple_ground_state_variable_component_decision_type )* ')' '{' ( simple_ground_state_variable_transition_constraint )* '}' -> ^( ID ( simple_ground_state_variable_component_decision_type )+ ( simple_ground_state_variable_transition_constraint )* ) )
4587
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:99:4: 'COMP_TYPE' 'SimpleGroundStateVariable' ID '(' simple_ground_state_variable_component_decision_type ( ',' simple_ground_state_variable_component_decision_type )* ')' '{' ( simple_ground_state_variable_transition_constraint )* '}'
4588
			{
4589
			string_literal141=(Token)match(input,35,FOLLOW_35_in_simple_ground_state_variable_component_type1028); if (state.failed) return retval; 
4590
			if ( state.backtracking==0 ) stream_35.add(string_literal141);
4591
4592
			string_literal142=(Token)match(input,72,FOLLOW_72_in_simple_ground_state_variable_component_type1030); if (state.failed) return retval; 
4593
			if ( state.backtracking==0 ) stream_72.add(string_literal142);
4594
4595
			ID143=(Token)match(input,ID,FOLLOW_ID_in_simple_ground_state_variable_component_type1032); if (state.failed) return retval; 
4596
			if ( state.backtracking==0 ) stream_ID.add(ID143);
4597
4598
			char_literal144=(Token)match(input,11,FOLLOW_11_in_simple_ground_state_variable_component_type1034); if (state.failed) return retval; 
4599
			if ( state.backtracking==0 ) stream_11.add(char_literal144);
4600
4601
			pushFollow(FOLLOW_simple_ground_state_variable_component_decision_type_in_simple_ground_state_variable_component_type1036);
4602
			simple_ground_state_variable_component_decision_type145=simple_ground_state_variable_component_decision_type();
4603
			state._fsp--;
4604
			if (state.failed) return retval;
4605
			if ( state.backtracking==0 ) stream_simple_ground_state_variable_component_decision_type.add(simple_ground_state_variable_component_decision_type145.getTree());
4606
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:99:104: ( ',' simple_ground_state_variable_component_decision_type )*
4607
			loop16:
4608
			while (true) {
4609
				int alt16=2;
4610
				int LA16_0 = input.LA(1);
4611
				if ( (LA16_0==15) ) {
4612
					alt16=1;
4613
				}
4614
4615
				switch (alt16) {
4616
				case 1 :
4617
					// /home/alessandro/opt/antlr/ddl3/ddl3.g:99:105: ',' simple_ground_state_variable_component_decision_type
4618
					{
4619
					char_literal146=(Token)match(input,15,FOLLOW_15_in_simple_ground_state_variable_component_type1039); if (state.failed) return retval; 
4620
					if ( state.backtracking==0 ) stream_15.add(char_literal146);
4621
4622
					pushFollow(FOLLOW_simple_ground_state_variable_component_decision_type_in_simple_ground_state_variable_component_type1041);
4623
					simple_ground_state_variable_component_decision_type147=simple_ground_state_variable_component_decision_type();
4624
					state._fsp--;
4625
					if (state.failed) return retval;
4626
					if ( state.backtracking==0 ) stream_simple_ground_state_variable_component_decision_type.add(simple_ground_state_variable_component_decision_type147.getTree());
4627
					}
4628
					break;
4629
4630
				default :
4631
					break loop16;
4632
				}
4633
			}
4634
4635
			char_literal148=(Token)match(input,12,FOLLOW_12_in_simple_ground_state_variable_component_type1045); if (state.failed) return retval; 
4636
			if ( state.backtracking==0 ) stream_12.add(char_literal148);
4637
4638
			char_literal149=(Token)match(input,80,FOLLOW_80_in_simple_ground_state_variable_component_type1047); if (state.failed) return retval; 
4639
			if ( state.backtracking==0 ) stream_80.add(char_literal149);
4640
4641
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:99:172: ( simple_ground_state_variable_transition_constraint )*
4642
			loop17:
4643
			while (true) {
4644
				int alt17=2;
4645
				int LA17_0 = input.LA(1);
4646
				if ( (LA17_0==75) ) {
4647
					alt17=1;
4648
				}
4649
4650
				switch (alt17) {
4651
				case 1 :
4652
					// /home/alessandro/opt/antlr/ddl3/ddl3.g:99:173: simple_ground_state_variable_transition_constraint
4653
					{
4654
					pushFollow(FOLLOW_simple_ground_state_variable_transition_constraint_in_simple_ground_state_variable_component_type1050);
4655
					simple_ground_state_variable_transition_constraint150=simple_ground_state_variable_transition_constraint();
4656
					state._fsp--;
4657
					if (state.failed) return retval;
4658
					if ( state.backtracking==0 ) stream_simple_ground_state_variable_transition_constraint.add(simple_ground_state_variable_transition_constraint150.getTree());
4659
					}
4660
					break;
4661
4662
				default :
4663
					break loop17;
4664
				}
4665
			}
4666
4667
			char_literal151=(Token)match(input,81,FOLLOW_81_in_simple_ground_state_variable_component_type1054); if (state.failed) return retval; 
4668
			if ( state.backtracking==0 ) stream_81.add(char_literal151);
4669
4670
			// AST REWRITE
4671
			// elements: simple_ground_state_variable_component_decision_type, ID, simple_ground_state_variable_transition_constraint
4672
			// token labels: 
4673
			// rule labels: retval
4674
			// token list labels: 
4675
			// rule list labels: 
4676
			// wildcard labels: 
4677
			if ( state.backtracking==0 ) {
4678
			retval.tree = root_0;
4679
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null);
4680
4681
			root_0 = (Object)adaptor.nil();
4682
			// 99:230: -> ^( ID ( simple_ground_state_variable_component_decision_type )+ ( simple_ground_state_variable_transition_constraint )* )
4683
			{
4684
				// /home/alessandro/opt/antlr/ddl3/ddl3.g:99:232: ^( ID ( simple_ground_state_variable_component_decision_type )+ ( simple_ground_state_variable_transition_constraint )* )
4685
				{
4686
				Object root_1 = (Object)adaptor.nil();
4687
				root_1 = (Object)adaptor.becomeRoot(new DDLSimpleGroundStateVariableComponentType(stream_ID.nextToken()), root_1);
4688
				if ( !(stream_simple_ground_state_variable_component_decision_type.hasNext()) ) {
4689
					throw new RewriteEarlyExitException();
4690
				}
4691
				while ( stream_simple_ground_state_variable_component_decision_type.hasNext() ) {
4692
					adaptor.addChild(root_1, stream_simple_ground_state_variable_component_decision_type.nextTree());
4693
				}
4694
				stream_simple_ground_state_variable_component_decision_type.reset();
4695
4696
				// /home/alessandro/opt/antlr/ddl3/ddl3.g:99:336: ( simple_ground_state_variable_transition_constraint )*
4697
				while ( stream_simple_ground_state_variable_transition_constraint.hasNext() ) {
4698
					adaptor.addChild(root_1, stream_simple_ground_state_variable_transition_constraint.nextTree());
4699
				}
4700
				stream_simple_ground_state_variable_transition_constraint.reset();
4701
4702
				adaptor.addChild(root_0, root_1);
4703
				}
4704
4705
			}
4706
4707
4708
			retval.tree = root_0;
4709
			}
4710
4711
			}
4712
4713
			retval.stop = input.LT(-1);
4714
4715
			if ( state.backtracking==0 ) {
4716
			retval.tree = (Object)adaptor.rulePostProcessing(root_0);
4717
			adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
4718
			}
4719
		}
4720
		catch (RecognitionException re) {
4721
			reportError(re);
4722
			recover(input,re);
4723
			retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
4724
		}
4725
		finally {
4726
			// do for sure before leaving
4727
			if ( state.backtracking>0 ) { memoize(input, 19, simple_ground_state_variable_component_type_StartIndex); }
4728
4729
		}
4730
		return retval;
4731
	}
4732
	// $ANTLR end "simple_ground_state_variable_component_type"
4733