Ejemplo n.º 1
0
        public void ThrowExpectingRanges(int[] expecting)
        {
            ExpectingException ex = null;

            ex           = new ExpectingException(_GetExpectingMessageRanges(expecting));
            ex.Position  = Position;
            ex.Line      = Line;
            ex.Column    = Column;
            ex.Expecting = null;
            throw ex;
        }
Ejemplo n.º 2
0
        public void Expecting(params int[] expecting)
        {
            ExpectingException ex = null;

            switch (expecting.Length)
            {
            case 0:
                if (-1 == Current)
                {
                    ex = new ExpectingException(_GetExpectingMessage(expecting));
                }
                break;

            case 1:
                if (expecting[0] != Current)
                {
                    ex = new ExpectingException(_GetExpectingMessage(expecting));
                }
                break;

            default:
                if (0 > Array.IndexOf(expecting, Current))
                {
                    ex = new ExpectingException(_GetExpectingMessage(expecting));
                }
                break;
            }
            if (null != ex)
            {
                ex.Position  = Position;
                ex.Line      = Line;
                ex.Column    = Column;
                ex.Expecting = new string[expecting.Length];
                for (int i = 0; i < ex.Expecting.Length; i++)
                {
                    ex.Expecting[i] = Convert.ToString(expecting[i]);
                }
                throw ex;
            }
        }