Ejemplo n.º 1
0
 public override Template Visit(ExprLambda expr)
 {
     Template template = new Template("([<ref>](<args; separator=\",\">) { return <expr>; })");
     template.Add("args", expr.Args.Select(x => x.Accept(this)));
     template.Add("expr", expr.Expr.Accept(this));
     template.Add("ref", expr.IsRef ? "&" : "=");
     return template;
 }
Ejemplo n.º 2
0
 public override Template Visit(ExprLambda expr)
 {
     Template template = new Template("([<ref>](<args; separator=\",\">)<type> {\n    <block>\n})");
     template.Add("args", expr.Args.Select(x => x.Accept(this)));
     template.Add("block", expr.Block.Accept(this));
     template.Add("ref", expr.IsRef ? "&" : "=");
     if (expr.Type == null)
     {
         template.Add("type", "");
     }
     else
     {
         Template type = new Template(" -> <type>");
         type.Add("type", expr.Type.Accept(this));
         template.Add("type", type);
     }
     return template;
 }
Ejemplo n.º 3
0
	private ExprLambda lambda_expr()
	{
		EnterRule_lambda_expr();
		EnterRule("lambda_expr", 41);
		TraceIn("lambda_expr", 41);
		ExprLambda value = default(ExprLambda);


		List<ExprAlloc> b = default(List<ExprAlloc>);
		Expr a = default(Expr);

		try { DebugEnterRule(GrammarFileName, "lambda_expr");
		DebugLocation(492, 1);
		try
		{
			// SugarWalker.g:493:2: ( ^( Expr_Lambda '->' (b= func_args )? a= expr ) | ^( Expr_Lambda '=>' (b= func_args )? a= expr ) )
			int alt67=2;
			try { DebugEnterDecision(67, false);
			int LA67_0 = input.LA(1);

			if ((LA67_0==Expr_Lambda))
			{
				int LA67_1 = input.LA(2);

				if ((LA67_1==DOWN))
				{
					int LA67_2 = input.LA(3);

					if ((LA67_2==90))
					{
						alt67 = 1;
					}
					else if ((LA67_2==106))
					{
						alt67 = 2;
					}
					else
					{
						NoViableAltException nvae = new NoViableAltException("", 67, 2, input);
						DebugRecognitionException(nvae);
						throw nvae;
					}
				}
				else
				{
					NoViableAltException nvae = new NoViableAltException("", 67, 1, input);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}
			else
			{
				NoViableAltException nvae = new NoViableAltException("", 67, 0, input);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(67); }
			switch (alt67)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarWalker.g:493:4: ^( Expr_Lambda '->' (b= func_args )? a= expr )
				{
				DebugLocation(493, 4);
				DebugLocation(493, 6);
				Match(input,Expr_Lambda,Follow._Expr_Lambda_in_lambda_expr1971); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(493, 18);
				Match(input,90,Follow._90_in_lambda_expr1973); 
				DebugLocation(493, 23);
				// SugarWalker.g:493:23: (b= func_args )?
				int alt65=2;
				try { DebugEnterSubRule(65);
				try { DebugEnterDecision(65, false);
				int LA65_0 = input.LA(1);

				if ((LA65_0==Func_Args))
				{
					alt65 = 1;
				}
				} finally { DebugExitDecision(65); }
				switch (alt65)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:493:24: b= func_args
					{
					DebugLocation(493, 25);
					PushFollow(Follow._func_args_in_lambda_expr1978);
					b=func_args();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(65); }

				DebugLocation(493, 39);
				PushFollow(Follow._expr_in_lambda_expr1984);
				a=expr();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(494, 2);

						value = new ExprLambda(a, b, true);
					

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarWalker.g:497:4: ^( Expr_Lambda '=>' (b= func_args )? a= expr )
				{
				DebugLocation(497, 4);
				DebugLocation(497, 6);
				Match(input,Expr_Lambda,Follow._Expr_Lambda_in_lambda_expr1994); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(497, 18);
				Match(input,106,Follow._106_in_lambda_expr1996); 
				DebugLocation(497, 23);
				// SugarWalker.g:497:23: (b= func_args )?
				int alt66=2;
				try { DebugEnterSubRule(66);
				try { DebugEnterDecision(66, false);
				int LA66_0 = input.LA(1);

				if ((LA66_0==Func_Args))
				{
					alt66 = 1;
				}
				} finally { DebugExitDecision(66); }
				switch (alt66)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:497:24: b= func_args
					{
					DebugLocation(497, 25);
					PushFollow(Follow._func_args_in_lambda_expr2001);
					b=func_args();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(66); }

				DebugLocation(497, 39);
				PushFollow(Follow._expr_in_lambda_expr2007);
				a=expr();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(498, 2);

						value = new ExprLambda(a, b, false);
					

				}
				break;

			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("lambda_expr", 41);
			LeaveRule("lambda_expr", 41);
			LeaveRule_lambda_expr();
		}
		DebugLocation(501, 1);
		} finally { DebugExitRule(GrammarFileName, "lambda_expr"); }
		return value;

	}
Ejemplo n.º 4
0
 public abstract Template Visit(ExprLambda expr);
Ejemplo n.º 5
0
 public abstract Template Visit(ExprLambda expr);
Ejemplo n.º 6
0
	private Expr lambda_expr()
	{
		EnterRule_lambda_expr();
		EnterRule("lambda_expr", 50);
		TraceIn("lambda_expr", 50);
		Expr value = default(Expr);


		List<ExprAlloc> b = default(List<ExprAlloc>);
		SugarType t = default(SugarType);
		StmtBlock a = default(StmtBlock);

		try { DebugEnterRule(GrammarFileName, "lambda_expr");
		DebugLocation(640, 1);
		try
		{
			// SugarWalker.g:641:2: ( ^( Expr_Lambda '->' (b= func_args )? (t= type_name )? a= stmt_block ) | ^( Expr_Lambda '=>' (b= func_args )? (t= type_name )? a= stmt_block ) | ^( Expr_Lambda '-->' (b= func_args )? (t= type_name )? a= stmt_block ) | ^( Expr_Lambda '==>' (b= func_args )? (t= type_name )? a= stmt_block ) )
			int alt82=4;
			try { DebugEnterDecision(82, false);
			int LA82_0 = input.LA(1);

			if ((LA82_0==Expr_Lambda))
			{
				int LA82_1 = input.LA(2);

				if ((LA82_1==DOWN))
				{
					switch (input.LA(3))
					{
					case 105:
						{
						alt82 = 1;
						}
						break;
					case 124:
						{
						alt82 = 2;
						}
						break;
					case 103:
						{
						alt82 = 3;
						}
						break;
					case 123:
						{
						alt82 = 4;
						}
						break;
					default:
						{
							NoViableAltException nvae = new NoViableAltException("", 82, 2, input);
							DebugRecognitionException(nvae);
							throw nvae;
						}
					}

				}
				else
				{
					NoViableAltException nvae = new NoViableAltException("", 82, 1, input);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}
			else
			{
				NoViableAltException nvae = new NoViableAltException("", 82, 0, input);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(82); }
			switch (alt82)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarWalker.g:641:4: ^( Expr_Lambda '->' (b= func_args )? (t= type_name )? a= stmt_block )
				{
				DebugLocation(641, 4);
				DebugLocation(641, 6);
				Match(input,Expr_Lambda,Follow._Expr_Lambda_in_lambda_expr2444); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(641, 18);
				Match(input,105,Follow._105_in_lambda_expr2446); 
				DebugLocation(641, 23);
				// SugarWalker.g:641:23: (b= func_args )?
				int alt74=2;
				try { DebugEnterSubRule(74);
				try { DebugEnterDecision(74, false);
				int LA74_0 = input.LA(1);

				if ((LA74_0==Func_Args))
				{
					alt74 = 1;
				}
				} finally { DebugExitDecision(74); }
				switch (alt74)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:641:24: b= func_args
					{
					DebugLocation(641, 25);
					PushFollow(Follow._func_args_in_lambda_expr2451);
					b=func_args();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(74); }

				DebugLocation(641, 38);
				// SugarWalker.g:641:38: (t= type_name )?
				int alt75=2;
				try { DebugEnterSubRule(75);
				try { DebugEnterDecision(75, false);
				int LA75_0 = input.LA(1);

				if (((LA75_0>=Type_Array && LA75_0<=Type_Ident)||(LA75_0>=Type_Ref && LA75_0<=Type_Template)))
				{
					alt75 = 1;
				}
				} finally { DebugExitDecision(75); }
				switch (alt75)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:641:39: t= type_name
					{
					DebugLocation(641, 40);
					PushFollow(Follow._type_name_in_lambda_expr2458);
					t=type_name();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(75); }

				DebugLocation(641, 54);
				PushFollow(Follow._stmt_block_in_lambda_expr2464);
				a=stmt_block();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(642, 2);

						value = new ExprLambda(a, b, true, t);
					

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarWalker.g:645:4: ^( Expr_Lambda '=>' (b= func_args )? (t= type_name )? a= stmt_block )
				{
				DebugLocation(645, 4);
				DebugLocation(645, 6);
				Match(input,Expr_Lambda,Follow._Expr_Lambda_in_lambda_expr2474); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(645, 18);
				Match(input,124,Follow._124_in_lambda_expr2476); 
				DebugLocation(645, 23);
				// SugarWalker.g:645:23: (b= func_args )?
				int alt76=2;
				try { DebugEnterSubRule(76);
				try { DebugEnterDecision(76, false);
				int LA76_0 = input.LA(1);

				if ((LA76_0==Func_Args))
				{
					alt76 = 1;
				}
				} finally { DebugExitDecision(76); }
				switch (alt76)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:645:24: b= func_args
					{
					DebugLocation(645, 25);
					PushFollow(Follow._func_args_in_lambda_expr2481);
					b=func_args();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(76); }

				DebugLocation(645, 38);
				// SugarWalker.g:645:38: (t= type_name )?
				int alt77=2;
				try { DebugEnterSubRule(77);
				try { DebugEnterDecision(77, false);
				int LA77_0 = input.LA(1);

				if (((LA77_0>=Type_Array && LA77_0<=Type_Ident)||(LA77_0>=Type_Ref && LA77_0<=Type_Template)))
				{
					alt77 = 1;
				}
				} finally { DebugExitDecision(77); }
				switch (alt77)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:645:39: t= type_name
					{
					DebugLocation(645, 40);
					PushFollow(Follow._type_name_in_lambda_expr2488);
					t=type_name();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(77); }

				DebugLocation(645, 54);
				PushFollow(Follow._stmt_block_in_lambda_expr2494);
				a=stmt_block();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(646, 2);

						value = new ExprLambda(a, b, false, t);
					

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// SugarWalker.g:649:4: ^( Expr_Lambda '-->' (b= func_args )? (t= type_name )? a= stmt_block )
				{
				DebugLocation(649, 4);
				DebugLocation(649, 6);
				Match(input,Expr_Lambda,Follow._Expr_Lambda_in_lambda_expr2504); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(649, 18);
				Match(input,103,Follow._103_in_lambda_expr2506); 
				DebugLocation(649, 24);
				// SugarWalker.g:649:24: (b= func_args )?
				int alt78=2;
				try { DebugEnterSubRule(78);
				try { DebugEnterDecision(78, false);
				int LA78_0 = input.LA(1);

				if ((LA78_0==Func_Args))
				{
					alt78 = 1;
				}
				} finally { DebugExitDecision(78); }
				switch (alt78)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:649:25: b= func_args
					{
					DebugLocation(649, 26);
					PushFollow(Follow._func_args_in_lambda_expr2511);
					b=func_args();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(78); }

				DebugLocation(649, 39);
				// SugarWalker.g:649:39: (t= type_name )?
				int alt79=2;
				try { DebugEnterSubRule(79);
				try { DebugEnterDecision(79, false);
				int LA79_0 = input.LA(1);

				if (((LA79_0>=Type_Array && LA79_0<=Type_Ident)||(LA79_0>=Type_Ref && LA79_0<=Type_Template)))
				{
					alt79 = 1;
				}
				} finally { DebugExitDecision(79); }
				switch (alt79)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:649:40: t= type_name
					{
					DebugLocation(649, 41);
					PushFollow(Follow._type_name_in_lambda_expr2518);
					t=type_name();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(79); }

				DebugLocation(649, 55);
				PushFollow(Follow._stmt_block_in_lambda_expr2524);
				a=stmt_block();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(650, 2);

						value = new ExprCurryLambda(a, b, true, t);
					

				}
				break;
			case 4:
				DebugEnterAlt(4);
				// SugarWalker.g:653:4: ^( Expr_Lambda '==>' (b= func_args )? (t= type_name )? a= stmt_block )
				{
				DebugLocation(653, 4);
				DebugLocation(653, 6);
				Match(input,Expr_Lambda,Follow._Expr_Lambda_in_lambda_expr2534); 

				Match(input, TokenTypes.Down, null); 
				DebugLocation(653, 18);
				Match(input,123,Follow._123_in_lambda_expr2536); 
				DebugLocation(653, 24);
				// SugarWalker.g:653:24: (b= func_args )?
				int alt80=2;
				try { DebugEnterSubRule(80);
				try { DebugEnterDecision(80, false);
				int LA80_0 = input.LA(1);

				if ((LA80_0==Func_Args))
				{
					alt80 = 1;
				}
				} finally { DebugExitDecision(80); }
				switch (alt80)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:653:25: b= func_args
					{
					DebugLocation(653, 26);
					PushFollow(Follow._func_args_in_lambda_expr2541);
					b=func_args();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(80); }

				DebugLocation(653, 39);
				// SugarWalker.g:653:39: (t= type_name )?
				int alt81=2;
				try { DebugEnterSubRule(81);
				try { DebugEnterDecision(81, false);
				int LA81_0 = input.LA(1);

				if (((LA81_0>=Type_Array && LA81_0<=Type_Ident)||(LA81_0>=Type_Ref && LA81_0<=Type_Template)))
				{
					alt81 = 1;
				}
				} finally { DebugExitDecision(81); }
				switch (alt81)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:653:40: t= type_name
					{
					DebugLocation(653, 41);
					PushFollow(Follow._type_name_in_lambda_expr2548);
					t=type_name();
					PopFollow();


					}
					break;

				}
				} finally { DebugExitSubRule(81); }

				DebugLocation(653, 55);
				PushFollow(Follow._stmt_block_in_lambda_expr2554);
				a=stmt_block();
				PopFollow();


				Match(input, TokenTypes.Up, null); 

				DebugLocation(654, 2);

						value = new ExprCurryLambda(a, b, false, t);
					

				}
				break;

			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("lambda_expr", 50);
			LeaveRule("lambda_expr", 50);
			LeaveRule_lambda_expr();
		}
		DebugLocation(657, 1);
		} finally { DebugExitRule(GrammarFileName, "lambda_expr"); }
		return value;

	}