-
Notifications
You must be signed in to change notification settings - Fork 63
Add to non-reserved keywords; rework functionName
and symbolPrimitive
parse rules
#1457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,9 @@ byIdent | |
: BY symbolPrimitive; | ||
|
||
symbolPrimitive | ||
: ident=( IDENTIFIER | IDENTIFIER_QUOTED ) | ||
: IDENTIFIER # IdentifierUnquoted | ||
| IDENTIFIER_QUOTED # IdentifierQuoted | ||
| nonReserved # IdentifierUnquoted | ||
; | ||
|
||
/** | ||
|
@@ -653,8 +655,8 @@ exprPrimary | |
| dateFunction # ExprPrimaryBase | ||
| aggregate # ExprPrimaryBase | ||
| trimFunction # ExprPrimaryBase | ||
| functionCall # ExprPrimaryBase | ||
| nullIf # ExprPrimaryBase | ||
| functionCall # ExprPrimaryBase | ||
| exprPrimary pathStep+ # ExprPrimaryPath | ||
| exprGraphMatchMany # ExprPrimaryBase | ||
| caseExpr # ExprPrimaryBase | ||
|
@@ -761,13 +763,7 @@ dateFunction | |
|
||
// SQL-99 10.4 — <routine invocation> ::= <routine name> <SQL argument list> | ||
functionCall | ||
: functionName PAREN_LEFT ( expr ( COMMA expr )* )? PAREN_RIGHT | ||
; | ||
|
||
// SQL-99 10.4 — <routine name> ::= [ <schema name> <period> ] <qualified identifier> | ||
functionName | ||
: (qualifier+=symbolPrimitive PERIOD)* name=( CHAR_LENGTH | CHARACTER_LENGTH | OCTET_LENGTH | BIT_LENGTH | UPPER | LOWER | SIZE | EXISTS | COUNT | MOD ) # FunctionNameReserved | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (self-review) -- this is the rule we were aiming to remove from the ANTLR grammar in this PR |
||
| (qualifier+=symbolPrimitive PERIOD)* name=symbolPrimitive # FunctionNameSymbol | ||
: qualifiedName PAREN_LEFT ( expr ( COMMA expr )* )? PAREN_RIGHT | ||
; | ||
|
||
pathStep | ||
|
@@ -789,11 +785,52 @@ parameter | |
|
||
varRefExpr | ||
: qualifier=AT_SIGN? ident=(IDENTIFIER|IDENTIFIER_QUOTED) # VariableIdentifier | ||
| qualifier=AT_SIGN? key=nonReservedKeywords # VariableKeyword | ||
; | ||
|
||
nonReservedKeywords | ||
: EXCLUDED | ||
| qualifier=AT_SIGN? key=nonReserved # VariableKeyword | ||
; | ||
|
||
nonReserved | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (self-review) -- the non-reserved words were taken directly from the SQL-99 grammar. At the end are some, PartiQL specific-keywords marked as non-reserved. If you'll notice, postgresql along with other SQL dialects use their own set of non-reserved keywords that diverges from the SQL standards. Also between different SQL standards, there are some changes to the reserved vs non-reserved keywords. We choose to follow SQL-99 as we do in other places in the project. |
||
: /* From SQL99 <non-reserved word> https://ronsavage.github.io/SQL/sql-99.bnf.html#non-reserved%20word */ | ||
ABS | ADA | ADMIN | ASENSITIVE | ASSIGNMENT | ASYMMETRIC | ATOMIC | ||
| ATTRIBUTE | AVG | ||
| BIT_LENGTH | ||
| C | CALLED | CARDINALITY | CATALOG_NAME | CHAIN | CHAR_LENGTH | ||
| CHARACTERISTICS | CHARACTER_LENGTH | CHARACTER_SET_CATALOG | ||
| CHARACTER_SET_NAME | CHARACTER_SET_SCHEMA | CHECKED | CLASS_ORIGIN | ||
| COALESCE | COBOL | COLLATION_CATALOG | COLLATION_NAME | COLLATION_SCHEMA | ||
| COLUMN_NAME | COMMAND_FUNCTION | COMMAND_FUNCTION_CODE | COMMITTED | ||
| CONDITION_IDENTIFIER | CONDITION_NUMBER | CONNECTION_NAME | ||
| CONSTRAINT_CATALOG | CONSTRAINT_NAME | CONSTRAINT_SCHEMA | CONTAINS | ||
| CONVERT | COUNT | CURSOR_NAME | ||
| DATETIME_INTERVAL_CODE | DATETIME_INTERVAL_PRECISION | DEFINED | ||
| DEFINER | DEGREE | DERIVED | DISPATCH | ||
| EVERY | EXTRACT | ||
| FINAL | FORTRAN | ||
| G | GENERATED | GRANTED | ||
| HIERARCHY | ||
| IMPLEMENTATION | INSENSITIVE | INSTANCE | INSTANTIABLE | INVOKER | ||
| K | KEY_MEMBER | KEY_TYPE | ||
| LENGTH | LOWER | ||
| M | MAX | MIN | MESSAGE_LENGTH | MESSAGE_OCTET_LENGTH | MESSAGE_TEXT | ||
| MOD | MORE | MUMPS | ||
| NAME | NULLABLE | NUMBER | NULLIF | ||
| OCTET_LENGTH | ORDERING | OPTIONS | OVERLAY | OVERRIDING | ||
| PASCAL | PARAMETER_MODE | PARAMETER_NAME | ||
| PARAMETER_ORDINAL_POSITION | PARAMETER_SPECIFIC_CATALOG | ||
| PARAMETER_SPECIFIC_NAME | PARAMETER_SPECIFIC_SCHEMA | PLI | POSITION | ||
| REPEATABLE | RETURNED_CARDINALITY | RETURNED_LENGTH | ||
| RETURNED_OCTET_LENGTH | RETURNED_SQLSTATE | ROUTINE_CATALOG | ||
| ROUTINE_NAME | ROUTINE_SCHEMA | ROW_COUNT | ||
| SCALE | SCHEMA_NAME | SCOPE | SECURITY | SELF | SENSITIVE | SERIALIZABLE | ||
| SERVER_NAME | SIMPLE | SOURCE | SPECIFIC_NAME | STATEMENT | STRUCTURE | ||
| STYLE | SUBCLASS_ORIGIN | SUBSTRING | SUM | SYMMETRIC | SYSTEM | ||
| TABLE_NAME | TOP_LEVEL_COUNT | TRANSACTIONS_COMMITTED | ||
| TRANSACTIONS_ROLLED_BACK | TRANSACTION_ACTIVE | TRANSFORM | ||
| TRANSFORMS | TRANSLATE | TRIGGER_CATALOG | TRIGGER_SCHEMA | ||
| TRIGGER_NAME | TRIM | TYPE | ||
| UNCOMMITTED | UNNAMED | UPPER | ||
/* PartiQL */ | ||
| EXCLUDED | EXISTS | ||
| SIZE | ||
; | ||
|
||
/** | ||
|
Uh oh!
There was an error while loading. Please reload this page.