use super::Lexer;
use radixdb_core::SmartString;
impl Lexer {
pub(super) fn read_identifier(&mut self) -> SmartString {
let mut result = SmartString::new("");
result.push(self.ch);
self.read_char();
while self.ch.is_alphanumeric() || self.ch == '_' || self.ch == '$' {
result.push(self.ch);
self.read_char();
}
result
}
pub(super) fn read_quoted_identifier(&mut self, quote: char) -> SmartString {
let mut result = SmartString::new("");
self.read_char();
while !self.eof && self.ch != '\0' {
if self.ch == quote && self.peek_char() == quote {
result.push(self.ch);
self.read_char(); self.read_char(); } else if self.ch == quote {
break;
} else {
result.push(self.ch);
self.read_char();
}
}
if self.ch == quote {
self.read_char();
} else if self.eof {
self.last_error = Some(format!(
"unterminated quoted identifier starting with {}",
quote
));
} else {
self.last_error =
Some("NULL byte (0x00) is not allowed in quoted identifiers".to_string());
}
result
}
pub(super) fn read_parameter(&mut self) -> SmartString {
let mut result = SmartString::new("");
result.push(self.ch); self.read_char();
while self.ch.is_ascii_digit() {
result.push(self.ch);
self.read_char();
}
if result.len() == 1 {
self.last_error = Some("parameter number expected after $".to_string());
}
result
}
pub(super) fn read_named_parameter(&mut self) -> SmartString {
let mut result = SmartString::new("");
result.push(self.ch); self.read_char();
while self.ch.is_alphanumeric() || self.ch == '_' {
result.push(self.ch);
self.read_char();
}
result
}
}