private static void CompleteToken(ref SqlTokenizationType? currentTokenizationType, ITokenList tokenContainer, StringBuilder currentValue)
        {
            if (currentTokenizationType == null)
                throw new Exception("Cannot complete Token, as there is no current Tokenization Type");

            switch (currentTokenizationType)
            {


				case SqlTokenizationType.BlockComment:
                    tokenContainer.Add(new Token(SqlTokenType.MultiLineComment, currentValue.ToString()));
                    break;

                case SqlTokenizationType.OtherNode:
                    tokenContainer.Add(new Token(SqlTokenType.OtherNode, currentValue.ToString()));
                    break;

                case SqlTokenizationType.PseudoName:
                    tokenContainer.Add(new Token(SqlTokenType.PseudoName, currentValue.ToString()));
                    break;

                case SqlTokenizationType.SingleLineComment:
                    tokenContainer.Add(new Token(SqlTokenType.SingleLineComment, currentValue.ToString()));
                    break;

                case SqlTokenizationType.SingleLineCommentCStyle:
                    tokenContainer.Add(new Token(SqlTokenType.SingleLineCommentCStyle, currentValue.ToString()));
                    break;

                case SqlTokenizationType.SingleHyphen:
                    tokenContainer.Add(new Token(SqlTokenType.OtherOperator, "-"));
                    break;

                case SqlTokenizationType.SingleDollar:
                    tokenContainer.Add(new Token(SqlTokenType.MonetaryValue, "$"));
                    break;

                case SqlTokenizationType.SingleSlash:
                    tokenContainer.Add(new Token(SqlTokenType.OtherOperator, "/"));
                    break;

                case SqlTokenizationType.WhiteSpace:
                    tokenContainer.Add(new Token(SqlTokenType.WhiteSpace, currentValue.ToString()));
                    break;

                case SqlTokenizationType.SingleN:
                    tokenContainer.Add(new Token(SqlTokenType.OtherNode, "N"));
                    break;

                case SqlTokenizationType.SingleExclamation:
                    tokenContainer.Add(new Token(SqlTokenType.OtherNode, "!"));
                    break;

				case SqlTokenizationType.SinglePipe:
					tokenContainer.Add(new Token(SqlTokenType.OtherNode, "|"));
					break;

				case SqlTokenizationType.SingleGT:
					tokenContainer.Add(new Token(SqlTokenType.OtherOperator, ">"));
					break;

				case SqlTokenizationType.SingleLT:
					tokenContainer.Add(new Token(SqlTokenType.OtherOperator, "<"));
					break;

				case SqlTokenizationType.NString:
                    tokenContainer.Add(new Token(SqlTokenType.NationalString, currentValue.ToString()));
                    break;

                case SqlTokenizationType.String:
                    tokenContainer.Add(new Token(SqlTokenType.String, currentValue.ToString()));
                    break;

                case SqlTokenizationType.QuotedString:
                    tokenContainer.Add(new Token(SqlTokenType.QuotedString, currentValue.ToString()));
                    break;

                case SqlTokenizationType.BracketQuotedName:
                    tokenContainer.Add(new Token(SqlTokenType.BracketQuotedName, currentValue.ToString()));
                    break;

                case SqlTokenizationType.OtherOperator:
                case SqlTokenizationType.SingleOtherCompoundableOperator:
                    tokenContainer.Add(new Token(SqlTokenType.OtherOperator, currentValue.ToString()));
                    break;

                case SqlTokenizationType.SingleZero:
                    tokenContainer.Add(new Token(SqlTokenType.Number, "0"));
                    break;

                case SqlTokenizationType.SinglePeriod:
                    tokenContainer.Add(new Token(SqlTokenType.Period, "."));
                    break;

                case SqlTokenizationType.SingleAsterisk:
                    tokenContainer.Add(new Token(SqlTokenType.Asterisk, currentValue.ToString()));
                    break;

                case SqlTokenizationType.SingleEquals:
                    tokenContainer.Add(new Token(SqlTokenType.EqualsSign, currentValue.ToString()));
                    break;

                case SqlTokenizationType.Number:
                case SqlTokenizationType.DecimalValue:
                case SqlTokenizationType.FloatValue:
                    tokenContainer.Add(new Token(SqlTokenType.Number, currentValue.ToString()));
                    break;

                case SqlTokenizationType.BinaryValue:
                    tokenContainer.Add(new Token(SqlTokenType.BinaryValue, currentValue.ToString()));
                    break;

                case SqlTokenizationType.MonetaryValue:
                    tokenContainer.Add(new Token(SqlTokenType.MonetaryValue, currentValue.ToString()));
                    break;


                default:
                    throw new Exception("Unrecognized SQL Node Type");
            }

            currentTokenizationType = null;
        }
