private CUDDNode EncodeDoubleConstant(DoubleConstant exp)
 {
     return(CUDD.Constant(exp.Value));
 }
Exemple #2
0
        protected override uint Reduce(uint rule)
        {
            uint state = 0;

            switch (rule)
            {
            case 1:                     // expr = assignable
                items = 1;
                state = Reduce(16, At(0));
                break;

            case 2:                     // expr = unassignable
                items = 1;
                state = Reduce(16, At(0));
                break;

            case 3:                     // assignable = sum
                items = 1;
                state = Reduce(17, At(0));
                break;

            case 4:                     // unassignable = lambda
                items = 1;
                state = Reduce(18, At(0));
                break;

            case 5:                     // lambda = identifier "=>" sum
                items = 3;
                state = Reduce(19, Lambda(At <Token>(0), At <Expression>(2)));
                break;

            case 6:                     // lambda_parameters = identifier
                items = 1;
                state = Reduce(20, At(0));
                break;

            case 7:                     // lambda_parameters = "(" ")"
                items = 2;
                state = Reduce(20, At(0));
                break;

            case 8:                     // sum = sum "+" term
                items = 3;
                state = Reduce(21, new AddBinary(At <Expr>(0), At <Expr>(2)));
                break;

            case 9:                     // sum = sum "-" term
                items = 3;
                state = Reduce(21, new SubtractBinary(At <Expr>(0), At <Expr>(2)));
                break;

            case 10:                     // sum = term
                items = 1;
                state = Reduce(21, At(0));
                break;

            case 11:                     // term = term "*" unary
                items = 3;
                state = Reduce(22, new MultiplyBinary(At <Expr>(0), At <Expr>(2)));
                break;

            case 12:                     // term = term "/" unary
                items = 3;
                state = Reduce(22, new DivideBinary(At <Expr>(0), At <Expr>(2)));
                break;

            case 13:                     // term = unary
                items = 1;
                state = Reduce(22, At(0));
                break;

            case 14:                     // unary = primary
                items = 1;
                state = Reduce(23, At(0));
                break;

            case 15:                     // unary = "-" primary
                items = 2;
                state = Reduce(23, new NegateUnary(At <Token>(0), At <Expr>(1)));
                break;

            case 16:                     // unary = "+" primary
                items = 2;
                state = Reduce(23, At(0));
                break;

            case 17:                     // unary = "!" primary
                items = 2;
                state = Reduce(23, new NotUnary(At <Token>(0), At <Expr>(1)));
                break;

            case 18:                     // unary = "~" primary
                items = 2;
                state = Reduce(23, new OnesComplementUnary(At <Token>(0), At <Expr>(1)));
                break;

            case 19:                     // primary = "(" expr ")"
                items = 3;
                state = Reduce(24, At(1));
                break;

            case 20:                     // primary = constant
                items = 1;
                state = Reduce(24, At(0));
                break;

            case 21:                     // primary = identifier
                items = 1;
                state = Reduce(24, new VarExpr(At <Identifier>(0)));
                break;

            case 22:                     // identifier = Identifier
                items = 1;
                state = Reduce(25, new Identifier(At <Token>(0)));
                break;

            case 23:                     // constant = int
                items = 1;
                state = Reduce(26, At(0));
                break;

            case 24:                     // constant = double
                items = 1;
                state = Reduce(26, At(0));
                break;

            case 25:                     // constant = bool
                items = 1;
                state = Reduce(26, At(0));
                break;

            case 26:                     // int = Int
                items = 1;
                state = Reduce(27, new IntConstant(At <Token>(0)));
                break;

            case 27:                     // double = Double
                items = 1;
                state = Reduce(28, new DoubleConstant(At <Token>(0)));
                break;

            case 28:                     // double = DoubleInt
                items = 1;
                state = Reduce(28, DoubleConstant.ParseInt(At <Token>(0)));
                break;

            case 29:                     // bool = "true"
                items = 1;
                state = Reduce(29, new Constant <bool>(At <Token>(0), true));
                break;

            case 30:                     // bool = "false"
                items = 1;
                state = Reduce(29, new Constant <bool>(At <Token>(0), false));
                break;
            }
            return(state);
        }
