diff options
author | nkozlovskiy <nmk@ydb.tech> | 2023-09-29 12:24:06 +0300 |
---|---|---|
committer | nkozlovskiy <nmk@ydb.tech> | 2023-09-29 12:41:34 +0300 |
commit | e0e3e1717e3d33762ce61950504f9637a6e669ed (patch) | |
tree | bca3ff6939b10ed60c3d5c12439963a1146b9711 /contrib/python/Pygments/py3/pygments/lexers/dax.py | |
parent | 38f2c5852db84c7b4d83adfcb009eb61541d1ccd (diff) | |
download | ydb-e0e3e1717e3d33762ce61950504f9637a6e669ed.tar.gz |
add ydb deps
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/dax.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/lexers/dax.py | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/dax.py b/contrib/python/Pygments/py3/pygments/lexers/dax.py new file mode 100644 index 0000000000..39618c3bb9 --- /dev/null +++ b/contrib/python/Pygments/py3/pygments/lexers/dax.py @@ -0,0 +1,136 @@ +""" + pygments.lexers.dax + ~~~~~~~~~~~~~~~~~~~ + + Lexer for LilyPond. + + :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, words +from pygments.token import Comment, Punctuation, Whitespace,\ + Name, Operator, String, Number, Text + +__all__ = ['DaxLexer'] + + +class DaxLexer(RegexLexer): + """ + Lexer for Power BI DAX + Referenced from: https://github.com/sql-bi/SyntaxHighlighterBrushDax + + .. versionadded:: 2.15 + """ + name = 'Dax' + aliases = ['dax'] + filenames = ['*.dax'] + url = 'https://learn.microsoft.com/en-us/dax/dax-function-reference' + mimetypes = [] + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r"--.*\n?", Comment.Single), # Comment: Double dash comment + (r"//.*\n?", Comment.Single), # Comment: Double backslash comment + (r'/\*', Comment.Multiline, 'multiline-comments'), + (words(('abs', 'accrint', 'accrintm', 'acos', 'acosh', 'acot', 'acoth', + 'addcolumns', 'addmissingitems', 'all', 'allcrossfiltered', + 'allexcept', 'allnoblankrow', 'allselected', 'amordegrc', 'amorlinc', + 'and','approximatedistinctcount', 'asin', 'asinh', 'atan', 'atanh', + 'average', 'averagea', 'averagex', 'beta.dist', 'beta.inv', + 'bitand', 'bitlshift', 'bitor', 'bitrshift', 'bitxor', 'blank', + 'calculate', 'calculatetable', 'calendar', 'calendarauto', 'ceiling', + 'chisq.dist', 'chisq.dist.rt', 'chisq.inv', 'chisq.inv.rt', + 'closingbalancemonth', 'closingbalancequarter', 'closingbalanceyear', + 'coalesce', 'columnstatistics', 'combin', 'combina', 'combinevalues', + 'concatenate', 'concatenatex', 'confidence.norm', 'confidence.t', + 'contains', 'containsrow', 'containsstring', 'containsstringexact', + 'convert', 'cos', 'cosh', 'cot', 'coth', 'count', 'counta', 'countax', + 'countblank', 'countrows', 'countx', 'coupdaybs', 'coupdays', + 'coupdaysnc', 'coupncd', 'coupnum', 'couppcd', 'crossfilter', + 'crossjoin', 'cumipmt', 'cumprinc', 'currency', 'currentgroup', + 'customdata', 'datatable', 'date', 'dateadd', 'datediff', + 'datesbetween', 'datesinperiod', 'datesmtd', 'datesqtd', + 'datesytd', 'datevalue', 'day', 'db', 'ddb', 'degrees', 'detailrows', + 'disc', 'distinct', 'distinctcount', 'distinctcountnoblank', + 'divide', 'dollarde', 'dollarfr', 'duration', 'earlier', 'earliest', + 'edate', 'effect', 'endofmonth', 'endofquarter', 'endofyear', + 'eomonth', 'error', 'evaluateandlog', 'even', 'exact', 'except', + 'exp', 'expon.dist', 'fact', 'false', 'filter', 'filters', 'find', + 'firstdate', 'firstnonblank', 'firstnonblankvalue', 'fixed', 'floor', + 'format', 'fv', 'gcd', 'generate', 'generateall', 'generateseries', + 'geomean', 'geomeanx', 'groupby', 'hash', 'hasonefilter', + 'hasonevalue', 'hour', 'if', 'if.eager', 'iferror', 'ignore', 'index', + 'int', 'intersect', 'intrate', 'ipmt', 'isafter', 'isblank', + 'iscrossfiltered', 'isempty', 'iserror', 'iseven', 'isfiltered', + 'isinscope', 'islogical', 'isnontext', 'isnumber', 'iso.ceiling', + 'isodd', 'isonorafter', 'ispmt', 'isselectedmeasure', 'issubtotal', + 'istext', 'keepfilters', 'keywordmatch', 'lastdate', 'lastnonblank', + 'lastnonblankvalue', 'lcm', 'left', 'len', 'linest', 'linestx', 'ln', + 'log', 'log10', 'lookupvalue', 'lower', 'max', 'maxa', 'maxx', + 'mduration', 'median', 'medianx', 'mid', 'min', 'mina', 'minute', + 'minx', 'mod', 'month', 'mround', 'nameof', 'naturalinnerjoin', + 'naturalleftouterjoin', 'networkdays', 'nextday', 'nextmonth', + 'nextquarter', 'nextyear', 'nominal', 'nonvisual', 'norm.dist', + 'norm.inv', 'norm.s.dist', 'norm.s.inv', 'not', 'now', 'nper', 'odd', + 'oddfprice', 'oddfyield', 'oddlprice', 'oddlyield', 'offset', + 'openingbalancemonth', 'openingbalancequarter', 'openingbalanceyear', + 'or', 'orderby', 'parallelperiod', 'partitionby', 'path', + 'pathcontains', 'pathitem', 'pathitemreverse', 'pathlength', + 'pduration', 'percentile.exc', 'percentile.inc', 'percentilex.exc', + 'percentilex.inc', 'permut', 'pi', 'pmt', 'poisson.dist', 'power', + 'ppmt', 'previousday', 'previousmonth', 'previousquarter', + 'previousyear', 'price', 'pricedisc', 'pricemat', 'product', + 'productx', 'pv', 'quarter', 'quotient', 'radians', 'rand', + 'randbetween', 'rank.eq', 'rankx', 'rate', 'received', 'related', + 'relatedtable', 'removefilters', 'replace', 'rept', 'right', + 'rollup', 'rollupaddissubtotal', 'rollupgroup', 'rollupissubtotal', + 'round', 'rounddown', 'roundup', 'row', 'rri', 'sameperiodlastyear', + 'sample', 'sampleaxiswithlocalminmax', 'search', 'second', + 'selectcolumns', 'selectedmeasure', 'selectedmeasureformatstring', + 'selectedmeasurename', 'selectedvalue', 'sign', 'sin', 'sinh', 'sln', + 'sqrt', 'sqrtpi', 'startofmonth', 'startofquarter', 'startofyear', + 'stdev.p', 'stdev.s', 'stdevx.p', 'stdevx.s', 'substitute', + 'substitutewithindex', 'sum', 'summarize', 'summarizecolumns', 'sumx', + 'switch', 'syd', 't.dist', 't.dist.2t', 't.dist.rt', 't.inv', + 't.inv.2t', 'tan', 'tanh', 'tbilleq', 'tbillprice', 'tbillyield', + 'time', 'timevalue', 'tocsv', 'today', 'tojson', 'topn', + 'topnperlevel', 'topnskip', 'totalmtd', 'totalqtd', 'totalytd', + 'treatas', 'trim', 'true', 'trunc', 'unichar', 'unicode', 'union', + 'upper', 'userculture', 'userelationship', 'username', 'userobjectid', + 'userprincipalname', 'utcnow', 'utctoday', 'value', 'values', 'var.p', + 'var.s', 'varx.p', 'varx.s', 'vdb', 'weekday', 'weeknum', 'window', + 'xirr', 'xnpv', 'year', 'yearfrac', 'yield', 'yielddisc', 'yieldmat'), + prefix=r'(?i)', suffix=r'\b'), Name.Function), #Functions + + (words(('at','asc','boolean','both','by','create','currency', + 'datetime','day','define','desc','double', + 'evaluate','false','integer','measure', + 'month','none','order','return','single','start','string', + 'table','true','var','year'), + prefix=r'(?i)', suffix=r'\b'), Name.Builtin), # Keyword + + (r':=|[-+*\/=^]', Operator), + (r'\b(IN|NOT)\b', Operator.Word), + (r'"', String, 'string'), #StringLiteral + (r"'(?:[^']|'')*'(?!')(?:\[[ \w]+\])?|\w+\[[ \w]+\]", + Name.Attribute), # Column reference + (r"\[[ \w]+\]", Name.Attribute), #Measure reference + (r'(?<!\w)(\d+\.?\d*|\.\d+\b)', Number),# Number + (r'[\[\](){}`,.]', Punctuation), #Parenthesis + (r'.*\n', Text), + + ], + 'multiline-comments': [ + (r'/\*', Comment.Multiline, 'multiline-comments'), + (r'\*/', Comment.Multiline, '#pop'), + (r'[^/*]+', Comment.Multiline), + (r'[/*]', Comment.Multiline) + ], + 'string': [ + (r'""', String.Escape), + (r'"', String, '#pop'), + (r'[^"]+', String), + ] + } |