-
Notifications
You must be signed in to change notification settings - Fork 65
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
Error parsing strings with curly braces in JavaScript blocks #238
Comments
Yes, this is a known documented limitation, which will be eliminated in the future, when API for replacing part of grammar for parsing action code will be developed (because the goal of some plugins for pegjs/peggy is to replace javascript with another language). |
That's interesting. Do you plan to support one particular language or a bunch of them? Peggy has a nice syntax it would be nice to be able to use similar syntax for other languages. Do you have anything ready? BTW: That's funny: {
function foo(x) {
// { {
return x.replace(/\}/g, '}');
}
}
start = "x" this is valid! |
I plan to make an API that will allow plugins replace source code parsing part of the peggy grammar, so the plugins for other languages can implement a minimal subset to correctly parse braces for their languages. Peggy itself will contain only JS parser subset. When this will be implemented, I'll make issues/PRs to known plugins. |
Since this is documented, can we close this? |
I think, we can leave this open until proposed solution (pluggable |
To summarise what I said in the other issue: The one thing that poses a problem is regex literals since I haven't checked the performance of such a solution, but I expect the impact to be negligible compared to implementing a full ES parser. |
This is example that break the parser:
it throws:
In my language playground.
As a workaround I've used escaped value:
Curly braces in strings and regex confuse the parser. I've tried to use this on a Website:
and it throws random errors.
The text was updated successfully, but these errors were encountered: