-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add more string litral formats (from postgres) and numbers foramts
Add bit string literal https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-BIT-STRINGS Add unicode string https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-UESCAPE Add exponent in integers and decimals https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS-NUMERIC Add hexadecimal, binary and octal formats Add '_' as separator of digits Add string casting (eg: REAL '1.23')
- Loading branch information
Showing
2 changed files
with
193 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
================================================================================ | ||
Hexadecimal number | ||
================================================================================ | ||
|
||
SELECT 0xAA; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal)))))) | ||
|
||
================================================================================ | ||
binary number | ||
================================================================================ | ||
|
||
SELECT 0b1010; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal)))))) | ||
|
||
================================================================================ | ||
big integer with _ separators | ||
================================================================================ | ||
|
||
SELECT 1_000_000_000; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal)))))) | ||
|
||
================================================================================ | ||
integer with exponent with _ separators | ||
================================================================================ | ||
|
||
SELECT 12e1_000; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal)))))) | ||
|
||
================================================================================ | ||
decimal with exponent | ||
================================================================================ | ||
|
||
SELECT .2e-1_000; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal)))))) | ||
|
||
================================================================================ | ||
positive number | ||
================================================================================ | ||
|
||
SELECT +1; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal)))))) | ||
|
||
================================================================================ | ||
bit string | ||
================================================================================ | ||
|
||
SELECT b'1010'; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal)))))) | ||
|
||
================================================================================ | ||
bit string (hexa) | ||
================================================================================ | ||
|
||
SELECT x'AF'; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal)))))) | ||
|
||
================================================================================ | ||
multi line string | ||
================================================================================ | ||
|
||
SELECT 'hello ' | ||
'world'; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal)))))) | ||
|
||
================================================================================ | ||
unicode string | ||
================================================================================ | ||
|
||
SELECT u&'\041f\0440\0438\0432\0456\0442 ' | ||
'\0421\0432\0456\0442'; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal)))))) | ||
|
||
================================================================================ | ||
string casting | ||
================================================================================ | ||
|
||
SELECT int '123'; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(select | ||
(keyword_select) | ||
(select_expression | ||
(term | ||
(literal | ||
(identifier))))))) |