public InvocationExpression(Expression Target, ArgumentList Arguments, Expression.Operation Opcode, TextSpan Location)
			: base(Opcode, Location)
		{
			this.Target = Target;
			this.Arguments = Arguments;
		}
Exemple #2
0
		private Expression ParseLeftHandSideExpression ()
		{
			Token start = current;
			Expression expr;
			switch (current.Kind) {
				//primary expression
				case Token.Type.@this:
					expr = new Expression (Expression.Operation.@this, new TextSpan (current, current));
					break;
				case Token.Type.Identifier:
					expr = new IdentifierExpression ((current as IdentifierToken).Spelling, new TextSpan (current, current));
					break;
				case Token.Type.@null:
					expr = new NullExpression (new TextSpan (current, current));
					break;
				case Token.Type.@true:
					expr = new Expression (Expression.Operation.@true, new TextSpan (current, current));
					break;
				case Token.Type.@false:
					expr = new Expression (Expression.Operation.@false, new TextSpan (current, current));
					break;
				case Token.Type.NumericLiteral:
					expr = new NumericLiteralExpression (((NumericLiteralToken)current).Spelling, new TextSpan (current, current));
					break;
				case Token.Type.OctalIntegerLiteral:
					expr = new OctalLiteralExpression (((OctalIntegerLiteralToken)current).Value, new TextSpan (current, current));
					break;
				case Token.Type.HexIntegerLiteral:
					expr = new HexLiteralExpression (((HexIntegerLiteralToken)current).Value, new TextSpan (current, current));
					break;
				case Token.Type.StringLiteral:
					expr = new StringLiteralExpression ((current as StringLiteralToken).Value, (current as StringLiteralToken).Spelling, new TextSpan (current, current));
					break;
				case Token.Type.LeftBracket:
					expr = ParseArrayLiteral ();
					break;
				case Token.Type.LeftBrace:
					expr = ParseObjectLiteral ();
					break;
				case Token.Type.LeftParenthesis:
					Next ();
					expr = new UnaryOperatorExpression(ParseExpression (), Expression.Operation.Parenthesized, new TextSpan(current,current));
					CheckSyntaxExpected (Token.Type.RightParenthesis);
					break;
				//end primary
				case Token.Type.function:
					expr = new FunctionExpression (ParseFunctionDefinition ());
					break;
				case Token.Type.@new:
					Next ();
					Expression target = ParseExpression ();
					ArgumentList arguments;
					if (current.Kind == Token.Type.LeftParenthesis) {
						arguments = this.ParseArgumentList ();
					} else {
						arguments = new ArgumentList (new List<ExpressionListElement> (), new TextSpan (start, current));
					}
					expr = new InvocationExpression (target, arguments,Expression.Operation.@new, new TextSpan(start,current));
					break;
				default:
					SyntaxError.Add ("Expression start with a strange token :" + current.Kind.ToString ());
					return new Expression (Expression.Operation.SyntaxError, new TextSpan (start, current));
			}
			Next (); // to go ahead for other part
			return ParseRightExpression (expr);
		}
Exemple #3
0
 public InvocationExpression(Expression Target, ArgumentList Arguments, Expression.Operation Opcode, TextSpan Location)
     : base(Opcode, Location)
 {
     this.Target    = Target;
     this.Arguments = Arguments;
 }