예제 #1
0
	private ForItem for_item()
	{
		EnterRule_for_item();
		EnterRule("for_item", 28);
		TraceIn("for_item", 28);
		ForItem value = default(ForItem);


		string a = default(string);
		Expr b = default(Expr);
		Expr c = default(Expr);
		Expr d = default(Expr);

		try { DebugEnterRule(GrammarFileName, "for_item");
		DebugLocation(379, 1);
		try
		{
			// SugarWalker.g:380:2: ( ^( For_Item_To a= ident b= expr c= expr (d= expr )? ) | ^( For_Item_Down_To a= ident b= expr c= expr (d= expr )? ) | ^( For_Item_Each a= ident b= expr ) | ^( For_Item_When b= expr ) )
			int alt51=4;
			try { DebugEnterDecision(51, false);
			switch (input.LA(1))
			{
			case For_Item_To:
				{
				alt51 = 1;
				}
				break;
			case For_Item_Down_To:
				{
				alt51 = 2;
				}
				break;
			case For_Item_Each:
				{
				alt51 = 3;
				}
				break;
			case For_Item_When:
				{
				alt51 = 4;
				}
				break;
			default:
				{
					NoViableAltException nvae = new NoViableAltException("", 51, 0, input);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(51); }
			switch (alt51)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarWalker.g:380:4: ^( For_Item_To a= ident b= expr c= expr (d= expr )? )
				{
				DebugLocation(380, 4);
				DebugLocation(380, 6);
				Match(input,For_Item_To,Follow._For_Item_To_in_for_item1470); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(380, 19);
				PushFollow(Follow._ident_in_for_item1474);
				a=ident();
				PopFollow();

				DebugLocation(380, 27);
				PushFollow(Follow._expr_in_for_item1478);
				b=expr();
				PopFollow();

				DebugLocation(380, 34);
				PushFollow(Follow._expr_in_for_item1482);
				c=expr();
				PopFollow();

				DebugLocation(380, 40);
				// SugarWalker.g:380:40: (d= expr )?
				int alt49=2;
				try { DebugEnterSubRule(49);
				try { DebugEnterDecision(49, false);
				int LA49_0 = input.LA(1);

				if (((LA49_0>=Expr_Access && LA49_0<=Expr_Tuple)||LA49_0==IDENT||LA49_0==Match_Tuple||LA49_0==NUMBER||LA49_0==STRING||LA49_0==75||LA49_0==78||LA49_0==82||LA49_0==85||LA49_0==89||LA49_0==95||LA49_0==98||LA49_0==102||LA49_0==104||LA49_0==110||LA49_0==113||LA49_0==117||LA49_0==150||LA49_0==DOUBLE))
				{
					alt49 = 1;
				}
				} finally { DebugExitDecision(49); }
				switch (alt49)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:380:41: d= expr
					{
					DebugLocation(380, 42);
					PushFollow(Follow._expr_in_for_item1487);
					d=expr();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(49); }


				Match(input, TokenTypes.Up, null); 

				DebugLocation(381, 2);

						value = new ForItemTo(a, b, c, d);
					

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarWalker.g:384:4: ^( For_Item_Down_To a= ident b= expr c= expr (d= expr )? )
				{
				DebugLocation(384, 4);
				DebugLocation(384, 6);
				Match(input,For_Item_Down_To,Follow._For_Item_Down_To_in_for_item1499); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(384, 24);
				PushFollow(Follow._ident_in_for_item1503);
				a=ident();
				PopFollow();

				DebugLocation(384, 32);
				PushFollow(Follow._expr_in_for_item1507);
				b=expr();
				PopFollow();

				DebugLocation(384, 39);
				PushFollow(Follow._expr_in_for_item1511);
				c=expr();
				PopFollow();

				DebugLocation(384, 45);
				// SugarWalker.g:384:45: (d= expr )?
				int alt50=2;
				try { DebugEnterSubRule(50);
				try { DebugEnterDecision(50, false);
				int LA50_0 = input.LA(1);

				if (((LA50_0>=Expr_Access && LA50_0<=Expr_Tuple)||LA50_0==IDENT||LA50_0==Match_Tuple||LA50_0==NUMBER||LA50_0==STRING||LA50_0==75||LA50_0==78||LA50_0==82||LA50_0==85||LA50_0==89||LA50_0==95||LA50_0==98||LA50_0==102||LA50_0==104||LA50_0==110||LA50_0==113||LA50_0==117||LA50_0==150||LA50_0==DOUBLE))
				{
					alt50 = 1;
				}
				} finally { DebugExitDecision(50); }
				switch (alt50)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:384:46: d= expr
					{
					DebugLocation(384, 47);
					PushFollow(Follow._expr_in_for_item1516);
					d=expr();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(50); }


				Match(input, TokenTypes.Up, null); 

				DebugLocation(385, 2);

						value = new ForItemDownTo(a, b, c, d);
					

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// SugarWalker.g:388:4: ^( For_Item_Each a= ident b= expr )
				{
				DebugLocation(388, 4);
				DebugLocation(388, 6);
				Match(input,For_Item_Each,Follow._For_Item_Each_in_for_item1528); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(388, 21);
				PushFollow(Follow._ident_in_for_item1532);
				a=ident();
				PopFollow();

				DebugLocation(388, 29);
				PushFollow(Follow._expr_in_for_item1536);
				b=expr();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(389, 2);

						value = new ForItemEach(a, b);
					

				}
				break;
			case 4:
				DebugEnterAlt(4);
				// SugarWalker.g:392:4: ^( For_Item_When b= expr )
				{
				DebugLocation(392, 4);
				DebugLocation(392, 6);
				Match(input,For_Item_When,Follow._For_Item_When_in_for_item1546); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(392, 21);
				PushFollow(Follow._expr_in_for_item1550);
				b=expr();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(393, 2);

						value = new ForItemWhen(b);
					

				}
				break;

			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("for_item", 28);
			LeaveRule("for_item", 28);
			LeaveRule_for_item();
		}
		DebugLocation(396, 1);
		} finally { DebugExitRule(GrammarFileName, "for_item"); }
		return value;

	}
예제 #2
0
	private ForItem for_item()
	{
		EnterRule_for_item();
		EnterRule("for_item", 37);
		TraceIn("for_item", 37);
		ForItem value = default(ForItem);


		string a = default(string);
		Expr b = default(Expr);
		Expr c = default(Expr);
		Expr d = default(Expr);

		try { DebugEnterRule(GrammarFileName, "for_item");
		DebugLocation(509, 1);
		try
		{
			// SugarWalker.g:510:2: ( ^( For_Item_To a= ident b= expr c= expr (d= expr )? ) | ^( For_Item_Til a= ident b= expr c= expr (d= expr )? ) | ^( For_Item_Down_To a= ident b= expr c= expr (d= expr )? ) | ^( For_Item_Each a= ident b= expr ) | ^( For_Item_Map a= ident b= expr ) | ^( For_Item_When b= expr ) )
			int alt64=6;
			try { DebugEnterDecision(64, false);
			switch (input.LA(1))
			{
			case For_Item_To:
				{
				alt64 = 1;
				}
				break;
			case For_Item_Til:
				{
				alt64 = 2;
				}
				break;
			case For_Item_Down_To:
				{
				alt64 = 3;
				}
				break;
			case For_Item_Each:
				{
				alt64 = 4;
				}
				break;
			case For_Item_Map:
				{
				alt64 = 5;
				}
				break;
			case For_Item_When:
				{
				alt64 = 6;
				}
				break;
			default:
				{
					NoViableAltException nvae = new NoViableAltException("", 64, 0, input);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(64); }
			switch (alt64)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarWalker.g:510:4: ^( For_Item_To a= ident b= expr c= expr (d= expr )? )
				{
				DebugLocation(510, 4);
				DebugLocation(510, 6);
				Match(input,For_Item_To,Follow._For_Item_To_in_for_item1902); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(510, 19);
				PushFollow(Follow._ident_in_for_item1906);
				a=ident();
				PopFollow();

				DebugLocation(510, 27);
				PushFollow(Follow._expr_in_for_item1910);
				b=expr();
				PopFollow();

				DebugLocation(510, 34);
				PushFollow(Follow._expr_in_for_item1914);
				c=expr();
				PopFollow();

				DebugLocation(510, 40);
				// SugarWalker.g:510:40: (d= expr )?
				int alt61=2;
				try { DebugEnterSubRule(61);
				try { DebugEnterDecision(61, false);
				int LA61_0 = input.LA(1);

				if (((LA61_0>=Expr_Access && LA61_0<=Expr_Alloc_Equal)||(LA61_0>=Expr_Bin && LA61_0<=Expr_Where)||LA61_0==IDENT||LA61_0==Match_Expr||LA61_0==Match_Tuple||LA61_0==NUMBER||LA61_0==STRING||LA61_0==89||LA61_0==92||LA61_0==96||LA61_0==99||LA61_0==104||LA61_0==110||LA61_0==113||LA61_0==118||LA61_0==121||LA61_0==128||LA61_0==131||LA61_0==135||LA61_0==183||LA61_0==DOUBLE))
				{
					alt61 = 1;
				}
				} finally { DebugExitDecision(61); }
				switch (alt61)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:510:41: d= expr
					{
					DebugLocation(510, 42);
					PushFollow(Follow._expr_in_for_item1919);
					d=expr();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(61); }


				Match(input, TokenTypes.Up, null); 

				DebugLocation(511, 2);

						value = new ForItemRange(a, b, c, d, ForItemRangeType.To);
					

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarWalker.g:514:4: ^( For_Item_Til a= ident b= expr c= expr (d= expr )? )
				{
				DebugLocation(514, 4);
				DebugLocation(514, 6);
				Match(input,For_Item_Til,Follow._For_Item_Til_in_for_item1931); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(514, 20);
				PushFollow(Follow._ident_in_for_item1935);
				a=ident();
				PopFollow();

				DebugLocation(514, 28);
				PushFollow(Follow._expr_in_for_item1939);
				b=expr();
				PopFollow();

				DebugLocation(514, 35);
				PushFollow(Follow._expr_in_for_item1943);
				c=expr();
				PopFollow();

				DebugLocation(514, 41);
				// SugarWalker.g:514:41: (d= expr )?
				int alt62=2;
				try { DebugEnterSubRule(62);
				try { DebugEnterDecision(62, false);
				int LA62_0 = input.LA(1);

				if (((LA62_0>=Expr_Access && LA62_0<=Expr_Alloc_Equal)||(LA62_0>=Expr_Bin && LA62_0<=Expr_Where)||LA62_0==IDENT||LA62_0==Match_Expr||LA62_0==Match_Tuple||LA62_0==NUMBER||LA62_0==STRING||LA62_0==89||LA62_0==92||LA62_0==96||LA62_0==99||LA62_0==104||LA62_0==110||LA62_0==113||LA62_0==118||LA62_0==121||LA62_0==128||LA62_0==131||LA62_0==135||LA62_0==183||LA62_0==DOUBLE))
				{
					alt62 = 1;
				}
				} finally { DebugExitDecision(62); }
				switch (alt62)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:514:42: d= expr
					{
					DebugLocation(514, 43);
					PushFollow(Follow._expr_in_for_item1948);
					d=expr();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(62); }


				Match(input, TokenTypes.Up, null); 

				DebugLocation(515, 2);

						value = new ForItemRange(a, b, c, d, ForItemRangeType.Til);
					

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// SugarWalker.g:518:4: ^( For_Item_Down_To a= ident b= expr c= expr (d= expr )? )
				{
				DebugLocation(518, 4);
				DebugLocation(518, 6);
				Match(input,For_Item_Down_To,Follow._For_Item_Down_To_in_for_item1960); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(518, 24);
				PushFollow(Follow._ident_in_for_item1964);
				a=ident();
				PopFollow();

				DebugLocation(518, 32);
				PushFollow(Follow._expr_in_for_item1968);
				b=expr();
				PopFollow();

				DebugLocation(518, 39);
				PushFollow(Follow._expr_in_for_item1972);
				c=expr();
				PopFollow();

				DebugLocation(518, 45);
				// SugarWalker.g:518:45: (d= expr )?
				int alt63=2;
				try { DebugEnterSubRule(63);
				try { DebugEnterDecision(63, false);
				int LA63_0 = input.LA(1);

				if (((LA63_0>=Expr_Access && LA63_0<=Expr_Alloc_Equal)||(LA63_0>=Expr_Bin && LA63_0<=Expr_Where)||LA63_0==IDENT||LA63_0==Match_Expr||LA63_0==Match_Tuple||LA63_0==NUMBER||LA63_0==STRING||LA63_0==89||LA63_0==92||LA63_0==96||LA63_0==99||LA63_0==104||LA63_0==110||LA63_0==113||LA63_0==118||LA63_0==121||LA63_0==128||LA63_0==131||LA63_0==135||LA63_0==183||LA63_0==DOUBLE))
				{
					alt63 = 1;
				}
				} finally { DebugExitDecision(63); }
				switch (alt63)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:518:46: d= expr
					{
					DebugLocation(518, 47);
					PushFollow(Follow._expr_in_for_item1977);
					d=expr();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(63); }


				Match(input, TokenTypes.Up, null); 

				DebugLocation(519, 2);

						value = new ForItemRange(a, b, c, d, ForItemRangeType.DownTo);
					

				}
				break;
			case 4:
				DebugEnterAlt(4);
				// SugarWalker.g:522:4: ^( For_Item_Each a= ident b= expr )
				{
				DebugLocation(522, 4);
				DebugLocation(522, 6);
				Match(input,For_Item_Each,Follow._For_Item_Each_in_for_item1989); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(522, 21);
				PushFollow(Follow._ident_in_for_item1993);
				a=ident();
				PopFollow();

				DebugLocation(522, 29);
				PushFollow(Follow._expr_in_for_item1997);
				b=expr();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(523, 2);

						value = new ForItemEach(a, b);
					

				}
				break;
			case 5:
				DebugEnterAlt(5);
				// SugarWalker.g:526:4: ^( For_Item_Map a= ident b= expr )
				{
				DebugLocation(526, 4);
				DebugLocation(526, 6);
				Match(input,For_Item_Map,Follow._For_Item_Map_in_for_item2007); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(526, 20);
				PushFollow(Follow._ident_in_for_item2011);
				a=ident();
				PopFollow();

				DebugLocation(526, 28);
				PushFollow(Follow._expr_in_for_item2015);
				b=expr();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(527, 2);

						value = new ForItemMap(a, b);
					

				}
				break;
			case 6:
				DebugEnterAlt(6);
				// SugarWalker.g:530:4: ^( For_Item_When b= expr )
				{
				DebugLocation(530, 4);
				DebugLocation(530, 6);
				Match(input,For_Item_When,Follow._For_Item_When_in_for_item2025); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(530, 21);
				PushFollow(Follow._expr_in_for_item2029);
				b=expr();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(531, 2);

						value = new ForItemWhen(b);
					

				}
				break;

			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("for_item", 37);
			LeaveRule("for_item", 37);
			LeaveRule_for_item();
		}
		DebugLocation(534, 1);
		} finally { DebugExitRule(GrammarFileName, "for_item"); }
		return value;

	}