diff options
author | Alex Zimin <ziminav@gmail.com> | 2011-06-08 03:32:28 +0800 |
---|---|---|
committer | Alex Zimin <ziminav@gmail.com> | 2011-06-08 03:32:28 +0800 |
commit | 6d5b1c4145a43bba6d8d5649d2a2032d9590948e (patch) | |
tree | 3e2cb641a1d7439f83d3d300c8b7aea3099b12a3 /pygments/lexers/dotnet.py | |
parent | dc887220a592b9122b383575136e22246fe861e3 (diff) | |
download | pygments-6d5b1c4145a43bba6d8d5649d2a2032d9590948e.tar.gz |
fix expr injection into quasiquotation
Diffstat (limited to 'pygments/lexers/dotnet.py')
-rw-r--r-- | pygments/lexers/dotnet.py | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/pygments/lexers/dotnet.py b/pygments/lexers/dotnet.py index 6e74af1f..d9926294 100644 --- a/pygments/lexers/dotnet.py +++ b/pygments/lexers/dotnet.py @@ -203,13 +203,21 @@ class NemerleLexer(RegexLexer): (r'\$\s*"', String, 'splice-string'), (r'\$\s*<#', String, 'splice-string2'), (r'<#', String, 'recursive-string'), + + (r'(<\[)\s*(' + cs_ident + ':)?', Keyword), + (r'\]\>', Keyword), + + # quasiquotation only + (r'\$' + cs_ident, Name), + (r'(\$)(\()', bygroups(Name, Punctuation), 'splice-string-content'), + (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation), (r'[{}]', Punctuation), (r'@"(\\\\|\\"|[^"])*"', String), (r'"(\\\\|\\"|[^"\n])*["\n]', String), (r"'\\.'|'[^\\]'", String.Char), - (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?" - r"[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?", Number), + (r"0[xX][0-9a-fA-F]+[Ll]?", Number), + (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFLdD]?", Number), (r'#[ \t]*(if|endif|else|elif|define|undef|' r'line|error|warning|region|endregion|pragma)\b.*?\n', Comment.Preproc), @@ -218,17 +226,18 @@ class NemerleLexer(RegexLexer): (r'(abstract|and|as|base|catch|def|delegate|' r'enum|event|extern|false|finally|' r'fun|implements|interface|internal|' - r'is|macro|match|matches|module|mutable|new|' + r'is|macro|match|matches|mutable|new|' r'null|out|override|params|partial|private|' r'protected|public|ref|sealed|static|' r'syntax|this|throw|true|try|type|typeof|' r'virtual|volatile|when|where|with|' r'assert|assert2|async|break|checked|continue|do|else|' r'ensures|for|foreach|if|late|lock|new|nolate|' - r'otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b', Keyword), - (r'(global)(::)', bygroups(Keyword, Punctuation)), + r'otherwise|regexp|repeat|requires|return|surroundwith|' + r'unchecked|unless|using|while|yield)\b', Keyword), (r'(bool|byte|char|decimal|double|float|int|long|object|sbyte|' - r'short|string|uint|ulong|ushort)\b\??', Keyword.Type), + r'short|string|uint|ulong|ushort|void|array|list)\b\??', Keyword.Type), + (r'(:>?)\s*(' + cs_ident + r'\??)', bygroups(Punctuation, Keyword.Type)), (r'(class|struct|variant|module)(\s+)', bygroups(Keyword, Text), 'class'), (r'(namespace|using)(\s+)', bygroups(Keyword, Text), 'namespace'), (cs_ident, Name), @@ -242,15 +251,15 @@ class NemerleLexer(RegexLexer): ], 'splice-string': [ (r'[^"$]', String), - (r'\$\(', Name, 'splice-string-content'), - (r'\$', Name, 'splice-string-ident'), + (r'\$' + cs_ident, Name), + (r'(\$)(\()', bygroups(Name, Punctuation), 'splice-string-content'), (r'\\"', String), (r'"', String, '#pop') ], 'splice-string2': [ (r'[^#<>$]', String), - (r'\$\(', Name, 'splice-string-content'), - (r'\$', Name, 'splice-string-ident'), + (r'\$' + cs_ident, Name), + (r'(\$)(\()', bygroups(Name, Punctuation), 'splice-string-content'), (r'<#', String, '#push'), (r'#>', String, '#pop') ], @@ -263,13 +272,9 @@ class NemerleLexer(RegexLexer): (r'if|match', Keyword), (r'[~!%^&*+=|\[\]:;,.<>/?-]', Punctuation), (cs_ident, Name), - (r'\(', Name, '#push'), - (r'\)', Name, '#pop') - ], - 'splice-string-ident': [ - (cs_ident, Name, '#pop'), - (r'.', String, '#pop') - ], + (r'\(', Punctuation, '#push'), + (r'\)', Punctuation, '#pop') + ] } def __init__(self, **options): |