-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
base: master
Are you sure you want to change the base?
Conversation
@@ -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 { |
There was a problem hiding this comment.
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() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -455,6 +509,42 @@ impl<'a> Lexer<'a> { | |||
} | |||
} | |||
|
|||
struct IdentBuffer<'a> { |
There was a problem hiding this comment.
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 Cow
s. We only allocate a buffer for the identifier if we encounter an explicit escape.
adds support for escaped identifiers such as
|foo bar|
.