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
6.3 KiB
Notes
- show errors with ariadne
- [X] errors should have a generic show() function
- OSDBError::display() should take a filename and display it alongside the error
- OSDBError::display() should take an input string, to be able to resolve spans inside the error
- OSDBError::display() should generate ariadne errors and return those
- error display should include a span to show where the error occured
- deduplicate error display code
- snapshot testing
- exit message is not displayed when pressing C-d
- switch statement parsing to more extensible token-based algorithm
- recognize meta-commands as tokens
- CommandParseError must have a ScanError variant with an Into impl
- ScanErrors must be convertible to ariadne reports
- remove token types which are not recognized at all
- create a generic parse command that parses string into tokens into Command
- parse tokens into meta-commands
- error offsets are incorrect
- remove old FromStr parser implementation
- use a better readline impl
- handle non-interactive input better
- show marking where error occurs
- remove uneeded error variants
- parse integers
- parse strings
- better error message display for unclosed " in string
- print errors to stderr
- write a proper grammar
- .about meta-command
- .version meta-command
- .license meta-command
- .help meta-command
- parse insert statements in the form
- separate statements with semicolons
- this error message could be better
- correct all instances of <unknown> in locations
- meta-commands must be followed by end-of-file
- in case of parse error, skip until next semicolon to better recover
- serialize/deserialize row to/from raw bytes
- WAIT cli tests using insta-cmd
- WAIT autocompletion
- WAIT tweak rustyline it to make multiline entry work
DONE show errors with ariadne
[X] errors should have a generic show() function
CLOCK: [2025-05-03 sam. 18:40]–[2025-05-03 sam. 18:46] => 0:06
DONE OSDBError::display() should take a filename and display it alongside the error
CLOCK: [2025-05-03 sam. 21:24]–[2025-05-03 sam. 21:28] => 0:04
DONE OSDBError::display() should take an input string, to be able to resolve spans inside the error
CLOCK: [2025-05-03 sam. 21:28]–[2025-05-03 sam. 21:30] => 0:02
DONE OSDBError::display() should generate ariadne errors and return those
CLOCK: [2025-05-03 sam. 21:30]–[2025-05-03 sam. 21:50] => 0:20
DONE error display should include a span to show where the error occured
CLOCK: [2025-05-03 sam. 21:51]–[2025-05-03 sam. 21:54] => 0:03
DONE deduplicate error display code
CLOCK: [2025-05-03 sam. 21:55]–[2025-05-03 sam. 22:01] => 0:06
DONE snapshot testing
DONE Find the snapshot testing library
CLOCK: [2025-05-03 sam. 18:48]–[2025-05-03 sam. 18:49] => 0:01
DONE document myself on insta, the snapshot testing library
CLOCK: [2025-05-03 sam. 18:49]–[2025-05-03 sam. 18:57] => 0:08
DONE insta test startup message
CLOCK: [2025-05-03 sam. 19:00]–[2025-05-03 sam. 19:05] => 0:05
DONE insta test insert
CLOCK: [2025-05-03 sam. 21:10]–[2025-05-03 sam. 21:14] => 0:04 CLOCK: [2025-05-03 sam. 19:08]–[2025-05-03 sam. 19:21] => 0:13
DONE all display of command results must be made via a display method on CommandExecutionResult
CLOCK: [2025-05-03 sam. 21:02]–[2025-05-03 sam. 21:09] => 0:07
DONE insta test select
CLOCK: [2025-05-03 sam. 21:15]–[2025-05-03 sam. 21:16] => 0:01
DONE insta test .exit
CLOCK: [2025-05-03 sam. 21:16]–[2025-05-03 sam. 21:18] => 0:02
DONE insta test wrong statement
CLOCK: [2025-05-03 sam. 21:18]–[2025-05-03 sam. 21:21] => 0:03
DONE insta test wrong meta-command
CLOCK: [2025-05-03 sam. 21:21]–[2025-05-03 sam. 21:22] => 0:01
DONE exit message is not displayed when pressing C-d bug
CLOCK: [2025-05-03 sam. 19:06]–[2025-05-03 sam. 19:07] => 0:01
DONE switch statement parsing to more extensible token-based algorithm
CLOCK: [2025-05-04 dim. 12:07]–[2025-05-04 dim. 12:10] => 0:03 CLOCK: [2025-05-04 dim. 12:10]–[2025-05-04 dim. 12:22] => 0:12
DONE recognize meta-commands as tokens
CLOCK: [2025-05-04 dim. 13:32]–[2025-05-04 dim. 13:35] => 0:03 CLOCK: [2025-05-04 dim. 13:27]–[2025-05-04 dim. 13:32] => 0:05
DONE CommandParseError must have a ScanError variant with an Into impl
CLOCK: [2025-05-04 dim. 13:35]–[2025-05-04 dim. 13:38] => 0:03
DONE ScanErrors must be convertible to ariadne reports
DONE Remove the CommandParseError Display implementation
CLOCK: [2025-05-04 dim. 13:38]–[2025-05-04 dim. 13:44] => 0:06
DONE implement OSDBError for ScanError
CLOCK: [2025-05-04 dim. 13:45]–[2025-05-04 dim. 13:56] => 0:11
DONE remove token types which are not recognized at all
DONE create a generic parse command that parses string into tokens into Command
CLOCK: [2025-05-04 dim. 14:01]–[2025-05-04 dim. 14:14] => 0:13
DONE parse tokens into meta-commands
DONE error offsets are incorrect
DONE remove old FromStr parser implementation
DONE use a better readline impl
DONE inform myself on the different alternatives and decide on one
i will use rustyline, since it seems like the most feature-complete
DONE do the impl
DONE make history work
DONE have the rl instance be spawned from main
DONE figure out how to locate the app data directory on linux
DONE create our own app data directory
DONE load and save the history from a file in this directory
DONE handle non-interactive input better
DONE show marking where error occurs
DONE remove uneeded error variants
DONE parse integers
DONE Function to get a token until condition is false
DONE Parse the integer
DONE parse strings
DONE better error message display for unclosed " in string
DONE print errors to stderr
DONE write a proper grammar
DONE .about meta-command
DONE .version meta-command
TODO .license meta-command
TODO .help meta-command
DONE parse insert statements in the form
insert <id:int> <username:string> <email:string>
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
WAIT autocompletion
needs a more complicated parser for that to make sense
WAIT tweak rustyline it to make multiline entry work
need to terminate commands with semicolons for that to make sense