diff options
author | Alexei Sholik <alcosholik@gmail.com> | 2014-08-15 13:26:02 +0300 |
---|---|---|
committer | Alexei Sholik <alcosholik@gmail.com> | 2014-08-15 13:26:02 +0300 |
commit | 04e47f0f5ebd530eb9bc4380848d31279f01fb0b (patch) | |
tree | 78d5713932fe13c98bab6f72a8f6eeaf7a80882b /pygments/lexers/functional.py | |
parent | 37368d865858e12278cc31f8bb6b46d27d63fb2c (diff) | |
download | pygments-04e47f0f5ebd530eb9bc4380848d31279f01fb0b.tar.gz |
[Elixir] Parse maps and tuples to make non-trivial and nested string interpolation work
Diffstat (limited to 'pygments/lexers/functional.py')
-rw-r--r-- | pygments/lexers/functional.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py index b307a7d7..ed63be44 100644 --- a/pygments/lexers/functional.py +++ b/pygments/lexers/functional.py @@ -3187,12 +3187,12 @@ class ElixirLexer(RegexLexer): OPERATORS3 = ['<<<', '>>>', '|||', '&&&', '^^^', '~~~', '===', '!=='] OPERATORS2 = [ '==', '!=', '<=', '>=', '&&', '||', '<>', '++', '--', '|>', '=~', - '->', '<-', '|', '.', '%', '=' + '->', '<-', '|', '.', '=' ] OPERATORS1 = ['<', '>', '+', '-', '*', '/', '!', '^', '&'] PUNCTUATION = [ - '\\\\', '<<', '>>', '=>', '(', ')', '{', '}', ':', ';', ',', '[', ']' + '\\\\', '<<', '>>', '=>', '(', ')', ':', ';', ',', '[', ']' ] def get_tokens_unprocessed(self, text): @@ -3321,7 +3321,7 @@ class ElixirLexer(RegexLexer): # identifiers (name_re, Name), - (modname_re, Name.Class), + (r'(%%?)(%s)' % (modname_re,), bygroups(Punctuation, Name.Class)), # numbers (r'0b[01]+', Number.Bin), @@ -3337,6 +3337,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'), @@ -3371,6 +3374,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)) |