From 6b616f620d9aa76e0ff7eac4d59013857edd1388 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Sat, 12 Apr 2025 21:28:21 +0200 Subject: [PATCH] fix: c-style comments --- crates/pgt_lexer/src/lib.rs | 5 +++-- crates/pgt_statement_splitter/src/lib.rs | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/pgt_lexer/src/lib.rs b/crates/pgt_lexer/src/lib.rs index ce47725d..32bbdd42 100644 --- a/crates/pgt_lexer/src/lib.rs +++ b/crates/pgt_lexer/src/lib.rs @@ -22,8 +22,8 @@ pub enum TokenType { impl From<&ScanToken> for TokenType { fn from(token: &ScanToken) -> TokenType { match token.token { - // SqlComment - 275 => TokenType::Whitespace, + // SqlComment | CComment + 275 | 276 => TokenType::Whitespace, _ => match token.keyword_kind() { KeywordKind::NoKeyword => TokenType::NoKeyword, KeywordKind::UnreservedKeyword => TokenType::UnreservedKeyword, @@ -59,6 +59,7 @@ pub static WHITESPACE_TOKENS: &[SyntaxKind] = &[ SyntaxKind::Tab, SyntaxKind::Newline, SyntaxKind::SqlComment, + SyntaxKind::CComment, ]; static PATTERN_LEXER: LazyLock = LazyLock::new(|| { diff --git a/crates/pgt_statement_splitter/src/lib.rs b/crates/pgt_statement_splitter/src/lib.rs index 68f5daaf..4af5d5b4 100644 --- a/crates/pgt_statement_splitter/src/lib.rs +++ b/crates/pgt_statement_splitter/src/lib.rs @@ -142,6 +142,11 @@ mod tests { .expect_statements(vec!["insert into tbl (id) select 1", "select 3"]); } + #[test] + fn c_style_comments() { + Tester::from("/* this is a test */\nselect 1").expect_statements(vec!["select 1"]); + } + #[test] fn with_check() { Tester::from("create policy employee_insert on journey_execution for insert to authenticated with check ((select private.organisation_id()) = organisation_id);")