Beispiel #2
0
        private static void CompleteToken(ref SqlTokenizationType?currentTokenizationType, ITokenList tokenContainer, StringBuilder currentValue)
        {
            if (currentTokenizationType == null)
            {
                throw new Exception("Cannot complete Token, as there is no current Tokenization Type");
            }

            switch (currentTokenizationType)
            {
            case SqlTokenizationType.BlockComment:
                tokenContainer.Add(new Token(SqlTokenType.MultiLineComment, currentValue.ToString()));
                break;

            case SqlTokenizationType.OtherNode:
                tokenContainer.Add(new Token(SqlTokenType.OtherNode, currentValue.ToString()));
                break;

            case SqlTokenizationType.PseudoName:
                tokenContainer.Add(new Token(SqlTokenType.PseudoName, currentValue.ToString()));
                break;

            case SqlTokenizationType.SingleLineComment:
                tokenContainer.Add(new Token(SqlTokenType.SingleLineComment, currentValue.ToString()));
                break;

            case SqlTokenizationType.SingleHyphen:
                tokenContainer.Add(new Token(SqlTokenType.OtherOperator, "-"));
                break;

            case SqlTokenizationType.SingleDollar:
                tokenContainer.Add(new Token(SqlTokenType.MonetaryValue, "$"));
                break;

            case SqlTokenizationType.SingleSlash:
                tokenContainer.Add(new Token(SqlTokenType.OtherOperator, "/"));
                break;

            case SqlTokenizationType.WhiteSpace:
                tokenContainer.Add(new Token(SqlTokenType.WhiteSpace, currentValue.ToString()));
                break;

            case SqlTokenizationType.SingleN:
                tokenContainer.Add(new Token(SqlTokenType.OtherNode, "N"));
                break;

            case SqlTokenizationType.SingleExclamation:
                tokenContainer.Add(new Token(SqlTokenType.OtherNode, "!"));
                break;

            case SqlTokenizationType.SinglePipe:
                tokenContainer.Add(new Token(SqlTokenType.OtherNode, "|"));
                break;

            case SqlTokenizationType.NString:
                tokenContainer.Add(new Token(SqlTokenType.NationalString, currentValue.ToString()));
                break;

            case SqlTokenizationType.String:
                tokenContainer.Add(new Token(SqlTokenType.String, currentValue.ToString()));
                break;

            case SqlTokenizationType.QuotedString:
                tokenContainer.Add(new Token(SqlTokenType.QuotedString, currentValue.ToString()));
                break;

            case SqlTokenizationType.BracketQuotedName:
                tokenContainer.Add(new Token(SqlTokenType.BracketQuotedName, currentValue.ToString()));
                break;

            case SqlTokenizationType.OtherOperator:
            case SqlTokenizationType.SingleOtherCompoundableOperator:
                tokenContainer.Add(new Token(SqlTokenType.OtherOperator, currentValue.ToString()));
                break;

            case SqlTokenizationType.SingleZero:
                tokenContainer.Add(new Token(SqlTokenType.Number, "0"));
                break;

            case SqlTokenizationType.SinglePeriod:
                tokenContainer.Add(new Token(SqlTokenType.Period, "."));
                break;

            case SqlTokenizationType.SingleAsterisk:
                tokenContainer.Add(new Token(SqlTokenType.Asterisk, currentValue.ToString()));
                break;

            case SqlTokenizationType.Number:
            case SqlTokenizationType.DecimalValue:
            case SqlTokenizationType.FloatValue:
                tokenContainer.Add(new Token(SqlTokenType.Number, currentValue.ToString()));
                break;

            case SqlTokenizationType.BinaryValue:
                tokenContainer.Add(new Token(SqlTokenType.BinaryValue, currentValue.ToString()));
                break;

            case SqlTokenizationType.MonetaryValue:
                tokenContainer.Add(new Token(SqlTokenType.MonetaryValue, currentValue.ToString()));
                break;


            default:
                throw new Exception("Unrecognized SQL Node Type");
            }

            currentTokenizationType = null;
        }
        private static void ProcessOrOpenToken(ref SqlTokenizationType? currentTokenizationType, StringBuilder currentNodeValue, char currentCharacter, ITokenList tokenContainer)
        {

            if (currentTokenizationType != null)
                throw new Exception("Cannot start a new Token: existing Tokenization Type is not null");

            //start a new value.
            currentNodeValue.Length = 0;

            if (IsWhitespace(currentCharacter))
            {
                currentTokenizationType = SqlTokenizationType.WhiteSpace;
                currentNodeValue.Append(currentCharacter);
            }
            else if (currentCharacter == '-')
            {
                currentTokenizationType = SqlTokenizationType.SingleHyphen;
            }
            else if (currentCharacter == '$')
            {
                currentTokenizationType = SqlTokenizationType.SingleDollar;
            }
            else if (currentCharacter == '/')
            {
                currentTokenizationType = SqlTokenizationType.SingleSlash;
            }
            else if (currentCharacter == 'N')
            {
                currentTokenizationType = SqlTokenizationType.SingleN;
            }
            else if (currentCharacter == '\'')
            {
                currentTokenizationType = SqlTokenizationType.String;
            }
            else if (currentCharacter == '"')
            {
                currentTokenizationType = SqlTokenizationType.QuotedString;
            }
            else if (currentCharacter == '[')
            {
                currentTokenizationType = SqlTokenizationType.BracketQuotedName;
            }
            else if (currentCharacter == '(')
            {
                tokenContainer.Add(new Token(SqlTokenType.OpenParens, currentCharacter.ToString()));
            }
            else if (currentCharacter == ')')
            {
                tokenContainer.Add(new Token(SqlTokenType.CloseParens, currentCharacter.ToString()));
            }
            else if (currentCharacter == ',')
            {
                tokenContainer.Add(new Token(SqlTokenType.Comma, currentCharacter.ToString()));
            }
            else if (currentCharacter == '.')
            {
                currentTokenizationType = SqlTokenizationType.SinglePeriod;
            }
            else if (currentCharacter == '0')
            {
                currentTokenizationType = SqlTokenizationType.SingleZero;
            }
            else if (currentCharacter >= '1' && currentCharacter <= '9')
            {
                currentTokenizationType = SqlTokenizationType.Number;
                currentNodeValue.Append(currentCharacter);
            }
            else if (IsCurrencyPrefix(currentCharacter))
            {
                currentTokenizationType = SqlTokenizationType.MonetaryValue;
                currentNodeValue.Append(currentCharacter);
            }
            else if (currentCharacter == ';')
            {
                tokenContainer.Add(new Token(SqlTokenType.Semicolon, currentCharacter.ToString()));
            }
            else if (currentCharacter == ':')
            {
                tokenContainer.Add(new Token(SqlTokenType.Colon, currentCharacter.ToString()));
            }
            else if (currentCharacter == '*')
            {
				currentTokenizationType = SqlTokenizationType.SingleAsterisk;
			}
            else if (currentCharacter == '=')
            {
                currentTokenizationType = SqlTokenizationType.SingleEquals;
            }
            else if (currentCharacter == '<')
            {
                currentTokenizationType = SqlTokenizationType.SingleLT;
            }
            else if (currentCharacter == '>')
            {
                currentTokenizationType = SqlTokenizationType.SingleGT;
            }
            else if (currentCharacter == '!')
            {
                currentTokenizationType = SqlTokenizationType.SingleExclamation;
            }
            else if (currentCharacter == '|')
            {
                currentTokenizationType = SqlTokenizationType.SinglePipe;
            }
            else if (IsCompoundableOperatorCharacter(currentCharacter))
            {
                currentTokenizationType = SqlTokenizationType.SingleOtherCompoundableOperator;
                currentNodeValue.Append(currentCharacter);
            }
            else if (IsOperatorCharacter(currentCharacter))
            {
                tokenContainer.Add(new Token(SqlTokenType.OtherOperator, currentCharacter.ToString()));
            }
            else
            {
                currentTokenizationType = SqlTokenizationType.OtherNode;
                currentNodeValue.Append(currentCharacter);
            }
        }
