@@ -27,9 +27,11 @@ module.exports = grammar({
2727 [ $ . timestamp ] ,
2828 [ $ . grantable_on_function , $ . grantable_on_table ] ,
2929 [ $ . any_identifier , $ . column_identifier ] ,
30- [ $ . any_identifier , $ . schema_identifier , $ . table_identifier ] ,
30+ [ $ . any_identifier , $ . schema_identifier ] ,
31+ [ $ . any_identifier , $ . table_identifier ] ,
3132 [ $ . schema_identifier , $ . table_identifier ] ,
3233 [ $ . table_reference , $ . column_reference ] ,
34+ [ $ . object_reference , $ . table_reference ] ,
3335 ] ,
3436
3537 precedences : ( $ ) => [
@@ -3477,15 +3479,8 @@ module.exports = grammar({
34773479 bang : ( _ ) => "!" ,
34783480
34793481 // todo: handle (table).col vs. (type).attribute
3480- // todo: handle "schema"."table".column etc.
3481- // todo: handle alias.col vs. table.col
34823482 // todo: handle table.column::type
34833483 // todo: handle schema.function(arg1, arg2)
3484- // function_reference: $ => {},
3485-
3486- // table_reference: $ => {},
3487- // type_reference: $ => {},
3488- // column_reference: $ => {},
34893484
34903485 object_reference : ( $ ) =>
34913486 choice (
@@ -3506,31 +3501,51 @@ module.exports = grammar({
35063501
35073502 type_reference : ( $ ) =>
35083503 choice (
3509- seq ( $ . schema_identifier , "." , $ . type_identifier ) ,
3510- field ( "type_reference_first" , $ . type_identifier )
3504+ seq (
3505+ field ( "type_reference_1of2" , $ . schema_identifier ) ,
3506+ "." ,
3507+ field ( "type_reference_2of2" , $ . type_identifier )
3508+ ) ,
3509+ field ( "type_reference_1of1" , $ . any_identifier )
35113510 ) ,
35123511
35133512 table_reference : ( $ ) =>
35143513 choice (
3515- seq ( $ . schema_identifier , "." , $ . table_identifier ) ,
3516- field ( "table_reference_first" , $ . table_identifier )
3514+ seq (
3515+ field ( "table_reference_1of2" , $ . schema_identifier ) ,
3516+ "." ,
3517+ field ( "table_reference_2of2" , $ . table_identifier )
3518+ ) ,
3519+ field ( "table_reference_1of1" , $ . any_identifier )
35173520 ) ,
35183521
35193522 column_reference : ( $ ) =>
35203523 choice (
35213524 seq (
3522- $ . schema_identifier ,
3525+ field ( "column_reference_1of3" , $ . schema_identifier ) ,
35233526 "." ,
3524- $ . table_identifier ,
3527+ field ( "column_reference_2of3" , $ . table_identifier ) ,
35253528 "." ,
3526- $ . column_identifier
3529+ field ( "column_reference_3of3" , $ . column_identifier )
35273530 ) ,
3531+
3532+ seq (
3533+ field ( "column_reference_1of2" , $ . any_identifier ) ,
3534+ "." ,
3535+ field ( "column_reference_2of2" , $ . any_identifier )
3536+ ) ,
3537+
3538+ field ( "column_reference_1of1" , $ . column_identifier )
3539+ ) ,
3540+
3541+ function_reference : ( $ ) =>
3542+ choice (
35283543 seq (
3529- $ . table_identifier ,
3544+ field ( "function_reference_1of2" , $ . schema_identifier ) ,
35303545 "." ,
3531- field ( "column_reference_second " , $ . column_identifier )
3546+ field ( "function_reference_2of2 " , $ . function_identifier )
35323547 ) ,
3533- field ( "column_reference_first " , $ . column_identifier )
3548+ field ( "function_reference_1of1 " , $ . any_identifier )
35343549 ) ,
35353550
35363551 any_identifier : ( $ ) => $ . _any_identifier ,
@@ -3539,6 +3554,7 @@ module.exports = grammar({
35393554 table_identifier : ( $ ) => $ . _any_identifier ,
35403555 function_identifier : ( $ ) => $ . _any_identifier ,
35413556 type_identifier : ( $ ) => $ . _any_identifier ,
3557+ role_identifier : ( $ ) => $ . _any_identifier ,
35423558
35433559 _any_identifier : ( $ ) =>
35443560 choice (
0 commit comments