-
Notifications
You must be signed in to change notification settings - Fork 66
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
Failed compilation with '"' #22
Comments
Yes, quote and double quote escapes is a difficult subject: the double quote is passed as input and transformed into D code, which is itself assembled as a string. So quotes create problems. It's easier to use predefined parsers to deal with them (you get them when you import pegged.grammar):
See https://github.com/PhilippeSigaud/Pegged/wiki/Predefined-Parsers There are also predefined parsers for end of lines, slashes, and so on. Do you have an example of a failed compilation? |
import pegged.grammar;
mixin(grammar(`A < '"'`));
void main ()
{
}
|
Yeah, that's because it's difficult to propagate a double quote as a string argument to a template, when this template is itself being assembled as a string. Use import pegged.grammar;
mixin(grammar(`A < DoubleQuote`));
void main ()
{
} |
Will do, just checking it wasn't an unknown bug, thanks :) |
It's a known bug :) I should write a wiki page specifically on string escaping. IIRC I tried to automatically escape quotes with " and ', but it didn't work at the time. |
That would be really useful. |
It fails compilation if I put
'"'
, using'\"'
compiles fine.The text was updated successfully, but these errors were encountered: