Compare commits

...

4 Commits

4 changed files with 30360 additions and 30394 deletions

View File

@ -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)
@ -329,21 +329,16 @@ module.exports = grammar({
),
table_constraint: ($) =>
choice(
seq($.table_constraint_ty, optional($.constraint_when)),
seq(
kw("constraint"),
$.identifier,
$.table_constraint_ty,
optional($.constraint_when)
)
seq(
optional(seq($._constraint, $.identifier)),
$.table_constraint_ty,
optional($.constraint_when)
),
constraint_when: ($) =>
choice(
seq(
kw("deferrable"),
seq(kw("deferrable"), kw("initially"), kw("immediate")),
seq(kw("deferrable"), kw("initially"), kw("deferred"))
optional(seq(kw("initially"), choice(kw("immediate"), kw("deferred"))))
),
table_constraint_ty: ($) =>
@ -384,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: ($) =>
@ -418,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),
@ -522,7 +518,7 @@ module.exports = grammar({
create_trigger_statement: ($) =>
seq(
kw("create"),
optional(kw("constraint")),
optional($._constraint),
kw("trigger"),
$.identifier,
$.trigger_when,
@ -1088,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"),
},
});

View File

@ -8,7 +8,8 @@ set -xe
if [ ! -z $(git diff --cached --name-only | grep -e "^grammar.js$") ]
then
make build
make build-wasm
# TODO: Enable when performance improves
# make build-wasm
git add src bindings *.wasm
fi

View File

@ -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",
@ -2144,98 +2144,81 @@
]
},
"table_constraint": {
"type": "CHOICE",
"type": "SEQ",
"members": [
{
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "table_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": "table_constraint_ty"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]"
},
{
"type": "SYMBOL",
"name": "identifier"
"name": "constraint_when"
},
{
"type": "SYMBOL",
"name": "table_constraint_ty"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "constraint_when"
},
{
"type": "BLANK"
}
]
"type": "BLANK"
}
]
}
]
},
"constraint_when": {
"type": "CHOICE",
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "[dD][eE][fF][eE][rR][rR][aA][bB][lL][eE]"
},
{
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[dD][eE][fF][eE][rR][rR][aA][bB][lL][eE]"
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "[iI][nN][iI][tT][iI][aA][lL][lL][yY]"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[iI][mM][mM][eE][dD][iI][aA][tT][eE]"
},
{
"type": "PATTERN",
"value": "[dD][eE][fF][eE][rR][rR][eE][dD]"
}
]
}
]
},
{
"type": "PATTERN",
"value": "[iI][nN][iI][tT][iI][aA][lL][lL][yY]"
},
{
"type": "PATTERN",
"value": "[iI][mM][mM][eE][dD][iI][aA][tT][eE]"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "[dD][eE][fF][eE][rR][rR][aA][bB][lL][eE]"
},
{
"type": "PATTERN",
"value": "[iI][nN][iI][tT][iI][aA][lL][lL][yY]"
},
{
"type": "PATTERN",
"value": "[dD][eE][fF][eE][rR][rR][eE][dD]"
"type": "BLANK"
}
]
}
@ -2505,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"
}
]
}
@ -2677,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",
@ -3474,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"
@ -7061,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

File diff suppressed because it is too large Load Diff