# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersclassCSharp<RegexLexertag'csharp'aliases'c#','cs'filenames'*.cs'mimetypes'text/x-csharp'title"C#"desc'a multi-paradigm language targeting .NET'# TODO: support more of unicodeid=/@?[_a-z]\w*/i#Reserved Identifiers#Contextual Keywords#LINQ Query Expressionskeywords=%w(
abstract as base break case catch checked const continue
default delegate do else enum event explicit extern false
finally fixed for foreach goto if implicit in interface
internal is lock new null operator out override params private
protected public readonly ref return sealed sizeof stackalloc
static switch this throw true try typeof unchecked unsafe
virtual void volatile while
add alias async await get global partial remove set value where
yield nameof
ascending by descending equals from group in into join let on
orderby select
)keywords_type=%w(
bool byte char decimal double dynamic float int long object
sbyte short string uint ulong ushort var
)cpp_keywords=%w(
if endif else elif define undef line error warning region
endregion pragma
)state:whitespacedorule/\s+/m,Textrule%r(//.*?$),Comment::Singlerule%r(/[*].*?[*]/)m,Comment::Multilineendstate:nestdorule/{/,Punctuation,:nestrule/}/,Punctuation,:pop!mixin:rootendstate:splice_stringdorule/\\./,Strrule/{/,Punctuation,:nestrule/"|\n/,Str,:pop!rule/./,Strendstate:splice_literaldorule/""/,Strrule/{/,Punctuation,:nestrule/"/,Str,:pop!rule/./,Strendstate:rootdomixin:whitespacerule/^\s*\[.*?\]/,Name::Attributerule/[$]\s*"/,Str,:splice_stringrule/[$]@\s*"/,Str,:splice_literalrule/(<\[)\s*(#{id}:)?/,Keywordrule/\]>/,Keywordrule/[~!%^&*()+=|\[\]{}:;,.<>\/?-]/,Punctuationrule/@"(""|[^"])*"/m,Strrule/"(\\.|.)*?["\n]/,Strrule/'(\\.|.)'/,Str::Charrule/0x[0-9a-f]+[lu]?/i,Numrule%r(
[0-9]
([.][0-9]*)? # decimal
(e[+-][0-9]+)? # exponent
[fldu]? # type
)ix,Numrule/\b(?:class|struct|interface)\b/,Keyword,:classrule/\b(?:namespace|using)\b/,Keyword,:namespacerule/^#[ \t]*(#{cpp_keywords.join('|')})\b.*?\n/,Comment::Preprocrule/\b(#{keywords.join('|')})\b/,Keywordrule/\b(#{keywords_type.join('|')})\b/,Keyword::Typerule/#{id}(?=\s*[(])/,Name::Functionruleid,Nameendstate:classdomixin:whitespaceruleid,Name::Class,:pop!endstate:namespacedomixin:whitespacerule/(?=[(])/,Text,:pop!rule/(#{id}|[.])+/,Name::Namespace,:pop!endendendend