コード例 #1
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
 /// <summary>
 /// Advance to the point of the lexer error. If the error is only caught by the parser, this isn't useful.
 /// </summary>
 /// <param name="lexer"></param>
 private void AdvanceToScannerError(Scanner lexer)
 {
     while (true)
     {
         if (!lexer.Advance()) break;
         if (lexer.IsNext(Token.TokenType.EndOfInput)) break;
     }
 }
コード例 #2
0
ファイル: Parser.cs プロジェクト: nikson/msbuild
        //
        // Main entry point for parser.
        // You pass in the expression you want to parse, and you get an
        // ExpressionTree out the back end.
        //
        internal GenericExpressionNode Parse(string expression, XmlAttribute conditionAttributeRef, ParserOptions optionSettings)
        {
            // We currently have no support (and no scenarios) for disallowing property references
            // in Conditions.
            ErrorUtilities.VerifyThrow(0 != (optionSettings & ParserOptions.AllowProperties),
                "Properties should always be allowed.");

            this.conditionAttribute = conditionAttributeRef;
            this.options = optionSettings;

            lexer = new Scanner(expression, options);
            if (!lexer.Advance())
            {
                errorPosition = lexer.GetErrorPosition();
                ProjectErrorUtilities.VerifyThrowInvalidProject(false, this.conditionAttribute, lexer.GetErrorResource(), expression, errorPosition, lexer.UnexpectedlyFound);
            }
            GenericExpressionNode node = Expr(expression);
            if (!lexer.IsNext(Token.TokenType.EndOfInput))
            {
                errorPosition = lexer.GetErrorPosition();
                ProjectErrorUtilities.VerifyThrowInvalidProject(false, this.conditionAttribute, "UnexpectedTokenInCondition", expression, lexer.IsNextString(), errorPosition);
            }
            return node;
        }
コード例 #3
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void IllFormedProperty()
        {
            Scanner lexer;

            lexer = new Scanner("$(", ParserOptions.AllowProperties);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedPropertyCloseParenthesisInCondition");

            lexer = new Scanner("$x", ParserOptions.AllowProperties);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedPropertyOpenParenthesisInCondition");
        }
コード例 #4
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void SingleEquals()
        {
            Scanner lexer;

            lexer = new Scanner("a=b", ParserOptions.AllowProperties);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedEqualsInCondition");
            Assertion.Assert(lexer.UnexpectedlyFound == "b");
        }
コード例 #5
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void NegativeTests()
        {
            Scanner lexer;

            lexer = new Scanner("'$(DEBUG) == true", ParserOptions.AllowAll);
            Assertion.Assert(!lexer.Advance());
        }
コード例 #6
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void WhitespaceTests()
        {
            Scanner lexer;
            Console.WriteLine("here");
            lexer = new Scanner("$(DEBUG) and $(FOO)", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Property));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.And));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Property));

            lexer = new Scanner("1234$(DEBUG)0xabcd@(foo)asdf<>'foobar'<=false>=true==1234!=", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Property));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LessThan));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.GreaterThan));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LessThanOrEqualTo));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.GreaterThanOrEqualTo));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.EqualTo));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.NotEqualTo));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput));

            lexer = new Scanner("   1234    $(DEBUG)    0xabcd  \n@(foo)    \nasdf  \n<     \n>     \n'foobar'  \n<=    \nfalse     \n>=    \ntrue  \n== \n 1234    \n!=     ", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Property));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LessThan));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.GreaterThan));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LessThanOrEqualTo));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.GreaterThanOrEqualTo));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.EqualTo));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.NotEqualTo));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput));
        }
コード例 #7
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void ItemListTests()
        {
            Scanner lexer;

            lexer = new Scanner("@(foo)", ParserOptions.AllowProperties);
            Assertion.Assert(!lexer.Advance());
            Assertion.Assert(String.Compare(lexer.GetErrorResource(), "ItemListNotAllowedInThisConditional") == 0);

            lexer = new Scanner("1234 '@(foo)'", ParserOptions.AllowProperties);
            Assertion.Assert(lexer.Advance());
            Assertion.Assert(!lexer.Advance());
            Assertion.Assert(String.Compare(lexer.GetErrorResource(), "ItemListNotAllowedInThisConditional") == 0);

            lexer = new Scanner("'1234 @(foo)'", ParserOptions.AllowProperties);
            Assertion.Assert(!lexer.Advance());
            Assertion.Assert(String.Compare(lexer.GetErrorResource(), "ItemListNotAllowedInThisConditional") == 0);
        }
コード例 #8
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void ComplexTests1 ()
        {
            Scanner lexer;

            lexer = new Scanner("'String with a $(Property) inside'", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.AssertEquals(String.Compare("String with a $(Property) inside", lexer.IsNextString()), 0);

            lexer = new Scanner("'String with an embedded \\' in it'", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
//          Assertion.AssertEquals(String.Compare("String with an embedded ' in it", lexer.IsNextString()), 0);

            lexer = new Scanner("'String with a $(Property) inside'", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.AssertEquals(String.Compare("String with a $(Property) inside", lexer.IsNextString()), 0);

            lexer = new Scanner("@(list, ' ')", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList));
            Assertion.AssertEquals(String.Compare("@(list, ' ')", lexer.IsNextString()), 0);

            lexer = new Scanner("@(files->'%(Filename)')", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList));
            Assertion.AssertEquals(String.Compare("@(files->'%(Filename)')", lexer.IsNextString()), 0);
        }
コード例 #9
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void ComplexTests2()
        {
            Scanner lexer = new Scanner("1234", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());

            lexer = new Scanner("'abc-efg'==$(foo)", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.String), true);
            lexer.Advance();
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.EqualTo), true);
            lexer.Advance();
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Property), true);
            lexer.Advance();
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.EndOfInput), true);

            lexer = new Scanner("$(debug)!=true", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Property), true);
            lexer.Advance();
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.NotEqualTo), true);
            lexer.Advance();
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.String), true);
            lexer.Advance();
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.EndOfInput), true);

            lexer = new Scanner("$(VERSION)<5", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Property), true);
            lexer.Advance();
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.LessThan), true);
            lexer.Advance();
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Numeric), true);
            lexer.Advance();
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.EndOfInput), true);
        }
コード例 #10
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void StringEdgeTests()
        {
            Scanner lexer;

            lexer = new Scanner("@(Foo, ' ')", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput));

            lexer = new Scanner("'@(Foo, ' ')'", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput));

            lexer = new Scanner("'%40(( '", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput));

            lexer = new Scanner("'@(Complex_ItemType-123, ';')' == ''", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.EqualTo));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput));

        }
コード例 #11
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void FunctionTests()
        {
            Scanner lexer;

            lexer = new Scanner("Foobar()", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Function));
            Assertion.AssertEquals(String.Compare("Foobar", lexer.IsNextString()), 0);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis));

            lexer = new Scanner("Foobar( 1 )", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Function));
            Assertion.AssertEquals(String.Compare("Foobar", lexer.IsNextString()), 0);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis));

            lexer = new Scanner("Foobar( $(Property) )", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Function));
            Assertion.AssertEquals(String.Compare("Foobar", lexer.IsNextString()), 0);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Property));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis));

            lexer = new Scanner("Foobar( @(ItemList) )", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Function));
            Assertion.AssertEquals(String.Compare("Foobar", lexer.IsNextString()), 0);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis));

            lexer = new Scanner("Foobar( simplestring )", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Function));
            Assertion.AssertEquals(String.Compare("Foobar", lexer.IsNextString()), 0);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis));

            lexer = new Scanner("Foobar( 'Not a Simple String' )", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Function));
            Assertion.AssertEquals(String.Compare("Foobar", lexer.IsNextString()), 0);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis));

            lexer = new Scanner("Foobar( 'Not a Simple String', 1234 )", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Function));
            Assertion.AssertEquals(String.Compare("Foobar", lexer.IsNextString()), 0);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis));

            lexer = new Scanner("Foobar( $(Property), 'Not a Simple String', 1234 )", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Function));
            Assertion.AssertEquals(String.Compare("Foobar", lexer.IsNextString()), 0);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Property));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis));

            lexer = new Scanner("Foobar( @(ItemList), $(Property), simplestring, 'Not a Simple String', 1234 )", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Function));
            Assertion.AssertEquals(String.Compare("Foobar", lexer.IsNextString()), 0);
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Property));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.String));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric));
            Assertion.Assert(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis));
        }
コード例 #12
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
 public void SimpleSingleTokenTests ()
 {
     Scanner lexer = new Scanner("(", ParserOptions.AllowAll);
     Assertion.Assert(lexer.Advance());
     Assertion.AssertEquals(lexer.IsNext(Token.TokenType.LeftParenthesis), true);
     lexer = new Scanner(")", ParserOptions.AllowAll);
     Assertion.Assert(lexer.Advance());
     Assertion.AssertEquals(lexer.IsNext(Token.TokenType.RightParenthesis), true);
     lexer = new Scanner(",", ParserOptions.AllowAll);
     Assertion.Assert(lexer.Advance());
     Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Comma), true);
     lexer = new Scanner("==", ParserOptions.AllowAll);
     Assertion.Assert(lexer.Advance());
     Assertion.AssertEquals(lexer.IsNext(Token.TokenType.EqualTo), true);
     lexer = new Scanner("!=", ParserOptions.AllowAll);
     Assertion.Assert(lexer.Advance());
     Assertion.AssertEquals(lexer.IsNext(Token.TokenType.NotEqualTo), true);
     lexer = new Scanner("<", ParserOptions.AllowAll);
     Assertion.Assert(lexer.Advance());
     Assertion.AssertEquals(lexer.IsNext(Token.TokenType.LessThan), true);
     lexer = new Scanner(">", ParserOptions.AllowAll);
     Assertion.Assert(lexer.Advance());
     Assertion.AssertEquals(lexer.IsNext(Token.TokenType.GreaterThan), true);
     lexer = new Scanner("<=", ParserOptions.AllowAll);
     Assertion.Assert(lexer.Advance());
     Assertion.AssertEquals(lexer.IsNext(Token.TokenType.LessThanOrEqualTo), true);
     lexer = new Scanner(">=", ParserOptions.AllowAll);
     Assertion.Assert(lexer.Advance());
     Assertion.AssertEquals(lexer.IsNext(Token.TokenType.GreaterThanOrEqualTo), true);
     lexer = new Scanner("!", ParserOptions.AllowAll);
     Assertion.Assert(lexer.Advance());
     Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Not), true);
 }
コード例 #13
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void PropsStringsAndBooleanSingleTokenTests()
        {
            Scanner lexer = new Scanner("$(foo)", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Property), true);
            lexer = new Scanner("@(foo)", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.ItemList), true);
            lexer = new Scanner("abcde", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.String), true);
            Assertion.AssertEquals(String.Compare("abcde", lexer.IsNextString()), 0);

            lexer = new Scanner("'abc-efg'", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.String), true);
            Assertion.AssertEquals(String.Compare("abc-efg", lexer.IsNextString()), 0);

            lexer = new Scanner("and", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.And), true);
            Assertion.AssertEquals(String.Compare("and", lexer.IsNextString()), 0);
            lexer = new Scanner("or", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Or), true);
            Assertion.AssertEquals(String.Compare("or", lexer.IsNextString()), 0);
            lexer = new Scanner("AnD", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.And), true);
            Assertion.AssertEquals(String.Compare("AnD", lexer.IsNextString()), 0);
            lexer = new Scanner("Or", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Or), true);
            Assertion.AssertEquals(String.Compare("Or", lexer.IsNextString()), 0);
        }
コード例 #14
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void NumericSingleTokenTests()
        {
            Scanner lexer;
            
            lexer = new Scanner("1234", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Numeric), true);
            Assertion.AssertEquals(String.Compare("1234", lexer.IsNextString()), 0);

            lexer = new Scanner("-1234", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Numeric), true);
            Assertion.AssertEquals(String.Compare("-1234", lexer.IsNextString()), 0);

            lexer = new Scanner("+1234", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Numeric), true);
            Assertion.AssertEquals(String.Compare("+1234", lexer.IsNextString()), 0);

            lexer = new Scanner("1234.1234", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Numeric), true);
            Assertion.AssertEquals(String.Compare("1234.1234", lexer.IsNextString()), 0);

            lexer = new Scanner(".1234", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Numeric), true);
            Assertion.AssertEquals(String.Compare(".1234", lexer.IsNextString()), 0);

            lexer = new Scanner("1234.", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Numeric), true);
            Assertion.AssertEquals(String.Compare("1234.", lexer.IsNextString()), 0);
            lexer = new Scanner("0x1234", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Numeric), true);
            Assertion.AssertEquals(String.Compare("0x1234", lexer.IsNextString()), 0);
            lexer = new Scanner("0X1234abcd", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Numeric), true);
            Assertion.AssertEquals(String.Compare("0X1234abcd", lexer.IsNextString()), 0);
            lexer = new Scanner("0x1234ABCD", ParserOptions.AllowAll);
            Assertion.Assert(lexer.Advance());
            Assertion.AssertEquals(lexer.IsNext(Token.TokenType.Numeric), true);
            Assertion.AssertEquals(String.Compare("0x1234ABCD", lexer.IsNextString()), 0);
        }
コード例 #15
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void IllFormedQuotedString()
        {
            Scanner lexer;

            lexer = new Scanner("false or 'abc", ParserOptions.AllowAll);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedQuotedStringInCondition");
            Assertion.Assert(lexer.UnexpectedlyFound == null);

            lexer = new Scanner("\'", ParserOptions.AllowAll);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedQuotedStringInCondition");
            Assertion.Assert(lexer.UnexpectedlyFound == null);
        }
コード例 #16
0
ファイル: Scanner_Tests.cs プロジェクト: nikson/msbuild
        public void IllFormedItemList()
        {
            Scanner lexer;

            lexer = new Scanner("@(", ParserOptions.AllowAll);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedItemListCloseParenthesisInCondition");
            Assertion.Assert(lexer.UnexpectedlyFound == null);

            lexer = new Scanner("@x", ParserOptions.AllowAll);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedItemListOpenParenthesisInCondition");
            Assertion.Assert(lexer.UnexpectedlyFound == null);

            lexer = new Scanner("@(x", ParserOptions.AllowAll);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedItemListCloseParenthesisInCondition");
            Assertion.Assert(lexer.UnexpectedlyFound == null);

            lexer = new Scanner("@(x->'%(y)", ParserOptions.AllowAll);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedItemListQuoteInCondition");
            Assertion.Assert(lexer.UnexpectedlyFound == null);

            lexer = new Scanner("@(x->'%(y)', 'x", ParserOptions.AllowAll);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedItemListQuoteInCondition");
            Assertion.Assert(lexer.UnexpectedlyFound == null);

            lexer = new Scanner("@(x->'%(y)', 'x'", ParserOptions.AllowAll);
            AdvanceToScannerError(lexer);
            Assertion.Assert(lexer.GetErrorResource() == "IllFormedItemListCloseParenthesisInCondition");
            Assertion.Assert(lexer.UnexpectedlyFound == null);
        }