Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
dax.py136 linesDownload Raw Back to lexers
1"""2    pygments.lexers.dax3    ~~~~~~~~~~~~~~~~~~~4 5    Lexer for LilyPond.6 7    :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.8    :license: BSD, see LICENSE for details.9"""10 11from pygments.lexer import RegexLexer, words12from pygments.token import Comment, Punctuation, Whitespace,\13    Name, Operator, String, Number, Text14 15__all__ = ['DaxLexer']16 17 18class DaxLexer(RegexLexer):19    """20    Lexer for Power BI DAX21    Referenced from: https://github.com/sql-bi/SyntaxHighlighterBrushDax22    """23    name = 'Dax'24    aliases = ['dax']25    filenames = ['*.dax']26    url = 'https://learn.microsoft.com/en-us/dax/dax-function-reference'27    mimetypes = []28    version_added = '2.15'29 30    tokens = {31        'root': [32            (r'\s+', Whitespace),33            (r"--.*\n?", Comment.Single),	# Comment: Double dash comment34            (r"//.*\n?", Comment.Single),	# Comment: Double backslash comment35            (r'/\*', Comment.Multiline, 'multiline-comments'),36            (words(('abs', 'accrint', 'accrintm', 'acos', 'acosh', 'acot', 'acoth',37                    'addcolumns', 'addmissingitems', 'all', 'allcrossfiltered',38                    'allexcept', 'allnoblankrow', 'allselected', 'amordegrc', 'amorlinc',39                    'and','approximatedistinctcount', 'asin', 'asinh', 'atan', 'atanh',40                    'average', 'averagea', 'averagex', 'beta.dist', 'beta.inv',41                    'bitand', 'bitlshift', 'bitor', 'bitrshift', 'bitxor', 'blank',42                    'calculate', 'calculatetable', 'calendar', 'calendarauto', 'ceiling',43                    'chisq.dist', 'chisq.dist.rt', 'chisq.inv', 'chisq.inv.rt',44                    'closingbalancemonth', 'closingbalancequarter', 'closingbalanceyear',45                    'coalesce', 'columnstatistics', 'combin', 'combina', 'combinevalues',46                    'concatenate', 'concatenatex', 'confidence.norm', 'confidence.t',47                    'contains', 'containsrow', 'containsstring', 'containsstringexact',48                    'convert', 'cos', 'cosh', 'cot', 'coth', 'count', 'counta', 'countax',49                    'countblank', 'countrows', 'countx', 'coupdaybs', 'coupdays',50                    'coupdaysnc', 'coupncd', 'coupnum', 'couppcd', 'crossfilter',51                    'crossjoin', 'cumipmt', 'cumprinc', 'currency', 'currentgroup',52                    'customdata', 'datatable', 'date', 'dateadd', 'datediff',53                    'datesbetween', 'datesinperiod', 'datesmtd', 'datesqtd',54                    'datesytd', 'datevalue', 'day', 'db', 'ddb', 'degrees', 'detailrows',55                    'disc', 'distinct', 'distinctcount', 'distinctcountnoblank',56                    'divide', 'dollarde', 'dollarfr', 'duration', 'earlier', 'earliest',57                    'edate', 'effect', 'endofmonth', 'endofquarter', 'endofyear',58                    'eomonth', 'error', 'evaluateandlog', 'even', 'exact', 'except',59                    'exp', 'expon.dist', 'fact', 'false', 'filter', 'filters', 'find',60                    'firstdate', 'firstnonblank', 'firstnonblankvalue', 'fixed', 'floor',61                    'format', 'fv', 'gcd', 'generate', 'generateall', 'generateseries',62                    'geomean', 'geomeanx', 'groupby', 'hash', 'hasonefilter',63                    'hasonevalue', 'hour', 'if', 'if.eager', 'iferror', 'ignore', 'index',64                    'int', 'intersect', 'intrate', 'ipmt', 'isafter', 'isblank',65                    'iscrossfiltered', 'isempty', 'iserror', 'iseven', 'isfiltered',66                    'isinscope', 'islogical', 'isnontext', 'isnumber', 'iso.ceiling',67                    'isodd', 'isonorafter', 'ispmt', 'isselectedmeasure', 'issubtotal',68                    'istext', 'keepfilters', 'keywordmatch', 'lastdate', 'lastnonblank',69                    'lastnonblankvalue', 'lcm', 'left', 'len', 'linest', 'linestx', 'ln',70                    'log', 'log10', 'lookupvalue', 'lower', 'max', 'maxa', 'maxx',71                    'mduration', 'median', 'medianx', 'mid', 'min', 'mina', 'minute',72                    'minx', 'mod', 'month', 'mround', 'nameof', 'naturalinnerjoin',73                    'naturalleftouterjoin', 'networkdays', 'nextday', 'nextmonth',74                    'nextquarter', 'nextyear', 'nominal', 'nonvisual', 'norm.dist',75                    'norm.inv', 'norm.s.dist', 'norm.s.inv', 'not', 'now', 'nper', 'odd',76                    'oddfprice', 'oddfyield', 'oddlprice', 'oddlyield', 'offset',77                    'openingbalancemonth', 'openingbalancequarter', 'openingbalanceyear',78                    'or', 'orderby', 'parallelperiod', 'partitionby', 'path',79                    'pathcontains', 'pathitem', 'pathitemreverse', 'pathlength',80                    'pduration', 'percentile.exc', 'percentile.inc', 'percentilex.exc',81                    'percentilex.inc', 'permut', 'pi', 'pmt', 'poisson.dist', 'power',82                    'ppmt', 'previousday', 'previousmonth', 'previousquarter',83                    'previousyear', 'price', 'pricedisc', 'pricemat', 'product',84                    'productx', 'pv', 'quarter', 'quotient', 'radians', 'rand',85                    'randbetween', 'rank.eq', 'rankx', 'rate', 'received', 'related',86                    'relatedtable', 'removefilters', 'replace', 'rept', 'right',87                    'rollup', 'rollupaddissubtotal', 'rollupgroup', 'rollupissubtotal',88                    'round', 'rounddown', 'roundup', 'row', 'rri', 'sameperiodlastyear',89                    'sample', 'sampleaxiswithlocalminmax', 'search', 'second',90                    'selectcolumns', 'selectedmeasure', 'selectedmeasureformatstring',91                    'selectedmeasurename', 'selectedvalue', 'sign', 'sin', 'sinh', 'sln',92                    'sqrt', 'sqrtpi', 'startofmonth', 'startofquarter', 'startofyear',93                    'stdev.p', 'stdev.s', 'stdevx.p', 'stdevx.s', 'substitute',94                    'substitutewithindex', 'sum', 'summarize', 'summarizecolumns', 'sumx',95                    'switch', 'syd', 't.dist', 't.dist.2t', 't.dist.rt', 't.inv',96                    't.inv.2t', 'tan', 'tanh', 'tbilleq', 'tbillprice', 'tbillyield',97                    'time', 'timevalue', 'tocsv', 'today', 'tojson', 'topn',98                    'topnperlevel', 'topnskip', 'totalmtd', 'totalqtd', 'totalytd',99                    'treatas', 'trim', 'true', 'trunc', 'unichar', 'unicode', 'union',100                    'upper', 'userculture', 'userelationship', 'username', 'userobjectid',101                    'userprincipalname', 'utcnow', 'utctoday', 'value', 'values', 'var.p',102                    'var.s', 'varx.p', 'varx.s', 'vdb', 'weekday', 'weeknum', 'window',103                    'xirr', 'xnpv', 'year', 'yearfrac', 'yield', 'yielddisc', 'yieldmat'),104                 prefix=r'(?i)', suffix=r'\b'), Name.Function), #Functions105 106            (words(('at','asc','boolean','both','by','create','currency',107                'datetime','day','define','desc','double',108                'evaluate','false','integer','measure',109                'month','none','order','return','single','start','string',110                'table','true','var','year'),111                prefix=r'(?i)', suffix=r'\b'), Name.Builtin), # Keyword112 113            (r':=|[-+*\/=^]', Operator),114            (r'\b(IN|NOT)\b', Operator.Word),115            (r'"', String, 'string'), #StringLiteral116            (r"'(?:[^']|'')*'(?!')(?:\[[ \w]+\])?|\w+\[[ \w]+\]",117                Name.Attribute),	# Column reference118            (r"\[[ \w]+\]", Name.Attribute), #Measure reference119            (r'(?<!\w)(\d+\.?\d*|\.\d+\b)', Number),# Number120            (r'[\[\](){}`,.]', Punctuation), #Parenthesis121            (r'.*\n', Text),122 123        ],124        'multiline-comments': [125            (r'/\*', Comment.Multiline, 'multiline-comments'),126            (r'\*/', Comment.Multiline, '#pop'),127            (r'[^/*]+', Comment.Multiline),128            (r'[/*]', Comment.Multiline)129        ],130        'string': [131            (r'""', String.Escape),132            (r'"', String, '#pop'),133            (r'[^"]+', String),134        ]135    }136 
codekingpro/portable-devtools · Team Ai