Skip to content

Commit 1cfa5b8

Browse files
authored
fix: c-style comments (#332)
1 parent a1fdb5b commit 1cfa5b8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: crates/pgt_lexer/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ pub enum TokenType {
2222
impl From<&ScanToken> for TokenType {
2323
fn from(token: &ScanToken) -> TokenType {
2424
match token.token {
25-
// SqlComment
26-
275 => TokenType::Whitespace,
25+
// SqlComment | CComment
26+
275 | 276 => TokenType::Whitespace,
2727
_ => match token.keyword_kind() {
2828
KeywordKind::NoKeyword => TokenType::NoKeyword,
2929
KeywordKind::UnreservedKeyword => TokenType::UnreservedKeyword,
@@ -59,6 +59,7 @@ pub static WHITESPACE_TOKENS: &[SyntaxKind] = &[
5959
SyntaxKind::Tab,
6060
SyntaxKind::Newline,
6161
SyntaxKind::SqlComment,
62+
SyntaxKind::CComment,
6263
];
6364

6465
static PATTERN_LEXER: LazyLock<Regex> = LazyLock::new(|| {

Diff for: crates/pgt_statement_splitter/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ mod tests {
142142
.expect_statements(vec!["insert into tbl (id) select 1", "select 3"]);
143143
}
144144

145+
#[test]
146+
fn c_style_comments() {
147+
Tester::from("/* this is a test */\nselect 1").expect_statements(vec!["select 1"]);
148+
}
149+
145150
#[test]
146151
fn with_check() {
147152
Tester::from("create policy employee_insert on journey_execution for insert to authenticated with check ((select private.organisation_id()) = organisation_id);")

0 commit comments

Comments
 (0)