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

            Assert.IsTrue(list.ToStringOnlyNoneReserved().Length == 0);
        }
コード例 #2
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");
        }
コード例 #3
0
        public void ReserveOneShouldShorten()
        {
            ReservedIndexedCharList list = new ReservedIndexedCharList("ABC");
            list[1].ReservedBy = new NullToken();

            Assert.IsTrue(list.ToStringOnlyNoneReserved().Length == 2);
            Assert.IsTrue(list.ToStringOnlyNoneReserved() == "AC");
        }
コード例 #4
0
        public void ReserveFromStartAndStopCharWorksCorrectly()
        {
            ReservedIndexedCharList list = new ReservedIndexedCharList("A'B'C");
            list.ReserveFromStartAndStopChar('\'', '\'', new NullToken());

            Assert.IsTrue(list.ToStringOnlyNoneReserved().Length == 2);
            Assert.IsTrue(list.ToStringOnlyNoneReserved() == "AC");
        }
コード例 #5
0
        public void RemoveWhiteSpace_Only_Keeps_None_WhiteSpace_Characters_In_List()
        {
            ReservedIndexedCharList list = new ReservedIndexedCharList(" A B\t     C    ");
            list.RemoveWhiteSpace();

            Assert.IsTrue(list.ToString() == "ABC");
            Assert.IsTrue(list[2].Position == 2);
        }
コード例 #6
0
        public void GetReservedRetunrsWhatTokenHasReserved()
        {
            ReservedIndexedCharList list = new ReservedIndexedCharList("ABC");
            Token t = new NullToken();
            list.Reserve(0, t);
            list.Reserve(2, t);

            Assert.IsTrue(list.ToStringOnlyNoneReserved().Length == 1);
            Assert.IsTrue(list.GetReserved(t) == "AC");
        }
コード例 #7
0
ファイル: FormulaTokenizer.cs プロジェクト: Tobbe1974/Oamaru
        public TokenTree TokenizeFormula(string formula)
        {
            var list = new ReservedIndexedCharList(formula);

            ReserveStrings(list);
            list.RemoveWhiteSpace();
            ReserveParanthesises(list);

            return CreateTokenTree(list);
        }
コード例 #8
0
ファイル: FormulaTokenizer.cs プロジェクト: Tobbe1974/Oamaru
        private void ReserveStrings(ReservedIndexedCharList list)
        {
            while (list.ToStringOnlyNoneReserved().Contains("'"))
            {
                list.ReserveFromStartAndStopChar('\'', '\'', new PathToken());
            }

            while (list.ToStringOnlyNoneReserved().Contains("\""))
            {
                list.ReserveFromStartAndStopChar('"', '"', new StringToken());
            }
        }
コード例 #9
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());
            }
        }
コード例 #10
0
 public void ToStringShouldBeTheSame()
 {
     ReservedIndexedCharList list = new ReservedIndexedCharList("ABC");
     Assert.IsTrue(list.ToString() == "ABC");
 }
コード例 #11
0
 public void NothingShouldBeReserved()
 {
     ReservedIndexedCharList list = new ReservedIndexedCharList("ABC");
     Assert.IsTrue(list.Chars.All(c => c.ReservedBy == null));
 }
コード例 #12
0
 public void ListLentghShouldBeThree()
 {
     ReservedIndexedCharList list = new ReservedIndexedCharList("ABC");
     Assert.IsTrue(list.Chars.Count == 3);
 }
コード例 #13
0
ファイル: FormulaTokenizer.cs プロジェクト: Tobbe1974/Oamaru
 private TokenTree CreateTokenTree(ReservedIndexedCharList list)
 {
     return null;
 }