-
Notifications
You must be signed in to change notification settings - Fork 62
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
naive statement splitter #142
base: main
Are you sure you want to change the base?
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 |
fn advance(&mut self) -> &Token { | ||
let mut first_relevant_token = None; | ||
loop { | ||
let token = self.tokens.get(self.next_pos).unwrap_or(&self.eof_token); |
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.
self.peek? 🤓
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.