refac #2

Merged
pleshevskiy merged 12 commits from refac into main 2023-03-16 13:22:15 +03:00
4 changed files with 705 additions and 715 deletions
Showing only changes of commit 13896dfb7b - Show all commits

View file

@ -92,26 +92,6 @@ module.exports = grammar({
$.keyword_null
),
// keywords
_if_not_exists: ($) => seq($.keyword_if, $.keyword_not, $.keyword_exists),
_not_null: ($) => seq($.keyword_not, $.keyword_null),
keyword_create: (_) => mkKeyword("create"),
keyword_table: (_) => mkKeyword("table"),
keyword_temporary: (_) => choice(mkKeyword("temporary"), mkKeyword("temp")),
keyword_unlogged: (_) => mkKeyword("unlogged"),
keyword_if: (_) => mkKeyword("if"),
keyword_not: (_) => mkKeyword("not"),
keyword_exists: (_) => mkKeyword("exists"),
keyword_null: (_) => mkKeyword("null"),
keyword_constraint: (_) => mkKeyword("constraint"),
keyword_default: (_) => mkKeyword("default"),
keyword_true: (_) => mkKeyword("true"),
keyword_false: (_) => mkKeyword("false"),
keyword_nulls: (_) => mkKeyword("nulls"),
keyword_distinct: (_) => mkKeyword("distinct"),
keyword_unique: (_) => mkKeyword("unique"),
// References: https://www.postgresql.org/docs/15/datatype.html
_type: ($) =>
choice(
@ -193,8 +173,35 @@ module.exports = grammar({
// References: https://www.postgresql.org/docs/15/datatype-json.html
_type_json: ($) => choice($.keyword_json, $.keyword_jsonb),
keyword_boolean: (_) => mkKeyword("boolean"),
// keywords
_if_not_exists: ($) => seq($.keyword_if, $.keyword_not, $.keyword_exists),
_not_null: ($) => seq($.keyword_not, $.keyword_null),
_without_time_zone: ($) => seq(mkKeyword("without"), $._keyword_time_zone),
_with_time_zone: ($) => seq(mkKeyword("with"), $._keyword_time_zone),
_keyword_time_zone: (_) => seq(mkKeyword("time"), mkKeyword("zone")),
keyword_create: (_) => mkKeyword("create"),
keyword_table: (_) => mkKeyword("table"),
keyword_temporary: (_) => choice(mkKeyword("temporary"), mkKeyword("temp")),
keyword_unlogged: (_) => mkKeyword("unlogged"),
keyword_if: (_) => mkKeyword("if"),
keyword_not: (_) => mkKeyword("not"),
keyword_exists: (_) => mkKeyword("exists"),
keyword_null: (_) => mkKeyword("null"),
keyword_constraint: (_) => mkKeyword("constraint"),
keyword_default: (_) => mkKeyword("default"),
keyword_true: (_) => mkKeyword("true"),
keyword_false: (_) => mkKeyword("false"),
keyword_nulls: (_) => mkKeyword("nulls"),
keyword_distinct: (_) => mkKeyword("distinct"),
keyword_unique: (_) => mkKeyword("unique"),
// References: https://www.postgresql.org/docs/15/datatype-xml.html
keyword_xml: (_) => mkKeyword("xml"),
// References: https://www.postgresql.org/docs/15/datatype-uuid.html
keyword_uuid: (_) => mkKeyword("uuid"),
keyword_json: (_) => mkKeyword("json"),
keyword_jsonb: (_) => mkKeyword("jsonb"),
keyword_boolean: (_) => mkKeyword("boolean"),
keyword_smallint: (_) => mkKeyword("smallint"),
keyword_integer: (_) => mkKeyword("integer"),
keyword_bigint: (_) => mkKeyword("bigint"),
@ -204,10 +211,8 @@ module.exports = grammar({
keyword_smallserial: (_) => mkKeyword("smallserial"),
keyword_serial: (_) => mkKeyword("serial"),
keyword_bigserial: (_) => mkKeyword("bigserial"),
// References: https://www.postgresql.org/docs/15/datatype-money.html
keyword_money: (_) => mkKeyword("money"),
keyword_text: (_) => mkKeyword("text"),
keyword_char: (_) => choice(mkKeyword("character"), mkKeyword("char")),
keyword_varchar: (_) =>
@ -215,9 +220,7 @@ module.exports = grammar({
mkKeyword("varchar"),
seq(mkKeyword("character", mkKeyword("varying")))
),
keyword_bytea: (_) => mkKeyword("bytea"),
keyword_date: (_) => mkKeyword("date"),
keyword_datetime: (_) => mkKeyword("datetime"),
keyword_time: ($) =>
@ -233,19 +236,6 @@ module.exports = grammar({
seq(mkKeyword("timestamp"), $._with_time_zone)
),
_without_time_zone: ($) => seq(mkKeyword("without"), $._keyword_time_zone),
_with_time_zone: ($) => seq(mkKeyword("with"), $._keyword_time_zone),
_keyword_time_zone: (_) => seq(mkKeyword("time"), mkKeyword("zone")),
// References: https://www.postgresql.org/docs/15/datatype-uuid.html
keyword_uuid: (_) => mkKeyword("uuid"),
// References: https://www.postgresql.org/docs/15/datatype-xml.html
keyword_xml: (_) => mkKeyword("xml"),
keyword_json: (_) => mkKeyword("json"),
keyword_jsonb: (_) => mkKeyword("jsonb"),
// -------
line_comment: (_) => seq("--", /.*\n/),

View file

@ -361,105 +361,6 @@
}
]
},
"_if_not_exists": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_if"
},
{
"type": "SYMBOL",
"name": "keyword_not"
},
{
"type": "SYMBOL",
"name": "keyword_exists"
}
]
},
"_not_null": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_not"
},
{
"type": "SYMBOL",
"name": "keyword_null"
}
]
},
"keyword_create": {
"type": "PATTERN",
"value": "create|CREATE"
},
"keyword_table": {
"type": "PATTERN",
"value": "table|TABLE"
},
"keyword_temporary": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "temporary|TEMPORARY"
},
{
"type": "PATTERN",
"value": "temp|TEMP"
}
]
},
"keyword_unlogged": {
"type": "PATTERN",
"value": "unlogged|UNLOGGED"
},
"keyword_if": {
"type": "PATTERN",
"value": "if|IF"
},
"keyword_not": {
"type": "PATTERN",
"value": "not|NOT"
},
"keyword_exists": {
"type": "PATTERN",
"value": "exists|EXISTS"
},
"keyword_null": {
"type": "PATTERN",
"value": "null|NULL"
},
"keyword_constraint": {
"type": "PATTERN",
"value": "constraint|CONSTRAINT"
},
"keyword_default": {
"type": "PATTERN",
"value": "default|DEFAULT"
},
"keyword_true": {
"type": "PATTERN",
"value": "true|TRUE"
},
"keyword_false": {
"type": "PATTERN",
"value": "false|FALSE"
},
"keyword_nulls": {
"type": "PATTERN",
"value": "nulls|NULLS"
},
"keyword_distinct": {
"type": "PATTERN",
"value": "distinct|DISTINCT"
},
"keyword_unique": {
"type": "PATTERN",
"value": "unique|UNIQUE"
},
"_type": {
"type": "CHOICE",
"members": [
@ -954,6 +855,160 @@
}
]
},
"_if_not_exists": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_if"
},
{
"type": "SYMBOL",
"name": "keyword_not"
},
{
"type": "SYMBOL",
"name": "keyword_exists"
}
]
},
"_not_null": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_not"
},
{
"type": "SYMBOL",
"name": "keyword_null"
}
]
},
"_without_time_zone": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "without|WITHOUT"
},
{
"type": "SYMBOL",
"name": "_keyword_time_zone"
}
]
},
"_with_time_zone": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "with|WITH"
},
{
"type": "SYMBOL",
"name": "_keyword_time_zone"
}
]
},
"_keyword_time_zone": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "time|TIME"
},
{
"type": "PATTERN",
"value": "zone|ZONE"
}
]
},
"keyword_create": {
"type": "PATTERN",
"value": "create|CREATE"
},
"keyword_table": {
"type": "PATTERN",
"value": "table|TABLE"
},
"keyword_temporary": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "temporary|TEMPORARY"
},
{
"type": "PATTERN",
"value": "temp|TEMP"
}
]
},
"keyword_unlogged": {
"type": "PATTERN",
"value": "unlogged|UNLOGGED"
},
"keyword_if": {
"type": "PATTERN",
"value": "if|IF"
},
"keyword_not": {
"type": "PATTERN",
"value": "not|NOT"
},
"keyword_exists": {
"type": "PATTERN",
"value": "exists|EXISTS"
},
"keyword_null": {
"type": "PATTERN",
"value": "null|NULL"
},
"keyword_constraint": {
"type": "PATTERN",
"value": "constraint|CONSTRAINT"
},
"keyword_default": {
"type": "PATTERN",
"value": "default|DEFAULT"
},
"keyword_true": {
"type": "PATTERN",
"value": "true|TRUE"
},
"keyword_false": {
"type": "PATTERN",
"value": "false|FALSE"
},
"keyword_nulls": {
"type": "PATTERN",
"value": "nulls|NULLS"
},
"keyword_distinct": {
"type": "PATTERN",
"value": "distinct|DISTINCT"
},
"keyword_unique": {
"type": "PATTERN",
"value": "unique|UNIQUE"
},
"keyword_xml": {
"type": "PATTERN",
"value": "xml|XML"
},
"keyword_uuid": {
"type": "PATTERN",
"value": "uuid|UUID"
},
"keyword_json": {
"type": "PATTERN",
"value": "json|JSON"
},
"keyword_jsonb": {
"type": "PATTERN",
"value": "jsonb|JSONB"
},
"keyword_boolean": {
"type": "PATTERN",
"value": "boolean|BOOLEAN"
@ -1118,61 +1173,6 @@
}
]
},
"_without_time_zone": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "without|WITHOUT"
},
{
"type": "SYMBOL",
"name": "_keyword_time_zone"
}
]
},
"_with_time_zone": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "with|WITH"
},
{
"type": "SYMBOL",
"name": "_keyword_time_zone"
}
]
},
"_keyword_time_zone": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "time|TIME"
},
{
"type": "PATTERN",
"value": "zone|ZONE"
}
]
},
"keyword_uuid": {
"type": "PATTERN",
"value": "uuid|UUID"
},
"keyword_xml": {
"type": "PATTERN",
"value": "xml|XML"
},
"keyword_json": {
"type": "PATTERN",
"value": "json|JSON"
},
"keyword_jsonb": {
"type": "PATTERN",
"value": "jsonb|JSONB"
},
"line_comment": {
"type": "SEQ",
"members": [

File diff suppressed because it is too large Load diff

Binary file not shown.