Compare commits
6 Commits
8a50f066ab
...
acda125c15
Author | SHA1 | Date |
---|---|---|
Dmitriy Pleshevskiy | acda125c15 | |
Dmitriy Pleshevskiy | b6be01e6a9 | |
Dmitriy Pleshevskiy | e4e1756164 | |
Dmitriy Pleshevskiy | 13896dfb7b | |
Dmitriy Pleshevskiy | 98c15a25dc | |
Dmitriy Pleshevskiy | cc6fa3e0f7 |
|
@ -2,7 +2,7 @@
|
|||
|
||||
let
|
||||
extraGrammars = {
|
||||
tree-sitter-plpgsql = {
|
||||
tree-sitter-psql = {
|
||||
language = "psql";
|
||||
src = ../.;
|
||||
version = "0.0.0";
|
||||
|
@ -10,14 +10,17 @@ let
|
|||
};
|
||||
|
||||
tree-sitter = (pkgs.tree-sitter.override { inherit extraGrammars; });
|
||||
grammars = tree-sitter.withPlugins (g: tree-sitter.allGrammars);
|
||||
grammars = tree-sitter.withPlugins (g: [ g.tree-sitter-psql ]);
|
||||
|
||||
nvim-treesitter = pkgs.vimPlugins.nvim-treesitter.overrideAttrs (oldAttrs: {
|
||||
nvim-treesitter = pkgs.vimPlugins.nvim-treesitter.withAllGrammars.overrideAttrs (oldAttrs: {
|
||||
passthru.dependencies = oldAttrs.passthru.dependencies ++ [
|
||||
(pkgs.runCommand "nvim-treesitter-psql-grammar" { } ''
|
||||
mkdir -p $out/parser
|
||||
ln -s ${grammars}/psql.so $out/parser/psql.so
|
||||
'')
|
||||
];
|
||||
postPatch = ''
|
||||
rm -r parser
|
||||
ln -s ${grammars} parser
|
||||
|
||||
ln -s ${../.}/queries queries/psql
|
||||
ln -s ${extraGrammars.tree-sitter-psql.src}/queries queries/psql
|
||||
'';
|
||||
});
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1672756850,
|
||||
"narHash": "sha256-Smbq3+fitwA13qsTMeaaurv09/KVbZfW7m7lINwzDGA=",
|
||||
"lastModified": 1672997035,
|
||||
"narHash": "sha256-DNaNjsGMRYefBTAxFIrVOB2ok477cj1FTpqnu/mKRf4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "298add347c2bbce14020fcb54051f517c391196b",
|
||||
"rev": "f1ffcf798e93b169321106a4aef79526a2b4bd0a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
148
grammar.js
148
grammar.js
|
@ -1,7 +1,7 @@
|
|||
module.exports = grammar({
|
||||
name: "plpgsql",
|
||||
name: "psql",
|
||||
|
||||
extras: ($) => [/\s\n/, /\s/, $.comment, $.marginalia],
|
||||
extras: ($) => [/\s\n/, /\s/, $.line_comment, $.block_comment],
|
||||
|
||||
conflicts: ($) => [[$.keyword_char, $.keyword_varchar]],
|
||||
|
||||
|
@ -55,16 +55,55 @@ module.exports = grammar({
|
|||
choice(
|
||||
$._not_null,
|
||||
$.keyword_null,
|
||||
seq($.keyword_default, $._expression)
|
||||
seq($.keyword_default, $._expression),
|
||||
// TODO: add index_parameters in UNIQUE, PRIMARY KEY
|
||||
seq(
|
||||
$.keyword_unique,
|
||||
optional(
|
||||
seq($.keyword_nulls, optional($.keyword_not), $.keyword_distinct)
|
||||
)
|
||||
),
|
||||
$._primary_key,
|
||||
seq(
|
||||
$.keyword_references,
|
||||
$.table_reference,
|
||||
optional(seq("(", field("refcolumn", $.identifier), ")")),
|
||||
optional($._foreign_key_match),
|
||||
optional(
|
||||
choice(
|
||||
seq($._foreign_key_on_delete, $._foreign_key_on_update),
|
||||
seq($._foreign_key_on_update, $._foreign_key_on_delete)
|
||||
)
|
||||
)
|
||||
)
|
||||
// TODO: CHECK
|
||||
// TODO: GENERATED
|
||||
// TODO: UNIQUE
|
||||
// TODO: PRIMARY KEY
|
||||
// TODO: FOREIGN KEY
|
||||
)
|
||||
// TODO: DEFERRABLE
|
||||
),
|
||||
|
||||
_foreign_key_match: ($) =>
|
||||
seq(
|
||||
$.keyword_match,
|
||||
choice($.keyword_full, $.keyword_partial, $.keyword_simple)
|
||||
),
|
||||
_foreign_key_on_delete: ($) =>
|
||||
seq($.keyword_on, $.keyword_delete, $.referencial_action),
|
||||
_foreign_key_on_update: ($) =>
|
||||
seq($.keyword_on, $.keyword_update, $.referencial_action),
|
||||
|
||||
referencial_action: ($) =>
|
||||
choice(
|
||||
seq($.keyword_no, $.keyword_action),
|
||||
$.keyword_restrict,
|
||||
$.keyword_cascade,
|
||||
seq(
|
||||
$.keyword_set,
|
||||
choice($.keyword_null, $.keyword_default),
|
||||
optional(seq("(", commaSepRepeat1($.identifier), ")"))
|
||||
)
|
||||
),
|
||||
|
||||
table_reference: ($) =>
|
||||
seq(
|
||||
optional(seq(field("schema", $.identifier), ".")),
|
||||
|
@ -79,30 +118,13 @@ module.exports = grammar({
|
|||
|
||||
literal: ($) =>
|
||||
choice(
|
||||
$._number,
|
||||
$._literal_string,
|
||||
$.number,
|
||||
$.literal_string,
|
||||
$.keyword_true,
|
||||
$.keyword_false,
|
||||
$.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"),
|
||||
|
||||
// References: https://www.postgresql.org/docs/15/datatype.html
|
||||
_type: ($) =>
|
||||
choice(
|
||||
|
@ -184,8 +206,53 @@ 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
|
||||
_primary_key: ($) => seq($.keyword_primary, $.keyword_key),
|
||||
_foreign_key: ($) => seq($.keyword_foreign, $.keyword_key),
|
||||
_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"),
|
||||
keyword_primary: (_) => mkKeyword("primary"),
|
||||
keyword_foreign: (_) => mkKeyword("foreign"),
|
||||
keyword_key: (_) => mkKeyword("key"),
|
||||
keyword_references: (_) => mkKeyword("references"),
|
||||
keyword_on: (_) => mkKeyword("on"),
|
||||
keyword_no: (_) => mkKeyword("no"),
|
||||
keyword_delete: (_) => mkKeyword("delete"),
|
||||
keyword_update: (_) => mkKeyword("update"),
|
||||
keyword_match: (_) => mkKeyword("match"),
|
||||
keyword_full: (_) => mkKeyword("full"),
|
||||
keyword_partial: (_) => mkKeyword("partial"),
|
||||
keyword_simple: (_) => mkKeyword("simple"),
|
||||
keyword_action: (_) => mkKeyword("action"),
|
||||
keyword_set: (_) => mkKeyword("set"),
|
||||
keyword_restrict: (_) => mkKeyword("restrict"),
|
||||
keyword_cascade: (_) => mkKeyword("cascade"),
|
||||
// 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"),
|
||||
|
@ -195,10 +262,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: (_) =>
|
||||
|
@ -206,9 +271,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: ($) =>
|
||||
|
@ -224,27 +287,14 @@ 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"),
|
||||
|
||||
// -------
|
||||
|
||||
comment: (_) => seq("--", /.*\n/),
|
||||
line_comment: (_) => seq("--", /.*\n/),
|
||||
// https://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment
|
||||
marginalia: (_) => seq("/*", /[^*]*\*+(?:[^/*][^*]*\*+)*/, "/"),
|
||||
block_comment: (_) => seq("/*", /[^*]*\*+(?:[^/*][^*]*\*+)*/, "/"),
|
||||
|
||||
_literal_string: ($) => choice(seq("'", /[^']*/, "'")),
|
||||
_number: (_) => /\d+/,
|
||||
literal_string: ($) => choice(seq("'", /[^']*/, "'")),
|
||||
number: (_) => /\d+/,
|
||||
|
||||
identifier: ($) => choice($._identifier, seq('"', /[^"]+/, '"')),
|
||||
|
||||
|
@ -268,9 +318,9 @@ function parametricType($, type, params = ["size"]) {
|
|||
type,
|
||||
"(",
|
||||
// first parameter is guaranteed, shift it out of the array
|
||||
field(params.shift(), alias($._number, $.literal)),
|
||||
field(params.shift(), $.number),
|
||||
// then, fill in the ", next" until done
|
||||
...params.map((p) => seq(",", field(p, alias($._number, $.literal)))),
|
||||
...params.map((p) => seq(",", field(p, $.number))),
|
||||
")"
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "tree-sitter-plpgsql",
|
||||
"name": "tree-sitter-psql",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "grammar.js",
|
||||
|
@ -8,7 +8,9 @@
|
|||
"tree-sitter": [
|
||||
{
|
||||
"scope": "source.psql",
|
||||
"file-types": ["psql"],
|
||||
"file-types": [
|
||||
"psql"
|
||||
],
|
||||
"injection-regex": "^psql$"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
; Keywords
|
||||
[
|
||||
(keyword_cascade)
|
||||
(keyword_constraint)
|
||||
(keyword_create)
|
||||
(keyword_default)
|
||||
(keyword_delete)
|
||||
(keyword_key)
|
||||
(keyword_not)
|
||||
(keyword_null)
|
||||
(keyword_on)
|
||||
(keyword_primary)
|
||||
(keyword_references)
|
||||
(keyword_table)
|
||||
(keyword_update)
|
||||
] @keyword
|
||||
|
||||
; Identifiers
|
||||
(column_definition name: (identifier) @variable)
|
||||
(column_constraint name: (identifier) @variable)
|
||||
|
||||
(table_reference schema: (identifier) @namespace)
|
||||
(table_reference name: (identifier) @constant)
|
||||
|
||||
; Types
|
||||
[
|
||||
(keyword_smallint)
|
||||
(keyword_integer)
|
||||
(keyword_bigint)
|
||||
(keyword_smallserial)
|
||||
(keyword_serial)
|
||||
(keyword_bigserial)
|
||||
(keyword_real)
|
||||
(double)
|
||||
(decimal)
|
||||
(numeric)
|
||||
(keyword_uuid)
|
||||
(keyword_text)
|
||||
(char)
|
||||
(varchar)
|
||||
(keyword_json)
|
||||
(keyword_jsonb)
|
||||
(keyword_date)
|
||||
(keyword_datetime)
|
||||
(keyword_time)
|
||||
(keyword_timestamp)
|
||||
(keyword_timestamptz)
|
||||
(keyword_bytea)
|
||||
(keyword_money)
|
||||
(keyword_boolean)
|
||||
(keyword_xml)
|
||||
] @type.builtin
|
||||
|
||||
; Literal
|
||||
[(keyword_true) (keyword_false)] @boolean
|
||||
(number) @number
|
||||
|
||||
; Comments
|
||||
(line_comment) @comment.line
|
||||
(block_comment) @comment.block
|
||||
|
||||
; Punctuation
|
||||
[
|
||||
";"
|
||||
"."
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
[
|
||||
"("
|
||||
")"
|
||||
] @punctuation.brackets
|
769
src/grammar.json
769
src/grammar.json
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "plpgsql",
|
||||
"name": "psql",
|
||||
"word": "_identifier",
|
||||
"rules": {
|
||||
"source_file": {
|
||||
|
@ -242,6 +242,299 @@
|
|||
"name": "_expression"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_unique"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_nulls"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_not"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_distinct"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_primary_key"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_references"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "table_reference"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "refcolumn",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_foreign_key_match"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_foreign_key_on_delete"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_foreign_key_on_update"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_foreign_key_on_update"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_foreign_key_on_delete"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"_foreign_key_match": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_match"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_full"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_partial"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_simple"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"_foreign_key_on_delete": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_on"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_delete"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "referencial_action"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_foreign_key_on_update": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_on"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_update"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "referencial_action"
|
||||
}
|
||||
]
|
||||
},
|
||||
"referencial_action": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_no"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_action"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_restrict"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_cascade"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_set"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_null"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_default"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -299,11 +592,11 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_number"
|
||||
"name": "number"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_literal_string"
|
||||
"name": "literal_string"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -319,93 +612,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"
|
||||
},
|
||||
"_type": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
|
@ -545,13 +751,8 @@
|
|||
"type": "FIELD",
|
||||
"name": "precision",
|
||||
"content": {
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_number"
|
||||
},
|
||||
"named": true,
|
||||
"value": "literal"
|
||||
"type": "SYMBOL",
|
||||
"name": "number"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -588,13 +789,8 @@
|
|||
"type": "FIELD",
|
||||
"name": "precision",
|
||||
"content": {
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_number"
|
||||
},
|
||||
"named": true,
|
||||
"value": "literal"
|
||||
"type": "SYMBOL",
|
||||
"name": "number"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -608,13 +804,8 @@
|
|||
"type": "FIELD",
|
||||
"name": "scale",
|
||||
"content": {
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_number"
|
||||
},
|
||||
"named": true,
|
||||
"value": "literal"
|
||||
"type": "SYMBOL",
|
||||
"name": "number"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -658,13 +849,8 @@
|
|||
"type": "FIELD",
|
||||
"name": "precision",
|
||||
"content": {
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_number"
|
||||
},
|
||||
"named": true,
|
||||
"value": "literal"
|
||||
"type": "SYMBOL",
|
||||
"name": "number"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -701,13 +887,8 @@
|
|||
"type": "FIELD",
|
||||
"name": "precision",
|
||||
"content": {
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_number"
|
||||
},
|
||||
"named": true,
|
||||
"value": "literal"
|
||||
"type": "SYMBOL",
|
||||
"name": "number"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -721,13 +902,8 @@
|
|||
"type": "FIELD",
|
||||
"name": "scale",
|
||||
"content": {
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_number"
|
||||
},
|
||||
"named": true,
|
||||
"value": "literal"
|
||||
"type": "SYMBOL",
|
||||
"name": "number"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -785,13 +961,8 @@
|
|||
"type": "FIELD",
|
||||
"name": "size",
|
||||
"content": {
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_number"
|
||||
},
|
||||
"named": true,
|
||||
"value": "literal"
|
||||
"type": "SYMBOL",
|
||||
"name": "number"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -828,13 +999,8 @@
|
|||
"type": "FIELD",
|
||||
"name": "size",
|
||||
"content": {
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_number"
|
||||
},
|
||||
"named": true,
|
||||
"value": "literal"
|
||||
"type": "SYMBOL",
|
||||
"name": "number"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -900,6 +1066,250 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"_primary_key": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_primary"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_key"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_foreign_key": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_foreign"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "keyword_key"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_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_primary": {
|
||||
"type": "PATTERN",
|
||||
"value": "primary|PRIMARY"
|
||||
},
|
||||
"keyword_foreign": {
|
||||
"type": "PATTERN",
|
||||
"value": "foreign|FOREIGN"
|
||||
},
|
||||
"keyword_key": {
|
||||
"type": "PATTERN",
|
||||
"value": "key|KEY"
|
||||
},
|
||||
"keyword_references": {
|
||||
"type": "PATTERN",
|
||||
"value": "references|REFERENCES"
|
||||
},
|
||||
"keyword_on": {
|
||||
"type": "PATTERN",
|
||||
"value": "on|ON"
|
||||
},
|
||||
"keyword_no": {
|
||||
"type": "PATTERN",
|
||||
"value": "no|NO"
|
||||
},
|
||||
"keyword_delete": {
|
||||
"type": "PATTERN",
|
||||
"value": "delete|DELETE"
|
||||
},
|
||||
"keyword_update": {
|
||||
"type": "PATTERN",
|
||||
"value": "update|UPDATE"
|
||||
},
|
||||
"keyword_match": {
|
||||
"type": "PATTERN",
|
||||
"value": "match|MATCH"
|
||||
},
|
||||
"keyword_full": {
|
||||
"type": "PATTERN",
|
||||
"value": "full|FULL"
|
||||
},
|
||||
"keyword_partial": {
|
||||
"type": "PATTERN",
|
||||
"value": "partial|PARTIAL"
|
||||
},
|
||||
"keyword_simple": {
|
||||
"type": "PATTERN",
|
||||
"value": "simple|SIMPLE"
|
||||
},
|
||||
"keyword_action": {
|
||||
"type": "PATTERN",
|
||||
"value": "action|ACTION"
|
||||
},
|
||||
"keyword_set": {
|
||||
"type": "PATTERN",
|
||||
"value": "set|SET"
|
||||
},
|
||||
"keyword_restrict": {
|
||||
"type": "PATTERN",
|
||||
"value": "restrict|RESTRICT"
|
||||
},
|
||||
"keyword_cascade": {
|
||||
"type": "PATTERN",
|
||||
"value": "cascade|CASCADE"
|
||||
},
|
||||
"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"
|
||||
|
@ -1064,62 +1474,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"_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"
|
||||
},
|
||||
"comment": {
|
||||
"line_comment": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
|
@ -1132,7 +1487,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"marginalia": {
|
||||
"block_comment": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
|
@ -1149,7 +1504,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"_literal_string": {
|
||||
"literal_string": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
|
@ -1171,7 +1526,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"_number": {
|
||||
"number": {
|
||||
"type": "PATTERN",
|
||||
"value": "\\d+"
|
||||
},
|
||||
|
@ -1217,11 +1572,11 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "comment"
|
||||
"name": "line_comment"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "marginalia"
|
||||
"name": "block_comment"
|
||||
}
|
||||
],
|
||||
"conflicts": [
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
[
|
||||
{
|
||||
"type": "block_comment",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "char",
|
||||
"named": true,
|
||||
|
@ -8,7 +13,7 @@
|
|||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "literal",
|
||||
"type": "number",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -38,6 +43,16 @@
|
|||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"refcolumn": {
|
||||
"multiple": false,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
|
@ -52,6 +67,26 @@
|
|||
"type": "keyword_default",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_delete",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_distinct",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_full",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_key",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_match",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_not",
|
||||
"named": true
|
||||
|
@ -60,9 +95,49 @@
|
|||
"type": "keyword_null",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_nulls",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_on",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_partial",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_primary",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_references",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_simple",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_unique",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_update",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "literal",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "referencial_action",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "table_reference",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -206,11 +281,6 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "comment",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "create_table",
|
||||
"named": true,
|
||||
|
@ -267,7 +337,7 @@
|
|||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "literal",
|
||||
"type": "number",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -277,7 +347,7 @@
|
|||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "literal",
|
||||
"type": "number",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -334,13 +404,18 @@
|
|||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "line_comment",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "literal",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "keyword_false",
|
||||
|
@ -353,12 +428,20 @@
|
|||
{
|
||||
"type": "keyword_true",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "literal_string",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "marginalia",
|
||||
"type": "literal_string",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
|
@ -371,7 +454,7 @@
|
|||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "literal",
|
||||
"type": "number",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -381,7 +464,7 @@
|
|||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "literal",
|
||||
"type": "number",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -398,6 +481,49 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "referencial_action",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_action",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_cascade",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_default",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_no",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_null",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_restrict",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_set",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "source_file",
|
||||
"named": true,
|
||||
|
@ -463,7 +589,7 @@
|
|||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "literal",
|
||||
"type": "number",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -520,6 +646,10 @@
|
|||
"type": ";",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "keyword_action",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_bigint",
|
||||
"named": true
|
||||
|
@ -536,6 +666,10 @@
|
|||
"type": "keyword_bytea",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_cascade",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_constraint",
|
||||
"named": true
|
||||
|
@ -560,6 +694,14 @@
|
|||
"type": "keyword_default",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_delete",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_distinct",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_exists",
|
||||
"named": true
|
||||
|
@ -568,6 +710,14 @@
|
|||
"type": "keyword_false",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_foreign",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_full",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_if",
|
||||
"named": true
|
||||
|
@ -584,10 +734,22 @@
|
|||
"type": "keyword_jsonb",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_key",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_match",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_money",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_no",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_not",
|
||||
"named": true
|
||||
|
@ -596,18 +758,50 @@
|
|||
"type": "keyword_null",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_nulls",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_numeric",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_on",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_partial",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_primary",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_real",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_references",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_restrict",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_serial",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_set",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_simple",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_smallint",
|
||||
"named": true
|
||||
|
@ -628,10 +822,18 @@
|
|||
"type": "keyword_true",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_unique",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_unlogged",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_update",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "keyword_uuid",
|
||||
"named": true
|
||||
|
@ -639,5 +841,9 @@
|
|||
{
|
||||
"type": "keyword_xml",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"named": true
|
||||
}
|
||||
]
|
7452
src/parser.c
7452
src/parser.c
File diff suppressed because it is too large
Load Diff
|
@ -145,7 +145,7 @@ create table foo (
|
|||
name: (identifier)
|
||||
datatype: (numeric
|
||||
(keyword_numeric)
|
||||
precision: (literal)
|
||||
precision: (number)
|
||||
)
|
||||
)
|
||||
(column_definition
|
||||
|
@ -156,7 +156,7 @@ create table foo (
|
|||
name: (identifier)
|
||||
datatype: (varchar
|
||||
(keyword_varchar)
|
||||
size: (literal)
|
||||
size: (number)
|
||||
)
|
||||
)
|
||||
(column_definition
|
||||
|
@ -172,9 +172,10 @@ create table foo (
|
|||
Create a table with column constraints
|
||||
================================================================================
|
||||
create table foo (
|
||||
id uuid primary key,
|
||||
c1 text not null,
|
||||
c2 text null,
|
||||
c2 text not null default 'hello'
|
||||
c3 text not null default 'hello'
|
||||
);
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -187,6 +188,14 @@ create table foo (
|
|||
name: (identifier)
|
||||
)
|
||||
(column_definitions
|
||||
(column_definition
|
||||
name: (identifier)
|
||||
datatype: (keyword_uuid)
|
||||
(column_constraint
|
||||
(keyword_primary)
|
||||
(keyword_key)
|
||||
)
|
||||
)
|
||||
(column_definition
|
||||
name: (identifier)
|
||||
datatype: (keyword_text)
|
||||
|
@ -211,7 +220,65 @@ create table foo (
|
|||
)
|
||||
(column_constraint
|
||||
(keyword_default)
|
||||
(literal)
|
||||
(literal
|
||||
(literal_string)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
================================================================================
|
||||
Create a table with primary key and foreign key
|
||||
================================================================================
|
||||
create table foo (
|
||||
id uuid primary key,
|
||||
bar_id uuid null references bar (id) on update set null on delete cascade
|
||||
);
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(statement
|
||||
(create_table
|
||||
(keyword_create)
|
||||
(keyword_table)
|
||||
(table_reference
|
||||
name: (identifier)
|
||||
)
|
||||
(column_definitions
|
||||
(column_definition
|
||||
name: (identifier)
|
||||
datatype: (keyword_uuid)
|
||||
(column_constraint
|
||||
(keyword_primary)
|
||||
(keyword_key)
|
||||
)
|
||||
)
|
||||
(column_definition
|
||||
name: (identifier)
|
||||
datatype: (keyword_uuid)
|
||||
(column_constraint
|
||||
(keyword_null)
|
||||
)
|
||||
(column_constraint
|
||||
(keyword_references)
|
||||
(table_reference
|
||||
name: (identifier)
|
||||
)
|
||||
refcolumn: (identifier)
|
||||
(keyword_on)
|
||||
(keyword_update)
|
||||
(referencial_action
|
||||
(keyword_set)
|
||||
(keyword_null)
|
||||
)
|
||||
(keyword_on)
|
||||
(keyword_delete)
|
||||
(referencial_action
|
||||
(keyword_cascade)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -223,9 +290,11 @@ create table foo (
|
|||
Create a table with named column constraints
|
||||
================================================================================
|
||||
create table foo (
|
||||
id uuid constraint foo_pkey primary key,
|
||||
c1 text constraint strong_c1 not null,
|
||||
c2 text constraint weak_c2 null,
|
||||
c3 text constraint "c3 with power" not null constraint "c2 set default hello" default 'hello'
|
||||
c3 text constraint "c3 with power" not null constraint "c2 set default hello" default 'hello',
|
||||
c4 text constraint "c4 unique" unique nulls not distinct
|
||||
);
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -238,6 +307,16 @@ create table foo (
|
|||
name: (identifier)
|
||||
)
|
||||
(column_definitions
|
||||
(column_definition
|
||||
name: (identifier)
|
||||
datatype: (keyword_uuid)
|
||||
(column_constraint
|
||||
(keyword_constraint)
|
||||
name: (identifier)
|
||||
(keyword_primary)
|
||||
(keyword_key)
|
||||
)
|
||||
)
|
||||
(column_definition
|
||||
name: (identifier)
|
||||
datatype: (keyword_text)
|
||||
|
@ -270,7 +349,21 @@ create table foo (
|
|||
(keyword_constraint)
|
||||
name: (identifier)
|
||||
(keyword_default)
|
||||
(literal)
|
||||
(literal
|
||||
(literal_string)
|
||||
)
|
||||
)
|
||||
)
|
||||
(column_definition
|
||||
name: (identifier)
|
||||
datatype: (keyword_text)
|
||||
(column_constraint
|
||||
(keyword_constraint)
|
||||
name: (identifier)
|
||||
(keyword_unique)
|
||||
(keyword_nulls)
|
||||
(keyword_not)
|
||||
(keyword_distinct)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
create table public.foo (
|
||||
-- <- keyword
|
||||
-- ^ keyword
|
||||
-- ^ namespace
|
||||
-- ^ punctuation.delimiter
|
||||
-- ^ constant
|
||||
-- ^ punctuation.brackets
|
||||
id uuid constraint foo_pkey primary key,
|
||||
-- <- variable
|
||||
-- ^ type.builtin
|
||||
-- ^ keyword
|
||||
-- ^ variable
|
||||
-- ^ keyword
|
||||
-- ^ keyword
|
||||
-- ^ punctuation.delimiter
|
||||
|
||||
confirmed boolean not null default true
|
||||
-- <- variable
|
||||
-- ^ type.builtin
|
||||
-- ^ keyword
|
||||
-- ^ keyword
|
||||
-- ^ keyword
|
||||
-- ^ boolean
|
||||
|
||||
bar_id uuid not null constraint foo_bar_id_fkey references bar on update cascade on delete cascade,
|
||||
-- ^ keyword
|
||||
-- ^ variable
|
||||
-- ^ keyword
|
||||
-- ^ constant
|
||||
-- ^ keyword
|
||||
-- ^ keyword
|
||||
-- ^ keyword
|
||||
-- ^ keyword
|
||||
-- ^ keyword
|
||||
-- ^ keyword
|
||||
) ;
|
||||
-- <- punctuation.brackets
|
||||
-- ^ punctuation.delimiter
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue