Code Duplication    Length = 86-89 lines in 2 locations

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

@@ 5809-5897 (lines=89) @@
5806
		RewriteRuleTokenStream stream_40=new RewriteRuleTokenStream(adaptor,"token 40");
5807
		RewriteRuleSubtreeStream stream_positive_number=new RewriteRuleSubtreeStream(adaptor,"rule positive_number");
5808
5809
		try {
5810
			if ( state.backtracking>0 && alreadyParsedRule(input, 28) ) { return retval; }
5811
5812
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:129:2: ( 'COMP_TYPE' 'ConsumableResource' ID '(' positive_number ',' positive_number ',' positive_number ')' -> ^( ID positive_number positive_number positive_number ) )
5813
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:129:4: 'COMP_TYPE' 'ConsumableResource' ID '(' positive_number ',' positive_number ',' positive_number ')'
5814
			{
5815
			string_literal197=(Token)match(input,35,FOLLOW_35_in_consumable_resource_component_type1334); if (state.failed) return retval; 
5816
			if ( state.backtracking==0 ) stream_35.add(string_literal197);
5817
5818
			string_literal198=(Token)match(input,40,FOLLOW_40_in_consumable_resource_component_type1336); if (state.failed) return retval; 
5819
			if ( state.backtracking==0 ) stream_40.add(string_literal198);
5820
5821
			ID199=(Token)match(input,ID,FOLLOW_ID_in_consumable_resource_component_type1338); if (state.failed) return retval; 
5822
			if ( state.backtracking==0 ) stream_ID.add(ID199);
5823
5824
			char_literal200=(Token)match(input,11,FOLLOW_11_in_consumable_resource_component_type1340); if (state.failed) return retval; 
5825
			if ( state.backtracking==0 ) stream_11.add(char_literal200);
5826
5827
			pushFollow(FOLLOW_positive_number_in_consumable_resource_component_type1342);
5828
			positive_number201=positive_number();
5829
			state._fsp--;
5830
			if (state.failed) return retval;
5831
			if ( state.backtracking==0 ) stream_positive_number.add(positive_number201.getTree());
5832
			char_literal202=(Token)match(input,15,FOLLOW_15_in_consumable_resource_component_type1344); if (state.failed) return retval; 
5833
			if ( state.backtracking==0 ) stream_15.add(char_literal202);
5834
5835
			pushFollow(FOLLOW_positive_number_in_consumable_resource_component_type1346);
5836
			positive_number203=positive_number();
5837
			state._fsp--;
5838
			if (state.failed) return retval;
5839
			if ( state.backtracking==0 ) stream_positive_number.add(positive_number203.getTree());
5840
			char_literal204=(Token)match(input,15,FOLLOW_15_in_consumable_resource_component_type1348); if (state.failed) return retval; 
5841
			if ( state.backtracking==0 ) stream_15.add(char_literal204);
5842
5843
			pushFollow(FOLLOW_positive_number_in_consumable_resource_component_type1350);
5844
			positive_number205=positive_number();
5845
			state._fsp--;
5846
			if (state.failed) return retval;
5847
			if ( state.backtracking==0 ) stream_positive_number.add(positive_number205.getTree());
5848
			char_literal206=(Token)match(input,12,FOLLOW_12_in_consumable_resource_component_type1352); if (state.failed) return retval; 
5849
			if ( state.backtracking==0 ) stream_12.add(char_literal206);
5850
5851
			// AST REWRITE
5852
			// elements: ID, positive_number, positive_number, positive_number
5853
			// token labels: 
5854
			// rule labels: retval
5855
			// token list labels: 
5856
			// rule list labels: 
5857
			// wildcard labels: 
5858
			if ( state.backtracking==0 ) {
5859
			retval.tree = root_0;
5860
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null);
5861
5862
			root_0 = (Object)adaptor.nil();
5863
			// 129:104: -> ^( ID positive_number positive_number positive_number )
5864
			{
5865
				// /home/alessandro/opt/antlr/ddl3/ddl3.g:129:106: ^( ID positive_number positive_number positive_number )
5866
				{
5867
				Object root_1 = (Object)adaptor.nil();
5868
				root_1 = (Object)adaptor.becomeRoot(new DDLConsumableResourceComponentType(stream_ID.nextToken()), root_1);
5869
				adaptor.addChild(root_1, stream_positive_number.nextTree());
5870
				adaptor.addChild(root_1, stream_positive_number.nextTree());
5871
				adaptor.addChild(root_1, stream_positive_number.nextTree());
5872
				adaptor.addChild(root_0, root_1);
5873
				}
5874
5875
			}
5876
5877
5878
			retval.tree = root_0;
5879
			}
5880
5881
			}
5882
5883
			retval.stop = input.LT(-1);
5884
5885
			if ( state.backtracking==0 ) {
5886
			retval.tree = (Object)adaptor.rulePostProcessing(root_0);
5887
			adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
5888
			}
5889
		}
