summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPHO <pho@cielonegro.org>2016-01-25 12:51:35 +0900
committerPHO <pho@cielonegro.org>2016-01-25 12:51:35 +0900
commit5354cee4445619cd75b7c202585858073651d840 (patch)
tree5170cbdbf276d372b54ad8348115345517810a9c
parente2617210227fd5e93638294fb1a2f0cc22acfb7f (diff)
downloadpygments-5354cee4445619cd75b7c202585858073651d840.tar.gz
Erlang lexer: Support map expressions introduced in Erlang/OTP 17
-rw-r--r--pygments/lexers/erlang.py15
-rw-r--r--tests/examplefiles/test.erl4
2 files changed, 19 insertions, 0 deletions
diff --git a/pygments/lexers/erlang.py b/pygments/lexers/erlang.py
index 5cde2f24..7838b3c5 100644
--- a/pygments/lexers/erlang.py
+++ b/pygments/lexers/erlang.py
@@ -119,6 +119,10 @@ class ErlangLexer(RegexLexer):
# 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),
@@ -134,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'),
+ ],
}
diff --git a/tests/examplefiles/test.erl b/tests/examplefiles/test.erl
index bcf9a0b7..d4ab4825 100644
--- a/tests/examplefiles/test.erl
+++ b/tests/examplefiles/test.erl
@@ -152,6 +152,10 @@ a_binary() ->
a_list_comprehension() ->
[X*2 || X <- [1,2,3]].
+a_map() ->
+ M0 = #{ a => 1, b => 2 },
+ M1 = M0#{ b := 200 }.
+
escape_sequences() ->
[ "\b\d\e\f\n\r\s\t\v\'\"\\"
, "\1\12\123" % octal