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
42 lines
975 B
EBNF
42 lines
975 B
EBNF
/* token is first stage of parsing */
|
|
token ::= insert
|
|
| select
|
|
| meta-command
|
|
| int
|
|
| string
|
|
| semicolon
|
|
| end-of-file
|
|
|
|
/* command is second stage of parsing */
|
|
command ::= cmd-insert semicolon
|
|
| cmd-select semicolon
|
|
cmd-insert ::= insert int string string
|
|
cmd-select ::= select
|
|
|
|
insert ::= "insert"
|
|
select ::= "select"
|
|
semicolon ::= ";"
|
|
|
|
meta-command ::= "." "exit"
|
|
| "about"
|
|
| "version"
|
|
|
|
int ::= sign? digit+
|
|
sign ::= "+"
|
|
| "-"
|
|
digit ::= "0"
|
|
| "1"
|
|
| "2"
|
|
| "3"
|
|
| "4"
|
|
| "5"
|
|
| "6"
|
|
| "7"
|
|
| "8"
|
|
| "9"
|
|
|
|
string ::= '"' string-char* '"'
|
|
string-char ::= '\' utf8-char
|
|
| utf8-char-not-dbl-quote
|
|
|
|
|