diff options
author | Georg Brandl <georg@python.org> | 2014-09-16 09:51:52 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-09-16 09:51:52 +0200 |
commit | 508e306f64288290c46602f904f8d25d867c0b50 (patch) | |
tree | 78579062c1169528dba5049efc7e1793653228e2 /pygments | |
parent | 318728914ec120c42bd892905f98414d01589d3b (diff) | |
parent | 36b2888b4a17b28e6bcd7bc76ee57ed706de0f01 (diff) | |
download | pygments-508e306f64288290c46602f904f8d25d867c0b50.tar.gz |
merge with R4PaSs/pygments-main
Diffstat (limited to 'pygments')
-rw-r--r-- | pygments/lexers/_mapping.py | 2 | ||||
-rw-r--r-- | pygments/lexers/agile.py | 6 | ||||
-rw-r--r-- | pygments/lexers/compiled.py | 24 | ||||
-rw-r--r-- | pygments/lexers/functional.py | 122 | ||||
-rw-r--r-- | pygments/lexers/other.py | 2 |
5 files changed, 86 insertions, 70 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index f8454357..b028aee6 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -20,7 +20,7 @@ LEXERS = { 'APLLexer': ('pygments.lexers.other', 'APL', ('apl',), ('*.apl',), ()), 'ActionScript3Lexer': ('pygments.lexers.web', 'ActionScript 3', ('as3', 'actionscript3'), ('*.as',), ('application/x-actionscript3', 'text/x-actionscript3', 'text/actionscript3')), 'ActionScriptLexer': ('pygments.lexers.web', 'ActionScript', ('as', 'actionscript'), ('*.as',), ('application/x-actionscript', 'text/x-actionscript', 'text/actionscript')), - 'AdaLexer': ('pygments.lexers.compiled', 'Ada', ('ada', 'ada95ada2005'), ('*.adb', '*.ads', '*.ada'), ('text/x-ada',)), + 'AdaLexer': ('pygments.lexers.compiled', 'Ada', ('ada', 'ada95', 'ada2005'), ('*.adb', '*.ads', '*.ada'), ('text/x-ada',)), 'AgdaLexer': ('pygments.lexers.functional', 'Agda', ('agda',), ('*.agda',), ('text/x-agda',)), 'AlloyLexer': ('pygments.lexers.other', 'Alloy', ('alloy',), ('*.als',), ('text/x-alloy',)), 'AmbientTalkLexer': ('pygments.lexers.other', 'AmbientTalk', ('at', 'ambienttalk', 'ambienttalk/2'), ('*.at',), ('text/x-ambienttalk',)), diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py index 576f44ed..1ae369b9 100644 --- a/pygments/lexers/agile.py +++ b/pygments/lexers/agile.py @@ -2010,8 +2010,8 @@ class Perl6Lexer(ExtendedRegexLexer): PERL6_BUILTINS = ( 'ACCEPTS', 'HOW', 'REJECTS', 'VAR', 'WHAT', 'WHENCE', 'WHERE', 'WHICH', 'WHO', 'abs', 'acos', 'acosec', 'acosech', 'acosh', 'acotan', 'acotanh', - 'all', 'any', 'approx', 'arity', 'asec', 'asech', 'asin', 'asinh' - 'assuming', 'atan', 'atan2', 'atanh', 'attr', 'bless', 'body', 'by' + 'all', 'any', 'approx', 'arity', 'asec', 'asech', 'asin', 'asinh', + 'assuming', 'atan', 'atan2', 'atanh', 'attr', 'bless', 'body', 'by', 'bytes', 'caller', 'callsame', 'callwith', 'can', 'capitalize', 'cat', 'ceiling', 'chars', 'chmod', 'chomp', 'chop', 'chr', 'chroot', 'circumfix', 'cis', 'classify', 'clone', 'close', 'cmp_ok', 'codes', @@ -2396,7 +2396,7 @@ class HyLexer(RegexLexer): ] declarations = [ - 'def' 'defn', 'defun', 'defmacro', 'defclass', 'lambda', 'fn', 'setv' + 'def', 'defn', 'defun', 'defmacro', 'defclass', 'lambda', 'fn', 'setv' ] hy_builtins = [] diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index 480e4a8f..1cf5fee7 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -2437,7 +2437,7 @@ class AdaLexer(RegexLexer): """ name = 'Ada' - aliases = ['ada', 'ada95' 'ada2005'] + aliases = ['ada', 'ada95', 'ada2005'] filenames = ['*.adb', '*.ads', '*.ada'] mimetypes = ['text/x-ada'] @@ -3321,7 +3321,7 @@ class RustLexer(RegexLexer): (r'\s+', Text), (r'//[/!](.*?)\n', Comment.Doc), (r'//(.*?)\n', Comment.Single), - (r'/[*](.|\n)*?[*]/', Comment.Multiline), + (r'/\*', Comment.Multiline, 'comment'), # Keywords (r'(as|box|break|continue' @@ -3403,6 +3403,12 @@ class RustLexer(RegexLexer): (r'([A-Za-z_]\w*)!\s*([A-Za-z_]\w*)?\(', bygroups(Comment.Preproc, Name), 'macro('), ], + 'comment': [ + (r'[^*/]+', Comment.Multiline), + (r'/\*', Comment.Multiline, '#push'), + (r'\*/', Comment.Multiline, '#pop'), + (r'[*/]', Comment.Multiline), + ], 'number_lit': [ (r'(([ui](8|16|32|64)?)|(f(32|64)?))?', Keyword, '#pop'), ], @@ -3920,11 +3926,11 @@ class ChapelLexer(RegexLexer): (r'(false|nil|true)\b', Keyword.Constant), (r'(bool|complex|imag|int|opaque|range|real|string|uint)\b', Keyword.Type), - (r'(atomic|begin|break|by|cobegin|coforall|continue|iter|' + (r'(align|atomic|begin|break|by|cobegin|coforall|continue|' r'delete|dmapped|do|domain|else|enum|export|extern|for|forall|' - r'if|index|inline|label|lambda|let|local|new|on|otherwise|' - r'reduce|return|scan|select|serial|single|sparse|' - r'subdomain|sync|then|use|when|where|while|yield|zip)\b', + r'if|index|inline|iter|label|lambda|let|local|new|noinit|on|' + r'otherwise|pragma|reduce|return|scan|select|serial|single|sparse|' + r'subdomain|sync|then|use|when|where|while|with|yield|zip)\b', Keyword), (r'(proc)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'procname'), (r'(class|module|record|union)(\s+)', bygroups(Keyword, Text), @@ -3946,15 +3952,17 @@ class ChapelLexer(RegexLexer): (r'0[bB][0-1]+', Number.Bin), # -- hex (r'0[xX][0-9a-fA-F]+', Number.Hex), + # -- octal + (r'0[oO][0-7]+', Number.Oct), # -- decimal - (r'(0|[1-9][0-9]*)', Number.Integer), + (r'[0-9]+', Number.Integer), # strings (r'["\'](\\\\|\\"|[^"\'])*["\']', String), # tokens (r'(=|\+=|-=|\*=|/=|\*\*=|%=|&=|\|=|\^=|&&=|\|\|=|<<=|>>=|' - r'<=>|\.\.|by|#|\.\.\.|' + r'<=>|<~>|\.\.|by|#|\.\.\.|' r'&&|\|\||!|&|\||\^|~|<<|>>|' r'==|!=|<=|>=|<|>|' r'[+\-*/%]|\*\*)', Operator), diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py index a22c4f55..2c13dce3 100644 --- a/pygments/lexers/functional.py +++ b/pygments/lexers/functional.py @@ -1530,7 +1530,7 @@ class IdrisLexer(RegexLexer): 'let','proof','of','then','static','where','_','with', 'pattern', 'term', 'syntax','prefix', 'postulate','parameters','record','dsl','impossible','implicit', - 'tactics','intros','intro','compute','refine','exaxt','trivial'] + 'tactics','intros','intro','compute','refine','exact','trivial'] ascii = ['NUL','SOH','[SE]TX','EOT','ENQ','ACK', 'BEL','BS','HT','LF','VT','FF','CR','S[OI]','DLE', @@ -3135,7 +3135,7 @@ def gen_elixir_string_rules(name, symbol, token): (r'[^#%s\\]+' % (symbol,), token), include('escapes'), (r'\\.', token), - (r'(%s)(:?)' % (symbol,), bygroups(token, Punctuation), "#pop"), + (r'(%s)' % (symbol,), bygroups(token), "#pop"), include('interpol') ] return states @@ -3169,7 +3169,7 @@ class ElixirLexer(RegexLexer): mimetypes = ['text/x-elixir'] KEYWORD = ['fn', 'do', 'end', 'after', 'else', 'rescue', 'catch'] - KEYWORD_OPERATOR = ['not', 'and', 'or', 'xor', 'when', 'in'] + KEYWORD_OPERATOR = ['not', 'and', 'or', 'when', 'in'] BUILTIN = [ 'case', 'cond', 'for', 'if', 'unless', 'try', 'receive', 'raise', 'quote', 'unquote', 'unquote_splicing', 'throw', 'super' @@ -3184,15 +3184,19 @@ class ElixirLexer(RegexLexer): PSEUDO_VAR = ['_', '__MODULE__', '__DIR__', '__ENV__', '__CALLER__'] - OPERATORS3 = ['<<<', '>>>', '|||', '&&&', '^^^', '~~~', '===', '!=='] + + OPERATORS3 = [ + '<<<', '>>>', '|||', '&&&', '^^^', '~~~', '===', '!==', + '~>>', '<~>', '|~>', '<|>', + ] OPERATORS2 = [ - '==', '!=', '<=', '>=', '&&', '||', '<>', '++', '--', '|>', '=~' + '==', '!=', '<=', '>=', '&&', '||', '<>', '++', '--', '|>', '=~', + '->', '<-', '|', '.', '=', '~>', '<~', ] OPERATORS1 = ['<', '>', '+', '-', '*', '/', '!', '^', '&'] PUNCTUATION = [ - '\\\\', '<<', '>>', '::', '->', '<-', '=>', '|', '(', ')', - '{', '}', ';', ',', '.', '[', ']', '%', '=' + '\\\\', '<<', '>>', '=>', '(', ')', ':', ';', ',', '[', ']' ] def get_tokens_unprocessed(self, text): @@ -3218,20 +3222,19 @@ class ElixirLexer(RegexLexer): yield index, token, value def gen_elixir_sigil_rules(): - # these braces are balanced inside the sigil string - braces = [ + # all valid sigil terminators (excluding heredocs) + terminators = [ (r'\{', r'\}', 'cb'), (r'\[', r'\]', 'sb'), (r'\(', r'\)', 'pa'), (r'\<', r'\>', 'ab'), + (r'/', r'/', 'slas'), + (r'\|', r'\|', 'pipe'), + ('"', '"', 'quot'), + ("'", "'", 'apos'), ] - # these are also valid sigil terminators, they are not balanced - terms = [ - (r'/', 'slas'), (r'\|', 'pipe'), ('"', 'quot'), ("'", 'apos'), - ] - - # heredocs have slightly different rules, they are not balanced + # heredocs have slightly different rules triquotes = [(r'"""', 'triquot'), (r"'''", 'triapos')] token = String.Other @@ -3255,33 +3258,14 @@ class ElixirLexer(RegexLexer): include('heredoc_no_interpol'), ] - for term, name in terms: + for lterm, rterm, name in terminators: states['sigils'] += [ - (r'~[a-z]' + term, token, name + '-intp'), - (r'~[A-Z]' + term, token, name + '-no-intp'), + (r'~[a-z]' + lterm, token, name + '-intp'), + (r'~[A-Z]' + lterm, token, name + '-no-intp'), ] - - # Similar states to the braced sigils, but no balancing of - # terminators - states[name +'-intp'] = gen_elixir_sigstr_rules(term, token) + states[name +'-intp'] = gen_elixir_sigstr_rules(rterm, token) states[name +'-no-intp'] = \ - gen_elixir_sigstr_rules(term, token, interpol=False) - - for lbrace, rbrace, name in braces: - states['sigils'] += [ - (r'~[a-z]' + lbrace, token, name + '-intp'), - (r'~[A-Z]' + lbrace, token, name + '-no-intp') - ] - - states[name +'-intp'] = [ - (r'\\.', token), - (lbrace, token, '#push'), - ] + gen_elixir_sigstr_rules(rbrace, token) - - states[name +'-no-intp'] = [ - (r'\\.', token), - (lbrace, token, '#push'), - ] + gen_elixir_sigstr_rules(rbrace, token, interpol=False) + gen_elixir_sigstr_rules(rterm, token, interpol=False) return states @@ -3290,28 +3274,35 @@ class ElixirLexer(RegexLexer): op1_re = "|".join(re.escape(s) for s in OPERATORS1) ops_re = r'(?:%s|%s|%s)' % (op3_re, op2_re, op1_re) punctuation_re = "|".join(re.escape(s) for s in PUNCTUATION) - name_re = r'[a-z_][a-zA-Z_0-9]*[!\?]?' - modname_re = r'[A-Z][A-Za-z_]*(?:\.[A-Z][A-Za-z_]*)*' + alnum = '[A-Za-z_0-9]' + name_re = r'(?:\.\.\.|[a-z_]%s*[!\?]?)' % alnum + modname_re = r'[A-Z]%(alnum)s*(?:\.[A-Z]%(alnum)s*)*' % {'alnum': alnum} complex_name_re = r'(?:%s|%s|%s)' % (name_re, modname_re, ops_re) special_atom_re = r'(?:\.\.\.|<<>>|%{}|%|{})' + long_hex_char_re = r'(\\x{)([\da-fA-F]+)(})' + hex_char_re = r'(\\x[\da-fA-F]{1,2})' + escape_char_re = r'(\\[abdefnrstv])' + tokens = { 'root': [ (r'\s+', Text), (r'#.*$', Comment.Single), # Various kinds of characters - (r'(?i)(\?)(\\x{)([\da-f]+)(})', + (r'(\?)' + long_hex_char_re, bygroups(String.Char, String.Escape, Number.Hex, String.Escape)), - (r'(?i)(\?)(\\x[\da-f]{1,2})', - bygroups(String.Char, String.Escape)), - (r'(\?)(\\[0-7]{1,3})', + (r'(\?)' + hex_char_re, bygroups(String.Char, String.Escape)), - (r'(\?)(\\[abdefnrstv])', + (r'(\?)' + escape_char_re, bygroups(String.Char, String.Escape)), (r'\?\\?.', String.Char), + # '::' has to go before atoms + (r':::', String.Symbol), + (r'::', Operator), + # atoms (r':' + special_atom_re, String.Symbol), (r':' + complex_name_re, String.Symbol), @@ -3325,6 +3316,10 @@ class ElixirLexer(RegexLexer): # @attributes (r'@' + name_re, Name.Attribute), + # identifiers + (name_re, Name), + (r'(%%?)(%s)' % (modname_re,), bygroups(Punctuation, Name.Class)), + # operators and punctuation (op3_re, Operator), (op2_re, Operator), @@ -3332,14 +3327,10 @@ class ElixirLexer(RegexLexer): (r'&\d', Name.Entity), # anon func arguments (op1_re, Operator), - # identifiers - (name_re, Name), - (modname_re, Name.Class), - # numbers - (r'0[bB][01]+', Number.Bin), - (r'0[0-7]+', Number.Oct), - (r'(?i)0x[\da-f]+', Number.Hex), + (r'0b[01]+', Number.Bin), + (r'0o[0-7]+', Number.Oct), + (r'0x[\da-fA-F]+', Number.Hex), (r'\d(_?\d)*\.\d(_?\d)*([eE][-+]?\d(_?\d)*)?', Number.Float), (r'\d(_?\d)*', Number.Integer), @@ -3350,6 +3341,9 @@ class ElixirLexer(RegexLexer): (r"'", String.Single, 'string_single'), include('sigils'), + + (r'%{', Punctuation, 'map_key'), + (r'{', Punctuation, 'tuple'), ], 'heredoc_double': [ (r'^\s*"""', String.Heredoc, '#pop'), @@ -3372,11 +3366,10 @@ class ElixirLexer(RegexLexer): (r'\n+', String.Heredoc), ], 'escapes': [ - (r'(?i)(\\x{)([\da-f]+)(})', + (long_hex_char_re, bygroups(String.Escape, Number.Hex, String.Escape)), - (r'(?i)\\x[\da-f]{1,2}', String.Escape), - (r'\\[0-7]{1,3}', String.Escape), - (r'\\[abdefnrstv]', String.Escape), + (hex_char_re, String.Escape), + (escape_char_re, String.Escape), ], 'interpol': [ (r'#{', String.Interpol, 'interpol_string'), @@ -3385,6 +3378,21 @@ class ElixirLexer(RegexLexer): (r'}', String.Interpol, "#pop"), include('root') ], + 'map_key': [ + include('root'), + (r':', Punctuation, 'map_val'), + (r'=>', Punctuation, 'map_val'), + (r'}', Punctuation, '#pop'), + ], + 'map_val': [ + include('root'), + (r',', Punctuation, '#pop'), + (r'(?=})', Punctuation, '#pop'), + ], + 'tuple': [ + include('root'), + (r'}', Punctuation, '#pop'), + ], } tokens.update(gen_elixir_string_rules('double', '"', String.Double)) tokens.update(gen_elixir_string_rules('single', "'", String.Single)) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 608e499d..0075fc07 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -2473,7 +2473,7 @@ class ProtoBufLexer(RegexLexer): (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single), (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline), (r'\b(import|option|optional|required|repeated|default|packed|' - r'ctype|extensions|to|max|rpc|returns)\b', Keyword), + r'ctype|extensions|to|max|rpc|returns|oneof)\b', Keyword), (r'(int32|int64|uint32|uint64|sint32|sint64|' r'fixed32|fixed64|sfixed32|sfixed64|' r'float|double|bool|string|bytes)\b', Keyword.Type), |