Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/squawk_ide/src/expand_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const ALL_LIST_KINDS: &[SyntaxKind] = &[
SyntaxKind::TARGET_LIST,
SyntaxKind::TRANSACTION_MODE_LIST,
SyntaxKind::VACUUM_OPTION_LIST,
SyntaxKind::VARIANT_LIST,
// only separated by whitespace
// SyntaxKind::XML_COLUMN_OPTION_LIST,
SyntaxKind::XML_TABLE_COLUMN_LIST,
Expand Down Expand Up @@ -572,6 +573,7 @@ $0
TARGET_LIST,
TRANSACTION_MODE_LIST,
VACUUM_OPTION_LIST,
VARIANT_LIST,
XML_TABLE_COLUMN_LIST,
]
");
Expand Down
2 changes: 2 additions & 0 deletions crates/squawk_parser/src/generated/syntax_kind.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 25 additions & 9 deletions crates/squawk_parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12926,15 +12926,7 @@ fn create_type(p: &mut Parser<'_>) -> CompletedMarker {
if p.eat(AS_KW) {
// AS ENUM
if p.eat(ENUM_KW) {
delimited(
p,
L_PAREN,
R_PAREN,
COMMA,
|| "unexpected comma".to_string(),
STRING_FIRST,
|p| opt_string_literal(p).is_some(),
);
variant_list(p);
// AS RANGE
} else if p.eat(RANGE_KW) {
attribute_list(p);
Expand All @@ -12959,6 +12951,30 @@ fn create_type(p: &mut Parser<'_>) -> CompletedMarker {
m.complete(p, CREATE_TYPE)
}

fn opt_variant(p: &mut Parser<'_>) -> bool {
let m = p.start();
if opt_string_literal(p).is_none() {
m.abandon(p);
return false;
}
m.complete(p, VARIANT);
true
}

fn variant_list(p: &mut Parser<'_>) {
let m = p.start();
delimited(
p,
L_PAREN,
R_PAREN,
COMMA,
|| "unexpected comma".to_string(),
STRING_FIRST,
opt_variant,
);
m.complete(p, VARIANT_LIST);
}

// CREATE EXTENSION [ IF NOT EXISTS ] extension_name
// [ WITH ] [ SCHEMA schema_name ]
// [ VERSION version ]
Expand Down
43 changes: 25 additions & 18 deletions crates/squawk_parser/tests/snapshots/tests__create_type_ok.snap
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ SOURCE_FILE
WHITESPACE " "
ENUM_KW "enum"
WHITESPACE " "
L_PAREN "("
R_PAREN ")"
VARIANT_LIST
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"
CREATE_TYPE
Expand All @@ -143,10 +144,12 @@ SOURCE_FILE
WHITESPACE " "
ENUM_KW "enum"
WHITESPACE " "
L_PAREN "("
LITERAL
STRING "'a'"
R_PAREN ")"
VARIANT_LIST
L_PAREN "("
VARIANT
LITERAL
STRING "'a'"
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"
CREATE_TYPE
Expand All @@ -163,18 +166,22 @@ SOURCE_FILE
WHITESPACE " "
ENUM_KW "enum"
WHITESPACE " "
L_PAREN "("
LITERAL
STRING "'a'"
COMMA ","
WHITESPACE " "
LITERAL
STRING "'b'"
COMMA ","
WHITESPACE " "
LITERAL
STRING "'c'"
R_PAREN ")"
VARIANT_LIST
L_PAREN "("
VARIANT
LITERAL
STRING "'a'"
COMMA ","
WHITESPACE " "
VARIANT
LITERAL
STRING "'b'"
COMMA ","
WHITESPACE " "
VARIANT
LITERAL
STRING "'c'"
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n\n"
COMMENT "-- create_type_as_range"
Expand Down
90 changes: 90 additions & 0 deletions crates/squawk_syntax/src/ast/generated/nodes.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions crates/squawk_syntax/src/postgresql.ungram
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,19 @@ IndexParams =
CreateType =
'create' 'type' Type

(('as' 'enum' VariantList)
| ('as' 'range' )
| ('as' '(' ')')
| ('(' ')'))

VariantList =
'('
(Variant (',' Variant)*)
')'

Variant =
Literal

CreateExtension =
'create' 'extension'

Expand Down
2 changes: 1 addition & 1 deletion crates/squawk_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn dump_tokens(text: String) -> String {
out
}

#[allow(dead_code)]
#[expect(unused)]
#[derive(Serialize)]
enum Severity {
Hint,
Expand Down
Loading