public static List<FunctionArgument> GenerateArguments(MethodBase method)
 {
     if (ArgumentCache.ContainsKey(method)) {
         return ArgumentCache[method];
     }
     var args = new List<FunctionArgument>();
     method.GetParameters().ToList().ForEach(p => {
         var arg = new FunctionArgument(p.Name);
         if (p.GetCustomAttributes(typeof (ParamArrayAttribute), false).Any()) {
             arg.IsVarArg = true;
         }
         if (p.DefaultValue != null && p.DefaultValue.GetType() != typeof (DBNull)) {
             arg.HasDefault = true;
             arg.DefaultValue = Expression.Constant(p.DefaultValue);
         }
         args.Add(arg);
     });
     ArgumentCache[method] = args;
     return args;
 }
 public void TestVarArgAnonFunc()
 {
     var varArg = new FunctionArgument("p");
     varArg.IsVarArg = true;
     SilverFunction expect = F("__anonFunc0", A(new FunctionArgument("x"), varArg), "for(pp in p) { i * pp; };");
     dynamic real = CompileAndExecute("^(x,*p) { for(pp in p) { i * pp; }; };");
     Assert.That(real, Is.Function(expect));
 }
Example #3
0
	private FunctionArgument end_block_arg()
	{
		EnterRule_end_block_arg();
		EnterRule("end_block_arg", 59);
		TraceIn("end_block_arg", 59);
		FunctionArgument result = default(FunctionArgument);


		IToken bl = default(IToken);

		try { DebugEnterRule(GrammarFileName, "end_block_arg");
		DebugLocation(502, 1);
		try
		{
			// SilverParser.g3:503:2: ( ( COMMA BITWISEAND bl= IDENTIFIER ) )
			DebugEnterAlt(1);
			// SilverParser.g3:503:4: ( COMMA BITWISEAND bl= IDENTIFIER )
			{
			DebugLocation(503, 4);
			// SilverParser.g3:503:4: ( COMMA BITWISEAND bl= IDENTIFIER )
			DebugEnterAlt(1);
			// SilverParser.g3:503:5: COMMA BITWISEAND bl= IDENTIFIER
			{
			DebugLocation(503, 5);
			Match(input,COMMA,Follow._COMMA_in_end_block_arg2958); if (state.failed) return result;
			DebugLocation(503, 11);
			Match(input,BITWISEAND,Follow._BITWISEAND_in_end_block_arg2960); if (state.failed) return result;
			DebugLocation(503, 24);
			bl=(IToken)Match(input,IDENTIFIER,Follow._IDENTIFIER_in_end_block_arg2964); if (state.failed) return result;
			DebugLocation(503, 36);
			if (state.backtracking == 0)
			{
				 FunctionArgument arg = new FunctionArgument(S<string>(bl).Value); arg.IsFunction = true; result = arg; 
			}

			}


			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("end_block_arg", 59);
			LeaveRule("end_block_arg", 59);
			LeaveRule_end_block_arg();
		}
		DebugLocation(504, 1);
		} finally { DebugExitRule(GrammarFileName, "end_block_arg"); }
		return result;

	}
Example #4
0
	private FunctionArgument next_arg()
	{
		EnterRule_next_arg();
		EnterRule("next_arg", 60);
		TraceIn("next_arg", 60);
		FunctionArgument result = default(FunctionArgument);


		IToken i = default(IToken);
		IToken a = default(IToken);
		Expression arg92 = default(Expression);

		 bool hasDefault = false; Expression @default = null; 
		try { DebugEnterRule(GrammarFileName, "next_arg");
		DebugLocation(506, 1);
		try
		{
			// SilverParser.g3:508:2: ( COMMA ( COLON )? i= IDENTIFIER (a= ASSIGN arg )? )
			DebugEnterAlt(1);
			// SilverParser.g3:508:4: COMMA ( COLON )? i= IDENTIFIER (a= ASSIGN arg )?
			{
			DebugLocation(508, 4);
			Match(input,COMMA,Follow._COMMA_in_next_arg2989); if (state.failed) return result;
			DebugLocation(508, 10);
			// SilverParser.g3:508:10: ( COLON )?
			int alt75=2;
			try { DebugEnterSubRule(75);
			try { DebugEnterDecision(75, false);
			int LA75_1 = input.LA(1);

			if ((LA75_1==COLON))
			{
				alt75 = 1;
			}
			} finally { DebugExitDecision(75); }
			switch (alt75)
			{
			case 1:
				DebugEnterAlt(1);
				// SilverParser.g3:508:11: COLON
				{
				DebugLocation(508, 11);
				Match(input,COLON,Follow._COLON_in_next_arg2992); if (state.failed) return result;
				DebugLocation(508, 17);
				if (state.backtracking == 0)
				{
					 IsLiteral = true; 
				}

				}
				break;

			}
			} finally { DebugExitSubRule(75); }

			DebugLocation(508, 42);
			i=(IToken)Match(input,IDENTIFIER,Follow._IDENTIFIER_in_next_arg3000); if (state.failed) return result;
			DebugLocation(508, 54);
			// SilverParser.g3:508:54: (a= ASSIGN arg )?
			int alt76=2;
			try { DebugEnterSubRule(76);
			try { DebugEnterDecision(76, false);
			int LA76_1 = input.LA(1);

			if ((LA76_1==ASSIGN))
			{
				alt76 = 1;
			}
			} finally { DebugExitDecision(76); }
			switch (alt76)
			{
			case 1:
				DebugEnterAlt(1);
				// SilverParser.g3:508:55: a= ASSIGN arg
				{
				DebugLocation(508, 56);
				a=(IToken)Match(input,ASSIGN,Follow._ASSIGN_in_next_arg3005); if (state.failed) return result;
				DebugLocation(508, 64);
				PushFollow(Follow._arg_in_next_arg3007);
				arg92=arg();
				PopFollow();
				if (state.failed) return result;
				DebugLocation(508, 68);
				if (state.backtracking == 0)
				{
					 if(IsLiteral) { 
						  	throw BuildException("Error: Cannot assign default value to literal argument", S<string>(a), 10000, Severity.Error);
						  }
						  hasDefault = true; @default = arg92; 
				}

				}
				break;

			}
			} finally { DebugExitSubRule(76); }

			DebugLocation(512, 4);
			if (state.backtracking == 0)
			{
				 FunctionArgument arg = new FunctionArgument(S<string>(i).Value);
					    if(hasDefault) {
					    	arg.HasDefault = true;
					    	arg.DefaultValue = @default;
					    	hasDefault = false;
					    }
					    if(IsLiteral) {
					    	arg.IsLiteral = true;
					    	IsLiteral = false;
					    }
					    result = arg;
					  
			}

			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("next_arg", 60);
			LeaveRule("next_arg", 60);
			LeaveRule_next_arg();
		}
		DebugLocation(524, 1);
		} finally { DebugExitRule(GrammarFileName, "next_arg"); }
		return result;

	}
Example #5
0
	private FunctionArgument end_var_arg()
	{
		EnterRule_end_var_arg();
		EnterRule("end_var_arg", 58);
		TraceIn("end_var_arg", 58);
		FunctionArgument result = default(FunctionArgument);


		IToken va = default(IToken);

		try { DebugEnterRule(GrammarFileName, "end_var_arg");
		DebugLocation(498, 1);
		try
		{
			// SilverParser.g3:499:2: ( ( COMMA MULTIPLY va= IDENTIFIER ) )
			DebugEnterAlt(1);
			// SilverParser.g3:499:4: ( COMMA MULTIPLY va= IDENTIFIER )
			{
			DebugLocation(499, 4);
			// SilverParser.g3:499:4: ( COMMA MULTIPLY va= IDENTIFIER )
			DebugEnterAlt(1);
			// SilverParser.g3:499:5: COMMA MULTIPLY va= IDENTIFIER
			{
			DebugLocation(499, 5);
			Match(input,COMMA,Follow._COMMA_in_end_var_arg2932); if (state.failed) return result;
			DebugLocation(499, 11);
			Match(input,MULTIPLY,Follow._MULTIPLY_in_end_var_arg2934); if (state.failed) return result;
			DebugLocation(499, 22);
			va=(IToken)Match(input,IDENTIFIER,Follow._IDENTIFIER_in_end_var_arg2938); if (state.failed) return result;
			DebugLocation(499, 34);
			if (state.backtracking == 0)
			{
				 FunctionArgument arg = new FunctionArgument(S<string>(va).Value); arg.IsVarArg = true; result = arg; 
			}

			}


			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("end_var_arg", 58);
			LeaveRule("end_var_arg", 58);
			LeaveRule_end_var_arg();
		}
		DebugLocation(500, 1);
		} finally { DebugExitRule(GrammarFileName, "end_var_arg"); }
		return result;

	}
Example #6
0
	private FunctionArgument first_block_arg()
	{
		EnterRule_first_block_arg();
		EnterRule("first_block_arg", 57);
		TraceIn("first_block_arg", 57);
		FunctionArgument result = default(FunctionArgument);


		IToken bl = default(IToken);

		try { DebugEnterRule(GrammarFileName, "first_block_arg");
		DebugLocation(494, 1);
		try
		{
			// SilverParser.g3:495:2: ( ( BITWISEAND bl= IDENTIFIER ) )
			DebugEnterAlt(1);
			// SilverParser.g3:495:4: ( BITWISEAND bl= IDENTIFIER )
			{
			DebugLocation(495, 4);
			// SilverParser.g3:495:4: ( BITWISEAND bl= IDENTIFIER )
			DebugEnterAlt(1);
			// SilverParser.g3:495:5: BITWISEAND bl= IDENTIFIER
			{
			DebugLocation(495, 5);
			Match(input,BITWISEAND,Follow._BITWISEAND_in_first_block_arg2908); if (state.failed) return result;
			DebugLocation(495, 18);
			bl=(IToken)Match(input,IDENTIFIER,Follow._IDENTIFIER_in_first_block_arg2912); if (state.failed) return result;
			DebugLocation(495, 30);
			if (state.backtracking == 0)
			{
				 FunctionArgument arg = new FunctionArgument(S<string>(bl).Value); arg.IsFunction = true; result = arg; 
			}

			}


			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("first_block_arg", 57);
			LeaveRule("first_block_arg", 57);
			LeaveRule_first_block_arg();
		}
		DebugLocation(496, 1);
		} finally { DebugExitRule(GrammarFileName, "first_block_arg"); }
		return result;

	}
Example #7
0
	private FunctionArgument first_var_arg()
	{
		EnterRule_first_var_arg();
		EnterRule("first_var_arg", 56);
		TraceIn("first_var_arg", 56);
		FunctionArgument result = default(FunctionArgument);


		IToken va = default(IToken);

		try { DebugEnterRule(GrammarFileName, "first_var_arg");
		DebugLocation(490, 1);
		try
		{
			// SilverParser.g3:491:2: ( ( MULTIPLY va= IDENTIFIER ) )
			DebugEnterAlt(1);
			// SilverParser.g3:491:4: ( MULTIPLY va= IDENTIFIER )
			{
			DebugLocation(491, 4);
			// SilverParser.g3:491:4: ( MULTIPLY va= IDENTIFIER )
			DebugEnterAlt(1);
			// SilverParser.g3:491:5: MULTIPLY va= IDENTIFIER
			{
			DebugLocation(491, 5);
			Match(input,MULTIPLY,Follow._MULTIPLY_in_first_var_arg2884); if (state.failed) return result;
			DebugLocation(491, 16);
			va=(IToken)Match(input,IDENTIFIER,Follow._IDENTIFIER_in_first_var_arg2888); if (state.failed) return result;
			DebugLocation(491, 28);
			if (state.backtracking == 0)
			{
				 FunctionArgument arg = new FunctionArgument(S<string>(va).Value); arg.IsVarArg = true; result = arg; 
			}

			}


			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("first_var_arg", 56);
			LeaveRule("first_var_arg", 56);
			LeaveRule_first_var_arg();
		}
		DebugLocation(492, 1);
		} finally { DebugExitRule(GrammarFileName, "first_var_arg"); }
		return result;

	}
Example #8
0
	private FunctionArgument first_arg()
	{
		EnterRule_first_arg();
		EnterRule("first_arg", 55);
		TraceIn("first_arg", 55);
		FunctionArgument result = default(FunctionArgument);


		IToken i = default(IToken);
		IToken a = default(IToken);
		Expression arg91 = default(Expression);

		 bool hasDefault = false; Expression @default = null; 
		try { DebugEnterRule(GrammarFileName, "first_arg");
		DebugLocation(470, 1);
		try
		{
			// SilverParser.g3:472:2: ( ( COLON )? i= IDENTIFIER (a= ASSIGN arg )? )
			DebugEnterAlt(1);
			// SilverParser.g3:472:4: ( COLON )? i= IDENTIFIER (a= ASSIGN arg )?
			{
			DebugLocation(472, 4);
			// SilverParser.g3:472:4: ( COLON )?
			int alt73=2;
			try { DebugEnterSubRule(73);
			try { DebugEnterDecision(73, false);
			int LA73_1 = input.LA(1);

			if ((LA73_1==COLON))
			{
				alt73 = 1;
			}
			} finally { DebugExitDecision(73); }
			switch (alt73)
			{
			case 1:
				DebugEnterAlt(1);
				// SilverParser.g3:472:5: COLON
				{
				DebugLocation(472, 5);
				Match(input,COLON,Follow._COLON_in_first_arg2844); if (state.failed) return result;
				DebugLocation(472, 11);
				if (state.backtracking == 0)
				{
					 IsLiteral = true; 
				}

				}
				break;

			}
			} finally { DebugExitSubRule(73); }

			DebugLocation(472, 36);
			i=(IToken)Match(input,IDENTIFIER,Follow._IDENTIFIER_in_first_arg2852); if (state.failed) return result;
			DebugLocation(472, 48);
			// SilverParser.g3:472:48: (a= ASSIGN arg )?
			int alt74=2;
			try { DebugEnterSubRule(74);
			try { DebugEnterDecision(74, false);
			int LA74_1 = input.LA(1);

			if ((LA74_1==ASSIGN))
			{
				alt74 = 1;
			}
			} finally { DebugExitDecision(74); }
			switch (alt74)
			{
			case 1:
				DebugEnterAlt(1);
				// SilverParser.g3:472:49: a= ASSIGN arg
				{
				DebugLocation(472, 50);
				a=(IToken)Match(input,ASSIGN,Follow._ASSIGN_in_first_arg2857); if (state.failed) return result;
				DebugLocation(472, 58);
				PushFollow(Follow._arg_in_first_arg2859);
				arg91=arg();
				PopFollow();
				if (state.failed) return result;
				DebugLocation(472, 62);
				if (state.backtracking == 0)
				{
					 if(IsLiteral) { 
						  	throw BuildException("Error: Cannot assign default value to literal argument", S<string>(a), 10000, Severity.Error);
						  }
						  hasDefault = true; @default = arg91; 
				}

				}
				break;

			}
			} finally { DebugExitSubRule(74); }

			DebugLocation(476, 4);
			if (state.backtracking == 0)
			{
				 FunctionArgument arg = new FunctionArgument(S<string>(i).Value);
					    if(hasDefault) {
					    	arg.HasDefault = true;
					    	arg.DefaultValue = @default;
					    	hasDefault = false;
					    }
					    if(IsLiteral) {
					    	arg.IsLiteral = true;
					    	IsLiteral = false;
					    }
					    result = arg;
					  
			}

			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("first_arg", 55);
			LeaveRule("first_arg", 55);
			LeaveRule_first_arg();
		}
		DebugLocation(488, 1);
		} finally { DebugExitRule(GrammarFileName, "first_arg"); }
		return result;

	}
Example #9
0
	private Expression primary()
	{
		EnterRule_primary();
		EnterRule("primary", 41);
		TraceIn("primary", 41);
		Expression result = default(Expression);


		List<FunctionArgument> funcargs = default(List<FunctionArgument>);
		Expression fy = default(Expression);
		List<FunctionArgument> accessargs = default(List<FunctionArgument>);
		Expression hv = default(Expression);
		List<FunctionArgument> cmdargs = default(List<FunctionArgument>);
		Expression cy = default(Expression);
		Expression dcy = default(Expression);
		Expression literal68 = default(Expression);
		Expression lvalue_instance_ref69 = default(Expression);
		Expression lvalue_method_change70 = default(Expression);
		Expression lvalue71 = default(Expression);
		Expression array72 = default(Expression);
		Expression hash73 = default(Expression);
		Expression anonymous_function74 = default(Expression);
		Expression anonymous_class_declaration75 = default(Expression);
		Expression single_hash_key76 = default(Expression);

		 var args = new List<FunctionArgument>(); 
		try { DebugEnterRule(GrammarFileName, "primary");
		DebugLocation(371, 1);
		try
		{
			// SilverParser.g3:373:2: ( ( literal | lvalue_instance_ref | lvalue_method_change | lvalue | array | hash | anonymous_function | anonymous_class_declaration ) ( ( ( LPAREN (funcargs= call_args )? RPAREN (fy= yield_block )? ) | ( LBRACKET accessargs= call_args RBRACKET ) )* | ( ( ( single_hash_key HASH hv= arg ) |cmdargs= call_args ) (cy= yield_block |dcy= do_yield_block )? ) ) )
			DebugEnterAlt(1);
			// SilverParser.g3:373:4: ( literal | lvalue_instance_ref | lvalue_method_change | lvalue | array | hash | anonymous_function | anonymous_class_declaration ) ( ( ( LPAREN (funcargs= call_args )? RPAREN (fy= yield_block )? ) | ( LBRACKET accessargs= call_args RBRACKET ) )* | ( ( ( single_hash_key HASH hv= arg ) |cmdargs= call_args ) (cy= yield_block |dcy= do_yield_block )? ) )
			{
			DebugLocation(373, 4);
			// SilverParser.g3:373:4: ( literal | lvalue_instance_ref | lvalue_method_change | lvalue | array | hash | anonymous_function | anonymous_class_declaration )
			int alt51=8;
			try { DebugEnterSubRule(51);
			try { DebugEnterDecision(51, false);
			switch (input.LA(1))
			{
			case COLON:
			case FALSE:
			case INTEGER:
			case NIL:
			case NUMBER:
			case REGEX:
			case STRING:
			case TRUE:
				{
				alt51 = 1;
				}
				break;
			case IDENTIFIER:
				{
				int LA51_2 = input.LA(2);

				if ((LA51_2==DOT))
				{
					int LA51_3 = input.LA(3);

					if ((LA51_3==REMOVE||LA51_3==UNDEF))
					{
						alt51 = 3;
					}
					else if ((LA51_3==BITWISEAND||(LA51_3>=BITWISEOR && LA51_3<=BRACKETSASSIGN)||LA51_3==CLASS||LA51_3==COMPARE||LA51_3==DCOLON||LA51_3==DIVIDE||(LA51_3>=EQUAL && LA51_3<=ERANGE)||LA51_3==EXPONENT||(LA51_3>=GREATERTHAN && LA51_3<=GREATERTHANEQUAL)||LA51_3==IDENTIFIER||LA51_3==IRANGE||(LA51_3>=LESSTHAN && LA51_3<=LESSTHANEQUAL)||LA51_3==MINUS||LA51_3==MODULO||LA51_3==MULTIPLY||LA51_3==OP||LA51_3==PLUS||LA51_3==REGEXMATCH||(LA51_3>=SHIFTLEFT && LA51_3<=SHIFTRIGHT)||LA51_3==UMINUS||(LA51_3>=UPLUS && LA51_3<=WHENCOMP)))
					{
						alt51 = 2;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return result;}
						NoViableAltException nvae = new NoViableAltException("", 51, 10, input, 3);
						DebugRecognitionException(nvae);
						throw nvae;
					}
				}
				else if ((LA51_2==EOF||LA51_2==BACKWARDPIPE||(LA51_2>=BITWISEAND && LA51_2<=BRACKETS)||(LA51_2>=COLON && LA51_2<=COMPARE)||LA51_2==CONTEXT||(LA51_2>=DIVIDE && LA51_2<=DO)||LA51_2==EQUAL||(LA51_2>=EXPONENT && LA51_2<=FALSE)||(LA51_2>=FORWARDPIPE && LA51_2<=IF)||LA51_2==INTEGER||(LA51_2>=LBRACE && LA51_2<=LOGICALXOR)||(LA51_2>=LPAREN && LA51_2<=MINUS)||LA51_2==MODULO||(LA51_2>=MULTIPLY && LA51_2<=OP)||(LA51_2>=PLUS && LA51_2<=REMOVE)||(LA51_2>=RPAREN && LA51_2<=SEMICOLON)||(LA51_2>=SHIFTLEFT && LA51_2<=SHIFTRIGHT)||LA51_2==STRING||LA51_2==SUPER||LA51_2==SWITCHOP||(LA51_2>=TRUE && LA51_2<=TYPEOF)||(LA51_2>=UNDEF && LA51_2<=UNTIL)||LA51_2==WHILE||LA51_2==YIELD))
				{
					alt51 = 4;
				}
				else
				{
					if (state.backtracking>0) {state.failed=true; return result;}
					NoViableAltException nvae = new NoViableAltException("", 51, 2, input, 2);
					DebugRecognitionException(nvae);
					throw nvae;
				}
				}
				break;
			case SELF:
				{
				int LA51_2 = input.LA(2);

				if ((LA51_2==DOT))
				{
					int LA51_3 = input.LA(3);

					if ((LA51_3==REMOVE||LA51_3==UNDEF))
					{
						alt51 = 3;
					}
					else if ((LA51_3==BITWISEAND||(LA51_3>=BITWISEOR && LA51_3<=BRACKETSASSIGN)||LA51_3==CLASS||LA51_3==COMPARE||LA51_3==DCOLON||LA51_3==DIVIDE||(LA51_3>=EQUAL && LA51_3<=ERANGE)||LA51_3==EXPONENT||(LA51_3>=GREATERTHAN && LA51_3<=GREATERTHANEQUAL)||LA51_3==IDENTIFIER||LA51_3==IRANGE||(LA51_3>=LESSTHAN && LA51_3<=LESSTHANEQUAL)||LA51_3==MINUS||LA51_3==MODULO||LA51_3==MULTIPLY||LA51_3==OP||LA51_3==PLUS||LA51_3==REGEXMATCH||(LA51_3>=SHIFTLEFT && LA51_3<=SHIFTRIGHT)||LA51_3==UMINUS||(LA51_3>=UPLUS && LA51_3<=WHENCOMP)))
					{
						alt51 = 2;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return result;}
						NoViableAltException nvae = new NoViableAltException("", 51, 10, input, 3);
						DebugRecognitionException(nvae);
						throw nvae;
					}
				}
				else if ((LA51_2==EOF||LA51_2==BACKWARDPIPE||(LA51_2>=BITWISEAND && LA51_2<=BRACKETS)||(LA51_2>=COLON && LA51_2<=COMPARE)||LA51_2==CONTEXT||(LA51_2>=DIVIDE && LA51_2<=DO)||LA51_2==EQUAL||(LA51_2>=EXPONENT && LA51_2<=FALSE)||(LA51_2>=FORWARDPIPE && LA51_2<=IF)||LA51_2==INTEGER||(LA51_2>=LBRACE && LA51_2<=LOGICALXOR)||(LA51_2>=LPAREN && LA51_2<=MINUS)||LA51_2==MODULO||(LA51_2>=MULTIPLY && LA51_2<=OP)||(LA51_2>=PLUS && LA51_2<=REMOVE)||(LA51_2>=RPAREN && LA51_2<=SEMICOLON)||(LA51_2>=SHIFTLEFT && LA51_2<=SHIFTRIGHT)||LA51_2==STRING||LA51_2==SUPER||LA51_2==SWITCHOP||(LA51_2>=TRUE && LA51_2<=TYPEOF)||(LA51_2>=UNDEF && LA51_2<=UNTIL)||LA51_2==WHILE||LA51_2==YIELD))
				{
					alt51 = 4;
				}
				else
				{
					if (state.backtracking>0) {state.failed=true; return result;}
					NoViableAltException nvae = new NoViableAltException("", 51, 3, input, 2);
					DebugRecognitionException(nvae);
					throw nvae;
				}
				}
				break;
			case SUPER:
				{
				int LA51_2 = input.LA(2);

				if ((LA51_2==DOT))
				{
					int LA51_3 = input.LA(3);

					if ((LA51_3==REMOVE||LA51_3==UNDEF))
					{
						alt51 = 3;
					}
					else if ((LA51_3==BITWISEAND||(LA51_3>=BITWISEOR && LA51_3<=BRACKETSASSIGN)||LA51_3==CLASS||LA51_3==COMPARE||LA51_3==DCOLON||LA51_3==DIVIDE||(LA51_3>=EQUAL && LA51_3<=ERANGE)||LA51_3==EXPONENT||(LA51_3>=GREATERTHAN && LA51_3<=GREATERTHANEQUAL)||LA51_3==IDENTIFIER||LA51_3==IRANGE||(LA51_3>=LESSTHAN && LA51_3<=LESSTHANEQUAL)||LA51_3==MINUS||LA51_3==MODULO||LA51_3==MULTIPLY||LA51_3==OP||LA51_3==PLUS||LA51_3==REGEXMATCH||(LA51_3>=SHIFTLEFT && LA51_3<=SHIFTRIGHT)||LA51_3==UMINUS||(LA51_3>=UPLUS && LA51_3<=WHENCOMP)))
					{
						alt51 = 2;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return result;}
						NoViableAltException nvae = new NoViableAltException("", 51, 10, input, 3);
						DebugRecognitionException(nvae);
						throw nvae;
					}
				}
				else if ((LA51_2==EOF||LA51_2==BACKWARDPIPE||(LA51_2>=BITWISEAND && LA51_2<=BRACKETS)||(LA51_2>=COLON && LA51_2<=COMPARE)||LA51_2==CONTEXT||(LA51_2>=DIVIDE && LA51_2<=DO)||LA51_2==EQUAL||(LA51_2>=EXPONENT && LA51_2<=FALSE)||(LA51_2>=FORWARDPIPE && LA51_2<=IF)||LA51_2==INTEGER||(LA51_2>=LBRACE && LA51_2<=LOGICALXOR)||(LA51_2>=LPAREN && LA51_2<=MINUS)||LA51_2==MODULO||(LA51_2>=MULTIPLY && LA51_2<=OP)||(LA51_2>=PLUS && LA51_2<=REMOVE)||(LA51_2>=RPAREN && LA51_2<=SEMICOLON)||(LA51_2>=SHIFTLEFT && LA51_2<=SHIFTRIGHT)||LA51_2==STRING||LA51_2==SUPER||LA51_2==SWITCHOP||(LA51_2>=TRUE && LA51_2<=TYPEOF)||(LA51_2>=UNDEF && LA51_2<=UNTIL)||LA51_2==WHILE||LA51_2==YIELD))
				{
					alt51 = 4;
				}
				else
				{
					if (state.backtracking>0) {state.failed=true; return result;}
					NoViableAltException nvae = new NoViableAltException("", 51, 4, input, 2);
					DebugRecognitionException(nvae);
					throw nvae;
				}
				}
				break;
			case CONTEXT:
				{
				int LA51_2 = input.LA(2);

				if ((LA51_2==DOT))
				{
					int LA51_3 = input.LA(3);

					if ((LA51_3==REMOVE||LA51_3==UNDEF))
					{
						alt51 = 3;
					}
					else if ((LA51_3==BITWISEAND||(LA51_3>=BITWISEOR && LA51_3<=BRACKETSASSIGN)||LA51_3==CLASS||LA51_3==COMPARE||LA51_3==DCOLON||LA51_3==DIVIDE||(LA51_3>=EQUAL && LA51_3<=ERANGE)||LA51_3==EXPONENT||(LA51_3>=GREATERTHAN && LA51_3<=GREATERTHANEQUAL)||LA51_3==IDENTIFIER||LA51_3==IRANGE||(LA51_3>=LESSTHAN && LA51_3<=LESSTHANEQUAL)||LA51_3==MINUS||LA51_3==MODULO||LA51_3==MULTIPLY||LA51_3==OP||LA51_3==PLUS||LA51_3==REGEXMATCH||(LA51_3>=SHIFTLEFT && LA51_3<=SHIFTRIGHT)||LA51_3==UMINUS||(LA51_3>=UPLUS && LA51_3<=WHENCOMP)))
					{
						alt51 = 2;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return result;}
						NoViableAltException nvae = new NoViableAltException("", 51, 10, input, 3);
						DebugRecognitionException(nvae);
						throw nvae;
					}
				}
				else if ((LA51_2==EOF||LA51_2==BACKWARDPIPE||(LA51_2>=BITWISEAND && LA51_2<=BRACKETS)||(LA51_2>=COLON && LA51_2<=COMPARE)||LA51_2==CONTEXT||(LA51_2>=DIVIDE && LA51_2<=DO)||LA51_2==EQUAL||(LA51_2>=EXPONENT && LA51_2<=FALSE)||(LA51_2>=FORWARDPIPE && LA51_2<=IF)||LA51_2==INTEGER||(LA51_2>=LBRACE && LA51_2<=LOGICALXOR)||(LA51_2>=LPAREN && LA51_2<=MINUS)||LA51_2==MODULO||(LA51_2>=MULTIPLY && LA51_2<=OP)||(LA51_2>=PLUS && LA51_2<=REMOVE)||(LA51_2>=RPAREN && LA51_2<=SEMICOLON)||(LA51_2>=SHIFTLEFT && LA51_2<=SHIFTRIGHT)||LA51_2==STRING||LA51_2==SUPER||LA51_2==SWITCHOP||(LA51_2>=TRUE && LA51_2<=TYPEOF)||(LA51_2>=UNDEF && LA51_2<=UNTIL)||LA51_2==WHILE||LA51_2==YIELD))
				{
					alt51 = 4;
				}
				else
				{
					if (state.backtracking>0) {state.failed=true; return result;}
					NoViableAltException nvae = new NoViableAltException("", 51, 5, input, 2);
					DebugRecognitionException(nvae);
					throw nvae;
				}
				}
				break;
			case BRACKETS:
			case LBRACKET:
				{
				alt51 = 5;
				}
				break;
			case LBRACE:
				{
				alt51 = 6;
				}
				break;
			case BITWISEXOR:
				{
				alt51 = 7;
				}
				break;
			case LPAREN:
				{
				alt51 = 8;
				}
				break;
			default:
				{
					if (state.backtracking>0) {state.failed=true; return result;}
					NoViableAltException nvae = new NoViableAltException("", 51, 0, input, 1);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(51); }
			switch (alt51)
			{
			case 1:
				DebugEnterAlt(1);
				// SilverParser.g3:373:5: literal
				{
				DebugLocation(373, 5);
				PushFollow(Follow._literal_in_primary2118);
				literal68=literal();
				PopFollow();
				if (state.failed) return result;
				DebugLocation(373, 13);
				if (state.backtracking == 0)
				{
					 result = literal68; 
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SilverParser.g3:374:4: lvalue_instance_ref
				{
				DebugLocation(374, 4);
				PushFollow(Follow._lvalue_instance_ref_in_primary2125);
				lvalue_instance_ref69=lvalue_instance_ref();
				PopFollow();
				if (state.failed) return result;
				DebugLocation(374, 24);
				if (state.backtracking == 0)
				{
					 result = lvalue_instance_ref69; 
				}

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// SilverParser.g3:375:4: lvalue_method_change
				{
				DebugLocation(375, 4);
				PushFollow(Follow._lvalue_method_change_in_primary2132);
				lvalue_method_change70=lvalue_method_change();
				PopFollow();
				if (state.failed) return result;
				DebugLocation(375, 25);
				if (state.backtracking == 0)
				{
					 result = lvalue_method_change70; 
				}

				}
				break;
			case 4:
				DebugEnterAlt(4);
				// SilverParser.g3:376:4: lvalue
				{
				DebugLocation(376, 4);
				PushFollow(Follow._lvalue_in_primary2139);
				lvalue71=lvalue();
				PopFollow();
				if (state.failed) return result;
				DebugLocation(376, 11);
				if (state.backtracking == 0)
				{
					 result = lvalue71; 
				}

				}
				break;
			case 5:
				DebugEnterAlt(5);
				// SilverParser.g3:377:4: array
				{
				DebugLocation(377, 4);
				PushFollow(Follow._array_in_primary2146);
				array72=array();
				PopFollow();
				if (state.failed) return result;
				DebugLocation(377, 10);
				if (state.backtracking == 0)
				{
					 result = array72; 
				}

				}
				break;
			case 6:
				DebugEnterAlt(6);
				// SilverParser.g3:378:4: hash
				{
				DebugLocation(378, 4);
				PushFollow(Follow._hash_in_primary2153);
				hash73=hash();
				PopFollow();
				if (state.failed) return result;
				DebugLocation(378, 9);
				if (state.backtracking == 0)
				{
					 result = hash73; 
				}

				}
				break;
			case 7:
				DebugEnterAlt(7);
				// SilverParser.g3:379:4: anonymous_function
				{
				DebugLocation(379, 4);
				PushFollow(Follow._anonymous_function_in_primary2160);
				anonymous_function74=anonymous_function();
				PopFollow();
				if (state.failed) return result;
				DebugLocation(379, 23);
				if (state.backtracking == 0)
				{
					 result = anonymous_function74; 
				}

				}
				break;
			case 8:
				DebugEnterAlt(8);
				// SilverParser.g3:380:4: anonymous_class_declaration
				{
				DebugLocation(380, 4);
				PushFollow(Follow._anonymous_class_declaration_in_primary2167);
				anonymous_class_declaration75=anonymous_class_declaration();
				PopFollow();
				if (state.failed) return result;
				DebugLocation(380, 32);
				if (state.backtracking == 0)
				{
					 result = anonymous_class_declaration75; 
				}

				}
				break;

			}
			} finally { DebugExitSubRule(51); }

			DebugLocation(381, 2);
			// SilverParser.g3:381:2: ( ( ( LPAREN (funcargs= call_args )? RPAREN (fy= yield_block )? ) | ( LBRACKET accessargs= call_args RBRACKET ) )* | ( ( ( single_hash_key HASH hv= arg ) |cmdargs= call_args ) (cy= yield_block |dcy= do_yield_block )? ) )
			int alt57=2;
			try { DebugEnterSubRule(57);
			try { DebugEnterDecision(57, false);
			try
			{
				alt57 = dfa57.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(57); }
			switch (alt57)
			{
			case 1:
				DebugEnterAlt(1);
				// SilverParser.g3:381:3: ( ( LPAREN (funcargs= call_args )? RPAREN (fy= yield_block )? ) | ( LBRACKET accessargs= call_args RBRACKET ) )*
				{
				DebugLocation(381, 3);
				// SilverParser.g3:381:3: ( ( LPAREN (funcargs= call_args )? RPAREN (fy= yield_block )? ) | ( LBRACKET accessargs= call_args RBRACKET ) )*
				try { DebugEnterSubRule(54);
				while (true)
				{
					int alt54=3;
					try { DebugEnterDecision(54, false);
					int LA54_1 = input.LA(1);

					if ((LA54_1==LPAREN))
					{
						alt54 = 1;
					}
					else if ((LA54_1==LBRACKET))
					{
						alt54 = 2;
					}


					} finally { DebugExitDecision(54); }
					switch ( alt54 )
					{
					case 1:
						DebugEnterAlt(1);
						// SilverParser.g3:381:4: ( LPAREN (funcargs= call_args )? RPAREN (fy= yield_block )? )
						{
						DebugLocation(381, 4);
						// SilverParser.g3:381:4: ( LPAREN (funcargs= call_args )? RPAREN (fy= yield_block )? )
						DebugEnterAlt(1);
						// SilverParser.g3:381:5: LPAREN (funcargs= call_args )? RPAREN (fy= yield_block )?
						{
						DebugLocation(381, 5);
						Match(input,LPAREN,Follow._LPAREN_in_primary2176); if (state.failed) return result;
						DebugLocation(381, 12);
						// SilverParser.g3:381:12: (funcargs= call_args )?
						int alt52=2;
						try { DebugEnterSubRule(52);
						try { DebugEnterDecision(52, false);
						int LA52_1 = input.LA(1);

						if ((LA52_1==BITWISEINVERSE||(LA52_1>=BITWISEXOR && LA52_1<=BRACKETS)||LA52_1==COLON||LA52_1==CONTEXT||LA52_1==FALSE||LA52_1==IDENTIFIER||LA52_1==INTEGER||(LA52_1>=LBRACE && LA52_1<=LBRACKET)||(LA52_1>=LPAREN && LA52_1<=MINUS)||(LA52_1>=NIL && LA52_1<=NOT)||(LA52_1>=NUMBER && LA52_1<=OP)||LA52_1==PLUS||LA52_1==REGEX||LA52_1==REMOVE||LA52_1==SELF||LA52_1==STRING||LA52_1==SUPER||(LA52_1>=TRUE && LA52_1<=TYPEOF)||LA52_1==UNDEF||LA52_1==YIELD))
						{
							alt52 = 1;
						}
						} finally { DebugExitDecision(52); }
						switch (alt52)
						{
						case 1:
							DebugEnterAlt(1);
							// SilverParser.g3:381:13: funcargs= call_args
							{
							DebugLocation(381, 21);
							PushFollow(Follow._call_args_in_primary2181);
							funcargs=call_args();
							PopFollow();
							if (state.failed) return result;
							DebugLocation(381, 32);
							if (state.backtracking == 0)
							{
								 args = funcargs; 
							}

							}
							break;

						}
						} finally { DebugExitSubRule(52); }

						DebugLocation(381, 63);
						Match(input,RPAREN,Follow._RPAREN_in_primary2187); if (state.failed) return result;
						DebugLocation(381, 70);
						// SilverParser.g3:381:70: (fy= yield_block )?
						int alt53=2;
						try { DebugEnterSubRule(53);
						try { DebugEnterDecision(53, false);
						int LA53_1 = input.LA(1);

						if ((LA53_1==LBRACE))
						{
							int LA53_2 = input.LA(2);

							if ((EvaluatePredicate(synpred120_SilverParser_fragment)))
							{
								alt53 = 1;
							}
						}
						} finally { DebugExitDecision(53); }
						switch (alt53)
						{
						case 1:
							DebugEnterAlt(1);
							// SilverParser.g3:381:71: fy= yield_block
							{
							DebugLocation(381, 73);
							PushFollow(Follow._yield_block_in_primary2192);
							fy=yield_block();
							PopFollow();
							if (state.failed) return result;
							DebugLocation(381, 86);
							if (state.backtracking == 0)
							{
								 FunctionArgument arg = new FunctionArgument("__yieldBlock",fy); args.Add(arg); 
							}

							}
							break;

						}
						} finally { DebugExitSubRule(53); }

						DebugLocation(382, 3);
						if (state.backtracking == 0)
						{
							 result = AstExpression.Call(result, args); 
						}

						}


						}
						break;
					case 2:
						DebugEnterAlt(2);
						// SilverParser.g3:383:3: ( LBRACKET accessargs= call_args RBRACKET )
						{
						DebugLocation(383, 3);
						// SilverParser.g3:383:3: ( LBRACKET accessargs= call_args RBRACKET )
						DebugEnterAlt(1);
						// SilverParser.g3:383:4: LBRACKET accessargs= call_args RBRACKET
						{
						DebugLocation(383, 4);
						Match(input,LBRACKET,Follow._LBRACKET_in_primary2206); if (state.failed) return result;
						DebugLocation(383, 23);
						PushFollow(Follow._call_args_in_primary2210);
						accessargs=call_args();
						PopFollow();
						if (state.failed) return result;
						DebugLocation(383, 34);
						Match(input,RBRACKET,Follow._RBRACKET_in_primary2212); if (state.failed) return result;
						DebugLocation(383, 43);
						if (state.backtracking == 0)
						{
							 result = AstExpression.Access(result, accessargs); 
						}

						}


						}
						break;

					default:
						goto loop54;
					}
				}

				loop54:
					;

				} finally { DebugExitSubRule(54); }


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SilverParser.g3:384:3: ( ( ( single_hash_key HASH hv= arg ) |cmdargs= call_args ) (cy= yield_block |dcy= do_yield_block )? )
				{
				DebugLocation(384, 3);
				// SilverParser.g3:384:3: ( ( ( single_hash_key HASH hv= arg ) |cmdargs= call_args ) (cy= yield_block |dcy= do_yield_block )? )
				DebugEnterAlt(1);
				// SilverParser.g3:384:4: ( ( single_hash_key HASH hv= arg ) |cmdargs= call_args ) (cy= yield_block |dcy= do_yield_block )?
				{
				DebugLocation(384, 4);
				// SilverParser.g3:384:4: ( ( single_hash_key HASH hv= arg ) |cmdargs= call_args )
				int alt55=2;
				try { DebugEnterSubRule(55);
				try { DebugEnterDecision(55, false);
				switch (input.LA(1))
				{
				case IDENTIFIER:
					{
					int LA55_2 = input.LA(2);

					if ((EvaluatePredicate(synpred124_SilverParser_fragment)))
					{
						alt55 = 1;
					}
					else if ((true))
					{
						alt55 = 2;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return result;}
						NoViableAltException nvae = new NoViableAltException("", 55, 1, input, 2);
						DebugRecognitionException(nvae);
						throw nvae;
					}
					}
					break;
				case STRING:
					{
					int LA55_2 = input.LA(2);

					if ((EvaluatePredicate(synpred124_SilverParser_fragment)))
					{
						alt55 = 1;
					}
					else if ((true))
					{
						alt55 = 2;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return result;}
						NoViableAltException nvae = new NoViableAltException("", 55, 2, input, 2);
						DebugRecognitionException(nvae);
						throw nvae;
					}
					}
					break;
				case COLON:
					{
					int LA55_2 = input.LA(2);

					if ((EvaluatePredicate(synpred124_SilverParser_fragment)))
					{
						alt55 = 1;
					}
					else if ((true))
					{
						alt55 = 2;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return result;}
						NoViableAltException nvae = new NoViableAltException("", 55, 3, input, 2);
						DebugRecognitionException(nvae);
						throw nvae;
					}
					}
					break;
				case BITWISEINVERSE:
				case BITWISEXOR:
				case BRACKETS:
				case CONTEXT:
				case FALSE:
				case INTEGER:
				case LBRACE:
				case LBRACKET:
				case LPAREN:
				case MINUS:
				case NIL:
				case NOT:
				case NUMBER:
				case OP:
				case PLUS:
				case REGEX:
				case REMOVE:
				case SELF:
				case SUPER:
				case TRUE:
				case TYPEOF:
				case UNDEF:
				case YIELD:
					{
					alt55 = 2;
					}
					break;
				default:
					{
						if (state.backtracking>0) {state.failed=true; return result;}
						NoViableAltException nvae = new NoViableAltException("", 55, 0, input, 1);
						DebugRecognitionException(nvae);
						throw nvae;
					}
				}

				} finally { DebugExitDecision(55); }
				switch (alt55)
				{
				case 1:
					DebugEnterAlt(1);
					// SilverParser.g3:384:5: ( single_hash_key HASH hv= arg )
					{
					DebugLocation(384, 5);
					// SilverParser.g3:384:5: ( single_hash_key HASH hv= arg )
					DebugEnterAlt(1);
					// SilverParser.g3:384:6: single_hash_key HASH hv= arg
					{
					DebugLocation(384, 6);
					PushFollow(Follow._single_hash_key_in_primary2224);
					single_hash_key76=single_hash_key();
					PopFollow();
					if (state.failed) return result;
					DebugLocation(384, 22);
					Match(input,HASH,Follow._HASH_in_primary2226); if (state.failed) return result;
					DebugLocation(384, 29);
					PushFollow(Follow._arg_in_primary2230);
					hv=arg();
					PopFollow();
					if (state.failed) return result;
					DebugLocation(384, 34);
					if (state.backtracking == 0)
					{
						 args.Add(new FunctionArgument(null, 
								AstExpression.CreateDictionary(new List<Expression>{AstExpression.KeyValuePair(single_hash_key76,hv)}))); 
					}

					}


					}
					break;
				case 2:
					DebugEnterAlt(2);
					// SilverParser.g3:385:128: cmdargs= call_args
					{
					DebugLocation(385, 135);
					PushFollow(Follow._call_args_in_primary2239);
					cmdargs=call_args();
					PopFollow();
					if (state.failed) return result;
					DebugLocation(385, 146);
					if (state.backtracking == 0)
					{
						 args = cmdargs; 
					}

					}
					break;

				}
				} finally { DebugExitSubRule(55); }

				DebugLocation(386, 2);
				// SilverParser.g3:386:2: (cy= yield_block |dcy= do_yield_block )?
				int alt56=3;
				try { DebugEnterSubRule(56);
				try { DebugEnterDecision(56, false);
				int LA56_1 = input.LA(1);

				if ((LA56_1==LBRACE))
				{
					int LA56_2 = input.LA(2);

					if ((EvaluatePredicate(synpred125_SilverParser_fragment)))
					{
						alt56 = 1;
					}
				}
				else if ((LA56_1==DO))
				{
					int LA56_2 = input.LA(2);

					if ((EvaluatePredicate(synpred126_SilverParser_fragment)))
					{
						alt56 = 2;
					}
				}
				} finally { DebugExitDecision(56); }
				switch (alt56)
				{
				case 1:
					DebugEnterAlt(1);
					// SilverParser.g3:386:3: cy= yield_block
					{
					DebugLocation(386, 5);
					PushFollow(Follow._yield_block_in_primary2248);
					cy=yield_block();
					PopFollow();
					if (state.failed) return result;
					DebugLocation(386, 18);
					if (state.backtracking == 0)
					{
						 FunctionArgument arg = new FunctionArgument("__yieldBlock",cy); args.Add(arg); 
					}

					}
					break;
				case 2:
					DebugEnterAlt(2);
					// SilverParser.g3:387:3: dcy= do_yield_block
					{
					DebugLocation(387, 6);
					PushFollow(Follow._do_yield_block_in_primary2256);
					dcy=do_yield_block();
					PopFollow();
					if (state.failed) return result;
					DebugLocation(387, 22);
					if (state.backtracking == 0)
					{
						 FunctionArgument arg = new FunctionArgument("__yieldBlock",dcy); 
					}

					}
					break;

				}
				} finally { DebugExitSubRule(56); }

				DebugLocation(387, 101);
				if (state.backtracking == 0)
				{
					 result = AstExpression.Call(result, args); 
				}

				}


				}
				break;

			}
			} finally { DebugExitSubRule(57); }


			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("primary", 41);
			LeaveRule("primary", 41);
			LeaveRule_primary();
		}
		DebugLocation(389, 1);
		} finally { DebugExitRule(GrammarFileName, "primary"); }
		return result;

	}