Example #1
0
        public bool Equals(TSQLCharacters obj)
        {
            // If parameter is null, return false.
            if (Object.ReferenceEquals(obj, null))
            {
                return(false);
            }

            // Optimization for a common success case.
            if (Object.ReferenceEquals(this, obj))
            {
                return(true);
            }

            // If run-time types are not exactly the same, return false.
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }

            // Return true if the fields match.
            // Note that the base class is not invoked because it is
            // System.Object, which defines Equals as reference equality.
            return(Token == obj.Token);
        }
        public bool Equals(TSQLCharacters obj)
        {
            // If parameter is null, return false.
            if (Object.ReferenceEquals(obj, null))
            {
                return false;
            }

            // Optimization for a common success case.
            if (Object.ReferenceEquals(this, obj))
            {
                return true;
            }

            // If run-time types are not exactly the same, return false.
            if (this.GetType() != obj.GetType())
                return false;

            // Return true if the fields match.
            // Note that the base class is not invoked because it is
            // System.Object, which defines Equals as reference equality.
            return Token == obj.Token;
        }
Example #3
0
 private TSQLToken DetermineTokenType(
     string tokenValue,
     int startPosition,
     int endPosition)
 {
     if (
         char.IsWhiteSpace(tokenValue[0]))
     {
         return
             (new TSQLWhitespace(
                  startPosition,
                  tokenValue));
     }
     else if (
         tokenValue[0] == '@')
     {
         return
             (new TSQLVariable(
                  startPosition,
                  tokenValue));
     }
     else if (tokenValue.StartsWith("--"))
     {
         return
             (new TSQLSingleLineComment(
                  startPosition,
                  tokenValue));
     }
     else if (tokenValue.StartsWith("/*"))
     {
         return
             (new TSQLMultilineComment(
                  startPosition,
                  tokenValue));
     }
     else if (
         tokenValue.StartsWith("\'") ||
         tokenValue.StartsWith("N\'") ||
         (
             !UseQuotedIdentifiers &&
             (
                 tokenValue.StartsWith("\"") ||
                 tokenValue.StartsWith("N\"")
             )
         ))
     {
         return
             (new TSQLStringLiteral(
                  startPosition,
                  tokenValue));
     }
     else if (
         tokenValue[0] == '$')
     {
         // $IDENTITY
         if (
             tokenValue.Length > 1 &&
             char.IsLetter(tokenValue[1]))
         {
             return
                 (new TSQLIdentifier(
                      startPosition,
                      tokenValue));
         }
         // $45.56
         else
         {
             return
                 (new TSQLMoneyLiteral(
                      startPosition,
                      tokenValue));
         }
     }
     else if (CharUnicodeInfo.GetUnicodeCategory(tokenValue[0]) == UnicodeCategory.CurrencySymbol)
     {
         return
             (new TSQLMoneyLiteral(
                  startPosition,
                  tokenValue));
     }
     else if (tokenValue.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
     {
         return
             (new TSQLBinaryLiteral(
                  startPosition,
                  tokenValue));
     }
     else if (
         char.IsDigit(tokenValue[0]) ||
         (
             tokenValue[0] == '.' &&
             tokenValue.Length > 1 &&
             char.IsDigit(tokenValue[1])
         ))
     {
         return
             (new TSQLNumericLiteral(
                  startPosition,
                  tokenValue));
     }
     else if (
         tokenValue[0] == '=' ||
         tokenValue[0] == '~' ||
         tokenValue[0] == '-' ||
         tokenValue[0] == '+' ||
         tokenValue[0] == '*' ||
         tokenValue[0] == '/' ||
         tokenValue[0] == '<' ||
         tokenValue[0] == '>' ||
         tokenValue[0] == '!' ||
         tokenValue[0] == '&' ||
         tokenValue[0] == '|' ||
         tokenValue[0] == '^' ||
         tokenValue[0] == '%' ||
         tokenValue[0] == ':')
     {
         return
             (new TSQLOperator(
                  startPosition,
                  tokenValue));
     }
     else if (TSQLCharacters.IsCharacter(tokenValue))
     {
         return
             (new TSQLCharacter(
                  startPosition,
                  tokenValue));
     }
     else if (TSQLKeywords.IsKeyword(tokenValue))
     {
         return
             (new TSQLKeyword(
                  startPosition,
                  tokenValue));
     }
     else
     {
         return
             (new TSQLIdentifier(
                  startPosition,
                  tokenValue));
     }
 }
 public bool Equals(TSQLCharacters obj)
 {
     return(Token == obj.Token);
 }
Example #5
0
 private TSQLToken DetermineTokenType(
     string tokenValue,
     int startPosition,
     int endPosition)
 {
     if (
         char.IsWhiteSpace(tokenValue[0]))
     {
         return
             (new TSQLWhitespace(
                  startPosition,
                  tokenValue));
     }
     else if (
         tokenValue[0] == '@')
     {
         if (TSQLVariables.IsVariable(tokenValue))
         {
             return
                 (new TSQLSystemVariable(
                      startPosition,
                      tokenValue));
         }
         else
         {
             return
                 (new TSQLVariable(
                      startPosition,
                      tokenValue));
         }
     }
     else if (tokenValue.StartsWith("--"))
     {
         return
             (new TSQLSingleLineComment(
                  startPosition,
                  tokenValue));
     }
     else if (tokenValue.StartsWith("/*"))
     {
         if (tokenValue.EndsWith("*/"))
         {
             return
                 (new TSQLMultilineComment(
                      startPosition,
                      tokenValue));
         }
         else
         {
             return
                 (new TSQLIncompleteCommentToken(
                      startPosition,
                      tokenValue));
         }
     }
     else if (
         tokenValue.StartsWith("'") ||
         tokenValue.StartsWith("N'"))
     {
         // make sure there's an even number of quotes so that it's closed properly
         if ((tokenValue.Split('\'').Length - 1) % 2 == 0)
         {
             return
                 (new TSQLStringLiteral(
                      startPosition,
                      tokenValue));
         }
         else
         {
             return
                 (new TSQLIncompleteStringToken(
                      startPosition,
                      tokenValue));
         }
     }
     else if (
         !UseQuotedIdentifiers &&
         tokenValue.StartsWith("\""))
     {
         // make sure there's an even number of quotes so that it's closed properly
         if ((tokenValue.Split('\"').Length - 1) % 2 == 0)
         {
             return
                 (new TSQLStringLiteral(
                      startPosition,
                      tokenValue));
         }
         else
         {
             return
                 (new TSQLIncompleteStringToken(
                      startPosition,
                      tokenValue));
         }
     }
     else if (
         tokenValue[0] == '$')
     {
         // $IDENTITY
         if (
             tokenValue.Length > 1 &&
             char.IsLetter(tokenValue[1]))
         {
             return
                 (new TSQLSystemColumnIdentifier(
                      startPosition,
                      tokenValue));
         }
         // $45.56
         else
         {
             return
                 (new TSQLMoneyLiteral(
                      startPosition,
                      tokenValue));
         }
     }
     else if (CharUnicodeInfo.GetUnicodeCategory(tokenValue[0]) == UnicodeCategory.CurrencySymbol)
     {
         return
             (new TSQLMoneyLiteral(
                  startPosition,
                  tokenValue));
     }
     else if (tokenValue.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
     {
         return
             (new TSQLBinaryLiteral(
                  startPosition,
                  tokenValue));
     }
     else if (
         char.IsDigit(tokenValue[0]) ||
         (
             tokenValue[0] == '.' &&
             tokenValue.Length > 1 &&
             char.IsDigit(tokenValue[1])
         ))
     {
         return
             (new TSQLNumericLiteral(
                  startPosition,
                  tokenValue));
     }
     else if (
         tokenValue[0] == '=' ||
         tokenValue[0] == '~' ||
         tokenValue[0] == '-' ||
         tokenValue[0] == '+' ||
         tokenValue[0] == '*' ||
         tokenValue[0] == '/' ||
         tokenValue[0] == '<' ||
         tokenValue[0] == '>' ||
         tokenValue[0] == '!' ||
         tokenValue[0] == '&' ||
         tokenValue[0] == '|' ||
         tokenValue[0] == '^' ||
         tokenValue[0] == '%' ||
         tokenValue[0] == ':')
     {
         return
             (new TSQLOperator(
                  startPosition,
                  tokenValue));
     }
     else if (TSQLCharacters.IsCharacter(tokenValue))
     {
         return
             (new TSQLCharacter(
                  startPosition,
                  tokenValue));
     }
     else if (TSQLKeywords.IsKeyword(tokenValue))
     {
         return
             (new TSQLKeyword(
                  startPosition,
                  tokenValue));
     }
     else if (TSQLIdentifiers.IsIdentifier(tokenValue))
     {
         return
             (new TSQLSystemIdentifier(
                  startPosition,
                  tokenValue));
     }
     else
     {
         if (
             (
                 tokenValue.StartsWith("[") &&
                 !tokenValue.EndsWith("]")
             ) ||
             (
                 UseQuotedIdentifiers &&
                 tokenValue.StartsWith("\"") &&
                 // see if there's an odd number of quotes
                 (tokenValue.Split('\"').Length - 1) % 2 == 1
             ))
         {
             return
                 (new TSQLIncompleteIdentifierToken(
                      startPosition,
                      tokenValue));
         }
         else
         {
             return
                 (new TSQLIdentifier(
                      startPosition,
                      tokenValue));
         }
     }
 }