示例#1
0
        private static void Initialize()
        {
            _baseReservedKeywords.Add("AND", LexicalComponent.CreateReservedKeyword(Category.And, "AND"));
            _baseReservedKeywords.Add("OR", LexicalComponent.CreateReservedKeyword(Category.Or, "OR"));
            _baseReservedKeywords.Add("ORDER BY", LexicalComponent.CreateReservedKeyword(Category.Order_by, "ORDER BY"));
            _baseReservedKeywords.Add("ASC", LexicalComponent.CreateReservedKeyword(Category.Asc, "ASC"));
            _baseReservedKeywords.Add("DESC", LexicalComponent.CreateReservedKeyword(Category.Desc, "DESC"));
            _baseReservedKeywords.Add("FROM", LexicalComponent.CreateReservedKeyword(Category.From, "FROM"));
            _baseReservedKeywords.Add("WHERE", LexicalComponent.CreateReservedKeyword(Category.Where, "WHERE"));
            _baseReservedKeywords.Add("SELECT", LexicalComponent.CreateReservedKeyword(Category.Select, "SELECT"));

            _tableInitialized = true;
        }
示例#2
0
        public static LexicalComponent CheckReservedKeyword(LexicalComponent component)
        {
            if (!_tableInitialized)
            {
                Initialize();
            }

            if (_baseReservedKeywords.ContainsKey(component?.Lexeme?.ToUpper()) && component.Category == Category.Identifier)
            {
                return(LexicalComponent.CreateReservedKeyword(
                           _baseReservedKeywords[component.Lexeme.ToUpper()].Category,
                           component.Lexeme,
                           component.LineNumber,
                           component.InitialPosition,
                           component.FinalPosition));
            }

            return(component);
        }