summaryrefslogtreecommitdiffstats
path: root/sqlglotrs/src/tokenizer.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-12 06:15:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-12 06:15:14 +0000
commit8fd7374bf370b99577a40d4de1716ad990d5a34b (patch)
tree061ecaf38b8a390a8a70348eea1fd11233f9e19c /sqlglotrs/src/tokenizer.rs
parentAdding upstream version 21.0.1. (diff)
downloadsqlglot-8fd7374bf370b99577a40d4de1716ad990d5a34b.tar.xz
sqlglot-8fd7374bf370b99577a40d4de1716ad990d5a34b.zip
Adding upstream version 21.0.2.upstream/21.0.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglotrs/src/tokenizer.rs')
-rw-r--r--sqlglotrs/src/tokenizer.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/sqlglotrs/src/tokenizer.rs b/sqlglotrs/src/tokenizer.rs
index 920a5b5..94a8b08 100644
--- a/sqlglotrs/src/tokenizer.rs
+++ b/sqlglotrs/src/tokenizer.rs
@@ -399,6 +399,19 @@ impl<'a> TokenizerState<'a> {
} else if *token_type == self.token_types.bit_string {
(Some(2), *token_type, end.clone())
} else if *token_type == self.token_types.heredoc_string {
+ if self.settings.heredoc_tag_is_identifier
+ && !self.is_identifier(self.peek_char)
+ && self.peek_char.to_string() != *end
+ {
+ if self.token_types.heredoc_string_alternative != self.token_types.var {
+ self.add(self.token_types.heredoc_string_alternative, None)?
+ } else {
+ self.scan_var()?
+ };
+
+ return Ok(true)
+ };
+
self.advance(1)?;
let tag = if self.current_char.to_string() == *end {
String::from("")
@@ -469,7 +482,7 @@ impl<'a> TokenizerState<'a> {
} else if self.peek_char.to_ascii_uppercase() == 'E' && scientific == 0 {
scientific += 1;
self.advance(1)?;
- } else if self.peek_char.is_alphabetic() || self.peek_char == '_' {
+ } else if self.is_identifier(self.peek_char) {
let number_text = self.text();
let mut literal = String::from("");
@@ -643,6 +656,10 @@ impl<'a> TokenizerState<'a> {
Ok(text)
}
+ fn is_identifier(&mut self, name: char) -> bool {
+ name.is_alphabetic() || name == '_'
+ }
+
fn extract_value(&mut self) -> Result<String, TokenizerError> {
loop {
if !self.peek_char.is_whitespace()