コード例 #1
0
        public void ReserveRangeReservesCorrect()
        {
            ReservedIndexedCharList list = new ReservedIndexedCharList("ABC");
            list.ReserveRange(0, 1, new NullToken());

            Assert.IsTrue(list.ToStringOnlyNoneReserved().Length == 1);
            Assert.IsTrue(list.ToStringOnlyNoneReserved() == "C");
        }
コード例 #2
0
ファイル: FormulaTokenizer.cs プロジェクト: Tobbe1974/Oamaru
        private void ReserveParanthesises(ReservedIndexedCharList list)
        {
            string current = list.ToStringOnlyNoneReserved();
            if (current.CountOf('(') != current.CountOf(')'))
                throw new BadFormulaExpression("Parentheses does not match");

            int expressionCount = current.CountOf('(');
            int start = 0;
            int end = current.Length - 1;

            while(expressionCount-- > 0)
            {
                start = current.IndexOf('(', start);
                end = current.LastIndexOf(')', end);
                list.ReserveRange(start++, end--, new ExpressionToken());
            }
        }