grammar: move constraint to hidden rule
This commit is contained in:
parent
78fa02efd1
commit
dc314830d2
3 changed files with 30316 additions and 30329 deletions
30
grammar.js
30
grammar.js
|
@ -160,7 +160,7 @@ module.exports = grammar({
|
|||
|
||||
conflict_target: ($) =>
|
||||
choice(
|
||||
seq(kw("on"), kw("constraint"), $.identifier),
|
||||
seq(kw("on"), $._constraint, $.identifier),
|
||||
seq("(", commaSep($._value_expression), ")")
|
||||
),
|
||||
|
||||
|
@ -298,7 +298,7 @@ module.exports = grammar({
|
|||
),
|
||||
seq(
|
||||
kw("drop"),
|
||||
kw("constraint"),
|
||||
$._constraint,
|
||||
optional($.if_exists),
|
||||
$.identifier,
|
||||
optional($.alter_table_fk_ref_action)
|
||||
|
@ -330,7 +330,7 @@ module.exports = grammar({
|
|||
|
||||
table_constraint: ($) =>
|
||||
seq(
|
||||
optional(seq(kw("constraint"), $.identifier)),
|
||||
optional(seq($._constraint, $.identifier)),
|
||||
$.table_constraint_ty,
|
||||
optional($.constraint_when)
|
||||
),
|
||||
|
@ -379,19 +379,17 @@ module.exports = grammar({
|
|||
|
||||
alter_column_type: ($) =>
|
||||
seq($._type, optional(seq(kw("using"), $._value_expression))),
|
||||
|
||||
alter_table_fk_ref_action: ($) => choice(kw("restrict"), kw("cascade")),
|
||||
|
||||
table_column_item: ($) =>
|
||||
seq($.identifier, $._type, repeat($.column_constraint)),
|
||||
|
||||
column_constraint: ($) =>
|
||||
choice(
|
||||
seq(
|
||||
kw("constraint"),
|
||||
$.identifier,
|
||||
$.column_constraint_ty,
|
||||
optional($.constraint_when)
|
||||
),
|
||||
seq($.column_constraint_ty, optional($.constraint_when))
|
||||
seq(
|
||||
optional(seq($._constraint, $.identifier)),
|
||||
$.column_constraint_ty,
|
||||
optional($.constraint_when)
|
||||
),
|
||||
|
||||
column_constraint_ty: ($) =>
|
||||
|
@ -413,9 +411,12 @@ module.exports = grammar({
|
|||
kw("to"),
|
||||
$.identifier
|
||||
),
|
||||
|
||||
alter_table_rename_constraint: ($) =>
|
||||
seq(kw("rename"), kw("constraint"), $.identifier, kw("to"), $.identifier),
|
||||
seq(kw("rename"), $._constraint, $.identifier, kw("to"), $.identifier),
|
||||
|
||||
alter_table_rename_table: ($) => seq(kw("rename"), kw("to"), $.identifier),
|
||||
|
||||
alter_table_change_schema: ($) =>
|
||||
seq(kw("set"), kw("schema"), $.identifier),
|
||||
|
||||
|
@ -517,7 +518,7 @@ module.exports = grammar({
|
|||
create_trigger_statement: ($) =>
|
||||
seq(
|
||||
kw("create"),
|
||||
optional(kw("constraint")),
|
||||
optional($._constraint),
|
||||
kw("trigger"),
|
||||
$.identifier,
|
||||
$.trigger_when,
|
||||
|
@ -1083,5 +1084,8 @@ module.exports = grammar({
|
|||
_identifier: ($) => /[a-zA-Z0-9_]+(\.?[a-zA-Z0-9_]+)*/,
|
||||
// ^
|
||||
// |- we dont want to match consecutive dots, e.g: 1..2 consists of 3 tokens
|
||||
|
||||
//--------------------------
|
||||
_constraint: ($) => kw("constraint"),
|
||||
},
|
||||
});
|
||||
|
|
|
@ -955,8 +955,8 @@
|
|||
"value": "[oO][nN]"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]"
|
||||
"type": "SYMBOL",
|
||||
"name": "_constraint"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -1919,8 +1919,8 @@
|
|||
"value": "[dD][rR][oO][pP]"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]"
|
||||
"type": "SYMBOL",
|
||||
"name": "_constraint"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
|
@ -2153,8 +2153,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]"
|
||||
"type": "SYMBOL",
|
||||
"name": "_constraint"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -2488,55 +2488,42 @@
|
|||
]
|
||||
},
|
||||
"column_constraint": {
|
||||
"type": "CHOICE",
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "column_constraint_ty"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "constraint_when"
|
||||
"name": "_constraint"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"type": "SYMBOL",
|
||||
"name": "column_constraint_ty"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "column_constraint_ty"
|
||||
"name": "constraint_when"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "constraint_when"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -2660,8 +2647,8 @@
|
|||
"value": "[rR][eE][nN][aA][mM][eE]"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]"
|
||||
"type": "SYMBOL",
|
||||
"name": "_constraint"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -3457,8 +3444,8 @@
|
|||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]"
|
||||
"type": "SYMBOL",
|
||||
"name": "_constraint"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
|
@ -7044,6 +7031,10 @@
|
|||
"_identifier": {
|
||||
"type": "PATTERN",
|
||||
"value": "[a-zA-Z0-9_]+(\\.?[a-zA-Z0-9_]+)*"
|
||||
},
|
||||
"_constraint": {
|
||||
"type": "PATTERN",
|
||||
"value": "[cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]"
|
||||
}
|
||||
},
|
||||
"extras": [
|
||||
|
|
60546
src/parser.c
60546
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue