/// <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; } }
public void SingleEquals() { Scanner lexer; lexer = new Scanner("a=b", ParserOptions.AllowProperties); AdvanceToScannerError(lexer); Assert.Equal(lexer.GetErrorResource(), "IllFormedEqualsInCondition"); Assert.Equal(lexer.UnexpectedlyFound, "b"); }
// // 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, ParserOptions optionSettings, ElementLocation elementLocation) { // 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."); _options = optionSettings; _elementLocation = elementLocation; _lexer = new Scanner(expression, _options); if (!_lexer.Advance()) { errorPosition = _lexer.GetErrorPosition(); ProjectErrorUtilities.VerifyThrowInvalidProject(false, elementLocation, _lexer.GetErrorResource(), expression, errorPosition, _lexer.UnexpectedlyFound); } GenericExpressionNode node = Expr(expression); if (!_lexer.IsNext(Token.TokenType.EndOfInput)) { errorPosition = _lexer.GetErrorPosition(); ProjectErrorUtilities.VerifyThrowInvalidProject(false, elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); } return node; }
public void IllFormedProperty() { Scanner lexer; lexer = new Scanner("$(", ParserOptions.AllowProperties); AdvanceToScannerError(lexer); Assert.IsTrue(lexer.GetErrorResource() == "IllFormedPropertyCloseParenthesisInCondition"); lexer = new Scanner("$x", ParserOptions.AllowProperties); AdvanceToScannerError(lexer); Assert.IsTrue(lexer.GetErrorResource() == "IllFormedPropertyOpenParenthesisInCondition"); }
public void NegativeTests() { Scanner lexer; lexer = new Scanner("'$(DEBUG) == true", ParserOptions.AllowAll); Assert.IsFalse(lexer.Advance()); }
public void ItemListTests() { Scanner lexer; lexer = new Scanner("@(foo)", ParserOptions.AllowProperties); Assert.IsFalse(lexer.Advance()); Assert.IsTrue(String.Compare(lexer.GetErrorResource(), "ItemListNotAllowedInThisConditional") == 0); lexer = new Scanner("1234 '@(foo)'", ParserOptions.AllowProperties); Assert.IsTrue(lexer.Advance()); Assert.IsFalse(lexer.Advance()); Assert.IsTrue(String.Compare(lexer.GetErrorResource(), "ItemListNotAllowedInThisConditional") == 0); lexer = new Scanner("'1234 @(foo)'", ParserOptions.AllowProperties); Assert.IsFalse(lexer.Advance()); Assert.IsTrue(String.Compare(lexer.GetErrorResource(), "ItemListNotAllowedInThisConditional") == 0); }
public void WhitespaceTests() { Scanner lexer; Console.WriteLine("here"); lexer = new Scanner("$(DEBUG) and $(FOO)", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Property)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.And)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Property)); lexer = new Scanner("1234$(DEBUG)0xabcd@(foo)asdf<>'foo'<=false>=true==1234!=", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Property)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LessThan)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.GreaterThan)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LessThanOrEqualTo)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.GreaterThanOrEqualTo)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.EqualTo)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.NotEqualTo)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput)); lexer = new Scanner(" 1234 $(DEBUG) 0xabcd \n@(foo) \nasdf \n< \n> \n'foo' \n<= \nfalse \n>= \ntrue \n== \n 1234 \n!= ", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Property)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LessThan)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.GreaterThan)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LessThanOrEqualTo)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.GreaterThanOrEqualTo)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.EqualTo)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.NotEqualTo)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput)); }
public void ComplexTests2() { Scanner lexer = new Scanner("1234", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); lexer = new Scanner("'abc-efg'==$(foo)", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.String), true); lexer.Advance(); Assert.AreEqual(lexer.IsNext(Token.TokenType.EqualTo), true); lexer.Advance(); Assert.AreEqual(lexer.IsNext(Token.TokenType.Property), true); lexer.Advance(); Assert.AreEqual(lexer.IsNext(Token.TokenType.EndOfInput), true); lexer = new Scanner("$(debug)!=true", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Property), true); lexer.Advance(); Assert.AreEqual(lexer.IsNext(Token.TokenType.NotEqualTo), true); lexer.Advance(); Assert.AreEqual(lexer.IsNext(Token.TokenType.String), true); lexer.Advance(); Assert.AreEqual(lexer.IsNext(Token.TokenType.EndOfInput), true); lexer = new Scanner("$(VERSION)<5", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Property), true); lexer.Advance(); Assert.AreEqual(lexer.IsNext(Token.TokenType.LessThan), true); lexer.Advance(); Assert.AreEqual(lexer.IsNext(Token.TokenType.Numeric), true); lexer.Advance(); Assert.AreEqual(lexer.IsNext(Token.TokenType.EndOfInput), true); }
public void ComplexTests1() { Scanner lexer; lexer = new Scanner("'String with a $(Property) inside'", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.AreEqual(String.Compare("String with a $(Property) inside", lexer.IsNextString()), 0); lexer = new Scanner("'String with an embedded \\' in it'", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); // Assert.AreEqual(String.Compare("String with an embedded ' in it", lexer.IsNextString()), 0); lexer = new Scanner("'String with a $(Property) inside'", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.AreEqual(String.Compare("String with a $(Property) inside", lexer.IsNextString()), 0); lexer = new Scanner("@(list, ' ')", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList)); Assert.AreEqual(String.Compare("@(list, ' ')", lexer.IsNextString()), 0); lexer = new Scanner("@(files->'%(Filename)')", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList)); Assert.AreEqual(String.Compare("@(files->'%(Filename)')", lexer.IsNextString()), 0); }
public void FunctionTests() { Scanner lexer; lexer = new Scanner("Foo()", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Function)); Assert.AreEqual(String.Compare("Foo", lexer.IsNextString()), 0); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis)); lexer = new Scanner("Foo( 1 )", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Function)); Assert.AreEqual(String.Compare("Foo", lexer.IsNextString()), 0); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis)); lexer = new Scanner("Foo( $(Property) )", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Function)); Assert.AreEqual(String.Compare("Foo", lexer.IsNextString()), 0); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Property)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis)); lexer = new Scanner("Foo( @(ItemList) )", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Function)); Assert.AreEqual(String.Compare("Foo", lexer.IsNextString()), 0); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis)); lexer = new Scanner("Foo( simplestring )", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Function)); Assert.AreEqual(String.Compare("Foo", lexer.IsNextString()), 0); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis)); lexer = new Scanner("Foo( 'Not a Simple String' )", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Function)); Assert.AreEqual(String.Compare("Foo", lexer.IsNextString()), 0); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis)); lexer = new Scanner("Foo( 'Not a Simple String', 1234 )", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Function)); Assert.AreEqual(String.Compare("Foo", lexer.IsNextString()), 0); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis)); lexer = new Scanner("Foo( $(Property), 'Not a Simple String', 1234 )", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Function)); Assert.AreEqual(String.Compare("Foo", lexer.IsNextString()), 0); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Property)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis)); lexer = new Scanner("Foo( @(ItemList), $(Property), simplestring, 'Not a Simple String', 1234 )", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Function)); Assert.AreEqual(String.Compare("Foo", lexer.IsNextString()), 0); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.LeftParenthesis)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Property)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Comma)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.Numeric)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.RightParenthesis)); }
public void StringEdgeTests() { Scanner lexer; lexer = new Scanner("@(Foo, ' ')", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.ItemList)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput)); lexer = new Scanner("'@(Foo, ' ')'", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput)); lexer = new Scanner("'%40(( '", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput)); lexer = new Scanner("'@(Complex_ItemType-123, ';')' == ''", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.EqualTo)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.String)); Assert.IsTrue(lexer.Advance() && lexer.IsNext(Token.TokenType.EndOfInput)); }
public void SimpleSingleTokenTests() { Scanner lexer = new Scanner("(", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.LeftParenthesis), true); lexer = new Scanner(")", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.RightParenthesis), true); lexer = new Scanner(",", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Comma), true); lexer = new Scanner("==", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.EqualTo), true); lexer = new Scanner("!=", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.NotEqualTo), true); lexer = new Scanner("<", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.LessThan), true); lexer = new Scanner(">", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.GreaterThan), true); lexer = new Scanner("<=", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.LessThanOrEqualTo), true); lexer = new Scanner(">=", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.GreaterThanOrEqualTo), true); lexer = new Scanner("!", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Not), true); }
public void PropsStringsAndBooleanSingleTokenTests() { Scanner lexer = new Scanner("$(foo)", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Property), true); lexer = new Scanner("@(foo)", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.ItemList), true); lexer = new Scanner("abcde", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.String), true); Assert.AreEqual(String.Compare("abcde", lexer.IsNextString()), 0); lexer = new Scanner("'abc-efg'", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.String), true); Assert.AreEqual(String.Compare("abc-efg", lexer.IsNextString()), 0); lexer = new Scanner("and", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.And), true); Assert.AreEqual(String.Compare("and", lexer.IsNextString()), 0); lexer = new Scanner("or", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Or), true); Assert.AreEqual(String.Compare("or", lexer.IsNextString()), 0); lexer = new Scanner("AnD", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.And), true); Assert.AreEqual(String.Compare(Token.And.String, lexer.IsNextString()), 0); lexer = new Scanner("Or", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Or), true); Assert.AreEqual(String.Compare(Token.Or.String, lexer.IsNextString()), 0); }
public void NumericSingleTokenTests() { Scanner lexer; lexer = new Scanner("1234", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Numeric), true); Assert.AreEqual(String.Compare("1234", lexer.IsNextString()), 0); lexer = new Scanner("-1234", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Numeric), true); Assert.AreEqual(String.Compare("-1234", lexer.IsNextString()), 0); lexer = new Scanner("+1234", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Numeric), true); Assert.AreEqual(String.Compare("+1234", lexer.IsNextString()), 0); lexer = new Scanner("1234.1234", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Numeric), true); Assert.AreEqual(String.Compare("1234.1234", lexer.IsNextString()), 0); lexer = new Scanner(".1234", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Numeric), true); Assert.AreEqual(String.Compare(".1234", lexer.IsNextString()), 0); lexer = new Scanner("1234.", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Numeric), true); Assert.AreEqual(String.Compare("1234.", lexer.IsNextString()), 0); lexer = new Scanner("0x1234", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Numeric), true); Assert.AreEqual(String.Compare("0x1234", lexer.IsNextString()), 0); lexer = new Scanner("0X1234abcd", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Numeric), true); Assert.AreEqual(String.Compare("0X1234abcd", lexer.IsNextString()), 0); lexer = new Scanner("0x1234ABCD", ParserOptions.AllowAll); Assert.IsTrue(lexer.Advance()); Assert.AreEqual(lexer.IsNext(Token.TokenType.Numeric), true); Assert.AreEqual(String.Compare("0x1234ABCD", lexer.IsNextString()), 0); }
public void IllFormedQuotedString() { Scanner lexer; lexer = new Scanner("false or 'abc", ParserOptions.AllowAll); AdvanceToScannerError(lexer); Assert.IsTrue(lexer.GetErrorResource() == "IllFormedQuotedStringInCondition"); Assert.IsTrue(lexer.UnexpectedlyFound == null); lexer = new Scanner("\'", ParserOptions.AllowAll); AdvanceToScannerError(lexer); Assert.IsTrue(lexer.GetErrorResource() == "IllFormedQuotedStringInCondition"); Assert.IsTrue(lexer.UnexpectedlyFound == null); }
public void IllFormedItemList() { Scanner lexer; lexer = new Scanner("@(", ParserOptions.AllowAll); AdvanceToScannerError(lexer); Assert.IsTrue(lexer.GetErrorResource() == "IllFormedItemListCloseParenthesisInCondition"); Assert.IsTrue(lexer.UnexpectedlyFound == null); lexer = new Scanner("@x", ParserOptions.AllowAll); AdvanceToScannerError(lexer); Assert.IsTrue(lexer.GetErrorResource() == "IllFormedItemListOpenParenthesisInCondition"); Assert.IsTrue(lexer.UnexpectedlyFound == null); lexer = new Scanner("@(x", ParserOptions.AllowAll); AdvanceToScannerError(lexer); Assert.IsTrue(lexer.GetErrorResource() == "IllFormedItemListCloseParenthesisInCondition"); Assert.IsTrue(lexer.UnexpectedlyFound == null); lexer = new Scanner("@(x->'%(y)", ParserOptions.AllowAll); AdvanceToScannerError(lexer); Assert.IsTrue(lexer.GetErrorResource() == "IllFormedItemListQuoteInCondition"); Assert.IsTrue(lexer.UnexpectedlyFound == null); lexer = new Scanner("@(x->'%(y)', 'x", ParserOptions.AllowAll); AdvanceToScannerError(lexer); Assert.IsTrue(lexer.GetErrorResource() == "IllFormedItemListQuoteInCondition"); Assert.IsTrue(lexer.UnexpectedlyFound == null); lexer = new Scanner("@(x->'%(y)', 'x'", ParserOptions.AllowAll); AdvanceToScannerError(lexer); Assert.IsTrue(lexer.GetErrorResource() == "IllFormedItemListCloseParenthesisInCondition"); Assert.IsTrue(lexer.UnexpectedlyFound == null); }