From 2aad7403e629153e8d57d6b0dbcb4dbee0940faf Mon Sep 17 00:00:00 2001 From: Christian Woltering Date: Tue, 15 Aug 2023 23:46:32 +0200 Subject: [PATCH] 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. --- lexers/embedded/csharp.xml | 10 ++++++++-- lexers/testdata/csharp/csharp_8_nullable.expected | 12 +++++++----- lexers/testdata/csharp/csharp_9_records_1.expected | 2 +- lexers/testdata/csharp/csharp_9_records_2.expected | 6 +++--- lexers/testdata/csharp/csharp_interface.expected | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lexers/embedded/csharp.xml b/lexers/embedded/csharp.xml index 8c2ff45..801a954 100644 --- a/lexers/embedded/csharp.xml +++ b/lexers/embedded/csharp.xml @@ -52,7 +52,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -71,9 +71,15 @@ + + + + + + diff --git a/lexers/testdata/csharp/csharp_8_nullable.expected b/lexers/testdata/csharp/csharp_8_nullable.expected index 61cfde3..448fb04 100644 --- a/lexers/testdata/csharp/csharp_8_nullable.expected +++ b/lexers/testdata/csharp/csharp_8_nullable.expected @@ -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":" "}, diff --git a/lexers/testdata/csharp/csharp_9_records_1.expected b/lexers/testdata/csharp/csharp_9_records_1.expected index 4bf2446..8117222 100644 --- a/lexers/testdata/csharp/csharp_9_records_1.expected +++ b/lexers/testdata/csharp/csharp_9_records_1.expected @@ -1,5 +1,5 @@ [ - {"type":"Keyword","value":"public"}, + {"type":"KeywordDeclaration","value":"public"}, {"type":"Text","value":" "}, {"type":"Keyword","value":"record"}, {"type":"Text","value":" "}, diff --git a/lexers/testdata/csharp/csharp_9_records_2.expected b/lexers/testdata/csharp/csharp_9_records_2.expected index 56ac690..37b4f38 100644 --- a/lexers/testdata/csharp/csharp_9_records_2.expected +++ b/lexers/testdata/csharp/csharp_9_records_2.expected @@ -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":" "}, diff --git a/lexers/testdata/csharp/csharp_interface.expected b/lexers/testdata/csharp/csharp_interface.expected index dfd0f61..8ac9e10 100644 --- a/lexers/testdata/csharp/csharp_interface.expected +++ b/lexers/testdata/csharp/csharp_interface.expected @@ -1,5 +1,5 @@ [ - {"type":"Keyword","value":"public"}, + {"type":"KeywordDeclaration","value":"public"}, {"type":"Text","value":" "}, {"type":"Keyword","value":"interface"}, {"type":"Text","value":" "},