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