예제 #1
0
        public object Visit_FunctionCallExpression(FunctionCallExpression func)
        {
            string name = func.Callee;

            List <object> arguments = new List <object>();

            foreach (IExpression argument in func.Arguments)
            {
                object value = argument.Accept(this);
                arguments.Add(value);
            }

            FunctionValue funcValue = (FunctionValue)Current[name];


            return(funcValue.GetValue(arguments));
        }
예제 #2
0
        private FunctionCallExpression Consume_FunctionCall()
        {
            Token token = currentToken;

            FunctionCallExpression call = new FunctionCallExpression(token.Value.ToString());

            Consume(TokenType.CALL);
            Consume(TokenType.L_PAREN);

            while (currentToken.Type != TokenType.R_PAREN)
            {
                call.AddArgument(Consume_Term());
                if (currentToken.Type == TokenType.COMMA)
                {
                    Consume(TokenType.COMMA);
                }
            }

            Consume(TokenType.R_PAREN);
            return(call);
        }
예제 #3
0
        private IExpression Consume_Statement()
        {
            Token token = currentToken;

            switch (token.Type)
            {
            case TokenType.ID:
                IExpression stmt = Consume_ID();
                Consume(TokenType.SEMI);
                return(stmt);

            case TokenType.CALL:
                FunctionCallExpression call = Consume_FunctionCall();
                Consume(TokenType.SEMI);
                return(call);

            case TokenType.CONDITION:
                return(Consume_ConditionalExpression());

            case TokenType.MEMBERDELIMITER_LEFT:
                return(Consume_DialogueExpression());
            }
            throw RaiseError(ScriptErrorCode.UNEXPECTED_TOKEN, token);
        }
예제 #4
0
 public object Visit_FunctionCallExpression(FunctionCallExpression func)
 {
     //Functions are added from outside of the environment
     //Whether or not they are already declared depends on the C# Script
     return(0);
 }