lib/rouge/lexers/csharp.rb in rouge-2.0.7 vs lib/rouge/lexers/csharp.rb in rouge-2.1.0

- old
+ new

@@ -24,11 +24,11 @@ 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 + yield nameof ascending by descending equals from group in into join let on orderby select ) keywords_type = %w( @@ -45,37 +45,56 @@ rule /\s+/m, Text rule %r(//.*?$), Comment::Single rule %r(/[*].*?[*]/)m, Comment::Multiline end + state :nest do + rule /{/, Punctuation, :nest + rule /}/, Punctuation, :pop! + mixin :root + end + + state :splice_string do + rule /\\./, Str + rule /{/, Punctuation, :nest + rule /"|\n/, Str, :pop! + rule /./, Str + end + + state :splice_literal do + rule /""/, Str + rule /{/, Punctuation, :nest + rule /"/, Str, :pop! + rule /./, Str + end + state :root do mixin :whitespace rule /^\s*\[.*?\]/, Name::Attribute - # rule /[$]\s*"/, Str, :splice_string - # rule /[$]\s*<#/, Str, :splice_recstring - # rule /<#/, Str, :recstring + rule /[$]\s*"/, Str, :splice_string + rule /[$]@\s*"/, Str, :splice_literal rule /(<\[)\s*(#{id}:)?/, Keyword rule /\]>/, Keyword rule /[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, Punctuation - rule /@"(\\.|.)*?"/, Str + rule /@"(""|[^"])*"/m, Str rule /"(\\.|.)*?["\n]/, Str rule /'(\\.|.)'/, Str::Char rule /0x[0-9a-f]+[lu]?/i, Num rule %r( [0-9] ([.][0-9]*)? # decimal (e[+-][0-9]+)? # exponent [fldu]? # type )ix, Num + rule /\b(?:class|struct|interface)\b/, Keyword, :class + rule /\b(?:namespace|using)\b/, Keyword, :namespace rule /^#[ \t]*(#{cpp_keywords.join('|')})\b.*?\n/, Comment::Preproc rule /\b(#{keywords.join('|')})\b/, Keyword rule /\b(#{keywords_type.join('|')})\b/, Keyword::Type - rule /class|struct/, Keyword, :class - rule /namespace|using/, Keyword, :namespace rule /#{id}(?=\s*[(])/, Name::Function rule id, Name end state :class do