Beispiel #4
0
        private static void ProcessOrOpenToken(ref SqlTokenizationType?currentTokenizationType, StringBuilder currentNodeValue, char currentCharacter, ITokenList tokenContainer)
        {
            if (currentTokenizationType != null)
            {
                throw new Exception("Cannot start a new Token: existing Tokenization Type is not null");
            }

            //start a new value.
            currentNodeValue.Length = 0;

            if (IsWhitespace(currentCharacter))
            {
                currentTokenizationType = SqlTokenizationType.WhiteSpace;
                currentNodeValue.Append(currentCharacter);
            }
            else if (currentCharacter == '-')
            {
                currentTokenizationType = SqlTokenizationType.SingleHyphen;
            }
            else if (currentCharacter == '$')
            {
                currentTokenizationType = SqlTokenizationType.SingleDollar;
            }
            else if (currentCharacter == '/')
            {
                currentTokenizationType = SqlTokenizationType.SingleSlash;
            }
            else if (currentCharacter == 'N')
            {
                currentTokenizationType = SqlTokenizationType.SingleN;
            }
            else if (currentCharacter == '\'')
            {
                currentTokenizationType = SqlTokenizationType.String;
            }
            else if (currentCharacter == '"')
            {
                currentTokenizationType = SqlTokenizationType.QuotedString;
            }
            else if (currentCharacter == '[')
            {
                currentTokenizationType = SqlTokenizationType.BracketQuotedName;
            }
            else if (currentCharacter == '(')
            {
                tokenContainer.Add(new Token(SqlTokenType.OpenParens, currentCharacter.ToString()));
            }
            else if (currentCharacter == ')')
            {
                tokenContainer.Add(new Token(SqlTokenType.CloseParens, currentCharacter.ToString()));
            }
            else if (currentCharacter == ',')
            {
                tokenContainer.Add(new Token(SqlTokenType.Comma, currentCharacter.ToString()));
            }
            else if (currentCharacter == '.')
            {
                currentTokenizationType = SqlTokenizationType.SinglePeriod;
            }
            else if (currentCharacter == '0')
            {
                currentTokenizationType = SqlTokenizationType.SingleZero;
            }
            else if (currentCharacter >= '1' && currentCharacter <= '9')
            {
                currentTokenizationType = SqlTokenizationType.Number;
                currentNodeValue.Append(currentCharacter);
            }
            else if (IsCurrencyPrefix(currentCharacter))
            {
                currentTokenizationType = SqlTokenizationType.MonetaryValue;
                currentNodeValue.Append(currentCharacter);
            }
            else if (currentCharacter == ';')
            {
                tokenContainer.Add(new Token(SqlTokenType.Semicolon, currentCharacter.ToString()));
            }
            else if (currentCharacter == ':')
            {
                tokenContainer.Add(new Token(SqlTokenType.Colon, currentCharacter.ToString()));
            }
            else if (currentCharacter == '*')
            {
                tokenContainer.Add(new Token(SqlTokenType.Asterisk, currentCharacter.ToString()));
            }
            else if (currentCharacter == '=')
            {
                tokenContainer.Add(new Token(SqlTokenType.EqualsSign, currentCharacter.ToString()));
            }
            else if (currentCharacter == '<')
            {
                currentTokenizationType = SqlTokenizationType.SingleLT;
            }
            else if (currentCharacter == '!')
            {
                currentTokenizationType = SqlTokenizationType.SingleExclamation;
            }
            else if (currentCharacter == '|')
            {
                currentTokenizationType = SqlTokenizationType.SinglePipe;
            }
            else if (IsCompoundableOperatorCharacter(currentCharacter))
            {
                currentTokenizationType = SqlTokenizationType.SingleOtherCompoundableOperator;
                currentNodeValue.Append(currentCharacter);
            }
            else if (IsOperatorCharacter(currentCharacter))
            {
                tokenContainer.Add(new Token(SqlTokenType.OtherOperator, currentCharacter.ToString()));
            }
            else
            {
                currentTokenizationType = SqlTokenizationType.OtherNode;
                currentNodeValue.Append(currentCharacter);
            }
        }