diff options
Diffstat (limited to 'pygments/lexers/erlang.py')
-rw-r--r-- | pygments/lexers/erlang.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/pygments/lexers/erlang.py b/pygments/lexers/erlang.py index c353a4dc..7838b3c5 100644 --- a/pygments/lexers/erlang.py +++ b/pygments/lexers/erlang.py @@ -82,7 +82,11 @@ class ErlangLexer(RegexLexer): variable_re = r'(?:[A-Z_]\w*)' - escape_re = r'(?:\\(?:[bdefnrstv\'"\\/]|[0-7][0-7]?[0-7]?|\^[a-zA-Z]))' + esc_char_re = r'[bdefnrstv\'"\\]' + esc_octal_re = r'[0-7][0-7]?[0-7]?' + esc_hex_re = r'(?:x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\})' + esc_ctrl_re = r'\^[a-zA-Z]' + escape_re = r'(?:\\(?:'+esc_char_re+r'|'+esc_octal_re+r'|'+esc_hex_re+r'|'+esc_ctrl_re+r'))' macro_re = r'(?:'+variable_re+r'|'+atom_re+r')' @@ -112,6 +116,13 @@ class ErlangLexer(RegexLexer): (r'\?'+macro_re, Name.Constant), (r'\$(?:'+escape_re+r'|\\[ %]|[^\\])', String.Char), (r'#'+atom_re+r'(:?\.'+atom_re+r')?', Name.Label), + + # Erlang script shebang + (r'\A#!.+\n', Comment.Hashbang), + + # EEP 43: Maps + # http://www.erlang.org/eeps/eep-0043.html + (r'#\{', Punctuation, 'map_key'), ], 'string': [ (escape_re, String.Escape), @@ -127,6 +138,17 @@ class ErlangLexer(RegexLexer): bygroups(Name.Entity, Text, Punctuation, Name.Label), '#pop'), (atom_re, Name.Entity, '#pop'), ], + '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'), + ], } |