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

CSharp grammar has incorrect definition of Interpolated Strings #1146

Open
attodorov opened this issue May 24, 2018 · 2 comments
Open

CSharp grammar has incorrect definition of Interpolated Strings #1146

attodorov opened this issue May 24, 2018 · 2 comments
Labels

Comments

@attodorov
Copy link

From the grammar:

interpolated_verbatium_string_part
	: interpolated_string_expression
	| DOUBLE_CURLY_INSIDE
	| VERBATIUM_DOUBLE_QUOTE_INSIDE
	| VERBATIUM_INSIDE_STRING
	;

It's not a double curly by spec. It's a single curly. Here's the correct def:

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated

So the grammar should be

interpolated_verbatium_string_part
	: interpolated_string_expression
	| SINGLE_CURLY_INSIDE
	| VERBATIUM_DOUBLE_QUOTE_INSIDE
	| VERBATIUM_INSIDE_STRING
	;
@attodorov
Copy link
Author

hmm, this still doesn't seem right for other scenarios. If I use the original (unmodified) current grammar, I am experiencing issues with the following code snippets:

s = Regex.Replace(s, pname, $"'{p.Value:MM/dd/yy HH:mm:ss}'");

 Db.Email(person.FromEmail, list,
   	                "Volunteer Substitute Commitment for "   org.OrganizationName,
   	                $@"
   	<p>{person.Name} has requested a substitute on {attend.MeetingDate:MMM d} at {attend.MeetingDate:h:mm tt}.</p>
   	<blockquote>
   	{reportlink}
   	</blockquote>");

public string Schedule => $"{MeetingTime:ddd h:mm tt}";

Thanks

@attodorov
Copy link
Author

I found this:

https://github.com/ljw1004/csharpspec/pull/1/files

as well as this:

https://github.com/ljw1004/csharpspec/blob/gh-pages/csharp.g4

But i am having a bit of a hard time transferring the interpolated string spec to the current ANTLR4 grammar.

Thanks,
Angel

@KvanTTT KvanTTT added the csharp label May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants