diff options
author | Jan de Visser <jan@de-visser.net> | 2021-06-21 11:20:09 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-24 00:36:53 +0200 |
commit | 5c4890411b9fdd8f8d44f20e833452f01fa67917 (patch) | |
tree | 7a392cf0e2ca0637f30cb61bc01a5c0ea444f56b /Kernel/Panic.cpp | |
parent | 4198f7e1af7997e0615891289194752f1375f5a1 (diff) | |
download | serenity-5c4890411b9fdd8f8d44f20e833452f01fa67917.zip |
LibSQL: Make lexer and parser more standard SQL compliant
SQL was standardized before there was consensus on sane language syntax
constructs had evolved. The language is mostly case-insensitive, with
unquoted text converted to upper case. Identifiers can include lower
case characters and other 'special' characters by enclosing the
identifier with double quotes. A double quote is escaped by doubling it.
Likewise, a single quote in a literal string is escaped by doubling it.
All this means that the strategy used in the lexer, where a token's
value is a StringView 'window' on the source string, does not work,
because the value needs to be massaged before being handed to the
parser. Therefore a token now has a String containing its value. Given
the limited lifetime of a token, this is acceptable overhead.
Not doing this means that for example quote removal and double quote
escaping would need to be done in the parser or in AST node
construction, which would spread lexing basically all over the place.
Which would be suboptimal.
There was some impact on the sql utility and SyntaxHighlighter component
which was addressed by storing the token's end position together with
the start position in order to properly highlight it.
Finally, reviewing the tests for parsing numeric literals revealed an
inconsistency in which tokens we accept or reject: `1a` is accepted but
`1e` is rejected. Related to this is the fate of `0x`. Added a FIXME
reminding us to address this.
Diffstat (limited to 'Kernel/Panic.cpp')
0 files changed, 0 insertions, 0 deletions