Skip to content

Commit f3d3aa7

Browse files
committed
fix: adapt statement regexp to work with create or replace function statements
1 parent 0438601 commit f3d3aa7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

crates/parser/src/source_file.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ use crate::{parser::Parser, syntax_kind::SyntaxKind};
1212
#[derive(Logos, Debug, PartialEq)]
1313
#[logos(skip r"[ \t\f]+")] // Ignore this regex pattern between tokens
1414
pub enum SourceFileToken {
15-
// TODO: this only parses based on the semicolon, which will fail for statements that contain
16-
// subexperessions such as transactions or functions.
17-
#[regex("[a-zA-Z0-9_]+[^;]*;"gm)]
15+
#[regex("[a-zA-Z0-9_]+(?:'[^']*'|(?:\\$\\$[^$]*\\$\\$|[^';])+)*;"gm)]
1816
Statement,
1917
#[regex("\n+"gm)]
2018
Newline,

crates/parser/src/statement.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ impl Parser {
143143
// parse root node if no syntax errors
144144
if pg_query_nodes.peek().is_some() {
145145
let (node, depth, _) = pg_query_nodes.next().unwrap();
146+
// TODO: if root node is a create or alter function stmt, parse the function body
147+
// separately
146148
self.stmt(node.to_enum(), range);
147149
self.start_node_at(SyntaxKind::from_pg_query_node(&node), Some(depth));
148150
self.set_checkpoint(false);

0 commit comments

Comments
 (0)