reimplement C string literals

This commit is contained in:
Deadbeef 2023-07-16 18:59:05 +00:00
parent cec34a43b1
commit df9bd80d74
10 changed files with 48 additions and 89 deletions

View file

@ -24,6 +24,10 @@ impl<'a> Cursor<'a> {
}
}
pub fn as_str(&self) -> &'a str {
self.chars.as_str()
}
/// Returns the last eaten symbol (or `'\0'` in release builds).
/// (For debug assertions only.)
pub(crate) fn prev(&self) -> char {

View file

@ -367,6 +367,13 @@ impl Cursor<'_> {
Some(|terminated| Byte { terminated }),
),
// c-string literal, raw c-string literal or identifier.
'c' => self.c_or_byte_string(
|terminated| CStr { terminated },
|n_hashes| RawCStr { n_hashes },
None,
),
// Identifier (this should be checked after other variant that can
// start as identifier).
c if is_id_start(c) => self.ident_or_unknown_prefix(),