diff options
author | Georg Brandl <georg@python.org> | 2016-02-14 15:15:04 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2016-02-14 15:15:04 +0100 |
commit | be71a37c4b860a5247cf7f65ea8f3596cef11e9e (patch) | |
tree | 518bfd491c44e50b9298ea5948a460e584afe6d5 /pygments/lexers/erlang.py | |
parent | 1b8de7302a856a8046315758ae4ed51c775bc84f (diff) | |
parent | 6297dd482d0b0adcf8f9792da90f4543390cd154 (diff) | |
download | pygments-git-be71a37c4b860a5247cf7f65ea8f3596cef11e9e.tar.gz |
merge with stable
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'), + ], } |