Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: Added char token #3270

Merged
merged 1 commit into from Dec 5, 2021
Merged

Conversation

RunDevelopment
Copy link
Member

@RunDevelopment RunDevelopment commented Dec 5, 2021

No description provided.

@github-actions
Copy link

github-actions bot commented Dec 5, 2021

JS File Size Changes (gzipped)

A total of 1 files have changed, with a combined diff of -5 B (-0.2%).

file master pull size diff % diff
components/prism-csharp.min.js 2.43 KB 2.43 KB -5 B -0.2%

Generated by 🚫 dangerJS against 5d167f4

Copy link
Contributor

@hoonweiting hoonweiting left a comment

What a coincidence! I was looking at this exact same thing a couple of hours ago too.

I did have a question though, and that is, should character have the quantifier {1,8} at the end?

// strings & characters
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#character-literals
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#string-literals
var character = /'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source; // simplified pattern

I ask because I remember you asked me to remove it from #3105. I'm not familiar enough with C# (not that I knew Elm either!), so should the quantifier be removed here to make it consistent with Elm, or be left as it is for some special reason?

@RunDevelopment
Copy link
Member Author

RunDevelopment commented Dec 5, 2021

I used {1,8} to allow unfinished characters for a better typing experience. This is also the reason why I asked you to change Elm's char quantifier.

I though [0-9a-fA-F]+ was the best choice for Elm because many other languages with a \u{0000} escape syntax allow arbitrarily long hex numbers to represent the code point. I don't know much about Elm, so I assumed it's the same here (Elm docs aren't clear about this).

C# on the hand only allows \x00, \u0000, and \U00000000 as hex escape sequences. So 2, 4, or 8 hex digits. Since the maximum is 8, I went with {1,8} instead of +.

@hoonweiting
Copy link
Contributor

hoonweiting commented Dec 5, 2021

Ahh I see, thank you for the explanation! This PR looks good to me!

@RunDevelopment RunDevelopment merged commit 220bc40 into PrismJS:master Dec 5, 2021
12 checks passed
@RunDevelopment RunDevelopment deleted the issue3170-cs branch Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants