Esempio n. 1
0
        private ITripleExpression Atomic()
        {
            GetNext();
            ITripleExpression ret;

            switch (current)
            {
            case State.number:
                ret = new Const(constant);
                GetNext();
                break;

            case State.variable:
                ret = new Variable(Char.ToString(variable));
                GetNext();
                break;

            case State.minus:
                ret = new Subtract(new Const(0), Atomic());
                break;

            case State.abs:
                ret = new Abs(Atomic());
                break;

            case State.square:
                ret = new Square(Atomic());
                break;

            case State.lparen:
                ret = Shifts();
                if (current != State.rparen)
                {
                    Console.WriteLine(") missing");
                    throw new InvalidOperationException(") missing");
                }
                GetNext();
                break;

            default:
                ret = null;
                Console.WriteLine("Unrecognizable format");
                throw new InvalidOperationException("Unrecognizable format");
                break;
            }
            return(ret);
        }
Esempio n. 2
0
        private ITripleExpression <T> Atomic()
        {
            GetNext();
            ITripleExpression <T> ret;

            switch (current)
            {
            case State.number:
                ret = new Const <T>(constant);
                GetNext();
                break;

            case State.variable:
                ret = new Variable <T>(Char.ToString(variable));
                GetNext();
                break;

            case State.minus:
                ret = new Negate <T>(Atomic(), op);
                break;

            case State.abs:
                ret = new Abs <T>(Atomic(), op);
                break;

            case State.square:
                ret = new Square <T>(Atomic(), op);
                break;

            case State.lparen:
                ret = AddSubt();
                GetNext();
                break;

            default:
                ret = null;
                throw new ParsingException("unrecognizable format");
            }
            return(ret);
        }