Exemple #3
0
        private uint Reduce(uint rule)
        {
            uint state = 0;

            switch (rule)
            {
            case 1:                     // expr = assignable;
            {
                state = _stack.SetItems(1)
                        .Reduce(16, _stack[0]);
                break;
            }

            case 2:                     // expr = unassignable;
            {
                state = _stack.SetItems(1)
                        .Reduce(16, _stack[0]);
                break;
            }

            case 3:                     // assignable = sum;
            {
                state = _stack.SetItems(1)
                        .Reduce(17, _stack[0]);
                break;
            }

            case 4:                     // unassignable = lambda;
            {
                state = _stack.SetItems(1)
                        .Reduce(18, _stack[0]);
                break;
            }

            case 5:                     // lambda = identifier "=>" sum;
            {
                state = _stack.SetItems(3)
                        .Reduce(20, Lambda((Token)_stack[0], (Expression)_stack[2]));
                break;
            }

            case 6:                     // sum = sum "+" term;
            {
                state = _stack.SetItems(3)
                        .Reduce(19, new AddBinary((Expr)_stack[0], (Expr)_stack[2]));
                break;
            }

            case 7:                     // sum = sum "-" term;
            {
                state = _stack.SetItems(3)
                        .Reduce(19, new SubtractBinary((Expr)_stack[0], (Expr)_stack[2]));
                break;
            }

            case 8:                     // sum = term;
            {
                state = _stack.SetItems(1)
                        .Reduce(19, _stack[0]);
                break;
            }

            case 9:                     // term = term "*" unary;
            {
                state = _stack.SetItems(3)
                        .Reduce(22, new MultiplyBinary((Expr)_stack[0], (Expr)_stack[2]));
                break;
            }

            case 10:                     // term = term "/" unary;
            {
                state = _stack.SetItems(3)
                        .Reduce(22, new DivideBinary((Expr)_stack[0], (Expr)_stack[2]));
                break;
            }

            case 11:                     // term = unary;
            {
                state = _stack.SetItems(1)
                        .Reduce(22, _stack[0]);
                break;
            }

            case 12:                     // unary = primary;
            {
                state = _stack.SetItems(1)
                        .Reduce(23, _stack[0]);
                break;
            }

            case 13:                     // unary = "-" primary;
            {
                state = _stack.SetItems(2)
                        .Reduce(23, new NegateUnary((Token)_stack[0], (Expr)_stack[1]));
                break;
            }

            case 14:                     // unary = "+" primary;
            {
                state = _stack.SetItems(2)
                        .Reduce(23, _stack[0]);
                break;
            }

            case 15:                     // unary = "!" primary;
            {
                state = _stack.SetItems(2)
                        .Reduce(23, new NotUnary((Token)_stack[0], (Expr)_stack[1]));
                break;
            }

            case 16:                     // unary = "~" primary;
            {
                state = _stack.SetItems(2)
                        .Reduce(23, new OnesComplementUnary((Token)_stack[0], (Expr)_stack[1]));
                break;
            }

            case 17:                     // primary = "(" expr ")";
            {
                state = _stack.SetItems(3)
                        .Reduce(24, _stack[1]);
                break;
            }

            case 18:                     // primary = constant;
            {
                state = _stack.SetItems(1)
                        .Reduce(24, _stack[0]);
                break;
            }

            case 19:                     // primary = identifier;
            {
                state = _stack.SetItems(1)
                        .Reduce(24, new VarExpr((Identifier)_stack[0]));
                break;
            }

            case 20:                     // identifier = Identifier;
            {
                state = _stack.SetItems(1)
                        .Reduce(21, new Identifier((Token)_stack[0]));
                break;
            }

            case 21:                     // constant = int;
            {
                state = _stack.SetItems(1)
                        .Reduce(25, _stack[0]);
                break;
            }

            case 22:                     // constant = double;
            {
                state = _stack.SetItems(1)
                        .Reduce(25, _stack[0]);
                break;
            }

            case 23:                     // constant = bool;
            {
                state = _stack.SetItems(1)
                        .Reduce(25, _stack[0]);
                break;
            }

            case 24:                     // int = Int;
            {
                state = _stack.SetItems(1)
                        .Reduce(26, new IntConstant((Token)_stack[0]));
                break;
            }

            case 25:                     // double = Double;
            {
                state = _stack.SetItems(1)
                        .Reduce(27, new DoubleConstant((Token)_stack[0]));
                break;
            }

            case 26:                     // double = DoubleInt;
            {
                state = _stack.SetItems(1)
                        .Reduce(27, DoubleConstant.ParseInt((Token)_stack[0]));
                break;
            }

            case 27:                     // bool = true;
            {
                state = _stack.SetItems(1)
                        .Reduce(28, new Constant <bool>((Token)_stack[0], true));
                break;
            }

            case 28:                     // bool = false;
            {
                state = _stack.SetItems(1)
                        .Reduce(28, new Constant <bool>((Token)_stack[0], false));
                break;
            }
            }
            return(state);
        }