5890
		catch (RecognitionException re) {
5891
			reportError(re);
5892
			recover(input,re);
5893
			retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
5894
		}
5895
		finally {
5896
			// do for sure before leaving
5897
			if ( state.backtracking>0 ) { memoize(input, 28, consumable_resource_component_type_StartIndex); }
5898
5899
		}
5900
		return retval;
@@ 876-961 (lines=86) @@
873
		RewriteRuleTokenStream stream_76=new RewriteRuleTokenStream(adaptor,"token 76");
874
		RewriteRuleSubtreeStream stream_number=new RewriteRuleSubtreeStream(adaptor,"rule number");
875
876
		try {
877
			if ( state.backtracking>0 && alreadyParsedRule(input, 6) ) { return retval; }
878
879
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:25:2: ( 'PAR_TYPE' 'NumericParameterType' ID '=' '[' number ',' number ']' ';' -> ^( ID number number ) )
880
			// /home/alessandro/opt/antlr/ddl3/ddl3.g:25:4: 'PAR_TYPE' 'NumericParameterType' ID '=' '[' number ',' number ']' ';'
881
			{
882
			string_literal23=(Token)match(input,60,FOLLOW_60_in_numeric_parameter_type182); if (state.failed) return retval; 
883
			if ( state.backtracking==0 ) stream_60.add(string_literal23);
884
885
			string_literal24=(Token)match(input,57,FOLLOW_57_in_numeric_parameter_type184); if (state.failed) return retval; 
886
			if ( state.backtracking==0 ) stream_57.add(string_literal24);
887
888
			ID25=(Token)match(input,ID,FOLLOW_ID_in_numeric_parameter_type186); if (state.failed) return retval; 
889
			if ( state.backtracking==0 ) stream_ID.add(ID25);
890
891
			char_literal26=(Token)match(input,22,FOLLOW_22_in_numeric_parameter_type188); if (state.failed) return retval; 
892
			if ( state.backtracking==0 ) stream_22.add(char_literal26);
893
894
			char_literal27=(Token)match(input,76,FOLLOW_76_in_numeric_parameter_type190); if (state.failed) return retval; 
895
			if ( state.backtracking==0 ) stream_76.add(char_literal27);
896
897
			pushFollow(FOLLOW_number_in_numeric_parameter_type192);
898
			number28=number();
899
			state._fsp--;
900
			if (state.failed) return retval;
901
			if ( state.backtracking==0 ) stream_number.add(number28.getTree());
902
			char_literal29=(Token)match(input,15,FOLLOW_15_in_numeric_parameter_type194); if (state.failed) return retval; 
903
			if ( state.backtracking==0 ) stream_15.add(char_literal29);
904
905
			pushFollow(FOLLOW_number_in_numeric_parameter_type196);
906
			number30=number();
907
			state._fsp--;
908
			if (state.failed) return retval;
909
			if ( state.backtracking==0 ) stream_number.add(number30.getTree());
910
			char_literal31=(Token)match(input,77,FOLLOW_77_in_numeric_parameter_type198); if (state.failed) return retval; 
911
			if ( state.backtracking==0 ) stream_77.add(char_literal31);
912
913
			char_literal32=(Token)match(input,19,FOLLOW_19_in_numeric_parameter_type200); if (state.failed) return retval; 
914
			if ( state.backtracking==0 ) stream_19.add(char_literal32);
915
916
			// AST REWRITE
917
			// elements: number, ID, number
918
			// token labels: 
919
			// rule labels: retval
920
			// token list labels: 
921
			// rule list labels: 
922
			// wildcard labels: 
923
			if ( state.backtracking==0 ) {
924
			retval.tree = root_0;
925
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null);
926
927
			root_0 = (Object)adaptor.nil();
928
			// 25:75: -> ^( ID number number )
929
			{
930
				// /home/alessandro/opt/antlr/ddl3/ddl3.g:25:77: ^( ID number number )
931
				{
932
				Object root_1 = (Object)adaptor.nil();
933
				root_1 = (Object)adaptor.becomeRoot(new DDLNumericParameterType(stream_ID.nextToken()), root_1);
934
				adaptor.addChild(root_1, stream_number.nextTree());
935
				adaptor.addChild(root_1, stream_number.nextTree());
936
				adaptor.addChild(root_0, root_1);
937
				}
938
939
			}
940
941
942
			retval.tree = root_0;
943
			}
944
945
			}
946
947
			retval.stop = input.LT(-1);
948
949
			if ( state.backtracking==0 ) {
950
			retval.tree = (Object)adaptor.rulePostProcessing(root_0);
951
			adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
952
			}
953
		}
954
		catch (RecognitionException re) {
955
			reportError(re);
956
			recover(input,re);
957
			retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
958
		}
959
		finally {
960
			// do for sure before leaving
961
			if ( state.backtracking>0 ) { memoize(input, 6, numeric_parameter_type_StartIndex); }
962
963
		}
964
		return retval;