refac #2

Merged
pleshevskiy merged 12 commits from refac into main 2023-03-16 13:22:15 +03:00
6 changed files with 3999 additions and 664 deletions
Showing only changes of commit 0f7f6211db - Show all commits

View file

@ -3,6 +3,8 @@ module.exports = grammar({
extras: ($) => [/\s\n/, /\s/, $.comment, $.marginalia],
conflicts: ($) => [[$.keyword_char, $.keyword_varchar]],
word: ($) => $._identifier,
rules: {
@ -25,12 +27,6 @@ module.exports = grammar({
$.column_definitions
),
table_reference: ($) =>
seq(
optional(seq(field("schema", $.identifier), ".")),
field("name", $.identifier)
),
column_definitions: ($) =>
seq(
"(",
@ -38,11 +34,20 @@ module.exports = grammar({
")"
),
column_definition: ($) => seq(field("name", $.identifier)),
column_definition: ($) =>
seq(field("name", $.identifier), field("datatype", $._type)),
//constraint: $ => seq(),
table_reference: ($) =>
seq(
optional(seq(field("schema", $.identifier), ".")),
field("name", $.identifier)
),
// keywords
_if_not_exists: ($) => seq($.keyword_if, $.keyword_not, $.keyword_exists),
keyword_create: (_) => mkKeyword("create"),
keyword_table: (_) => mkKeyword("table"),
keyword_temporary: (_) => choice(mkKeyword("temporary"), mkKeyword("temp")),
@ -51,13 +56,150 @@ module.exports = grammar({
keyword_not: (_) => mkKeyword("not"),
keyword_exists: (_) => mkKeyword("exists"),
_if_not_exists: ($) => seq($.keyword_if, $.keyword_not, $.keyword_exists),
// References: https://www.postgresql.org/docs/15/datatype.html
_type: ($) =>
choice(
$._type_numeric,
$._type_character,
$._type_datetime,
$._type_geometric,
$._type_net,
$._type_bit_string,
$._type_text_search,
$.keyword_money,
$.keyword_bytea,
$.keyword_boolean,
$.keyword_uuid,
$.keyword_xml
// TODO: add arrays References: https://www.postgresql.org/docs/15/arrays.html
// TODO: add rangetypes References: https://www.postgresql.org/docs/15/rangetypes.html
// TODO: add OID types References: https://www.postgresql.org/docs/15/datatype-oid.html
),
// References: https://www.postgresql.org/docs/15/datatype-numeric.html
_type_numeric: ($) =>
choice(
$.keyword_smallint,
$.keyword_integer,
$.keyword_bigint,
$.keyword_real,
$.keyword_smallserial,
$.keyword_serial,
$.keyword_bigserial,
$.double,
$.numeric,
$.decimal
),
double: ($) => seq(mkKeyword("double"), mkKeyword("precision")),
decimal: ($) =>
choice(
parametricType($, $.keyword_decimal, ["precision"]),
parametricType($, $.keyword_decimal, ["precision", "scale"])
),
numeric: ($) =>
choice(
parametricType($, $.keyword_numeric, ["precision"]),
parametricType($, $.keyword_numeric, ["precision", "scale"])
),
// References: https://www.postgresql.org/docs/15/datatype-character.html
_type_character: ($) => choice($.keyword_text, $.char, $.varchar),
char: ($) => parametricType($, $.keyword_char),
varchar: ($) => parametricType($, $.keyword_varchar),
// TODO: add interval type
// References: https://www.postgresql.org/docs/15/datatype-datetime.html
_type_datetime: ($) =>
choice(
$.keyword_date,
$.keyword_datetime,
$.keyword_time,
$.keyword_timestamp,
$.keyword_timestamptz
),
// TODO: add geometric types
// References: https://www.postgresql.org/docs/15/datatype-geometric.html
_type_geometric: ($) => choice(),
// TODO: add net types
// References: https://www.postgresql.org/docs/15/datatype-net-types.html
_type_net: ($) => choice(),
// TODO: add bit string types
// References: https://www.postgresql.org/docs/15/datatype-bit.html
_type_bit_string: ($) => choice(),
// TODO: add text search types
// References: https://www.postgresql.org/docs/15/datatype-textsearch.html
_type_text_search: ($) => choice(),
// References: https://www.postgresql.org/docs/15/datatype-json.html
_type_json: ($) => choice($.keyword_json, $.keyword_jsonb),
keyword_boolean: (_) => mkKeyword("boolean"),
keyword_smallint: (_) => mkKeyword("smallint"),
keyword_integer: (_) => mkKeyword("integer"),
keyword_bigint: (_) => mkKeyword("bigint"),
keyword_decimal: (_) => mkKeyword("decimal"),
keyword_numeric: (_) => mkKeyword("numeric"),
keyword_real: (_) => mkKeyword("real"),
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: (_) =>
choice(
mkKeyword("varchar"),
seq(mkKeyword("character", mkKeyword("varying")))
),
keyword_bytea: (_) => mkKeyword("bytea"),
keyword_date: (_) => mkKeyword("date"),
keyword_datetime: (_) => mkKeyword("datetime"),
keyword_time: ($) =>
seq(
mkKeyword("time"),
choice(optional($._without_time_zone), $._with_time_zone)
),
keyword_timestamp: ($) =>
seq(mkKeyword("timestamp"), optional($._without_time_zone)),
keyword_timestamptz: ($) =>
choice(
mkKeyword("timestamptz"),
seq(mkKeyword("timestamp"), $._with_time_zone)
),
_without_time_zone: ($) => seq($._keyword_without, $._keyword_time_zone),
_with_time_zone: ($) => seq($._keyword_with, $._keyword_time_zone),
_keyword_without: (_) => mkKeyword("without"),
_keyword_with: (_) => mkKeyword("with"),
_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"),
// -------
comment: (_) => seq("--", /.*\n/),
// https://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment
marginalia: (_) => seq("/*", /[^*]*\*+(?:[^/*][^*]*\*+)*/, "/"),
_number: (_) => /\d+/,
identifier: ($) => choice($._identifier, seq('"', $._identifier, '"')),
_identifier: (_) => /([a-zA-Z_][0-9a-zA-Z_]*)/,
@ -71,3 +213,20 @@ function mkKeyword(word) {
function commaSepRepeat1(field) {
return seq(field, repeat(seq(",", field)));
}
function parametricType($, type, params = ["size"]) {
return prec.right(
choice(
type,
seq(
type,
"(",
// first parameter is guaranteed, shift it out of the array
field(params.shift(), alias($._number, $.literal)),
// then, fill in the ", next" until done
...params.map((p) => seq(",", field(p, alias($._number, $.literal)))),
")"
)
)
);
}

View file

@ -107,44 +107,6 @@
}
]
},
"table_reference": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "schema",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "STRING",
"value": "."
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
}
]
},
"column_definitions": {
"type": "SEQ",
"members": [
@ -211,6 +173,69 @@
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "FIELD",
"name": "datatype",
"content": {
"type": "SYMBOL",
"name": "_type"
}
}
]
},
"table_reference": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "schema",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "STRING",
"value": "."
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
}
]
},
"_if_not_exists": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_if"
},
{
"type": "SYMBOL",
"name": "keyword_not"
},
{
"type": "SYMBOL",
"name": "keyword_exists"
}
]
},
@ -251,23 +276,727 @@
"type": "PATTERN",
"value": "exists|EXISTS"
},
"_if_not_exists": {
"_type": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_type_numeric"
},
{
"type": "SYMBOL",
"name": "_type_character"
},
{
"type": "SYMBOL",
"name": "_type_datetime"
},
{
"type": "SYMBOL",
"name": "_type_geometric"
},
{
"type": "SYMBOL",
"name": "_type_net"
},
{
"type": "SYMBOL",
"name": "_type_bit_string"
},
{
"type": "SYMBOL",
"name": "_type_text_search"
},
{
"type": "SYMBOL",
"name": "keyword_money"
},
{
"type": "SYMBOL",
"name": "keyword_bytea"
},
{
"type": "SYMBOL",
"name": "keyword_boolean"
},
{
"type": "SYMBOL",
"name": "keyword_uuid"
},
{
"type": "SYMBOL",
"name": "keyword_xml"
}
]
},
"_type_numeric": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "keyword_smallint"
},
{
"type": "SYMBOL",
"name": "keyword_integer"
},
{
"type": "SYMBOL",
"name": "keyword_bigint"
},
{
"type": "SYMBOL",
"name": "keyword_real"
},
{
"type": "SYMBOL",
"name": "keyword_smallserial"
},
{
"type": "SYMBOL",
"name": "keyword_serial"
},
{
"type": "SYMBOL",
"name": "keyword_bigserial"
},
{
"type": "SYMBOL",
"name": "double"
},
{
"type": "SYMBOL",
"name": "numeric"
},
{
"type": "SYMBOL",
"name": "decimal"
}
]
},
"double": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "double|DOUBLE"
},
{
"type": "PATTERN",
"value": "precision|PRECISION"
}
]
},
"decimal": {
"type": "CHOICE",
"members": [
{
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "keyword_decimal"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_decimal"
},
{
"type": "STRING",
"value": "("
},
{
"type": "FIELD",
"name": "precision",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_number"
},
"named": true,
"value": "literal"
}
},
{
"type": "STRING",
"value": ")"
}
]
}
]
}
},
{
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "keyword_decimal"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_decimal"
},
{
"type": "STRING",
"value": "("
},
{
"type": "FIELD",
"name": "precision",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_number"
},
"named": true,
"value": "literal"
}
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "FIELD",
"name": "scale",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_number"
},
"named": true,
"value": "literal"
}
}
]
},
{
"type": "STRING",
"value": ")"
}
]
}
]
}
}
]
},
"numeric": {
"type": "CHOICE",
"members": [
{
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "keyword_numeric"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_numeric"
},
{
"type": "STRING",
"value": "("
},
{
"type": "FIELD",
"name": "precision",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_number"
},
"named": true,
"value": "literal"
}
},
{
"type": "STRING",
"value": ")"
}
]
}
]
}
},
{
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "keyword_numeric"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_numeric"
},
{
"type": "STRING",
"value": "("
},
{
"type": "FIELD",
"name": "precision",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_number"
},
"named": true,
"value": "literal"
}
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "FIELD",
"name": "scale",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_number"
},
"named": true,
"value": "literal"
}
}
]
},
{
"type": "STRING",
"value": ")"
}
]
}
]
}
}
]
},
"_type_character": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "keyword_text"
},
{
"type": "SYMBOL",
"name": "char"
},
{
"type": "SYMBOL",
"name": "varchar"
}
]
},
"char": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "keyword_char"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_char"
},
{
"type": "STRING",
"value": "("
},
{
"type": "FIELD",
"name": "size",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_number"
},
"named": true,
"value": "literal"
}
},
{
"type": "STRING",
"value": ")"
}
]
}
]
}
},
"varchar": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "keyword_varchar"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_varchar"
},
{
"type": "STRING",
"value": "("
},
{
"type": "FIELD",
"name": "size",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_number"
},
"named": true,
"value": "literal"
}
},
{
"type": "STRING",
"value": ")"
}
]
}
]
}
},
"_type_datetime": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "keyword_date"
},
{
"type": "SYMBOL",
"name": "keyword_datetime"
},
{
"type": "SYMBOL",
"name": "keyword_time"
},
{
"type": "SYMBOL",
"name": "keyword_timestamp"
},
{
"type": "SYMBOL",
"name": "keyword_timestamptz"
}
]
},
"_type_geometric": {
"type": "CHOICE",
"members": []
},
"_type_net": {
"type": "CHOICE",
"members": []
},
"_type_bit_string": {
"type": "CHOICE",
"members": []
},
"_type_text_search": {
"type": "CHOICE",
"members": []
},
"_type_json": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "keyword_json"
},
{
"type": "SYMBOL",
"name": "keyword_jsonb"
}
]
},
"keyword_boolean": {
"type": "PATTERN",
"value": "boolean|BOOLEAN"
},
"keyword_smallint": {
"type": "PATTERN",
"value": "smallint|SMALLINT"
},
"keyword_integer": {
"type": "PATTERN",
"value": "integer|INTEGER"
},
"keyword_bigint": {
"type": "PATTERN",
"value": "bigint|BIGINT"
},
"keyword_decimal": {
"type": "PATTERN",
"value": "decimal|DECIMAL"
},
"keyword_numeric": {
"type": "PATTERN",
"value": "numeric|NUMERIC"
},
"keyword_real": {
"type": "PATTERN",
"value": "real|REAL"
},
"keyword_smallserial": {
"type": "PATTERN",
"value": "smallserial|SMALLSERIAL"
},
"keyword_serial": {
"type": "PATTERN",
"value": "serial|SERIAL"
},
"keyword_bigserial": {
"type": "PATTERN",
"value": "bigserial|BIGSERIAL"
},
"keyword_money": {
"type": "PATTERN",
"value": "money|MONEY"
},
"keyword_text": {
"type": "PATTERN",
"value": "text|TEXT"
},
"keyword_char": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "character|CHARACTER"
},
{
"type": "PATTERN",
"value": "char|CHAR"
}
]
},
"keyword_varchar": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "varchar|VARCHAR"
},
{
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "character|CHARACTER"
}
]
}
]
},
"keyword_bytea": {
"type": "PATTERN",
"value": "bytea|BYTEA"
},
"keyword_date": {
"type": "PATTERN",
"value": "date|DATE"
},
"keyword_datetime": {
"type": "PATTERN",
"value": "datetime|DATETIME"
},
"keyword_time": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "time|TIME"
},
{
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_without_time_zone"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_with_time_zone"
}
]
}
]
},
"keyword_timestamp": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "timestamp|TIMESTAMP"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_without_time_zone"
},
{
"type": "BLANK"
}
]
}
]
},
"keyword_timestamptz": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "timestamptz|TIMESTAMPTZ"
},
{
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "timestamp|TIMESTAMP"
},
{
"type": "SYMBOL",
"name": "_with_time_zone"
}
]
}
]
},
"_without_time_zone": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_if"
"name": "_keyword_without"
},
{
"type": "SYMBOL",
"name": "keyword_not"
},
{
"type": "SYMBOL",
"name": "keyword_exists"
"name": "_keyword_time_zone"
}
]
},
"_with_time_zone": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_keyword_with"
},
{
"type": "SYMBOL",
"name": "_keyword_time_zone"
}
]
},
"_keyword_without": {
"type": "PATTERN",
"value": "without|WITHOUT"
},
"_keyword_with": {
"type": "PATTERN",
"value": "with|WITH"
},
"_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"
},
"comment": {
"type": "SEQ",
"members": [
@ -298,6 +1027,10 @@
}
]
},
"_number": {
"type": "PATTERN",
"value": "\\d+"
},
"identifier": {
"type": "CHOICE",
"members": [
@ -347,7 +1080,12 @@
"name": "marginalia"
}
],
"conflicts": [],
"conflicts": [
[
"keyword_char",
"keyword_varchar"
]
],
"precedences": [],
"externals": [],
"inline": [],

