grammar: improve table constraint

This commit is contained in:
Dmitriy Pleshevskiy 2023-01-06 00:54:05 +03:00
parent 6e78cac399
commit dc0ff18f18
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
2 changed files with 21 additions and 38 deletions

View file

@ -329,14 +329,10 @@ module.exports = grammar({
), ),
table_constraint: ($) => table_constraint: ($) =>
choice( seq(
seq($.table_constraint_ty, optional($.constraint_when)), optional(seq(kw("constraint"), $.identifier)),
seq( $.table_constraint_ty,
kw("constraint"), optional($.constraint_when)
$.identifier,
$.table_constraint_ty,
optional($.constraint_when)
)
), ),
constraint_when: ($) => constraint_when: ($) =>

View file

@ -2144,55 +2144,42 @@
] ]
}, },
"table_constraint": { "table_constraint": {
"type": "CHOICE", "type": "SEQ",
"members": [ "members": [
{ {
"type": "SEQ", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SEQ",
"name": "table_constraint_ty"
},
{
"type": "CHOICE",
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "PATTERN",
"name": "constraint_when" "value": "[cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]"
}, },
{ {
"type": "BLANK" "type": "SYMBOL",
"name": "identifier"
} }
] ]
},
{
"type": "BLANK"
} }
] ]
}, },
{ {
"type": "SEQ", "type": "SYMBOL",
"name": "table_constraint_ty"
},
{
"type": "CHOICE",
"members": [ "members": [
{
"type": "PATTERN",
"value": "[cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "identifier" "name": "constraint_when"
}, },
{ {
"type": "SYMBOL", "type": "BLANK"
"name": "table_constraint_ty"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "constraint_when"
},
{
"type": "BLANK"
}
]
} }
] ]
} }