예제 #1
0
        public static TokenType ExecuteUnaryOperation(Operator op, TokenType param)
        {
            Type             pType = param.GetType();
            UnaryOperatorDef def   = new UnaryOperatorDef(op, pType);

            if (unary_operators.ContainsKey(def))
            {
                return(unary_operators[def].func(param));
            }

            throw new ExprCoreException("인식할 수 없는 연산자입니다. " + op + "(" + pType.Name + ")");
        }
예제 #2
0
파일: Operators.cs 프로젝트: won983212/UMPL
        public static TokenType ExecuteOperation(OperatorDef op, TokenType param1, TokenType param2)
        {
            if (op is UnaryOperatorDef)
            {
                UnaryOperatorDef def = op as UnaryOperatorDef;
                if (unary_operators.ContainsKey(def))
                {
                    return(unary_operators[def](param1));
                }
            }
            else if (op is BinaryOperatorDef)
            {
                BinaryOperatorDef def = op as BinaryOperatorDef;
                if (binary_operators.ContainsKey(def))
                {
                    return(binary_operators[def](param1, param2));
                }
            }

            throw new ProcessingException("인식할 수 없는 연산자입니다. [" + op + "]");
        }