Add support for semicolon-terminated statements according to the updated grammar. This change enables executing multiple SQL statements in a single input by separating them with semicolons. Key improvements include: - Update grammar to require semicolons after statements - Add Semicolon token to the tokenizer - Implement error recovery by skipping to next semicolon on parse errors - Create helper functions for checking semicolons in statement parsers - Add tests for multiple statements and error conditions
38 lines
1 KiB
Rust
38 lines
1 KiB
Rust
use crate::branding;
|
|
|
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
|
pub enum MetaCommand {
|
|
Exit,
|
|
About,
|
|
Version,
|
|
}
|
|
|
|
impl std::fmt::Display for MetaCommand {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
match self {
|
|
MetaCommand::Exit => write!(f, "exit"),
|
|
MetaCommand::About => write!(f, "about"),
|
|
MetaCommand::Version => write!(f, "version"),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub struct MetaCommandExecuteResult {
|
|
pub should_exit: bool,
|
|
}
|
|
|
|
impl MetaCommand {
|
|
pub fn execute(&self) -> MetaCommandExecuteResult {
|
|
match self {
|
|
MetaCommand::Exit => MetaCommandExecuteResult { should_exit: true },
|
|
MetaCommand::About => {
|
|
print!("{}", branding::about_msg());
|
|
MetaCommandExecuteResult { should_exit: false }
|
|
}
|
|
MetaCommand::Version => {
|
|
print!("{}", branding::version_msg());
|
|
MetaCommandExecuteResult { should_exit: false }
|
|
}
|
|
}
|
|
}
|
|
}
|