-
Notifications
You must be signed in to change notification settings - Fork 102
naive statement splitter #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is so much simpler than the previous implementation. I love it.
// delete(p); | ||
} | ||
t => { | ||
panic!("stmt: Unknown token {:?}", t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
panic!("stmt: Unknown token {:?}", t); | |
panic!("stmt: Unknown start token {:?}", t); |
@juleswritescode I refactored the parser to work with an index into the vector. this comes with a few benefits:
edit: added a little test helper |
@juleswritescode I think this is ready now. dml statements should work good enough. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amazing work 💪
@@ -1,12 +0,0 @@ | |||
brin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YEAH ⛹️
r.start(), | ||
r.end() + TextSize::from(self.diff_size()), | ||
); | ||
*r = TextRange::new(r.start(), r.end() + self.diff_size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, strange that there's no method on the type for increasing the range 🤷
statement_ranges: text.as_ref().map_or_else(Vec::new, |f| { | ||
pg_statement_splitter::split(f).ranges.to_vec() | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty cool changes here in the file!
self.errors.push(SyntaxError::new( | ||
format!("Expected {:#?}", kind), | ||
self.peek().span, | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice! much cleaner.
naive attempt at splitting statements.
implements the splitter as a simple Pratt Parser. The approach now is the opposite of what I tried before: Instead of assuming it works perfectly as long as we cover all possible edge cases, we assume it does not work at all. We want to make all important cases work (mostly DML, a few DDL statements), while asking the user to fallback to a double newline if they are seeing weird things coming from the lsp.