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

Don't escape backslashes in grammar_codegen #916

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

racko
Copy link

@racko racko commented Jan 17, 2024

Fixes #915

inline constexpr absl::string_view kStrLiteral4 = "\"";
inline constexpr absl::string_view kStrLiteral13 = "]";
inline constexpr absl::string_view kStrLiteral5 = "\\";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the fix in antlr_frontend.cc, this (string of length one) "\\" would be (a string of length two) "\\\\".

// - No escape sequences (e.g., \n, \t, \uff01, etc.)
// - No unicode escape sequences (e.g., \uff01)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After at first adding the unicode escape sequences, I had to remove them again because nlohmann/json actually validates that the generated codepoints are "proper":
https://github.com/nlohmann/json/blob/a259ecc51e1951e12f757ce17db958e9881e9c6c/include/nlohmann/detail/input/lexer.hpp#L359-L381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backslashes are wrongly escaped in grammar_codegen
1 participant