Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
tokens.py72 linesDownload Raw Back to sqlparse
1#2# Copyright (C) 2009-2020 the sqlparse authors and contributors3# <see AUTHORS file>4#5# This module is part of python-sqlparse and is released under6# the BSD License: https://opensource.org/licenses/BSD-3-Clause7#8# The Token implementation is based on pygment's token system written9# by Georg Brandl.10# http://pygments.org/11 12"""Tokens"""13 14 15class _TokenType(tuple):16    parent = None17 18    def __contains__(self, item):19        return item is not None and (self is item or item[:len(self)] == self)20 21    def __getattr__(self, name):22        # don't mess with dunder23        if name.startswith('__'):24            return super().__getattr__(self, name)25        new = _TokenType(self + (name,))26        setattr(self, name, new)27        new.parent = self28        return new29 30    def __repr__(self):31        # self can be False only if its the `root` i.e. Token itself32        return 'Token' + ('.' if self else '') + '.'.join(self)33 34 35Token = _TokenType()36 37# Special token types38Text = Token.Text39Whitespace = Text.Whitespace40Newline = Whitespace.Newline41Error = Token.Error42# Text that doesn't belong to this lexer (e.g. HTML in PHP)43Other = Token.Other44 45# Common token types for source code46Keyword = Token.Keyword47Name = Token.Name48Literal = Token.Literal49String = Literal.String50Number = Literal.Number51Punctuation = Token.Punctuation52Operator = Token.Operator53Comparison = Operator.Comparison54Wildcard = Token.Wildcard55Comment = Token.Comment56Assignment = Token.Assignment57 58# Generic types for non-source code59Generic = Token.Generic60Command = Generic.Command61 62# String and some others are not direct children of Token.63# alias them:64Token.Token = Token65Token.String = String66Token.Number = Number67 68# SQL specific tokens69DML = Keyword.DML70DDL = Keyword.DDL71CTE = Keyword.CTE72 
codekingpro/portable-devtools · Team Ai