grammar: add varchar predefined type
This commit is contained in:
parent
ce72078360
commit
6e78cac399
6 changed files with 70965 additions and 69043 deletions
10
grammar.js
10
grammar.js
|
@ -875,7 +875,7 @@ module.exports = grammar({
|
|||
|
||||
_type: ($) =>
|
||||
seq(
|
||||
choice($.predefined_types, $.identifier),
|
||||
choice($.predefined_type, $.identifier),
|
||||
optional(choice(repeat1(seq("[", "]")), kw("%rowtype"), kw("%type")))
|
||||
),
|
||||
|
||||
|
@ -907,10 +907,16 @@ module.exports = grammar({
|
|||
// | VARCHAR l = type_length? { VarChar(l) }
|
||||
// (* | schema_qualified_name_nontype (LEFT_PAREN vex (COMMA vex)* RIGHT_PAREN)? *)
|
||||
// TODO(chrde): moar types!!
|
||||
predefined_types: ($) => choice(seq(kw("numeric"), optional($.precision))),
|
||||
predefined_type: ($) =>
|
||||
choice(
|
||||
seq(kw("numeric"), optional($.precision)),
|
||||
seq(kw("varchar"), optional($.type_length))
|
||||
),
|
||||
|
||||
precision: ($) => seq("(", $.number, optional(seq(",", $.number)), ")"),
|
||||
|
||||
type_length: ($) => seq("(", $.number, ")"),
|
||||
|
||||
string: ($) =>
|
||||
seq("'", repeat(choice(prec(1, /''/), prec(2, /[^']/))), "'"),
|
||||
|
||||
|
|
|
@ -5869,7 +5869,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "predefined_types"
|
||||
"name": "predefined_type"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -5916,7 +5916,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"predefined_types": {
|
||||
"predefined_type": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
|
@ -5939,6 +5939,27 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[vV][aA][rR][cC][hH][aA][rR]"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "type_length"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -5980,6 +6001,23 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"type_length": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "number"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"string": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "predefined_types",
|
||||
"type": "predefined_type",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
|
@ -1163,7 +1163,7 @@
|
|||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "predefined_types",
|
||||
"type": "predefined_type",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
|
@ -1770,7 +1770,7 @@
|
|||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "predefined_types",
|
||||
"type": "predefined_type",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
|
@ -1841,7 +1841,7 @@
|
|||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "predefined_types",
|
||||
"type": "predefined_type",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -2577,7 +2577,7 @@
|
|||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "predefined_types",
|
||||
"type": "predefined_type",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
|
@ -2749,7 +2749,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"type": "predefined_types",
|
||||
"type": "predefined_type",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
|
@ -2759,6 +2759,10 @@
|
|||
{
|
||||
"type": "precision",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "type_length",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -2854,7 +2858,7 @@
|
|||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "predefined_types",
|
||||
"type": "predefined_type",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -3584,7 +3588,7 @@
|
|||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "predefined_types",
|
||||
"type": "predefined_type",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -3841,6 +3845,21 @@
|
|||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "type_length",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "number",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "update_set",
|
||||
"named": true,
|
||||
|
@ -3989,7 +4008,7 @@
|
|||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "predefined_types",
|
||||
"type": "predefined_type",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
|
139867
src/parser.c
139867
src/parser.c
File diff suppressed because it is too large
Load diff
|
@ -55,6 +55,54 @@ create unlogged table foo();
|
|||
)
|
||||
)
|
||||
|
||||
================================================================================
|
||||
create table with predefined types
|
||||
================================================================================
|
||||
create table foo(
|
||||
col1 numeric,
|
||||
col2 numeric(2),
|
||||
col3 numeric(2, 4),
|
||||
col4 varchar,
|
||||
col5 varchar(255)
|
||||
);
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(create_table_statement
|
||||
(identifier)
|
||||
(create_table_item
|
||||
(table_column_item
|
||||
(identifier)
|
||||
(predefined_type)
|
||||
)
|
||||
)
|
||||
(create_table_item
|
||||
(table_column_item
|
||||
(identifier)
|
||||
(predefined_type (precision (number)))
|
||||
)
|
||||
)
|
||||
(create_table_item
|
||||
(table_column_item
|
||||
(identifier)
|
||||
(predefined_type (precision (number) (number)))
|
||||
)
|
||||
)
|
||||
(create_table_item
|
||||
(table_column_item
|
||||
(identifier)
|
||||
(predefined_type)
|
||||
)
|
||||
)
|
||||
(create_table_item
|
||||
(table_column_item
|
||||
(identifier)
|
||||
(predefined_type (type_length (number)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
================================================================================
|
||||
constraints with deferred
|
||||
================================================================================
|
||||
|
@ -85,7 +133,7 @@ create table foo(
|
|||
(create_table_item
|
||||
(table_column_item
|
||||
(identifier)
|
||||
(predefined_types
|
||||
(predefined_type
|
||||
(precision
|
||||
(number)
|
||||
(number)))
|
||||
|
@ -137,7 +185,7 @@ create table foo(
|
|||
(create_table_item
|
||||
(table_column_item
|
||||
(identifier)
|
||||
(predefined_types
|
||||
(predefined_type
|
||||
(precision
|
||||
(number)
|
||||
(number)))
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue