feat(parser): implement semicolon-separated statements

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
This commit is contained in:
Khaïs COLIN 2025-06-03 17:53:22 +02:00
parent 28cb288eaf
commit e78511f692
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
11 changed files with 237 additions and 75 deletions

View file

@ -231,14 +231,27 @@ i will use rustyline, since it seems like the most feature-complete
* TODO .license meta-command
* TODO .help meta-command
* TODO parse insert statements in the form
* DONE parse insert statements in the form
insert <id:int> <username:string> <email:string>
** TODO Row struct
** TODO parse row insert
** TODO separate statements with semicolons
** TODO in case of parse error, skip until next semicolon to better recover
** TODO serialize/deserialize row to/from raw bytes
*** TODO look for best practices for creating binary formats
** DONE parse row insert
* DONE separate statements with semicolons
* TODO this error message could be better
#+begin example
Error: unexpected token
╭─[ <stdin>:1:24 ]
1 │ insert 0 "user" "email"
│ │
│ ╰─ found end of file ""
│ Note: expected token type to be one of ["semicolon"]
───╯
#+end example
* TODO correct all instances of <unknown> in locations
* TODO meta-commands must be followed by end-of-file
* DONE in case of parse error, skip until next semicolon to better recover
* TODO serialize/deserialize row to/from raw bytes
** TODO look for best practices for creating binary formats
* WAIT cli tests using insta-cmd
https://insta.rs/docs/cmd/