View file

@ -1,8 +1,132 @@
[
{
"type": "char",
"named": true,
"fields": {
"size": {
"multiple": false,
"required": false,
"types": [
{
"type": "literal",
"named": true
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "keyword_char",
"named": true
}
]
}
},
{
"type": "column_definition",
"named": true,
"fields": {
"datatype": {
"multiple": false,
"required": true,
"types": [
{
"type": "char",
"named": true
},
{
"type": "decimal",
"named": true
},
{
"type": "double",
"named": true
},
{
"type": "keyword_bigint",
"named": true
},
{
"type": "keyword_bigserial",
"named": true
},
{
"type": "keyword_boolean",
"named": true
},
{
"type": "keyword_bytea",
"named": true
},
{
"type": "keyword_date",
"named": true
},
{
"type": "keyword_datetime",
"named": true
},
{
"type": "keyword_integer",
"named": true
},
{
"type": "keyword_money",
"named": true
},
{
"type": "keyword_real",
"named": true
},
{
"type": "keyword_serial",
"named": true
},
{
"type": "keyword_smallint",
"named": true
},
{
"type": "keyword_smallserial",
"named": true
},
{
"type": "keyword_text",
"named": true
},
{
"type": "keyword_time",
"named": true
},
{
"type": "keyword_timestamp",
"named": true
},
{
"type": "keyword_timestamptz",
"named": true
},
{
"type": "keyword_uuid",
"named": true
},
{
"type": "keyword_xml",
"named": true
},
{
"type": "numeric",
"named": true
},
{
"type": "varchar",
"named": true
}
]
},
"name": {
"multiple": false,
"required": true,
@ -82,21 +206,123 @@
]
}
},
{
"type": "decimal",
"named": true,
"fields": {
"precision": {
"multiple": false,
"required": false,
"types": [
{
"type": "literal",
"named": true
}
]
},
"scale": {
"multiple": false,
"required": false,
"types": [
{
"type": "literal",
"named": true
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "keyword_decimal",
"named": true
}
]
}
},
{
"type": "double",
"named": true,
"fields": {}
},
{
"type": "identifier",
"named": true,
"fields": {}
},
{
"type": "keyword_char",
"named": true,
"fields": {}
},
{
"type": "keyword_temporary",
"named": true,
"fields": {}
},
{
"type": "keyword_time",
"named": true,
"fields": {}
},
{
"type": "keyword_timestamp",
"named": true,
"fields": {}
},
{
"type": "keyword_timestamptz",
"named": true,
"fields": {}
},
{
"type": "keyword_varchar",
"named": true,
"fields": {}
},
{
"type": "marginalia",
"named": true,
"fields": {}
},
{
"type": "numeric",
"named": true,
"fields": {
"precision": {
"multiple": false,
"required": false,
"types": [
{
"type": "literal",
"named": true
}
]
},
"scale": {
"multiple": false,
"required": false,
"types": [
{
"type": "literal",
"named": true
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "keyword_numeric",
"named": true
}
]
}
},
{
"type": "source_file",
"named": true,
@ -153,6 +379,32 @@
}
}
},
{
"type": "varchar",
"named": true,
"fields": {
"size": {
"multiple": false,
"required": false,
"types": [
{
"type": "literal",
"named": true
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "keyword_varchar",
"named": true
}
]
}
},
{
"type": "\"",
"named": false
@ -189,10 +441,38 @@
"type": ";",
"named": false
},
{
"type": "keyword_bigint",
"named": true
},
{
"type": "keyword_bigserial",
"named": true
},
{
"type": "keyword_boolean",
"named": true
},
{
"type": "keyword_bytea",
"named": true
},
{
"type": "keyword_create",
"named": true
},
{
"type": "keyword_date",
"named": true
},
{
"type": "keyword_datetime",
"named": true
},
{
"type": "keyword_decimal",
"named": true
},
{
"type": "keyword_exists",
"named": true
@ -201,16 +481,68 @@
"type": "keyword_if",
"named": true
},
{
"type": "keyword_integer",
"named": true
},
{
"type": "keyword_json",
"named": true
},
{
"type": "keyword_jsonb",
"named": true
},
{
"type": "keyword_money",
"named": true
},
{
"type": "keyword_not",
"named": true
},
{
"type": "keyword_numeric",
"named": true
},
{
"type": "keyword_real",
"named": true
},
{
"type": "keyword_serial",
"named": true
},
{
"type": "keyword_smallint",
"named": true
},
{
"type": "keyword_smallserial",
"named": true
},
{
"type": "keyword_table",
"named": true
},
{
"type": "keyword_text",
"named": true
},
{
"type": "keyword_unlogged",
"named": true
},
{
"type": "keyword_uuid",
"named": true
},
{
"type": "keyword_xml",
"named": true
},
{
"type": "literal",
"named": true
}
]

File diff suppressed because it is too large Load diff

View file

@ -110,3 +110,60 @@ create table if not exists foo ();
)
)
)
================================================================================
Create a table with different columns
================================================================================
create table foo (
c1 text,
c2 boolean,
c3 numeric(1),
c4 timestamp with time zone,
c5 varchar(120),
c6 uuid
);
--------------------------------------------------------------------------------
(source_file
(statement
(create_table
(keyword_create)
(keyword_table)
(table_reference
name: (identifier)
)
(column_definitions
(column_definition
name: (identifier)
datatype: (keyword_text)
)
(column_definition
name: (identifier)
datatype: (keyword_boolean)
)
(column_definition
name: (identifier)
datatype: (numeric
(keyword_numeric)
precision: (literal)
)
)
(column_definition
name: (identifier)
datatype: (keyword_timestamptz)
)
(column_definition
name: (identifier)
datatype: (varchar
(keyword_varchar)
size: (literal)
)
)
(column_definition
name: (identifier)
datatype: (keyword_uuid)
)
)
)
)
)

Binary file not shown.