diff options
author | Jon Parise <jon@indelible.org> | 2015-05-23 15:30:41 -0700 |
---|---|---|
committer | Jon Parise <jon@indelible.org> | 2015-05-23 15:30:41 -0700 |
commit | f7a597a4ae3537b5a75c564e00972cec0f95aa34 (patch) | |
tree | 6280605b2b70be6ad1920677a0b0d2ae2b8c2d82 /pygments/lexers/dsls.py | |
parent | 549e0b5a7d972c20ce87a02b505e8cc45afa1f73 (diff) | |
download | pygments-f7a597a4ae3537b5a75c564e00972cec0f95aa34.tar.gz |
Apply String.(Single|Double) to the entire string.
Diffstat (limited to 'pygments/lexers/dsls.py')
-rw-r--r-- | pygments/lexers/dsls.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/pygments/lexers/dsls.py b/pygments/lexers/dsls.py index 60ffeae5..4b7a50b0 100644 --- a/pygments/lexers/dsls.py +++ b/pygments/lexers/dsls.py @@ -12,7 +12,7 @@ import re from pygments.lexer import RegexLexer, bygroups, words, include, default, \ - this, using + this, using, combined from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Literal @@ -97,8 +97,8 @@ class ThriftLexer(RegexLexer): 'root': [ include('whitespace'), include('comments'), - (r'"', String.Double, 'dqs'), - (r'\'', String.Single, 'sqs'), + (r'"', String.Double, combined('stringescape', 'dqs')), + (r'\'', String.Single, combined('stringescape', 'sqs')), (r'(namespace)(\s+)', bygroups(Keyword.Namespace, Text.Whitespace), 'namespace'), (r'(enum|union|struct|service|exception)(\s+)', @@ -122,18 +122,16 @@ class ThriftLexer(RegexLexer): (r'//.*?\n', Comment), (r'/\*[\w\W]*?\*/', Comment.Multiline), ], - 'string': [ - (r'\\([\\nrt"\'])', String.Escape), # escape characters - (r'[^\\"\\\'\n]+', String), # all other characters - (r'\\', String), # literal backslash + 'stringescape': [ + (r'\\([\\nrt"\'])', String.Escape), ], 'dqs': [ - (r'"', String, '#pop'), - include('string') + (r'"', String.Double, '#pop'), + (r'[^\\"\n]+', String.Double), ], 'sqs': [ - (r"'", String, '#pop'), - include('string') + (r"'", String.String, '#pop'), + (r'[^\\\'\n]+', String.Single), ], 'namespace': [ (r'[a-z\*](\.[a-zA-Z_0-9]|[a-zA-Z_0-9])*', Name.Namespace, '#pop'), |