summaryrefslogtreecommitdiffstats
path: root/sqlglotrs/src
diff options
context:
space:
mode:
Diffstat (limited to 'sqlglotrs/src')
-rw-r--r--sqlglotrs/src/settings.rs3
-rw-r--r--sqlglotrs/src/tokenizer.rs2
2 files changed, 4 insertions, 1 deletions
diff --git a/sqlglotrs/src/settings.rs b/sqlglotrs/src/settings.rs
index 9fb8fda..3068fd2 100644
--- a/sqlglotrs/src/settings.rs
+++ b/sqlglotrs/src/settings.rs
@@ -77,6 +77,7 @@ pub struct TokenizerSettings {
pub command_prefix_tokens: HashSet<TokenType>,
pub heredoc_tag_is_identifier: bool,
pub string_escapes_allowed_in_raw_strings: bool,
+ pub nested_comments: bool,
}
#[pymethods]
@@ -100,6 +101,7 @@ impl TokenizerSettings {
command_prefix_tokens: HashSet<TokenType>,
heredoc_tag_is_identifier: bool,
string_escapes_allowed_in_raw_strings: bool,
+ nested_comments: bool,
) -> Self {
let to_char = |v: &String| {
if v.len() == 1 {
@@ -150,6 +152,7 @@ impl TokenizerSettings {
command_prefix_tokens,
heredoc_tag_is_identifier,
string_escapes_allowed_in_raw_strings,
+ nested_comments,
}
}
}
diff --git a/sqlglotrs/src/tokenizer.rs b/sqlglotrs/src/tokenizer.rs
index ca5c44b..6df3bfb 100644
--- a/sqlglotrs/src/tokenizer.rs
+++ b/sqlglotrs/src/tokenizer.rs
@@ -375,7 +375,7 @@ impl<'a> TokenizerState<'a> {
self.advance(1)?;
// Nested comments are allowed by some dialects, e.g. databricks, duckdb, postgres
- if !self.is_end && self.chars(comment_start_size) == *comment_start {
+ if self.settings.nested_comments && !self.is_end && self.chars(comment_start_size) == *comment_start {
self.advance(comment_start_size as isize)?;
comment_count += 1
}