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

support escaped identifiers #310

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jrvidal
Copy link
Contributor

@jrvidal jrvidal commented Feb 18, 2025

adds support for escaped identifiers such as |foo bar|.

@@ -16,13 +17,13 @@ pub const NEG_NAN: &str = "-nan.0";
pub struct OwnedString;

impl ToOwnedString<String> for OwnedString {
fn own(&self, s: &str) -> String {
fn own(&self, s: Cow<str>) -> String {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This Cow epidemic is a bit noisy.

while let Some(&c) = self.chars.peek() {
match c {
c if c.is_numeric() => {
c if c.is_ascii_digit() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

⚠️ Unrelated fix.

@@ -455,6 +509,42 @@ impl<'a> Lexer<'a> {
}
}

struct IdentBuffer<'a> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a small helper to optimize all those Cows. We only allocate a buffer for the identifier if we encounter an explicit escape.

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.

1 participant