diff options
author | Georg Brandl <georg@python.org> | 2016-02-02 11:23:10 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2016-02-02 11:23:10 +0100 |
commit | 76e9a0a6e71ff20090f88f1949e4ae33f2079259 (patch) | |
tree | abc04aaa43dfacc4fc62e143643e97475643f819 /pygments/lexers/julia.py | |
parent | 92f69ad7ed20e30baab3ba6d1c12de8ee3260584 (diff) | |
download | pygments-76e9a0a6e71ff20090f88f1949e4ae33f2079259.tar.gz |
Fixed Julia string interpolation (closes #1170).
Diffstat (limited to 'pygments/lexers/julia.py')
-rw-r--r-- | pygments/lexers/julia.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/pygments/lexers/julia.py b/pygments/lexers/julia.py index ea726080..d0aa6d35 100644 --- a/pygments/lexers/julia.py +++ b/pygments/lexers/julia.py @@ -132,14 +132,23 @@ class JuliaLexer(RegexLexer): 'string': [ (r'"', String, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings - (r'\$(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?', - String.Interpol), - (r'[^\\"$]+', String), - # quotes, dollar signs, and backslashes must be parsed one at a time - (r'["\\]', String), - # unhandled string formatting sign - (r'\$', String) + # Interpolation is defined as "$" followed by the shortest full + # expression, which is something we can't parse. + # Include the most common cases here: $word, and $(paren'd expr). + (r'\$[a-zA-Z_]+', String.Interpol), + (r'\$\(', String.Interpol, 'in-intp'), + # @printf and @sprintf formats + (r'%[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[diouxXeEfFgGcrs%]', + String.Interpol), + (r'[^$%"\\]+', String), + # unhandled special signs + (r'[$%"\\]', String), ], + 'in-intp': [ + (r'[^()]+', String.Interpol), + (r'\(', String.Interpol, '#push'), + (r'\)', String.Interpol, '#pop'), + ] } def analyse_text(text): |