diff --git a/example/stmt.sql b/example/stmt.sql index 54a333e..12e6201 100644 --- a/example/stmt.sql +++ b/example/stmt.sql @@ -35,5 +35,9 @@ ROLLBACK TO save_point; ROLLBACK TO SAVEPOINT save_point; ROLLBACK TRANSACTION; ROLLBACK TRANSACTION TO save_point; -ROLLBACK TRANSACTION TO SAVEPOINT 'huh'; +ROLLBACK TRANSACTION TO SAVEPOINT save_point; /* ------------------------------------------------------ */ + +-- https://www.sqlite.org/lang_detach.html +DETACH schema_name; +DETACH DATABASE schema_name; diff --git a/src/lexer/tests.rs b/src/lexer/tests.rs index 0581289..0851eec 100644 --- a/src/lexer/tests.rs +++ b/src/lexer/tests.rs @@ -39,6 +39,7 @@ macro_rules! test_group_fail { #[cfg(test)] mod should_pass { + test_group_pass_assert! { booleans, r#true: "true"=vec![Type::Boolean(true)], diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 32353e8..f0e487a 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -143,7 +143,6 @@ impl<'a> Parser<'a> { } err.doc_url = Some("https://www.sqlite.org/syntax/sql-stmt.html"); self.errors.push(err); - self.advance(); } self.advance(); // we advance either way to keep the parser error resistant } diff --git a/src/parser/nodes.rs b/src/parser/nodes.rs index b153882..671777b 100644 --- a/src/parser/nodes.rs +++ b/src/parser/nodes.rs @@ -41,18 +41,29 @@ node!( Literal, "holds all literal types, such as strings, numbers, etc.", ); + node!(Explain,"Explain stmt, see: https://www.sqlite.org/lang_explain.html", child: Option>); + node!(Vacuum,"Vacuum stmt, see: https://www.sqlite.org/lang_vacuum.html", schema_name: Option, filename: Option); + node!( Begin, "Begin stmt, see: https://www.sqlite.org/syntax/begin-stmt.html", ); + node!( Commit, "Commit stmt, see: https://www.sqlite.org/syntax/commit-stmt.html", ); + node!( Rollback, "Rollback stmt, see: https://www.sqlite.org/syntax/rollback-stmt.html", save_point: Option ); + +node!( + Detach, + "Rollback stmt, see: https://www.sqlite.org/syntax/rollback-stmt.html", + schema_name: String +); diff --git a/src/parser/tests.rs b/src/parser/tests.rs index 5d96677..5dd441d 100644 --- a/src/parser/tests.rs +++ b/src/parser/tests.rs @@ -108,6 +108,14 @@ EXPLAIN VACUUM; rollback_transaction_to_save_point:r"ROLLBACK TRANSACTION TO save_point;"=vec![Type::Keyword(Keyword::ROLLBACK)], rollback_transaction_to_savepoint_save_point:r"ROLLBACK TRANSACTION TO SAVEPOINT save_point;"=vec![Type::Keyword(Keyword::ROLLBACK)] } + + test_group_pass_assert! { + detach_stmt, + + detach:r"DETACH;"=vec![Type::Keyword(Keyword::DETACH)], + detach_schema_name:r"DETACH schema_name;"=vec![Type::Keyword(Keyword::DETACH)], + detach_database_schema_name:r"DETACH DATABASE schema_name;"=vec![Type::Keyword(Keyword::DETACH)] + } } #[cfg(test)]