mirror of
https://github.com/alecthomas/chroma.git
synced 2025-03-17 20:58:08 +02:00
Update C# lexer (#811)
* Fix CommentPreproc regex (and update corresponding test) * Separate KeywordDeclaration and KeywordConstant from Keyword list (similar to Java lexer). * Update csharp lexer tests. * Remove duplicate keyword 'static' from csharp lexer.
This commit is contained in:
parent
9864526122
commit
2aad7403e6
@ -52,7 +52,7 @@
|
||||
<rule pattern="0[xX][0-9a-fA-F]+[Ll]?|\d[_\d]*(\.\d*)?([eE][+-]?\d+)?[flFLdD]?">
|
||||
<token type="LiteralNumber"/>
|
||||
</rule>
|
||||
<rule pattern="#[ \t]*(if|endif|else|elif|define|undef|line|error|warning|region|endregion|pragma|nullable)\b[^\n\r]+">
|
||||
<rule pattern="#[ \t]*(if|endif|else|elif|define|undef|line|error|warning|region|endregion|pragma|nullable)\b">
|
||||
<token type="CommentPreproc"/>
|
||||
</rule>
|
||||
<rule pattern="\b(extern)(\s+)(alias)\b">
|
||||
@ -62,7 +62,7 @@
|
||||
<token type="Keyword"/>
|
||||
</bygroups>
|
||||
</rule>
|
||||
<rule pattern="(abstract|as|async|await|base|break|by|case|catch|checked|const|continue|default|delegate|do|else|enum|event|explicit|extern|false|finally|fixed|for|foreach|goto|if|implicit|in|init|internal|is|let|lock|new|null|on|operator|out|override|params|private|protected|public|readonly|ref|return|sealed|sizeof|stackalloc|static|switch|this|throw|true|try|typeof|unchecked|unsafe|virtual|void|while|get|set|new|partial|yield|add|remove|value|alias|ascending|descending|from|group|into|orderby|select|thenby|where|join|equals)\b">
|
||||
<rule pattern="(as|await|base|break|by|case|catch|checked|continue|default|delegate|do|else|event|finally|fixed|for|foreach|goto|if|in|init|is|let|lock|new|on|out|params|readonly|ref|return|sizeof|stackalloc|switch|this|throw|try|typeof|unchecked|virtual|void|while|get|set|new|yield|add|remove|value|alias|ascending|descending|from|group|into|orderby|select|thenby|where|join|equals)\b">
|
||||
<token type="Keyword"/>
|
||||
</rule>
|
||||
<rule pattern="(global)(::)">
|
||||
@ -71,9 +71,15 @@
|
||||
<token type="Punctuation"/>
|
||||
</bygroups>
|
||||
</rule>
|
||||
<rule pattern="(abstract|async|const|enum|explicit|extern|implicit|internal|operator|override|partial|private|protected|public|static|sealed|unsafe|volatile)\b">
|
||||
<token type="KeywordDeclaration"/>
|
||||
</rule>
|
||||
<rule pattern="(bool|byte|char|decimal|double|dynamic|float|int|long|object|sbyte|short|string|uint|ulong|ushort|var)\b\??">
|
||||
<token type="KeywordType"/>
|
||||
</rule>
|
||||
<rule pattern="(true|false|null)\b">
|
||||
<token type="KeywordConstant"/>
|
||||
</rule>
|
||||
<rule pattern="(class|struct|record|interface)(\s+)">
|
||||
<bygroups>
|
||||
<token type="Keyword"/>
|
||||
|
@ -4,9 +4,11 @@
|
||||
{"type":"NameNamespace","value":"System"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"CommentPreproc","value":"#nullable enable"},
|
||||
{"type":"CommentPreproc","value":"#nullable"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"enable"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"Keyword","value":"public"},
|
||||
{"type":"KeywordDeclaration","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Keyword","value":"struct"},
|
||||
{"type":"Text","value":" "},
|
||||
@ -14,21 +16,21 @@
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"public"},
|
||||
{"type":"KeywordDeclaration","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordType","value":"string"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"FirstName"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"public"},
|
||||
{"type":"KeywordDeclaration","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordType","value":"string?"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"MiddleName"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"public"},
|
||||
{"type":"KeywordDeclaration","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordType","value":"string"},
|
||||
{"type":"Text","value":" "},
|
||||
|
@ -1,5 +1,5 @@
|
||||
[
|
||||
{"type":"Keyword","value":"public"},
|
||||
{"type":"KeywordDeclaration","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Keyword","value":"record"},
|
||||
{"type":"Text","value":" "},
|
||||
|
@ -1,5 +1,5 @@
|
||||
[
|
||||
{"type":"Keyword","value":"public"},
|
||||
{"type":"KeywordDeclaration","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Keyword","value":"record"},
|
||||
{"type":"Text","value":" "},
|
||||
@ -7,7 +7,7 @@
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"public"},
|
||||
{"type":"KeywordDeclaration","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordType","value":"string"},
|
||||
{"type":"Text","value":" "},
|
||||
@ -28,7 +28,7 @@
|
||||
{"type":"Keyword","value":"default"},
|
||||
{"type":"Punctuation","value":"!;"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"public"},
|
||||
{"type":"KeywordDeclaration","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"KeywordType","value":"string"},
|
||||
{"type":"Text","value":" "},
|
||||
|
@ -1,5 +1,5 @@
|
||||
[
|
||||
{"type":"Keyword","value":"public"},
|
||||
{"type":"KeywordDeclaration","value":"public"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Keyword","value":"interface"},
|
||||
{"type":"Text","value":" "},
|
||||
|
Loading…
x
Reference in New Issue
Block a user