summaryrefslogtreecommitdiff
path: root/pygments/lexers/julia.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/julia.py')
-rw-r--r--pygments/lexers/julia.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/pygments/lexers/julia.py b/pygments/lexers/julia.py
index cf7c7d61..d0aa6d35 100644
--- a/pygments/lexers/julia.py
+++ b/pygments/lexers/julia.py
@@ -65,7 +65,7 @@ class JuliaLexer(RegexLexer):
bygroups(Keyword, Name.Function), 'funcname'),
# types
- (r'(type|typealias|abstract)((?:\s|\\\s)+)',
+ (r'(type|typealias|abstract|immutable)((?:\s|\\\s)+)',
bygroups(Keyword, Name.Class), 'typename'),
# operators
@@ -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):