diff options
| author | Alexei Sholik <alcosholik@gmail.com> | 2014-08-15 12:14:00 +0300 |
|---|---|---|
| committer | Alexei Sholik <alcosholik@gmail.com> | 2014-08-15 12:14:00 +0300 |
| commit | b5bc6c6d441b87f1b2cce478cd4de3c3143eac3a (patch) | |
| tree | 94daa8e4614584b82e22ad5d7b7c4ce32ee91718 | |
| parent | eeaff14517a7779c28d1e3eaacdc9ad501e862e8 (diff) | |
| download | pygments-b5bc6c6d441b87f1b2cce478cd4de3c3143eac3a.tar.gz | |
[Elixir] Resolve issues with ':' and '::' punctionation
| -rw-r--r-- | pygments/lexers/functional.py | 12 | ||||
| -rw-r--r-- | tests/examplefiles/example_elixir.ex | 5 |
2 files changed, 11 insertions, 6 deletions
diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py index 9c010b1e..b307a7d7 100644 --- a/pygments/lexers/functional.py +++ b/pygments/lexers/functional.py @@ -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 @@ -3186,13 +3186,13 @@ class ElixirLexer(RegexLexer): OPERATORS3 = ['<<<', '>>>', '|||', '&&&', '^^^', '~~~', '===', '!=='] OPERATORS2 = [ - '==', '!=', '<=', '>=', '&&', '||', '<>', '++', '--', '|>', '=~' + '==', '!=', '<=', '>=', '&&', '||', '<>', '++', '--', '|>', '=~', + '->', '<-', '|', '.', '%', '=' ] OPERATORS1 = ['<', '>', '+', '-', '*', '/', '!', '^', '&'] PUNCTUATION = [ - '\\\\', '<<', '>>', '::', '->', '<-', '=>', '|', '(', ')', - '{', '}', ';', ',', '.', '[', ']', '%', '=' + '\\\\', '<<', '>>', '=>', '(', ')', '{', '}', ':', ';', ',', '[', ']' ] def get_tokens_unprocessed(self, text): @@ -3295,6 +3295,10 @@ class ElixirLexer(RegexLexer): 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), diff --git a/tests/examplefiles/example_elixir.ex b/tests/examplefiles/example_elixir.ex index 6a525ace..41de83e5 100644 --- a/tests/examplefiles/example_elixir.ex +++ b/tests/examplefiles/example_elixir.ex @@ -24,7 +24,8 @@ line ' \s \123 \xff atom" :... ; :<<>> ; :%{} ; :% ; :{} -:++; :--; :*; :~~~ +:++; :--; :*; :~~~; ::: +:% ; :. ; :<- # Strings "Hello world" @@ -83,7 +84,7 @@ map = %{shortcut: "syntax"} # Comprehensions for x <- 1..10, x < 5, do: {x, x} pixels = "12345678" -for << <<r::4, g::4, b::4, a::4>> <- pixels >> do +for << <<r::4, g::4, b::4, a::size(4)>> <- pixels >> do [r, {g, %{"b" => a}}] end |
