diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/agile.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/agile.py new file mode 100644 index 0000000000000000000000000000000000000000..ac88cf67907214cdb5c8dc5bf55376678d95a218 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/agile.py @@ -0,0 +1,25 @@ +""" + pygments.lexers.agile + ~~~~~~~~~~~~~~~~~~~~~ + + Just export lexer classes previously contained in this module. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +# ruff: noqa: F401 + +from pygments.lexers.lisp import SchemeLexer +from pygments.lexers.jvm import IokeLexer, ClojureLexer +from pygments.lexers.python import PythonLexer, PythonConsoleLexer, \ + PythonTracebackLexer, Python3Lexer, Python3TracebackLexer, DgLexer +from pygments.lexers.ruby import RubyLexer, RubyConsoleLexer, FancyLexer +from pygments.lexers.perl import PerlLexer, Perl6Lexer +from pygments.lexers.d import CrocLexer, MiniDLexer +from pygments.lexers.iolang import IoLexer +from pygments.lexers.tcl import TclLexer +from pygments.lexers.factor import FactorLexer +from pygments.lexers.scripting import LuaLexer, MoonScriptLexer + +__all__ = [] diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/algebra.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/algebra.py new file mode 100644 index 0000000000000000000000000000000000000000..06fa404a218c5beafd9e6f8f74dd5c4a27198928 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/algebra.py @@ -0,0 +1,303 @@ +""" + pygments.lexers.algebra + ~~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for computer algebra systems. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import Lexer, RegexLexer, bygroups, do_insertions, words +from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Generic, Whitespace + +__all__ = ['GAPLexer', 'GAPConsoleLexer', 'MathematicaLexer', 'MuPADLexer', + 'BCLexer'] + + +class GAPLexer(RegexLexer): + """ + For GAP source code. + """ + name = 'GAP' + url = 'https://www.gap-system.org' + aliases = ['gap'] + filenames = ['*.g', '*.gd', '*.gi', '*.gap'] + version_added = '2.0' + + tokens = { + 'root': [ + (r'#.*$', Comment.Single), + (r'"(?:[^"\\]|\\.)*"', String), + (r'\(|\)|\[|\]|\{|\}', Punctuation), + (r'''(?x)\b(?: + if|then|elif|else|fi| + for|while|do|od| + repeat|until| + break|continue| + function|local|return|end| + rec| + quit|QUIT| + IsBound|Unbind| + TryNextMethod| + Info|Assert + )\b''', Keyword), + (r'''(?x)\b(?: + true|false|fail|infinity + )\b''', + Name.Constant), + (r'''(?x)\b(?: + (Declare|Install)([A-Z][A-Za-z]+)| + BindGlobal|BIND_GLOBAL + )\b''', + Name.Builtin), + (r'\.|,|:=|;|=|\+|-|\*|/|\^|>|<', Operator), + (r'''(?x)\b(?: + and|or|not|mod|in + )\b''', + Operator.Word), + (r'''(?x) + (?:\w+|`[^`]*`) + (?:::\w+|`[^`]*`)*''', Name.Variable), + (r'[0-9]+(?:\.[0-9]*)?(?:e[0-9]+)?', Number), + (r'\.[0-9]+(?:e[0-9]+)?', Number), + (r'.', Text) + ], + } + + def analyse_text(text): + score = 0.0 + + # Declaration part + if re.search( + r"(InstallTrueMethod|Declare(Attribute|Category|Filter|Operation" + + r"|GlobalFunction|Synonym|SynonymAttr|Property))", text + ): + score += 0.7 + + # Implementation part + if re.search( + r"(DeclareRepresentation|Install(GlobalFunction|Method|" + + r"ImmediateMethod|OtherMethod)|New(Family|Type)|Objectify)", text + ): + score += 0.7 + + return min(score, 1.0) + + +class GAPConsoleLexer(Lexer): + """ + For GAP console sessions. Modeled after JuliaConsoleLexer. + """ + name = 'GAP session' + aliases = ['gap-console', 'gap-repl'] + filenames = ['*.tst'] + url = 'https://www.gap-system.org' + version_added = '2.14' + _example = "gap-repl/euclidean.tst" + + def get_tokens_unprocessed(self, text): + gaplexer = GAPLexer(**self.options) + start = 0 + curcode = '' + insertions = [] + output = False + error = False + + for line in text.splitlines(keepends=True): + if line.startswith('gap> ') or line.startswith('brk> '): + insertions.append((len(curcode), [(0, Generic.Prompt, line[:5])])) + curcode += line[5:] + output = False + error = False + elif not output and line.startswith('> '): + insertions.append((len(curcode), [(0, Generic.Prompt, line[:2])])) + curcode += line[2:] + else: + if curcode: + yield from do_insertions( + insertions, gaplexer.get_tokens_unprocessed(curcode)) + curcode = '' + insertions = [] + if line.startswith('Error, ') or error: + yield start, Generic.Error, line + error = True + else: + yield start, Generic.Output, line + output = True + start += len(line) + + if curcode: + yield from do_insertions( + insertions, gaplexer.get_tokens_unprocessed(curcode)) + + # the following is needed to distinguish Scilab and GAP .tst files + def analyse_text(text): + # GAP prompts are a dead give away, although hypothetical;y a + # file in another language could be trying to compare a variable + # "gap" as in "gap> 0.1". But that this should happen at the + # start of a line seems unlikely... + if re.search(r"^gap> ", text): + return 0.9 + else: + return 0.0 + + +class MathematicaLexer(RegexLexer): + """ + Lexer for Mathematica source code. + """ + name = 'Mathematica' + url = 'https://www.wolfram.com/language/' + aliases = ['mathematica', 'mma', 'nb', 'wl', 'wolfram'] + filenames = ['*.nb', '*.cdf', '*.nbp', '*.ma', '*.wl', '*.wls'] + mimetypes = ['application/mathematica', + 'application/vnd.wolfram.mathematica', + 'application/vnd.wolfram.mathematica.package', + 'application/vnd.wolfram.cdf', + 'application/vnd.wolfram.wl'] + version_added = '2.0' + + # https://reference.wolfram.com/language/guide/Syntax.html + operators = ( + ";;", "=", "=.", "!=" "==", ":=", "->", ":>", "/.", "+", "-", "*", "/", + "^", "&&", "||", "!", "<>", "|", "/;", "?", "@", "//", "/@", "@@", + "@@@", "~~", "===", "&", "<", ">", "<=", ">=", + ) + + punctuation = (",", ";", "(", ")", "[", "]", "{", "}") + + def _multi_escape(entries): + return '({})'.format('|'.join(re.escape(entry) for entry in entries)) + + tokens = { + 'root': [ + (r'(?s)\(\*.*?\*\)', Comment), + + # Named character escapes, e.g. \[Nu], \[CapitalAlpha]. + (r'\\\[[A-Za-z][A-Za-z0-9]*\]', String.Escape), + + (r'([a-zA-Z]+[A-Za-z0-9]*`)', Name.Namespace), + (r'([A-Za-z0-9]*_+[A-Za-z0-9]*)', Name.Variable), + (r'#\d*', Name.Variable), + (r'([a-zA-Z]+[a-zA-Z0-9]*)', Name), + + (r'-?\d+\.\d*', Number.Float), + (r'-?\d*\.\d+', Number.Float), + (r'-?\d+', Number.Integer), + + (words(operators), Operator), + (words(punctuation), Punctuation), + (r'".*?"', String), + (r'\s+', Text.Whitespace), + ], + } + + +class MuPADLexer(RegexLexer): + """ + A MuPAD lexer. + Contributed by Christopher Creutzig . + """ + name = 'MuPAD' + url = 'http://www.mupad.com' + aliases = ['mupad'] + filenames = ['*.mu'] + version_added = '0.8' + + tokens = { + 'root': [ + (r'//.*?$', Comment.Single), + (r'/\*', Comment.Multiline, 'comment'), + (r'"(?:[^"\\]|\\.)*"', String), + (r'\(|\)|\[|\]|\{|\}', Punctuation), + (r'''(?x)\b(?: + next|break|end| + axiom|end_axiom|category|end_category|domain|end_domain|inherits| + if|%if|then|elif|else|end_if| + case|of|do|otherwise|end_case| + while|end_while| + repeat|until|end_repeat| + for|from|to|downto|step|end_for| + proc|local|option|save|begin|end_proc| + delete|frame + )\b''', Keyword), + (r'''(?x)\b(?: + DOM_ARRAY|DOM_BOOL|DOM_COMPLEX|DOM_DOMAIN|DOM_EXEC|DOM_EXPR| + DOM_FAIL|DOM_FLOAT|DOM_FRAME|DOM_FUNC_ENV|DOM_HFARRAY|DOM_IDENT| + DOM_INT|DOM_INTERVAL|DOM_LIST|DOM_NIL|DOM_NULL|DOM_POLY|DOM_PROC| + DOM_PROC_ENV|DOM_RAT|DOM_SET|DOM_STRING|DOM_TABLE|DOM_VAR + )\b''', Name.Class), + (r'''(?x)\b(?: + PI|EULER|E|CATALAN| + NIL|FAIL|undefined|infinity| + TRUE|FALSE|UNKNOWN + )\b''', + Name.Constant), + (r'\b(?:dom|procname)\b', Name.Builtin.Pseudo), + (r'\.|,|:|;|=|\+|-|\*|/|\^|@|>|<|\$|\||!|\'|%|~=', Operator), + (r'''(?x)\b(?: + and|or|not|xor| + assuming| + div|mod| + union|minus|intersect|in|subset + )\b''', + Operator.Word), + (r'\b(?:I|RDN_INF|RD_NINF|RD_NAN)\b', Number), + # (r'\b(?:adt|linalg|newDomain|hold)\b', Name.Builtin), + (r'''(?x) + ((?:[a-zA-Z_#][\w#]*|`[^`]*`) + (?:::[a-zA-Z_#][\w#]*|`[^`]*`)*)(\s*)([(])''', + bygroups(Name.Function, Text, Punctuation)), + (r'''(?x) + (?:[a-zA-Z_#][\w#]*|`[^`]*`) + (?:::[a-zA-Z_#][\w#]*|`[^`]*`)*''', Name.Variable), + (r'[0-9]+(?:\.[0-9]*)?(?:e[0-9]+)?', Number), + (r'\.[0-9]+(?:e[0-9]+)?', Number), + (r'\s+', Whitespace), + (r'.', Text) + ], + 'comment': [ + (r'[^/*]+', Comment.Multiline), + (r'/\*', Comment.Multiline, '#push'), + (r'\*/', Comment.Multiline, '#pop'), + (r'[*/]', Comment.Multiline) + ], + } + + +class BCLexer(RegexLexer): + """ + A BC lexer. + """ + name = 'BC' + url = 'https://www.gnu.org/software/bc/' + aliases = ['bc'] + filenames = ['*.bc'] + version_added = '2.1' + + tokens = { + 'root': [ + (r'/\*', Comment.Multiline, 'comment'), + (r'"(?:[^"\\]|\\.)*"', String), + (r'[{}();,]', Punctuation), + (words(('if', 'else', 'while', 'for', 'break', 'continue', + 'halt', 'return', 'define', 'auto', 'print', 'read', + 'length', 'scale', 'sqrt', 'limits', 'quit', + 'warranty'), suffix=r'\b'), Keyword), + (r'\+\+|--|\|\||&&|' + r'([-<>+*%\^/!=])=?', Operator), + # bc doesn't support exponential + (r'[0-9]+(\.[0-9]*)?', Number), + (r'\.[0-9]+', Number), + (r'.', Text) + ], + 'comment': [ + (r'[^*/]+', Comment.Multiline), + (r'\*/', Comment.Multiline, '#pop'), + (r'[*/]', Comment.Multiline) + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/ambient.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/ambient.py new file mode 100644 index 0000000000000000000000000000000000000000..2da64d12d63c594d75e20e57a3131b45f8adf00c --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/ambient.py @@ -0,0 +1,75 @@ +""" + pygments.lexers.ambient + ~~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for AmbientTalk language. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, include, words, bygroups +from pygments.token import Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace + +__all__ = ['AmbientTalkLexer'] + + +class AmbientTalkLexer(RegexLexer): + """ + Lexer for AmbientTalk source code. + """ + name = 'AmbientTalk' + url = 'https://code.google.com/p/ambienttalk' + filenames = ['*.at'] + aliases = ['ambienttalk', 'ambienttalk/2', 'at'] + mimetypes = ['text/x-ambienttalk'] + version_added = '2.0' + + flags = re.MULTILINE | re.DOTALL + + builtin = words(('if:', 'then:', 'else:', 'when:', 'whenever:', 'discovered:', + 'disconnected:', 'reconnected:', 'takenOffline:', 'becomes:', + 'export:', 'as:', 'object:', 'actor:', 'mirror:', 'taggedAs:', + 'mirroredBy:', 'is:')) + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'//.*?\n', Comment.Single), + (r'/\*.*?\*/', Comment.Multiline), + (r'(def|deftype|import|alias|exclude)\b', Keyword), + (builtin, Name.Builtin), + (r'(true|false|nil)\b', Keyword.Constant), + (r'(~|lobby|jlobby|/)\.', Keyword.Constant, 'namespace'), + (r'"(\\\\|\\[^\\]|[^"\\])*"', String), + (r'\|', Punctuation, 'arglist'), + (r'<:|[*^!%&<>+=,./?-]|:=', Operator), + (r"`[a-zA-Z_]\w*", String.Symbol), + (r"[a-zA-Z_]\w*:", Name.Function), + (r"[{}()\[\];`]", Punctuation), + (r'(self|super)\b', Name.Variable.Instance), + (r"[a-zA-Z_]\w*", Name.Variable), + (r"@[a-zA-Z_]\w*", Name.Class), + (r"@\[", Name.Class, 'annotations'), + include('numbers'), + ], + 'numbers': [ + (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), + (r'\d+', Number.Integer) + ], + 'namespace': [ + (r'[a-zA-Z_]\w*\.', Name.Namespace), + (r'[a-zA-Z_]\w*:', Name.Function, '#pop'), + (r'[a-zA-Z_]\w*(?!\.)', Name.Function, '#pop') + ], + 'annotations': [ + (r"(.*?)\]", Name.Class, '#pop') + ], + 'arglist': [ + (r'\|', Punctuation, '#pop'), + (r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace)), + (r'[a-zA-Z_]\w*', Name.Variable), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/amdgpu.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/amdgpu.py new file mode 100644 index 0000000000000000000000000000000000000000..0d8c98896581e9bb7fc8e581b15b583ac7fb5c67 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/amdgpu.py @@ -0,0 +1,54 @@ +""" + pygments.lexers.amdgpu + ~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for the AMDGPU ISA assembly. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, words +from pygments.token import Name, Text, Keyword, Whitespace, Number, Comment + +import re + +__all__ = ['AMDGPULexer'] + + +class AMDGPULexer(RegexLexer): + """ + For AMD GPU assembly. + """ + name = 'AMDGPU' + aliases = ['amdgpu'] + filenames = ['*.isa'] + url = 'https://gpuopen.com/amd-isa-documentation' + version_added = '2.8' + + flags = re.IGNORECASE + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'[\r\n]+', Text), + (r'(([a-z_0-9])*:([a-z_0-9])*)', Name.Attribute), + (r'(\[|\]|\(|\)|,|\:|\&)', Text), + (r'([;#]|//).*?\n', Comment.Single), + (r'((s_)?(scratch|ds|buffer|flat|image)_[a-z0-9_]+)', Keyword.Reserved), + (r'(_lo|_hi)', Name.Variable), + (r'(vmcnt|lgkmcnt|expcnt)', Name.Attribute), + (r'(attr[0-9].[a-z])', Name.Attribute), + (words(( + 'op', 'vaddr', 'vdata', 'off', 'soffset', 'srsrc', 'format', + 'offset', 'offen', 'idxen', 'glc', 'dlc', 'slc', 'tfe', 'lds', + 'lit', 'unorm'), suffix=r'\b'), Name.Attribute), + (r'(label_[a-z0-9]+)', Keyword), + (r'(_L[0-9]*)', Name.Variable), + (r'[sv]_[a-z0-9_]+', Keyword), + (r'(v[0-9.]+|vcc|exec|v)', Name.Variable), + (r's[0-9.]+|s', Name.Variable), + (r'[0-9]+\.[^0-9]+', Number.Float), + (r'(0[xX][a-z0-9]+)|([0-9]+)', Number.Integer) + ] + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/ampl.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/ampl.py new file mode 100644 index 0000000000000000000000000000000000000000..bb5ba26807f6386db0cdc3c0e57c7d75096ee8c6 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/ampl.py @@ -0,0 +1,87 @@ +""" + pygments.lexers.ampl + ~~~~~~~~~~~~~~~~~~~~ + + Lexers for the AMPL language. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, bygroups, using, this, words +from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace + +__all__ = ['AmplLexer'] + + +class AmplLexer(RegexLexer): + """ + For AMPL source code. + """ + name = 'Ampl' + url = 'http://ampl.com/' + aliases = ['ampl'] + filenames = ['*.run'] + version_added = '2.2' + + tokens = { + 'root': [ + (r'\n', Text), + (r'\s+', Whitespace), + (r'#.*?\n', Comment.Single), + (r'/[*][\s\S]*?[*]/', Comment.Multiline), + (words(( + 'call', 'cd', 'close', 'commands', 'data', 'delete', 'display', + 'drop', 'end', 'environ', 'exit', 'expand', 'include', 'load', + 'model', 'objective', 'option', 'problem', 'purge', 'quit', + 'redeclare', 'reload', 'remove', 'reset', 'restore', 'shell', + 'show', 'solexpand', 'solution', 'solve', 'update', 'unload', + 'xref', 'coeff', 'coef', 'cover', 'obj', 'interval', 'default', + 'from', 'to', 'to_come', 'net_in', 'net_out', 'dimen', + 'dimension', 'check', 'complements', 'write', 'function', + 'pipe', 'format', 'if', 'then', 'else', 'in', 'while', 'repeat', + 'for'), suffix=r'\b'), Keyword.Reserved), + (r'(integer|binary|symbolic|ordered|circular|reversed|INOUT|IN|OUT|LOCAL)', + Keyword.Type), + (r'\".*?\"', String.Double), + (r'\'.*?\'', String.Single), + (r'[()\[\]{},;:]+', Punctuation), + (r'\b(\w+)(\.)(astatus|init0|init|lb0|lb1|lb2|lb|lrc|' + r'lslack|rc|relax|slack|sstatus|status|ub0|ub1|ub2|' + r'ub|urc|uslack|val)', + bygroups(Name.Variable, Punctuation, Keyword.Reserved)), + (r'(set|param|var|arc|minimize|maximize|subject to|s\.t\.|subj to|' + r'node|table|suffix|read table|write table)(\s+)(\w+)', + bygroups(Keyword.Declaration, Whitespace, Name.Variable)), + (r'(param)(\s*)(:)(\s*)(\w+)(\s*)(:)(\s*)((\w|\s)+)', + bygroups(Keyword.Declaration, Whitespace, Punctuation, Whitespace, + Name.Variable, Whitespace, Punctuation, Whitespace, Name.Variable)), + (r'(let|fix|unfix)(\s*)((?:\{.*\})?)(\s*)(\w+)', + bygroups(Keyword.Declaration, Whitespace, using(this), Whitespace, + Name.Variable)), + (words(( + 'abs', 'acos', 'acosh', 'alias', 'asin', 'asinh', 'atan', 'atan2', + 'atanh', 'ceil', 'ctime', 'cos', 'exp', 'floor', 'log', 'log10', + 'max', 'min', 'precision', 'round', 'sin', 'sinh', 'sqrt', 'tan', + 'tanh', 'time', 'trunc', 'Beta', 'Cauchy', 'Exponential', 'Gamma', + 'Irand224', 'Normal', 'Normal01', 'Poisson', 'Uniform', 'Uniform01', + 'num', 'num0', 'ichar', 'char', 'length', 'substr', 'sprintf', + 'match', 'sub', 'gsub', 'print', 'printf', 'next', 'nextw', 'prev', + 'prevw', 'first', 'last', 'ord', 'ord0', 'card', 'arity', + 'indexarity'), prefix=r'\b', suffix=r'\b'), Name.Builtin), + (r'(\+|\-|\*|/|\*\*|=|<=|>=|==|\||\^|<|>|\!|\.\.|:=|\&|\!=|<<|>>)', + Operator), + (words(( + 'or', 'exists', 'forall', 'and', 'in', 'not', 'within', 'union', + 'diff', 'difference', 'symdiff', 'inter', 'intersect', + 'intersection', 'cross', 'setof', 'by', 'less', 'sum', 'prod', + 'product', 'div', 'mod'), suffix=r'\b'), + Keyword.Reserved), # Operator.Name but not enough emphasized with that + (r'(\d+\.(?!\.)\d*|\.(?!.)\d+)([eE][+-]?\d+)?', Number.Float), + (r'\d+([eE][+-]?\d+)?', Number.Integer), + (r'[+-]?Infinity', Number.Integer), + (r'(\w+|(\.(?!\.)))', Text) + ] + + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/apdlexer.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/apdlexer.py new file mode 100644 index 0000000000000000000000000000000000000000..eca004e24955303e37d88c1eeeb538a47e96563c --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/apdlexer.py @@ -0,0 +1,593 @@ +""" + pygments.lexers.apdlexer + ~~~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for ANSYS Parametric Design Language. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, include, words, default +from pygments.token import Comment, Keyword, Name, Number, Operator, \ + String, Generic, Punctuation, Whitespace, Escape + +__all__ = ['apdlexer'] + + +class apdlexer(RegexLexer): + """ + For APDL source code. + """ + name = 'ANSYS parametric design language' + aliases = ['ansys', 'apdl'] + filenames = ['*.ans'] + url = 'https://www.ansys.com' + version_added = '2.9' + + flags = re.IGNORECASE + + # list of elements + elafunb = ("SURF152", "SURF153", "SURF154", "SURF156", "SHELL157", + "SURF159", "LINK160", "BEAM161", "PLANE162", + "SHELL163", "SOLID164", "COMBI165", "MASS166", + "LINK167", "SOLID168", "TARGE169", "TARGE170", + "CONTA171", "CONTA172", "CONTA173", "CONTA174", + "CONTA175", "CONTA176", "CONTA177", "CONTA178", + "PRETS179", "LINK180", "SHELL181", "PLANE182", + "PLANE183", "MPC184", "SOLID185", "SOLID186", + "SOLID187", "BEAM188", "BEAM189", "SOLSH190", + "INTER192", "INTER193", "INTER194", "INTER195", + "MESH200", "FOLLW201", "INTER202", "INTER203", + "INTER204", "INTER205", "SHELL208", "SHELL209", + "CPT212", "CPT213", "COMBI214", "CPT215", "CPT216", + "CPT217", "FLUID220", "FLUID221", "PLANE223", + "SOLID226", "SOLID227", "PLANE230", "SOLID231", + "SOLID232", "PLANE233", "SOLID236", "SOLID237", + "PLANE238", "SOLID239", "SOLID240", "HSFLD241", + "HSFLD242", "SURF251", "SURF252", "REINF263", + "REINF264", "REINF265", "SOLID272", "SOLID273", + "SOLID278", "SOLID279", "SHELL281", "SOLID285", + "PIPE288", "PIPE289", "ELBOW290", "USER300", "BEAM3", + "BEAM4", "BEAM23", "BEAM24", "BEAM44", "BEAM54", + "COMBIN7", "FLUID79", "FLUID80", "FLUID81", "FLUID141", + "FLUID142", "INFIN9", "INFIN47", "PLANE13", "PLANE25", + "PLANE42", "PLANE53", "PLANE67", "PLANE82", "PLANE83", + "PLANE145", "PLANE146", "CONTAC12", "CONTAC52", + "LINK1", "LINK8", "LINK10", "LINK32", "PIPE16", + "PIPE17", "PIPE18", "PIPE20", "PIPE59", "PIPE60", + "SHELL41", "SHELL43", "SHELL57", "SHELL63", "SHELL91", + "SHELL93", "SHELL99", "SHELL150", "SOLID5", "SOLID45", + "SOLID46", "SOLID65", "SOLID69", "SOLID92", "SOLID95", + "SOLID117", "SOLID127", "SOLID128", "SOLID147", + "SOLID148", "SOLID191", "VISCO88", "VISCO89", + "VISCO106", "VISCO107", "VISCO108", "TRANS109") + + elafunc = ("PGRAPH", "/VT", "VTIN", "VTRFIL", "VTTEMP", "PGRSET", + "VTCLR", "VTMETH", "VTRSLT", "VTVMOD", "PGSELE", + "VTDISC", "VTMP", "VTSEC", "PGWRITE", "VTEVAL", "VTOP", + "VTSFE", "POUTRES", "VTFREQ", "VTPOST", "VTSL", + "FLDATA1-40", "HFPCSWP", "MSDATA", "MSVARY", "QFACT", + "FLOCHECK", "HFPOWER", "MSMASS", "PERI", "SPADP", + "FLREAD", "HFPORT", "MSMETH", "PLFSS", "SPARM", + "FLOTRAN", "HFSCAT", "MSMIR", "PLSCH", "SPFSS", + "HFADP", "ICE", "MSNOMF", "PLSYZ", "SPICE", "HFARRAY", + "ICEDELE", "MSPROP", "PLTD", "SPSCAN", "HFDEEM", + "ICELIST", "MSQUAD", "PLTLINE", "SPSWP", "HFEIGOPT", + "ICVFRC", "MSRELAX", "PLVFRC", "HFEREFINE", "LPRT", + "MSSOLU", "/PICE", "HFMODPRT", "MSADV", "MSSPEC", + "PLWAVE", "HFPA", "MSCAP", "MSTERM", "PRSYZ") + + elafund = ("*VOPER", "VOVLAP", "*VPLOT", "VPLOT", "VPTN", "*VPUT", + "VPUT", "*VREAD", "VROTAT", "VSBA", "VSBV", "VSBW", + "/VSCALE", "*VSCFUN", "VSEL", "VSLA", "*VSTAT", "VSUM", + "VSWEEP", "VSYMM", "VTRAN", "VTYPE", "/VUP", "*VWRITE", + "/WAIT", "WAVES", "WERASE", "WFRONT", "/WINDOW", + "WMID", "WMORE", "WPAVE", "WPCSYS", "WPLANE", "WPOFFS", + "WPROTA", "WPSTYL", "WRFULL", "WRITE", "WRITEMAP", + "*WRK", "WSORT", "WSPRINGS", "WSTART", "WTBCREATE", + "XFDATA", "XFENRICH", "XFLIST", "/XFRM", "/XRANGE", + "XVAR", "/YRANGE", "/ZOOM", "/WB", "XMLO", "/XML", + "CNTR", "EBLOCK", "CMBLOCK", "NBLOCK", "/TRACK", + "CWZPLOT", "~EUI", "NELE", "EALL", "NALL", "FLITEM", + "LSLN", "PSOLVE", "ASLN", "/VERIFY", "/SSS", "~CFIN", + "*EVAL", "*MOONEY", "/RUNSTAT", "ALPFILL", + "ARCOLLAPSE", "ARDETACH", "ARFILL", "ARMERGE", + "ARSPLIT", "FIPLOT", "GAPFINISH", "GAPLIST", + "GAPMERGE", "GAPOPT", "GAPPLOT", "LNCOLLAPSE", + "LNDETACH", "LNFILL", "LNMERGE", "LNSPLIT", "PCONV", + "PLCONV", "PEMOPTS", "PEXCLUDE", "PINCLUDE", "PMETH", + "/PMETH", "PMOPTS", "PPLOT", "PPRANGE", "PRCONV", + "PRECISION", "RALL", "RFILSZ", "RITER", "RMEMRY", + "RSPEED", "RSTAT", "RTIMST", "/RUNST", "RWFRNT", + "SARPLOT", "SHSD", "SLPPLOT", "SLSPLOT", "VCVFILL", + "/OPT", "OPEQN", "OPFACT", "OPFRST", "OPGRAD", + "OPKEEP", "OPLOOP", "OPPRNT", "OPRAND", "OPSUBP", + "OPSWEEP", "OPTYPE", "OPUSER", "OPVAR", "OPADD", + "OPCLR", "OPDEL", "OPMAKE", "OPSEL", "OPANL", "OPDATA", + "OPRESU", "OPSAVE", "OPEXE", "OPLFA", "OPLGR", + "OPLIST", "OPLSW", "OPRFA", "OPRGR", "OPRSW", + "PILECALC", "PILEDISPSET", "PILEGEN", "PILELOAD", + "PILEMASS", "PILERUN", "PILESEL", "PILESTIF", + "PLVAROPT", "PRVAROPT", "TOCOMP", "TODEF", "TOFREQ", + "TOTYPE", "TOVAR", "TOEXE", "TOLOOP", "TOGRAPH", + "TOLIST", "TOPLOT", "TOPRINT", "TOSTAT", "TZAMESH", + "TZDELE", "TZEGEN", "XVAROPT", "PGSAVE", "SOLCONTROL", + "TOTAL", "VTGEOM", "VTREAL", "VTSTAT") + + elafune = ("/ANUM", "AOFFST", "AOVLAP", "APLOT", "APPEND", "APTN", + "ARCLEN", "ARCTRM", "AREAS", "AREFINE", "AREMESH", + "AREVERSE", "AROTAT", "ARSCALE", "ARSYM", "ASBA", + "ASBL", "ASBV", "ASBW", "ASCRES", "ASEL", "ASIFILE", + "*ASK", "ASKIN", "ASLL", "ASLV", "ASOL", "/ASSIGN", + "ASUB", "ASUM", "ATAN", "ATRAN", "ATYPE", "/AUTO", + "AUTOTS", "/AUX2", "/AUX3", "/AUX12", "/AUX15", + "AVPRIN", "AVRES", "AWAVE", "/AXLAB", "*AXPY", + "/BATCH", "BCSOPTION", "BETAD", "BF", "BFA", "BFADELE", + "BFALIST", "BFCUM", "BFDELE", "BFE", "BFECUM", + "BFEDELE", "BFELIST", "BFESCAL", "BFINT", "BFK", + "BFKDELE", "BFKLIST", "BFL", "BFLDELE", "BFLIST", + "BFLLIST", "BFSCALE", "BFTRAN", "BFUNIF", "BFV", + "BFVDELE", "BFVLIST", "BIOOPT", "BIOT", "BLC4", "BLC5", + "BLOCK", "BOOL", "BOPTN", "BSAX", "BSMD", "BSM1", + "BSM2", "BSPLIN", "BSS1", "BSS2", "BSTE", "BSTQ", + "BTOL", "BUCOPT", "C", "CALC", "CAMPBELL", "CBDOF", + "CBMD", "CBMX", "CBTE", "CBTMP", "CDOPT", "CDREAD", + "CDWRITE", "CE", "CECHECK", "CECMOD", "CECYC", + "CEDELE", "CEINTF", "CELIST", "CENTER", "CEQN", + "CERIG", "CESGEN", "CFACT", "*CFCLOS", "*CFOPEN", + "*CFWRITE", "/CFORMAT", "CGLOC", "CGOMGA", "CGROW", + "CHECK", "CHKMSH", "CINT", "CIRCLE", "CISOL", + "/CLABEL", "/CLEAR", "CLOCAL", "CLOG", "/CLOG", + "CLRMSHLN", "CM", "CMACEL", "/CMAP", "CMATRIX", + "CMDELE", "CMDOMEGA", "CMEDIT", "CMGRP", "CMLIST", + "CMMOD", "CMOMEGA", "CMPLOT", "CMROTATE", "CMSEL", + "CMSFILE", "CMSOPT", "CMWRITE", "CNCHECK", "CNKMOD", + "CNTR", "CNVTOL", "/COLOR", "*COMP", "COMBINE", + "COMPRESS", "CON4", "CONE", "/CONFIG", "CONJUG", + "/CONTOUR", "/COPY", "CORIOLIS", "COUPLE", "COVAL", + "CP", "CPCYC", "CPDELE", "CPINTF", "/CPLANE", "CPLGEN", + "CPLIST", "CPMERGE", "CPNGEN", "CPSGEN", "CQC", + "*CREATE", "CRPLIM", "CS", "CSCIR", "CSDELE", "CSKP", + "CSLIST", "CSWPLA", "CSYS", "/CTYPE", "CURR2D", + "CUTCONTROL", "/CVAL", "CVAR", "/CWD", "CYCCALC", + "/CYCEXPAND", "CYCFILES", "CYCFREQ", "*CYCLE", + "CYCLIC", "CYCOPT", "CYCPHASE", "CYCSPEC", "CYL4", + "CYL5", "CYLIND", "CZDEL", "CZMESH", "D", "DA", + "DADELE", "DALIST", "DAMORPH", "DATA", "DATADEF", + "DCGOMG", "DCUM", "DCVSWP", "DDASPEC", "DDELE", + "DDOPTION", "DEACT", "DEFINE", "*DEL", "DELETE", + "/DELETE", "DELTIM", "DELTIME", "DEMORPH", "DERIV", "DESIZE", + "DESOL", "DETAB", "/DEVDISP", "/DEVICE", "/DFLAB", + "DFLX", "DFSWAVE", "DIG", "DIGIT", "*DIM", + "/DIRECTORY", "DISPLAY", "/DIST", "DJ", "DJDELE", + "DJLIST", "DK", "DKDELE", "DKLIST", "DL", "DLDELE", + "DLIST", "DLLIST", "*DMAT", "DMOVE", "DMPEXT", + "DMPOPTION", "DMPRAT", "DMPSTR", "DNSOL", "*DO", "DOF", + "DOFSEL", "DOMEGA", "*DOT", "*DOWHILE", "DSCALE", + "/DSCALE", "DSET", "DSPOPTION", "DSUM", "DSURF", + "DSYM", "DSYS", "DTRAN", "DUMP", "/DV3D", "DVAL", + "DVMORPH", "DYNOPT", "E", "EALIVE", "EDADAPT", "EDALE", + "EDASMP", "EDBOUND", "EDBX", "EDBVIS", "EDCADAPT", + "EDCGEN", "EDCLIST", "EDCMORE", "EDCNSTR", "EDCONTACT", + "EDCPU", "EDCRB", "EDCSC", "EDCTS", "EDCURVE", + "EDDAMP", "EDDBL", "EDDC", "EDDRELAX", "EDDUMP", + "EDELE", "EDENERGY", "EDFPLOT", "EDGCALE", "/EDGE", + "EDHGLS", "EDHIST", "EDHTIME", "EDINT", "EDIPART", + "EDIS", "EDLCS", "EDLOAD", "EDMP", "EDNB", "EDNDTSD", + "EDNROT", "EDOPT", "EDOUT", "EDPART", "EDPC", "EDPL", + "EDPVEL", "EDRC", "EDRD", "EDREAD", "EDRI", "EDRST", + "EDRUN", "EDSHELL", "EDSOLV", "EDSP", "EDSTART", + "EDTERM", "EDTP", "EDVEL", "EDWELD", "EDWRITE", + "EEXTRUDE", "/EFACET", "EGEN", "*EIGEN", "EINFIN", + "EINTF", "EKILL", "ELBOW", "ELEM", "ELIST", "*ELSE", + "*ELSEIF", "EMAGERR", "EMATWRITE", "EMF", "EMFT", + "EMID", "EMIS", "EMODIF", "EMORE", "EMSYM", "EMTGEN", + "EMUNIT", "EN", "*END", "*ENDDO", "*ENDIF", + "ENDRELEASE", "ENERSOL", "ENGEN", "ENORM", "ENSYM", + "EORIENT", "EPLOT", "EQSLV", "ERASE", "/ERASE", + "EREAD", "EREFINE", "EREINF", "ERESX", "ERNORM", + "ERRANG", "ESCHECK", "ESEL", "/ESHAPE", "ESIZE", + "ESLA", "ESLL", "ESLN", "ESLV", "ESOL", "ESORT", + "ESSOLV", "ESTIF", "ESURF", "ESYM", "ESYS", "ET", + "ETABLE", "ETCHG", "ETCONTROL", "ETDELE", "ETLIST", + "ETYPE", "EUSORT", "EWRITE", "*EXIT", "/EXIT", "EXP", + "EXPAND", "/EXPAND", "EXPASS", "*EXPORT", "EXPROFILE", + "EXPSOL", "EXTOPT", "EXTREM", "EXUNIT", "F", "/FACET", + "FATIGUE", "FC", "FCCHECK", "FCDELE", "FCLIST", "FCUM", + "FCTYP", "FDELE", "/FDELE", "FE", "FEBODY", "FECONS", + "FEFOR", "FELIST", "FESURF", "*FFT", "FILE", + "FILEAUX2", "FILEAUX3", "FILEDISP", "FILL", "FILLDATA", + "/FILNAME", "FINISH", "FITEM", "FJ", "FJDELE", + "FJLIST", "FK", "FKDELE", "FKLIST", "FL", "FLIST", + "FLLIST", "FLST", "FLUXV", "FLUREAD", "FMAGBC", + "FMAGSUM", "/FOCUS", "FOR2D", "FORCE", "FORM", + "/FORMAT", "FP", "FPLIST", "*FREE", "FREQ", "FRQSCL", + "FS", "FSCALE", "FSDELE", "FSLIST", "FSNODE", "FSPLOT", + "FSSECT", "FSSPARM", "FSUM", "FTCALC", "FTRAN", + "FTSIZE", "FTWRITE", "FTYPE", "FVMESH", "GAP", "GAPF", + "GAUGE", "GCDEF", "GCGEN", "/GCMD", "/GCOLUMN", + "GENOPT", "GEOM", "GEOMETRY", "*GET", "/GFILE", + "/GFORMAT", "/GLINE", "/GMARKER", "GMATRIX", "GMFACE", + "*GO", "/GO", "/GOLIST", "/GOPR", "GP", "GPDELE", + "GPLIST", "GPLOT", "/GRAPHICS", "/GRESUME", "/GRID", + "/GROPT", "GRP", "/GRTYP", "/GSAVE", "GSBDATA", + "GSGDATA", "GSLIST", "GSSOL", "/GST", "GSUM", "/GTHK", + "/GTYPE", "HARFRQ", "/HBC", "HBMAT", "/HEADER", "HELP", + "HELPDISP", "HEMIOPT", "HFANG", "HFSYM", "HMAGSOLV", + "HPGL", "HPTCREATE", "HPTDELETE", "HRCPLX", "HREXP", + "HROPT", "HROCEAN", "HROUT", "IC", "ICDELE", "ICLIST", + "/ICLWID", "/ICSCALE", "*IF", "IGESIN", "IGESOUT", + "/IMAGE", "IMAGIN", "IMESH", "IMMED", "IMPD", + "INISTATE", "*INIT", "/INPUT", "/INQUIRE", "INRES", + "INRTIA", "INT1", "INTSRF", "IOPTN", "IRLF", "IRLIST", + "*ITENGINE", "JPEG", "JSOL", "K", "KATT", "KBC", + "KBETW", "KCALC", "KCENTER", "KCLEAR", "KDELE", + "KDIST", "KEEP", "KESIZE", "KEYOPT", "KEYPTS", "KEYW", + "KFILL", "KGEN", "KL", "KLIST", "KMESH", "KMODIF", + "KMOVE", "KNODE", "KPLOT", "KPSCALE", "KREFINE", + "KSCALE", "KSCON", "KSEL", "KSLL", "KSLN", "KSUM", + "KSYMM", "KTRAN", "KUSE", "KWPAVE", "KWPLAN", "L", + "L2ANG", "L2TAN", "LANG", "LARC", "/LARC", "LAREA", + "LARGE", "LATT", "LAYER", "LAYERP26", "LAYLIST", + "LAYPLOT", "LCABS", "LCASE", "LCCALC", "LCCAT", + "LCDEF", "LCFACT", "LCFILE", "LCLEAR", "LCOMB", + "LCOPER", "LCSEL", "LCSL", "LCSUM", "LCWRITE", + "LCZERO", "LDELE", "LDIV", "LDRAG", "LDREAD", "LESIZE", + "LEXTND", "LFILLT", "LFSURF", "LGEN", "LGLUE", + "LGWRITE", "/LIGHT", "LINA", "LINE", "/LINE", "LINES", + "LINL", "LINP", "LINV", "LIST", "*LIST", "LLIST", + "LMATRIX", "LMESH", "LNSRCH", "LOCAL", "LOVLAP", + "LPLOT", "LPTN", "LREFINE", "LREVERSE", "LROTAT", + "LSBA", "*LSBAC", "LSBL", "LSBV", "LSBW", "LSCLEAR", + "LSDELE", "*LSDUMP", "LSEL", "*LSENGINE", "*LSFACTOR", + "LSLA", "LSLK", "LSOPER", "/LSPEC", "LSREAD", + "*LSRESTORE", "LSSCALE", "LSSOLVE", "LSTR", "LSUM", + "LSWRITE", "/LSYMBOL", "LSYMM", "LTAN", "LTRAN", + "LUMPM", "LVSCALE", "LWPLAN", "M", "MADAPT", "MAGOPT", + "MAGSOLV", "/MAIL", "MAP", "/MAP", "MAP2DTO3D", + "MAPSOLVE", "MAPVAR", "MASTER", "MAT", "MATER", + "MCHECK", "MDAMP", "MDELE", "MDPLOT", "MEMM", "/MENU", + "MESHING", "MFANALYSIS", "MFBUCKET", "MFCALC", "MFCI", + "MFCLEAR", "MFCMMAND", "MFCONV", "MFDTIME", "MFELEM", + "MFEM", "MFEXTER", "MFFNAME", "MFFR", "MFIMPORT", + "MFINTER", "MFITER", "MFLCOMM", "MFLIST", "MFMAP", + "MFORDER", "MFOUTPUT", "*MFOURI", "MFPSIMUL", "MFRC", + "MFRELAX", "MFRSTART", "MFSORDER", "MFSURFACE", + "MFTIME", "MFTOL", "*MFUN", "MFVOLUME", "MFWRITE", + "MGEN", "MIDTOL", "/MKDIR", "MLIST", "MMASS", "MMF", + "MODCONT", "MODE", "MODIFY", "MODMSH", "MODSELOPTION", + "MODOPT", "MONITOR", "*MOPER", "MOPT", "MORPH", "MOVE", + "MP", "MPAMOD", "MPCHG", "MPCOPY", "MPDATA", "MPDELE", + "MPDRES", "/MPLIB", "MPLIST", "MPPLOT", "MPREAD", + "MPRINT", "MPTEMP", "MPTGEN", "MPTRES", "MPWRITE", + "/MREP", "MSAVE", "*MSG", "MSHAPE", "MSHCOPY", + "MSHKEY", "MSHMID", "MSHPATTERN", "MSOLVE", "/MSTART", + "MSTOLE", "*MULT", "*MWRITE", "MXPAND", "N", "NANG", + "NAXIS", "NCNV", "NDELE", "NDIST", "NDSURF", "NEQIT", + "/NERR", "NFORCE", "NGEN", "NKPT", "NLADAPTIVE", + "NLDIAG", "NLDPOST", "NLGEOM", "NLHIST", "NLIST", + "NLMESH", "NLOG", "NLOPT", "NMODIF", "NOCOLOR", + "NODES", "/NOERASE", "/NOLIST", "NOOFFSET", "NOORDER", + "/NOPR", "NORA", "NORL", "/NORMAL", "NPLOT", "NPRINT", + "NREAD", "NREFINE", "NRLSUM", "*NRM", "NROPT", + "NROTAT", "NRRANG", "NSCALE", "NSEL", "NSLA", "NSLE", + "NSLK", "NSLL", "NSLV", "NSMOOTH", "NSOL", "NSORT", + "NSTORE", "NSUBST", "NSVR", "NSYM", "/NUMBER", + "NUMCMP", "NUMEXP", "NUMMRG", "NUMOFF", "NUMSTR", + "NUMVAR", "NUSORT", "NWPAVE", "NWPLAN", "NWRITE", + "OCDATA", "OCDELETE", "OCLIST", "OCREAD", "OCTABLE", + "OCTYPE", "OCZONE", "OMEGA", "OPERATE", "OPNCONTROL", + "OUTAERO", "OUTOPT", "OUTPR", "/OUTPUT", "OUTRES", + "OVCHECK", "PADELE", "/PAGE", "PAGET", "PAPUT", + "PARESU", "PARTSEL", "PARRES", "PARSAV", "PASAVE", + "PATH", "PAUSE", "/PBC", "/PBF", "PCALC", "PCGOPT", + "PCIRC", "/PCIRCLE", "/PCOPY", "PCROSS", "PDANL", + "PDCDF", "PDCFLD", "PDCLR", "PDCMAT", "PDCORR", + "PDDMCS", "PDDOEL", "PDEF", "PDEXE", "PDHIST", + "PDINQR", "PDLHS", "PDMETH", "PDOT", "PDPINV", + "PDPLOT", "PDPROB", "PDRESU", "PDROPT", "/PDS", + "PDSAVE", "PDSCAT", "PDSENS", "PDSHIS", "PDUSER", + "PDVAR", "PDWRITE", "PERBC2D", "PERTURB", "PFACT", + "PHYSICS", "PIVCHECK", "PLCAMP", "PLCFREQ", "PLCHIST", + "PLCINT", "PLCPLX", "PLCRACK", "PLDISP", "PLESOL", + "PLETAB", "PLFAR", "PLF2D", "PLGEOM", "PLLS", "PLMAP", + "PLMC", "PLNEAR", "PLNSOL", "/PLOPTS", "PLORB", "PLOT", + "PLOTTING", "PLPAGM", "PLPATH", "PLSECT", "PLST", + "PLTIME", "PLTRAC", "PLVAR", "PLVECT", "PLZZ", + "/PMACRO", "PMAP", "PMGTRAN", "PMLOPT", "PMLSIZE", + "/PMORE", "PNGR", "/PNUM", "POINT", "POLY", "/POLYGON", + "/POST1", "/POST26", "POWERH", "PPATH", "PRANGE", + "PRAS", "PRCAMP", "PRCINT", "PRCPLX", "PRED", + "PRENERGY", "/PREP7", "PRERR", "PRESOL", "PRETAB", + "PRFAR", "PRI2", "PRIM", "PRINT", "*PRINT", "PRISM", + "PRITER", "PRJSOL", "PRNEAR", "PRNLD", "PRNSOL", + "PROD", "PRORB", "PRPATH", "PRRFOR", "PRRSOL", + "PRSCONTROL", "PRSECT", "PRTIME", "PRVAR", "PRVECT", + "PSCONTROL", "PSCR", "PSDCOM", "PSDFRQ", "PSDGRAPH", + "PSDRES", "PSDSPL", "PSDUNIT", "PSDVAL", "PSDWAV", + "/PSEARCH", "PSEL", "/PSF", "PSMAT", "PSMESH", + "/PSPEC", "/PSTATUS", "PSTRES", "/PSYMB", "PTR", + "PTXY", "PVECT", "/PWEDGE", "QDVAL", "QRDOPT", "QSOPT", + "QUAD", "/QUIT", "QUOT", "R", "RACE", "RADOPT", + "RAPPND", "RATE", "/RATIO", "RBE3", "RCON", "RCYC", + "RDEC", "RDELE", "READ", "REAL", "REALVAR", "RECTNG", + "REMESH", "/RENAME", "REORDER", "*REPEAT", "/REPLOT", + "RESCOMBINE", "RESCONTROL", "RESET", "/RESET", "RESP", + "RESUME", "RESVEC", "RESWRITE", "*RETURN", "REXPORT", + "REZONE", "RFORCE", "/RGB", "RIGID", "RIGRESP", + "RIMPORT", "RLIST", "RMALIST", "RMANL", "RMASTER", + "RMCAP", "RMCLIST", "/RMDIR", "RMFLVEC", "RMLVSCALE", + "RMMLIST", "RMMRANGE", "RMMSELECT", "RMNDISP", + "RMNEVEC", "RMODIF", "RMORE", "RMPORDER", "RMRESUME", + "RMRGENERATE", "RMROPTIONS", "RMRPLOT", "RMRSTATUS", + "RMSAVE", "RMSMPLE", "RMUSE", "RMXPORT", "ROCK", + "ROSE", "RPOLY", "RPR4", "RPRISM", "RPSD", "RSFIT", + "RSOPT", "RSPLIT", "RSPLOT", "RSPRNT", "RSSIMS", + "RSTMAC", "RSTOFF", "RSURF", "RSYMM", "RSYS", "RTHICK", + "SABS", "SADD", "SALLOW", "SAVE", "SBCLIST", "SBCTRAN", + "SDELETE", "SE", "SECCONTROL", "SECDATA", + "SECFUNCTION", "SECJOINT", "/SECLIB", "SECLOCK", + "SECMODIF", "SECNUM", "SECOFFSET", "SECPLOT", + "SECREAD", "SECSTOP", "SECTYPE", "SECWRITE", "SED", + "SEDLIST", "SEEXP", "/SEG", "SEGEN", "SELIST", "SELM", + "SELTOL", "SENERGY", "SEOPT", "SESYMM", "*SET", "SET", + "SETFGAP", "SETRAN", "SEXP", "SF", "SFA", "SFACT", + "SFADELE", "SFALIST", "SFBEAM", "SFCALC", "SFCUM", + "SFDELE", "SFE", "SFEDELE", "SFELIST", "SFFUN", + "SFGRAD", "SFL", "SFLDELE", "SFLEX", "SFLIST", + "SFLLIST", "SFSCALE", "SFTRAN", "/SHADE", "SHELL", + "/SHOW", "/SHOWDISP", "SHPP", "/SHRINK", "SLIST", + "SLOAD", "SMALL", "*SMAT", "SMAX", "/SMBC", "SMBODY", + "SMCONS", "SMFOR", "SMIN", "SMOOTH", "SMRTSIZE", + "SMSURF", "SMULT", "SNOPTION", "SOLU", "/SOLU", + "SOLUOPT", "SOLVE", "SORT", "SOURCE", "SPACE", + "SPCNOD", "SPCTEMP", "SPDAMP", "SPEC", "SPFREQ", + "SPGRAPH", "SPH4", "SPH5", "SPHERE", "SPLINE", "SPLOT", + "SPMWRITE", "SPOINT", "SPOPT", "SPREAD", "SPTOPT", + "SPOWER", "SPUNIT", "SPVAL", "SQRT", "*SREAD", "SRSS", + "SSBT", "/SSCALE", "SSLN", "SSMT", "SSPA", "SSPB", + "SSPD", "SSPE", "SSPM", "SSUM", "SSTATE", "STABILIZE", + "STAOPT", "STAT", "*STATUS", "/STATUS", "STEF", + "STORE", "SUBOPT", "SUBSET", "SUCALC", + "SUCR", "SUDEL", "SUEVAL", "SUGET", "SUMAP", "SUMTYPE", + "SUPL", "SUPR", "SURESU", "SUSAVE", "SUSEL", "SUVECT", + "SV", "SVPLOT", "SVTYP", "SWADD", "SWDEL", "SWGEN", + "SWLIST", "SYNCHRO", "/SYP", "/SYS", "TALLOW", + "TARGET", "*TAXIS", "TB", "TBCOPY", "TBDATA", "TBDELE", + "TBEO", "TBIN", "TBFIELD", "TBFT", "TBLE", "TBLIST", + "TBMODIF", "TBPLOT", "TBPT", "TBTEMP", "TCHG", "/TEE", + "TERM", "THEXPAND", "THOPT", "TIFF", "TIME", + "TIMERANGE", "TIMINT", "TIMP", "TINTP", + "/TLABEL", "TOFFST", "*TOPER", "TORQ2D", "TORQC2D", + "TORQSUM", "TORUS", "TRANS", "TRANSFER", "*TREAD", + "TREF", "/TRIAD", "/TRLCY", "TRNOPT", "TRPDEL", + "TRPLIS", "TRPOIN", "TRTIME", "TSHAP", "/TSPEC", + "TSRES", "TUNIF", "TVAR", "/TXTRE", "/TYPE", "TYPE", + "/UCMD", "/UDOC", "/UI", "UIMP", "/UIS", "*ULIB", "/UPF", + "UNDELETE", "UNDO", "/UNITS", "UNPAUSE", "UPCOORD", + "UPGEOM", "*USE", "/USER", "USRCAL", "USRDOF", + "USRELEM", "V", "V2DOPT", "VA", "*VABS", "VADD", + "VARDEL", "VARNAM", "VATT", "VCLEAR", "*VCOL", + "/VCONE", "VCROSS", "*VCUM", "VDDAM", "VDELE", "VDGL", + "VDOT", "VDRAG", "*VEC", "*VEDIT", "VEORIENT", "VEXT", + "*VFACT", "*VFILL", "VFOPT", "VFQUERY", "VFSM", + "*VFUN", "VGEN", "*VGET", "VGET", "VGLUE", "/VIEW", + "VIMP", "VINP", "VINV", "*VITRP", "*VLEN", "VLIST", + "VLSCALE", "*VMASK", "VMESH", "VOFFST", "VOLUMES") + + # list of in-built () functions + elafunf = ("NX()", "NY()", "NZ()", "KX()", "KY()", "KZ()", "LX()", + "LY()", "LZ()", "LSX()", "LSY()", "LSZ()", "NODE()", + "KP()", "DISTND()", "DISTKP()", "DISTEN()", "ANGLEN()", + "ANGLEK()", "NNEAR()", "KNEAR()", "ENEARN()", + "AREAND()", "AREAKP()", "ARNODE()", "NORMNX()", + "NORMNY()", "NORMNZ()", "NORMKX()", "NORMKY()", + "NORMKZ()", "ENEXTN()", "NELEM()", "NODEDOF()", + "ELADJ()", "NDFACE()", "NMFACE()", "ARFACE()", "UX()", + "UY()", "UZ()", "ROTX()", "ROTY()", "ROTZ()", "TEMP()", + "PRES()", "VX()", "VY()", "VZ()", "ENKE()", "ENDS()", + "VOLT()", "MAG()", "AX()", "AY()", "AZ()", + "VIRTINQR()", "KWGET()", "VALCHR()", "VALHEX()", + "CHRHEX()", "STRFILL()", "STRCOMP()", "STRPOS()", + "STRLENG()", "UPCASE()", "LWCASE()", "JOIN()", + "SPLIT()", "ABS()", "SIGN()", "CXABS()", "EXP()", + "LOG()", "LOG10()", "SQRT()", "NINT()", "MOD()", + "RAND()", "GDIS()", "SIN()", "COS()", "TAN()", + "SINH()", "COSH()", "TANH()", "ASIN()", "ACOS()", + "ATAN()", "ATAN2()") + + elafung = ("NSEL()", "ESEL()", "KSEL()", "LSEL()", "ASEL()", + "VSEL()", "NDNEXT()", "ELNEXT()", "KPNEXT()", + "LSNEXT()", "ARNEXT()", "VLNEXT()", "CENTRX()", + "CENTRY()", "CENTRZ()") + + elafunh = ("~CAT5IN", "~CATIAIN", "~PARAIN", "~PROEIN", "~SATIN", + "~UGIN", "A", "AADD", "AATT", "ABEXTRACT", "*ABBR", + "ABBRES", "ABBSAV", "ABS", "ACCAT", "ACCOPTION", + "ACEL", "ACLEAR", "ADAMS", "ADAPT", "ADD", "ADDAM", + "ADELE", "ADGL", "ADRAG", "AESIZE", "AFILLT", "AFLIST", + "AFSURF", "*AFUN", "AGEN", "AGLUE", "AINA", "AINP", + "AINV", "AL", "ALIST", "ALLSEL", "ALPHAD", "AMAP", + "AMESH", "/AN3D", "ANCNTR", "ANCUT", "ANCYC", "ANDATA", + "ANDSCL", "ANDYNA", "/ANFILE", "ANFLOW", "/ANGLE", + "ANHARM", "ANIM", "ANISOS", "ANMODE", "ANMRES", + "/ANNOT", "ANORM", "ANPRES", "ANSOL", "ANSTOAQWA", + "ANSTOASAS", "ANTIME", "ANTYPE") + + special = ("/COM", "/TITLE", "STITLE") + + elements = ("SOLID5", + "LINK11", + "PLANE13", + "COMBIN14", + "MASS2", + "PLANE25", + "MATRIX27", + "FLUID29", + "FLUID30", + "LINK31", + "LINK33", + "LINK34", + "PLANE35", + "SOURC36", + "COMBIN37", + "FLUID38", + "COMBIN39", + "COMBIN40", + "INFIN47", + "MATRIX50", + "PLANE55", + "SHELL61", + "LINK68", + "SOLID70", + "MASS71", + "PLANE75", + "PLANE77", + "PLANE78", + "PLANE83", + "SOLID87", + "SOLID90", + "CIRCU94", + "SOLID96", + "SOLID98", + "INFIN110", + "INFIN111", + "FLUID116", + "PLANE121", + "SOLID122", + "SOLID123", + "CIRCU124", + "CIRCU125", + "TRANS126", + "FLUID129", + "FLUID130", + "SHELL131", + "SHELL132", + "FLUID136", + "FLUID138", + "FLUID139", + "SURF151", + "SURF152", + "SURF153", + "SURF154", + "SURF155", + "SURF156", + "SHELL157", + "SURF159", + "TARGE169", + "TARGE170", + "CONTA172", + "CONTA174", + "CONTA175", + "CONTA177", + "CONTA178", + "PRETS179", + "LINK180", + "SHELL181", + "PLANE182", + "PLANE183", + "MPC184", + "SOLID185", + "SOLID186", + "SOLID187", + "BEAM188", + "BEAM189", + "SOLSH190", + "INTER192", + "INTER193", + "INTER194", + "INTER195", + "MESH200", + "FOLLW201", + "INTER202", + "INTER203", + "INTER204", + "INTER205", + "SHELL208", + "SHELL209", + "CPT212", + "CPT213", + "COMBI214", + "CPT215", + "CPT216", + "CPT217", + "FLUID218", + "FLUID220", + "FLUID221", + "PLANE222", + "PLANE223", + "SOLID225", + "SOLID226", + "SOLID227", + "PLANE230", + "SOLID231", + "SOLID232", + "PLANE233", + "SOLID236", + "SOLID237", + "PLANE238", + "SOLID239", + "SOLID240", + "HSFLD241", + "HSFLD242", + "COMBI250", + "SURF251", + "SURF252", + "INFIN257", + "REINF263", + "REINF264", + "REINF265", + "SOLID272", + "SOLID273", + "SOLID278", + "SOLID279", + "CABLE280", + "SHELL281", + "SOLID285", + "PIPE288", + "PIPE289", + "ELBOW290", + "SOLID291", + "PLANE292", + "PLANE293", + "USER300") + + tokens = { + 'root': [ + (r'[^\S\n]+', Whitespace), + (words((elafunb+elafunc+elafund+elafune+elafunh+special), suffix=r'\b'), Keyword, 'non-keyword'), + default('non-keyword'), + ], + 'non-keyword': [ + (r'!.*\n', Comment, '#pop'), + (r'%.*?%', Escape), + include('strings'), + include('nums'), + (words((elafunf+elafung), suffix=r'\b'), Name.Builtin), + (words((elements), suffix=r'\b'), Name.Property), + include('core'), + (r'AR[0-9]+', Name.Variable.Instance), + (r'[a-z_][a-z0-9_]*', Name.Variable), + (r'\n+', Whitespace, '#pop'), + (r'[^\S\n]+', Whitespace), + ], + 'core': [ + # Operators + (r'(\*\*|\*|\+|-|\/|<|>|<=|>=|==|\/=|=|\(|\))', Operator), + (r'/EOF', Generic.Emph), + (r'[\.(),:&;]', Punctuation), + ], + 'strings': [ + (r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double), + (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single), + (r'[$%]', String.Symbol), + ], + 'nums': [ + (r'[+-]?\d*\.\d+([efEF][-+]?\d+)?', Number.Float), # with dot + (r'([+-]?\d+([efEF][-+]?\d+))', Number.Float), # With scientific notation + (r'\b\d+(?![.ef])', Number.Integer), # integer simple + ] + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/apl.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/apl.py new file mode 100644 index 0000000000000000000000000000000000000000..147a7e21c7b105b0e7ee7b2e153ac5d64fd654dd --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/apl.py @@ -0,0 +1,103 @@ +""" + pygments.lexers.apl + ~~~~~~~~~~~~~~~~~~~ + + Lexers for APL. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer +from pygments.token import Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace + +__all__ = ['APLLexer'] + + +class APLLexer(RegexLexer): + """ + A simple APL lexer. + """ + name = 'APL' + url = 'https://en.m.wikipedia.org/wiki/APL_(programming_language)' + aliases = ['apl'] + filenames = [ + '*.apl', '*.aplf', '*.aplo', '*.apln', + '*.aplc', '*.apli', '*.dyalog', + ] + version_added = '2.0' + + tokens = { + 'root': [ + # Whitespace + # ========== + (r'\s+', Whitespace), + # + # Comment + # ======= + # '⍝' is traditional; '#' is supported by GNU APL and NGN (but not Dyalog) + (r'[⍝#].*$', Comment.Single), + # + # Strings + # ======= + (r'\'((\'\')|[^\'])*\'', String.Single), + (r'"(("")|[^"])*"', String.Double), # supported by NGN APL + # + # Punctuation + # =========== + # This token type is used for diamond and parenthesis + # but not for bracket and ; (see below) + (r'[⋄◇()]', Punctuation), + # + # Array indexing + # ============== + # Since this token type is very important in APL, it is not included in + # the punctuation token type but rather in the following one + (r'[\[\];]', String.Regex), + # + # Distinguished names + # =================== + # following IBM APL2 standard + (r'⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Function), + # + # Labels + # ====== + # following IBM APL2 standard + # (r'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*:', Name.Label), + # + # Variables + # ========= + # following IBM APL2 standard (with a leading _ ok for GNU APL and Dyalog) + (r'[A-Za-zΔ∆⍙_][A-Za-zΔ∆⍙_¯0-9]*', Name.Variable), + # + # Numbers + # ======= + (r'¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)' + r'([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?', + Number), + # + # Operators + # ========== + (r'[\.\\\/⌿⍀¨⍣⍨⍠⍤∘⌸&⌶@⌺⍥⍛⍢]', Name.Attribute), # closest token type + (r'[+\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗⊆⊇⍸√⌾…⍮]', + Operator), + # + # Constant + # ======== + (r'⍬', Name.Constant), + # + # Quad symbol + # =========== + (r'[⎕⍞]', Name.Variable.Global), + # + # Arrows left/right + # ================= + (r'[←→]', Keyword.Declaration), + # + # D-Fn + # ==== + (r'[⍺⍵⍶⍹∇:]', Name.Builtin.Pseudo), + (r'[{}]', Keyword.Type), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/archetype.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/archetype.py new file mode 100644 index 0000000000000000000000000000000000000000..977b02f7516a28f470b4d78003f30ab15e3ef93a --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/archetype.py @@ -0,0 +1,315 @@ +""" + pygments.lexers.archetype + ~~~~~~~~~~~~~~~~~~~~~~~~~ + + Lexer for Archetype-related syntaxes, including ODIN, ADL and cADL. + + For uses of this syntax, see the openEHR archetypes + + Contributed by Thomas Beale , + . + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, include, bygroups, using, default +from pygments.token import Text, Comment, Name, Literal, Number, String, \ + Punctuation, Keyword, Operator, Generic, Whitespace + +__all__ = ['OdinLexer', 'CadlLexer', 'AdlLexer'] + + +class AtomsLexer(RegexLexer): + """ + Lexer for Values used in ADL and ODIN. + + .. versionadded:: 2.1 + """ + + tokens = { + # ----- pseudo-states for inclusion ----- + 'whitespace': [ + (r'\n', Whitespace), + (r'\s+', Whitespace), + (r'([ \t]*)(--.*)$', bygroups(Whitespace, Comment)), + ], + 'archetype_id': [ + (r'([ \t]*)(([a-zA-Z]\w{1,100}(\.[a-zA-Z]\w{1,100})*::)?[a-zA-Z]\w{1,100}(-[a-zA-Z]\w{1,100}){2}' + r'\.\w{1,100}[\w-]*\.v\d+(\.\d+){,2}((-[a-z]+)(\.\d+)?)?)', + bygroups(Whitespace, Name.Decorator)), + ], + 'date_constraints': [ + # ISO 8601-based date/time constraints + (r'[Xx?YyMmDdHhSs\d]{2,4}([:-][Xx?YyMmDdHhSs\d]{2}){2}', Literal.Date), + # ISO 8601-based duration constraints + optional trailing slash + (r'(P[YyMmWwDd]+(T[HhMmSs]+)?|PT[HhMmSs]+)/?', Literal.Date), + ], + 'ordered_values': [ + # ISO 8601 date with optional 'T' ligature + (r'\d{4}-\d{2}-\d{2}T?', Literal.Date), + # ISO 8601 time + (r'\d{2}:\d{2}:\d{2}(\.\d+)?([+-]\d{4}|Z)?', Literal.Date), + # ISO 8601 duration + (r'P((\d*(\.\d+)?[YyMmWwDd]){1,3}(T(\d*(\.\d+)?[HhMmSs]){,3})?|' + r'T(\d*(\.\d+)?[HhMmSs]){,3})', Literal.Date), + (r'[+-]?(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float), + (r'[+-]?\d*\.\d+%?', Number.Float), + (r'0x[0-9a-fA-F]+', Number.Hex), + (r'[+-]?\d+%?', Number.Integer), + ], + 'values': [ + include('ordered_values'), + (r'([Tt]rue|[Ff]alse)', Literal), + (r'"', String, 'string'), + (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char), + (r'[a-z][a-z0-9+.-]*:', Literal, 'uri'), + # term code + (r'(\[)(\w[\w-]*(?:\([^)\n]+\))?)(::)(\w[\w-]*)(\])', + bygroups(Punctuation, Name.Decorator, Punctuation, Name.Decorator, + Punctuation)), + (r'\|', Punctuation, 'interval'), + # list continuation + (r'\.\.\.', Punctuation), + ], + 'constraint_values': [ + (r'(\[)(\w[\w-]*(?:\([^)\n]+\))?)(::)', + bygroups(Punctuation, Name.Decorator, Punctuation), 'adl14_code_constraint'), + # ADL 1.4 ordinal constraint + (r'(\d*)(\|)(\[\w[\w-]*::\w[\w-]*\])((?:[,;])?)', + bygroups(Number, Punctuation, Name.Decorator, Punctuation)), + include('date_constraints'), + include('values'), + ], + + # ----- real states ----- + 'string': [ + ('"', String, '#pop'), + (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|' + r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape), + # all other characters + (r'[^\\"]+', String), + # stray backslash + (r'\\', String), + ], + 'uri': [ + # effective URI terminators + (r'[,>\s]', Punctuation, '#pop'), + (r'[^>\s,]+', Literal), + ], + 'interval': [ + (r'\|', Punctuation, '#pop'), + include('ordered_values'), + (r'\.\.', Punctuation), + (r'[<>=] *', Punctuation), + # handle +/- + (r'\+/-', Punctuation), + (r'\s+', Whitespace), + ], + 'any_code': [ + include('archetype_id'), + # if it is a code + (r'[a-z_]\w*[0-9.]+(@[^\]]+)?', Name.Decorator), + # if it is tuple with attribute names + (r'[a-z_]\w*', Name.Class), + # if it is an integer, i.e. Xpath child index + (r'[0-9]+', Text), + (r'\|', Punctuation, 'code_rubric'), + (r'\]', Punctuation, '#pop'), + # handle use_archetype statement + (r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace)), + ], + 'code_rubric': [ + (r'\|', Punctuation, '#pop'), + (r'[^|]+', String), + ], + 'adl14_code_constraint': [ + (r'\]', Punctuation, '#pop'), + (r'\|', Punctuation, 'code_rubric'), + (r'(\w[\w-]*)([;,]?)', bygroups(Name.Decorator, Punctuation)), + include('whitespace'), + ], + } + + +class OdinLexer(AtomsLexer): + """ + Lexer for ODIN syntax. + """ + name = 'ODIN' + aliases = ['odin'] + filenames = ['*.odin'] + mimetypes = ['text/odin'] + url = 'https://github.com/openEHR/odin' + version_added = '2.1' + + tokens = { + 'path': [ + (r'>', Punctuation, '#pop'), + # attribute name + (r'[a-z_]\w*', Name.Class), + (r'/', Punctuation), + (r'\[', Punctuation, 'key'), + (r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace), '#pop'), + (r'\s+', Whitespace, '#pop'), + ], + 'key': [ + include('values'), + (r'\]', Punctuation, '#pop'), + ], + 'type_cast': [ + (r'\)', Punctuation, '#pop'), + (r'[^)]+', Name.Class), + ], + 'root': [ + include('whitespace'), + (r'([Tt]rue|[Ff]alse)', Literal), + include('values'), + # x-ref path + (r'/', Punctuation, 'path'), + # x-ref path starting with key + (r'\[', Punctuation, 'key'), + # attribute name + (r'[a-z_]\w*', Name.Class), + (r'=', Operator), + (r'\(', Punctuation, 'type_cast'), + (r',', Punctuation), + (r'<', Punctuation), + (r'>', Punctuation), + (r';', Punctuation), + ], + } + + +class CadlLexer(AtomsLexer): + """ + Lexer for cADL syntax. + """ + name = 'cADL' + aliases = ['cadl'] + filenames = ['*.cadl'] + url = 'https://specifications.openehr.org/releases/AM/latest/ADL2.html#_cadl_constraint_adl' + version_added = '2.1' + + tokens = { + 'path': [ + # attribute name + (r'[a-z_]\w*', Name.Class), + (r'/', Punctuation), + (r'\[', Punctuation, 'any_code'), + (r'\s+', Punctuation, '#pop'), + ], + 'root': [ + include('whitespace'), + (r'(cardinality|existence|occurrences|group|include|exclude|' + r'allow_archetype|use_archetype|use_node)\W', Keyword.Type), + (r'(and|or|not|there_exists|xor|implies|for_all)\W', Keyword.Type), + (r'(after|before|closed)\W', Keyword.Type), + (r'(not)\W', Operator), + (r'(matches|is_in)\W', Operator), + # is_in / not is_in char + ('(\u2208|\u2209)', Operator), + # there_exists / not there_exists / for_all / and / or + ('(\u2203|\u2204|\u2200|\u2227|\u2228|\u22BB|\223C)', + Operator), + # regex in slot or as string constraint + (r'(\{)(\s*)(/[^}]+/)(\s*)(\})', + bygroups(Punctuation, Whitespace, String.Regex, Whitespace, Punctuation)), + # regex in slot or as string constraint + (r'(\{)(\s*)(\^[^}]+\^)(\s*)(\})', + bygroups(Punctuation, Whitespace, String.Regex, Whitespace, Punctuation)), + (r'/', Punctuation, 'path'), + # for cardinality etc + (r'(\{)((?:\d+\.\.)?(?:\d+|\*))' + r'((?:\s*;\s*(?:ordered|unordered|unique)){,2})(\})', + bygroups(Punctuation, Number, Number, Punctuation)), + # [{ is start of a tuple value + (r'\[\{', Punctuation), + (r'\}\]', Punctuation), + (r'\{', Punctuation), + (r'\}', Punctuation), + include('constraint_values'), + # type name + (r'[A-Z]\w+(<[A-Z]\w+([A-Za-z_<>]*)>)?', Name.Class), + # attribute name + (r'[a-z_]\w*', Name.Class), + (r'\[', Punctuation, 'any_code'), + (r'(~|//|\\\\|\+|-|/|\*|\^|!=|=|<=|>=|<|>]?)', Operator), + (r'\(', Punctuation), + (r'\)', Punctuation), + # for lists of values + (r',', Punctuation), + (r'"', String, 'string'), + # for assumed value + (r';', Punctuation), + ], + } + + +class AdlLexer(AtomsLexer): + """ + Lexer for ADL syntax. + """ + + name = 'ADL' + aliases = ['adl'] + filenames = ['*.adl', '*.adls', '*.adlf', '*.adlx'] + url = 'https://specifications.openehr.org/releases/AM/latest/ADL2.html' + version_added = '2.1' + + tokens = { + 'whitespace': [ + # blank line ends + (r'\s*\n', Whitespace), + # comment-only line + (r'^([ \t]*)(--.*)$', bygroups(Whitespace, Comment)), + ], + 'odin_section': [ + # repeating the following two rules from the root state enable multi-line + # strings that start in the first column to be dealt with + (r'^(language|description|ontology|terminology|annotations|' + r'component_terminologies|revision_history)([ \t]*\n)', + bygroups(Generic.Heading, Whitespace)), + (r'^(definition)([ \t]*\n)', bygroups(Generic.Heading, Whitespace), 'cadl_section'), + (r'^([ \t]*|[ \t]+.*)\n', using(OdinLexer)), + (r'^([^"]*")(>[ \t]*\n)', bygroups(String, Punctuation)), + # template overlay delimiter + (r'^----------*\n', Text, '#pop'), + (r'^.*\n', String), + default('#pop'), + ], + 'cadl_section': [ + (r'^([ \t]*|[ \t]+.*)\n', using(CadlLexer)), + default('#pop'), + ], + 'rules_section': [ + (r'^[ \t]+.*\n', using(CadlLexer)), + default('#pop'), + ], + 'metadata': [ + (r'\)', Punctuation, '#pop'), + (r';', Punctuation), + (r'([Tt]rue|[Ff]alse)', Literal), + # numbers and version ids + (r'\d+(\.\d+)*', Literal), + # Guids + (r'[0-9a-fA-F]{1,36}(-[0-9a-fA-F]{1,36}){3,}', Literal), + (r'\w+', Name.Class), + (r'"', String, 'string'), + (r'=', Operator), + (r'[ \t]+', Whitespace), + default('#pop'), + ], + 'root': [ + (r'^(archetype|template_overlay|operational_template|template|' + r'speciali[sz]e)', Generic.Heading), + (r'^(language|description|ontology|terminology|annotations|' + r'component_terminologies|revision_history)[ \t]*\n', + Generic.Heading, 'odin_section'), + (r'^(definition)[ \t]*\n', Generic.Heading, 'cadl_section'), + (r'^(rules)[ \t]*\n', Generic.Heading, 'rules_section'), + include('archetype_id'), + (r'([ \t]*)(\()', bygroups(Whitespace, Punctuation), 'metadata'), + include('whitespace'), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/arrow.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/arrow.py new file mode 100644 index 0000000000000000000000000000000000000000..3e55725b95a66a29a9e437a67bf71e4883b66eeb --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/arrow.py @@ -0,0 +1,116 @@ +""" + pygments.lexers.arrow + ~~~~~~~~~~~~~~~~~~~~~ + + Lexer for Arrow. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, bygroups, default, include +from pygments.token import Text, Operator, Keyword, Punctuation, Name, \ + String, Number, Whitespace + +__all__ = ['ArrowLexer'] + +TYPES = r'\b(int|bool|char)((?:\[\])*)(?=\s+)' +IDENT = r'([a-zA-Z_][a-zA-Z0-9_]*)' +DECL = TYPES + r'(\s+)' + IDENT + + +class ArrowLexer(RegexLexer): + """ + Lexer for Arrow + """ + + name = 'Arrow' + url = 'https://pypi.org/project/py-arrow-lang/' + aliases = ['arrow'] + filenames = ['*.arw'] + version_added = '2.7' + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'^[|\s]+', Punctuation), + include('blocks'), + include('statements'), + include('expressions'), + ], + 'blocks': [ + (r'(function)(\n+)(/-->)(\s*)' + + DECL + # 4 groups + r'(\()', bygroups( + Keyword.Reserved, Whitespace, Punctuation, + Whitespace, Keyword.Type, Punctuation, Whitespace, + Name.Function, Punctuation + ), 'fparams'), + (r'/-->$|\\-->$|/--<|\\--<|\^', Punctuation), + ], + 'statements': [ + (DECL, bygroups(Keyword.Type, Punctuation, Text, Name.Variable)), + (r'\[', Punctuation, 'index'), + (r'=', Operator), + (r'require|main', Keyword.Reserved), + (r'print', Keyword.Reserved, 'print'), + ], + 'expressions': [ + (r'\s+', Whitespace), + (r'[0-9]+', Number.Integer), + (r'true|false', Keyword.Constant), + (r"'", String.Char, 'char'), + (r'"', String.Double, 'string'), + (r'\{', Punctuation, 'array'), + (r'==|!=|<|>|\+|-|\*|/|%', Operator), + (r'and|or|not|length', Operator.Word), + (r'(input)(\s+)(int|char\[\])', bygroups( + Keyword.Reserved, Whitespace, Keyword.Type + )), + (IDENT + r'(\()', bygroups( + Name.Function, Punctuation + ), 'fargs'), + (IDENT, Name.Variable), + (r'\[', Punctuation, 'index'), + (r'\(', Punctuation, 'expressions'), + (r'\)', Punctuation, '#pop'), + ], + 'print': [ + include('expressions'), + (r',', Punctuation), + default('#pop'), + ], + 'fparams': [ + (DECL, bygroups(Keyword.Type, Punctuation, Whitespace, Name.Variable)), + (r',', Punctuation), + (r'\)', Punctuation, '#pop'), + ], + 'escape': [ + (r'\\(["\\/abfnrtv]|[0-9]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})', + String.Escape), + ], + 'char': [ + (r"'", String.Char, '#pop'), + include('escape'), + (r"[^'\\]", String.Char), + ], + 'string': [ + (r'"', String.Double, '#pop'), + include('escape'), + (r'[^"\\]+', String.Double), + ], + 'array': [ + include('expressions'), + (r'\}', Punctuation, '#pop'), + (r',', Punctuation), + ], + 'fargs': [ + include('expressions'), + (r'\)', Punctuation, '#pop'), + (r',', Punctuation), + ], + 'index': [ + include('expressions'), + (r'\]', Punctuation, '#pop'), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/arturo.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/arturo.py new file mode 100644 index 0000000000000000000000000000000000000000..c082a898173ad005909d6c2d17de99dc6df6a63f --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/arturo.py @@ -0,0 +1,249 @@ +""" + pygments.lexers.arturo + ~~~~~~~~~~~~~~~~~~~~~~ + + Lexer for the Arturo language. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, bygroups, do_insertions, include, \ + this, using, words +from pygments.token import Comment, Error, Keyword, Name, Number, Operator, \ + Punctuation, String, Text + +from pygments.util import ClassNotFound, get_bool_opt + +__all__ = ['ArturoLexer'] + + +class ArturoLexer(RegexLexer): + """ + For Arturo source code. + + See `Arturo's Github `_ + and `Arturo's Website `_. + """ + + name = 'Arturo' + aliases = ['arturo', 'art'] + filenames = ['*.art'] + url = 'https://arturo-lang.io/' + version_added = '2.14' + + def __init__(self, **options): + self.handle_annotateds = get_bool_opt(options, 'handle_annotateds', + True) + RegexLexer.__init__(self, **options) + + def handle_annotated_strings(self, match): + """Adds syntax from another languages inside annotated strings + + match args: + 1:open_string, + 2:exclamation_mark, + 3:lang_name, + 4:space_or_newline, + 5:code, + 6:close_string + """ + from pygments.lexers import get_lexer_by_name + + # Header's section + yield match.start(1), String.Double, match.group(1) + yield match.start(2), String.Interpol, match.group(2) + yield match.start(3), String.Interpol, match.group(3) + yield match.start(4), Text.Whitespace, match.group(4) + + lexer = None + if self.handle_annotateds: + try: + lexer = get_lexer_by_name(match.group(3).strip()) + except ClassNotFound: + pass + code = match.group(5) + + if lexer is None: + yield match.group(5), String, code + else: + yield from do_insertions([], lexer.get_tokens_unprocessed(code)) + + yield match.start(6), String.Double, match.group(6) + + tokens = { + 'root': [ + (r';.*?$', Comment.Single), + (r'^((\s#!)|(#!)).*?$', Comment.Hashbang), + + # Constants + (words(('false', 'true', 'maybe'), # boolean + suffix=r'\b'), Name.Constant), + (words(('this', 'init'), # class related keywords + prefix=r'\b', suffix=r'\b\??:?'), Name.Builtin.Pseudo), + (r'`.`', String.Char), # character + (r'\\\w+\b\??:?', Name.Property), # array index + (r'#\w+', Name.Constant), # color + (r'\b[0-9]+\.[0-9]+', Number.Float), # float + (r'\b[0-9]+', Number.Integer), # integer + (r'\w+\b\??:', Name.Label), # label + # Note: Literals can be labeled too + (r'\'(?:\w+\b\??:?)', Keyword.Declaration), # literal + (r'\:\w+', Keyword.Type), # type + # Note: Attributes can be labeled too + (r'\.\w+\??:?', Name.Attribute), # attributes + + # Switch structure + (r'(\()(.*?)(\)\?)', + bygroups(Punctuation, using(this), Punctuation)), + + # Single Line Strings + (r'"', String.Double, 'inside-simple-string'), + (r'»', String.Single, 'inside-smart-string'), + (r'«««', String.Double, 'inside-safe-string'), + (r'\{\/', String.Single, 'inside-regex-string'), + + # Multi Line Strings + (r'\{\:', String.Double, 'inside-curly-verb-string'), + (r'(\{)(\!)(\w+)(\s|\n)([\w\W]*?)(^\})', handle_annotated_strings), + (r'\{', String.Single, 'inside-curly-string'), + (r'\-{3,}', String.Single, 'inside-eof-string'), + + include('builtin-functions'), + + # Operators + (r'[()[\],]', Punctuation), + (words(('->', '==>', '|', '::', '@', '#', # sugar syntax + '$', '&', '!', '!!', './')), Name.Decorator), + (words(('<:', ':>', ':<', '>:', '<\\', '<>', '<', '>', + 'ø', '∞', + '+', '-', '*', '~', '=', '^', '%', '/', '//', + '==>', '<=>', '<==>', + '=>>', '<<=>>', '<<==>>', + '-->', '<->', '<-->', + '=|', '|=', '-:', ':-', + '_', '.', '..', '\\')), Operator), + + (r'\b\w+', Name), + (r'\s+', Text.Whitespace), + (r'.+$', Error), + ], + + 'inside-interpol': [ + (r'\|', String.Interpol, '#pop'), + (r'[^|]+', using(this)), + ], + 'inside-template': [ + (r'\|\|\>', String.Interpol, '#pop'), + (r'[^|]+', using(this)), + ], + 'string-escape': [ + (words(('\\\\', '\\n', '\\t', '\\"')), String.Escape), + ], + + 'inside-simple-string': [ + include('string-escape'), + (r'\|', String.Interpol, 'inside-interpol'), # Interpolation + (r'\<\|\|', String.Interpol, 'inside-template'), # Templates + (r'"', String.Double, '#pop'), # Closing Quote + (r'[^|"]+', String) # String Content + ], + 'inside-smart-string': [ + include('string-escape'), + (r'\|', String.Interpol, 'inside-interpol'), # Interpolation + (r'\<\|\|', String.Interpol, 'inside-template'), # Templates + (r'\n', String.Single, '#pop'), # Closing Quote + (r'[^|\n]+', String) # String Content + ], + 'inside-safe-string': [ + include('string-escape'), + (r'\|', String.Interpol, 'inside-interpol'), # Interpolation + (r'\<\|\|', String.Interpol, 'inside-template'), # Templates + (r'»»»', String.Double, '#pop'), # Closing Quote + (r'[^|»]+', String) # String Content + ], + 'inside-regex-string': [ + (r'\\[sSwWdDbBZApPxucItnvfr0]+', String.Escape), + (r'\|', String.Interpol, 'inside-interpol'), # Interpolation + (r'\<\|\|', String.Interpol, 'inside-template'), # Templates + (r'\/\}', String.Single, '#pop'), # Closing Quote + (r'[^|\/]+', String.Regex), # String Content + ], + 'inside-curly-verb-string': [ + include('string-escape'), + (r'\|', String.Interpol, 'inside-interpol'), # Interpolation + (r'\<\|\|', String.Interpol, 'inside-template'), # Templates + (r'\:\}', String.Double, '#pop'), # Closing Quote + (r'[^|<:]+', String), # String Content + ], + 'inside-curly-string': [ + include('string-escape'), + (r'\|', String.Interpol, 'inside-interpol'), # Interpolation + (r'\<\|\|', String.Interpol, 'inside-template'), # Templates + (r'\}', String.Single, '#pop'), # Closing Quote + (r'[^|<}]+', String), # String Content + ], + 'inside-eof-string': [ + include('string-escape'), + (r'\|', String.Interpol, 'inside-interpol'), # Interpolation + (r'\<\|\|', String.Interpol, 'inside-template'), # Templates + (r'\Z', String.Single, '#pop'), # Closing Quote + (r'[^|<]+', String), # String Content + ], + + 'builtin-functions': [ + (words(( + 'all', 'and', 'any', 'ascii', 'attr', 'attribute', + 'attributeLabel', 'binary', 'block' 'char', 'contains', + 'database', 'date', 'dictionary', 'empty', 'equal', 'even', + 'every', 'exists', 'false', 'floatin', 'function', 'greater', + 'greaterOrEqual', 'if', 'in', 'inline', 'integer', 'is', + 'key', 'label', 'leap', 'less', 'lessOrEqual', 'literal', + 'logical', 'lower', 'nand', 'negative', 'nor', 'not', + 'notEqual', 'null', 'numeric', 'odd', 'or', 'path', + 'pathLabel', 'positive', 'prefix', 'prime', 'set', 'some', + 'sorted', 'standalone', 'string', 'subset', 'suffix', + 'superset', 'ymbol', 'true', 'try', 'type', 'unless', 'upper', + 'when', 'whitespace', 'word', 'xnor', 'xor', 'zero', + ), prefix=r'\b', suffix=r'\b\?'), Name.Builtin), + (words(( + 'abs', 'acos', 'acosh', 'acsec', 'acsech', 'actan', 'actanh', + 'add', 'after', 'alphabet', 'and', 'angle', 'append', 'arg', + 'args', 'arity', 'array', 'as', 'asec', 'asech', 'asin', + 'asinh', 'atan', 'atan2', 'atanh', 'attr', 'attrs', 'average', + 'before', 'benchmark', 'blend', 'break', 'builtins1', + 'builtins2', 'call', 'capitalize', 'case', 'ceil', 'chop', + 'chunk', 'clear', 'close', 'cluster', 'color', 'combine', + 'conj', 'continue', 'copy', 'cos', 'cosh', 'couple', 'csec', + 'csech', 'ctan', 'ctanh', 'cursor', 'darken', 'dec', 'decode', + 'decouple', 'define', 'delete', 'desaturate', 'deviation', + 'dictionary', 'difference', 'digest', 'digits', 'div', 'do', + 'download', 'drop', 'dup', 'e', 'else', 'empty', 'encode', + 'ensure', 'env', 'epsilon', 'escape', 'execute', 'exit', 'exp', + 'extend', 'extract', 'factors', 'false', 'fdiv', 'filter', + 'first', 'flatten', 'floor', 'fold', 'from', 'function', + 'gamma', 'gcd', 'get', 'goto', 'hash', 'help', 'hypot', 'if', + 'in', 'inc', 'indent', 'index', 'infinity', 'info', 'input', + 'insert', 'inspect', 'intersection', 'invert', 'join', 'keys', + 'kurtosis', 'last', 'let', 'levenshtein', 'lighten', 'list', + 'ln', 'log', 'loop', 'lower', 'mail', 'map', 'match', 'max', + 'maybe', 'median', 'min', 'mod', 'module', 'mul', 'nand', + 'neg', 'new', 'nor', 'normalize', 'not', 'now', 'null', 'open', + 'or', 'outdent', 'pad', 'panic', 'path', 'pause', + 'permissions', 'permutate', 'pi', 'pop', 'pow', 'powerset', + 'powmod', 'prefix', 'print', 'prints', 'process', 'product', + 'query', 'random', 'range', 'read', 'relative', 'remove', + 'rename', 'render', 'repeat', 'replace', 'request', 'return', + 'reverse', 'round', 'sample', 'saturate', 'script', 'sec', + 'sech', 'select', 'serve', 'set', 'shl', 'shr', 'shuffle', + 'sin', 'sinh', 'size', 'skewness', 'slice', 'sort', 'split', + 'sqrt', 'squeeze', 'stack', 'strip', 'sub', 'suffix', 'sum', + 'switch', 'symbols', 'symlink', 'sys', 'take', 'tan', 'tanh', + 'terminal', 'to', 'true', 'truncate', 'try', 'type', 'union', + 'unique', 'unless', 'until', 'unzip', 'upper', 'values', 'var', + 'variance', 'volume', 'webview', 'while', 'with', 'wordwrap', + 'write', 'xnor', 'xor', 'zip' + ), prefix=r'\b', suffix=r'\b'), Name.Builtin) + ], + + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/asc.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/asc.py new file mode 100644 index 0000000000000000000000000000000000000000..49b82f5aa93ec5b7731e344ffbad1e9971f22bbc --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/asc.py @@ -0,0 +1,55 @@ +""" + pygments.lexers.asc + ~~~~~~~~~~~~~~~~~~~ + + Lexer for various ASCII armored files. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" +import re + +from pygments.lexer import RegexLexer, bygroups +from pygments.token import Comment, Generic, Name, Operator, String, Whitespace + +__all__ = ['AscLexer'] + + +class AscLexer(RegexLexer): + """ + Lexer for ASCII armored files, containing `-----BEGIN/END ...-----` wrapped + base64 data. + """ + name = 'ASCII armored' + aliases = ['asc', 'pem'] + filenames = [ + '*.asc', # PGP; *.gpg, *.pgp, and *.sig too, but those can be binary + '*.pem', # X.509; *.cer, *.crt, *.csr, and key etc too, but those can be binary + 'id_dsa', 'id_ecdsa', 'id_ecdsa_sk', 'id_ed25519', 'id_ed25519_sk', + 'id_rsa', # SSH private keys + ] + mimetypes = ['application/pgp-keys', 'application/pgp-encrypted', + 'application/pgp-signature', 'application/pem-certificate-chain'] + url = 'https://www.openpgp.org' + version_added = '2.10' + + flags = re.MULTILINE + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'^-----BEGIN [^\n]+-----$', Generic.Heading, 'data'), + (r'\S+', Comment), + ], + 'data': [ + (r'\s+', Whitespace), + (r'^([^:]+)(:)([ \t]+)(.*)', + bygroups(Name.Attribute, Operator, Whitespace, String)), + (r'^-----END [^\n]+-----$', Generic.Heading, 'root'), + (r'\S+', String), + ], + } + + def analyse_text(text): + if re.search(r'^-----BEGIN [^\n]+-----\r?\n', text): + return True diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/asm.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/asm.py new file mode 100644 index 0000000000000000000000000000000000000000..ff2ac67a913fd979cf1e4fe7173d67cff9e4c5ae --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/asm.py @@ -0,0 +1,1058 @@ +""" + pygments.lexers.asm + ~~~~~~~~~~~~~~~~~~~ + + Lexers for assembly languages. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, include, bygroups, using, words, \ + DelegatingLexer, default +from pygments.lexers.c_cpp import CppLexer, CLexer +from pygments.lexers.d import DLexer +from pygments.token import Text, Name, Number, String, Comment, Punctuation, \ + Other, Keyword, Operator, Whitespace + +__all__ = ['GasLexer', 'ObjdumpLexer', 'DObjdumpLexer', 'CppObjdumpLexer', + 'CObjdumpLexer', 'HsailLexer', 'LlvmLexer', 'LlvmMirBodyLexer', + 'LlvmMirLexer', 'NasmLexer', 'NasmObjdumpLexer', 'TasmLexer', + 'Ca65Lexer', 'Dasm16Lexer'] + + +class GasLexer(RegexLexer): + """ + For Gas (AT&T) assembly code. + """ + name = 'GAS' + aliases = ['gas', 'asm'] + filenames = ['*.s', '*.S'] + mimetypes = ['text/x-gas'] + url = 'https://www.gnu.org/software/binutils' + version_added = '' + + #: optional Comment or Whitespace + string = r'"(\\"|[^"])*"' + char = r'[\w$.@-]' + identifier = r'(?:[a-zA-Z$_]' + char + r'*|\.' + char + '+)' + number = r'(?:0[xX][a-fA-F0-9]+|#?-?\d+)' + register = '%' + identifier + r'\b' + + tokens = { + 'root': [ + include('whitespace'), + (identifier + ':', Name.Label), + (r'\.' + identifier, Name.Attribute, 'directive-args'), + (r'lock|rep(n?z)?|data\d+', Name.Attribute), + (identifier, Name.Function, 'instruction-args'), + (r'[\r\n]+', Text) + ], + 'directive-args': [ + (identifier, Name.Constant), + (string, String), + ('@' + identifier, Name.Attribute), + (number, Number.Integer), + (register, Name.Variable), + (r'[\r\n]+', Whitespace, '#pop'), + (r'([;#]|//).*?\n', Comment.Single, '#pop'), + (r'/[*].*?[*]/', Comment.Multiline), + (r'/[*].*?\n[\w\W]*?[*]/', Comment.Multiline, '#pop'), + + include('punctuation'), + include('whitespace') + ], + 'instruction-args': [ + # For objdump-disassembled code, shouldn't occur in + # actual assembler input + ('([a-z0-9]+)( )(<)('+identifier+')(>)', + bygroups(Number.Hex, Text, Punctuation, Name.Constant, + Punctuation)), + ('([a-z0-9]+)( )(<)('+identifier+')([-+])('+number+')(>)', + bygroups(Number.Hex, Text, Punctuation, Name.Constant, + Punctuation, Number.Integer, Punctuation)), + + # Address constants + (identifier, Name.Constant), + (number, Number.Integer), + # Registers + (register, Name.Variable), + # Numeric constants + ('$'+number, Number.Integer), + (r"$'(.|\\')'", String.Char), + (r'[\r\n]+', Whitespace, '#pop'), + (r'([;#]|//).*?\n', Comment.Single, '#pop'), + (r'/[*].*?[*]/', Comment.Multiline), + (r'/[*].*?\n[\w\W]*?[*]/', Comment.Multiline, '#pop'), + + include('punctuation'), + include('whitespace') + ], + 'whitespace': [ + (r'\n', Whitespace), + (r'\s+', Whitespace), + (r'([;#]|//).*?\n', Comment.Single), + (r'/[*][\w\W]*?[*]/', Comment.Multiline) + ], + 'punctuation': [ + (r'[-*,.()\[\]!:{}]+', Punctuation) + ] + } + + def analyse_text(text): + if re.search(r'^\.(text|data|section)', text, re.M): + return True + elif re.search(r'^\.\w+', text, re.M): + return 0.1 + + +def _objdump_lexer_tokens(asm_lexer): + """ + Common objdump lexer tokens to wrap an ASM lexer. + """ + hex_re = r'[0-9A-Za-z]' + return { + 'root': [ + # File name & format: + ('(.*?)(:)( +file format )(.*?)$', + bygroups(Name.Label, Punctuation, Text, String)), + # Section header + ('(Disassembly of section )(.*?)(:)$', + bygroups(Text, Name.Label, Punctuation)), + # Function labels + # (With offset) + ('('+hex_re+'+)( )(<)(.*?)([-+])(0[xX][A-Za-z0-9]+)(>:)$', + bygroups(Number.Hex, Whitespace, Punctuation, Name.Function, + Punctuation, Number.Hex, Punctuation)), + # (Without offset) + ('('+hex_re+'+)( )(<)(.*?)(>:)$', + bygroups(Number.Hex, Whitespace, Punctuation, Name.Function, + Punctuation)), + # Code line with disassembled instructions + ('( *)('+hex_re+r'+:)(\t)((?:'+hex_re+hex_re+' )+)( *\t)([a-zA-Z].*?)$', + bygroups(Whitespace, Name.Label, Whitespace, Number.Hex, Whitespace, + using(asm_lexer))), + # Code line without raw instructions (objdump --no-show-raw-insn) + ('( *)('+hex_re+r'+:)( *\t)([a-zA-Z].*?)$', + bygroups(Whitespace, Name.Label, Whitespace, + using(asm_lexer))), + # Code line with ascii + ('( *)('+hex_re+r'+:)(\t)((?:'+hex_re+hex_re+' )+)( *)(.*?)$', + bygroups(Whitespace, Name.Label, Whitespace, Number.Hex, Whitespace, String)), + # Continued code line, only raw opcodes without disassembled + # instruction + ('( *)('+hex_re+r'+:)(\t)((?:'+hex_re+hex_re+' )+)$', + bygroups(Whitespace, Name.Label, Whitespace, Number.Hex)), + # Skipped a few bytes + (r'\t\.\.\.$', Text), + # Relocation line + # (With offset) + (r'(\t\t\t)('+hex_re+r'+:)( )([^\t]+)(\t)(.*?)([-+])(0x'+hex_re+'+)$', + bygroups(Whitespace, Name.Label, Whitespace, Name.Property, Whitespace, + Name.Constant, Punctuation, Number.Hex)), + # (Without offset) + (r'(\t\t\t)('+hex_re+r'+:)( )([^\t]+)(\t)(.*?)$', + bygroups(Whitespace, Name.Label, Whitespace, Name.Property, Whitespace, + Name.Constant)), + (r'[^\n]+\n', Other) + ] + } + + +class ObjdumpLexer(RegexLexer): + """ + For the output of ``objdump -dr``. + """ + name = 'objdump' + aliases = ['objdump'] + filenames = ['*.objdump'] + mimetypes = ['text/x-objdump'] + url = 'https://www.gnu.org/software/binutils' + version_added = '' + + tokens = _objdump_lexer_tokens(GasLexer) + + +class DObjdumpLexer(DelegatingLexer): + """ + For the output of ``objdump -Sr`` on compiled D files. + """ + name = 'd-objdump' + aliases = ['d-objdump'] + filenames = ['*.d-objdump'] + mimetypes = ['text/x-d-objdump'] + url = 'https://www.gnu.org/software/binutils' + version_added = '' + + def __init__(self, **options): + super().__init__(DLexer, ObjdumpLexer, **options) + + +class CppObjdumpLexer(DelegatingLexer): + """ + For the output of ``objdump -Sr`` on compiled C++ files. + """ + name = 'cpp-objdump' + aliases = ['cpp-objdump', 'c++-objdumb', 'cxx-objdump'] + filenames = ['*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'] + mimetypes = ['text/x-cpp-objdump'] + url = 'https://www.gnu.org/software/binutils' + version_added = '' + + def __init__(self, **options): + super().__init__(CppLexer, ObjdumpLexer, **options) + + +class CObjdumpLexer(DelegatingLexer): + """ + For the output of ``objdump -Sr`` on compiled C files. + """ + name = 'c-objdump' + aliases = ['c-objdump'] + filenames = ['*.c-objdump'] + mimetypes = ['text/x-c-objdump'] + url = 'https://www.gnu.org/software/binutils' + version_added = '' + + + def __init__(self, **options): + super().__init__(CLexer, ObjdumpLexer, **options) + + +class HsailLexer(RegexLexer): + """ + For HSAIL assembly code. + """ + name = 'HSAIL' + aliases = ['hsail', 'hsa'] + filenames = ['*.hsail'] + mimetypes = ['text/x-hsail'] + url = 'https://en.wikipedia.org/wiki/Heterogeneous_System_Architecture#HSA_Intermediate_Layer' + version_added = '2.2' + + string = r'"[^"]*?"' + identifier = r'[a-zA-Z_][\w.]*' + # Registers + register_number = r'[0-9]+' + register = r'(\$(c|s|d|q)' + register_number + r')\b' + # Qualifiers + alignQual = r'(align\(\d+\))' + widthQual = r'(width\((\d+|all)\))' + allocQual = r'(alloc\(agent\))' + # Instruction Modifiers + roundingMod = (r'((_ftz)?(_up|_down|_zero|_near))') + datatypeMod = (r'_(' + # packedTypes + r'u8x4|s8x4|u16x2|s16x2|u8x8|s8x8|u16x4|s16x4|u32x2|s32x2|' + r'u8x16|s8x16|u16x8|s16x8|u32x4|s32x4|u64x2|s64x2|' + r'f16x2|f16x4|f16x8|f32x2|f32x4|f64x2|' + # baseTypes + r'u8|s8|u16|s16|u32|s32|u64|s64|' + r'b128|b8|b16|b32|b64|b1|' + r'f16|f32|f64|' + # opaqueType + r'roimg|woimg|rwimg|samp|sig32|sig64)') + + # Numeric Constant + float = r'((\d+\.)|(\d*\.\d+))[eE][+-]?\d+' + hexfloat = r'0[xX](([0-9a-fA-F]+\.[0-9a-fA-F]*)|([0-9a-fA-F]*\.[0-9a-fA-F]+))[pP][+-]?\d+' + ieeefloat = r'0(?:[hH][0-9a-fA-F]{4}|[fF][0-9a-fA-F]{8}|[dD][0-9a-fA-F]{16})' + + tokens = { + 'root': [ + include('whitespace'), + include('comments'), + + (string, String), + + (r'@' + identifier + ':?', Name.Label), + + (register, Name.Variable.Anonymous), + + include('keyword'), + + (r'&' + identifier, Name.Variable.Global), + (r'%' + identifier, Name.Variable), + + (hexfloat, Number.Hex), + (r'0[xX][a-fA-F0-9]+', Number.Hex), + (ieeefloat, Number.Float), + (float, Number.Float), + (r'\d+', Number.Integer), + + (r'[=<>{}\[\]()*.,:;!]|x\b', Punctuation) + ], + 'whitespace': [ + (r'\s+', Whitespace), + ], + 'comments': [ + (r'/\*.*?\*/', Comment.Multiline), + (r'//.*?\n', Comment.Single), + ], + 'keyword': [ + # Types + (r'kernarg' + datatypeMod, Keyword.Type), + + # Regular keywords + (r'\$(full|base|small|large|default|zero|near)', Keyword), + (words(( + 'module', 'extension', 'pragma', 'prog', 'indirect', 'signature', + 'decl', 'kernel', 'function', 'enablebreakexceptions', + 'enabledetectexceptions', 'maxdynamicgroupsize', 'maxflatgridsize', + 'maxflatworkgroupsize', 'requireddim', 'requiredgridsize', + 'requiredworkgroupsize', 'requirenopartialworkgroups'), + suffix=r'\b'), Keyword), + + # instructions + (roundingMod, Keyword), + (datatypeMod, Keyword), + (r'_(' + alignQual + '|' + widthQual + ')', Keyword), + (r'_kernarg', Keyword), + (r'(nop|imagefence)\b', Keyword), + (words(( + 'cleardetectexcept', 'clock', 'cuid', 'debugtrap', 'dim', + 'getdetectexcept', 'groupbaseptr', 'kernargbaseptr', 'laneid', + 'maxcuid', 'maxwaveid', 'packetid', 'setdetectexcept', 'waveid', + 'workitemflatabsid', 'workitemflatid', 'nullptr', 'abs', 'bitrev', + 'currentworkgroupsize', 'currentworkitemflatid', 'fract', 'ncos', + 'neg', 'nexp2', 'nlog2', 'nrcp', 'nrsqrt', 'nsin', 'nsqrt', + 'gridgroups', 'gridsize', 'not', 'sqrt', 'workgroupid', + 'workgroupsize', 'workitemabsid', 'workitemid', 'ceil', 'floor', + 'rint', 'trunc', 'add', 'bitmask', 'borrow', 'carry', 'copysign', + 'div', 'rem', 'sub', 'shl', 'shr', 'and', 'or', 'xor', 'unpackhi', + 'unpacklo', 'max', 'min', 'fma', 'mad', 'bitextract', 'bitselect', + 'shuffle', 'cmov', 'bitalign', 'bytealign', 'lerp', 'nfma', 'mul', + 'mulhi', 'mul24hi', 'mul24', 'mad24', 'mad24hi', 'bitinsert', + 'combine', 'expand', 'lda', 'mov', 'pack', 'unpack', 'packcvt', + 'unpackcvt', 'sad', 'sementp', 'ftos', 'stof', 'cmp', 'ld', 'st', + '_eq', '_ne', '_lt', '_le', '_gt', '_ge', '_equ', '_neu', '_ltu', + '_leu', '_gtu', '_geu', '_num', '_nan', '_seq', '_sne', '_slt', + '_sle', '_sgt', '_sge', '_snum', '_snan', '_sequ', '_sneu', '_sltu', + '_sleu', '_sgtu', '_sgeu', 'atomic', '_ld', '_st', '_cas', '_add', + '_and', '_exch', '_max', '_min', '_or', '_sub', '_wrapdec', + '_wrapinc', '_xor', 'ret', 'cvt', '_readonly', '_kernarg', '_global', + 'br', 'cbr', 'sbr', '_scacq', '_screl', '_scar', '_rlx', '_wave', + '_wg', '_agent', '_system', 'ldimage', 'stimage', '_v2', '_v3', '_v4', + '_1d', '_2d', '_3d', '_1da', '_2da', '_1db', '_2ddepth', '_2dadepth', + '_width', '_height', '_depth', '_array', '_channelorder', + '_channeltype', 'querysampler', '_coord', '_filter', '_addressing', + 'barrier', 'wavebarrier', 'initfbar', 'joinfbar', 'waitfbar', + 'arrivefbar', 'leavefbar', 'releasefbar', 'ldf', 'activelaneid', + 'activelanecount', 'activelanemask', 'activelanepermute', 'call', + 'scall', 'icall', 'alloca', 'packetcompletionsig', + 'addqueuewriteindex', 'casqueuewriteindex', 'ldqueuereadindex', + 'stqueuereadindex', 'readonly', 'global', 'private', 'group', + 'spill', 'arg', '_upi', '_downi', '_zeroi', '_neari', '_upi_sat', + '_downi_sat', '_zeroi_sat', '_neari_sat', '_supi', '_sdowni', + '_szeroi', '_sneari', '_supi_sat', '_sdowni_sat', '_szeroi_sat', + '_sneari_sat', '_pp', '_ps', '_sp', '_ss', '_s', '_p', '_pp_sat', + '_ps_sat', '_sp_sat', '_ss_sat', '_s_sat', '_p_sat')), Keyword), + + # Integer types + (r'i[1-9]\d*', Keyword) + ] + } + + +class LlvmLexer(RegexLexer): + """ + For LLVM assembly code. + """ + name = 'LLVM' + url = 'https://llvm.org/docs/LangRef.html' + aliases = ['llvm'] + filenames = ['*.ll'] + mimetypes = ['text/x-llvm'] + version_added = '' + + #: optional Comment or Whitespace + string = r'"[^"]*?"' + identifier = r'([-a-zA-Z$._][\w\-$.]*|' + string + ')' + block_label = r'(' + identifier + r'|(\d+))' + + tokens = { + 'root': [ + include('whitespace'), + + # Before keywords, because keywords are valid label names :(... + (block_label + r'\s*:', Name.Label), + + include('keyword'), + + (r'%' + identifier, Name.Variable), + (r'@' + identifier, Name.Variable.Global), + (r'%\d+', Name.Variable.Anonymous), + (r'@\d+', Name.Variable.Global), + (r'#\d+', Name.Variable.Global), + (r'!' + identifier, Name.Variable), + (r'!\d+', Name.Variable.Anonymous), + (r'c?' + string, String), + + (r'0[xX][KLMHR]?[a-fA-F0-9]+', Number), + (r'-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?', Number), + + (r'[=<>{}\[\]()*.,!]|x\b', Punctuation) + ], + 'whitespace': [ + (r'\s+', Whitespace), + (r';.*?\n', Comment), + (r'/\*', Comment, 'c-comment'), + ], + 'c-comment': [ + (r'[^*]+', Comment), + (r'\*/', Comment, '#pop'), + # Consume lone asterisks as non-comment-ending content. + (r'\*', Comment), + ], + 'keyword': [ + # Regular keywords + (words(( + 'aarch64_sve_vector_pcs', 'aarch64_vector_pcs', 'acq_rel', + 'acquire', 'add', 'addrspace', 'addrspacecast', 'afn', 'alias', + 'aliasee', 'align', 'alignLog2', 'alignstack', 'alloca', + 'allocsize', 'allOnes', 'alwaysinline', 'alwaysInline', + 'amdgpu_cs', 'amdgpu_es', 'amdgpu_gfx', 'amdgpu_gs', + 'amdgpu_hs', 'amdgpu_kernel', 'amdgpu_ls', 'amdgpu_ps', + 'amdgpu_vs', 'and', 'any', 'anyregcc', 'appending', 'arcp', + 'argmemonly', 'args', 'arm_aapcs_vfpcc', 'arm_aapcscc', + 'arm_apcscc', 'ashr', 'asm', 'atomic', 'atomicrmw', + 'attributes', 'available_externally', 'avr_intrcc', + 'avr_signalcc', 'bit', 'bitcast', 'bitMask', 'blockaddress', + 'blockcount', 'br', 'branchFunnel', 'builtin', 'byArg', + 'byref', 'byte', 'byteArray', 'byval', 'c', 'call', 'callbr', + 'callee', 'caller', 'calls', 'canAutoHide', 'catch', + 'catchpad', 'catchret', 'catchswitch', 'cc', 'ccc', + 'cfguard_checkcc', 'cleanup', 'cleanuppad', 'cleanupret', + 'cmpxchg', 'cold', 'coldcc', 'comdat', 'common', 'constant', + 'contract', 'convergent', 'critical', 'cxx_fast_tlscc', + 'datalayout', 'declare', 'default', 'define', 'deplibs', + 'dereferenceable', 'dereferenceable_or_null', 'distinct', + 'dllexport', 'dllimport', 'dso_local', 'dso_local_equivalent', + 'dso_preemptable', 'dsoLocal', 'eq', 'exact', 'exactmatch', + 'extern_weak', 'external', 'externally_initialized', + 'extractelement', 'extractvalue', 'fadd', 'false', 'fast', + 'fastcc', 'fcmp', 'fdiv', 'fence', 'filter', 'flags', 'fmul', + 'fneg', 'fpext', 'fptosi', 'fptoui', 'fptrunc', 'freeze', + 'frem', 'from', 'fsub', 'funcFlags', 'function', 'gc', + 'getelementptr', 'ghccc', 'global', 'guid', 'gv', 'hash', + 'hhvm_ccc', 'hhvmcc', 'hidden', 'hot', 'hotness', 'icmp', + 'ifunc', 'inaccessiblemem_or_argmemonly', + 'inaccessiblememonly', 'inalloca', 'inbounds', 'indir', + 'indirectbr', 'info', 'initialexec', 'inline', 'inlineBits', + 'inlinehint', 'inrange', 'inreg', 'insertelement', + 'insertvalue', 'insts', 'intel_ocl_bicc', 'inteldialect', + 'internal', 'inttoptr', 'invoke', 'jumptable', 'kind', + 'landingpad', 'largest', 'linkage', 'linkonce', 'linkonce_odr', + 'live', 'load', 'local_unnamed_addr', 'localdynamic', + 'localexec', 'lshr', 'max', 'metadata', 'min', 'minsize', + 'module', 'monotonic', 'msp430_intrcc', 'mul', 'mustprogress', + 'musttail', 'naked', 'name', 'nand', 'ne', 'nest', 'ninf', + 'nnan', 'noalias', 'nobuiltin', 'nocallback', 'nocapture', + 'nocf_check', 'noduplicate', 'noduplicates', 'nofree', + 'noimplicitfloat', 'noinline', 'noInline', 'nomerge', 'none', + 'nonlazybind', 'nonnull', 'noprofile', 'norecurse', + 'noRecurse', 'noredzone', 'noreturn', 'nosync', 'notail', + 'notEligibleToImport', 'noundef', 'nounwind', 'nsw', + 'nsz', 'null', 'null_pointer_is_valid', 'nuw', 'oeq', 'offset', + 'oge', 'ogt', 'ole', 'olt', 'one', 'opaque', 'optforfuzzing', + 'optnone', 'optsize', 'or', 'ord', 'param', 'params', + 'partition', 'path', 'personality', 'phi', 'poison', + 'preallocated', 'prefix', 'preserve_allcc', 'preserve_mostcc', + 'private', 'prologue', 'protected', 'ptrtoint', 'ptx_device', + 'ptx_kernel', 'readnone', 'readNone', 'readonly', 'readOnly', + 'reassoc', 'refs', 'relbf', 'release', 'resByArg', 'resume', + 'ret', 'returnDoesNotAlias', 'returned', 'returns_twice', + 'safestack', 'samesize', 'sanitize_address', + 'sanitize_hwaddress', 'sanitize_memory', 'sanitize_memtag', + 'sanitize_thread', 'sdiv', 'section', 'select', 'seq_cst', + 'sext', 'sge', 'sgt', 'shadowcallstack', 'shl', + 'shufflevector', 'sideeffect', 'signext', 'single', + 'singleImpl', 'singleImplName', 'sitofp', 'sizeM1', + 'sizeM1BitWidth', 'sle', 'slt', 'source_filename', + 'speculatable', 'speculative_load_hardening', 'spir_func', + 'spir_kernel', 'splat', 'srem', 'sret', 'ssp', 'sspreq', + 'sspstrong', 'store', 'strictfp', 'sub', 'summaries', + 'summary', 'swiftcc', 'swifterror', 'swiftself', 'switch', + 'syncscope', 'tail', 'tailcc', 'target', 'thread_local', 'to', + 'token', 'triple', 'true', 'trunc', 'type', + 'typeCheckedLoadConstVCalls', 'typeCheckedLoadVCalls', + 'typeid', 'typeidCompatibleVTable', 'typeIdInfo', + 'typeTestAssumeConstVCalls', 'typeTestAssumeVCalls', + 'typeTestRes', 'typeTests', 'udiv', 'ueq', 'uge', 'ugt', + 'uitofp', 'ule', 'ult', 'umax', 'umin', 'undef', 'une', + 'uniformRetVal', 'uniqueRetVal', 'unknown', 'unnamed_addr', + 'uno', 'unordered', 'unreachable', 'unsat', 'unwind', 'urem', + 'uselistorder', 'uselistorder_bb', 'uwtable', 'va_arg', + 'varFlags', 'variable', 'vcall_visibility', 'vFuncId', + 'virtFunc', 'virtualConstProp', 'void', 'volatile', 'vscale', + 'vTableFuncs', 'weak', 'weak_odr', 'webkit_jscc', 'win64cc', + 'within', 'wpdRes', 'wpdResolutions', 'writeonly', 'x', + 'x86_64_sysvcc', 'x86_fastcallcc', 'x86_intrcc', 'x86_mmx', + 'x86_regcallcc', 'x86_stdcallcc', 'x86_thiscallcc', + 'x86_vectorcallcc', 'xchg', 'xor', 'zeroext', + 'zeroinitializer', 'zext', 'immarg', 'willreturn'), + suffix=r'\b'), Keyword), + + # Types + (words(('void', 'half', 'bfloat', 'float', 'double', 'fp128', + 'x86_fp80', 'ppc_fp128', 'label', 'metadata', 'x86_mmx', + 'x86_amx', 'token', 'ptr')), + Keyword.Type), + + # Integer types + (r'i[1-9]\d*', Keyword.Type) + ] + } + + +class LlvmMirBodyLexer(RegexLexer): + """ + For LLVM MIR examples without the YAML wrapper. + """ + name = 'LLVM-MIR Body' + url = 'https://llvm.org/docs/MIRLangRef.html' + aliases = ['llvm-mir-body'] + filenames = [] + mimetypes = [] + version_added = '2.6' + + tokens = { + 'root': [ + # Attributes on basic blocks + (words(('liveins', 'successors'), suffix=':'), Keyword), + # Basic Block Labels + (r'bb\.[0-9]+(\.[a-zA-Z0-9_.-]+)?( \(address-taken\))?:', Name.Label), + (r'bb\.[0-9]+ \(%[a-zA-Z0-9_.-]+\)( \(address-taken\))?:', Name.Label), + (r'%bb\.[0-9]+(\.\w+)?', Name.Label), + # Stack references + (r'%stack\.[0-9]+(\.\w+\.addr)?', Name), + # Subreg indices + (r'%subreg\.\w+', Name), + # Virtual registers + (r'%[a-zA-Z0-9_]+ *', Name.Variable, 'vreg'), + # Reference to LLVM-IR global + include('global'), + # Reference to Intrinsic + (r'intrinsic\(\@[a-zA-Z0-9_.]+\)', Name.Variable.Global), + # Comparison predicates + (words(('eq', 'ne', 'sgt', 'sge', 'slt', 'sle', 'ugt', 'uge', 'ult', + 'ule'), prefix=r'intpred\(', suffix=r'\)'), Name.Builtin), + (words(('oeq', 'one', 'ogt', 'oge', 'olt', 'ole', 'ugt', 'uge', + 'ult', 'ule'), prefix=r'floatpred\(', suffix=r'\)'), + Name.Builtin), + # Physical registers + (r'\$\w+', String.Single), + # Assignment operator + (r'=', Operator), + # gMIR Opcodes + (r'(G_ANYEXT|G_[SZ]EXT|G_SEXT_INREG|G_TRUNC|G_IMPLICIT_DEF|G_PHI|' + r'G_FRAME_INDEX|G_GLOBAL_VALUE|G_INTTOPTR|G_PTRTOINT|G_BITCAST|' + r'G_CONSTANT|G_FCONSTANT|G_VASTART|G_VAARG|G_CTLZ|G_CTLZ_ZERO_UNDEF|' + r'G_CTTZ|G_CTTZ_ZERO_UNDEF|G_CTPOP|G_BSWAP|G_BITREVERSE|' + r'G_ADDRSPACE_CAST|G_BLOCK_ADDR|G_JUMP_TABLE|G_DYN_STACKALLOC|' + r'G_ADD|G_SUB|G_MUL|G_[SU]DIV|G_[SU]REM|G_AND|G_OR|G_XOR|G_SHL|' + r'G_[LA]SHR|G_[IF]CMP|G_SELECT|G_GEP|G_PTR_MASK|G_SMIN|G_SMAX|' + r'G_UMIN|G_UMAX|G_[US]ADDO|G_[US]ADDE|G_[US]SUBO|G_[US]SUBE|' + r'G_[US]MULO|G_[US]MULH|G_FNEG|G_FPEXT|G_FPTRUNC|G_FPTO[US]I|' + r'G_[US]ITOFP|G_FABS|G_FCOPYSIGN|G_FCANONICALIZE|G_FMINNUM|' + r'G_FMAXNUM|G_FMINNUM_IEEE|G_FMAXNUM_IEEE|G_FMINIMUM|G_FMAXIMUM|' + r'G_FADD|G_FSUB|G_FMUL|G_FMA|G_FMAD|G_FDIV|G_FREM|G_FPOW|G_FEXP|' + r'G_FEXP2|G_FLOG|G_FLOG2|G_FLOG10|G_FCEIL|G_FCOS|G_FSIN|G_FSQRT|' + r'G_FFLOOR|G_FRINT|G_FNEARBYINT|G_INTRINSIC_TRUNC|' + r'G_INTRINSIC_ROUND|G_LOAD|G_[ZS]EXTLOAD|G_INDEXED_LOAD|' + r'G_INDEXED_[ZS]EXTLOAD|G_STORE|G_INDEXED_STORE|' + r'G_ATOMIC_CMPXCHG_WITH_SUCCESS|G_ATOMIC_CMPXCHG|' + r'G_ATOMICRMW_(XCHG|ADD|SUB|AND|NAND|OR|XOR|MAX|MIN|UMAX|UMIN|FADD|' + r'FSUB)' + r'|G_FENCE|G_EXTRACT|G_UNMERGE_VALUES|G_INSERT|G_MERGE_VALUES|' + r'G_BUILD_VECTOR|G_BUILD_VECTOR_TRUNC|G_CONCAT_VECTORS|' + r'G_INTRINSIC|G_INTRINSIC_W_SIDE_EFFECTS|G_BR|G_BRCOND|' + r'G_BRINDIRECT|G_BRJT|G_INSERT_VECTOR_ELT|G_EXTRACT_VECTOR_ELT|' + r'G_SHUFFLE_VECTOR)\b', + Name.Builtin), + # Target independent opcodes + (r'(COPY|PHI|INSERT_SUBREG|EXTRACT_SUBREG|REG_SEQUENCE)\b', + Name.Builtin), + # Flags + (words(('killed', 'implicit')), Keyword), + # ConstantInt values + (r'(i[0-9]+)( +)', bygroups(Keyword.Type, Whitespace), 'constantint'), + # ConstantFloat values + (r'(half|float|double) +', Keyword.Type, 'constantfloat'), + # Bare immediates + include('integer'), + # MMO's + (r'(::)( *)', bygroups(Operator, Whitespace), 'mmo'), + # MIR Comments + (r';.*', Comment), + # If we get here, assume it's a target instruction + (r'[a-zA-Z0-9_]+', Name), + # Everything else that isn't highlighted + (r'[(), \n]+', Text), + ], + # The integer constant from a ConstantInt value + 'constantint': [ + include('integer'), + (r'(?=.)', Text, '#pop'), + ], + # The floating point constant from a ConstantFloat value + 'constantfloat': [ + include('float'), + (r'(?=.)', Text, '#pop'), + ], + 'vreg': [ + # The bank or class if there is one + (r'( *)(:(?!:))', bygroups(Whitespace, Keyword), ('#pop', 'vreg_bank_or_class')), + # The LLT if there is one + (r'( *)(\()', bygroups(Whitespace, Text), 'vreg_type'), + (r'(?=.)', Text, '#pop'), + ], + 'vreg_bank_or_class': [ + # The unassigned bank/class + (r'( *)(_)', bygroups(Whitespace, Name.Variable.Magic)), + (r'( *)([a-zA-Z0-9_]+)', bygroups(Whitespace, Name.Variable)), + # The LLT if there is one + (r'( *)(\()', bygroups(Whitespace, Text), 'vreg_type'), + (r'(?=.)', Text, '#pop'), + ], + 'vreg_type': [ + # Scalar and pointer types + (r'( *)([sp][0-9]+)', bygroups(Whitespace, Keyword.Type)), + (r'( *)(<[0-9]+ *x *[sp][0-9]+>)', bygroups(Whitespace, Keyword.Type)), + (r'\)', Text, '#pop'), + (r'(?=.)', Text, '#pop'), + ], + 'mmo': [ + (r'\(', Text), + (r' +', Whitespace), + (words(('load', 'store', 'on', 'into', 'from', 'align', 'monotonic', + 'acquire', 'release', 'acq_rel', 'seq_cst')), + Keyword), + # IR references + (r'%ir\.[a-zA-Z0-9_.-]+', Name), + (r'%ir-block\.[a-zA-Z0-9_.-]+', Name), + (r'[-+]', Operator), + include('integer'), + include('global'), + (r',', Punctuation), + (r'\), \(', Text), + (r'\)', Text, '#pop'), + ], + 'integer': [(r'-?[0-9]+', Number.Integer),], + 'float': [(r'-?[0-9]+\.[0-9]+(e[+-][0-9]+)?', Number.Float)], + 'global': [(r'\@[a-zA-Z0-9_.]+', Name.Variable.Global)], + } + + +class LlvmMirLexer(RegexLexer): + """ + Lexer for the overall LLVM MIR document format. + + MIR is a human readable serialization format that's used to represent LLVM's + machine specific intermediate representation. It allows LLVM's developers to + see the state of the compilation process at various points, as well as test + individual pieces of the compiler. + """ + name = 'LLVM-MIR' + url = 'https://llvm.org/docs/MIRLangRef.html' + aliases = ['llvm-mir'] + filenames = ['*.mir'] + version_added = '2.6' + + tokens = { + 'root': [ + # Comments are hashes at the YAML level + (r'#.*', Comment), + # Documents starting with | are LLVM-IR + (r'--- \|$', Keyword, 'llvm_ir'), + # Other documents are MIR + (r'---', Keyword, 'llvm_mir'), + # Consume everything else in one token for efficiency + (r'[^-#]+|.', Text), + ], + 'llvm_ir': [ + # Documents end with '...' or '---' + (r'(\.\.\.|(?=---))', Keyword, '#pop'), + # Delegate to the LlvmLexer + (r'([\s\S]+?)(?=(\.\.\.|---))', bygroups(using(LlvmLexer))), + ], + 'llvm_mir': [ + # Comments are hashes at the YAML level + (r'#.*', Comment), + # Documents end with '...' or '---' + (r'(\.\.\.|(?=---))', Keyword, '#pop'), + # Handle the simple attributes + (r'name:', Keyword, 'name'), + (words(('alignment', ), + suffix=':'), Keyword, 'number'), + (words(('legalized', 'regBankSelected', 'tracksRegLiveness', + 'selected', 'exposesReturnsTwice'), + suffix=':'), Keyword, 'boolean'), + # Handle the attributes don't highlight inside + (words(('registers', 'stack', 'fixedStack', 'liveins', 'frameInfo', + 'machineFunctionInfo'), + suffix=':'), Keyword), + # Delegate the body block to the LlvmMirBodyLexer + (r'body: *\|', Keyword, 'llvm_mir_body'), + # Consume everything else + (r'.+', Text), + (r'\n', Whitespace), + ], + 'name': [ + (r'[^\n]+', Name), + default('#pop'), + ], + 'boolean': [ + (r' *(true|false)', Name.Builtin), + default('#pop'), + ], + 'number': [ + (r' *[0-9]+', Number), + default('#pop'), + ], + 'llvm_mir_body': [ + # Documents end with '...' or '---'. + # We have to pop llvm_mir_body and llvm_mir + (r'(\.\.\.|(?=---))', Keyword, '#pop:2'), + # Delegate the body block to the LlvmMirBodyLexer + (r'([\s\S]+?)(?=\.\.\.|---)', bygroups(using(LlvmMirBodyLexer))), + # The '...' is optional. If we didn't already find it then it isn't + # there. There might be a '---' instead though. + (r'(?!\.\.\.|---)([\s\S]+)', bygroups(using(LlvmMirBodyLexer))), + ], + } + + +class NasmLexer(RegexLexer): + """ + For Nasm (Intel) assembly code. + """ + name = 'NASM' + aliases = ['nasm'] + filenames = ['*.asm', '*.ASM', '*.nasm'] + mimetypes = ['text/x-nasm'] + url = 'https://nasm.us' + version_added = '' + + # Tasm uses the same file endings, but TASM is not as common as NASM, so + # we prioritize NASM higher by default + priority = 1.0 + + identifier = r'[a-z$._?][\w$.?#@~]*' + hexn = r'(?:0x[0-9a-f]+|$0[0-9a-f]*|[0-9]+[0-9a-f]*h)' + octn = r'[0-7]+q' + binn = r'[01]+b' + decn = r'[0-9]+' + floatn = decn + r'\.e?' + decn + string = r'"(\\"|[^"\n])*"|' + r"'(\\'|[^'\n])*'|" + r"`(\\`|[^`\n])*`" + declkw = r'(?:res|d)[bwdqt]|times' + register = (r'(r[0-9][0-5]?[bwd]?|' + r'[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|' + r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]|k[0-7]|' + r'[xyz]mm(?:[12][0-9]?|3[01]?|[04-9]))\b') + wordop = r'seg|wrt|strict|rel|abs' + type = r'byte|[dq]?word' + # Directives must be followed by whitespace, otherwise CPU will match + # cpuid for instance. + directives = (r'(?:BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|' + r'ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|' + r'EXPORT|LIBRARY|MODULE)(?=\s)') + + flags = re.IGNORECASE | re.MULTILINE + tokens = { + 'root': [ + (r'^\s*%', Comment.Preproc, 'preproc'), + include('whitespace'), + (identifier + ':', Name.Label), + (rf'({identifier})(\s+)(equ)', + bygroups(Name.Constant, Whitespace, Keyword.Declaration), + 'instruction-args'), + (directives, Keyword, 'instruction-args'), + (declkw, Keyword.Declaration, 'instruction-args'), + (identifier, Name.Function, 'instruction-args'), + (r'[\r\n]+', Whitespace) + ], + 'instruction-args': [ + (string, String), + (hexn, Number.Hex), + (octn, Number.Oct), + (binn, Number.Bin), + (floatn, Number.Float), + (decn, Number.Integer), + include('punctuation'), + (register, Name.Builtin), + (identifier, Name.Variable), + (r'[\r\n]+', Whitespace, '#pop'), + include('whitespace') + ], + 'preproc': [ + (r'[^;\n]+', Comment.Preproc), + (r';.*?\n', Comment.Single, '#pop'), + (r'\n', Comment.Preproc, '#pop'), + ], + 'whitespace': [ + (r'\n', Whitespace), + (r'[ \t]+', Whitespace), + (r';.*', Comment.Single), + (r'#.*', Comment.Single) + ], + 'punctuation': [ + (r'[,{}():\[\]]+', Punctuation), + (r'[&|^<>+*/%~-]+', Operator), + (r'[$]+', Keyword.Constant), + (wordop, Operator.Word), + (type, Keyword.Type) + ], + } + + def analyse_text(text): + # Probably TASM + if re.match(r'PROC', text, re.IGNORECASE): + return False + + +class NasmObjdumpLexer(ObjdumpLexer): + """ + For the output of ``objdump -d -M intel``. + """ + name = 'objdump-nasm' + aliases = ['objdump-nasm'] + filenames = ['*.objdump-intel'] + mimetypes = ['text/x-nasm-objdump'] + url = 'https://www.gnu.org/software/binutils' + version_added = '2.0' + + tokens = _objdump_lexer_tokens(NasmLexer) + + +class TasmLexer(RegexLexer): + """ + For Tasm (Turbo Assembler) assembly code. + """ + name = 'TASM' + aliases = ['tasm'] + filenames = ['*.asm', '*.ASM', '*.tasm'] + mimetypes = ['text/x-tasm'] + url = 'https://en.wikipedia.org/wiki/Turbo_Assembler' + version_added = '' + + identifier = r'[@a-z$._?][\w$.?#@~]*' + hexn = r'(?:0x[0-9a-f]+|$0[0-9a-f]*|[0-9]+[0-9a-f]*h)' + octn = r'[0-7]+q' + binn = r'[01]+b' + decn = r'[0-9]+' + floatn = decn + r'\.e?' + decn + string = r'"(\\"|[^"\n])*"|' + r"'(\\'|[^'\n])*'|" + r"`(\\`|[^`\n])*`" + declkw = r'(?:res|d)[bwdqt]|times' + register = (r'(r[0-9][0-5]?[bwd]|' + r'[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|' + r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7])\b') + wordop = r'seg|wrt|strict' + type = r'byte|[dq]?word' + directives = (r'BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|' + r'ORG|ALIGN|STRUC|ENDSTRUC|ENDS|COMMON|CPU|GROUP|UPPERCASE|INCLUDE|' + r'EXPORT|LIBRARY|MODULE|PROC|ENDP|USES|ARG|DATASEG|UDATASEG|END|IDEAL|' + r'P386|MODEL|ASSUME|CODESEG|SIZE') + # T[A-Z][a-z] is more of a convention. Lexer should filter out STRUC definitions + # and then 'add' them to datatype somehow. + datatype = (r'db|dd|dw|T[A-Z][a-z]+') + + flags = re.IGNORECASE | re.MULTILINE + tokens = { + 'root': [ + (r'^\s*%', Comment.Preproc, 'preproc'), + include('whitespace'), + (identifier + ':', Name.Label), + (directives, Keyword, 'instruction-args'), + (rf'({identifier})(\s+)({datatype})', + bygroups(Name.Constant, Whitespace, Keyword.Declaration), + 'instruction-args'), + (declkw, Keyword.Declaration, 'instruction-args'), + (identifier, Name.Function, 'instruction-args'), + (r'[\r\n]+', Whitespace) + ], + 'instruction-args': [ + (string, String), + (hexn, Number.Hex), + (octn, Number.Oct), + (binn, Number.Bin), + (floatn, Number.Float), + (decn, Number.Integer), + include('punctuation'), + (register, Name.Builtin), + (identifier, Name.Variable), + # Do not match newline when it's preceded by a backslash + (r'(\\)(\s*)(;.*)([\r\n])', + bygroups(Text, Whitespace, Comment.Single, Whitespace)), + (r'[\r\n]+', Whitespace, '#pop'), + include('whitespace') + ], + 'preproc': [ + (r'[^;\n]+', Comment.Preproc), + (r';.*?\n', Comment.Single, '#pop'), + (r'\n', Comment.Preproc, '#pop'), + ], + 'whitespace': [ + (r'[\n\r]', Whitespace), + (r'(\\)([\n\r])', bygroups(Text, Whitespace)), + (r'[ \t]+', Whitespace), + (r';.*', Comment.Single) + ], + 'punctuation': [ + (r'[,():\[\]]+', Punctuation), + (r'[&|^<>+*=/%~-]+', Operator), + (r'[$]+', Keyword.Constant), + (wordop, Operator.Word), + (type, Keyword.Type) + ], + } + + def analyse_text(text): + # See above + if re.match(r'PROC', text, re.I): + return True + + +class Ca65Lexer(RegexLexer): + """ + For ca65 assembler sources. + """ + name = 'ca65 assembler' + aliases = ['ca65'] + filenames = ['*.s'] + url = 'https://cc65.github.io' + version_added = '1.6' + + flags = re.IGNORECASE + + tokens = { + 'root': [ + (r';.*', Comment.Single), + (r'\s+', Whitespace), + (r'[a-z_.@$][\w.@$]*:', Name.Label), + (r'((ld|st)[axy]|(in|de)[cxy]|asl|lsr|ro[lr]|adc|sbc|cmp|cp[xy]' + r'|cl[cvdi]|se[cdi]|jmp|jsr|bne|beq|bpl|bmi|bvc|bvs|bcc|bcs' + r'|p[lh][ap]|rt[is]|brk|nop|ta[xy]|t[xy]a|txs|tsx|and|ora|eor' + r'|bit)\b', Keyword), + (r'\.\w+', Keyword.Pseudo), + (r'[-+~*/^&|!<>=]', Operator), + (r'"[^"\n]*.', String), + (r"'[^'\n]*.", String.Char), + (r'\$[0-9a-f]+|[0-9a-f]+h\b', Number.Hex), + (r'\d+', Number.Integer), + (r'%[01]+', Number.Bin), + (r'[#,.:()=\[\]]', Punctuation), + (r'[a-z_.@$][\w.@$]*', Name), + ] + } + + def analyse_text(self, text): + # comments in GAS start with "#" + if re.search(r'^\s*;', text, re.MULTILINE): + return 0.9 + + +class Dasm16Lexer(RegexLexer): + """ + For DCPU-16 Assembly. + """ + name = 'DASM16' + url = 'http://0x10c.com/doc/dcpu-16.txt' + aliases = ['dasm16'] + filenames = ['*.dasm16', '*.dasm'] + mimetypes = ['text/x-dasm16'] + version_added = '2.4' + + INSTRUCTIONS = [ + 'SET', + 'ADD', 'SUB', + 'MUL', 'MLI', + 'DIV', 'DVI', + 'MOD', 'MDI', + 'AND', 'BOR', 'XOR', + 'SHR', 'ASR', 'SHL', + 'IFB', 'IFC', 'IFE', 'IFN', 'IFG', 'IFA', 'IFL', 'IFU', + 'ADX', 'SBX', + 'STI', 'STD', + 'JSR', + 'INT', 'IAG', 'IAS', 'RFI', 'IAQ', 'HWN', 'HWQ', 'HWI', + ] + + REGISTERS = [ + 'A', 'B', 'C', + 'X', 'Y', 'Z', + 'I', 'J', + 'SP', 'PC', 'EX', + 'POP', 'PEEK', 'PUSH' + ] + + # Regexes yo + char = r'[a-zA-Z0-9_$@.]' + identifier = r'(?:[a-zA-Z$_]' + char + r'*|\.' + char + '+)' + number = r'[+-]?(?:0[xX][a-zA-Z0-9]+|\d+)' + binary_number = r'0b[01_]+' + instruction = r'(?i)(' + '|'.join(INSTRUCTIONS) + ')' + single_char = r"'\\?" + char + "'" + string = r'"(\\"|[^"])*"' + + def guess_identifier(lexer, match): + ident = match.group(0) + klass = Name.Variable if ident.upper() in lexer.REGISTERS else Name.Label + yield match.start(), klass, ident + + tokens = { + 'root': [ + include('whitespace'), + (':' + identifier, Name.Label), + (identifier + ':', Name.Label), + (instruction, Name.Function, 'instruction-args'), + (r'\.' + identifier, Name.Function, 'data-args'), + (r'[\r\n]+', Whitespace) + ], + + 'numeric' : [ + (binary_number, Number.Integer), + (number, Number.Integer), + (single_char, String), + ], + + 'arg' : [ + (identifier, guess_identifier), + include('numeric') + ], + + 'deref' : [ + (r'\+', Punctuation), + (r'\]', Punctuation, '#pop'), + include('arg'), + include('whitespace') + ], + + 'instruction-line' : [ + (r'[\r\n]+', Whitespace, '#pop'), + (r';.*?$', Comment, '#pop'), + include('whitespace') + ], + + 'instruction-args': [ + (r',', Punctuation), + (r'\[', Punctuation, 'deref'), + include('arg'), + include('instruction-line') + ], + + 'data-args' : [ + (r',', Punctuation), + include('numeric'), + (string, String), + include('instruction-line') + ], + + 'whitespace': [ + (r'\n', Whitespace), + (r'\s+', Whitespace), + (r';.*?\n', Comment) + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/asn1.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/asn1.py new file mode 100644 index 0000000000000000000000000000000000000000..711801dc548c5101f43ed0858a8e34df0562b017 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/asn1.py @@ -0,0 +1,178 @@ +""" + pygments.lexers.asn1 + ~~~~~~~~~~~~~~~~~~~~ + + Pygments lexers for ASN.1. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.token import Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace +from pygments.lexer import RegexLexer, words, bygroups + +__all__ = ['Asn1Lexer'] + +SINGLE_WORD_KEYWORDS = [ + "ENCODED", + "ABSTRACT-SYNTAX", + "END", + "APPLICATION", + "EXPLICIT", + "IMPLICIT", + "AUTOMATIC", + "TAGS", + "BEGIN", + "EXTENSIBILITY", + "BY", + "FROM", + "COMPONENT", + "UNIVERSAL", + "COMPONENTS", + "CONSTRAINED", + "IMPLIED", + "DEFINITIONS", + "INCLUDES", + "PRIVATE", + "WITH", + "OF", +] + +OPERATOR_WORDS = [ + "EXCEPT", + "UNION", + "INTERSECTION", +] + +SINGLE_WORD_NAMESPACE_KEYWORDS = [ + "EXPORTS", + "IMPORTS", +] + +MULTI_WORDS_DECLARATIONS = [ + "SEQUENCE OF", + "SET OF", + "INSTANCE OF", + "WITH SYNTAX", +] + +SINGLE_WORDS_DECLARATIONS = [ + "SIZE", + "SEQUENCE", + "SET", + "CLASS", + "UNIQUE", + "DEFAULT", + "CHOICE", + "PATTERN", + "OPTIONAL", + "PRESENT", + "ABSENT", + "CONTAINING", + "ENUMERATED", + "ALL", +] + +TWO_WORDS_TYPES = [ + "OBJECT IDENTIFIER", + "BIT STRING", + "OCTET STRING", + "CHARACTER STRING", + "EMBEDDED PDV", +] + +SINGLE_WORD_TYPES = [ + "RELATIVE-OID", + "TYPE-IDENTIFIER", + "ObjectDescriptor", + "IA5String", + "INTEGER", + "ISO646String", + "T61String", + "BMPString", + "NumericString", + "TeletexString", + "GeneralizedTime", + "REAL", + "BOOLEAN", + "GeneralString", + "GraphicString", + "UniversalString", + "UTCTime", + "VisibleString", + "UTF8String", + "PrintableString", + "VideotexString", + "EXTERNAL", +] + + +def word_sequences(tokens): + return "(" + '|'.join(token.replace(' ', r'\s+') for token in tokens) + r')\b' + + +class Asn1Lexer(RegexLexer): + + """ + Lexer for ASN.1 module definition + """ + + flags = re.MULTILINE + + name = 'ASN.1' + aliases = ['asn1'] + filenames = ["*.asn1"] + url = "https://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf" + version_added = '2.16' + + tokens = { + 'root': [ + # Whitespace: + (r'\s+', Whitespace), + # Comments: + (r'--.*$', Comment.Single), + (r'/\*', Comment.Multiline, 'comment'), + # Numbers: + (r'\d+\.\d+([eE][-+]?\d+)?', Number.Float), + (r'\d+', Number.Integer), + # Identifier: + (r"&?[a-z][-a-zA-Z0-9]*[a-zA-Z0-9]\b", Name.Variable), + # Constants: + (words(("TRUE", "FALSE", "NULL", "MINUS-INFINITY", "PLUS-INFINITY", "MIN", "MAX"), suffix=r'\b'), Keyword.Constant), + # Builtin types: + (word_sequences(TWO_WORDS_TYPES), Keyword.Type), + (words(SINGLE_WORD_TYPES, suffix=r'\b'), Keyword.Type), + # Other keywords: + (r"EXPORTS\s+ALL\b", Keyword.Namespace), + (words(SINGLE_WORD_NAMESPACE_KEYWORDS, suffix=r'\b'), Operator.Namespace), + (word_sequences(MULTI_WORDS_DECLARATIONS), Keyword.Declaration), + (words(SINGLE_WORDS_DECLARATIONS, suffix=r'\b'), Keyword.Declaration), + (words(OPERATOR_WORDS, suffix=r'\b'), Operator.Word), + (words(SINGLE_WORD_KEYWORDS), Keyword), + # Type identifier: + (r"&?[A-Z][-a-zA-Z0-9]*[a-zA-Z0-9]\b", Name.Type), + # Operators: + (r"(::=|\.\.\.|\.\.|\[\[|\]\]|\||\^|-)", Operator), + # Punctuation: + (r"(\.|,|\{|\}|\(|\)|\[|\])", Punctuation), + # String: + (r'"', String, 'string'), + # Binary string: + (r"('[01 ]*')(B)\b", bygroups(String, String.Affix)), + (r"('[0-9A-F ]*')(H)\b",bygroups(String, String.Affix)), + ], + 'comment': [ + (r'[^*/]+', Comment.Multiline), + (r'/\*', Comment.Multiline, '#push'), + (r'\*/', Comment.Multiline, '#pop'), + (r'[*/]', Comment.Multiline) + ], + 'string': [ + (r'""', String), + (r'"', String, "#pop"), + (r'[^"]', String), + ] + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/automation.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/automation.py new file mode 100644 index 0000000000000000000000000000000000000000..7fd0862684256e4a4f65b3bdaec390f1c54a1e71 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/automation.py @@ -0,0 +1,379 @@ +""" + pygments.lexers.automation + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for automation scripting languages. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, include, bygroups, combined +from pygments.token import Text, Comment, Operator, Name, String, \ + Number, Punctuation, Generic + +__all__ = ['AutohotkeyLexer', 'AutoItLexer'] + + +class AutohotkeyLexer(RegexLexer): + """ + For autohotkey source code. + """ + name = 'autohotkey' + url = 'http://www.autohotkey.com/' + aliases = ['autohotkey', 'ahk'] + filenames = ['*.ahk', '*.ahkl'] + mimetypes = ['text/x-autohotkey'] + version_added = '1.4' + + tokens = { + 'root': [ + (r'^(\s*)(/\*)', bygroups(Text, Comment.Multiline), 'incomment'), + (r'^(\s*)(\()', bygroups(Text, Generic), 'incontinuation'), + (r'\s+;.*?$', Comment.Single), + (r'^;.*?$', Comment.Single), + (r'[]{}(),;[]', Punctuation), + (r'(in|is|and|or|not)\b', Operator.Word), + (r'\%[a-zA-Z_#@$][\w#@$]*\%', Name.Variable), + (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator), + include('commands'), + include('labels'), + include('builtInFunctions'), + include('builtInVariables'), + (r'"', String, combined('stringescape', 'dqs')), + include('numbers'), + (r'[a-zA-Z_#@$][\w#@$]*', Name), + (r'\\|\'', Text), + (r'\`([,%`abfnrtv\-+;])', String.Escape), + include('garbage'), + ], + 'incomment': [ + (r'^\s*\*/', Comment.Multiline, '#pop'), + (r'[^*]+', Comment.Multiline), + (r'\*', Comment.Multiline) + ], + 'incontinuation': [ + (r'^\s*\)', Generic, '#pop'), + (r'[^)]', Generic), + (r'[)]', Generic), + ], + 'commands': [ + (r'(?i)^(\s*)(global|local|static|' + r'#AllowSameLineComments|#ClipboardTimeout|#CommentFlag|' + r'#ErrorStdOut|#EscapeChar|#HotkeyInterval|#HotkeyModifierTimeout|' + r'#Hotstring|#IfWinActive|#IfWinExist|#IfWinNotActive|' + r'#IfWinNotExist|#IncludeAgain|#Include|#InstallKeybdHook|' + r'#InstallMouseHook|#KeyHistory|#LTrim|#MaxHotkeysPerInterval|' + r'#MaxMem|#MaxThreads|#MaxThreadsBuffer|#MaxThreadsPerHotkey|' + r'#NoEnv|#NoTrayIcon|#Persistent|#SingleInstance|#UseHook|' + r'#WinActivateForce|AutoTrim|BlockInput|Break|Click|ClipWait|' + r'Continue|Control|ControlClick|ControlFocus|ControlGetFocus|' + r'ControlGetPos|ControlGetText|ControlGet|ControlMove|ControlSend|' + r'ControlSendRaw|ControlSetText|CoordMode|Critical|' + r'DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|' + r'DriveSpaceFree|Edit|Else|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|' + r'EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|' + r'FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|' + r'FileDelete|FileGetAttrib|FileGetShortcut|FileGetSize|' + r'FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|' + r'FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|' + r'FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|' + r'FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|' + r'GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|' + r'GuiControlGet|Hotkey|IfEqual|IfExist|IfGreaterOrEqual|IfGreater|' + r'IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|' + r'IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|' + r'IfWinNotExist|If |ImageSearch|IniDelete|IniRead|IniWrite|' + r'InputBox|Input|KeyHistory|KeyWait|ListHotkeys|ListLines|' + r'ListVars|Loop|Menu|MouseClickDrag|MouseClick|MouseGetPos|' + r'MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|' + r'PixelSearch|PostMessage|Process|Progress|Random|RegDelete|' + r'RegRead|RegWrite|Reload|Repeat|Return|RunAs|RunWait|Run|' + r'SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|Send|' + r'SetBatchLines|SetCapslockState|SetControlDelay|' + r'SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|' + r'SetMouseDelay|SetNumlockState|SetScrollLockState|' + r'SetStoreCapslockMode|SetTimer|SetTitleMatchMode|' + r'SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|' + r'SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|' + r'SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|' + r'SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|' + r'StringGetPos|StringLeft|StringLen|StringLower|StringMid|' + r'StringReplace|StringRight|StringSplit|StringTrimLeft|' + r'StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|' + r'Transform|TrayTip|URLDownloadToFile|While|WinActivate|' + r'WinActivateBottom|WinClose|WinGetActiveStats|WinGetActiveTitle|' + r'WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinGet|WinHide|' + r'WinKill|WinMaximize|WinMenuSelectItem|WinMinimizeAllUndo|' + r'WinMinimizeAll|WinMinimize|WinMove|WinRestore|WinSetTitle|' + r'WinSet|WinShow|WinWaitActive|WinWaitClose|WinWaitNotActive|' + r'WinWait)\b', bygroups(Text, Name.Builtin)), + ], + 'builtInFunctions': [ + (r'(?i)(Abs|ACos|Asc|ASin|ATan|Ceil|Chr|Cos|DllCall|Exp|FileExist|' + r'Floor|GetKeyState|IL_Add|IL_Create|IL_Destroy|InStr|IsFunc|' + r'IsLabel|Ln|Log|LV_Add|LV_Delete|LV_DeleteCol|LV_GetCount|' + r'LV_GetNext|LV_GetText|LV_Insert|LV_InsertCol|LV_Modify|' + r'LV_ModifyCol|LV_SetImageList|Mod|NumGet|NumPut|OnMessage|' + r'RegExMatch|RegExReplace|RegisterCallback|Round|SB_SetIcon|' + r'SB_SetParts|SB_SetText|Sin|Sqrt|StrLen|SubStr|Tan|TV_Add|' + r'TV_Delete|TV_GetChild|TV_GetCount|TV_GetNext|TV_Get|' + r'TV_GetParent|TV_GetPrev|TV_GetSelection|TV_GetText|TV_Modify|' + r'VarSetCapacity|WinActive|WinExist|Object|ComObjActive|' + r'ComObjArray|ComObjEnwrap|ComObjUnwrap|ComObjParameter|' + r'ComObjType|ComObjConnect|ComObjCreate|ComObjGet|ComObjError|' + r'ComObjValue|Insert|MinIndex|MaxIndex|Remove|SetCapacity|' + r'GetCapacity|GetAddress|_NewEnum|FileOpen|Read|Write|ReadLine|' + r'WriteLine|ReadNumType|WriteNumType|RawRead|RawWrite|Seek|Tell|' + r'Close|Next|IsObject|StrPut|StrGet|Trim|LTrim|RTrim)\b', + Name.Function), + ], + 'builtInVariables': [ + (r'(?i)(A_AhkPath|A_AhkVersion|A_AppData|A_AppDataCommon|' + r'A_AutoTrim|A_BatchLines|A_CaretX|A_CaretY|A_ComputerName|' + r'A_ControlDelay|A_Cursor|A_DDDD|A_DDD|A_DD|A_DefaultMouseSpeed|' + r'A_Desktop|A_DesktopCommon|A_DetectHiddenText|' + r'A_DetectHiddenWindows|A_EndChar|A_EventInfo|A_ExitReason|' + r'A_FormatFloat|A_FormatInteger|A_Gui|A_GuiEvent|A_GuiControl|' + r'A_GuiControlEvent|A_GuiHeight|A_GuiWidth|A_GuiX|A_GuiY|A_Hour|' + r'A_IconFile|A_IconHidden|A_IconNumber|A_IconTip|A_Index|' + r'A_IPAddress1|A_IPAddress2|A_IPAddress3|A_IPAddress4|A_ISAdmin|' + r'A_IsCompiled|A_IsCritical|A_IsPaused|A_IsSuspended|A_KeyDelay|' + r'A_Language|A_LastError|A_LineFile|A_LineNumber|A_LoopField|' + r'A_LoopFileAttrib|A_LoopFileDir|A_LoopFileExt|A_LoopFileFullPath|' + r'A_LoopFileLongPath|A_LoopFileName|A_LoopFileShortName|' + r'A_LoopFileShortPath|A_LoopFileSize|A_LoopFileSizeKB|' + r'A_LoopFileSizeMB|A_LoopFileTimeAccessed|A_LoopFileTimeCreated|' + r'A_LoopFileTimeModified|A_LoopReadLine|A_LoopRegKey|' + r'A_LoopRegName|A_LoopRegSubkey|A_LoopRegTimeModified|' + r'A_LoopRegType|A_MDAY|A_Min|A_MM|A_MMM|A_MMMM|A_Mon|A_MouseDelay|' + r'A_MSec|A_MyDocuments|A_Now|A_NowUTC|A_NumBatchLines|A_OSType|' + r'A_OSVersion|A_PriorHotkey|A_ProgramFiles|A_Programs|' + r'A_ProgramsCommon|A_ScreenHeight|A_ScreenWidth|A_ScriptDir|' + r'A_ScriptFullPath|A_ScriptName|A_Sec|A_Space|A_StartMenu|' + r'A_StartMenuCommon|A_Startup|A_StartupCommon|A_StringCaseSense|' + r'A_Tab|A_Temp|A_ThisFunc|A_ThisHotkey|A_ThisLabel|A_ThisMenu|' + r'A_ThisMenuItem|A_ThisMenuItemPos|A_TickCount|A_TimeIdle|' + r'A_TimeIdlePhysical|A_TimeSincePriorHotkey|A_TimeSinceThisHotkey|' + r'A_TitleMatchMode|A_TitleMatchModeSpeed|A_UserName|A_WDay|' + r'A_WinDelay|A_WinDir|A_WorkingDir|A_YDay|A_YEAR|A_YWeek|A_YYYY|' + r'Clipboard|ClipboardAll|ComSpec|ErrorLevel|ProgramFiles|True|' + r'False|A_IsUnicode|A_FileEncoding|A_OSVersion|A_PtrSize)\b', + Name.Variable), + ], + 'labels': [ + # hotkeys and labels + # technically, hotkey names are limited to named keys and buttons + (r'(^\s*)([^:\s("]+?:{1,2})', bygroups(Text, Name.Label)), + (r'(^\s*)(::[^:\s]+?::)', bygroups(Text, Name.Label)), + ], + 'numbers': [ + (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), + (r'\d+[eE][+-]?[0-9]+', Number.Float), + (r'0\d+', Number.Oct), + (r'0[xX][a-fA-F0-9]+', Number.Hex), + (r'\d+L', Number.Integer.Long), + (r'\d+', Number.Integer) + ], + 'stringescape': [ + (r'\"\"|\`([,%`abfnrtv])', String.Escape), + ], + 'strings': [ + (r'[^"\n]+', String), + ], + 'dqs': [ + (r'"', String, '#pop'), + include('strings') + ], + 'garbage': [ + (r'[^\S\n]', Text), + # (r'.', Text), # no cheating + ], + } + + +class AutoItLexer(RegexLexer): + """ + For AutoIt files. + + AutoIt is a freeware BASIC-like scripting language + designed for automating the Windows GUI and general scripting + """ + name = 'AutoIt' + url = 'http://www.autoitscript.com/site/autoit/' + aliases = ['autoit'] + filenames = ['*.au3'] + mimetypes = ['text/x-autoit'] + version_added = '1.6' + + # Keywords, functions, macros from au3.keywords.properties + # which can be found in AutoIt installed directory, e.g. + # c:\Program Files (x86)\AutoIt3\SciTE\au3.keywords.properties + + keywords = """\ + #include-once #include #endregion #forcedef #forceref #region + and byref case continueloop dim do else elseif endfunc endif + endselect exit exitloop for func global + if local next not or return select step + then to until wend while exit""".split() + + functions = """\ + abs acos adlibregister adlibunregister asc ascw asin assign atan + autoitsetoption autoitwingettitle autoitwinsettitle beep binary binarylen + binarymid binarytostring bitand bitnot bitor bitrotate bitshift bitxor + blockinput break call cdtray ceiling chr chrw clipget clipput consoleread + consolewrite consolewriteerror controlclick controlcommand controldisable + controlenable controlfocus controlgetfocus controlgethandle controlgetpos + controlgettext controlhide controllistview controlmove controlsend + controlsettext controlshow controltreeview cos dec dircopy dircreate + dirgetsize dirmove dirremove dllcall dllcalladdress dllcallbackfree + dllcallbackgetptr dllcallbackregister dllclose dllopen dllstructcreate + dllstructgetdata dllstructgetptr dllstructgetsize dllstructsetdata + drivegetdrive drivegetfilesystem drivegetlabel drivegetserial drivegettype + drivemapadd drivemapdel drivemapget drivesetlabel drivespacefree + drivespacetotal drivestatus envget envset envupdate eval execute exp + filechangedir fileclose filecopy filecreatentfslink filecreateshortcut + filedelete fileexists filefindfirstfile filefindnextfile fileflush + filegetattrib filegetencoding filegetlongname filegetpos filegetshortcut + filegetshortname filegetsize filegettime filegetversion fileinstall filemove + fileopen fileopendialog fileread filereadline filerecycle filerecycleempty + filesavedialog fileselectfolder filesetattrib filesetpos filesettime + filewrite filewriteline floor ftpsetproxy guicreate guictrlcreateavi + guictrlcreatebutton guictrlcreatecheckbox guictrlcreatecombo + guictrlcreatecontextmenu guictrlcreatedate guictrlcreatedummy + guictrlcreateedit guictrlcreategraphic guictrlcreategroup guictrlcreateicon + guictrlcreateinput guictrlcreatelabel guictrlcreatelist + guictrlcreatelistview guictrlcreatelistviewitem guictrlcreatemenu + guictrlcreatemenuitem guictrlcreatemonthcal guictrlcreateobj + guictrlcreatepic guictrlcreateprogress guictrlcreateradio + guictrlcreateslider guictrlcreatetab guictrlcreatetabitem + guictrlcreatetreeview guictrlcreatetreeviewitem guictrlcreateupdown + guictrldelete guictrlgethandle guictrlgetstate guictrlread guictrlrecvmsg + guictrlregisterlistviewsort guictrlsendmsg guictrlsendtodummy + guictrlsetbkcolor guictrlsetcolor guictrlsetcursor guictrlsetdata + guictrlsetdefbkcolor guictrlsetdefcolor guictrlsetfont guictrlsetgraphic + guictrlsetimage guictrlsetlimit guictrlsetonevent guictrlsetpos + guictrlsetresizing guictrlsetstate guictrlsetstyle guictrlsettip guidelete + guigetcursorinfo guigetmsg guigetstyle guiregistermsg guisetaccelerators + guisetbkcolor guisetcoord guisetcursor guisetfont guisethelp guiseticon + guisetonevent guisetstate guisetstyle guistartgroup guiswitch hex hotkeyset + httpsetproxy httpsetuseragent hwnd inetclose inetget inetgetinfo inetgetsize + inetread inidelete iniread inireadsection inireadsectionnames + inirenamesection iniwrite iniwritesection inputbox int isadmin isarray + isbinary isbool isdeclared isdllstruct isfloat ishwnd isint iskeyword + isnumber isobj isptr isstring log memgetstats mod mouseclick mouseclickdrag + mousedown mousegetcursor mousegetpos mousemove mouseup mousewheel msgbox + number objcreate objcreateinterface objevent objevent objget objname + onautoitexitregister onautoitexitunregister opt ping pixelchecksum + pixelgetcolor pixelsearch pluginclose pluginopen processclose processexists + processgetstats processlist processsetpriority processwait processwaitclose + progressoff progresson progressset ptr random regdelete regenumkey + regenumval regread regwrite round run runas runaswait runwait send + sendkeepactive seterror setextended shellexecute shellexecutewait shutdown + sin sleep soundplay soundsetwavevolume splashimageon splashoff splashtexton + sqrt srandom statusbargettext stderrread stdinwrite stdioclose stdoutread + string stringaddcr stringcompare stringformat stringfromasciiarray + stringinstr stringisalnum stringisalpha stringisascii stringisdigit + stringisfloat stringisint stringislower stringisspace stringisupper + stringisxdigit stringleft stringlen stringlower stringmid stringregexp + stringregexpreplace stringreplace stringright stringsplit stringstripcr + stringstripws stringtoasciiarray stringtobinary stringtrimleft + stringtrimright stringupper tan tcpaccept tcpclosesocket tcpconnect + tcplisten tcpnametoip tcprecv tcpsend tcpshutdown tcpstartup timerdiff + timerinit tooltip traycreateitem traycreatemenu traygetmsg trayitemdelete + trayitemgethandle trayitemgetstate trayitemgettext trayitemsetonevent + trayitemsetstate trayitemsettext traysetclick trayseticon traysetonevent + traysetpauseicon traysetstate traysettooltip traytip ubound udpbind + udpclosesocket udpopen udprecv udpsend udpshutdown udpstartup vargettype + winactivate winactive winclose winexists winflash wingetcaretpos + wingetclasslist wingetclientsize wingethandle wingetpos wingetprocess + wingetstate wingettext wingettitle winkill winlist winmenuselectitem + winminimizeall winminimizeallundo winmove winsetontop winsetstate + winsettitle winsettrans winwait winwaitactive winwaitclose + winwaitnotactive""".split() + + macros = """\ + @appdatacommondir @appdatadir @autoitexe @autoitpid @autoitversion + @autoitx64 @com_eventobj @commonfilesdir @compiled @computername @comspec + @cpuarch @cr @crlf @desktopcommondir @desktopdepth @desktopdir + @desktopheight @desktoprefresh @desktopwidth @documentscommondir @error + @exitcode @exitmethod @extended @favoritescommondir @favoritesdir + @gui_ctrlhandle @gui_ctrlid @gui_dragfile @gui_dragid @gui_dropid + @gui_winhandle @homedrive @homepath @homeshare @hotkeypressed @hour + @ipaddress1 @ipaddress2 @ipaddress3 @ipaddress4 @kblayout @lf + @logondnsdomain @logondomain @logonserver @mday @min @mon @msec @muilang + @mydocumentsdir @numparams @osarch @osbuild @oslang @osservicepack @ostype + @osversion @programfilesdir @programscommondir @programsdir @scriptdir + @scriptfullpath @scriptlinenumber @scriptname @sec @startmenucommondir + @startmenudir @startupcommondir @startupdir @sw_disable @sw_enable @sw_hide + @sw_lock @sw_maximize @sw_minimize @sw_restore @sw_show @sw_showdefault + @sw_showmaximized @sw_showminimized @sw_showminnoactive @sw_showna + @sw_shownoactivate @sw_shownormal @sw_unlock @systemdir @tab @tempdir + @tray_id @trayiconflashing @trayiconvisible @username @userprofiledir @wday + @windowsdir @workingdir @yday @year""".split() + + tokens = { + 'root': [ + (r';.*\n', Comment.Single), + (r'(#comments-start|#cs)[\s\S]*?(#comments-end|#ce)', + Comment.Multiline), + (r'[\[\]{}(),;]', Punctuation), + (r'(and|or|not)\b', Operator.Word), + (r'[$|@][a-zA-Z_]\w*', Name.Variable), + (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator), + include('commands'), + include('labels'), + include('builtInFunctions'), + include('builtInMarcros'), + (r'"', String, combined('stringescape', 'dqs')), + (r"'", String, 'sqs'), + include('numbers'), + (r'[a-zA-Z_#@$][\w#@$]*', Name), + (r'\\|\'', Text), + (r'\`([,%`abfnrtv\-+;])', String.Escape), + (r'_\n', Text), # Line continuation + include('garbage'), + ], + 'commands': [ + (r'(?i)(\s*)({})\b'.format('|'.join(keywords)), + bygroups(Text, Name.Builtin)), + ], + 'builtInFunctions': [ + (r'(?i)({})\b'.format('|'.join(functions)), + Name.Function), + ], + 'builtInMarcros': [ + (r'(?i)({})\b'.format('|'.join(macros)), + Name.Variable.Global), + ], + 'labels': [ + # sendkeys + (r'(^\s*)(\{\S+?\})', bygroups(Text, Name.Label)), + ], + 'numbers': [ + (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), + (r'\d+[eE][+-]?[0-9]+', Number.Float), + (r'0\d+', Number.Oct), + (r'0[xX][a-fA-F0-9]+', Number.Hex), + (r'\d+L', Number.Integer.Long), + (r'\d+', Number.Integer) + ], + 'stringescape': [ + (r'\"\"|\`([,%`abfnrtv])', String.Escape), + ], + 'strings': [ + (r'[^"\n]+', String), + ], + 'dqs': [ + (r'"', String, '#pop'), + include('strings') + ], + 'sqs': [ + (r'\'\'|\`([,%`abfnrtv])', String.Escape), + (r"'", String, '#pop'), + (r"[^'\n]+", String) + ], + 'garbage': [ + (r'[^\S\n]', Text), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bare.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bare.py new file mode 100644 index 0000000000000000000000000000000000000000..ba512b9d0aa833f5440dae2d30438d419f31b54c --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bare.py @@ -0,0 +1,101 @@ +""" + pygments.lexers.bare + ~~~~~~~~~~~~~~~~~~~~ + + Lexer for the BARE schema. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, words, bygroups +from pygments.token import Text, Comment, Keyword, Name, Literal, Whitespace + +__all__ = ['BareLexer'] + + +class BareLexer(RegexLexer): + """ + For BARE schema source. + """ + name = 'BARE' + url = 'https://baremessages.org' + filenames = ['*.bare'] + aliases = ['bare'] + version_added = '2.7' + + keywords = [ + 'type', + 'enum', + 'u8', + 'u16', + 'u32', + 'u64', + 'uint', + 'i8', + 'i16', + 'i32', + 'i64', + 'int', + 'f32', + 'f64', + 'bool', + 'void', + 'data', + 'string', + 'optional', + 'map', + ] + + tokens = { + 'root': [ + (r'(type)(\s+)([A-Z][a-zA-Z0-9]+)(\s+)(\{)', + bygroups(Keyword, Whitespace, Name.Class, Whitespace, Text), 'struct'), + (r'(type)(\s+)([A-Z][a-zA-Z0-9]+)(\s+)(\()', + bygroups(Keyword, Whitespace, Name.Class, Whitespace, Text), 'union'), + (r'(type)(\s+)([A-Z][a-zA-Z0-9]+)(\s+)', + bygroups(Keyword, Whitespace, Name, Whitespace), 'typedef'), + (r'(enum)(\s+)([A-Z][a-zA-Z0-9]+)(\s+\{)', + bygroups(Keyword, Whitespace, Name.Class, Whitespace), 'enum'), + (r'#.*?$', Comment), + (r'\s+', Whitespace), + ], + 'struct': [ + (r'\{', Text, '#push'), + (r'\}', Text, '#pop'), + (r'([a-zA-Z0-9]+)(:)(\s*)', + bygroups(Name.Attribute, Text, Whitespace), 'typedef'), + (r'\s+', Whitespace), + ], + 'union': [ + (r'\)', Text, '#pop'), + (r'(\s*)(\|)(\s*)', bygroups(Whitespace, Text, Whitespace)), + (r'[A-Z][a-zA-Z0-9]+', Name.Class), + (words(keywords), Keyword), + (r'\s+', Whitespace), + ], + 'typedef': [ + (r'\[\]', Text), + (r'#.*?$', Comment, '#pop'), + (r'(\[)(\d+)(\])', bygroups(Text, Literal, Text)), + (r'<|>', Text), + (r'\(', Text, 'union'), + (r'(\[)([a-z][a-z-A-Z0-9]+)(\])', bygroups(Text, Keyword, Text)), + (r'(\[)([A-Z][a-z-A-Z0-9]+)(\])', bygroups(Text, Name.Class, Text)), + (r'([A-Z][a-z-A-Z0-9]+)', Name.Class), + (words(keywords), Keyword), + (r'\n', Text, '#pop'), + (r'\{', Text, 'struct'), + (r'\s+', Whitespace), + (r'\d+', Literal), + ], + 'enum': [ + (r'\{', Text, '#push'), + (r'\}', Text, '#pop'), + (r'([A-Z][A-Z0-9_]*)(\s*=\s*)(\d+)', + bygroups(Name.Attribute, Text, Literal)), + (r'([A-Z][A-Z0-9_]*)', bygroups(Name.Attribute)), + (r'#.*?$', Comment), + (r'\s+', Whitespace), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/basic.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/basic.py new file mode 100644 index 0000000000000000000000000000000000000000..b2e9e52f7f0cf5e9670b65f9e03678a643504a23 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/basic.py @@ -0,0 +1,655 @@ +""" + pygments.lexers.basic + ~~~~~~~~~~~~~~~~~~~~~ + + Lexers for BASIC like languages (other than VB.net). + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, bygroups, default, words, include +from pygments.token import Comment, Error, Keyword, Name, Number, \ + Punctuation, Operator, String, Text, Whitespace +from pygments.lexers import _vbscript_builtins + + +__all__ = ['BlitzBasicLexer', 'BlitzMaxLexer', 'MonkeyLexer', 'CbmBasicV2Lexer', + 'QBasicLexer', 'VBScriptLexer', 'BBCBasicLexer'] + + +class BlitzMaxLexer(RegexLexer): + """ + For BlitzMax source code. + """ + + name = 'BlitzMax' + url = 'http://blitzbasic.com' + aliases = ['blitzmax', 'bmax'] + filenames = ['*.bmx'] + mimetypes = ['text/x-bmx'] + version_added = '1.4' + + bmax_vopwords = r'\b(Shl|Shr|Sar|Mod)\b' + bmax_sktypes = r'@{1,2}|[!#$%]' + bmax_lktypes = r'\b(Int|Byte|Short|Float|Double|Long)\b' + bmax_name = r'[a-z_]\w*' + bmax_var = (rf'({bmax_name})(?:(?:([ \t]*)({bmax_sktypes})|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)' + rf'|([ \t]*)(:)([ \t]*)(?:{bmax_lktypes}|({bmax_name})))(?:([ \t]*)(Ptr))?)') + bmax_func = bmax_var + r'?((?:[ \t]|\.\.\n)*)([(])' + + flags = re.MULTILINE | re.IGNORECASE + tokens = { + 'root': [ + # Text + (r'\s+', Whitespace), + (r'(\.\.)(\n)', bygroups(Text, Whitespace)), # Line continuation + # Comments + (r"'.*?\n", Comment.Single), + (r'([ \t]*)\bRem\n[\s\S]*?\s*\bEnd([ \t]*)Rem', Comment.Multiline), + # Data types + ('"', String.Double, 'string'), + # Numbers + (r'[0-9]+\.[0-9]*(?!\.)', Number.Float), + (r'\.[0-9]*(?!\.)', Number.Float), + (r'[0-9]+', Number.Integer), + (r'\$[0-9a-f]+', Number.Hex), + (r'\%[10]+', Number.Bin), + # Other + (rf'(?:(?:(:)?([ \t]*)(:?{bmax_vopwords}|([+\-*/&|~]))|Or|And|Not|[=<>^]))', Operator), + (r'[(),.:\[\]]', Punctuation), + (r'(?:#[\w \t]*)', Name.Label), + (r'(?:\?[\w \t]*)', Comment.Preproc), + # Identifiers + (rf'\b(New)\b([ \t]?)([(]?)({bmax_name})', + bygroups(Keyword.Reserved, Whitespace, Punctuation, Name.Class)), + (rf'\b(Import|Framework|Module)([ \t]+)({bmax_name}\.{bmax_name})', + bygroups(Keyword.Reserved, Whitespace, Keyword.Namespace)), + (bmax_func, bygroups(Name.Function, Whitespace, Keyword.Type, + Operator, Whitespace, Punctuation, Whitespace, + Keyword.Type, Name.Class, Whitespace, + Keyword.Type, Whitespace, Punctuation)), + (bmax_var, bygroups(Name.Variable, Whitespace, Keyword.Type, Operator, + Whitespace, Punctuation, Whitespace, Keyword.Type, + Name.Class, Whitespace, Keyword.Type)), + (rf'\b(Type|Extends)([ \t]+)({bmax_name})', + bygroups(Keyword.Reserved, Whitespace, Name.Class)), + # Keywords + (r'\b(Ptr)\b', Keyword.Type), + (r'\b(Pi|True|False|Null|Self|Super)\b', Keyword.Constant), + (r'\b(Local|Global|Const|Field)\b', Keyword.Declaration), + (words(( + 'TNullMethodException', 'TNullFunctionException', + 'TNullObjectException', 'TArrayBoundsException', + 'TRuntimeException'), prefix=r'\b', suffix=r'\b'), Name.Exception), + (words(( + 'Strict', 'SuperStrict', 'Module', 'ModuleInfo', + 'End', 'Return', 'Continue', 'Exit', 'Public', 'Private', + 'Var', 'VarPtr', 'Chr', 'Len', 'Asc', 'SizeOf', 'Sgn', 'Abs', 'Min', 'Max', + 'New', 'Release', 'Delete', 'Incbin', 'IncbinPtr', 'IncbinLen', + 'Framework', 'Include', 'Import', 'Extern', 'EndExtern', + 'Function', 'EndFunction', 'Type', 'EndType', 'Extends', 'Method', 'EndMethod', + 'Abstract', 'Final', 'If', 'Then', 'Else', 'ElseIf', 'EndIf', + 'For', 'To', 'Next', 'Step', 'EachIn', 'While', 'Wend', 'EndWhile', + 'Repeat', 'Until', 'Forever', 'Select', 'Case', 'Default', 'EndSelect', + 'Try', 'Catch', 'EndTry', 'Throw', 'Assert', 'Goto', 'DefData', 'ReadData', + 'RestoreData'), prefix=r'\b', suffix=r'\b'), + Keyword.Reserved), + # Final resolve (for variable names and such) + (rf'({bmax_name})', Name.Variable), + ], + 'string': [ + (r'""', String.Double), + (r'"C?', String.Double, '#pop'), + (r'[^"]+', String.Double), + ], + } + + +class BlitzBasicLexer(RegexLexer): + """ + For BlitzBasic source code. + """ + + name = 'BlitzBasic' + url = 'http://blitzbasic.com' + aliases = ['blitzbasic', 'b3d', 'bplus'] + filenames = ['*.bb', '*.decls'] + mimetypes = ['text/x-bb'] + version_added = '2.0' + + bb_sktypes = r'@{1,2}|[#$%]' + bb_name = r'[a-z]\w*' + bb_var = (rf'({bb_name})(?:([ \t]*)({bb_sktypes})|([ \t]*)([.])([ \t]*)(?:({bb_name})))?') + + flags = re.MULTILINE | re.IGNORECASE + tokens = { + 'root': [ + # Text + (r'\s+', Whitespace), + # Comments + (r";.*?\n", Comment.Single), + # Data types + ('"', String.Double, 'string'), + # Numbers + (r'[0-9]+\.[0-9]*(?!\.)', Number.Float), + (r'\.[0-9]+(?!\.)', Number.Float), + (r'[0-9]+', Number.Integer), + (r'\$[0-9a-f]+', Number.Hex), + (r'\%[10]+', Number.Bin), + # Other + (words(('Shl', 'Shr', 'Sar', 'Mod', 'Or', 'And', 'Not', + 'Abs', 'Sgn', 'Handle', 'Int', 'Float', 'Str', + 'First', 'Last', 'Before', 'After'), + prefix=r'\b', suffix=r'\b'), + Operator), + (r'([+\-*/~=<>^])', Operator), + (r'[(),:\[\]\\]', Punctuation), + (rf'\.([ \t]*)({bb_name})', Name.Label), + # Identifiers + (rf'\b(New)\b([ \t]+)({bb_name})', + bygroups(Keyword.Reserved, Whitespace, Name.Class)), + (rf'\b(Gosub|Goto)\b([ \t]+)({bb_name})', + bygroups(Keyword.Reserved, Whitespace, Name.Label)), + (rf'\b(Object)\b([ \t]*)([.])([ \t]*)({bb_name})\b', + bygroups(Operator, Whitespace, Punctuation, Whitespace, Name.Class)), + (rf'\b{bb_var}\b([ \t]*)(\()', + bygroups(Name.Function, Whitespace, Keyword.Type, Whitespace, Punctuation, + Whitespace, Name.Class, Whitespace, Punctuation)), + (rf'\b(Function)\b([ \t]+){bb_var}', + bygroups(Keyword.Reserved, Whitespace, Name.Function, Whitespace, Keyword.Type, + Whitespace, Punctuation, Whitespace, Name.Class)), + (rf'\b(Type)([ \t]+)({bb_name})', + bygroups(Keyword.Reserved, Whitespace, Name.Class)), + # Keywords + (r'\b(Pi|True|False|Null)\b', Keyword.Constant), + (r'\b(Local|Global|Const|Field|Dim)\b', Keyword.Declaration), + (words(( + 'End', 'Return', 'Exit', 'Chr', 'Len', 'Asc', 'New', 'Delete', 'Insert', + 'Include', 'Function', 'Type', 'If', 'Then', 'Else', 'ElseIf', 'EndIf', + 'For', 'To', 'Next', 'Step', 'Each', 'While', 'Wend', + 'Repeat', 'Until', 'Forever', 'Select', 'Case', 'Default', + 'Goto', 'Gosub', 'Data', 'Read', 'Restore'), prefix=r'\b', suffix=r'\b'), + Keyword.Reserved), + # Final resolve (for variable names and such) + # (r'(%s)' % (bb_name), Name.Variable), + (bb_var, bygroups(Name.Variable, Whitespace, Keyword.Type, + Whitespace, Punctuation, Whitespace, Name.Class)), + ], + 'string': [ + (r'""', String.Double), + (r'"C?', String.Double, '#pop'), + (r'[^"\n]+', String.Double), + ], + } + + +class MonkeyLexer(RegexLexer): + """ + For Monkey source code. + """ + + name = 'Monkey' + aliases = ['monkey'] + filenames = ['*.monkey'] + mimetypes = ['text/x-monkey'] + url = 'https://blitzresearch.itch.io/monkeyx' + version_added = '1.6' + + name_variable = r'[a-z_]\w*' + name_function = r'[A-Z]\w*' + name_constant = r'[A-Z_][A-Z0-9_]*' + name_class = r'[A-Z]\w*' + name_module = r'[a-z0-9_]*' + + keyword_type = r'(?:Int|Float|String|Bool|Object|Array|Void)' + # ? == Bool // % == Int // # == Float // $ == String + keyword_type_special = r'[?%#$]' + + flags = re.MULTILINE + + tokens = { + 'root': [ + # Text + (r'\s+', Whitespace), + # Comments + (r"'.*", Comment), + (r'(?i)^#rem\b', Comment.Multiline, 'comment'), + # preprocessor directives + (r'(?i)^(?:#If|#ElseIf|#Else|#EndIf|#End|#Print|#Error)\b', Comment.Preproc), + # preprocessor variable (any line starting with '#' that is not a directive) + (r'^#', Comment.Preproc, 'variables'), + # String + ('"', String.Double, 'string'), + # Numbers + (r'[0-9]+\.[0-9]*(?!\.)', Number.Float), + (r'\.[0-9]+(?!\.)', Number.Float), + (r'[0-9]+', Number.Integer), + (r'\$[0-9a-fA-Z]+', Number.Hex), + (r'\%[10]+', Number.Bin), + # Native data types + (rf'\b{keyword_type}\b', Keyword.Type), + # Exception handling + (r'(?i)\b(?:Try|Catch|Throw)\b', Keyword.Reserved), + (r'Throwable', Name.Exception), + # Builtins + (r'(?i)\b(?:Null|True|False)\b', Name.Builtin), + (r'(?i)\b(?:Self|Super)\b', Name.Builtin.Pseudo), + (r'\b(?:HOST|LANG|TARGET|CONFIG)\b', Name.Constant), + # Keywords + (r'(?i)^(Import)(\s+)(.*)(\n)', + bygroups(Keyword.Namespace, Whitespace, Name.Namespace, Whitespace)), + (r'(?i)^Strict\b.*\n', Keyword.Reserved), + (r'(?i)(Const|Local|Global|Field)(\s+)', + bygroups(Keyword.Declaration, Whitespace), 'variables'), + (r'(?i)(New|Class|Interface|Extends|Implements)(\s+)', + bygroups(Keyword.Reserved, Whitespace), 'classname'), + (r'(?i)(Function|Method)(\s+)', + bygroups(Keyword.Reserved, Whitespace), 'funcname'), + (r'(?i)(?:End|Return|Public|Private|Extern|Property|' + r'Final|Abstract)\b', Keyword.Reserved), + # Flow Control stuff + (r'(?i)(?:If|Then|Else|ElseIf|EndIf|' + r'Select|Case|Default|' + r'While|Wend|' + r'Repeat|Until|Forever|' + r'For|To|Until|Step|EachIn|Next|' + r'Exit|Continue)(?=\s)', Keyword.Reserved), + # not used yet + (r'(?i)\b(?:Module|Inline)\b', Keyword.Reserved), + # Array + (r'[\[\]]', Punctuation), + # Other + (r'<=|>=|<>|\*=|/=|\+=|-=|&=|~=|\|=|[-&*/^+=<>|~]', Operator), + (r'(?i)(?:Not|Mod|Shl|Shr|And|Or)', Operator.Word), + (r'[(){}!#,.:]', Punctuation), + # catch the rest + (rf'{name_constant}\b', Name.Constant), + (rf'{name_function}\b', Name.Function), + (rf'{name_variable}\b', Name.Variable), + ], + 'funcname': [ + (rf'(?i){name_function}\b', Name.Function), + (r':', Punctuation, 'classname'), + (r'\s+', Whitespace), + (r'\(', Punctuation, 'variables'), + (r'\)', Punctuation, '#pop') + ], + 'classname': [ + (rf'{name_module}\.', Name.Namespace), + (rf'{keyword_type}\b', Keyword.Type), + (rf'{name_class}\b', Name.Class), + # array (of given size) + (r'(\[)(\s*)(\d*)(\s*)(\])', + bygroups(Punctuation, Whitespace, Number.Integer, Whitespace, Punctuation)), + # generics + (r'\s+(?!<)', Whitespace, '#pop'), + (r'<', Punctuation, '#push'), + (r'>', Punctuation, '#pop'), + (r'\n', Whitespace, '#pop'), + default('#pop') + ], + 'variables': [ + (rf'{name_constant}\b', Name.Constant), + (rf'{name_variable}\b', Name.Variable), + (rf'{keyword_type_special}', Keyword.Type), + (r'\s+', Whitespace), + (r':', Punctuation, 'classname'), + (r',', Punctuation, '#push'), + default('#pop') + ], + 'string': [ + (r'[^"~]+', String.Double), + (r'~q|~n|~r|~t|~z|~~', String.Escape), + (r'"', String.Double, '#pop'), + ], + 'comment': [ + (r'(?i)^#rem.*?', Comment.Multiline, "#push"), + (r'(?i)^#end.*?', Comment.Multiline, "#pop"), + (r'\n', Comment.Multiline), + (r'.+', Comment.Multiline), + ], + } + + +class CbmBasicV2Lexer(RegexLexer): + """ + For CBM BASIC V2 sources. + """ + name = 'CBM BASIC V2' + aliases = ['cbmbas'] + filenames = ['*.bas'] + url = 'https://en.wikipedia.org/wiki/Commodore_BASIC' + version_added = '1.6' + + flags = re.IGNORECASE + + tokens = { + 'root': [ + (r'rem.*\n', Comment.Single), + (r'\s+', Whitespace), + (r'new|run|end|for|to|next|step|go(to|sub)?|on|return|stop|cont' + r'|if|then|input#?|read|wait|load|save|verify|poke|sys|print#?' + r'|list|clr|cmd|open|close|get#?', Keyword.Reserved), + (r'data|restore|dim|let|def|fn', Keyword.Declaration), + (r'tab|spc|sgn|int|abs|usr|fre|pos|sqr|rnd|log|exp|cos|sin|tan|atn' + r'|peek|len|val|asc|(str|chr|left|right|mid)\$', Name.Builtin), + (r'[-+*/^<>=]', Operator), + (r'not|and|or', Operator.Word), + (r'"[^"\n]*.', String), + (r'\d+|[-+]?\d*\.\d*(e[-+]?\d+)?', Number.Float), + (r'[(),:;]', Punctuation), + (r'\w+[$%]?', Name), + ] + } + + def analyse_text(text): + # if it starts with a line number, it shouldn't be a "modern" Basic + # like VB.net + if re.match(r'^\d+', text): + return 0.2 + + +class QBasicLexer(RegexLexer): + """ + For QBasic source code. + """ + + name = 'QBasic' + aliases = ['qbasic', 'basic'] + filenames = ['*.BAS', '*.bas'] + mimetypes = ['text/basic'] + url = 'https://en.wikipedia.org/wiki/QBasic' + version_added = '2.0' + + declarations = ('DATA', 'LET') + + functions = ( + 'ABS', 'ASC', 'ATN', 'CDBL', 'CHR$', 'CINT', 'CLNG', + 'COMMAND$', 'COS', 'CSNG', 'CSRLIN', 'CVD', 'CVDMBF', 'CVI', + 'CVL', 'CVS', 'CVSMBF', 'DATE$', 'ENVIRON$', 'EOF', 'ERDEV', + 'ERDEV$', 'ERL', 'ERR', 'EXP', 'FILEATTR', 'FIX', 'FRE', + 'FREEFILE', 'HEX$', 'INKEY$', 'INP', 'INPUT$', 'INSTR', 'INT', + 'IOCTL$', 'LBOUND', 'LCASE$', 'LEFT$', 'LEN', 'LOC', 'LOF', + 'LOG', 'LPOS', 'LTRIM$', 'MID$', 'MKD$', 'MKDMBF$', 'MKI$', + 'MKL$', 'MKS$', 'MKSMBF$', 'OCT$', 'PEEK', 'PEN', 'PLAY', + 'PMAP', 'POINT', 'POS', 'RIGHT$', 'RND', 'RTRIM$', 'SADD', + 'SCREEN', 'SEEK', 'SETMEM', 'SGN', 'SIN', 'SPACE$', 'SPC', + 'SQR', 'STICK', 'STR$', 'STRIG', 'STRING$', 'TAB', 'TAN', + 'TIME$', 'TIMER', 'UBOUND', 'UCASE$', 'VAL', 'VARPTR', + 'VARPTR$', 'VARSEG' + ) + + metacommands = ('$DYNAMIC', '$INCLUDE', '$STATIC') + + operators = ('AND', 'EQV', 'IMP', 'NOT', 'OR', 'XOR') + + statements = ( + 'BEEP', 'BLOAD', 'BSAVE', 'CALL', 'CALL ABSOLUTE', + 'CALL INTERRUPT', 'CALLS', 'CHAIN', 'CHDIR', 'CIRCLE', 'CLEAR', + 'CLOSE', 'CLS', 'COLOR', 'COM', 'COMMON', 'CONST', 'DATA', + 'DATE$', 'DECLARE', 'DEF FN', 'DEF SEG', 'DEFDBL', 'DEFINT', + 'DEFLNG', 'DEFSNG', 'DEFSTR', 'DEF', 'DIM', 'DO', 'LOOP', + 'DRAW', 'END', 'ENVIRON', 'ERASE', 'ERROR', 'EXIT', 'FIELD', + 'FILES', 'FOR', 'NEXT', 'FUNCTION', 'GET', 'GOSUB', 'GOTO', + 'IF', 'THEN', 'INPUT', 'INPUT #', 'IOCTL', 'KEY', 'KEY', + 'KILL', 'LET', 'LINE', 'LINE INPUT', 'LINE INPUT #', 'LOCATE', + 'LOCK', 'UNLOCK', 'LPRINT', 'LSET', 'MID$', 'MKDIR', 'NAME', + 'ON COM', 'ON ERROR', 'ON KEY', 'ON PEN', 'ON PLAY', + 'ON STRIG', 'ON TIMER', 'ON UEVENT', 'ON', 'OPEN', 'OPEN COM', + 'OPTION BASE', 'OUT', 'PAINT', 'PALETTE', 'PCOPY', 'PEN', + 'PLAY', 'POKE', 'PRESET', 'PRINT', 'PRINT #', 'PRINT USING', + 'PSET', 'PUT', 'PUT', 'RANDOMIZE', 'READ', 'REDIM', 'REM', + 'RESET', 'RESTORE', 'RESUME', 'RETURN', 'RMDIR', 'RSET', 'RUN', + 'SCREEN', 'SEEK', 'SELECT CASE', 'SHARED', 'SHELL', 'SLEEP', + 'SOUND', 'STATIC', 'STOP', 'STRIG', 'SUB', 'SWAP', 'SYSTEM', + 'TIME$', 'TIMER', 'TROFF', 'TRON', 'TYPE', 'UEVENT', 'UNLOCK', + 'VIEW', 'WAIT', 'WHILE', 'WEND', 'WIDTH', 'WINDOW', 'WRITE' + ) + + keywords = ( + 'ACCESS', 'ALIAS', 'ANY', 'APPEND', 'AS', 'BASE', 'BINARY', + 'BYVAL', 'CASE', 'CDECL', 'DOUBLE', 'ELSE', 'ELSEIF', 'ENDIF', + 'INTEGER', 'IS', 'LIST', 'LOCAL', 'LONG', 'LOOP', 'MOD', + 'NEXT', 'OFF', 'ON', 'OUTPUT', 'RANDOM', 'SIGNAL', 'SINGLE', + 'STEP', 'STRING', 'THEN', 'TO', 'UNTIL', 'USING', 'WEND' + ) + + tokens = { + 'root': [ + (r'\n+', Text), + (r'\s+', Text.Whitespace), + (r'^(\s*)(\d*)(\s*)(REM .*)$', + bygroups(Text.Whitespace, Name.Label, Text.Whitespace, + Comment.Single)), + (r'^(\s*)(\d+)(\s*)', + bygroups(Text.Whitespace, Name.Label, Text.Whitespace)), + (r'(?=[\s]*)(\w+)(?=[\s]*=)', Name.Variable.Global), + (r'(?=[^"]*)\'.*$', Comment.Single), + (r'"[^\n"]*"', String.Double), + (r'(END)(\s+)(FUNCTION|IF|SELECT|SUB)', + bygroups(Keyword.Reserved, Text.Whitespace, Keyword.Reserved)), + (r'(DECLARE)(\s+)([A-Z]+)(\s+)(\S+)', + bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable, + Text.Whitespace, Name)), + (r'(DIM)(\s+)(SHARED)(\s+)([^\s(]+)', + bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable, + Text.Whitespace, Name.Variable.Global)), + (r'(DIM)(\s+)([^\s(]+)', + bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable.Global)), + (r'^(\s*)([a-zA-Z_]+)(\s*)(\=)', + bygroups(Text.Whitespace, Name.Variable.Global, Text.Whitespace, + Operator)), + (r'(GOTO|GOSUB)(\s+)(\w+\:?)', + bygroups(Keyword.Reserved, Text.Whitespace, Name.Label)), + (r'(SUB)(\s+)(\w+\:?)', + bygroups(Keyword.Reserved, Text.Whitespace, Name.Label)), + include('declarations'), + include('functions'), + include('metacommands'), + include('operators'), + include('statements'), + include('keywords'), + (r'[a-zA-Z_]\w*[$@#&!]', Name.Variable.Global), + (r'[a-zA-Z_]\w*\:', Name.Label), + (r'\-?\d*\.\d+[@|#]?', Number.Float), + (r'\-?\d+[@|#]', Number.Float), + (r'\-?\d+#?', Number.Integer.Long), + (r'!=|==|:=|\.=|<<|>>|[-~+/\\*%=<>&^|?:!.]', Operator), + (r'[\[\]{}(),;]', Punctuation), + (r'[\w]+', Name.Variable.Global), + ], + # can't use regular \b because of X$() + # XXX: use words() here + 'declarations': [ + (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, declarations))), + Keyword.Declaration), + ], + 'functions': [ + (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, functions))), + Keyword.Reserved), + ], + 'metacommands': [ + (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, metacommands))), + Keyword.Constant), + ], + 'operators': [ + (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, operators))), Operator.Word), + ], + 'statements': [ + (r'\b({})\b'.format('|'.join(map(re.escape, statements))), + Keyword.Reserved), + ], + 'keywords': [ + (r'\b({})\b'.format('|'.join(keywords)), Keyword), + ], + } + + def analyse_text(text): + if '$DYNAMIC' in text or '$STATIC' in text: + return 0.9 + + +class VBScriptLexer(RegexLexer): + """ + VBScript is scripting language that is modeled on Visual Basic. + """ + name = 'VBScript' + aliases = ['vbscript'] + filenames = ['*.vbs', '*.VBS'] + url = 'https://learn.microsoft.com/en-us/previous-versions/t0aew7h6(v=vs.85)' + version_added = '2.4' + + flags = re.IGNORECASE + + tokens = { + 'root': [ + (r"'[^\n]*", Comment.Single), + (r'\s+', Whitespace), + ('"', String.Double, 'string'), + ('&h[0-9a-f]+', Number.Hex), + # Float variant 1, for example: 1., 1.e2, 1.2e3 + (r'[0-9]+\.[0-9]*(e[+-]?[0-9]+)?', Number.Float), + (r'\.[0-9]+(e[+-]?[0-9]+)?', Number.Float), # Float variant 2, for example: .1, .1e2 + (r'[0-9]+e[+-]?[0-9]+', Number.Float), # Float variant 3, for example: 123e45 + (r'[0-9]+', Number.Integer), + ('#.+#', String), # date or time value + (r'(dim)(\s+)([a-z_][a-z0-9_]*)', + bygroups(Keyword.Declaration, Whitespace, Name.Variable), 'dim_more'), + (r'(function|sub)(\s+)([a-z_][a-z0-9_]*)', + bygroups(Keyword.Declaration, Whitespace, Name.Function)), + (r'(class)(\s+)([a-z_][a-z0-9_]*)', + bygroups(Keyword.Declaration, Whitespace, Name.Class)), + (r'(const)(\s+)([a-z_][a-z0-9_]*)', + bygroups(Keyword.Declaration, Whitespace, Name.Constant)), + (r'(end)(\s+)(class|function|if|property|sub|with)', + bygroups(Keyword, Whitespace, Keyword)), + (r'(on)(\s+)(error)(\s+)(goto)(\s+)(0)', + bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword, Whitespace, Number.Integer)), + (r'(on)(\s+)(error)(\s+)(resume)(\s+)(next)', + bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword, Whitespace, Keyword)), + (r'(option)(\s+)(explicit)', bygroups(Keyword, Whitespace, Keyword)), + (r'(property)(\s+)(get|let|set)(\s+)([a-z_][a-z0-9_]*)', + bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration, Whitespace, Name.Property)), + (r'rem\s.*[^\n]*', Comment.Single), + (words(_vbscript_builtins.KEYWORDS, suffix=r'\b'), Keyword), + (words(_vbscript_builtins.OPERATORS), Operator), + (words(_vbscript_builtins.OPERATOR_WORDS, suffix=r'\b'), Operator.Word), + (words(_vbscript_builtins.BUILTIN_CONSTANTS, suffix=r'\b'), Name.Constant), + (words(_vbscript_builtins.BUILTIN_FUNCTIONS, suffix=r'\b'), Name.Builtin), + (words(_vbscript_builtins.BUILTIN_VARIABLES, suffix=r'\b'), Name.Builtin), + (r'[a-z_][a-z0-9_]*', Name), + (r'\b_\n', Operator), + (words(r'(),.:'), Punctuation), + (r'.+(\n)?', Error) + ], + 'dim_more': [ + (r'(\s*)(,)(\s*)([a-z_][a-z0-9]*)', + bygroups(Whitespace, Punctuation, Whitespace, Name.Variable)), + default('#pop'), + ], + 'string': [ + (r'[^"\n]+', String.Double), + (r'\"\"', String.Double), + (r'"', String.Double, '#pop'), + (r'\n', Error, '#pop'), # Unterminated string + ], + } + + +class BBCBasicLexer(RegexLexer): + """ + BBC Basic was supplied on the BBC Micro, and later Acorn RISC OS. + It is also used by BBC Basic For Windows. + """ + base_keywords = ['OTHERWISE', 'AND', 'DIV', 'EOR', 'MOD', 'OR', 'ERROR', + 'LINE', 'OFF', 'STEP', 'SPC', 'TAB', 'ELSE', 'THEN', + 'OPENIN', 'PTR', 'PAGE', 'TIME', 'LOMEM', 'HIMEM', 'ABS', + 'ACS', 'ADVAL', 'ASC', 'ASN', 'ATN', 'BGET', 'COS', 'COUNT', + 'DEG', 'ERL', 'ERR', 'EVAL', 'EXP', 'EXT', 'FALSE', 'FN', + 'GET', 'INKEY', 'INSTR', 'INT', 'LEN', 'LN', 'LOG', 'NOT', + 'OPENUP', 'OPENOUT', 'PI', 'POINT', 'POS', 'RAD', 'RND', + 'SGN', 'SIN', 'SQR', 'TAN', 'TO', 'TRUE', 'USR', 'VAL', + 'VPOS', 'CHR$', 'GET$', 'INKEY$', 'LEFT$', 'MID$', + 'RIGHT$', 'STR$', 'STRING$', 'EOF', 'PTR', 'PAGE', 'TIME', + 'LOMEM', 'HIMEM', 'SOUND', 'BPUT', 'CALL', 'CHAIN', 'CLEAR', + 'CLOSE', 'CLG', 'CLS', 'DATA', 'DEF', 'DIM', 'DRAW', 'END', + 'ENDPROC', 'ENVELOPE', 'FOR', 'GOSUB', 'GOTO', 'GCOL', 'IF', + 'INPUT', 'LET', 'LOCAL', 'MODE', 'MOVE', 'NEXT', 'ON', + 'VDU', 'PLOT', 'PRINT', 'PROC', 'READ', 'REM', 'REPEAT', + 'REPORT', 'RESTORE', 'RETURN', 'RUN', 'STOP', 'COLOUR', + 'TRACE', 'UNTIL', 'WIDTH', 'OSCLI'] + + basic5_keywords = ['WHEN', 'OF', 'ENDCASE', 'ENDIF', 'ENDWHILE', 'CASE', + 'CIRCLE', 'FILL', 'ORIGIN', 'POINT', 'RECTANGLE', 'SWAP', + 'WHILE', 'WAIT', 'MOUSE', 'QUIT', 'SYS', 'INSTALL', + 'LIBRARY', 'TINT', 'ELLIPSE', 'BEATS', 'TEMPO', 'VOICES', + 'VOICE', 'STEREO', 'OVERLAY', 'APPEND', 'AUTO', 'CRUNCH', + 'DELETE', 'EDIT', 'HELP', 'LIST', 'LOAD', 'LVAR', 'NEW', + 'OLD', 'RENUMBER', 'SAVE', 'TEXTLOAD', 'TEXTSAVE', + 'TWIN', 'TWINO', 'INSTALL', 'SUM', 'BEAT'] + + + name = 'BBC Basic' + aliases = ['bbcbasic'] + filenames = ['*.bbc'] + url = 'https://www.bbcbasic.co.uk/bbcbasic.html' + version_added = '2.4' + + tokens = { + 'root': [ + (r"[0-9]+", Name.Label), + (r"(\*)([^\n]*)", + bygroups(Keyword.Pseudo, Comment.Special)), + default('code'), + ], + + 'code': [ + (r"(REM)([^\n]*)", + bygroups(Keyword.Declaration, Comment.Single)), + (r'\n', Whitespace, 'root'), + (r'\s+', Whitespace), + (r':', Comment.Preproc), + + # Some special cases to make functions come out nicer + (r'(DEF)(\s*)(FN|PROC)([A-Za-z_@][\w@]*)', + bygroups(Keyword.Declaration, Whitespace, + Keyword.Declaration, Name.Function)), + (r'(FN|PROC)([A-Za-z_@][\w@]*)', + bygroups(Keyword, Name.Function)), + + (r'(GOTO|GOSUB|THEN|RESTORE)(\s*)(\d+)', + bygroups(Keyword, Whitespace, Name.Label)), + + (r'(TRUE|FALSE)', Keyword.Constant), + (r'(PAGE|LOMEM|HIMEM|TIME|WIDTH|ERL|ERR|REPORT\$|POS|VPOS|VOICES)', + Keyword.Pseudo), + + (words(base_keywords), Keyword), + (words(basic5_keywords), Keyword), + + ('"', String.Double, 'string'), + + ('%[01]{1,32}', Number.Bin), + ('&[0-9a-f]{1,8}', Number.Hex), + + (r'[+-]?[0-9]+\.[0-9]*(E[+-]?[0-9]+)?', Number.Float), + (r'[+-]?\.[0-9]+(E[+-]?[0-9]+)?', Number.Float), + (r'[+-]?[0-9]+E[+-]?[0-9]+', Number.Float), + (r'[+-]?\d+', Number.Integer), + + (r'([A-Za-z_@][\w@]*[%$]?)', Name.Variable), + (r'([+\-]=|[$!|?+\-*/%^=><();]|>=|<=|<>|<<|>>|>>>|,)', Operator), + ], + 'string': [ + (r'[^"\n]+', String.Double), + (r'"', String.Double, '#pop'), + (r'\n', Error, 'root'), # Unterminated string + ], + } + + def analyse_text(text): + if text.startswith('10REM >') or text.startswith('REM >'): + return 0.9 diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bdd.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bdd.py new file mode 100644 index 0000000000000000000000000000000000000000..82a03b64a3ec855a61c5d8ecfc608e46731a1d0c --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bdd.py @@ -0,0 +1,57 @@ +""" + pygments.lexers.bdd + ~~~~~~~~~~~~~~~~~~~ + + Lexer for BDD(Behavior-driven development). + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, include +from pygments.token import Comment, Keyword, Name, String, Number, Text, \ + Punctuation, Whitespace + +__all__ = ['BddLexer'] + +class BddLexer(RegexLexer): + """ + Lexer for BDD(Behavior-driven development), which highlights not only + keywords, but also comments, punctuations, strings, numbers, and variables. + """ + + name = 'Bdd' + aliases = ['bdd'] + filenames = ['*.feature'] + mimetypes = ['text/x-bdd'] + url = 'https://en.wikipedia.org/wiki/Behavior-driven_development' + version_added = '2.11' + + step_keywords = (r'Given|When|Then|Add|And|Feature|Scenario Outline|' + r'Scenario|Background|Examples|But') + + tokens = { + 'comments': [ + (r'^\s*#.*$', Comment), + ], + 'miscellaneous': [ + (r'(<|>|\[|\]|=|\||:|\(|\)|\{|\}|,|\.|;|-|_|\$)', Punctuation), + (r'((?<=\<)[^\\>]+(?=\>))', Name.Variable), + (r'"([^\"]*)"', String), + (r'^@\S+', Name.Label), + ], + 'numbers': [ + (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number), + ], + 'root': [ + (r'\n|\s+', Whitespace), + (step_keywords, Keyword), + include('comments'), + include('miscellaneous'), + include('numbers'), + (r'\S+', Text), + ] + } + + def analyse_text(self, text): + return diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/berry.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/berry.py new file mode 100644 index 0000000000000000000000000000000000000000..3702c1867ebff304bebb04bd1b0b9fa0fc854233 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/berry.py @@ -0,0 +1,99 @@ +""" + pygments.lexers.berry + ~~~~~~~~~~~~~~~~~~~~~ + + Lexer for Berry. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, words, include, bygroups +from pygments.token import Comment, Whitespace, Operator, Keyword, Name, \ + String, Number, Punctuation + +__all__ = ['BerryLexer'] + + +class BerryLexer(RegexLexer): + """ + For Berry source code. + """ + name = 'Berry' + aliases = ['berry', 'be'] + filenames = ['*.be'] + mimetypes = ['text/x-berry', 'application/x-berry'] + url = 'https://berry-lang.github.io' + version_added = '2.12' + + _name = r'\b[^\W\d]\w*' + + tokens = { + 'root': [ + include('whitespace'), + include('numbers'), + include('keywords'), + (rf'(def)(\s+)({_name})', + bygroups(Keyword.Declaration, Whitespace, Name.Function)), + (rf'\b(class)(\s+)({_name})', + bygroups(Keyword.Declaration, Whitespace, Name.Class)), + (rf'\b(import)(\s+)({_name})', + bygroups(Keyword.Namespace, Whitespace, Name.Namespace)), + include('expr') + ], + 'expr': [ + (r'[^\S\n]+', Whitespace), + (r'\.\.|[~!%^&*+=|?:<>/-]', Operator), + (r'[(){}\[\],.;]', Punctuation), + include('controls'), + include('builtins'), + include('funccall'), + include('member'), + include('name'), + include('strings') + ], + 'whitespace': [ + (r'\s+', Whitespace), + (r'#-[\s\S]*?-#', Comment.Multiline), + (r'#.*?$', Comment.Single) + ], + 'keywords': [ + (words(( + 'as', 'break', 'continue', 'import', 'static', 'self', 'super'), + suffix=r'\b'), Keyword.Reserved), + (r'(true|false|nil)\b', Keyword.Constant), + (r'(var|def)\b', Keyword.Declaration) + ], + 'controls': [ + (words(( + 'if', 'elif', 'else', 'for', 'while', 'do', 'end', 'break', + 'continue', 'return', 'try', 'except', 'raise'), + suffix=r'\b'), Keyword) + ], + 'builtins': [ + (words(( + 'assert', 'bool', 'input', 'classname', 'classof', 'number', 'real', + 'bytes', 'compile', 'map', 'list', 'int', 'isinstance', 'print', + 'range', 'str', 'super', 'module', 'size', 'issubclass', 'open', + 'file', 'type', 'call'), + suffix=r'\b'), Name.Builtin) + ], + 'numbers': [ + (r'0[xX][a-fA-F0-9]+', Number.Hex), + (r'-?\d+', Number.Integer), + (r'(-?\d+\.?|\.\d)\d*([eE][+-]?\d+)?', Number.Float) + ], + 'name': [ + (_name, Name) + ], + 'funccall': [ + (rf'{_name}(?=\s*\()', Name.Function, '#pop') + ], + 'member': [ + (rf'(?<=\.){_name}\b(?!\()', Name.Attribute, '#pop') + ], + 'strings': [ + (r'"([^\\]|\\.)*?"', String.Double, '#pop'), + (r'\'([^\\]|\\.)*?\'', String.Single, '#pop') + ] + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bibtex.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bibtex.py new file mode 100644 index 0000000000000000000000000000000000000000..069219635d436219093abe9ae9197ef5cd0f9b11 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bibtex.py @@ -0,0 +1,159 @@ +""" + pygments.lexers.bibtex + ~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for BibTeX bibliography data and styles + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, default, \ + words +from pygments.token import Name, Comment, String, Error, Number, Keyword, \ + Punctuation, Whitespace + +__all__ = ['BibTeXLexer', 'BSTLexer'] + + +class BibTeXLexer(ExtendedRegexLexer): + """ + A lexer for BibTeX bibliography data format. + """ + + name = 'BibTeX' + aliases = ['bibtex', 'bib'] + filenames = ['*.bib'] + mimetypes = ["text/x-bibtex"] + version_added = '2.2' + flags = re.IGNORECASE + url = 'https://texfaq.org/FAQ-BibTeXing' + + ALLOWED_CHARS = r'@!$&*+\-./:;<>?\[\\\]^`|~' + IDENTIFIER = '[{}][{}]*'.format('a-z_' + ALLOWED_CHARS, r'\w' + ALLOWED_CHARS) + + def open_brace_callback(self, match, ctx): + opening_brace = match.group() + ctx.opening_brace = opening_brace + yield match.start(), Punctuation, opening_brace + ctx.pos = match.end() + + def close_brace_callback(self, match, ctx): + closing_brace = match.group() + if ( + ctx.opening_brace == '{' and closing_brace != '}' or + ctx.opening_brace == '(' and closing_brace != ')' + ): + yield match.start(), Error, closing_brace + else: + yield match.start(), Punctuation, closing_brace + del ctx.opening_brace + ctx.pos = match.end() + + tokens = { + 'root': [ + include('whitespace'), + (r'@comment(?!ary)', Comment), + ('@preamble', Name.Class, ('closing-brace', 'value', 'opening-brace')), + ('@string', Name.Class, ('closing-brace', 'field', 'opening-brace')), + ('@' + IDENTIFIER, Name.Class, + ('closing-brace', 'command-body', 'opening-brace')), + ('.+', Comment), + ], + 'opening-brace': [ + include('whitespace'), + (r'[{(]', open_brace_callback, '#pop'), + ], + 'closing-brace': [ + include('whitespace'), + (r'[})]', close_brace_callback, '#pop'), + ], + 'command-body': [ + include('whitespace'), + (r'[^\s\,\}]+', Name.Label, ('#pop', 'fields')), + ], + 'fields': [ + include('whitespace'), + (',', Punctuation, 'field'), + default('#pop'), + ], + 'field': [ + include('whitespace'), + (IDENTIFIER, Name.Attribute, ('value', '=')), + default('#pop'), + ], + '=': [ + include('whitespace'), + ('=', Punctuation, '#pop'), + ], + 'value': [ + include('whitespace'), + (IDENTIFIER, Name.Variable), + ('"', String, 'quoted-string'), + (r'\{', String, 'braced-string'), + (r'[\d]+', Number), + ('#', Punctuation), + default('#pop'), + ], + 'quoted-string': [ + (r'\{', String, 'braced-string'), + ('"', String, '#pop'), + (r'[^\{\"]+', String), + ], + 'braced-string': [ + (r'\{', String, '#push'), + (r'\}', String, '#pop'), + (r'[^\{\}]+', String), + ], + 'whitespace': [ + (r'\s+', Whitespace), + ], + } + + +class BSTLexer(RegexLexer): + """ + A lexer for BibTeX bibliography styles. + """ + + name = 'BST' + aliases = ['bst', 'bst-pybtex'] + filenames = ['*.bst'] + version_added = '2.2' + flags = re.IGNORECASE | re.MULTILINE + url = 'https://texfaq.org/FAQ-BibTeXing' + + tokens = { + 'root': [ + include('whitespace'), + (words(['read', 'sort']), Keyword), + (words(['execute', 'integers', 'iterate', 'reverse', 'strings']), + Keyword, ('group')), + (words(['function', 'macro']), Keyword, ('group', 'group')), + (words(['entry']), Keyword, ('group', 'group', 'group')), + ], + 'group': [ + include('whitespace'), + (r'\{', Punctuation, ('#pop', 'group-end', 'body')), + ], + 'group-end': [ + include('whitespace'), + (r'\}', Punctuation, '#pop'), + ], + 'body': [ + include('whitespace'), + (r"\'[^#\"\{\}\s]+", Name.Function), + (r'[^#\"\{\}\s]+\$', Name.Builtin), + (r'[^#\"\{\}\s]+', Name.Variable), + (r'"[^\"]*"', String), + (r'#-?\d+', Number), + (r'\{', Punctuation, ('group-end', 'body')), + default('#pop'), + ], + 'whitespace': [ + (r'\s+', Whitespace), + ('%.*?$', Comment.Single), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bitbake.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bitbake.py new file mode 100644 index 0000000000000000000000000000000000000000..3b459b5c5b503051595ad01a1144330311ec5238 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bitbake.py @@ -0,0 +1,166 @@ +""" + pygments.lexers.bitbake + ~~~~~~~~~~~~~~~~~~~~~~~ + + Lexer for BitBake recipes, classes, includes and configuration files + used by the Yocto Project / OpenEmbedded build system. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, bygroups, include, using, words +from pygments.lexers.python import PythonLexer +from pygments.lexers.shell import BashLexer +from pygments.token import Comment, Keyword, Name, Operator, Punctuation, \ + String, Text, Whitespace + +__all__ = ['BitBakeLexer'] + +# A bare BitBake identifier (variable, function or flag name). Allows the +# characters used by OE-Core variable names (digits, ``-``, ``.``, ``+``). +_IDENT = r'[A-Za-z_][A-Za-z0-9_\-.+]*' + +# Optional OE override chain such as ``:append``, ``:remove``, ``:class-target`` +# or ``:${PN}-doc``. Anchored so it only consumes ``:foo`` runs and never +# eats the leading ``:`` of the ``:=`` assignment operator. +_OVERRIDE = r'(?::[A-Za-z0-9_\-.+${}]+)*' + +# All BitBake variable assignment operators, ordered so that the longer +# operators win the regex alternation. +_ASSIGN = r'(?:\?\?=|\?=|:=|\+=|=\+|\.=|=\.|=)' + + +class BitBakeLexer(RegexLexer): + """ + Lexer for BitBake recipes, classes, includes and configuration files + used by the Yocto Project and OpenEmbedded build system. + """ + + name = 'BitBake' + url = 'https://docs.yoctoproject.org/bitbake/' + aliases = ['bitbake'] + filenames = ['*.bbclass', '*.bbappend'] + mimetypes = ['text/x-bitbake'] + version_added = '2.21' + + flags = re.MULTILINE + + tokens = { + 'root': [ + (r'[ \t]+', Whitespace), + (r'\n', Whitespace), + (r'#.*$', Comment.Single), + + # ``python [name]() { ... }`` blocks (also ``fakeroot python``). + # Must be tried before the generic shell function rule so the + # ``python`` keyword is not mistaken for a shell function name. + (r'(^(?:fakeroot[ \t]+)?)(python)((?:[ \t]+' + _IDENT + r')?)' + r'([ \t]*\([ \t]*\)[ \t]*)(\{[ \t]*\n)' + r'((?:.*\n)*?)' + r'(^\}[ \t]*$)', + bygroups(Keyword.Type, Keyword, Name.Function, Text, + Punctuation, using(PythonLexer), Punctuation)), + + # Shell task bodies: ``[fakeroot ]name[:override]() { ... }``. + (r'(^(?:fakeroot[ \t]+)?)(' + _IDENT + r')(' + _OVERRIDE + r')' + r'([ \t]*\([ \t]*\)[ \t]*)(\{[ \t]*\n)' + r'((?:.*\n)*?)' + r'(^\}[ \t]*$)', + bygroups(Keyword.Type, Name.Function, Name.Decorator, Text, + Punctuation, using(BashLexer), Punctuation)), + + # Top-level python ``def`` blocks; the body is any run of + # indented or blank lines following the signature. + (r'^def[ \t]+' + _IDENT + r'[ \t]*\([^)]*\)[ \t]*:[ \t]*\n' + r'(?:[ \t]+.*\n|\n)+', + using(PythonLexer)), + + # ``inherit`` / ``inherit_defer`` / ``include`` / ``include_all`` / + # ``require`` directives. Longer keywords are listed first so the + # regex alternation does not match the shorter prefix. + (r'^(inherit_defer|inherit|include_all|include|require)\b', + Keyword.Namespace, 'include-line'), + + # ``addtask`` / ``deltask`` / ``addhandler`` / ``EXPORT_FUNCTIONS``. + (r'^(addtask|deltask|addhandler|EXPORT_FUNCTIONS)\b', + Keyword, 'statement'), + + # ``VAR[flag] = "value"`` (varflag assignment). + (r'^(' + _IDENT + r')(\[)(' + _IDENT + r')(\])([ \t]*)(' + + _ASSIGN + r')', + bygroups(Name.Variable, Punctuation, Name.Attribute, + Punctuation, Whitespace, Operator), + 'value'), + + # ``[export ]VAR[:override...] OP "value"`` assignments. + (r'^(export[ \t]+)?(' + _IDENT + r')(' + _OVERRIDE + r')' + r'([ \t]*)(' + _ASSIGN + r')', + bygroups(Keyword.Type, Name.Variable, Name.Decorator, + Whitespace, Operator), + 'value'), + + # Anything else: consume runs of "boring" characters in one + # token, then fall back to a single character if needed. + (r'[^\s#${}\[\]:=+?.@\\"\']+', Text), + (r'.', Text), + ], + + 'include-line': [ + (r'[ \t]+', Whitespace), + (r'\\\n', Text), + (r'\n', Whitespace, '#pop'), + include('interp'), + (r'[^\s$]+', String), + ], + + 'statement': [ + (r'[ \t]+', Whitespace), + (r'\\\n', Text), + (r'\n', Whitespace, '#pop'), + (words(('after', 'before'), suffix=r'\b'), Keyword), + include('interp'), + (r'[^\s$\\]+', Name), + ], + + 'value': [ + (r'[ \t]+', Whitespace), + (r'\\\n', String.Escape), + (r'\n', Whitespace, '#pop'), + (r'"', String.Double, 'string-double'), + (r"'", String.Single, 'string-single'), + include('interp'), + (r'[^\s"\'$\\]+', String), + ], + + 'string-double': [ + (r'\\\n', String.Escape), + (r'\\.', String.Escape), + (r'"', String.Double, '#pop'), + include('interp'), + (r'[^"\\$]+', String.Double), + ], + + 'string-single': [ + (r'\\\n', String.Escape), + (r'\\.', String.Escape), + (r"'", String.Single, '#pop'), + include('interp'), + (r"[^'\\$]+", String.Single), + ], + + 'interp': [ + # ``${@ python expression }`` evaluated by BitBake at parse time. + (r'\$\{@', String.Interpol, 'py-interp'), + # ``${VAR}`` variable expansion. + (r'(\$\{)([A-Za-z0-9_\-:.+/]+)(\})', + bygroups(String.Interpol, Name.Variable, String.Interpol)), + ], + + 'py-interp': [ + (r'\}', String.Interpol, '#pop'), + (r'[^}]+', using(PythonLexer)), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/blueprint.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/blueprint.py new file mode 100644 index 0000000000000000000000000000000000000000..1dcc235e2624b163c9d2d4b5f0182fc527a93eb7 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/blueprint.py @@ -0,0 +1,173 @@ +""" + pygments.lexers.blueprint + ~~~~~~~~~~~~~~~~~~~~~~~~~ + + Lexer for the Blueprint UI markup language. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, include, bygroups, words +from pygments.token import ( + Comment, + Operator, + Keyword, + Name, + String, + Number, + Punctuation, + Whitespace, +) + +__all__ = ["BlueprintLexer"] + + +class BlueprintLexer(RegexLexer): + """ + For Blueprint UI markup. + """ + + name = "Blueprint" + aliases = ["blueprint"] + filenames = ["*.blp"] + mimetypes = ["text/x-blueprint"] + url = "https://gitlab.gnome.org/jwestman/blueprint-compiler" + version_added = '2.16' + + flags = re.IGNORECASE + tokens = { + "root": [ + include("block-content"), + ], + "type": [ + (r"\$\s*[a-z_][a-z0-9_\-]*", Name.Class), + (r"(?:([a-z_][a-z0-9_\-]*)(\s*)(\.)(\s*))?([a-z_][a-z0-9_\-]*)", + bygroups(Name.Namespace, Whitespace, Punctuation, Whitespace, Name.Class)), + ], + "whitespace": [ + (r"\s+", Whitespace), + (r"//.*?\n", Comment.Single), + (r"/\*", Comment.Multiline, "comment-multiline"), + ], + "comment-multiline": [ + (r"\*/", Comment.Multiline, "#pop"), + (r"[^*]+", Comment.Multiline), + (r"\*", Comment.Multiline), + ], + "value": [ + (r"(typeof)(\s*)(<)", bygroups(Keyword, Whitespace, Punctuation), "typeof"), + (words(("true", "false", "null")), Keyword.Constant), + (r"[a-z_][a-z0-9_\-]*", Name.Variable), + (r"\|", Operator), + (r'".*?"', String.Double), + (r"\'.*?\'", String.Single), + (r"0x[\d_]*", Number.Hex), + (r"[0-9_]+", Number.Integer), + (r"\d[\d\.a-z_]*", Number), + ], + "typeof": [ + include("whitespace"), + include("type"), + (r">", Punctuation, "#pop"), + ], + "content": [ + include("whitespace"), + # Keywords + (words(("after", "bidirectional", "bind-property", "bind", "default", + "destructive", "disabled", "inverted", "no-sync-create", + "suggested", "swapped", "sync-create", "template")), + Keyword), + # Translated strings + (r"(C?_)(\s*)(\()", + bygroups(Name.Function.Builtin, Whitespace, Punctuation), + "paren-content"), + # Cast expressions + (r"(as)(\s*)(<)", bygroups(Keyword, Whitespace, Punctuation), "typeof"), + # Closures + (r"(\$?[a-z_][a-z0-9_\-]*)(\s*)(\()", + bygroups(Name.Function, Whitespace, Punctuation), + "paren-content"), + # Objects + (r"(?:(\$\s*[a-z_][a-z0-9_\-]+)|(?:([a-z_][a-z0-9_\-]*)(\s*)(\.)(\s*))?([a-z_][a-z0-9_\-]*))(?:(\s+)([a-z_][a-z0-9_\-]*))?(\s*)(\{)", + bygroups(Name.Class, Name.Namespace, Whitespace, Punctuation, Whitespace, + Name.Class, Whitespace, Name.Variable, Whitespace, Punctuation), + "brace-block"), + # Misc + include("value"), + (r",|\.", Punctuation), + ], + "block-content": [ + # Import statements + (r"(using)(\s+)([a-z_][a-z0-9_\-]*)(\s+)(\d[\d\.]*)(;)", + bygroups(Keyword, Whitespace, Name.Namespace, Whitespace, + Name.Namespace, Punctuation)), + # Menus + (r"(menu|section|submenu)(?:(\s+)([a-z_][a-z0-9_\-]*))?(\s*)(\{)", + bygroups(Keyword, Whitespace, Name.Variable, Whitespace, Punctuation), + "brace-block"), + (r"(item)(\s*)(\{)", + bygroups(Keyword, Whitespace, Punctuation), + "brace-block"), + (r"(item)(\s*)(\()", + bygroups(Keyword, Whitespace, Punctuation), + "paren-block"), + # Templates + (r"template", Keyword.Declaration, "template"), + # Nested blocks. When extensions are added, this is where they go. + (r"(responses|items|mime-types|patterns|suffixes|marks|widgets|strings|styles)(\s*)(\[)", + bygroups(Keyword, Whitespace, Punctuation), + "bracket-block"), + (r"(accessibility|setters|layout|item)(\s*)(\{)", + bygroups(Keyword, Whitespace, Punctuation), + "brace-block"), + (r"(condition|mark|item)(\s*)(\()", + bygroups(Keyword, Whitespace, Punctuation), + "paren-content"), + (r"\[", Punctuation, "child-type"), + # Properties and signals + (r"([a-z_][a-z0-9_\-]*(?:::[a-z0-9_]+)?)(\s*)(:|=>)", + bygroups(Name.Property, Whitespace, Punctuation), + "statement"), + include("content"), + ], + "paren-block": [ + include("block-content"), + (r"\)", Punctuation, "#pop"), + ], + "paren-content": [ + include("content"), + (r"\)", Punctuation, "#pop"), + ], + "bracket-block": [ + include("block-content"), + (r"\]", Punctuation, "#pop"), + ], + "brace-block": [ + include("block-content"), + (r"\}", Punctuation, "#pop"), + ], + "statement": [ + include("content"), + (r";", Punctuation, "#pop"), + ], + "child-type": [ + include("whitespace"), + (r"(action)(\s+)(response)(\s*)(=)(\s*)", + bygroups(Keyword, Whitespace, Name.Attribute, Whitespace, + Punctuation, Whitespace)), + (words(("default", "internal-child", "response")), Keyword), + (r"[a-z_][a-z0-9_\-]*", Name.Decorator), + include("value"), + (r"=", Punctuation), + (r"\]", Punctuation, "#pop"), + ], + "template": [ + include("whitespace"), + include("type"), + (r":", Punctuation), + (r"\{", Punctuation, ("#pop", "brace-block")), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/boa.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/boa.py new file mode 100644 index 0000000000000000000000000000000000000000..06977dd198e573f17e5d3d9d37a74b4da2eeb929 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/boa.py @@ -0,0 +1,97 @@ +""" + pygments.lexers.boa + ~~~~~~~~~~~~~~~~~~~ + + Lexers for the Boa language. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, words +from pygments.token import String, Comment, Keyword, Name, Number, Operator, \ + Punctuation, Whitespace + +__all__ = ['BoaLexer'] + + +class BoaLexer(RegexLexer): + """ + Lexer for the Boa language. + """ + name = 'Boa' + aliases = ['boa'] + filenames = ['*.boa'] + url = 'https://boa.cs.iastate.edu/docs' + version_added = '2.4' + + reserved = words( + ('input', 'output', 'of', 'weight', 'before', 'after', 'stop', + 'ifall', 'foreach', 'exists', 'function', 'break', 'switch', 'case', + 'visitor', 'default', 'return', 'visit', 'while', 'if', 'else'), + suffix=r'\b', prefix=r'\b') + keywords = words( + ('bottom', 'collection', 'maximum', 'mean', 'minimum', 'set', 'sum', + 'top', 'string', 'int', 'bool', 'float', 'time', 'false', 'true', + 'array', 'map', 'stack', 'enum', 'type'), suffix=r'\b', prefix=r'\b') + classes = words( + ('Project', 'ForgeKind', 'CodeRepository', 'Revision', 'RepositoryKind', + 'ChangedFile', 'FileKind', 'ASTRoot', 'Namespace', 'Declaration', 'Type', + 'Method', 'Variable', 'Statement', 'Expression', 'Modifier', + 'StatementKind', 'ExpressionKind', 'ModifierKind', 'Visibility', + 'TypeKind', 'Person', 'ChangeKind'), + suffix=r'\b', prefix=r'\b') + operators = ('->', ':=', ':', '=', '<<', '!', '++', '||', + '&&', '+', '-', '*', ">", "<") + string_sep = ('`', '\"') + built_in_functions = words( + ( + # Array functions + 'new', 'sort', + # Date & Time functions + 'yearof', 'dayofyear', 'hourof', 'minuteof', 'secondof', 'now', + 'addday', 'addmonth', 'addweek', 'addyear', 'dayofmonth', 'dayofweek', + 'dayofyear', 'formattime', 'trunctoday', 'trunctohour', 'trunctominute', + 'trunctomonth', 'trunctosecond', 'trunctoyear', + # Map functions + 'clear', 'haskey', 'keys', 'lookup', 'remove', 'values', + # Math functions + 'abs', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', + 'ceil', 'cos', 'cosh', 'exp', 'floor', 'highbit', 'isfinite', 'isinf', + 'isnan', 'isnormal', 'log', 'log10', 'max', 'min', 'nrand', 'pow', + 'rand', 'round', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc', + # Other functions + 'def', 'hash', 'len', + # Set functions + 'add', 'contains', 'remove', + # String functions + 'format', 'lowercase', 'match', 'matchposns', 'matchstrs', 'regex', + 'split', 'splitall', 'splitn', 'strfind', 'strreplace', 'strrfind', + 'substring', 'trim', 'uppercase', + # Type Conversion functions + 'bool', 'float', 'int', 'string', 'time', + # Domain-Specific functions + 'getast', 'getsnapshot', 'hasfiletype', 'isfixingrevision', 'iskind', + 'isliteral', + ), + prefix=r'\b', + suffix=r'\(') + + tokens = { + 'root': [ + (r'#.*?$', Comment.Single), + (r'/\*.*?\*/', Comment.Multiline), + (reserved, Keyword.Reserved), + (built_in_functions, Name.Function), + (keywords, Keyword.Type), + (classes, Name.Classes), + (words(operators), Operator), + (r'[][(),;{}\\.]', Punctuation), + (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), + (r"`(\\\\|\\[^\\]|[^`\\])*`", String.Backtick), + (words(string_sep), String.Delimiter), + (r'[a-zA-Z_]+', Name.Variable), + (r'[0-9]+', Number.Integer), + (r'\s+', Whitespace), # Whitespace + ] + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bqn.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bqn.py new file mode 100644 index 0000000000000000000000000000000000000000..beb292fbf48d0fcccd07120cfad2c4dd18abc302 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/bqn.py @@ -0,0 +1,112 @@ +""" + pygments.lexers.bqn + ~~~~~~~~~~~~~~~~~~~ + + Lexer for BQN. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer +from pygments.token import Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace + +__all__ = ['BQNLexer'] + + +class BQNLexer(RegexLexer): + """ + A simple BQN lexer. + """ + name = 'BQN' + url = 'https://mlochbaum.github.io/BQN/index.html' + aliases = ['bqn'] + filenames = ['*.bqn'] + mimetypes = [] + version_added = '2.16' + + # An inter_word_char. Necessary because \w matches all alphanumeric + # Unicode characters, including ones (e.g., 𝕊) that BQN treats special. + _iwc = r'((?=[^𝕎𝕏𝔽𝔾𝕊𝕨𝕩𝕗𝕘𝕤𝕣])\w)' + + tokens = { + 'root': [ + # Whitespace + # ========== + (r'\s+', Whitespace), + # + # Comment + # ======= + # '#' is a comment that continues to the end of the line + (r'#.*$', Comment.Single), + # + # Strings + # ======= + (r'\'((\'\')|[^\'])*\'', String.Single), + (r'"(("")|[^"])*"', String.Double), + # + # Null Character + # ============== + # Literal representation of the null character + (r'@', String.Symbol), + # + # Punctuation + # =========== + # This token type is used for diamond, commas + # and array and list brackets and strand syntax + (r'[\.⋄,\[\]⟨⟩‿]', Punctuation), + # + # Expression Grouping + # =================== + # Since this token type is important in BQN, it is not included in + # the punctuation token type but rather in the following one + (r'[\(\)]', String.Regex), + # + # Numbers + # ======= + # Includes the numeric literals and the Nothing character + (r'¯?[0-9](([0-9]|_)*\.?([0-9]|_)+|([0-9]|_)*)([Ee][¯]?([0-9]|_)+)?|¯|∞|π|·', Number), + # + # Variables + # ========= + (r'[a-z]' + _iwc + r'*', Name.Variable), + # + # 2-Modifiers + # =========== + # Needs to come before the 1-modifiers due to _𝕣 and _𝕣_ + (r'[∘○⊸⟜⌾⊘◶⎉⚇⍟⎊]', Name.Property), + (r'_(𝕣|[a-zA-Z0-9]+)_', Name.Property), + # + # 1-Modifiers + # =========== + (r'[˙˜˘¨⌜⁼´˝`𝕣]', Name.Attribute), + (r'_(𝕣|[a-zA-Z0-9]+)', Name.Attribute), + # + # Functions + # ========= + # The monadic or dyadic function primitives and function + # operands and arguments, along with function self-reference + (r'[+\-×÷\⋆√⌊⌈∧∨¬|≤<>≥=≠≡≢⊣⊢⥊∾≍⋈↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!𝕎𝕏𝔽𝔾𝕊]', + Operator), + (r'[A-Z]' + _iwc + r'*|•' + _iwc + r'+', Operator), + # + # Constant + # ======== + (r'˙', Name.Constant), + # + # Define/Export/Change + # ==================== + (r'[←↩⇐]', Keyword.Declaration), + # + # Blocks + # ====== + (r'[{}]', Keyword.Type), + # + # Extra characters + # ================ + (r'[;:?𝕨𝕩𝕗𝕘𝕤]', Name.Entity), + # + + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/business.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/business.py new file mode 100644 index 0000000000000000000000000000000000000000..3f9a86829b46c4444f3e4aa4dbc7ba64f7fc7599 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/business.py @@ -0,0 +1,625 @@ +""" + pygments.lexers.business + ~~~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for "business-oriented" languages. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, include, words, bygroups +from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Error, Whitespace + +from pygments.lexers._openedge_builtins import OPENEDGEKEYWORDS + +__all__ = ['CobolLexer', 'CobolFreeformatLexer', 'ABAPLexer', 'OpenEdgeLexer', + 'GoodDataCLLexer', 'MaqlLexer'] + + +class CobolLexer(RegexLexer): + """ + Lexer for OpenCOBOL code. + """ + name = 'COBOL' + aliases = ['cobol'] + filenames = ['*.cob', '*.COB', '*.cpy', '*.CPY'] + mimetypes = ['text/x-cobol'] + url = 'https://en.wikipedia.org/wiki/COBOL' + version_added = '1.6' + + flags = re.IGNORECASE | re.MULTILINE + + # Data Types: by PICTURE and USAGE + # Operators: **, *, +, -, /, <, >, <=, >=, =, <> + # Logical (?): NOT, AND, OR + + # Reserved words: + # http://opencobol.add1tocobol.com/#reserved-words + # Intrinsics: + # http://opencobol.add1tocobol.com/#does-opencobol-implement-any-intrinsic-functions + + tokens = { + 'root': [ + include('comment'), + include('strings'), + include('core'), + include('nums'), + (r'[a-z0-9]([\w\-]*[a-z0-9]+)?', Name.Variable), + # (r'[\s]+', Text), + (r'[ \t]+', Whitespace), + ], + 'comment': [ + (r'(^.{6}[*/].*\n|^.{6}|\*>.*\n)', Comment), + ], + 'core': [ + # Figurative constants + (r'(^|(?<=[^\w\-]))(ALL\s+)?' + r'((ZEROES)|(HIGH-VALUE|LOW-VALUE|QUOTE|SPACE|ZERO)(S)?)' + r'\s*($|(?=[^\w\-]))', + Name.Constant), + + # Reserved words STATEMENTS and other bolds + (words(( + 'ACCEPT', 'ADD', 'ALLOCATE', 'CALL', 'CANCEL', 'CLOSE', 'COMPUTE', + 'CONFIGURATION', 'CONTINUE', 'DATA', 'DELETE', 'DISPLAY', 'DIVIDE', + 'DIVISION', 'ELSE', 'END', 'END-ACCEPT', + 'END-ADD', 'END-CALL', 'END-COMPUTE', 'END-DELETE', 'END-DISPLAY', + 'END-DIVIDE', 'END-EVALUATE', 'END-IF', 'END-MULTIPLY', 'END-OF-PAGE', + 'END-PERFORM', 'END-READ', 'END-RETURN', 'END-REWRITE', 'END-SEARCH', + 'END-START', 'END-STRING', 'END-SUBTRACT', 'END-UNSTRING', 'END-WRITE', + 'ENVIRONMENT', 'EVALUATE', 'EXIT', 'FD', 'FILE', 'FILE-CONTROL', 'FOREVER', + 'FREE', 'GENERATE', 'GO', 'GOBACK', 'IDENTIFICATION', 'IF', 'INITIALIZE', + 'INITIATE', 'INPUT-OUTPUT', 'INSPECT', 'INVOKE', 'I-O-CONTROL', 'LINKAGE', + 'LOCAL-STORAGE', 'MERGE', 'MOVE', 'MULTIPLY', 'OPEN', 'PERFORM', + 'PROCEDURE', 'PROGRAM-ID', 'RAISE', 'READ', 'RELEASE', 'RESUME', + 'RETURN', 'REWRITE', 'SCREEN', 'SD', 'SEARCH', 'SECTION', 'SET', + 'SORT', 'START', 'STOP', 'STRING', 'SUBTRACT', 'SUPPRESS', + 'TERMINATE', 'THEN', 'UNLOCK', 'UNSTRING', 'USE', 'VALIDATE', + 'WORKING-STORAGE', 'WRITE'), prefix=r'(^|(?<=[^\w\-]))', + suffix=r'\s*($|(?=[^\w\-]))'), + Keyword.Reserved), + + # Reserved words + (words(( + 'ACCESS', 'ADDRESS', 'ADVANCING', 'AFTER', 'ALL', + 'ALPHABET', 'ALPHABETIC', 'ALPHABETIC-LOWER', 'ALPHABETIC-UPPER', + 'ALPHANUMERIC', 'ALPHANUMERIC-EDITED', 'ALSO', 'ALTER', 'ALTERNATE', + 'ANY', 'ARE', 'AREA', 'AREAS', 'ARGUMENT-NUMBER', 'ARGUMENT-VALUE', 'AS', + 'ASCENDING', 'ASSIGN', 'AT', 'AUTO', 'AUTO-SKIP', 'AUTOMATIC', + 'AUTOTERMINATE', 'BACKGROUND-COLOR', 'BASED', 'BEEP', 'BEFORE', 'BELL', + 'BLANK', 'BLINK', 'BLOCK', 'BOTTOM', 'BY', 'BYTE-LENGTH', 'CHAINING', + 'CHARACTER', 'CHARACTERS', 'CLASS', 'CODE', 'CODE-SET', 'COL', + 'COLLATING', 'COLS', 'COLUMN', 'COLUMNS', 'COMMA', 'COMMAND-LINE', + 'COMMIT', 'COMMON', 'CONSTANT', 'CONTAINS', 'CONTENT', 'CONTROL', + 'CONTROLS', 'CONVERTING', 'COPY', 'CORR', 'CORRESPONDING', 'COUNT', 'CRT', + 'CURRENCY', 'CURSOR', 'CYCLE', 'DATE', 'DAY', 'DAY-OF-WEEK', 'DE', + 'DEBUGGING', 'DECIMAL-POINT', 'DECLARATIVES', 'DEFAULT', 'DELIMITED', + 'DELIMITER', 'DEPENDING', 'DESCENDING', 'DETAIL', 'DISK', + 'DOWN', 'DUPLICATES', 'DYNAMIC', 'EBCDIC', + 'ENTRY', 'ENVIRONMENT-NAME', 'ENVIRONMENT-VALUE', 'EOL', 'EOP', + 'EOS', 'ERASE', 'ERROR', 'ESCAPE', 'EXCEPTION', + 'EXCLUSIVE', 'EXTEND', 'EXTERNAL', 'FILE-ID', 'FILLER', 'FINAL', + 'FIRST', 'FIXED', 'FLOAT-LONG', 'FLOAT-SHORT', + 'FOOTING', 'FOR', 'FOREGROUND-COLOR', 'FORMAT', 'FROM', 'FULL', + 'FUNCTION', 'FUNCTION-ID', 'GIVING', 'GLOBAL', 'GROUP', + 'HEADING', 'HIGHLIGHT', 'I-O', 'ID', + 'IGNORE', 'IGNORING', 'IN', 'INDEX', 'INDEXED', 'INDICATE', + 'INITIAL', 'INITIALIZED', 'INPUT', 'INTO', 'INTRINSIC', 'INVALID', + 'IS', 'JUST', 'JUSTIFIED', 'KEY', 'LABEL', + 'LAST', 'LEADING', 'LEFT', 'LENGTH', 'LIMIT', 'LIMITS', 'LINAGE', + 'LINAGE-COUNTER', 'LINE', 'LINES', 'LOCALE', 'LOCK', + 'LOWLIGHT', 'MANUAL', 'MEMORY', 'MINUS', 'MODE', 'MULTIPLE', + 'NATIONAL', 'NATIONAL-EDITED', 'NATIVE', 'NEGATIVE', 'NEXT', 'NO', + 'NULL', 'NULLS', 'NUMBER', 'NUMBERS', 'NUMERIC', 'NUMERIC-EDITED', + 'OBJECT-COMPUTER', 'OCCURS', 'OF', 'OFF', 'OMITTED', 'ON', 'ONLY', + 'OPTIONAL', 'ORDER', 'ORGANIZATION', 'OTHER', 'OUTPUT', 'OVERFLOW', + 'OVERLINE', 'PACKED-DECIMAL', 'PADDING', 'PAGE', 'PARAGRAPH', + 'PLUS', 'POINTER', 'POSITION', 'POSITIVE', 'PRESENT', 'PREVIOUS', + 'PRINTER', 'PRINTING', 'PROCEDURE-POINTER', 'PROCEDURES', + 'PROCEED', 'PROGRAM', 'PROGRAM-POINTER', 'PROMPT', 'QUOTE', + 'QUOTES', 'RANDOM', 'RD', 'RECORD', 'RECORDING', 'RECORDS', 'RECURSIVE', + 'REDEFINES', 'REEL', 'REFERENCE', 'RELATIVE', 'REMAINDER', 'REMOVAL', + 'RENAMES', 'REPLACING', 'REPORT', 'REPORTING', 'REPORTS', 'REPOSITORY', + 'REQUIRED', 'RESERVE', 'RETURNING', 'REVERSE-VIDEO', 'REWIND', + 'RIGHT', 'ROLLBACK', 'ROUNDED', 'RUN', 'SAME', 'SCROLL', + 'SECURE', 'SEGMENT-LIMIT', 'SELECT', 'SENTENCE', 'SEPARATE', + 'SEQUENCE', 'SEQUENTIAL', 'SHARING', 'SIGN', 'SIGNED', 'SIGNED-INT', + 'SIGNED-LONG', 'SIGNED-SHORT', 'SIZE', 'SORT-MERGE', 'SOURCE', + 'SOURCE-COMPUTER', 'SPECIAL-NAMES', 'STANDARD', + 'STANDARD-1', 'STANDARD-2', 'STATUS', 'SUBKEY', 'SUM', + 'SYMBOLIC', 'SYNC', 'SYNCHRONIZED', 'TALLYING', 'TAPE', + 'TEST', 'THROUGH', 'THRU', 'TIME', 'TIMES', 'TO', 'TOP', 'TRAILING', + 'TRANSFORM', 'TYPE', 'UNDERLINE', 'UNIT', 'UNSIGNED', + 'UNSIGNED-INT', 'UNSIGNED-LONG', 'UNSIGNED-SHORT', 'UNTIL', 'UP', + 'UPDATE', 'UPON', 'USAGE', 'USING', 'VALUE', 'VALUES', 'VARYING', + 'WAIT', 'WHEN', 'WITH', 'WORDS', 'YYYYDDD', 'YYYYMMDD'), + prefix=r'(^|(?<=[^\w\-]))', suffix=r'\s*($|(?=[^\w\-]))'), + Keyword.Pseudo), + + # inactive reserved words + (words(( + 'ACTIVE-CLASS', 'ALIGNED', 'ANYCASE', 'ARITHMETIC', 'ATTRIBUTE', + 'B-AND', 'B-NOT', 'B-OR', 'B-XOR', 'BIT', 'BOOLEAN', 'CD', 'CENTER', + 'CF', 'CH', 'CHAIN', 'CLASS-ID', 'CLASSIFICATION', 'COMMUNICATION', + 'CONDITION', 'DATA-POINTER', 'DESTINATION', 'DISABLE', 'EC', 'EGI', + 'EMI', 'ENABLE', 'END-RECEIVE', 'ENTRY-CONVENTION', 'EO', 'ESI', + 'EXCEPTION-OBJECT', 'EXPANDS', 'FACTORY', 'FLOAT-BINARY-16', + 'FLOAT-BINARY-34', 'FLOAT-BINARY-7', 'FLOAT-DECIMAL-16', + 'FLOAT-DECIMAL-34', 'FLOAT-EXTENDED', 'FORMAT', 'FUNCTION-POINTER', + 'GET', 'GROUP-USAGE', 'IMPLEMENTS', 'INFINITY', 'INHERITS', + 'INTERFACE', 'INTERFACE-ID', 'INVOKE', 'LC_ALL', 'LC_COLLATE', + 'LC_CTYPE', 'LC_MESSAGES', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', + 'LINE-COUNTER', 'MESSAGE', 'METHOD', 'METHOD-ID', 'NESTED', 'NONE', + 'NORMAL', 'OBJECT', 'OBJECT-REFERENCE', 'OPTIONS', 'OVERRIDE', + 'PAGE-COUNTER', 'PF', 'PH', 'PROPERTY', 'PROTOTYPE', 'PURGE', + 'QUEUE', 'RAISE', 'RAISING', 'RECEIVE', 'RELATION', 'REPLACE', + 'REPRESENTS-NOT-A-NUMBER', 'RESET', 'RESUME', 'RETRY', 'RF', 'RH', + 'SECONDS', 'SEGMENT', 'SELF', 'SEND', 'SOURCES', 'STATEMENT', + 'STEP', 'STRONG', 'SUB-QUEUE-1', 'SUB-QUEUE-2', 'SUB-QUEUE-3', + 'SUPER', 'SYMBOL', 'SYSTEM-DEFAULT', 'TABLE', 'TERMINAL', 'TEXT', + 'TYPEDEF', 'UCS-4', 'UNIVERSAL', 'USER-DEFAULT', 'UTF-16', 'UTF-8', + 'VAL-STATUS', 'VALID', 'VALIDATE', 'VALIDATE-STATUS'), + prefix=r'(^|(?<=[^\w\-]))', suffix=r'\s*($|(?=[^\w\-]))'), + Error), + + # Data Types + (r'(^|(?<=[^\w\-]))' + r'(PIC\s+.+?(?=(\s|\.\s))|PICTURE\s+.+?(?=(\s|\.\s))|' + r'(COMPUTATIONAL)(-[1-5X])?|(COMP)(-[1-5X])?|' + r'BINARY-C-LONG|' + r'BINARY-CHAR|BINARY-DOUBLE|BINARY-LONG|BINARY-SHORT|' + r'BINARY)\s*($|(?=[^\w\-]))', Keyword.Type), + + # Operators + (r'(\*\*|\*|\+|-|/|<=|>=|<|>|==|/=|=)', Operator), + + # (r'(::)', Keyword.Declaration), + + (r'([(),;:&%.])', Punctuation), + + # Intrinsics + (r'(^|(?<=[^\w\-]))(ABS|ACOS|ANNUITY|ASIN|ATAN|BYTE-LENGTH|' + r'CHAR|COMBINED-DATETIME|CONCATENATE|COS|CURRENT-DATE|' + r'DATE-OF-INTEGER|DATE-TO-YYYYMMDD|DAY-OF-INTEGER|DAY-TO-YYYYDDD|' + r'EXCEPTION-(?:FILE|LOCATION|STATEMENT|STATUS)|EXP10|EXP|E|' + r'FACTORIAL|FRACTION-PART|INTEGER-OF-(?:DATE|DAY|PART)|INTEGER|' + r'LENGTH|LOCALE-(?:DATE|TIME(?:-FROM-SECONDS)?)|LOG(?:10)?|' + r'LOWER-CASE|MAX|MEAN|MEDIAN|MIDRANGE|MIN|MOD|NUMVAL(?:-C)?|' + r'ORD(?:-MAX|-MIN)?|PI|PRESENT-VALUE|RANDOM|RANGE|REM|REVERSE|' + r'SECONDS-FROM-FORMATTED-TIME|SECONDS-PAST-MIDNIGHT|SIGN|SIN|SQRT|' + r'STANDARD-DEVIATION|STORED-CHAR-LENGTH|SUBSTITUTE(?:-CASE)?|' + r'SUM|TAN|TEST-DATE-YYYYMMDD|TEST-DAY-YYYYDDD|TRIM|' + r'UPPER-CASE|VARIANCE|WHEN-COMPILED|YEAR-TO-YYYY)\s*' + r'($|(?=[^\w\-]))', Name.Function), + + # Booleans + (r'(^|(?<=[^\w\-]))(true|false)\s*($|(?=[^\w\-]))', Name.Builtin), + # Comparing Operators + (r'(^|(?<=[^\w\-]))(equal|equals|ne|lt|le|gt|ge|' + r'greater|less|than|not|and|or)\s*($|(?=[^\w\-]))', Operator.Word), + ], + + # \"[^\"\n]*\"|\'[^\'\n]*\' + 'strings': [ + # apparently strings can be delimited by EOL if they are continued + # in the next line + (r'"[^"\n]*("|\n)', String.Double), + (r"'[^'\n]*('|\n)", String.Single), + ], + + 'nums': [ + (r'\d+(\s*|\.$|$)', Number.Integer), + (r'[+-]?\d*\.\d+(E[-+]?\d+)?', Number.Float), + (r'[+-]?\d+\.\d*(E[-+]?\d+)?', Number.Float), + ], + } + + +class CobolFreeformatLexer(CobolLexer): + """ + Lexer for Free format OpenCOBOL code. + """ + name = 'COBOLFree' + aliases = ['cobolfree'] + filenames = ['*.cbl', '*.CBL'] + mimetypes = [] + url = 'https://opencobol.add1tocobol.com' + version_added = '1.6' + + flags = re.IGNORECASE | re.MULTILINE + + tokens = { + 'comment': [ + (r'(\*>.*\n|^\w*\*.*$)', Comment), + ], + } + + +class ABAPLexer(RegexLexer): + """ + Lexer for ABAP, SAP's integrated language. + """ + name = 'ABAP' + aliases = ['abap'] + filenames = ['*.abap', '*.ABAP'] + mimetypes = ['text/x-abap'] + url = 'https://community.sap.com/topics/abap' + version_added = '1.1' + + flags = re.IGNORECASE | re.MULTILINE + + tokens = { + 'common': [ + (r'\s+', Whitespace), + (r'^\*.*$', Comment.Single), + (r'\".*?\n', Comment.Single), + (r'##\w+', Comment.Special), + ], + 'variable-names': [ + (r'<\S+>', Name.Variable), + (r'\w[\w~]*(?:(\[\])|->\*)?', Name.Variable), + ], + 'root': [ + include('common'), + # function calls + (r'CALL\s+(?:BADI|CUSTOMER-FUNCTION|FUNCTION)', + Keyword), + (r'(CALL\s+(?:DIALOG|SCREEN|SUBSCREEN|SELECTION-SCREEN|' + r'TRANSACTION|TRANSFORMATION))\b', + Keyword), + (r'(FORM|PERFORM)(\s+)(\w+)', + bygroups(Keyword, Whitespace, Name.Function)), + (r'(PERFORM)(\s+)(\()(\w+)(\))', + bygroups(Keyword, Whitespace, Punctuation, Name.Variable, Punctuation)), + (r'(MODULE)(\s+)(\S+)(\s+)(INPUT|OUTPUT)', + bygroups(Keyword, Whitespace, Name.Function, Whitespace, Keyword)), + + # method implementation + (r'(METHOD)(\s+)([\w~]+)', + bygroups(Keyword, Whitespace, Name.Function)), + # method calls + (r'(\s+)([\w\-]+)([=\-]>)([\w\-~]+)', + bygroups(Whitespace, Name.Variable, Operator, Name.Function)), + # call methodnames returning style + (r'(?<=[=-]>)([\w\-~]+)(?=\()', Name.Function), + + # text elements + (r'(TEXT)(-)(\d{3})', + bygroups(Keyword, Punctuation, Number.Integer)), + (r'(TEXT)(-)(\w{3})', + bygroups(Keyword, Punctuation, Name.Variable)), + + # keywords with dashes in them. + # these need to be first, because for instance the -ID part + # of MESSAGE-ID wouldn't get highlighted if MESSAGE was + # first in the list of keywords. + (r'(ADD-CORRESPONDING|AUTHORITY-CHECK|' + r'CLASS-DATA|CLASS-EVENTS|CLASS-METHODS|CLASS-POOL|' + r'DELETE-ADJACENT|DIVIDE-CORRESPONDING|' + r'EDITOR-CALL|ENHANCEMENT-POINT|ENHANCEMENT-SECTION|EXIT-COMMAND|' + r'FIELD-GROUPS|FIELD-SYMBOLS|FIELD-SYMBOL|FUNCTION-POOL|' + r'INTERFACE-POOL|INVERTED-DATE|' + r'LOAD-OF-PROGRAM|LOG-POINT|' + r'MESSAGE-ID|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|' + r'NEW-LINE|NEW-PAGE|NEW-SECTION|NO-EXTENSION|' + r'OUTPUT-LENGTH|PRINT-CONTROL|' + r'SELECT-OPTIONS|START-OF-SELECTION|SUBTRACT-CORRESPONDING|' + r'SYNTAX-CHECK|SYSTEM-EXCEPTIONS|' + r'TYPE-POOL|TYPE-POOLS|NO-DISPLAY' + r')\b', Keyword), + + # keyword kombinations + (r'(?])(CREATE\s+(PUBLIC|PRIVATE|DATA|OBJECT)|' + r'(PUBLIC|PRIVATE|PROTECTED)\s+SECTION|' + r'(TYPE|LIKE)\s+((LINE\s+OF|REF\s+TO|' + r'(SORTED|STANDARD|HASHED)\s+TABLE\s+OF))?|' + r'FROM\s+(DATABASE|MEMORY)|CALL\s+METHOD|' + r'(GROUP|ORDER) BY|HAVING|SEPARATED BY|' + r'GET\s+(BADI|BIT|CURSOR|DATASET|LOCALE|PARAMETER|' + r'PF-STATUS|(PROPERTY|REFERENCE)\s+OF|' + r'RUN\s+TIME|TIME\s+(STAMP)?)?|' + r'SET\s+(BIT|BLANK\s+LINES|COUNTRY|CURSOR|DATASET|EXTENDED\s+CHECK|' + r'HANDLER|HOLD\s+DATA|LANGUAGE|LEFT\s+SCROLL-BOUNDARY|' + r'LOCALE|MARGIN|PARAMETER|PF-STATUS|PROPERTY\s+OF|' + r'RUN\s+TIME\s+(ANALYZER|CLOCK\s+RESOLUTION)|SCREEN|' + r'TITLEBAR|UPADTE\s+TASK\s+LOCAL|USER-COMMAND)|' + r'CONVERT\s+((INVERTED-)?DATE|TIME|TIME\s+STAMP|TEXT)|' + r'(CLOSE|OPEN)\s+(DATASET|CURSOR)|' + r'(TO|FROM)\s+(DATA BUFFER|INTERNAL TABLE|MEMORY ID|' + r'DATABASE|SHARED\s+(MEMORY|BUFFER))|' + r'DESCRIBE\s+(DISTANCE\s+BETWEEN|FIELD|LIST|TABLE)|' + r'FREE\s(MEMORY|OBJECT)?|' + r'PROCESS\s+(BEFORE\s+OUTPUT|AFTER\s+INPUT|' + r'ON\s+(VALUE-REQUEST|HELP-REQUEST))|' + r'AT\s+(LINE-SELECTION|USER-COMMAND|END\s+OF|NEW)|' + r'AT\s+SELECTION-SCREEN(\s+(ON(\s+(BLOCK|(HELP|VALUE)-REQUEST\s+FOR|' + r'END\s+OF|RADIOBUTTON\s+GROUP))?|OUTPUT))?|' + r'SELECTION-SCREEN:?\s+((BEGIN|END)\s+OF\s+((TABBED\s+)?BLOCK|LINE|' + r'SCREEN)|COMMENT|FUNCTION\s+KEY|' + r'INCLUDE\s+BLOCKS|POSITION|PUSHBUTTON|' + r'SKIP|ULINE)|' + r'LEAVE\s+(LIST-PROCESSING|PROGRAM|SCREEN|' + r'TO LIST-PROCESSING|TO TRANSACTION)' + r'(ENDING|STARTING)\s+AT|' + r'FORMAT\s+(COLOR|INTENSIFIED|INVERSE|HOTSPOT|INPUT|FRAMES|RESET)|' + r'AS\s+(CHECKBOX|SUBSCREEN|WINDOW)|' + r'WITH\s+(((NON-)?UNIQUE)?\s+KEY|FRAME)|' + r'(BEGIN|END)\s+OF|' + r'DELETE(\s+ADJACENT\s+DUPLICATES\sFROM)?|' + r'COMPARING(\s+ALL\s+FIELDS)?|' + r'(INSERT|APPEND)(\s+INITIAL\s+LINE\s+(IN)?TO|\s+LINES\s+OF)?|' + r'IN\s+((BYTE|CHARACTER)\s+MODE|PROGRAM)|' + r'END-OF-(DEFINITION|PAGE|SELECTION)|' + r'WITH\s+FRAME(\s+TITLE)|' + r'(REPLACE|FIND)\s+((FIRST|ALL)\s+OCCURRENCES?\s+OF\s+)?(SUBSTRING|REGEX)?|' + r'MATCH\s+(LENGTH|COUNT|LINE|OFFSET)|' + r'(RESPECTING|IGNORING)\s+CASE|' + r'IN\s+UPDATE\s+TASK|' + r'(SOURCE|RESULT)\s+(XML)?|' + r'REFERENCE\s+INTO|' + + # simple kombinations + r'AND\s+(MARK|RETURN)|CLIENT\s+SPECIFIED|CORRESPONDING\s+FIELDS\s+OF|' + r'IF\s+FOUND|FOR\s+EVENT|INHERITING\s+FROM|LEAVE\s+TO\s+SCREEN|' + r'LOOP\s+AT\s+(SCREEN)?|LOWER\s+CASE|MATCHCODE\s+OBJECT|MODIF\s+ID|' + r'MODIFY\s+SCREEN|NESTING\s+LEVEL|NO\s+INTERVALS|OF\s+STRUCTURE|' + r'RADIOBUTTON\s+GROUP|RANGE\s+OF|REF\s+TO|SUPPRESS DIALOG|' + r'TABLE\s+OF|UPPER\s+CASE|TRANSPORTING\s+NO\s+FIELDS|' + r'VALUE\s+CHECK|VISIBLE\s+LENGTH|HEADER\s+LINE|COMMON\s+PART)\b', Keyword), + + # single word keywords. + (r'(^|(?<=(\s|\.)))(ABBREVIATED|ABSTRACT|ADD|ALIASES|ALIGN|ALPHA|' + r'ASSERT|AS|ASSIGN(ING)?|AT(\s+FIRST)?|' + r'BACK|BLOCK|BREAK-POINT|' + r'CASE|CAST|CATCH|CHANGING|CHECK|CLASS|CLEAR|COLLECT|COLOR|COMMIT|COND|CONV|' + r'CREATE|COMMUNICATION|COMPONENTS?|COMPUTE|CONCATENATE|CONDENSE|' + r'CONSTANTS|CONTEXTS|CONTINUE|CONTROLS|COUNTRY|CURRENCY|' + r'DATA|DATE|DECIMALS|DEFAULT|DEFINE|DEFINITION|DEFERRED|DEMAND|' + r'DETAIL|DIRECTORY|DIVIDE|DO|DUMMY|' + r'ELSE(IF)?|ENDAT|ENDCASE|ENDCATCH|ENDCLASS|ENDDO|ENDFORM|ENDFUNCTION|' + r'ENDIF|ENDINTERFACE|ENDLOOP|ENDMETHOD|ENDMODULE|ENDSELECT|ENDTRY|ENDWHILE|' + r'ENHANCEMENT|EVENTS|EXACT|EXCEPTIONS?|EXIT|EXPONENT|EXPORT|EXPORTING|EXTRACT|' + r'FETCH|FIELDS?|FOR|FORM|FORMAT|FREE|FROM|FUNCTION|' + r'HIDE|' + r'ID|IF|IMPORT|IMPLEMENTATION|IMPORTING|IN|INCLUDE|INCLUDING|' + r'INDEX|INFOTYPES|INITIALIZATION|INTERFACE|INTERFACES|INTO|' + r'LANGUAGE|LEAVE|LENGTH|LINES|LOAD|LOCAL|' + r'JOIN|' + r'KEY|' + r'NEW|NEXT|' + r'MAXIMUM|MESSAGE|METHOD[S]?|MINIMUM|MODULE|MODIFIER|MODIFY|MOVE|MULTIPLY|' + r'NODES|NUMBER|' + r'OBLIGATORY|OBJECT|OF|OFF|ON|OTHERS|OVERLAY|' + r'PACK|PAD|PARAMETERS|PERCENTAGE|POSITION|PROGRAM|PROVIDE|PUBLIC|PUT|PF\d\d|' + r'RAISE|RAISING|RANGES?|READ|RECEIVE|REDEFINITION|REFRESH|REJECT|REPORT|RESERVE|' + r'REF|RESUME|RETRY|RETURN|RETURNING|RIGHT|ROLLBACK|REPLACE|' + r'SCROLL|SEARCH|SELECT|SHIFT|SIGN|SINGLE|SIZE|SKIP|SORT|SPLIT|STATICS|STOP|' + r'STYLE|SUBMATCHES|SUBMIT|SUBTRACT|SUM(?!\()|SUMMARY|SUMMING|SUPPLY|SWITCH|' + r'TABLE|TABLES|TIMESTAMP|TIMES?|TIMEZONE|TITLE|\??TO|' + r'TOP-OF-PAGE|TRANSFER|TRANSLATE|TRY|TYPES|' + r'ULINE|UNDER|UNPACK|UPDATE|USING|' + r'VALUE|VALUES|VIA|VARYING|VARY|' + r'WAIT|WHEN|WHERE|WIDTH|WHILE|WITH|WINDOW|WRITE|XSD|ZERO)\b', Keyword), + + # builtins + (r'(abs|acos|asin|atan|' + r'boolc|boolx|bit_set|' + r'char_off|charlen|ceil|cmax|cmin|condense|contains|' + r'contains_any_of|contains_any_not_of|concat_lines_of|cos|cosh|' + r'count|count_any_of|count_any_not_of|' + r'dbmaxlen|distance|' + r'escape|exp|' + r'find|find_end|find_any_of|find_any_not_of|floor|frac|from_mixed|' + r'insert|' + r'lines|log|log10|' + r'match|matches|' + r'nmax|nmin|numofchar|' + r'repeat|replace|rescale|reverse|round|' + r'segment|shift_left|shift_right|sign|sin|sinh|sqrt|strlen|' + r'substring|substring_after|substring_from|substring_before|substring_to|' + r'tan|tanh|to_upper|to_lower|to_mixed|translate|trunc|' + r'xstrlen)(\()\b', bygroups(Name.Builtin, Punctuation)), + + (r'&[0-9]', Name), + (r'[0-9]+', Number.Integer), + + # operators which look like variable names before + # parsing variable names. + (r'(?<=(\s|.))(AND|OR|EQ|NE|GT|LT|GE|LE|CO|CN|CA|NA|CS|NOT|NS|CP|NP|' + r'BYTE-CO|BYTE-CN|BYTE-CA|BYTE-NA|BYTE-CS|BYTE-NS|' + r'IS\s+(NOT\s+)?(INITIAL|ASSIGNED|REQUESTED|BOUND))\b', Operator.Word), + + include('variable-names'), + + # standard operators after variable names, + # because < and > are part of field symbols. + (r'[?*<>=\-+&]', Operator), + (r"'(''|[^'])*'", String.Single), + (r"`([^`])*`", String.Single), + (r"([|}])([^{}|]*?)([|{])", + bygroups(Punctuation, String.Single, Punctuation)), + (r'[/;:()\[\],.]', Punctuation), + (r'(!)(\w+)', bygroups(Operator, Name)), + ], + } + + +class OpenEdgeLexer(RegexLexer): + """ + Lexer for OpenEdge ABL (formerly Progress) source code. + """ + name = 'OpenEdge ABL' + aliases = ['openedge', 'abl', 'progress'] + filenames = ['*.p', '*.cls'] + mimetypes = ['text/x-openedge', 'application/x-openedge'] + url = 'https://www.progress.com/openedge/features/abl' + version_added = '1.5' + + types = (r'(?i)(^|(?<=[^\w\-]))(CHARACTER|CHAR|CHARA|CHARAC|CHARACT|CHARACTE|' + r'COM-HANDLE|DATE|DATETIME|DATETIME-TZ|' + r'DECIMAL|DEC|DECI|DECIM|DECIMA|HANDLE|' + r'INT64|INTEGER|INT|INTE|INTEG|INTEGE|' + r'LOGICAL|LONGCHAR|MEMPTR|RAW|RECID|ROWID)\s*($|(?=[^\w\-]))') + + keywords = words(OPENEDGEKEYWORDS, + prefix=r'(?i)(^|(?<=[^\w\-]))', + suffix=r'\s*($|(?=[^\w\-]))') + + tokens = { + 'root': [ + (r'/\*', Comment.Multiline, 'comment'), + (r'\{', Comment.Preproc, 'preprocessor'), + (r'\s*&.*', Comment.Preproc), + (r'0[xX][0-9a-fA-F]+[LlUu]*', Number.Hex), + (r'(?i)(DEFINE|DEF|DEFI|DEFIN)\b', Keyword.Declaration), + (types, Keyword.Type), + (keywords, Name.Builtin), + (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), + (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single), + (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), + (r'[0-9]+', Number.Integer), + (r'\s+', Whitespace), + (r'[+*/=-]', Operator), + (r'[.:()]', Punctuation), + (r'.', Name.Variable), # Lazy catch-all + ], + 'comment': [ + (r'[^*/]', Comment.Multiline), + (r'/\*', Comment.Multiline, '#push'), + (r'\*/', Comment.Multiline, '#pop'), + (r'[*/]', Comment.Multiline) + ], + 'preprocessor': [ + (r'[^{}]', Comment.Preproc), + (r'\{', Comment.Preproc, '#push'), + (r'\}', Comment.Preproc, '#pop'), + ], + } + + def analyse_text(text): + """Try to identify OpenEdge ABL based on a few common constructs.""" + result = 0 + + if 'END.' in text: + result += 0.05 + + if 'END PROCEDURE.' in text: + result += 0.05 + + if 'ELSE DO:' in text: + result += 0.05 + + return result + + +class GoodDataCLLexer(RegexLexer): + """ + Lexer for GoodData-CL script files. + """ + + name = 'GoodData-CL' + aliases = ['gooddata-cl'] + filenames = ['*.gdc'] + mimetypes = ['text/x-gooddata-cl'] + url = 'https://github.com/gooddata/GoodData-CL' + version_added = '1.4' + + flags = re.IGNORECASE + + # Syntax: + # https://github.com/gooddata/GoodData-CL/raw/master/cli/src/main/resources/com/gooddata/processor/COMMANDS.txt + tokens = { + 'root': [ + # Comments + (r'#.*', Comment.Single), + # Function call + (r'[a-z]\w*', Name.Function), + # Argument list + (r'\(', Punctuation, 'args-list'), + # Punctuation + (r';', Punctuation), + # Space is not significant + (r'\s+', Text) + ], + 'args-list': [ + (r'\)', Punctuation, '#pop'), + (r',', Punctuation), + (r'[a-z]\w*', Name.Variable), + (r'=', Operator), + (r'"', String, 'string-literal'), + (r'[0-9]+(?:\.[0-9]+)?(?:e[+-]?[0-9]{1,3})?', Number), + # Space is not significant + (r'\s', Whitespace) + ], + 'string-literal': [ + (r'\\[tnrfbae"\\]', String.Escape), + (r'"', String, '#pop'), + (r'[^\\"]+', String) + ] + } + + +class MaqlLexer(RegexLexer): + """ + Lexer for GoodData MAQL scripts. + """ + + name = 'MAQL' + aliases = ['maql'] + filenames = ['*.maql'] + mimetypes = ['text/x-gooddata-maql', 'application/x-gooddata-maql'] + url = 'https://help.gooddata.com/doc/enterprise/en/dashboards-and-insights/maql-analytical-query-language' + version_added = '1.4' + + flags = re.IGNORECASE + tokens = { + 'root': [ + # IDENTITY + (r'IDENTIFIER\b', Name.Builtin), + # IDENTIFIER + (r'\{[^}]+\}', Name.Variable), + # NUMBER + (r'[0-9]+(?:\.[0-9]+)?(?:e[+-]?[0-9]{1,3})?', Number), + # STRING + (r'"', String, 'string-literal'), + # RELATION + (r'\<\>|\!\=', Operator), + (r'\=|\>\=|\>|\<\=|\<', Operator), + # := + (r'\:\=', Operator), + # OBJECT + (r'\[[^]]+\]', Name.Variable.Class), + # keywords + (words(( + 'DIMENSION', 'DIMENSIONS', 'BOTTOM', 'METRIC', 'COUNT', 'OTHER', + 'FACT', 'WITH', 'TOP', 'OR', 'ATTRIBUTE', 'CREATE', 'PARENT', + 'FALSE', 'ROW', 'ROWS', 'FROM', 'ALL', 'AS', 'PF', 'COLUMN', + 'COLUMNS', 'DEFINE', 'REPORT', 'LIMIT', 'TABLE', 'LIKE', 'AND', + 'BY', 'BETWEEN', 'EXCEPT', 'SELECT', 'MATCH', 'WHERE', 'TRUE', + 'FOR', 'IN', 'WITHOUT', 'FILTER', 'ALIAS', 'WHEN', 'NOT', 'ON', + 'KEYS', 'KEY', 'FULLSET', 'PRIMARY', 'LABELS', 'LABEL', + 'VISUAL', 'TITLE', 'DESCRIPTION', 'FOLDER', 'ALTER', 'DROP', + 'ADD', 'DATASET', 'DATATYPE', 'INT', 'BIGINT', 'DOUBLE', 'DATE', + 'VARCHAR', 'DECIMAL', 'SYNCHRONIZE', 'TYPE', 'DEFAULT', 'ORDER', + 'ASC', 'DESC', 'HYPERLINK', 'INCLUDE', 'TEMPLATE', 'MODIFY'), + suffix=r'\b'), + Keyword), + # FUNCNAME + (r'[a-z]\w*\b', Name.Function), + # Comments + (r'#.*', Comment.Single), + # Punctuation + (r'[,;()]', Punctuation), + # Space is not significant + (r'\s+', Whitespace) + ], + 'string-literal': [ + (r'\\[tnrfbae"\\]', String.Escape), + (r'"', String, '#pop'), + (r'[^\\"]+', String) + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/c_cpp.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/c_cpp.py new file mode 100644 index 0000000000000000000000000000000000000000..136448022df1510c5b5efd396269311b2fc1a9e8 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/c_cpp.py @@ -0,0 +1,481 @@ +""" + pygments.lexers.c_cpp + ~~~~~~~~~~~~~~~~~~~~~ + + Lexers for C/C++ languages. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, include, bygroups, using, \ + this, inherit, default, words +from pygments.util import get_bool_opt +from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace + +__all__ = ['CLexer', 'CppLexer'] + + +class CFamilyLexer(RegexLexer): + """ + For C family source code. This is used as a base class to avoid repetitious + definitions. + """ + + # The trailing ?, rather than *, avoids a geometric performance drop here. + #: only one /* */ style comment + _ws1 = r'\s*(?:/[*].*?[*]/\s*)?' + + # Hexadecimal part in an hexadecimal integer/floating-point literal. + # This includes decimal separators matching. + _hexpart = r'[0-9a-fA-F](\'?[0-9a-fA-F])*' + # Decimal part in an decimal integer/floating-point literal. + # This includes decimal separators matching. + _decpart = r'\d(\'?\d)*' + # Integer literal suffix (e.g. 'ull' or 'll'). + _intsuffix = r'(([uU]?[zZ])|([zZ][uU])|([uU][lL]{0,2})|([lL]{1,2}[uU]?))?' + + # Identifier regex with C and C++ Universal Character Name (UCN) support. + _ident = r'(?!\d)(?:[\w$]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8})+' + _namespaced_ident = r'(?!\d)(?:[\w$]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|::)+' + + # Single and multiline comment regexes + # Beware not to use *? for the inner content! When these regexes + # are embedded in larger regexes, that can cause the stuff*? to + # match more than it would have if the regex had been used in + # a standalone way ... + _comment_single = r'//(?:.|(?<=\\)\n)*\n' + _comment_multiline = r'/(?:\\\n)?[*](?:[^*]|[*](?!(?:\\\n)?/))*[*](?:\\\n)?/' + + # Regex to match optional comments + _possible_comments = rf'\s*(?:(?:(?:{_comment_single})|(?:{_comment_multiline}))\s*)*' + + tokens = { + 'whitespace': [ + # preprocessor directives: without whitespace + (r'^#if\s+0', Comment.Preproc, 'if0'), + ('^#', Comment.Preproc, 'macro'), + # or with whitespace + ('^(' + _ws1 + r')(#if\s+0)', + bygroups(using(this), Comment.Preproc), 'if0'), + ('^(' + _ws1 + ')(#)', + bygroups(using(this), Comment.Preproc), 'macro'), + # Labels: + # Line start and possible indentation. + (r'(^[ \t]*)' + # Not followed by keywords which can be mistaken as labels. + r'(?!(?:public|private|protected|default)\b)' + # Actual label, followed by a single colon. + r'(' + _ident + r')(\s*)(:)(?!:)', + bygroups(Whitespace, Name.Label, Whitespace, Punctuation)), + (r'\n', Whitespace), + (r'[^\S\n]+', Whitespace), + (r'\\\n', Text), # line continuation + (_comment_single, Comment.Single), + (_comment_multiline, Comment.Multiline), + # Open until EOF, so no ending delimiter + (r'/(\\\n)?[*][\w\W]*', Comment.Multiline), + ], + 'statements': [ + include('keywords'), + include('types'), + (r'([LuU]|u8)?(")', bygroups(String.Affix, String), 'string'), + (r"([LuU]|u8)?(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')", + bygroups(String.Affix, String.Char, String.Char, String.Char)), + + # Hexadecimal floating-point literals (C11, C++17) + (r'0[xX](' + _hexpart + r'\.' + _hexpart + r'|\.' + _hexpart + + r'|' + _hexpart + r')[pP][+-]?' + _hexpart + r'[lL]?', Number.Float), + + (r'(-)?(' + _decpart + r'\.' + _decpart + r'|\.' + _decpart + r'|' + + _decpart + r')[eE][+-]?' + _decpart + r'[fFlL]?', Number.Float), + (r'(-)?((' + _decpart + r'\.(' + _decpart + r')?|\.' + + _decpart + r')[fFlL]?)|(' + _decpart + r'[fFlL])', Number.Float), + (r'(-)?0[xX]' + _hexpart + _intsuffix, Number.Hex), + (r'(-)?0[bB][01](\'?[01])*' + _intsuffix, Number.Bin), + (r'(-)?0(\'?[0-7])+' + _intsuffix, Number.Oct), + (r'(-)?' + _decpart + _intsuffix, Number.Integer), + (r'[~!%^&*+=|?:<>/-]', Operator), + (r'[()\[\],.]', Punctuation), + (r'(true|false|NULL|nullptr)\b', Name.Builtin), + (_ident, Name) + ], + 'types': [ + (words(('int8', 'int16', 'int32', 'int64', 'wchar_t'), prefix=r'__', + suffix=r'\b'), Keyword.Reserved), + (words(('bool', 'int', 'long', 'float', 'short', 'double', 'char', + 'unsigned', 'signed', 'void', '_BitInt', + '__int128'), suffix=r'\b'), Keyword.Type) + ], + 'keywords': [ + (r'(struct|union)(\s+)', bygroups(Keyword, Whitespace), 'classname'), + (r'case\b', Keyword, 'case-value'), + (words(('asm', 'auto', 'break', 'const', 'constexpr', 'continue', 'countof', 'default', + 'defer', 'do', 'else', 'enum', 'extern', 'for', 'goto', 'if', 'register', + 'restricted', 'return', 'sizeof', 'struct', 'static', 'switch', + 'typedef', 'typeof', 'typeof_unqual', 'volatile', 'while', 'union', + 'thread_local', 'alignas', 'alignof', 'static_assert', '_Pragma', 'fortran'), + suffix=r'\b'), Keyword), + (words(('inline', '_inline', '__inline', 'naked', 'restrict', + 'thread'), suffix=r'\b'), Keyword.Reserved), + # Vector intrinsics + (r'(__m(128i|128d|128|64))\b', Keyword.Reserved), + # Microsoft-isms + (words(( + 'asm', 'based', 'except', 'stdcall', 'cdecl', + 'fastcall', 'declspec', 'finally', 'try', + 'leave', 'w64', 'unaligned', 'raise', 'noop', + 'identifier', 'forceinline', 'assume', 'null'), + prefix=r'__', suffix=r'\b'), Keyword.Reserved) + ], + 'root': [ + include('whitespace'), + include('keywords'), + # functions + (r'(' + _namespaced_ident + r'(?:[&*\s])+)' # return arguments + r'(' + _possible_comments + r')' + r'(' + _namespaced_ident + r')' # method name + r'(' + _possible_comments + r')' + r'(\([^;"\')]*?\))' # signature + r'(' + _possible_comments + r')' + r'([^;{/"\']*)(\{)', + bygroups(using(this), using(this, state='whitespace'), + Name.Function, using(this, state='whitespace'), + using(this), using(this, state='whitespace'), + using(this), Punctuation), + 'function'), + # function declarations + (r'(' + _namespaced_ident + r'(?:[&*\s])+)' # return arguments + r'(' + _possible_comments + r')' + r'(' + _namespaced_ident + r')' # method name + r'(' + _possible_comments + r')' + r'(\([^;"\')]*?\))' # signature + r'(' + _possible_comments + r')' + r'([^;/"\']*)(;)', + bygroups(using(this), using(this, state='whitespace'), + Name.Function, using(this, state='whitespace'), + using(this), using(this, state='whitespace'), + using(this), Punctuation)), + include('types'), + default('statement'), + ], + 'statement': [ + include('whitespace'), + include('statements'), + (r'\}', Punctuation), + (r'[{;]', Punctuation, '#pop'), + ], + 'function': [ + include('whitespace'), + include('statements'), + (';', Punctuation), + (r'\{', Punctuation, '#push'), + (r'\}', Punctuation, '#pop'), + ], + 'string': [ + (r'"', String, '#pop'), + (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|' + r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape), + (r'[^\\"\n]+', String), # all other characters + (r'\\\n', String), # line continuation + (r'\\', String), # stray backslash + ], + 'macro': [ + (r'('+_ws1+r')(include)('+_ws1+r')("[^"]+"|<[^>]+>)([^\S\n]*)([^/\n]*/[*][\s\S]*?[*]/)', + bygroups(using(this), Comment.Preproc, using(this), + Comment.PreprocFile, using(this), Comment.Multiline)), + (r'('+_ws1+r')(include)('+_ws1+r')("[^"]+"|<[^>]+>)([^\S\n]*)([^\n]*)', + bygroups(using(this), Comment.Preproc, using(this), + Comment.PreprocFile, using(this), Comment.Single)), + (r'[^/\n]+', Comment.Preproc), + (r'/[*][\s\S]*?[*]/', Comment.Multiline), + (r'//.*?\n', Comment.Single, '#pop'), + (r'/', Comment.Preproc), + (r'(?<=\\)\n', Comment.Preproc), + (r'\n', Comment.Preproc, '#pop'), + ], + 'if0': [ + (r'^\s*#if.*?(?)', Text, '#pop'), + default('#pop') + ], + # Mark identifiers preceded by `case` keyword as constants. + 'case-value': [ + (r'(?)', Text, '#pop'), + default('#pop') + ], + 'enumname': [ + include('whitespace'), + # 'enum class' and 'enum struct' C++11 support + (words(('class', 'struct'), suffix=r'\b'), Keyword), + # C++26 annotations before enum name + (r'(\[\[)(=)(' + CFamilyLexer._ident + r')', + bygroups(Punctuation, Punctuation, Name.Decorator), 'annotation'), + # C++ attributes before enum name + (r'\[\[(?=[^\[\]]*\]\])', Punctuation, 'attribute'), + (CFamilyLexer._ident, Name.Class, '#pop'), + # template specification + (r'\s*(?=>)', Text, '#pop'), + default('#pop') + ], + 'attribute': [ + (r'using\b', Keyword), + (r':', Punctuation), + inherit, + ], + 'keywords': [ + (r'(class|concept|typename)(\s+)', bygroups(Keyword, Whitespace), 'classname'), + (words(( + 'catch', 'const_cast', 'delete', 'dynamic_cast', 'explicit', + 'export', 'friend', 'mutable', 'new', 'operator', + 'private', 'protected', 'public', 'reinterpret_cast', 'class', + '__restrict', 'static_cast', 'template', 'this', 'throw', 'throws', + 'try', 'typeid', 'using', 'virtual', 'concept', + 'decltype', 'noexcept', 'override', 'final', 'constinit', 'consteval', + 'co_await', 'co_return', 'co_yield', 'requires', 'import', 'module', + 'typename', 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not', + 'not_eq', 'or', 'or_eq', 'xor', 'xor_eq', 'contract_assert', 'pre', 'post'), + suffix=r'\b'), Keyword), + (r'namespace\b', Keyword, 'namespace'), + (r'(enum)(\s+)', bygroups(Keyword, Whitespace), 'enumname'), + inherit + ], + 'types': [ + (r'char(16_t|32_t|8_t)\b', Keyword.Type), + inherit + ], + 'namespace': [ + (r';', Punctuation, ('#pop', 'root')), + (r'\{', Punctuation, ('#pop', 'namespace-body')), + (r'inline\b', Keyword.Reserved), + (CFamilyLexer._ident, Name.Namespace), + include('statement') + ], + 'namespace-body': [ + (r'\}', Punctuation, '#pop'), + include('root'), + ], + 'annotation': [ + (r'\]\]', Punctuation, '#pop'), + (r'\(', Punctuation, 'annotation-args'), + (r'::', Punctuation), + (r',', Punctuation), + (CFamilyLexer._ident, Name.Decorator), + include('whitespace'), + ], + 'annotation-args': [ + (r'\)', Punctuation, '#pop'), + (r'\(', Punctuation, '#push'), + include('statements'), + ], + } + + def analyse_text(text): + if re.search('#include <[a-z_]+>', text): + return 0.2 + if re.search('using namespace ', text): + return 0.4 diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/c_like.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/c_like.py new file mode 100644 index 0000000000000000000000000000000000000000..a5f991cb27e5fba8d4d26686efd0e113682e8f01 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/c_like.py @@ -0,0 +1,743 @@ +""" + pygments.lexers.c_like + ~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for other C-like languages. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, include, bygroups, inherit, words, \ + default +from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace + +from pygments.lexers.c_cpp import CLexer, CppLexer +from pygments.lexers import _mql_builtins + +__all__ = ['PikeLexer', 'NesCLexer', 'ClayLexer', 'ECLexer', 'ValaLexer', + 'CudaLexer', 'SwigLexer', 'MqlLexer', 'ArduinoLexer', 'CharmciLexer', + 'OmgIdlLexer', 'PromelaLexer'] + + +class PikeLexer(CppLexer): + """ + For `Pike `_ source code. + """ + name = 'Pike' + aliases = ['pike'] + filenames = ['*.pike', '*.pmod'] + mimetypes = ['text/x-pike'] + version_added = '2.0' + + tokens = { + 'statements': [ + (words(( + 'catch', 'new', 'private', 'protected', 'public', 'gauge', + 'throw', 'throws', 'class', 'interface', 'implement', 'abstract', + 'extends', 'from', 'this', 'super', 'constant', 'final', 'static', + 'import', 'use', 'extern', 'inline', 'proto', 'break', 'continue', + 'if', 'else', 'for', 'while', 'do', 'switch', 'case', 'as', 'in', + 'version', 'return', 'true', 'false', 'null', + '__VERSION__', '__MAJOR__', '__MINOR__', '__BUILD__', '__REAL_VERSION__', + '__REAL_MAJOR__', '__REAL_MINOR__', '__REAL_BUILD__', '__DATE__', '__TIME__', + '__FILE__', '__DIR__', '__LINE__', '__AUTO_BIGNUM__', '__NT__', '__PIKE__', + '__amigaos__', '_Pragma', 'static_assert', 'defined', 'sscanf'), suffix=r'\b'), + Keyword), + (r'(bool|int|long|float|short|double|char|string|object|void|mapping|' + r'array|multiset|program|function|lambda|mixed|' + r'[a-z_][a-z0-9_]*_t)\b', + Keyword.Type), + (r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'), + (r'[~!%^&*+=|?:<>/@-]', Operator), + inherit, + ], + 'classname': [ + (r'[a-zA-Z_]\w*', Name.Class, '#pop'), + # template specification + (r'\s*(?=>)', Whitespace, '#pop'), + ], + } + + +class NesCLexer(CLexer): + """ + For `nesC `_ source code with preprocessor + directives. + """ + name = 'nesC' + aliases = ['nesc'] + filenames = ['*.nc'] + mimetypes = ['text/x-nescsrc'] + version_added = '2.0' + + tokens = { + 'statements': [ + (words(( + 'abstract', 'as', 'async', 'atomic', 'call', 'command', 'component', + 'components', 'configuration', 'event', 'extends', 'generic', + 'implementation', 'includes', 'interface', 'module', 'new', 'norace', + 'post', 'provides', 'signal', 'task', 'uses'), suffix=r'\b'), + Keyword), + (words(('nx_struct', 'nx_union', 'nx_int8_t', 'nx_int16_t', 'nx_int32_t', + 'nx_int64_t', 'nx_uint8_t', 'nx_uint16_t', 'nx_uint32_t', + 'nx_uint64_t'), suffix=r'\b'), + Keyword.Type), + inherit, + ], + } + + +class ClayLexer(RegexLexer): + """ + For Clay source. + """ + name = 'Clay' + filenames = ['*.clay'] + aliases = ['clay'] + mimetypes = ['text/x-clay'] + url = 'http://claylabs.com/clay' + version_added = '2.0' + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'//.*?$', Comment.Single), + (r'/(\\\n)?[*][\s\S]*?[*](\\\n)?/', Comment.Multiline), + (words(('public', 'private', 'import', 'as', 'record', 'variant', + 'instance', 'define', 'overload', 'default', + 'external', 'alias', 'rvalue', 'ref', + 'forward', 'inline', 'noinline', + 'forceinline', 'enum', 'var', 'and', 'or', + 'not', 'if', 'else', 'goto', 'return', + 'while', 'switch', 'case', 'break', + 'continue', 'for', 'in', 'true', 'false', + 'try', 'catch', 'throw', 'finally', + 'onerror', 'staticassert', 'eval', 'when', + 'newtype', '__FILE__', '__LINE__', + '__COLUMN__', '__ARG__'), prefix=r'\b', suffix=r'\b'), Keyword), + (r'[~!%^&*+=|:<>/-]', Operator), + (r'[#(){}\[\],;.]', Punctuation), + (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex), + (r'\d+[LlUu]*', Number.Integer), + (r'\b(true|false)\b', Name.Builtin), + (r'(?i)[a-z_?][\w?]*', Name), + (r'"""', String, 'tdqs'), + (r'"', String, 'dqs'), + ], + 'strings': [ + (r'(?i)\\(x[0-9a-f]{2}|.)', String.Escape), + (r'[^\\"]+', String), + ], + 'nl': [ + (r'\n', String), + ], + 'dqs': [ + (r'"', String, '#pop'), + include('strings'), + ], + 'tdqs': [ + (r'"""', String, '#pop'), + include('strings'), + include('nl'), + ], + } + + +class ECLexer(CLexer): + """ + For eC source code with preprocessor directives. + """ + name = 'eC' + aliases = ['ec'] + filenames = ['*.ec', '*.eh'] + mimetypes = ['text/x-echdr', 'text/x-ecsrc'] + url = 'https://ec-lang.org' + version_added = '1.5' + + tokens = { + 'statements': [ + (words(( + 'virtual', 'class', 'private', 'public', 'property', 'import', + 'delete', 'new', 'new0', 'renew', 'renew0', 'define', 'get', + 'set', 'remote', 'dllexport', 'dllimport', 'stdcall', 'subclass', + '__on_register_module', 'namespace', 'using', 'typed_object', + 'any_object', 'incref', 'register', 'watch', 'stopwatching', 'firewatchers', + 'watchable', 'class_designer', 'class_fixed', 'class_no_expansion', 'isset', + 'class_default_property', 'property_category', 'class_data', + 'class_property', 'thisclass', 'dbtable', 'dbindex', + 'database_open', 'dbfield'), suffix=r'\b'), Keyword), + (words(('uint', 'uint16', 'uint32', 'uint64', 'bool', 'byte', + 'unichar', 'int64'), suffix=r'\b'), + Keyword.Type), + (r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'), + (r'(null|value|this)\b', Name.Builtin), + inherit, + ] + } + + +class ValaLexer(RegexLexer): + """ + For Vala source code with preprocessor directives. + """ + name = 'Vala' + aliases = ['vala', 'vapi'] + filenames = ['*.vala', '*.vapi'] + mimetypes = ['text/x-vala'] + url = 'https://vala.dev' + version_added = '1.1' + + tokens = { + 'whitespace': [ + (r'^\s*#if\s+0', Comment.Preproc, 'if0'), + (r'^\s*#(?:if|elif|else|endif)\b[^\n]*', Comment.Preproc), + (r'\n', Whitespace), + (r'\s+', Whitespace), + (r'\\\n', Text), # line continuation + (r'//(\n|[\s\S]*?[^\\]\n)', Comment.Single), + (r'/(\\\n)?[*][\s\S]*?[*](\\\n)?/', Comment.Multiline), + ], + 'statements': [ + (r'(?s)""".*?"""', String), # verbatim strings + (r'[L@]?"', String, 'string'), + (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", + String.Char), + (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float), + (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float), + (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex), + (r'0[0-7]+[Ll]?', Number.Oct), + (r'\d+[Ll]?', Number.Integer), + (r'[~!%^&*+=|?:<>/-]', Operator), + (r'(\[)(Compact|Immutable|(?:Boolean|Simple)Type)(\])', + bygroups(Punctuation, Name.Decorator, Punctuation)), + # TODO: "correctly" parse complex code attributes + (r'(\[)(CCode|(?:Integer|Floating)Type)', + bygroups(Punctuation, Name.Decorator)), + (r'[()\[\],.]', Punctuation), + (words(( + 'as', 'base', 'break', 'case', 'catch', 'construct', 'continue', + 'default', 'delete', 'do', 'else', 'enum', 'finally', 'for', + 'foreach', 'get', 'if', 'in', 'is', 'lock', 'new', 'out', 'params', + 'return', 'set', 'sizeof', 'switch', 'this', 'throw', 'try', + 'typeof', 'while', 'yield'), suffix=r'\b'), + Keyword), + (words(( + 'abstract', 'const', 'delegate', 'dynamic', 'ensures', 'extern', + 'inline', 'internal', 'override', 'owned', 'private', 'protected', + 'public', 'ref', 'requires', 'signal', 'static', 'throws', 'unowned', + 'var', 'virtual', 'volatile', 'weak', 'yields'), suffix=r'\b'), + Keyword.Declaration), + (r'(namespace|using)(\s+)', bygroups(Keyword.Namespace, Whitespace), + 'namespace'), + (r'(class|errordomain|interface|struct)(\s+)', + bygroups(Keyword.Declaration, Whitespace), 'class'), + (r'(\.)([a-zA-Z_]\w*)', + bygroups(Operator, Name.Attribute)), + # void is an actual keyword, others are in glib-2.0.vapi + (words(( + 'void', 'bool', 'char', 'double', 'float', 'int', 'int8', 'int16', + 'int32', 'int64', 'long', 'short', 'size_t', 'ssize_t', 'string', + 'time_t', 'uchar', 'uint', 'uint8', 'uint16', 'uint32', 'uint64', + 'ulong', 'unichar', 'ushort'), suffix=r'\b'), + Keyword.Type), + (r'(true|false|null)\b', Name.Builtin), + (r'[a-zA-Z_]\w*', Name), + ], + 'root': [ + include('whitespace'), + default('statement'), + ], + 'statement': [ + include('whitespace'), + include('statements'), + ('[{}]', Punctuation), + (';', Punctuation, '#pop'), + ], + 'string': [ + (r'"', String, '#pop'), + (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape), + (r'[^\\"\n]+', String), # all other characters + (r'\\\n', String), # line continuation + (r'\\', String), # stray backslash + ], + 'if0': [ + (r'^\s*#if.*?(?>>'} + + def get_tokens_unprocessed(self, text, stack=('root',)): + for index, token, value in CppLexer.get_tokens_unprocessed(self, text, stack): + if token is Name: + if value in self.variable_qualifiers: + token = Keyword.Type + elif value in self.vector_types: + token = Keyword.Type + elif value in self.variables: + token = Name.Builtin + elif value in self.execution_confs: + token = Keyword.Pseudo + elif value in self.function_qualifiers: + token = Keyword.Reserved + elif value in self.functions: + token = Name.Function + yield index, token, value + + +class SwigLexer(CppLexer): + """ + For `SWIG `_ source code. + """ + name = 'SWIG' + aliases = ['swig'] + filenames = ['*.swg', '*.i'] + mimetypes = ['text/swig'] + version_added = '2.0' + priority = 0.04 # Lower than C/C++ and Objective C/C++ + + tokens = { + 'root': [ + # Match it here so it won't be matched as a function in the rest of root + (r'\$\**\&?\w+', Name), + inherit + ], + 'statements': [ + # SWIG directives + (r'(%[a-z_][a-z0-9_]*)', Name.Function), + # Special variables + (r'\$\**\&?\w+', Name), + # Stringification / additional preprocessor directives + (r'##*[a-zA-Z_]\w*', Comment.Preproc), + inherit, + ], + } + + # This is a far from complete set of SWIG directives + swig_directives = { + # Most common directives + '%apply', '%define', '%director', '%enddef', '%exception', '%extend', + '%feature', '%fragment', '%ignore', '%immutable', '%import', '%include', + '%inline', '%insert', '%module', '%newobject', '%nspace', '%pragma', + '%rename', '%shared_ptr', '%template', '%typecheck', '%typemap', + # Less common directives + '%arg', '%attribute', '%bang', '%begin', '%callback', '%catches', '%clear', + '%constant', '%copyctor', '%csconst', '%csconstvalue', '%csenum', + '%csmethodmodifiers', '%csnothrowexception', '%default', '%defaultctor', + '%defaultdtor', '%defined', '%delete', '%delobject', '%descriptor', + '%exceptionclass', '%exceptionvar', '%extend_smart_pointer', '%fragments', + '%header', '%ifcplusplus', '%ignorewarn', '%implicit', '%implicitconv', + '%init', '%javaconst', '%javaconstvalue', '%javaenum', '%javaexception', + '%javamethodmodifiers', '%kwargs', '%luacode', '%mutable', '%naturalvar', + '%nestedworkaround', '%perlcode', '%pythonabc', '%pythonappend', + '%pythoncallback', '%pythoncode', '%pythondynamic', '%pythonmaybecall', + '%pythonnondynamic', '%pythonprepend', '%refobject', '%shadow', '%sizeof', + '%trackobjects', '%types', '%unrefobject', '%varargs', '%warn', + '%warnfilter'} + + def analyse_text(text): + rv = 0 + # Search for SWIG directives, which are conventionally at the beginning of + # a line. The probability of them being within a line is low, so let another + # lexer win in this case. + matches = re.findall(r'^\s*(%[a-z_][a-z0-9_]*)', text, re.M) + for m in matches: + if m in SwigLexer.swig_directives: + rv = 0.98 + break + else: + rv = 0.91 # Fraction higher than MatlabLexer + return rv + + +class MqlLexer(CppLexer): + """ + For `MQL4 `_ and + `MQL5 `_ source code. + """ + name = 'MQL' + aliases = ['mql', 'mq4', 'mq5', 'mql4', 'mql5'] + filenames = ['*.mq4', '*.mq5', '*.mqh'] + mimetypes = ['text/x-mql'] + version_added = '2.0' + + tokens = { + 'statements': [ + (words(_mql_builtins.keywords, suffix=r'\b'), Keyword), + (words(_mql_builtins.c_types, suffix=r'\b'), Keyword.Type), + (words(_mql_builtins.types, suffix=r'\b'), Name.Function), + (words(_mql_builtins.constants, suffix=r'\b'), Name.Constant), + (words(_mql_builtins.colors, prefix='(clr)?', suffix=r'\b'), + Name.Constant), + inherit, + ], + } + + +class ArduinoLexer(CppLexer): + """ + For `Arduino(tm) `_ source. + + This is an extension of the CppLexer, as the Arduino® Language is a superset + of C++ + """ + + name = 'Arduino' + aliases = ['arduino'] + filenames = ['*.ino'] + mimetypes = ['text/x-arduino'] + version_added = '2.1' + + # Language sketch main structure functions + structure = {'setup', 'loop'} + + # Language operators + operators = {'not', 'or', 'and', 'xor'} + + # Language 'variables' + variables = { + 'DIGITAL_MESSAGE', 'FIRMATA_STRING', 'ANALOG_MESSAGE', 'REPORT_DIGITAL', + 'REPORT_ANALOG', 'INPUT_PULLUP', 'SET_PIN_MODE', 'INTERNAL2V56', 'SYSTEM_RESET', + 'LED_BUILTIN', 'INTERNAL1V1', 'SYSEX_START', 'INTERNAL', 'EXTERNAL', 'HIGH', + 'LOW', 'INPUT', 'OUTPUT', 'INPUT_PULLUP', 'LED_BUILTIN', 'true', 'false', + 'void', 'boolean', 'char', 'unsigned char', 'byte', 'int', 'unsigned int', + 'word', 'long', 'unsigned long', 'short', 'float', 'double', 'string', 'String', + 'array', 'static', 'volatile', 'const', 'boolean', 'byte', 'word', 'string', + 'String', 'array', 'int', 'float', 'private', 'char', 'virtual', 'operator', + 'sizeof', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int8_t', 'int16_t', + 'int32_t', 'int64_t', 'dynamic_cast', 'typedef', 'const_cast', 'const', + 'struct', 'static_cast', 'union', 'unsigned', 'long', 'volatile', 'static', + 'protected', 'bool', 'public', 'friend', 'auto', 'void', 'enum', 'extern', + 'class', 'short', 'reinterpret_cast', 'double', 'register', 'explicit', + 'signed', 'inline', 'delete', '_Bool', 'complex', '_Complex', '_Imaginary', + 'atomic_bool', 'atomic_char', 'atomic_schar', 'atomic_uchar', 'atomic_short', + 'atomic_ushort', 'atomic_int', 'atomic_uint', 'atomic_long', 'atomic_ulong', + 'atomic_llong', 'atomic_ullong', 'PROGMEM'} + + # Language shipped functions and class ( ) + functions = { + 'KeyboardController', 'MouseController', 'SoftwareSerial', 'EthernetServer', + 'EthernetClient', 'LiquidCrystal', 'RobotControl', 'GSMVoiceCall', + 'EthernetUDP', 'EsploraTFT', 'HttpClient', 'RobotMotor', 'WiFiClient', + 'GSMScanner', 'FileSystem', 'Scheduler', 'GSMServer', 'YunClient', 'YunServer', + 'IPAddress', 'GSMClient', 'GSMModem', 'Keyboard', 'Ethernet', 'Console', + 'GSMBand', 'Esplora', 'Stepper', 'Process', 'WiFiUDP', 'GSM_SMS', 'Mailbox', + 'USBHost', 'Firmata', 'PImage', 'Client', 'Server', 'GSMPIN', 'FileIO', + 'Bridge', 'Serial', 'EEPROM', 'Stream', 'Mouse', 'Audio', 'Servo', 'File', + 'Task', 'GPRS', 'WiFi', 'Wire', 'TFT', 'GSM', 'SPI', 'SD', + 'runShellCommandAsynchronously', 'analogWriteResolution', + 'retrieveCallingNumber', 'printFirmwareVersion', 'analogReadResolution', + 'sendDigitalPortPair', 'noListenOnLocalhost', 'readJoystickButton', + 'setFirmwareVersion', 'readJoystickSwitch', 'scrollDisplayRight', + 'getVoiceCallStatus', 'scrollDisplayLeft', 'writeMicroseconds', + 'delayMicroseconds', 'beginTransmission', 'getSignalStrength', + 'runAsynchronously', 'getAsynchronously', 'listenOnLocalhost', + 'getCurrentCarrier', 'readAccelerometer', 'messageAvailable', + 'sendDigitalPorts', 'lineFollowConfig', 'countryNameWrite', 'runShellCommand', + 'readStringUntil', 'rewindDirectory', 'readTemperature', 'setClockDivider', + 'readLightSensor', 'endTransmission', 'analogReference', 'detachInterrupt', + 'countryNameRead', 'attachInterrupt', 'encryptionType', 'readBytesUntil', + 'robotNameWrite', 'readMicrophone', 'robotNameRead', 'cityNameWrite', + 'userNameWrite', 'readJoystickY', 'readJoystickX', 'mouseReleased', + 'openNextFile', 'scanNetworks', 'noInterrupts', 'digitalWrite', 'beginSpeaker', + 'mousePressed', 'isActionDone', 'mouseDragged', 'displayLogos', 'noAutoscroll', + 'addParameter', 'remoteNumber', 'getModifiers', 'keyboardRead', 'userNameRead', + 'waitContinue', 'processInput', 'parseCommand', 'printVersion', 'readNetworks', + 'writeMessage', 'blinkVersion', 'cityNameRead', 'readMessage', 'setDataMode', + 'parsePacket', 'isListening', 'setBitOrder', 'beginPacket', 'isDirectory', + 'motorsWrite', 'drawCompass', 'digitalRead', 'clearScreen', 'serialEvent', + 'rightToLeft', 'setTextSize', 'leftToRight', 'requestFrom', 'keyReleased', + 'compassRead', 'analogWrite', 'interrupts', 'WiFiServer', 'disconnect', + 'playMelody', 'parseFloat', 'autoscroll', 'getPINUsed', 'setPINUsed', + 'setTimeout', 'sendAnalog', 'readSlider', 'analogRead', 'beginWrite', + 'createChar', 'motorsStop', 'keyPressed', 'tempoWrite', 'readButton', + 'subnetMask', 'debugPrint', 'macAddress', 'writeGreen', 'randomSeed', + 'attachGPRS', 'readString', 'sendString', 'remotePort', 'releaseAll', + 'mouseMoved', 'background', 'getXChange', 'getYChange', 'answerCall', + 'getResult', 'voiceCall', 'endPacket', 'constrain', 'getSocket', 'writeJSON', + 'getButton', 'available', 'connected', 'findUntil', 'readBytes', 'exitValue', + 'readGreen', 'writeBlue', 'startLoop', 'IPAddress', 'isPressed', 'sendSysex', + 'pauseMode', 'gatewayIP', 'setCursor', 'getOemKey', 'tuneWrite', 'noDisplay', + 'loadImage', 'switchPIN', 'onRequest', 'onReceive', 'changePIN', 'playFile', + 'noBuffer', 'parseInt', 'overflow', 'checkPIN', 'knobRead', 'beginTFT', + 'bitClear', 'updateIR', 'bitWrite', 'position', 'writeRGB', 'highByte', + 'writeRed', 'setSpeed', 'readBlue', 'noStroke', 'remoteIP', 'transfer', + 'shutdown', 'hangCall', 'beginSMS', 'endWrite', 'attached', 'maintain', + 'noCursor', 'checkReg', 'checkPUK', 'shiftOut', 'isValid', 'shiftIn', 'pulseIn', + 'connect', 'println', 'localIP', 'pinMode', 'getIMEI', 'display', 'noBlink', + 'process', 'getBand', 'running', 'beginSD', 'drawBMP', 'lowByte', 'setBand', + 'release', 'bitRead', 'prepare', 'pointTo', 'readRed', 'setMode', 'noFill', + 'remove', 'listen', 'stroke', 'detach', 'attach', 'noTone', 'exists', 'buffer', + 'height', 'bitSet', 'circle', 'config', 'cursor', 'random', 'IRread', 'setDNS', + 'endSMS', 'getKey', 'micros', 'millis', 'begin', 'print', 'write', 'ready', + 'flush', 'width', 'isPIN', 'blink', 'clear', 'press', 'mkdir', 'rmdir', 'close', + 'point', 'yield', 'image', 'BSSID', 'click', 'delay', 'read', 'text', 'move', + 'peek', 'beep', 'rect', 'line', 'open', 'seek', 'fill', 'size', 'turn', 'stop', + 'home', 'find', 'step', 'tone', 'sqrt', 'RSSI', 'SSID', 'end', 'bit', 'tan', + 'cos', 'sin', 'pow', 'map', 'abs', 'max', 'min', 'get', 'run', 'put', + 'isAlphaNumeric', 'isAlpha', 'isAscii', 'isWhitespace', 'isControl', 'isDigit', + 'isGraph', 'isLowerCase', 'isPrintable', 'isPunct', 'isSpace', 'isUpperCase', + 'isHexadecimalDigit'} + + # do not highlight + suppress_highlight = { + 'namespace', 'template', 'mutable', 'using', 'asm', 'typeid', + 'typename', 'this', 'alignof', 'constexpr', 'decltype', 'noexcept', + 'static_assert', 'thread_local', 'restrict'} + + def get_tokens_unprocessed(self, text, stack=('root',)): + for index, token, value in CppLexer.get_tokens_unprocessed(self, text, stack): + if value in self.structure: + yield index, Name.Builtin, value + elif value in self.operators: + yield index, Operator, value + elif value in self.variables: + yield index, Keyword.Reserved, value + elif value in self.suppress_highlight: + yield index, Name, value + elif value in self.functions: + yield index, Name.Function, value + else: + yield index, token, value + + +class CharmciLexer(CppLexer): + """ + For `Charm++ `_ interface files (.ci). + """ + + name = 'Charmci' + aliases = ['charmci'] + filenames = ['*.ci'] + version_added = '2.4' + + mimetypes = [] + + tokens = { + 'keywords': [ + (r'(module)(\s+)', bygroups(Keyword, Text), 'classname'), + (words(('mainmodule', 'mainchare', 'chare', 'array', 'group', + 'nodegroup', 'message', 'conditional')), Keyword), + (words(('entry', 'aggregate', 'threaded', 'sync', 'exclusive', + 'nokeep', 'notrace', 'immediate', 'expedited', 'inline', + 'local', 'python', 'accel', 'readwrite', 'writeonly', + 'accelblock', 'memcritical', 'packed', 'varsize', + 'initproc', 'initnode', 'initcall', 'stacksize', + 'createhere', 'createhome', 'reductiontarget', 'iget', + 'nocopy', 'mutable', 'migratable', 'readonly')), Keyword), + inherit, + ], + } + + +class OmgIdlLexer(CLexer): + """ + Lexer for Object Management Group Interface Definition Language. + """ + + name = 'OMG Interface Definition Language' + url = 'https://www.omg.org/spec/IDL/About-IDL/' + aliases = ['omg-idl'] + filenames = ['*.idl', '*.pidl'] + mimetypes = [] + version_added = '2.9' + + scoped_name = r'((::)?\w+)+' + + tokens = { + 'values': [ + (words(('true', 'false'), prefix=r'(?i)', suffix=r'\b'), Number), + (r'([Ll]?)(")', bygroups(String.Affix, String.Double), 'string'), + (r'([Ll]?)(\')(\\[^\']+)(\')', + bygroups(String.Affix, String.Char, String.Escape, String.Char)), + (r'([Ll]?)(\')(\\\')(\')', + bygroups(String.Affix, String.Char, String.Escape, String.Char)), + (r'([Ll]?)(\'.\')', bygroups(String.Affix, String.Char)), + (r'[+-]?\d+(\.\d*)?[Ee][+-]?\d+', Number.Float), + (r'[+-]?(\d+\.\d*)|(\d*\.\d+)([Ee][+-]?\d+)?', Number.Float), + (r'(?i)[+-]?0x[0-9a-f]+', Number.Hex), + (r'[+-]?[1-9]\d*', Number.Integer), + (r'[+-]?0[0-7]*', Number.Oct), + (r'[\+\-\*\/%^&\|~]', Operator), + (words(('<<', '>>')), Operator), + (scoped_name, Name), + (r'[{};:,<>\[\]]', Punctuation), + ], + 'annotation_params': [ + include('whitespace'), + (r'\(', Punctuation, '#push'), + include('values'), + (r'=', Punctuation), + (r'\)', Punctuation, '#pop'), + ], + 'annotation_params_maybe': [ + (r'\(', Punctuation, 'annotation_params'), + include('whitespace'), + default('#pop'), + ], + 'annotation_appl': [ + (r'@' + scoped_name, Name.Decorator, 'annotation_params_maybe'), + ], + 'enum': [ + include('whitespace'), + (r'[{,]', Punctuation), + (r'\w+', Name.Constant), + include('annotation_appl'), + (r'\}', Punctuation, '#pop'), + ], + 'root': [ + include('whitespace'), + (words(( + 'typedef', 'const', + 'in', 'out', 'inout', 'local', + ), prefix=r'(?i)', suffix=r'\b'), Keyword.Declaration), + (words(( + 'void', 'any', 'native', 'bitfield', + 'unsigned', 'boolean', 'char', 'wchar', 'octet', 'short', 'long', + 'int8', 'uint8', 'int16', 'int32', 'int64', 'uint16', 'uint32', 'uint64', + 'float', 'double', 'fixed', + 'sequence', 'string', 'wstring', 'map', + ), prefix=r'(?i)', suffix=r'\b'), Keyword.Type), + (words(( + '@annotation', 'struct', 'union', 'bitset', 'interface', + 'exception', 'valuetype', 'eventtype', 'component', + ), prefix=r'(?i)', suffix=r'(\s+)(\w+)'), bygroups(Keyword, Whitespace, Name.Class)), + (words(( + 'abstract', 'alias', 'attribute', 'case', 'connector', + 'consumes', 'context', 'custom', 'default', 'emits', 'factory', + 'finder', 'getraises', 'home', 'import', 'manages', 'mirrorport', + 'multiple', 'Object', 'oneway', 'primarykey', 'private', 'port', + 'porttype', 'provides', 'public', 'publishes', 'raises', + 'readonly', 'setraises', 'supports', 'switch', 'truncatable', + 'typeid', 'typename', 'typeprefix', 'uses', 'ValueBase', + ), prefix=r'(?i)', suffix=r'\b'), Keyword), + (r'(?i)(enum|bitmask)(\s+)(\w+)', + bygroups(Keyword, Whitespace, Name.Class), 'enum'), + (r'(?i)(module)(\s+)(\w+)', + bygroups(Keyword.Namespace, Whitespace, Name.Namespace)), + (r'(\w+)(\s*)(=)', bygroups(Name.Constant, Whitespace, Operator)), + (r'[\(\)]', Punctuation), + include('values'), + include('annotation_appl'), + ], + } + + +class PromelaLexer(CLexer): + """ + For the Promela language used with SPIN. + """ + + name = 'Promela' + aliases = ['promela'] + filenames = ['*.pml', '*.prom', '*.prm', '*.promela', '*.pr', '*.pm'] + mimetypes = ['text/x-promela'] + url = 'https://spinroot.com/spin/whatispin.html' + version_added = '2.18' + + # Promela's language reference: + # https://spinroot.com/spin/Man/promela.html + # Promela's grammar definition: + # https://spinroot.com/spin/Man/grammar.html + + tokens = { + 'statements': [ + (r'(\[\]|<>|/\\|\\/)|(U|W|V)\b', Operator), # LTL Operators + (r'@', Punctuation), #remoterefs + (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)), + inherit + ], + 'types': [ + # Predefined (data types) + (words(( + 'bit', 'bool', 'byte', 'pid', 'short', 'int', 'unsigned'), + suffix=r'\b'), + Keyword.Type), + ], + 'keywords': [ + # ControlFlow + (words(( + 'atomic', 'break', 'd_step', 'do', 'od', 'for', 'in', 'goto', + 'if', 'fi', 'unless'), suffix=r'\b'), + Keyword), + # BasicStatements + (words(( + 'assert', 'get_priority', 'printf', 'printm', 'set_priority'), + suffix=r'\b'), + Name.Function), + # Embedded C Code + (words(( + 'c_code', 'c_decl', 'c_expr', 'c_state', 'c_track'), + suffix=r'\b'), + Keyword), + # Predefined (local/global variables) + (words(( + '_', '_last', '_nr_pr', '_pid', '_priority', 'else', 'np_', + 'STDIN'), suffix=r'\b'), + Name.Builtin), + # Predefined (functions) + (words(( + 'empty', 'enabled', 'eval', 'full', 'len', 'nempty', 'nfull', + 'pc_value'), suffix=r'\b'), + Name.Function), + # Predefined (operators) + (r'run\b', Operator.Word), + # Declarators + (words(( + 'active', 'chan', 'D_proctype', 'hidden', 'init', 'local', + 'mtype', 'never', 'notrace', 'proctype', 'show', 'trace', + 'typedef', 'xr', 'xs'), suffix=r'\b'), + Keyword.Declaration), + # Declarators (suffixes) + (words(( + 'priority', 'provided'), suffix=r'\b'), + Keyword), + # MetaTerms (declarators) + (words(( + 'inline', 'ltl', 'select'), suffix=r'\b'), + Keyword.Declaration), + # MetaTerms (keywords) + (r'skip\b', Keyword), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/capnproto.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/capnproto.py new file mode 100644 index 0000000000000000000000000000000000000000..1e819c7f876f06b481d03b15c24e4b5140dc5414 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/capnproto.py @@ -0,0 +1,74 @@ +""" + pygments.lexers.capnproto + ~~~~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for the Cap'n Proto schema language. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, default +from pygments.token import Text, Comment, Keyword, Name, Literal, Whitespace + +__all__ = ['CapnProtoLexer'] + + +class CapnProtoLexer(RegexLexer): + """ + For Cap'n Proto source. + """ + name = 'Cap\'n Proto' + url = 'https://capnproto.org' + filenames = ['*.capnp'] + aliases = ['capnp'] + version_added = '2.2' + + tokens = { + 'root': [ + (r'#.*?$', Comment.Single), + (r'@[0-9a-zA-Z]*', Name.Decorator), + (r'=', Literal, 'expression'), + (r':', Name.Class, 'type'), + (r'\$', Name.Attribute, 'annotation'), + (r'(struct|enum|interface|union|import|using|const|annotation|' + r'extends|in|of|on|as|with|from|fixed)\b', + Keyword), + (r'[\w.]+', Name), + (r'[^#@=:$\w\s]+', Text), + (r'\s+', Whitespace), + ], + 'type': [ + (r'[^][=;,(){}$]+', Name.Class), + (r'[\[(]', Name.Class, 'parentype'), + default('#pop'), + ], + 'parentype': [ + (r'[^][;()]+', Name.Class), + (r'[\[(]', Name.Class, '#push'), + (r'[])]', Name.Class, '#pop'), + default('#pop'), + ], + 'expression': [ + (r'[^][;,(){}$]+', Literal), + (r'[\[(]', Literal, 'parenexp'), + default('#pop'), + ], + 'parenexp': [ + (r'[^][;()]+', Literal), + (r'[\[(]', Literal, '#push'), + (r'[])]', Literal, '#pop'), + default('#pop'), + ], + 'annotation': [ + (r'[^][;,(){}=:]+', Name.Attribute), + (r'[\[(]', Name.Attribute, 'annexp'), + default('#pop'), + ], + 'annexp': [ + (r'[^][;()]+', Name.Attribute), + (r'[\[(]', Name.Attribute, '#push'), + (r'[])]', Name.Attribute, '#pop'), + default('#pop'), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/carbon.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/carbon.py new file mode 100644 index 0000000000000000000000000000000000000000..d45b78800cd6b9082f5c83950b12761dfe24f74c --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/carbon.py @@ -0,0 +1,95 @@ +""" + pygments.lexers.carbon + ~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for the Carbon programming language. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" +import re + +from pygments.lexer import RegexLexer, words +from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace + +__all__ = ['CarbonLexer'] + + +class CarbonLexer(RegexLexer): + """ + For Carbon source. + """ + name = 'Carbon' + url = 'https://github.com/carbon-language/carbon-lang' + filenames = ['*.carbon'] + aliases = ['carbon'] + mimetypes = ['text/x-carbon'] + version_added = '2.15' + + flags = re.MULTILINE | re.DOTALL + + tokens = { + 'root': [ + (r'\n', Whitespace), + (r'\s+', Whitespace), + (r'\\\n', Text), + # comments + (r'//(.*?)\n', Comment.Single), + (r'/(\\\n)?[*].*?[*](\\\n)?/', Comment.Multiline), + # Declaration + (r'(package|import|api|namespace|library)\b', Keyword.Namespace), + (r'(abstract|alias|fn|class|interface|let|var|virtual|external|' + r'base|addr|extends|choice|constraint|impl)\b', Keyword.Declaration), + # Keywords + (words(('as', 'or', 'not', 'and', 'break', 'continue', 'case', + 'default', 'if', 'else', 'destructor', 'for', 'forall', + 'while', 'where', 'then', 'in', 'is', 'return', 'returned', + 'friend', 'partial', 'private', 'protected', 'observe', 'Self', + 'override', 'final', 'match', 'type', 'like'), suffix=r'\b'), Keyword), + (r'(self)\b', Keyword.Pseudo), + (r'(true|false)\b', Keyword.Constant), + (r'(auto|bool|string|i8|i16|i32|i64|u8|u16|u32|u64|' + r'f8|f16|f32|f64)\b', Keyword.Type), + # numeric literals + (r'[0-9]*[.][0-9]+', Number.Double), + (r'0b[01]+', Number.Bin), + (r'0o[0-7]+', Number.Oct), + (r'0x[0-9a-fA-F]+', Number.Hex), + (r'[0-9]+', Number.Integer), + # string literal + (r'"(\\.|[^"\\])*"', String), + # char literal + (r'\'(\\.|[^\'\\])\'', String.Char), + # tokens + (r'<<=|>>=|<<|>>|<=|>=|\+=|-=|\*=|/=|\%=|\|=|&=|\^=|&&|\|\||&|\||' + r'\+\+|--|\%|\^|\~|==|!=|::|[.]{3}|->|=>|[+\-*/&]', Operator), + (r'[|<>=!()\[\]{}.,;:\?]', Punctuation), + # identifiers + (r'[^\W\d]\w*', Name.Other), + ] + } + + def analyse_text(text): + result = 0 + if 'forall' in text: + result += 0.1 + if 'type' in text: + result += 0.1 + if 'Self' in text: + result += 0.1 + if 'observe' in text: + result += 0.1 + if 'package' in text: + result += 0.1 + if 'library' in text: + result += 0.1 + if 'choice' in text: + result += 0.1 + if 'addr' in text: + result += 0.1 + if 'constraint' in text: + result += 0.1 + if 'impl' in text: + result += 0.1 + return result diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/cddl.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/cddl.py new file mode 100644 index 0000000000000000000000000000000000000000..38346ddb9ddbba4b9e83488124b56ad372fdcaf6 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/cddl.py @@ -0,0 +1,172 @@ +""" + pygments.lexers.cddl + ~~~~~~~~~~~~~~~~~~~~ + + Lexer for the Concise data definition language (CDDL), a notational + convention to express CBOR and JSON data structures. + + More information: + https://datatracker.ietf.org/doc/rfc8610/ + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, bygroups, include, words +from pygments.token import Comment, Error, Keyword, Name, Number, Operator, \ + Punctuation, String, Whitespace + +__all__ = ['CddlLexer'] + + +class CddlLexer(RegexLexer): + """ + Lexer for CDDL definitions. + """ + name = "CDDL" + url = 'https://datatracker.ietf.org/doc/rfc8610/' + aliases = ["cddl"] + filenames = ["*.cddl"] + mimetypes = ["text/x-cddl"] + version_added = '2.8' + + _prelude_types = [ + "any", + "b64legacy", + "b64url", + "bigfloat", + "bigint", + "bignint", + "biguint", + "bool", + "bstr", + "bytes", + "cbor-any", + "decfrac", + "eb16", + "eb64legacy", + "eb64url", + "encoded-cbor", + "false", + "float", + "float16", + "float16-32", + "float32", + "float32-64", + "float64", + "int", + "integer", + "mime-message", + "nil", + "nint", + "null", + "number", + "regexp", + "tdate", + "text", + "time", + "true", + "tstr", + "uint", + "undefined", + "unsigned", + "uri", + ] + + _controls = [ + ".and", + ".bits", + ".cbor", + ".cborseq", + ".default", + ".eq", + ".ge", + ".gt", + ".le", + ".lt", + ".ne", + ".regexp", + ".size", + ".within", + ] + + _re_id = ( + r"[$@A-Z_a-z]" + r"(?:[\-\.]+(?=[$@0-9A-Z_a-z])|[$@0-9A-Z_a-z])*" + + ) + + # While the spec reads more like "an int must not start with 0" we use a + # lookahead here that says "after a 0 there must be no digit". This makes the + # '0' the invalid character in '01', which looks nicer when highlighted. + _re_uint = r"(?:0b[01]+|0x[0-9a-fA-F]+|[1-9]\d*|0(?!\d))" + _re_int = r"-?" + _re_uint + + tokens = { + "commentsandwhitespace": [(r"\s+", Whitespace), (r";.+$", Comment.Single)], + "root": [ + include("commentsandwhitespace"), + # tag types + (rf"#(\d\.{_re_uint})?", Keyword.Type), # type or any + # occurrence + ( + rf"({_re_uint})?(\*)({_re_uint})?", + bygroups(Number, Operator, Number), + ), + (r"\?|\+", Operator), # occurrence + (r"\^", Operator), # cuts + (r"(\.\.\.|\.\.)", Operator), # rangeop + (words(_controls, suffix=r"\b"), Operator.Word), # ctlops + # into choice op + (rf"&(?=\s*({_re_id}|\())", Operator), + (rf"~(?=\s*{_re_id})", Operator), # unwrap op + (r"//|/(?!/)", Operator), # double und single slash + (r"=>|/==|/=|=", Operator), + (r"[\[\]{}\(\),<>:]", Punctuation), + # Bytestrings + (r"(b64)(')", bygroups(String.Affix, String.Single), "bstrb64url"), + (r"(h)(')", bygroups(String.Affix, String.Single), "bstrh"), + (r"'", String.Single, "bstr"), + # Barewords as member keys (must be matched before values, types, typenames, + # groupnames). + # Token type is String as barewords are always interpreted as such. + (rf"({_re_id})(\s*)(:)", + bygroups(String, Whitespace, Punctuation)), + # predefined types + (words(_prelude_types, prefix=r"(?![\-_$@])\b", suffix=r"\b(?![\-_$@])"), + Name.Builtin), + # user-defined groupnames, typenames + (_re_id, Name.Class), + # values + (r"0b[01]+", Number.Bin), + (r"0o[0-7]+", Number.Oct), + (r"0x[0-9a-fA-F]+(\.[0-9a-fA-F]+)?p[+-]?\d+", Number.Hex), # hexfloat + (r"0x[0-9a-fA-F]+", Number.Hex), # hex + # Float + (rf"{_re_int}(?=(\.\d|e[+-]?\d))(?:\.\d+)?(?:e[+-]?\d+)?", + Number.Float), + # Int + (_re_int, Number.Integer), + (r'"(\\\\|\\"|[^"])*"', String.Double), + ], + "bstrb64url": [ + (r"'", String.Single, "#pop"), + include("commentsandwhitespace"), + (r"\\.", String.Escape), + (r"[0-9a-zA-Z\-_=]+", String.Single), + (r".", Error), + # (r";.+$", Token.Other), + ], + "bstrh": [ + (r"'", String.Single, "#pop"), + include("commentsandwhitespace"), + (r"\\.", String.Escape), + (r"[0-9a-fA-F]+", String.Single), + (r".", Error), + ], + "bstr": [ + (r"'", String.Single, "#pop"), + (r"\\.", String.Escape), + (r"[^'\\]+", String.Single), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/cel.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/cel.py new file mode 100644 index 0000000000000000000000000000000000000000..f636b6171a9fffd97fadf016d5bef52fc2d5dc99 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/cel.py @@ -0,0 +1,142 @@ +""" + pygments.lexers.cel + ~~~~~~~~~~~~~~~~~~~ + + Lexer for CEL (Common Expression Language). + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +__all__ = ['CELLexer'] + +import re + +from pygments.lexer import RegexLexer, words +from pygments.token import ( + Comment, Keyword, Name, Number, Operator, Punctuation, String, Whitespace, +) + + +class CELLexer(RegexLexer): + """Lexer for CEL (Common Expression Language).""" + + name = 'CEL' + aliases = ['cel'] + filenames = ['*.cel'] + mimetypes = [] + url = 'https://cel.dev' + version_added = '2.21' + + flags = re.MULTILINE | re.UNICODE + + # Escape sequence per the CEL spec: + # \a \b \f \n \r \t \v \\ \" \' \` \? + # \xHH or \XHH (exactly 2 hex digits) + # \uHHHH (exactly 4 hex digits) + # \UHHHHHHHH (exactly 8 hex digits) + # \OOO (3-digit octal, first digit 0-3) + # \. (fallback for unknown escapes) + _ESCAPE = r"""\\(?:[abfnrtv\\"'`?]|[xX][0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|[0-3][0-7][0-7]|.)""" + + # Raw prefix: r/R alone, or b/B combined with r/R in either order + _RAW = r'(?:[bB][rR]|[rR][bB]|[rR])' + + tokens = { + 'root': [ + (r'\s+', Whitespace), + # CEL only has line comments; no block comments. + (r'//.*$', Comment.Single), + + # Bytes and string literals. + # Raw variants (no escape processing) must be tried before + # non-raw so that br/rb/r prefixes are consumed greedily. + # Triple-quoted raw (br""", rb""", r""") + (_RAW + r'"""', String, 'triple-double-raw'), + (_RAW + r"'''", String, 'triple-single-raw'), + # Triple-quoted non-raw with optional b prefix (b""" or """) + (r'[bB]?"""', String, 'triple-double'), + (r"[bB]?'''", String, 'triple-single'), + # Single-line raw + (_RAW + r'"[^"\r\n]*"', String), + (_RAW + r"'[^'\r\n]*'", String), + # Single-line non-raw with optional b prefix + (r'[bB]?"', String, 'double-string'), + (r"[bB]?'", String, 'single-string'), + + # Numbers. + # uint_literal: integer (decimal or hex) followed by u/U suffix. + (r'(?:0[xX][0-9a-fA-F]+|0|[1-9][0-9]*)[uU]', Number.Integer), + # float_literal: the grammar requires digits on both sides of the + # decimal point for the dotted form — `1.` is not valid CEL. + (r'(?:[0-9]+\.[0-9]+(?:[eE][+-]?[0-9]+)?' + r'|[0-9]+[eE][+-]?[0-9]+' + r'|\.[0-9]+(?:[eE][+-]?[0-9]+)?)', + Number.Float), + # int_literal: hex or decimal. + (r'0[xX][0-9a-fA-F]+|0|[1-9][0-9]*', Number.Integer), + + # Reserved keywords (may not appear as identifiers). + (words(( + 'as', 'break', 'const', 'continue', 'else', 'for', + 'function', 'if', 'import', 'let', 'loop', 'namespace', + 'package', 'return', 'var', 'void', 'while', + ), suffix=r'\b'), Keyword.Reserved), + # `in` is a comparison operator keyword. + (r'in\b', Keyword), + # Built-in literal constants. + (words(('true', 'false', 'null'), suffix=r'\b'), Keyword.Constant), + + # Logical and comparison operators. + (r'&&|\|\|', Operator), + (r'==|!=|<=|>=', Operator), + # Arithmetic, unary, ternary, and remaining comparison operators. + (r'[+\-*/%<>!?]', Operator), + + # Punctuation: brackets, comma, dot, colon. + (r'[(){}\[\]]', Punctuation), + (r'[,.]', Punctuation), + (r':', Punctuation), + + # Identifiers: start with letter or underscore (Unicode-aware). + (r'[^\W\d]\w*', Name), + ], + + # Raw triple-quoted (no escape tokens; content is one big String). + 'triple-double-raw': [ + (r'"""', String, '#pop'), + (r'"(?!"")', String), + (r'[^"]+', String), + ], + 'triple-single-raw': [ + (r"'''", String, '#pop'), + (r"'(?!'')", String), + (r"[^']+", String), + ], + + # Non-raw triple-quoted (escape sequences highlighted separately). + 'triple-double': [ + (r'"""', String, '#pop'), + (_ESCAPE, String.Escape), + (r'"(?!"")', String), + (r'[^"\\]+', String), + ], + 'triple-single': [ + (r"'''", String, '#pop'), + (_ESCAPE, String.Escape), + (r"'(?!'')", String), + (r"[^'\\]+", String), + ], + + # Single-line non-raw strings (cannot span lines). + 'double-string': [ + (r'"', String, '#pop'), + (_ESCAPE, String.Escape), + (r'[^"\\\r\n]+', String), + ], + 'single-string': [ + (r"'", String, '#pop'), + (_ESCAPE, String.Escape), + (r"[^'\\\r\n]+", String), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/chapel.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/chapel.py new file mode 100644 index 0000000000000000000000000000000000000000..585be75d8a6ba3d1779c7782b80ce26a018fae8d --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/chapel.py @@ -0,0 +1,139 @@ +""" + pygments.lexers.chapel + ~~~~~~~~~~~~~~~~~~~~~~ + + Lexer for the Chapel language. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, bygroups, words +from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace + +__all__ = ['ChapelLexer'] + + +class ChapelLexer(RegexLexer): + """ + For Chapel source. + """ + name = 'Chapel' + url = 'https://chapel-lang.org/' + filenames = ['*.chpl'] + aliases = ['chapel', 'chpl'] + version_added = '2.0' + # mimetypes = ['text/x-chapel'] + + known_types = ('bool', 'bytes', 'complex', 'imag', 'int', 'locale', + 'nothing', 'opaque', 'range', 'real', 'string', 'uint', + 'void') + + type_modifiers_par = ('atomic', 'single', 'sync') + type_modifiers_mem = ('borrowed', 'owned', 'shared', 'unmanaged') + type_modifiers = (*type_modifiers_par, *type_modifiers_mem) + + declarations = ('config', 'const', 'in', 'inout', 'out', 'param', 'ref', + 'type', 'var') + + constants = ('false', 'nil', 'none', 'true') + + other_keywords = ('align', 'as', + 'begin', 'break', 'by', + 'catch', 'cobegin', 'coforall', 'continue', + 'defer', 'delete', 'dmapped', 'do', 'domain', + 'else', 'enum', 'except', 'export', 'extern', + 'for', 'forall', 'foreach', 'forwarding', + 'if', 'implements', 'import', 'index', 'init', 'inline', + 'label', 'lambda', 'let', 'lifetime', 'local', + 'new', 'noinit', + 'on', 'only', 'otherwise', 'override', + 'pragma', 'primitive', 'private', 'prototype', 'public', + 'reduce', 'require', 'return', + 'scan', 'select', 'serial', 'sparse', 'subdomain', + 'then', 'this', 'throw', 'throws', 'try', + 'use', + 'when', 'where', 'while', 'with', + 'yield', + 'zip') + + tokens = { + 'root': [ + (r'\n', Whitespace), + (r'\s+', Whitespace), + (r'\\\n', Text), + + (r'//(.*?)\n', Comment.Single), + (r'/(\\\n)?[*][\s\S]*?[*](\\\n)?/', Comment.Multiline), + + (words(declarations, suffix=r'\b'), Keyword.Declaration), + (words(constants, suffix=r'\b'), Keyword.Constant), + (words(known_types, suffix=r'\b'), Keyword.Type), + (words((*type_modifiers, *other_keywords), suffix=r'\b'), Keyword), + + (r'@', Keyword, 'attributename'), + (r'(iter)(\s+)', bygroups(Keyword, Whitespace), 'procname'), + (r'(proc)(\s+)', bygroups(Keyword, Whitespace), 'procname'), + (r'(operator)(\s+)', bygroups(Keyword, Whitespace), 'procname'), + (r'(class|interface|module|record|union)(\s+)', bygroups(Keyword, Whitespace), + 'classname'), + + # imaginary integers + (r'\d+i', Number), + (r'\d+\.\d*([Ee][-+]\d+)?i', Number), + (r'\.\d+([Ee][-+]\d+)?i', Number), + (r'\d+[Ee][-+]\d+i', Number), + + # reals cannot end with a period due to lexical ambiguity with + # .. operator. See reference for rationale. + (r'(\d*\.\d+)([eE][+-]?[0-9]+)?i?', Number.Float), + (r'\d+[eE][+-]?[0-9]+i?', Number.Float), + + # integer literals + # -- binary + (r'0[bB][01]+', Number.Bin), + # -- hex + (r'0[xX][0-9a-fA-F]+', Number.Hex), + # -- octal + (r'0[oO][0-7]+', Number.Oct), + # -- decimal + (r'[0-9]+', Number.Integer), + + # strings + (r'"(\\\\|\\"|[^"])*"', String), + (r"'(\\\\|\\'|[^'])*'", String), + + # tokens + (r'(=|\+=|-=|\*=|/=|\*\*=|%=|&=|\|=|\^=|&&=|\|\|=|<<=|>>=|' + r'<=>|<~>|\.\.|by|#|\.\.\.|' + r'&&|\|\||!|&|\||\^|~|<<|>>|' + r'==|!=|<=|>=|<|>|' + r'[+\-*/%]|\*\*)', Operator), + (r'[:;,.?()\[\]{}]', Punctuation), + + # identifiers + (r'[a-zA-Z_][\w$]*', Name.Other), + ], + 'classname': [ + (r'[a-zA-Z_][\w$]*', Name.Class, '#pop'), + ], + 'procname': [ + (r'([a-zA-Z_][.\w$]*|' # regular function name, including secondary + r'\~[a-zA-Z_][.\w$]*|' # support for legacy destructors + r'[+*/!~%<>=&^|\-:]{1,2})', # operators + Name.Function, '#pop'), + + # allow `proc (atomic T).foo` + (r'\(', Punctuation, "receivertype"), + (r'\)+\.', Punctuation), + ], + 'receivertype': [ + (words(type_modifiers, suffix=r'\b'), Keyword), + (words(known_types, suffix=r'\b'), Keyword.Type), + (r'[^()]*', Name.Other, '#pop'), + ], + 'attributename': [ + (r'[a-zA-Z_][.\w$]*', Name.Decorator, '#pop'), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/clean.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/clean.py new file mode 100644 index 0000000000000000000000000000000000000000..1500e2c4c599487665a25b347afeca774fe8224f --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/clean.py @@ -0,0 +1,180 @@ +""" + pygments.lexers.clean + ~~~~~~~~~~~~~~~~~~~~~ + + Lexer for the Clean language. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import ExtendedRegexLexer, words, default, include, bygroups +from pygments.token import Comment, Error, Keyword, Literal, Name, Number, \ + Operator, Punctuation, String, Whitespace + +__all__ = ['CleanLexer'] + + +class CleanLexer(ExtendedRegexLexer): + """ + Lexer for the general purpose, state-of-the-art, pure and lazy functional + programming language Clean. + + .. versionadded: 2.2 + """ + name = 'Clean' + url = 'http://clean.cs.ru.nl/Clean' + aliases = ['clean'] + filenames = ['*.icl', '*.dcl'] + version_added = '' + + keywords = ( + 'case', 'ccall', 'class', 'code', 'code inline', 'derive', 'export', + 'foreign', 'generic', 'if', 'in', 'infix', 'infixl', 'infixr', + 'instance', 'let', 'of', 'otherwise', 'special', 'stdcall', 'where', + 'with') + + modulewords = ('implementation', 'definition', 'system') + + lowerId = r'[a-z`][\w`]*' + upperId = r'[A-Z`][\w`]*' + funnyId = r'[~@#$%\^?!+\-*<>\\/|&=:]+' + scoreUpperId = r'_' + upperId + scoreLowerId = r'_' + lowerId + moduleId = r'[a-zA-Z_][a-zA-Z0-9_.`]+' + classId = '|'.join([lowerId, upperId, funnyId]) + + tokens = { + 'root': [ + include('comments'), + include('keywords'), + include('module'), + include('import'), + include('whitespace'), + include('literals'), + include('operators'), + include('delimiters'), + include('names'), + ], + 'whitespace': [ + (r'\s+', Whitespace), + ], + 'comments': [ + (r'//.*\n', Comment.Single), + (r'/\*', Comment.Multiline, 'comments.in'), + (r'/\*\*', Comment.Special, 'comments.in'), + ], + 'comments.in': [ + (r'\*\/', Comment.Multiline, '#pop'), + (r'/\*', Comment.Multiline, '#push'), + (r'[^*/]+', Comment.Multiline), + (r'\*(?!/)', Comment.Multiline), + (r'/', Comment.Multiline), + ], + 'keywords': [ + (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword), + ], + 'module': [ + (words(modulewords, prefix=r'\b', suffix=r'\b'), Keyword.Namespace), + (r'\bmodule\b', Keyword.Namespace, 'module.name'), + ], + 'module.name': [ + include('whitespace'), + (moduleId, Name.Class, '#pop'), + ], + 'import': [ + (r'\b(import)\b(\s*)', bygroups(Keyword, Whitespace), 'import.module'), + (r'\b(from)\b(\s*)\b(' + moduleId + r')\b(\s*)\b(import)\b', + bygroups(Keyword, Whitespace, Name.Class, Whitespace, Keyword), + 'import.what'), + ], + 'import.module': [ + (r'\b(qualified)\b(\s*)', bygroups(Keyword, Whitespace)), + (r'(\s*)\b(as)\b', bygroups(Whitespace, Keyword), ('#pop', 'import.module.as')), + (moduleId, Name.Class), + (r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace)), + (r'\s+', Whitespace), + default('#pop'), + ], + 'import.module.as': [ + include('whitespace'), + (lowerId, Name.Class, '#pop'), + (upperId, Name.Class, '#pop'), + ], + 'import.what': [ + (r'\b(class)\b(\s+)(' + classId + r')', + bygroups(Keyword, Whitespace, Name.Class), 'import.what.class'), + (r'\b(instance)(\s+)(' + classId + r')(\s+)', + bygroups(Keyword, Whitespace, Name.Class, Whitespace), 'import.what.instance'), + (r'(::)(\s*)\b(' + upperId + r')\b', + bygroups(Punctuation, Whitespace, Name.Class), 'import.what.type'), + (r'\b(generic)\b(\s+)\b(' + lowerId + '|' + upperId + r')\b', + bygroups(Keyword, Whitespace, Name)), + include('names'), + (r'(,)(\s+)', bygroups(Punctuation, Whitespace)), + (r'$', Whitespace, '#pop'), + include('whitespace'), + ], + 'import.what.class': [ + (r',', Punctuation, '#pop'), + (r'\(', Punctuation, 'import.what.class.members'), + (r'$', Whitespace, '#pop:2'), + include('whitespace'), + ], + 'import.what.class.members': [ + (r',', Punctuation), + (r'\.\.', Punctuation), + (r'\)', Punctuation, '#pop'), + include('names'), + ], + 'import.what.instance': [ + (r'[,)]', Punctuation, '#pop'), + (r'\(', Punctuation, 'import.what.instance'), + (r'$', Whitespace, '#pop:2'), + include('whitespace'), + include('names'), + ], + 'import.what.type': [ + (r',', Punctuation, '#pop'), + (r'[({]', Punctuation, 'import.what.type.consesandfields'), + (r'$', Whitespace, '#pop:2'), + include('whitespace'), + ], + 'import.what.type.consesandfields': [ + (r',', Punctuation), + (r'\.\.', Punctuation), + (r'[)}]', Punctuation, '#pop'), + include('names'), + ], + 'literals': [ + (r'\'([^\'\\]|\\(x[\da-fA-F]+|\d+|.))\'', Literal.Char), + (r'[+~-]?0[0-7]+\b', Number.Oct), + (r'[+~-]?\d+\.\d+(E[+-]?\d+)?', Number.Float), + (r'[+~-]?\d+\b', Number.Integer), + (r'[+~-]?0x[\da-fA-F]+\b', Number.Hex), + (r'True|False', Literal), + (r'"', String.Double, 'literals.stringd'), + ], + 'literals.stringd': [ + (r'[^\\"\n]+', String.Double), + (r'"', String.Double, '#pop'), + (r'\\.', String.Double), + (r'[$\n]', Error, '#pop'), + ], + 'operators': [ + (r'[-~@#$%\^?!+*<>\\/|&=:.]+', Operator), + (r'\b_+\b', Operator), + ], + 'delimiters': [ + (r'[,;(){}\[\]]', Punctuation), + (r'(\')([\w`.]+)(\')', + bygroups(Punctuation, Name.Class, Punctuation)), + ], + 'names': [ + (lowerId, Name), + (scoreLowerId, Name), + (funnyId, Name.Function), + (upperId, Name.Class), + (scoreUpperId, Name.Class), + ] + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/codeql.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/codeql.py new file mode 100644 index 0000000000000000000000000000000000000000..ab27bf508311214e062dd88aa8b2247cd3d87cdb --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/codeql.py @@ -0,0 +1,80 @@ +""" + pygments.lexers.codeql + ~~~~~~~~~~~~~~~~~~~~~~ + + Lexer for CodeQL query language. + + The grammar is originating from: + https://github.com/github/vscode-codeql/blob/main/syntaxes/README.md + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +__all__ = ['CodeQLLexer'] + +import re + +from pygments.lexer import RegexLexer, words +from pygments.token import Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace + +class CodeQLLexer(RegexLexer): + name = 'CodeQL' + aliases = ['codeql', 'ql'] + filenames = ['*.ql', '*.qll'] + mimetypes = [] + url = 'https://github.com/github/codeql' + version_added = '2.19' + + flags = re.MULTILINE | re.UNICODE + + tokens = { + 'root': [ + # Whitespace and comments + (r'\s+', Whitespace), + (r'//.*?\n', Comment.Single), + (r'/\*', Comment.Multiline, 'multiline-comments'), + + # Keywords + (words(( + 'module', 'import', 'class', 'extends', 'implements', + 'predicate', 'select', 'where', 'from', 'as', 'and', 'or', 'not', + 'in', 'if', 'then', 'else', 'exists', 'forall', 'instanceof', + 'private', 'predicate', 'abstract', 'cached', 'external', + 'final', 'library', 'override', 'query' + ), suffix=r'\b'), Keyword.Builtin), + + # Special Keywords + (words(('this'), # class related keywords + prefix=r'\b', suffix=r'\b\??:?'), Name.Builtin.Pseudo), + + # Types + (words(( + 'boolean', 'date', 'float', 'int', 'string' + ), suffix=r'\b'), Keyword.Type), + + # Literals + (r'"(\\\\|\\[^\\]|[^"\\])*"', String), + (r'[0-9]+\.[0-9]+', Number.Float), + (r'[0-9]+', Number.Integer), + + # Operators + (r'<=|>=|<|>|=|!=|\+|-|\*|/', Operator), + + # Punctuation + (r'[.,;:\[\]{}()]+', Punctuation), + + # Identifiers + (r'@[a-zA-Z_]\w*', Name.Variable), # Variables with @ prefix + (r'[A-Z][a-zA-Z0-9_]*', Name.Class), # Types and classes + (r'[a-z][a-zA-Z0-9_]*', Name.Variable), # Variables and predicates + ], + 'multiline-comments': [ + (r'[^*/]+', Comment.Multiline), + (r'/\*', Comment.Multiline, '#push'), + (r'\*/', Comment.Multiline, '#pop'), + (r'[*/]', Comment.Multiline), + ], + + } \ No newline at end of file diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/comal.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/comal.py new file mode 100644 index 0000000000000000000000000000000000000000..6b0a8d11a8135f7fdf3424622cb1d5e3c227075a --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/comal.py @@ -0,0 +1,81 @@ +""" + pygments.lexers.comal + ~~~~~~~~~~~~~~~~~~~~~ + + Lexer for COMAL-80. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, words +from pygments.token import Comment, Whitespace, Operator, Keyword, String, \ + Number, Name, Punctuation + +__all__ = ["Comal80Lexer"] + + +class Comal80Lexer(RegexLexer): + """ + For COMAL-80 source code. + """ + + name = 'COMAL-80' + url = 'https://en.wikipedia.org/wiki/COMAL' + aliases = ['comal', 'comal80'] + filenames = ['*.cml', '*.comal'] + version_added = '' + flags = re.IGNORECASE + # + # COMAL allows for some strange characters in names which we list here so + # keywords and word operators will not be recognized at the start of an + # identifier. + # + _suffix = r"\b(?!['\[\]←£\\])" + _identifier = r"[a-z]['\[\]←£\\\w]*" + + tokens = { + 'root': [ + (r'//.*\n', Comment.Single), + (r'\s+', Whitespace), + (r':[=+-]|\<\>|[-+*/^↑<>=]', Operator), + (r'(and +then|or +else)' + _suffix, Operator.Word), + (words([ + 'and', 'bitand', 'bitor', 'bitxor', 'div', 'in', 'mod', 'not', + 'or'], suffix=_suffix,), Operator.Word), + (words([ + 'append', 'at', 'case', 'chain', 'close', 'copy', 'create', 'cursor', + 'data', 'delete', 'dir', 'do', 'elif', 'else', 'end', 'endcase', 'endif', + 'endfor', 'endloop', 'endtrap', 'endwhile', 'exec', 'exit', 'file', + 'for', 'goto', 'handler', 'if', 'input', 'let', 'loop', 'mount', 'null', + 'of', 'open', 'otherwise', 'output', 'page', 'pass', 'poke', 'print', + 'random', 'read', 'repeat', 'report', 'return', 'rename', 'restore', + 'select', 'step', 'stop', 'sys', 'then', 'to', 'trap', 'unit', 'unit$', + 'until', 'using', 'when', 'while', 'write', 'zone'], suffix=_suffix), + Keyword.Reserved), + (words([ + 'closed', 'dim', 'endfunc', 'endproc', 'external', 'func', 'import', + 'proc', 'ref', 'use'], suffix=_suffix), Keyword.Declaration), + (words([ + 'abs', 'atn', 'chr$', 'cos', 'eod', 'eof', 'err', 'errfile', 'errtext', + 'esc', 'exp', 'int', 'key$', 'len', 'log', 'ord', 'peek', 'randomize', + 'rnd', 'sgn', 'sin', 'spc$', 'sqr', 'status$', 'str$', 'tab', 'tan', + 'time', 'val'], suffix=_suffix), Name.Builtin), + (words(['false', 'pi', 'true'], suffix=_suffix), Keyword.Constant), + (r'"', String, 'string'), + (_identifier + r":(?=[ \n/])", Name.Label), + (_identifier + r"[$#]?", Name), + (r'%[01]+', Number.Bin), + (r'\$[0-9a-f]+', Number.Hex), + (r'\d*\.\d*(e[-+]?\d+)?', Number.Float), + (r'\d+', Number.Integer), + (r'[(),:;]', Punctuation), + ], + 'string': [ + (r'[^"]+', String), + (r'"[0-9]*"', String.Escape), + (r'"', String, '#pop'), + ], + } diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/compiled.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/compiled.py new file mode 100644 index 0000000000000000000000000000000000000000..fb0a70364dd8b13555b74b31eafcb738972e16b7 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/compiled.py @@ -0,0 +1,35 @@ +""" + pygments.lexers.compiled + ~~~~~~~~~~~~~~~~~~~~~~~~ + + Just export lexer classes previously contained in this module. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +# ruff: noqa: F401 +from pygments.lexers.jvm import JavaLexer, ScalaLexer +from pygments.lexers.c_cpp import CLexer, CppLexer +from pygments.lexers.d import DLexer +from pygments.lexers.objective import ObjectiveCLexer, \ + ObjectiveCppLexer, LogosLexer +from pygments.lexers.go import GoLexer +from pygments.lexers.rust import RustLexer +from pygments.lexers.c_like import ECLexer, ValaLexer, CudaLexer +from pygments.lexers.pascal import DelphiLexer, PortugolLexer, Modula2Lexer +from pygments.lexers.ada import AdaLexer +from pygments.lexers.business import CobolLexer, CobolFreeformatLexer +from pygments.lexers.fortran import FortranLexer +from pygments.lexers.prolog import PrologLexer +from pygments.lexers.python import CythonLexer +from pygments.lexers.graphics import GLShaderLexer +from pygments.lexers.ml import OcamlLexer +from pygments.lexers.basic import BlitzBasicLexer, BlitzMaxLexer, MonkeyLexer +from pygments.lexers.dylan import DylanLexer, DylanLidLexer, DylanConsoleLexer +from pygments.lexers.ooc import OocLexer +from pygments.lexers.felix import FelixLexer +from pygments.lexers.nimrod import NimrodLexer +from pygments.lexers.crystal import CrystalLexer + +__all__ = [] diff --git a/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/configs.py b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/configs.py new file mode 100644 index 0000000000000000000000000000000000000000..9f0bb447db9f3c852908378545b1c1344657b845 --- /dev/null +++ b/HAI-Sidecar/.venv/lib/python3.12/site-packages/pygments/lexers/configs.py @@ -0,0 +1,1499 @@ +""" + pygments.lexers.configs + ~~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for configuration file formats. + + :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import ExtendedRegexLexer, RegexLexer, default, words, \ + bygroups, include, using, this, line_re +from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace, Literal, Error, Generic +from pygments.lexers.shell import BashLexer +from pygments.lexers.data import JsonLexer + +__all__ = ['IniLexer', 'SystemdLexer', 'DesktopLexer', 'RegeditLexer', 'PropertiesLexer', + 'KconfigLexer', 'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer', + 'NginxConfLexer', 'LighttpdConfLexer', 'DockerLexer', + 'TerraformLexer', 'TermcapLexer', 'TerminfoLexer', + 'PkgConfigLexer', 'PacmanConfLexer', 'AugeasLexer', 'TOMLLexer', + 'NestedTextLexer', 'SingularityLexer', 'UnixConfigLexer', + 'CaddyfileLexer'] + + +class IniLexer(RegexLexer): + """ + Lexer for configuration files in INI style. + """ + + name = 'INI' + aliases = ['ini', 'cfg', 'dosini'] + filenames = [ + '*.ini', '*.cfg', '*.inf', '.editorconfig', + ] + mimetypes = ['text/x-ini', 'text/inf'] + url = 'https://en.wikipedia.org/wiki/INI_file' + version_added = '' + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'[;#].*', Comment.Single), + (r'(\[.*?\])([ \t]*)$', bygroups(Keyword, Whitespace)), + (r'''(.*?)([ \t]*)([=:])([ \t]*)(["'])''', + bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String), + "quoted_value"), + (r'(.*?)([ \t]*)([=:])([ \t]*)([^;#\n]*)(\\)(\s+)', + bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String, + Text, Whitespace), + "value"), + (r'(.*?)([ \t]*)([=:])([ \t]*)([^ ;#\n]*(?: +[^ ;#\n]+)*)', + bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String)), + # standalone option, supported by some INI parsers + (r'(.+?)$', Name.Attribute), + ], + 'quoted_value': [ + (r'''([^"'\n]*)(["'])(\s*)''', + bygroups(String, String, Whitespace), "#pop"), + (r'[;#].*', Comment.Single), + (r'$', String, "#pop"), + ], + 'value': [ # line continuation + (r'\s+', Whitespace), + (r'(\s*)(.*)(\\)([ \t]*)', + bygroups(Whitespace, String, Text, Whitespace)), + (r'.*$', String, "#pop"), + ], + } + + def analyse_text(text): + npos = text.find('\n') + if npos < 3: + return False + if text[0] == '[' and text[npos-1] == ']': + return 0.8 + return False + + +class DesktopLexer(RegexLexer): + """ + Lexer for .desktop files. + """ + + name = 'Desktop file' + url = "https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" + aliases = ['desktop'] + filenames = ['*.desktop'] + mimetypes = ['application/x-desktop'] + version_added = '2.16' + + tokens = { + 'root': [ + (r'^[ \t]*\n', Whitespace), + (r'^(#.*)(\n)', bygroups(Comment.Single, Whitespace)), + (r'(\[[^\]\n]+\])(\n)', bygroups(Keyword, Whitespace)), + (r'([-A-Za-z0-9]+)(\[[^\] \t=]+\])?([ \t]*)(=)([ \t]*)([^\n]*)([ \t\n]*\n)', + bygroups(Name.Attribute, Name.Namespace, Whitespace, Operator, Whitespace, String, Whitespace)), + ], + } + + def analyse_text(text): + if text.startswith("[Desktop Entry]"): + return 1.0 + if re.search(r"^\[Desktop Entry\][ \t]*$", text[:500], re.MULTILINE) is not None: + return 0.9 + return 0.0 + + +class SystemdLexer(RegexLexer): + """ + Lexer for systemd unit files. + """ + + name = 'Systemd' + url = "https://www.freedesktop.org/software/systemd/man/systemd.syntax.html" + aliases = ['systemd'] + filenames = [ + '*.service', '*.socket', '*.device', '*.mount', '*.automount', + '*.swap', '*.target', '*.path', '*.timer', '*.slice', '*.scope', + ] + version_added = '2.16' + + tokens = { + 'root': [ + (r'^[ \t]*\n', Whitespace), + (r'^([;#].*)(\n)', bygroups(Comment.Single, Whitespace)), + (r'(\[[^\]\n]+\])(\n)', bygroups(Keyword, Whitespace)), + (r'([^=]+)([ \t]*)(=)([ \t]*)([^\n]*)(\\)(\n)', + bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String, + Text, Whitespace), + "value"), + (r'([^=]+)([ \t]*)(=)([ \t]*)([^\n]*)(\n)', + bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String, Whitespace)), + ], + 'value': [ + # line continuation + (r'^([;#].*)(\n)', bygroups(Comment.Single, Whitespace)), + (r'([ \t]*)([^\n]*)(\\)(\n)', + bygroups(Whitespace, String, Text, Whitespace)), + (r'([ \t]*)([^\n]*)(\n)', + bygroups(Whitespace, String, Whitespace), "#pop"), + ], + } + + def analyse_text(text): + if text.startswith("[Unit]"): + return 1.0 + if re.search(r"^\[Unit\][ \t]*$", text[:500], re.MULTILINE) is not None: + return 0.9 + return 0.0 + + +class RegeditLexer(RegexLexer): + """ + Lexer for Windows Registry files produced by regedit. + """ + + name = 'reg' + url = 'http://en.wikipedia.org/wiki/Windows_Registry#.REG_files' + aliases = ['registry'] + filenames = ['*.reg'] + mimetypes = ['text/x-windows-registry'] + version_added = '1.6' + + tokens = { + 'root': [ + (r'Windows Registry Editor.*', Text), + (r'\s+', Whitespace), + (r'[;#].*', Comment.Single), + (r'(\[)(-?)(HKEY_[A-Z_]+)(.*?\])$', + bygroups(Keyword, Operator, Name.Builtin, Keyword)), + # String keys, which obey somewhat normal escaping + (r'("(?:\\"|\\\\|[^"])+")([ \t]*)(=)([ \t]*)', + bygroups(Name.Attribute, Whitespace, Operator, Whitespace), + 'value'), + # Bare keys (includes @) + (r'(.*?)([ \t]*)(=)([ \t]*)', + bygroups(Name.Attribute, Whitespace, Operator, Whitespace), + 'value'), + ], + 'value': [ + (r'-', Operator, '#pop'), # delete value + (r'(dword|hex(?:\([0-9a-fA-F]\))?)(:)([0-9a-fA-F,]+)', + bygroups(Name.Variable, Punctuation, Number), '#pop'), + # As far as I know, .reg files do not support line continuation. + (r'.+', String, '#pop'), + default('#pop'), + ] + } + + def analyse_text(text): + return text.startswith('Windows Registry Editor') + + +class PropertiesLexer(RegexLexer): + """ + Lexer for configuration files in Java's properties format. + + Note: trailing whitespace counts as part of the value as per spec + """ + + name = 'Properties' + aliases = ['properties', 'jproperties'] + filenames = ['*.properties'] + mimetypes = ['text/x-java-properties'] + url = 'https://en.wikipedia.org/wiki/.properties' + version_added = '1.4' + + tokens = { + 'root': [ + # comments + (r'[!#].*|/{2}.*', Comment.Single), + # ending a comment or whitespace-only line + (r'\n', Whitespace), + # eat whitespace at the beginning of a line + (r'^[^\S\n]+', Whitespace), + # start lexing a key + default('key'), + ], + 'key': [ + # non-escaped key characters + (r'[^\\:=\s]+', Name.Attribute), + # escapes + include('escapes'), + # separator is the first non-escaped whitespace or colon or '=' on the line; + # if it's whitespace, = and : are gobbled after it + (r'([^\S\n]*)([:=])([^\S\n]*)', + bygroups(Whitespace, Operator, Whitespace), + ('#pop', 'value')), + (r'[^\S\n]+', Whitespace, ('#pop', 'value')), + # maybe we got no value after all + (r'\n', Whitespace, '#pop'), + ], + 'value': [ + # non-escaped value characters + (r'[^\\\n]+', String), + # escapes + include('escapes'), + # end the value on an unescaped newline + (r'\n', Whitespace, '#pop'), + ], + 'escapes': [ + # line continuations; these gobble whitespace at the beginning of the next line + (r'(\\\n)([^\S\n]*)', bygroups(String.Escape, Whitespace)), + # other escapes + (r'\\([\s\S])', String.Escape), + ], + } + + +def _rx_indent(level): + # Kconfig *always* interprets a tab as 8 spaces, so this is the default. + # Edit this if you are in an environment where KconfigLexer gets expanded + # input (tabs expanded to spaces) and the expansion tab width is != 8, + # e.g. in connection with Trac (trac.ini, [mimeviewer], tab_width). + # Value range here is 2 <= {tab_width} <= 8. + tab_width = 8 + # Regex matching a given indentation {level}, assuming that indentation is + # a multiple of {tab_width}. In other cases there might be problems. + if tab_width == 2: + space_repeat = '+' + else: + space_repeat = '{1,%d}' % (tab_width - 1) + if level == 1: + level_repeat = '' + else: + level_repeat = f'{{{level}}}' + return rf'(?:\t| {space_repeat}\t| {{{tab_width}}}){level_repeat}.*\n' + + +class KconfigLexer(RegexLexer): + """ + For Linux-style Kconfig files. + """ + + name = 'Kconfig' + aliases = ['kconfig', 'menuconfig', 'linux-config', 'kernel-config'] + version_added = '1.6' + # Adjust this if new kconfig file names appear in your environment + filenames = ['Kconfig*', '*Config.in*', 'external.in*', + 'standard-modules.in'] + mimetypes = ['text/x-kconfig'] + url = 'https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html' + + # No re.MULTILINE, indentation-aware help text needs line-by-line handling + flags = 0 + + def call_indent(level): + # If indentation >= {level} is detected, enter state 'indent{level}' + return (_rx_indent(level), String.Doc, f'indent{level}') + + def do_indent(level): + # Print paragraphs of indentation level >= {level} as String.Doc, + # ignoring blank lines. Then return to 'root' state. + return [ + (_rx_indent(level), String.Doc), + (r'\s*\n', Text), + default('#pop:2') + ] + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'#.*?\n', Comment.Single), + (words(( + 'mainmenu', 'config', 'menuconfig', 'choice', 'endchoice', + 'comment', 'menu', 'endmenu', 'visible if', 'if', 'endif', + 'source', 'prompt', 'select', 'depends on', 'default', + 'range', 'option'), suffix=r'\b'), + Keyword), + (r'(---help---|help)[\t ]*\n', Keyword, 'help'), + (r'(bool|tristate|string|hex|int|defconfig_list|modules|env)\b', + Name.Builtin), + (r'[!=&|]', Operator), + (r'[()]', Punctuation), + (r'[0-9]+', Number.Integer), + (r"'(''|[^'])*'", String.Single), + (r'"(""|[^"])*"', String.Double), + (r'\S+', Text), + ], + # Help text is indented, multi-line and ends when a lower indentation + # level is detected. + 'help': [ + # Skip blank lines after help token, if any + (r'\s*\n', Text), + # Determine the first help line's indentation level heuristically(!). + # Attention: this is not perfect, but works for 99% of "normal" + # indentation schemes up to a max. indentation level of 7. + call_indent(7), + call_indent(6), + call_indent(5), + call_indent(4), + call_indent(3), + call_indent(2), + call_indent(1), + default('#pop'), # for incomplete help sections without text + ], + # Handle text for indentation levels 7 to 1 + 'indent7': do_indent(7), + 'indent6': do_indent(6), + 'indent5': do_indent(5), + 'indent4': do_indent(4), + 'indent3': do_indent(3), + 'indent2': do_indent(2), + 'indent1': do_indent(1), + } + + +class Cfengine3Lexer(RegexLexer): + """ + Lexer for CFEngine3 policy files. + """ + + name = 'CFEngine3' + url = 'http://cfengine.org' + aliases = ['cfengine3', 'cf3'] + filenames = ['*.cf'] + mimetypes = [] + version_added = '1.5' + + tokens = { + 'root': [ + (r'#.*?\n', Comment), + (r'(body)(\s+)(\S+)(\s+)(control)', + bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword)), + (r'(body|bundle)(\s+)(\S+)(\s+)(\w+)(\()', + bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Function, Punctuation), + 'arglist'), + (r'(body|bundle)(\s+)(\S+)(\s+)(\w+)', + bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Function)), + (r'(")([^"]+)(")(\s+)(string|slist|int|real)(\s*)(=>)(\s*)', + bygroups(Punctuation, Name.Variable, Punctuation, + Whitespace, Keyword.Type, Whitespace, Operator, Whitespace)), + (r'(\S+)(\s*)(=>)(\s*)', + bygroups(Keyword.Reserved, Whitespace, Operator, Text)), + (r'"', String, 'string'), + (r'(\w+)(\()', bygroups(Name.Function, Punctuation)), + (r'([\w.!&|()]+)(::)', bygroups(Name.Class, Punctuation)), + (r'(\w+)(:)', bygroups(Keyword.Declaration, Punctuation)), + (r'@[{(][^)}]+[})]', Name.Variable), + (r'[(){},;]', Punctuation), + (r'=>', Operator), + (r'->', Operator), + (r'\d+\.\d+', Number.Float), + (r'\d+', Number.Integer), + (r'\w+', Name.Function), + (r'\s+', Whitespace), + ], + 'string': [ + (r'\$[{(]', String.Interpol, 'interpol'), + (r'\\.', String.Escape), + (r'"', String, '#pop'), + (r'\n', String), + (r'.', String), + ], + 'interpol': [ + (r'\$[{(]', String.Interpol, '#push'), + (r'[})]', String.Interpol, '#pop'), + (r'[^${()}]+', String.Interpol), + ], + 'arglist': [ + (r'\)', Punctuation, '#pop'), + (r',', Punctuation), + (r'\w+', Name.Variable), + (r'\s+', Whitespace), + ], + } + + +class ApacheConfLexer(RegexLexer): + """ + Lexer for configuration files following the Apache config file + format. + """ + + name = 'ApacheConf' + aliases = ['apacheconf', 'aconf', 'apache'] + filenames = ['.htaccess', 'apache.conf', 'apache2.conf'] + mimetypes = ['text/x-apacheconf'] + url = 'https://httpd.apache.org/docs/current/configuring.html' + version_added = '0.6' + flags = re.MULTILINE | re.IGNORECASE + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'#(.*\\\n)+.*$|(#.*?)$', Comment), + (r'(<[^\s>/][^\s>]*)(?:(\s+)(.*))?(>)', + bygroups(Name.Tag, Whitespace, String, Name.Tag)), + (r'(]+)(>)', + bygroups(Name.Tag, Name.Tag)), + (r'[a-z]\w*', Name.Builtin, 'value'), + (r'\.+', Text), + ], + 'value': [ + (r'\\\n', Text), + (r'\n+', Whitespace, '#pop'), + (r'\\', Text), + (r'[^\S\n]+', Whitespace), + (r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number), + (r'\d+', Number), + (r'/([*a-z0-9][*\w./-]+)', String.Other), + (r'(on|off|none|any|all|double|email|dns|min|minimal|' + r'os|productonly|full|emerg|alert|crit|error|warn|' + r'notice|info|debug|registry|script|inetd|standalone|' + r'user|group)\b', Keyword), + (r'"([^"\\]*(?:\\([\s\S])[^"\\]*)*)"', String.Double), + (r'[^\s"\\]+', Text) + ], + } + + +class SquidConfLexer(RegexLexer): + """ + Lexer for squid configuration files. + """ + + name = 'SquidConf' + url = 'http://www.squid-cache.org/' + aliases = ['squidconf', 'squid.conf', 'squid'] + filenames = ['squid.conf'] + mimetypes = ['text/x-squidconf'] + version_added = '0.9' + flags = re.IGNORECASE + + keywords = ( + "access_log", "acl", "always_direct", "announce_host", + "announce_period", "announce_port", "announce_to", "anonymize_headers", + "append_domain", "as_whois_server", "auth_param_basic", + "authenticate_children", "authenticate_program", "authenticate_ttl", + "broken_posts", "buffered_logs", "cache_access_log", "cache_announce", + "cache_dir", "cache_dns_program", "cache_effective_group", + "cache_effective_user", "cache_host", "cache_host_acl", + "cache_host_domain", "cache_log", "cache_mem", "cache_mem_high", + "cache_mem_low", "cache_mgr", "cachemgr_passwd", "cache_peer", + "cache_peer_access", "cache_replacement_policy", "cache_stoplist", + "cache_stoplist_pattern", "cache_store_log", "cache_swap", + "cache_swap_high", "cache_swap_log", "cache_swap_low", "client_db", + "client_lifetime", "client_netmask", "connect_timeout", "coredump_dir", + "dead_peer_timeout", "debug_options", "delay_access", "delay_class", + "delay_initial_bucket_level", "delay_parameters", "delay_pools", + "deny_info", "dns_children", "dns_defnames", "dns_nameservers", + "dns_testnames", "emulate_httpd_log", "err_html_text", + "fake_user_agent", "firewall_ip", "forwarded_for", "forward_snmpd_port", + "fqdncache_size", "ftpget_options", "ftpget_program", "ftp_list_width", + "ftp_passive", "ftp_user", "half_closed_clients", "header_access", + "header_replace", "hierarchy_stoplist", "high_response_time_warning", + "high_page_fault_warning", "hosts_file", "htcp_port", "http_access", + "http_anonymizer", "httpd_accel", "httpd_accel_host", + "httpd_accel_port", "httpd_accel_uses_host_header", + "httpd_accel_with_proxy", "http_port", "http_reply_access", + "icp_access", "icp_hit_stale", "icp_port", "icp_query_timeout", + "ident_lookup", "ident_lookup_access", "ident_timeout", + "incoming_http_average", "incoming_icp_average", "inside_firewall", + "ipcache_high", "ipcache_low", "ipcache_size", "local_domain", + "local_ip", "logfile_rotate", "log_fqdn", "log_icp_queries", + "log_mime_hdrs", "maximum_object_size", "maximum_single_addr_tries", + "mcast_groups", "mcast_icp_query_timeout", "mcast_miss_addr", + "mcast_miss_encode_key", "mcast_miss_port", "memory_pools", + "memory_pools_limit", "memory_replacement_policy", "mime_table", + "min_http_poll_cnt", "min_icp_poll_cnt", "minimum_direct_hops", + "minimum_object_size", "minimum_retry_timeout", "miss_access", + "negative_dns_ttl", "negative_ttl", "neighbor_timeout", + "neighbor_type_domain", "netdb_high", "netdb_low", "netdb_ping_period", + "netdb_ping_rate", "never_direct", "no_cache", "passthrough_proxy", + "pconn_timeout", "pid_filename", "pinger_program", "positive_dns_ttl", + "prefer_direct", "proxy_auth", "proxy_auth_realm", "query_icmp", + "quick_abort", "quick_abort_max", "quick_abort_min", + "quick_abort_pct", "range_offset_limit", "read_timeout", + "redirect_children", "redirect_program", + "redirect_rewrites_host_header", "reference_age", + "refresh_pattern", "reload_into_ims", "request_body_max_size", + "request_size", "request_timeout", "shutdown_lifetime", + "single_parent_bypass", "siteselect_timeout", "snmp_access", + "snmp_incoming_address", "snmp_port", "source_ping", "ssl_proxy", + "store_avg_object_size", "store_objects_per_bucket", + "strip_query_terms", "swap_level1_dirs", "swap_level2_dirs", + "tcp_incoming_address", "tcp_outgoing_address", "tcp_recv_bufsize", + "test_reachability", "udp_hit_obj", "udp_hit_obj_size", + "udp_incoming_address", "udp_outgoing_address", "unique_hostname", + "unlinkd_program", "uri_whitespace", "useragent_log", + "visible_hostname", "wais_relay", "wais_relay_host", "wais_relay_port", + ) + + opts = ( + "proxy-only", "weight", "ttl", "no-query", "default", "round-robin", + "multicast-responder", "on", "off", "all", "deny", "allow", "via", + "parent", "no-digest", "heap", "lru", "realm", "children", "q1", "q2", + "credentialsttl", "none", "disable", "offline_toggle", "diskd", + ) + + actions = ( + "shutdown", "info", "parameter", "server_list", "client_list", + r'squid.conf', + ) + + actions_stats = ( + "objects", "vm_objects", "utilization", "ipcache", "fqdncache", "dns", + "redirector", "io", "reply_headers", "filedescriptors", "netdb", + ) + + actions_log = ("status", "enable", "disable", "clear") + + acls = ( + "url_regex", "urlpath_regex", "referer_regex", "port", "proto", + "req_mime_type", "rep_mime_type", "method", "browser", "user", "src", + "dst", "time", "dstdomain", "ident", "snmp_community", + ) + + ipv4_group = r'(\d+|0x[0-9a-f]+)' + ipv4 = rf'({ipv4_group}(\.{ipv4_group}){{3}})' + ipv6_group = r'([0-9a-f]{0,4})' + ipv6 = rf'({ipv6_group}(:{ipv6_group}){{1,7}})' + bare_ip = rf'({ipv4}|{ipv6})' + # XXX: /integer is a subnet mark, but what is /IP ? + # There is no test where it is used. + ip = rf'{bare_ip}(/({bare_ip}|\d+))?' + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'#', Comment, 'comment'), + (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword), + (words(opts, prefix=r'\b', suffix=r'\b'), Name.Constant), + # Actions + (words(actions, prefix=r'\b', suffix=r'\b'), String), + (words(actions_stats, prefix=r'stats/', suffix=r'\b'), String), + (words(actions_log, prefix=r'log/', suffix=r'='), String), + (words(acls, prefix=r'\b', suffix=r'\b'), Keyword), + (ip, Number.Float), + (r'(?:\b\d+\b(?:-\b\d+|%)?)', Number), + (r'\S+', Text), + ], + 'comment': [ + (r'\s*TAG:.*', String.Escape, '#pop'), + (r'.+', Comment, '#pop'), + default('#pop'), + ], + } + + +class NginxConfLexer(RegexLexer): + """ + Lexer for Nginx configuration files. + """ + name = 'Nginx configuration file' + url = 'http://nginx.net/' + aliases = ['nginx'] + filenames = ['nginx.conf'] + mimetypes = ['text/x-nginx-conf'] + version_added = '0.11' + + tokens = { + 'root': [ + (r'(include)(\s+)([^\s;]+)', bygroups(Keyword, Whitespace, Name)), + (r'[^\s;#]+', Keyword, 'stmt'), + include('base'), + ], + 'block': [ + (r'\}', Punctuation, '#pop:2'), + (r'[^\s;#]+', Keyword.Namespace, 'stmt'), + include('base'), + ], + 'stmt': [ + (r'\{', Punctuation, 'block'), + (r';', Punctuation, '#pop'), + include('base'), + ], + 'base': [ + (r'#.*\n', Comment.Single), + (r'on|off', Name.Constant), + (r'\$[^\s;#()]+', Name.Variable), + (r'([a-z0-9.-]+)(:)([0-9]+)', + bygroups(Name, Punctuation, Number.Integer)), + (r'[a-z-]+/[a-z-+]+', String), # mimetype + # (r'[a-zA-Z._-]+', Keyword), + (r'[0-9]+[km]?\b', Number.Integer), + (r'(~)(\s*)([^\s{]+)', bygroups(Punctuation, Whitespace, String.Regex)), + (r'[:=~]', Punctuation), + (r'[^\s;#{}$]+', String), # catch all + (r'/[^\s;#]*', Name), # pathname + (r'\s+', Whitespace), + (r'[$;]', Text), # leftover characters + ], + } + + +class LighttpdConfLexer(RegexLexer): + """ + Lexer for Lighttpd configuration files. + """ + name = 'Lighttpd configuration file' + url = 'http://lighttpd.net/' + aliases = ['lighttpd', 'lighty'] + filenames = ['lighttpd.conf'] + mimetypes = ['text/x-lighttpd-conf'] + version_added = '0.11' + + tokens = { + 'root': [ + (r'#.*\n', Comment.Single), + (r'/\S*', Name), # pathname + (r'[a-zA-Z._-]+', Keyword), + (r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number), + (r'[0-9]+', Number), + (r'=>|=~|\+=|==|=|\+', Operator), + (r'\$[A-Z]+', Name.Builtin), + (r'[(){}\[\],]', Punctuation), + (r'"([^"\\]*(?:\\.[^"\\]*)*)"', String.Double), + (r'\s+', Whitespace), + ], + + } + + +class DockerLexer(RegexLexer): + """ + Lexer for Docker configuration files. + """ + name = 'Docker' + url = 'http://docker.io' + aliases = ['docker', 'dockerfile'] + filenames = ['Dockerfile', '*.docker'] + mimetypes = ['text/x-dockerfile-config'] + version_added = '2.0' + + _keywords = (r'(?:MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)') + _bash_keywords = (r'(?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY)') + _lb = r'(?:\s*\\?\s*)' # dockerfile line break regex + flags = re.IGNORECASE | re.MULTILINE + + tokens = { + 'root': [ + (r'#.*', Comment), + (r'(FROM)([ \t]*)(\S*)([ \t]*)(?:(AS)([ \t]*)(\S*))?', + bygroups(Keyword, Whitespace, String, Whitespace, Keyword, Whitespace, String)), + (rf'(ONBUILD)(\s+)({_lb})', bygroups(Keyword, Whitespace, using(BashLexer))), + (rf'(HEALTHCHECK)(\s+)(({_lb}--\w+=\w+{_lb})*)', + bygroups(Keyword, Whitespace, using(BashLexer))), + (rf'(VOLUME|ENTRYPOINT|CMD|SHELL)(\s+)({_lb})(\[.*?\])', + bygroups(Keyword, Whitespace, using(BashLexer), using(JsonLexer))), + (rf'(LABEL|ENV|ARG)(\s+)(({_lb}\w+=\w+{_lb})*)', + bygroups(Keyword, Whitespace, using(BashLexer))), + (rf'({_keywords}|VOLUME)\b(\s+)(.*)', bygroups(Keyword, Whitespace, String)), + (rf'({_bash_keywords})(\s+)', bygroups(Keyword, Whitespace)), + (r'(.*\\\n)*.+', using(BashLexer)), + ] + } + + +class TerraformLexer(ExtendedRegexLexer): + """ + Lexer for terraformi ``.tf`` files. + """ + + name = 'Terraform' + url = 'https://www.terraform.io/' + aliases = ['terraform', 'tf', 'hcl'] + filenames = ['*.tf', '*.hcl'] + mimetypes = ['application/x-tf', 'application/x-terraform'] + version_added = '2.1' + + classes = ('backend', 'data', 'module', 'output', 'provider', + 'provisioner', 'resource', 'variable') + classes_re = "({})".format(('|').join(classes)) + + types = ('string', 'number', 'bool', 'list', 'tuple', 'map', 'set', 'object', 'null') + + numeric_functions = ('abs', 'ceil', 'floor', 'log', 'max', + 'mix', 'parseint', 'pow', 'signum') + + string_functions = ('chomp', 'format', 'formatlist', 'indent', + 'join', 'lower', 'regex', 'regexall', 'replace', + 'split', 'strrev', 'substr', 'title', 'trim', + 'trimprefix', 'trimsuffix', 'trimspace', 'upper' + ) + + collection_functions = ('alltrue', 'anytrue', 'chunklist', 'coalesce', + 'coalescelist', 'compact', 'concat', 'contains', + 'distinct', 'element', 'flatten', 'index', 'keys', + 'length', 'list', 'lookup', 'map', 'matchkeys', + 'merge', 'range', 'reverse', 'setintersection', + 'setproduct', 'setsubtract', 'setunion', 'slice', + 'sort', 'sum', 'transpose', 'values', 'zipmap' + ) + + encoding_functions = ('base64decode', 'base64encode', 'base64gzip', + 'csvdecode', 'jsondecode', 'jsonencode', 'textdecodebase64', + 'textencodebase64', 'urlencode', 'yamldecode', 'yamlencode') + + filesystem_functions = ('abspath', 'dirname', 'pathexpand', 'basename', + 'file', 'fileexists', 'fileset', 'filebase64', 'templatefile') + + date_time_functions = ('formatdate', 'timeadd', 'timestamp') + + hash_crypto_functions = ('base64sha256', 'base64sha512', 'bcrypt', 'filebase64sha256', + 'filebase64sha512', 'filemd5', 'filesha1', 'filesha256', 'filesha512', + 'md5', 'rsadecrypt', 'sha1', 'sha256', 'sha512', 'uuid', 'uuidv5') + + ip_network_functions = ('cidrhost', 'cidrnetmask', 'cidrsubnet', 'cidrsubnets') + + type_conversion_functions = ('can', 'defaults', 'tobool', 'tolist', 'tomap', + 'tonumber', 'toset', 'tostring', 'try') + + builtins = numeric_functions + string_functions + collection_functions + encoding_functions +\ + filesystem_functions + date_time_functions + hash_crypto_functions + ip_network_functions +\ + type_conversion_functions + builtins_re = "({})".format(('|').join(builtins)) + + def heredoc_callback(self, match, ctx): + # Parse a terraform heredoc + # match: 1 = <<[-]?, 2 = name 3 = rest of line + + start = match.start(1) + yield start, Operator, match.group(1) # <<[-]? + yield match.start(2), String.Delimiter, match.group(2) # heredoc name + + ctx.pos = match.start(3) + ctx.end = match.end(3) + yield ctx.pos, String.Heredoc, match.group(3) + ctx.pos = match.end() + + hdname = match.group(2) + tolerant = True # leading whitespace is always accepted + + lines = [] + + for match in line_re.finditer(ctx.text, ctx.pos): + if tolerant: + check = match.group().strip() + else: + check = match.group().rstrip() + if check == hdname: + for amatch in lines: + yield amatch.start(), String.Heredoc, amatch.group() + yield match.start(), String.Delimiter, match.group() + ctx.pos = match.end() + break + else: + lines.append(match) + else: + # end of heredoc not found -- error! + for amatch in lines: + yield amatch.start(), Error, amatch.group() + ctx.end = len(ctx.text) + + tokens = { + 'root': [ + include('basic'), + include('whitespace'), + + # Strings + (r'(".*")', bygroups(String.Double)), + + # Constants + (words(('true', 'false'), prefix=r'\b', suffix=r'\b'), Name.Constant), + + # Types + (words(types, prefix=r'\b', suffix=r'\b'), Keyword.Type), + + include('identifier'), + include('punctuation'), + (r'[0-9]+', Number), + ], + 'basic': [ + (r'\s*/\*', Comment.Multiline, 'comment'), + (r'\s*(#|//).*\n', Comment.Single), + include('whitespace'), + + # e.g. terraform { + # e.g. egress { + (r'(\s*)([0-9a-zA-Z-_]+)(\s*)(=?)(\s*)(\{)', + bygroups(Whitespace, Name.Builtin, Whitespace, Operator, Whitespace, Punctuation)), + + # Assignment with attributes, e.g. something = ... + (r'(\s*)([0-9a-zA-Z-_]+)(\s*)(=)(\s*)', + bygroups(Whitespace, Name.Attribute, Whitespace, Operator, Whitespace)), + + # Assignment with environment variables and similar, e.g. "something" = ... + # or key value assignment, e.g. "SlotName" : ... + (r'(\s*)("\S+")(\s*)([=:])(\s*)', + bygroups(Whitespace, Literal.String.Double, Whitespace, Operator, Whitespace)), + + # Functions, e.g. jsonencode(element("value")) + (builtins_re + r'(\()', bygroups(Name.Function, Punctuation)), + + # List of attributes, e.g. ignore_changes = [last_modified, filename] + (r'(\[)([a-z_,\s]+)(\])', bygroups(Punctuation, Name.Builtin, Punctuation)), + + # e.g. resource "aws_security_group" "allow_tls" { + # e.g. backend "consul" { + (classes_re + r'(\s+)("[0-9a-zA-Z-_]+")?(\s*)("[0-9a-zA-Z-_]+")(\s+)(\{)', + bygroups(Keyword.Reserved, Whitespace, Name.Class, Whitespace, Name.Variable, Whitespace, Punctuation)), + + # here-doc style delimited strings + (r'(<<-?)\s*([a-zA-Z_]\w*)(.*?\n)', heredoc_callback), + ], + 'identifier': [ + (r'\b(var\.[0-9a-zA-Z-_\.\[\]]+)\b', bygroups(Name.Variable)), + (r'\b([0-9a-zA-Z-_\[\]]+\.[0-9a-zA-Z-_\.\[\]]+)\b', + bygroups(Name.Variable)), + ], + 'punctuation': [ + (r'[\[\]()\{\},.?:!=]', Punctuation), + ], + 'comment': [ + (r'[^*/]', Comment.Multiline), + (r'/\*', Comment.Multiline, '#push'), + (r'\*/', Comment.Multiline, '#pop'), + (r'[*/]', Comment.Multiline) + ], + 'whitespace': [ + (r'\n', Whitespace), + (r'\s+', Whitespace), + (r'(\\)(\n)', bygroups(Text, Whitespace)), + ], + } + + +class TermcapLexer(RegexLexer): + """ + Lexer for termcap database source. + + This is very simple and minimal. + """ + name = 'Termcap' + aliases = ['termcap'] + filenames = ['termcap', 'termcap.src'] + mimetypes = [] + url = 'https://en.wikipedia.org/wiki/Termcap' + version_added = '2.1' + + # NOTE: + # * multiline with trailing backslash + # * separator is ':' + # * to embed colon as data, we must use \072 + # * space after separator is not allowed (mayve) + tokens = { + 'root': [ + (r'^#.*', Comment), + (r'^[^\s#:|]+', Name.Tag, 'names'), + (r'\s+', Whitespace), + ], + 'names': [ + (r'\n', Whitespace, '#pop'), + (r':', Punctuation, 'defs'), + (r'\|', Punctuation), + (r'[^:|]+', Name.Attribute), + ], + 'defs': [ + (r'(\\)(\n[ \t]*)', bygroups(Text, Whitespace)), + (r'\n[ \t]*', Whitespace, '#pop:2'), + (r'(#)([0-9]+)', bygroups(Operator, Number)), + (r'=', Operator, 'data'), + (r':', Punctuation), + (r'[^\s:=#]+', Name.Class), + ], + 'data': [ + (r'\\072', Literal), + (r':', Punctuation, '#pop'), + (r'[^:\\]+', Literal), # for performance + (r'.', Literal), + ], + } + + +class TerminfoLexer(RegexLexer): + """ + Lexer for terminfo database source. + + This is very simple and minimal. + """ + name = 'Terminfo' + aliases = ['terminfo'] + filenames = ['terminfo', 'terminfo.src'] + mimetypes = [] + url = 'https://en.wikipedia.org/wiki/Terminfo' + version_added = '2.1' + + # NOTE: + # * multiline with leading whitespace + # * separator is ',' + # * to embed comma as data, we can use \, + # * space after separator is allowed + tokens = { + 'root': [ + (r'^#.*$', Comment), + (r'^[^\s#,|]+', Name.Tag, 'names'), + (r'\s+', Whitespace), + ], + 'names': [ + (r'\n', Whitespace, '#pop'), + (r'(,)([ \t]*)', bygroups(Punctuation, Whitespace), 'defs'), + (r'\|', Punctuation), + (r'[^,|]+', Name.Attribute), + ], + 'defs': [ + (r'\n[ \t]+', Whitespace), + (r'\n', Whitespace, '#pop:2'), + (r'(#)([0-9]+)', bygroups(Operator, Number)), + (r'=', Operator, 'data'), + (r'(,)([ \t]*)', bygroups(Punctuation, Whitespace)), + (r'[^\s,=#]+', Name.Class), + ], + 'data': [ + (r'\\[,\\]', Literal), + (r'(,)([ \t]*)', bygroups(Punctuation, Whitespace), '#pop'), + (r'[^\\,]+', Literal), # for performance + (r'.', Literal), + ], + } + + +class PkgConfigLexer(RegexLexer): + """ + Lexer for pkg-config + (see also `manual page `_). + """ + + name = 'PkgConfig' + url = 'http://www.freedesktop.org/wiki/Software/pkg-config/' + aliases = ['pkgconfig'] + filenames = ['*.pc'] + mimetypes = [] + version_added = '2.1' + + tokens = { + 'root': [ + (r'#.*$', Comment.Single), + + # variable definitions + (r'^(\w+)(=)', bygroups(Name.Attribute, Operator)), + + # keyword lines + (r'^([\w.]+)(:)', + bygroups(Name.Tag, Punctuation), 'spvalue'), + + # variable references + include('interp'), + + # fallback + (r'\s+', Whitespace), + (r'[^${}#=:\n.]+', Text), + (r'.', Text), + ], + 'interp': [ + # you can escape literal "$" as "$$" + (r'\$\$', Text), + + # variable references + (r'\$\{', String.Interpol, 'curly'), + ], + 'curly': [ + (r'\}', String.Interpol, '#pop'), + (r'\w+', Name.Attribute), + ], + 'spvalue': [ + include('interp'), + + (r'#.*$', Comment.Single, '#pop'), + (r'\n', Whitespace, '#pop'), + + # fallback + (r'\s+', Whitespace), + (r'[^${}#\n\s]+', Text), + (r'.', Text), + ], + } + + +class PacmanConfLexer(RegexLexer): + """ + Lexer for pacman.conf. + + Actually, IniLexer works almost fine for this format, + but it yield error token. It is because pacman.conf has + a form without assignment like: + + UseSyslog + Color + TotalDownload + CheckSpace + VerbosePkgLists + + These are flags to switch on. + """ + + name = 'PacmanConf' + url = 'https://www.archlinux.org/pacman/pacman.conf.5.html' + aliases = ['pacmanconf'] + filenames = ['pacman.conf'] + mimetypes = [] + version_added = '2.1' + + tokens = { + 'root': [ + # comment + (r'#.*$', Comment.Single), + + # section header + (r'^(\s*)(\[.*?\])(\s*)$', bygroups(Whitespace, Keyword, Whitespace)), + + # variable definitions + # (Leading space is allowed...) + (r'(\w+)(\s*)(=)', + bygroups(Name.Attribute, Whitespace, Operator)), + + # flags to on + (r'^(\s*)(\w+)(\s*)$', + bygroups(Whitespace, Name.Attribute, Whitespace)), + + # built-in special values + (words(( + '$repo', # repository + '$arch', # architecture + '%o', # outfile + '%u', # url + ), suffix=r'\b'), + Name.Variable), + + # fallback + (r'\s+', Whitespace), + (r'.', Text), + ], + } + + +class AugeasLexer(RegexLexer): + """ + Lexer for Augeas. + """ + name = 'Augeas' + url = 'http://augeas.net' + aliases = ['augeas'] + filenames = ['*.aug'] + version_added = '2.4' + + tokens = { + 'root': [ + (r'(module)(\s*)([^\s=]+)', bygroups(Keyword.Namespace, Whitespace, Name.Namespace)), + (r'(let)(\s*)([^\s=]+)', bygroups(Keyword.Declaration, Whitespace, Name.Variable)), + (r'(del|store|value|counter|seq|key|label|autoload|incl|excl|transform|test|get|put)(\s+)', bygroups(Name.Builtin, Whitespace)), + (r'(\()([^:]+)(\:)(unit|string|regexp|lens|tree|filter)(\))', bygroups(Punctuation, Name.Variable, Punctuation, Keyword.Type, Punctuation)), + (r'\(\*', Comment.Multiline, 'comment'), + (r'[*+\-.;=?|]', Operator), + (r'[()\[\]{}]', Operator), + (r'"', String.Double, 'string'), + (r'\/', String.Regex, 'regex'), + (r'([A-Z]\w*)(\.)(\w+)', bygroups(Name.Namespace, Punctuation, Name.Variable)), + (r'.', Name.Variable), + (r'\s+', Whitespace), + ], + 'string': [ + (r'\\.', String.Escape), + (r'[^"]', String.Double), + (r'"', String.Double, '#pop'), + ], + 'regex': [ + (r'\\.', String.Escape), + (r'[^/]', String.Regex), + (r'\/', String.Regex, '#pop'), + ], + 'comment': [ + (r'[^*)]', Comment.Multiline), + (r'\(\*', Comment.Multiline, '#push'), + (r'\*\)', Comment.Multiline, '#pop'), + (r'[)*]', Comment.Multiline) + ], + } + + +class TOMLLexer(RegexLexer): + """ + Lexer for TOML, a simple language for config files. + """ + + name = 'TOML' + aliases = ['toml'] + filenames = ['*.toml', 'Pipfile', 'poetry.lock'] + mimetypes = ['application/toml'] + url = 'https://toml.io' + version_added = '2.4' + + # Based on the TOML spec: https://toml.io/en/v1.0.0 + + # The following is adapted from CPython's tomllib: + _time = r"\d\d:\d\d(:\d\d(\.\d+)?)?" + _datetime = rf"""(?x) + \d\d\d\d-\d\d-\d\d # date, e.g., 1988-10-27 + ( + [Tt ] {_time} # optional time + ( + [Zz]|[+-]\d\d:\d\d # optional time offset + )? + )? + """ + + tokens = { + 'root': [ + # Note that we make an effort in order to distinguish + # moments at which we're parsing a key and moments at + # which we're parsing a value. In the TOML code + # + # 1234 = 1234 + # + # the first "1234" should be Name, the second Integer. + + # Whitespace + (r'\s+', Whitespace), + + # Comment + (r'#.*', Comment.Single), + + # Assignment keys + include('key'), + + # After "=", find a value + (r'(=)(\s*)', bygroups(Operator, Whitespace), 'value'), + + # Table header + (r'\[\[?', Keyword, 'table-key'), + ], + 'key': [ + # Start of bare key (only ASCII is allowed here). + (r'[A-Za-z0-9_-]+', Name), + # Quoted key + (r'"', String.Double, 'basic-string'), + (r"'", String.Single, 'literal-string'), + # Dots act as separators in keys + (r'\.', Punctuation), + ], + 'table-key': [ + # This is like 'key', but highlights the name components + # and separating dots as Keyword because it looks better + # when the whole table header is Keyword. We do highlight + # strings as strings though. + # Start of bare key (only ASCII is allowed here). + (r'[A-Za-z0-9_-]+', Keyword), + (r'"', String.Double, 'basic-string'), + (r"'", String.Single, 'literal-string'), + (r'\.', Keyword), + (r'\]\]?', Keyword, '#pop'), + + # Inline whitespace allowed + (r'[ \t]+', Whitespace), + ], + 'value': [ + # Datetime, baretime + (_datetime, Literal.Date, '#pop'), + (_time, Literal.Date, '#pop'), + + # Recognize as float if there is a fractional part + # and/or an exponent. + (r'[+-]?\d[0-9_]*[eE][+-]?\d[0-9_]*', Number.Float, '#pop'), + (r'[+-]?\d[0-9_]*\.\d[0-9_]*([eE][+-]?\d[0-9_]*)?', + Number.Float, '#pop'), + + # Infinities and NaN + (r'[+-]?(inf|nan)', Number.Float, '#pop'), + + # Integers + (r'-?0b[01_]+', Number.Bin, '#pop'), + (r'-?0o[0-7_]+', Number.Oct, '#pop'), + (r'-?0x[0-9a-fA-F_]+', Number.Hex, '#pop'), + (r'[+-]?[0-9_]+', Number.Integer, '#pop'), + + # Strings + (r'"""', String.Double, ('#pop', 'multiline-basic-string')), + (r'"', String.Double, ('#pop', 'basic-string')), + (r"'''", String.Single, ('#pop', 'multiline-literal-string')), + (r"'", String.Single, ('#pop', 'literal-string')), + + # Booleans + (r'true|false', Keyword.Constant, '#pop'), + + # Start of array + (r'\[', Punctuation, ('#pop', 'array')), + + # Start of inline table + (r'\{', Punctuation, ('#pop', 'inline-table')), + ], + 'array': [ + # Whitespace, including newlines, is ignored inside arrays, + # and comments are allowed. + (r'\s+', Whitespace), + (r'#.*', Comment.Single), + + # Delimiters + (r',', Punctuation), + + # End of array + (r'\]', Punctuation, '#pop'), + + # Parse a value and come back + default('value'), + ], + 'inline-table': [ + # Whitespace (since TOML 1.1.0, same as in array) + (r'\s+', Whitespace), + (r'#.*', Comment.Single), + + # Keys + include('key'), + + # Values + (r'(=)(\s*)', bygroups(Punctuation, Whitespace), 'value'), + + # Delimiters + (r',', Punctuation), + + # End of inline table + (r'\}', Punctuation, '#pop'), + ], + 'basic-string': [ + (r'"', String.Double, '#pop'), + include('escapes'), + (r'[^"\\]+', String.Double), + ], + 'literal-string': [ + (r".*?'", String.Single, '#pop'), + ], + 'multiline-basic-string': [ + (r'"""', String.Double, '#pop'), + (r'(\\)(\n)', bygroups(String.Escape, Whitespace)), + include('escapes'), + (r'[^"\\]+', String.Double), + (r'"', String.Double), + ], + 'multiline-literal-string': [ + (r"'''", String.Single, '#pop'), + (r"[^']+", String.Single), + (r"'", String.Single), + ], + 'escapes': [ + (r'\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}', String.Escape), + (r'\\.', String.Escape), + ], + } + +class NestedTextLexer(RegexLexer): + """ + Lexer for *NextedText*, a human-friendly data format. + + .. versionchanged:: 2.16 + Added support for *NextedText* v3.0. + """ + + name = 'NestedText' + url = 'https://nestedtext.org' + aliases = ['nestedtext', 'nt'] + filenames = ['*.nt'] + version_added = '2.9' + + tokens = { + 'root': [ + # Comment: # ... + (r'^([ ]*)(#.*)$', bygroups(Whitespace, Comment)), + + # Inline dictionary: {...} + (r'^([ ]*)(\{)', bygroups(Whitespace, Punctuation), 'inline_dict'), + + # Inline list: [...] + (r'^([ ]*)(\[)', bygroups(Whitespace, Punctuation), 'inline_list'), + + # empty multiline string item: > + (r'^([ ]*)(>)$', bygroups(Whitespace, Punctuation)), + + # multiline string item: > ... + (r'^([ ]*)(>)( )(.*?)([ \t]*)$', bygroups(Whitespace, Punctuation, Whitespace, Text, Whitespace)), + + # empty list item: - + (r'^([ ]*)(-)$', bygroups(Whitespace, Punctuation)), + + # list item: - ... + (r'^([ ]*)(-)( )(.*?)([ \t]*)$', bygroups(Whitespace, Punctuation, Whitespace, Text, Whitespace)), + + # empty multiline key item: : + (r'^([ ]*)(:)$', bygroups(Whitespace, Punctuation)), + + # multiline key item: : ... + (r'^([ ]*)(:)( )([^\n]*?)([ \t]*)$', bygroups(Whitespace, Punctuation, Whitespace, Name.Tag, Whitespace)), + + # empty dict key item: ...: + (r'^([ ]*)([^\{\[\s].*?)(:)$', bygroups(Whitespace, Name.Tag, Punctuation)), + + # dict key item: ...: ... + (r'^([ ]*)([^\{\[\s].*?)(:)( )(.*?)([ \t]*)$', bygroups(Whitespace, Name.Tag, Punctuation, Whitespace, Text, Whitespace)), + ], + 'inline_list': [ + include('whitespace'), + (r'[^\{\}\[\],\s]+', Text), + include('inline_value'), + (r',', Punctuation), + (r'\]', Punctuation, '#pop'), + (r'\n', Error, '#pop'), + ], + 'inline_dict': [ + include('whitespace'), + (r'[^\{\}\[\],:\s]+', Name.Tag), + (r':', Punctuation, 'inline_dict_value'), + (r'\}', Punctuation, '#pop'), + (r'\n', Error, '#pop'), + ], + 'inline_dict_value': [ + include('whitespace'), + (r'[^\{\}\[\],:\s]+', Text), + include('inline_value'), + (r',', Punctuation, '#pop'), + (r'\}', Punctuation, '#pop:2'), + ], + 'inline_value': [ + include('whitespace'), + (r'\{', Punctuation, 'inline_dict'), + (r'\[', Punctuation, 'inline_list'), + ], + 'whitespace': [ + (r'[ \t]+', Whitespace), + ], + } + + +class SingularityLexer(RegexLexer): + """ + Lexer for Singularity definition files. + """ + + name = 'Singularity' + url = 'https://www.sylabs.io/guides/3.0/user-guide/definition_files.html' + aliases = ['singularity'] + filenames = ['*.def', 'Singularity'] + version_added = '2.6' + flags = re.IGNORECASE | re.MULTILINE | re.DOTALL + + _headers = r'^(\s*)(bootstrap|from|osversion|mirrorurl|include|registry|namespace|includecmd)(:)' + _section = r'^(%(?:pre|post|setup|environment|help|labels|test|runscript|files|startscript))(\s*)' + _appsect = r'^(%app(?:install|help|run|labels|env|test|files))(\s*)' + + tokens = { + 'root': [ + (_section, bygroups(Generic.Heading, Whitespace), 'script'), + (_appsect, bygroups(Generic.Heading, Whitespace), 'script'), + (_headers, bygroups(Whitespace, Keyword, Text)), + (r'\s*#.*?\n', Comment), + (r'\b(([0-9]+\.?[0-9]*)|(\.[0-9]+))\b', Number), + (r'[ \t]+', Whitespace), + (r'(?!^\s*%).', Text), + ], + 'script': [ + (r'(.+?(?=^\s*%))|(.*)', using(BashLexer), '#pop'), + ], + } + + def analyse_text(text): + """This is a quite simple script file, but there are a few keywords + which seem unique to this language.""" + result = 0 + if re.search(r'\b(?:osversion|includecmd|mirrorurl)\b', text, re.IGNORECASE): + result += 0.5 + + if re.search(SingularityLexer._section[1:], text): + result += 0.49 + + return result + + +class UnixConfigLexer(RegexLexer): + """ + Lexer for Unix/Linux config files using colon-separated values, e.g. + + * ``/etc/group`` + * ``/etc/passwd`` + * ``/etc/shadow`` + """ + + name = 'Unix/Linux config files' + aliases = ['unixconfig', 'linuxconfig'] + filenames = [] + url = 'https://en.wikipedia.org/wiki/Configuration_file#Unix_and_Unix-like_operating_systems' + version_added = '2.12' + + tokens = { + 'root': [ + (r'^#.*', Comment), + (r'\n', Whitespace), + (r':', Punctuation), + (r'[0-9]+', Number), + (r'((?!\n)[a-zA-Z0-9\_\-\s\(\),]){2,}', Text), + (r'[^:\n]+', String), + ], + } + + +class CaddyfileLexer(RegexLexer): + """ + Lexer for Caddyfile, the configuration file format of the Caddy web server. + """ + + name = 'Caddyfile' + url = 'https://caddyserver.com/docs/caddyfile' + aliases = ['caddyfile', 'caddy'] + filenames = ['Caddyfile'] + version_added = '2.21' + + # The standard HTTP directives shipped with Caddy. + directives = ( + 'abort', 'acme_server', 'basic_auth', 'bind', 'encode', 'error', + 'file_server', 'forward_auth', 'handle', 'handle_errors', + 'handle_path', 'header', 'import', 'invoke', 'log', 'map', 'metrics', + 'php_fastcgi', 'push', 'redir', 'request_body', 'request_header', + 'respond', 'reverse_proxy', 'rewrite', 'root', 'route', 'templates', + 'tls', 'tracing', 'try_files', 'uri', 'vars', + ) + + tokens = { + 'root': [ + # Directives are only keywords as the first token on a line, so + # anchor them to the start of the (possibly indented) line. This + # consumes the preceding newline(s)/indentation itself, otherwise + # the generic whitespace rule below would swallow it first. + (r'((?:\A|\s*\n)[ \t]*)(' + '|'.join(directives) + r')\b', + bygroups(Whitespace, Keyword)), + (r'\s+', Whitespace), + (r'#.*', Comment.Single), + # Heredoc: <