summaryrefslogtreecommitdiff
path: root/pygments/lexers/jvm.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-10-07 11:17:30 +0200
committerGeorg Brandl <georg@python.org>2014-10-07 11:17:30 +0200
commit554d80c14d145050512e1c1e9c7f20aa266bca83 (patch)
tree1c67fc577562a9c0ba13ad539b25b6061a683938 /pygments/lexers/jvm.py
parentd2aef9093d60c6965d66eed160292ee854c0a4da (diff)
downloadpygments-554d80c14d145050512e1c1e9c7f20aa266bca83.tar.gz
Closes #1010: recognize string interpolation in Scala lexer.
Diffstat (limited to 'pygments/lexers/jvm.py')
-rw-r--r--pygments/lexers/jvm.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py
index 19f0ded9..34198530 100644
--- a/pygments/lexers/jvm.py
+++ b/pygments/lexers/jvm.py
@@ -268,6 +268,8 @@ class ScalaLexer(RegexLexer):
(r'""".*?"""(?!")', String),
(r'"(\\\\|\\"|[^"])*"', String),
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
+ (r'[fs]"', String, 'interpstring'), # interpolated strings
+ (r'raw"(\\\\|\\"|[^"])*"', String), # raw strings
# (ur'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,
# Name.Attribute)),
(idrest, Name),
@@ -320,6 +322,17 @@ class ScalaLexer(RegexLexer):
'import': [
(u'(%s|\\.)+' % idrest, Name.Namespace, '#pop')
],
+ 'interpstring': [
+ (r'[^"$\\]', String),
+ (r'\$\{', String.Interpol, 'interpbrace'),
+ (r'\\.', String),
+ (r'"', String, '#pop'),
+ ],
+ 'interpbrace': [
+ (r'\}', String.Interpol, '#pop'),
+ (r'\{', String.Interpol, '#push'),
+ include('root'),
+ ]
}