示例#1
0
 public void ForLoopWithNegativeConstraints()
 {
     Assert.Equal(
         new IToken[]
     {
         new KeyWordToken("FOR", 0),
         new NameToken("i", 0),
         new ComparisonOperatorToken("=", 0),
         new NumericValueToken("-1", 0),
         new KeyWordToken("TO", 0),
         new NumericValueToken("-4", 0),
         new KeyWordToken("STEP", 0),
         new NumericValueToken("-1", 0)
     },
         NumberRebuilder.Rebuild(
             new IToken[]
     {
         new KeyWordToken("FOR", 0),
         new NameToken("i", 0),
         new ComparisonOperatorToken("=", 0),
         new OperatorToken("-", 0),
         new NumericValueToken("1", 0),
         new KeyWordToken("TO", 0),
         new OperatorToken("-", 0),
         new NumericValueToken("4", 0),
         new KeyWordToken("STEP", 0),
         new OperatorToken("-", 0),
         new NumericValueToken("1", 0)
     }
             ),
         new TokenSetComparer()
         );
 }
示例#2
0
 public void PointOne()
 {
     Assert.Equal(
         new[]
     {
         new NumericValueToken(".1", 0)
     },
         NumberRebuilder.Rebuild(
             new IToken[]
     {
         new MemberAccessorOrDecimalPointToken(".", 0),
         new NumericValueToken("1", 0)
     }
             ),
         new TokenSetComparer()
         );
 }
示例#3
0
 public void NegativeOne()
 {
     Assert.Equal(
         new[]
     {
         new NumericValueToken("-1", 0)
     },
         NumberRebuilder.Rebuild(
             new IToken[]
     {
         new OperatorToken("-", 0),
         new NumericValueToken("1", 0)
     }
             ),
         new TokenSetComparer()
         );
 }
示例#4
0
 public void DoNotTryToTreatMemberSeparatorRelyUponWithKeywordAsDecimalPoint()
 {
     Assert.Equal(
         new IToken[]
     {
         new MemberAccessorToken(0),
         new NameToken("Name", 0),
     },
         NumberRebuilder.Rebuild(
             new IToken[]
     {
         new MemberAccessorOrDecimalPointToken(".", 0),
         new NameToken("Name", 0),
     }
             ),
         new TokenSetComparer()
         );
 }
示例#5
0
 public void PointOneAsNonBracketedArgument()
 {
     Assert.Equal(
         new IToken[]
     {
         new NameToken("fnc", 0),
         new NumericValueToken(".1", 0)
     },
         NumberRebuilder.Rebuild(
             new IToken[]
     {
         new NameToken("fnc", 0),
         new MemberAccessorOrDecimalPointToken(".", 0),
         new NumericValueToken("1", 0)
     }
             ),
         new TokenSetComparer()
         );
 }
        private static IEnumerable <IToken> GetTokens(string scriptContent)
        {
            // Break down content into String, Comment and UnprocessedContent tokens
            var tokens = StringBreaker.SegmentString(scriptContent);

            // Break down further into String, Comment, Atom and AbstractEndOfStatement tokens
            var atomTokens = new List <IToken>();

            foreach (var token in tokens)
            {
                if (token is UnprocessedContentToken)
                {
                    atomTokens.AddRange(TokenBreaker.BreakUnprocessedToken((UnprocessedContentToken)token));
                }
                else
                {
                    atomTokens.Add(token);
                }
            }

            return(NumberRebuilder.Rebuild(OperatorCombiner.Combine(atomTokens)).ToList());
        }