diff --git a/crates/squawk_parser/src/generated/syntax_kind.rs b/crates/squawk_parser/src/generated/syntax_kind.rs index 7076217d..077ea734 100644 --- a/crates/squawk_parser/src/generated/syntax_kind.rs +++ b/crates/squawk_parser/src/generated/syntax_kind.rs @@ -993,6 +993,10 @@ pub enum SyntaxKind { WITH_CLAUSE, WITH_TABLE, WITH_TIMEZONE, + XML_COLUMN_OPTION, + XML_COLUMN_OPTION_LIST, + XML_TABLE_COLUMN, + XML_TABLE_COLUMN_LIST, #[doc(hidden)] __LAST, diff --git a/crates/squawk_parser/src/grammar.rs b/crates/squawk_parser/src/grammar.rs index a4ef5664..59193a7d 100644 --- a/crates/squawk_parser/src/grammar.rs +++ b/crates/squawk_parser/src/grammar.rs @@ -882,9 +882,6 @@ fn opt_xml_passing_mech(p: &mut Parser<'_>) -> bool { } fn xmlexists_arg(p: &mut Parser<'_>) { - if expr(p).is_none() { - p.error("expected expression"); - } p.expect(PASSING_KW); opt_xml_passing_mech(p); if expr(p).is_none() { @@ -905,6 +902,9 @@ fn xmlexists_arg(p: &mut Parser<'_>) { fn xmlexists_fn(p: &mut Parser<'_>) -> CompletedMarker { assert!(p.at(XMLEXISTS_KW)); custom_fn(p, XMLEXISTS_KW, |p| { + if expr(p).is_none() { + p.error("expected expression"); + } xmlexists_arg(p); }) } @@ -979,7 +979,7 @@ fn xmlserialize_fn(p: &mut Parser<'_>) -> CompletedMarker { p.error("expected expression"); } p.expect(AS_KW); - simple_type_name(p); + type_name(p); if p.eat(NO_KW) { p.expect(INDENT_KW); } else { @@ -2898,14 +2898,15 @@ fn data_source(p: &mut Parser<'_>) { p.expect(L_PAREN); xml_namespace_list(p); p.expect(R_PAREN); + p.expect(COMMA); } if expr(p).is_none() { p.error("expected expression"); } xmlexists_arg(p); - p.expect(COLUMNS_KW); xmltable_column_list(p); p.expect(R_PAREN); + opt_alias(p); } ROWS_KW if p.nth_at(1, FROM_KW) => { p.bump(ROWS_KW); @@ -2940,13 +2941,17 @@ fn data_source(p: &mut Parser<'_>) { } fn xmltable_column_list(p: &mut Parser<'_>) { + let m = p.start(); + p.expect(COLUMNS_KW); xmltable_column_el(p); while !p.at(EOF) && p.eat(COMMA) { xmltable_column_el(p); } + m.complete(p, XML_TABLE_COLUMN_LIST); } fn xmltable_column_el(p: &mut Parser<'_>) { + let m = p.start(); name(p); if p.eat(FOR_KW) { p.expect(ORDINALITY_KW); @@ -2954,20 +2959,21 @@ fn xmltable_column_el(p: &mut Parser<'_>) { type_name(p); opt_xmltable_column_option_list(p); } + m.complete(p, XML_TABLE_COLUMN); } fn opt_xmltable_column_option_list(p: &mut Parser<'_>) { - if opt_xmltable_column_option_el(p) { + let m = p.start(); + if opt_xmltable_column_option_el(p).is_none() { + m.abandon(p); return; } - while !p.at(EOF) && p.eat(COMMA) { - if !opt_xmltable_column_option_el(p) { - p.error("expected column option"); - } - } + while !p.at(EOF) && opt_xmltable_column_option_el(p).is_some() {} + m.complete(p, XML_COLUMN_OPTION_LIST); } -fn opt_xmltable_column_option_el(p: &mut Parser<'_>) -> bool { +fn opt_xmltable_column_option_el(p: &mut Parser<'_>) -> Option { + let m = p.start(); match p.current() { DEFAULT_KW | PATH_KW | IDENT => { p.bump_any(); @@ -2982,9 +2988,12 @@ fn opt_xmltable_column_option_el(p: &mut Parser<'_>) -> bool { NULL_KW => { p.bump(NULL_KW); } - _ => return false, + _ => { + m.abandon(p); + return None; + } } - true + Some(m.complete(p, XML_COLUMN_OPTION)) } fn xml_namespace_list(p: &mut Parser<'_>) { @@ -13098,6 +13107,10 @@ fn set(p: &mut Parser<'_>) -> CompletedMarker { let m = p.start(); p.bump(SET_KW); let _ = p.eat(SESSION_KW) || p.eat(LOCAL_KW); + if p.eat(XML_KW) { + p.expect(OPTION_KW); + let _ = p.eat(DOCUMENT_KW) || p.eat(CONTENT_KW); + } else // TIME ZONE { value | 'value' | LOCAL | DEFAULT } if p.eat(TIME_KW) { p.expect(ZONE_KW); diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_suite_errors.snap b/crates/squawk_parser/tests/snapshots/tests__regression_suite_errors.snap index c44d102a..2b211282 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_suite_errors.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_suite_errors.snap @@ -3,4 +3,3 @@ source: crates/squawk_parser/tests/tests.rs expression: "out.join(\"\\n\")" --- tests/snapshots/tests__regression_strings.snap:49 -tests/snapshots/tests__regression_xml.snap:382 diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap b/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap index 9c69fdcc..a4468dfb 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap @@ -2,385 +2,4 @@ source: crates/squawk_parser/tests/tests.rs input_file: crates/squawk_parser/tests/data/regression_suite/xml.sql --- -ERROR@4527: expected R_PAREN -ERROR@4531: expected SEMICOLON -ERROR@4531: expected command, found R_PAREN -ERROR@4533: expected command, found FROM_KW -ERROR@4538: expected command, found IDENT -ERROR@4589: expected R_PAREN -ERROR@4593: expected SEMICOLON -ERROR@4593: expected command, found R_PAREN -ERROR@7929: expected EQ -ERROR@7936: expected SEMICOLON -ERROR@7937: expected command, found DOCUMENT_KW -ERROR@8035: expected EQ -ERROR@8042: expected SEMICOLON -ERROR@8043: expected command, found CONTENT_KW -ERROR@9037: expected R_PAREN -ERROR@9041: expected SEMICOLON -ERROR@9041: expected command, found R_PAREN -ERROR@18420: expected PASSING_KW -ERROR@18610: expected R_PAREN -ERROR@18610: expected SEMICOLON -ERROR@18611: expected command, found NOT_KW -ERROR@18615: expected command, found NULL_KW -ERROR@18619: expected command, found COMMA -ERROR@18655: expected command, found IDENT -ERROR@18666: expected command, found TEXT_KW -ERROR@18671: expected command, found PATH_KW -ERROR@18676: expected command, found STRING -ERROR@18688: expected command, found COMMA -ERROR@18724: expected command, found IDENT -ERROR@18734: expected command, found INT_KW -ERROR@18738: expected command, found PATH_KW -ERROR@18743: expected command, found STRING -ERROR@18754: expected command, found COMMA -ERROR@18790: expected command, found IDENT -ERROR@18795: expected command, found FLOAT_KW -ERROR@18801: expected command, found PATH_KW -ERROR@18806: expected command, found STRING -ERROR@18812: expected command, found COMMA -ERROR@18848: expected command, found IDENT -ERROR@18853: expected command, found TEXT_KW -ERROR@18858: expected command, found PATH_KW -ERROR@18863: expected command, found STRING -ERROR@18875: expected command, found COMMA -ERROR@18911: expected command, found IDENT -ERROR@18924: expected command, found TEXT_KW -ERROR@18929: expected command, found PATH_KW -ERROR@18934: expected command, found STRING -ERROR@18949: expected command, found DEFAULT_KW -ERROR@18957: expected command, found STRING -ERROR@18972: expected command, found R_PAREN -ERROR@19131: expected PASSING_KW -ERROR@19321: expected R_PAREN -ERROR@19321: expected SEMICOLON -ERROR@19322: expected command, found NOT_KW -ERROR@19326: expected command, found NULL_KW -ERROR@19330: expected command, found COMMA -ERROR@19366: expected command, found IDENT -ERROR@19377: expected command, found TEXT_KW -ERROR@19382: expected command, found PATH_KW -ERROR@19387: expected command, found STRING -ERROR@19399: expected command, found COMMA -ERROR@19435: expected command, found IDENT -ERROR@19445: expected command, found INT_KW -ERROR@19449: expected command, found PATH_KW -ERROR@19454: expected command, found STRING -ERROR@19465: expected command, found COMMA -ERROR@19501: expected command, found IDENT -ERROR@19506: expected command, found FLOAT_KW -ERROR@19512: expected command, found PATH_KW -ERROR@19517: expected command, found STRING -ERROR@19523: expected command, found COMMA -ERROR@19559: expected command, found IDENT -ERROR@19564: expected command, found TEXT_KW -ERROR@19569: expected command, found PATH_KW -ERROR@19574: expected command, found STRING -ERROR@19586: expected command, found COMMA -ERROR@19622: expected command, found IDENT -ERROR@19635: expected command, found TEXT_KW -ERROR@19640: expected command, found PATH_KW -ERROR@19645: expected command, found STRING -ERROR@19660: expected command, found DEFAULT_KW -ERROR@19668: expected command, found STRING -ERROR@19683: expected command, found R_PAREN -ERROR@19874: expected PASSING_KW -ERROR@19901: expected SEMICOLON -ERROR@19902: expected command, found AS_KW -ERROR@19905: expected command, found IDENT -ERROR@19908: expected R_PAREN -ERROR@19908: expected SEMICOLON -ERROR@19908: expected command, found IDENT -ERROR@19910: expected command, found COMMA -ERROR@19912: expected command, found IDENT -ERROR@19914: expected command, found R_PAREN -ERROR@19956: expected PASSING_KW -ERROR@20003: expected SEMICOLON -ERROR@20004: expected command, found AS_KW -ERROR@20007: expected command, found IDENT -ERROR@20010: expected R_PAREN -ERROR@20010: expected SEMICOLON -ERROR@20010: expected command, found IDENT -ERROR@20012: expected command, found R_PAREN -ERROR@20095: expected an expression, found COMMA -ERROR@20096: expected expression -ERROR@20360: expected an expression, found COMMA -ERROR@20361: expected expression -ERROR@20627: expected an expression, found COMMA -ERROR@20628: expected expression -ERROR@20862: expected PASSING_KW -ERROR@20893: expected COLUMNS_KW -ERROR@21103: expected PASSING_KW -ERROR@21286: expected R_PAREN -ERROR@21286: expected SEMICOLON -ERROR@21287: expected command, found NOT_KW -ERROR@21291: expected command, found NULL_KW -ERROR@21295: expected command, found COMMA -ERROR@21331: expected command, found IDENT -ERROR@21342: expected command, found TEXT_KW -ERROR@21347: expected command, found PATH_KW -ERROR@21352: expected command, found STRING -ERROR@21364: expected command, found COMMA -ERROR@21400: expected command, found IDENT -ERROR@21410: expected command, found INT_KW -ERROR@21414: expected command, found PATH_KW -ERROR@21419: expected command, found STRING -ERROR@21430: expected command, found COMMA -ERROR@21466: expected command, found IDENT -ERROR@21471: expected command, found FLOAT_KW -ERROR@21477: expected command, found PATH_KW -ERROR@21482: expected command, found STRING -ERROR@21488: expected command, found COMMA -ERROR@21524: expected command, found IDENT -ERROR@21529: expected command, found TEXT_KW -ERROR@21534: expected command, found PATH_KW -ERROR@21539: expected command, found STRING -ERROR@21551: expected command, found COMMA -ERROR@21587: expected command, found IDENT -ERROR@21600: expected command, found TEXT_KW -ERROR@21605: expected command, found PATH_KW -ERROR@21610: expected command, found STRING -ERROR@21625: expected command, found DEFAULT_KW -ERROR@21633: expected command, found STRING -ERROR@21648: expected command, found R_PAREN -ERROR@21779: expected PASSING_KW -ERROR@21946: expected PASSING_KW -ERROR@22132: expected PASSING_KW -ERROR@22318: expected PASSING_KW -ERROR@22466: expected PASSING_KW -ERROR@22614: expected PASSING_KW -ERROR@22696: expected R_PAREN -ERROR@22696: expected SEMICOLON -ERROR@22697: expected command, found PATH_KW -ERROR@22702: expected command, found STRING -ERROR@22705: expected command, found R_PAREN -ERROR@22822: expected PASSING_KW -ERROR@22904: expected R_PAREN -ERROR@22904: expected SEMICOLON -ERROR@22905: expected command, found PATH_KW -ERROR@22910: expected command, found STRING -ERROR@22915: expected command, found R_PAREN -ERROR@23049: expected PASSING_KW -ERROR@23057: expected COLUMNS_KW -ERROR@23203: expected PASSING_KW -ERROR@23211: expected COLUMNS_KW -ERROR@23389: expected PASSING_KW -ERROR@23397: expected COLUMNS_KW -ERROR@23594: expected PASSING_KW -ERROR@23602: expected COLUMNS_KW -ERROR@23776: expected PASSING_KW -ERROR@23784: expected COLUMNS_KW -ERROR@23951: expected PASSING_KW -ERROR@24134: expected R_PAREN -ERROR@24134: expected SEMICOLON -ERROR@24135: expected command, found NOT_KW -ERROR@24139: expected command, found NULL_KW -ERROR@24143: expected command, found COMMA -ERROR@24179: expected command, found IDENT -ERROR@24190: expected command, found TEXT_KW -ERROR@24195: expected command, found PATH_KW -ERROR@24200: expected command, found STRING -ERROR@24212: expected command, found COMMA -ERROR@24248: expected command, found IDENT -ERROR@24258: expected command, found INT_KW -ERROR@24262: expected command, found PATH_KW -ERROR@24267: expected command, found STRING -ERROR@24278: expected command, found COMMA -ERROR@24314: expected command, found IDENT -ERROR@24319: expected command, found FLOAT_KW -ERROR@24325: expected command, found PATH_KW -ERROR@24330: expected command, found STRING -ERROR@24336: expected command, found COMMA -ERROR@24372: expected command, found IDENT -ERROR@24377: expected command, found TEXT_KW -ERROR@24382: expected command, found PATH_KW -ERROR@24387: expected command, found STRING -ERROR@24399: expected command, found COMMA -ERROR@24435: expected command, found IDENT -ERROR@24448: expected command, found TEXT_KW -ERROR@24453: expected command, found PATH_KW -ERROR@24458: expected command, found STRING -ERROR@24473: expected command, found DEFAULT_KW -ERROR@24481: expected command, found STRING -ERROR@24496: expected command, found R_PAREN -ERROR@24627: expected PASSING_KW -ERROR@24848: expected PASSING_KW -ERROR@24899: expected SEMICOLON -ERROR@24900: expected command, found AS_KW -ERROR@24903: expected command, found IDENT -ERROR@24905: expected command, found WHERE_KW -ERROR@24911: expected command, found IDENT -ERROR@24926: expected command, found EQ -ERROR@24928: expected command, found STRING -ERROR@25087: expected PASSING_KW -ERROR@25138: expected SEMICOLON -ERROR@25139: expected command, found AS_KW -ERROR@25142: expected command, found IDENT -ERROR@25144: expected command, found WHERE_KW -ERROR@25150: expected command, found IDENT -ERROR@25165: expected command, found EQ -ERROR@25167: expected command, found STRING -ERROR@26057: expected PASSING_KW -ERROR@26240: expected R_PAREN -ERROR@26240: expected SEMICOLON -ERROR@26241: expected command, found NOT_KW -ERROR@26245: expected command, found NULL_KW -ERROR@26249: expected command, found COMMA -ERROR@26285: expected command, found IDENT -ERROR@26296: expected command, found TEXT_KW -ERROR@26301: expected command, found PATH_KW -ERROR@26306: expected command, found STRING -ERROR@26318: expected command, found COMMA -ERROR@26354: expected command, found IDENT -ERROR@26364: expected command, found INT_KW -ERROR@26368: expected command, found PATH_KW -ERROR@26373: expected command, found STRING -ERROR@26384: expected command, found COMMA -ERROR@26420: expected command, found IDENT -ERROR@26425: expected command, found FLOAT_KW -ERROR@26431: expected command, found PATH_KW -ERROR@26436: expected command, found STRING -ERROR@26442: expected command, found COMMA -ERROR@26478: expected command, found IDENT -ERROR@26483: expected command, found TEXT_KW -ERROR@26488: expected command, found PATH_KW -ERROR@26493: expected command, found STRING -ERROR@26505: expected command, found COMMA -ERROR@26541: expected command, found IDENT -ERROR@26554: expected command, found TEXT_KW -ERROR@26559: expected command, found PATH_KW -ERROR@26564: expected command, found STRING -ERROR@26579: expected command, found DEFAULT_KW -ERROR@26587: expected command, found STRING -ERROR@26602: expected command, found R_PAREN -ERROR@26732: expected PASSING_KW -ERROR@26915: expected R_PAREN -ERROR@26915: expected SEMICOLON -ERROR@26916: expected command, found NOT_KW -ERROR@26920: expected command, found NULL_KW -ERROR@26924: expected command, found COMMA -ERROR@26960: expected command, found IDENT -ERROR@26971: expected command, found TEXT_KW -ERROR@26976: expected command, found PATH_KW -ERROR@26981: expected command, found STRING -ERROR@26993: expected command, found COMMA -ERROR@27029: expected command, found IDENT -ERROR@27039: expected command, found INT_KW -ERROR@27043: expected command, found PATH_KW -ERROR@27048: expected command, found STRING -ERROR@27059: expected command, found COMMA -ERROR@27095: expected command, found IDENT -ERROR@27100: expected command, found FLOAT_KW -ERROR@27106: expected command, found PATH_KW -ERROR@27111: expected command, found STRING -ERROR@27117: expected command, found COMMA -ERROR@27153: expected command, found IDENT -ERROR@27158: expected command, found TEXT_KW -ERROR@27163: expected command, found PATH_KW -ERROR@27168: expected command, found STRING -ERROR@27180: expected command, found COMMA -ERROR@27216: expected command, found IDENT -ERROR@27229: expected command, found TEXT_KW -ERROR@27234: expected command, found PATH_KW -ERROR@27239: expected command, found STRING -ERROR@27254: expected command, found DEFAULT_KW -ERROR@27262: expected command, found STRING -ERROR@27277: expected command, found R_PAREN -ERROR@27281: expected command, found WHERE_KW -ERROR@27287: expected command, found IDENT -ERROR@27297: expected command, found EQ -ERROR@27299: expected command, found INT_NUMBER -ERROR@27458: expected PASSING_KW -ERROR@27641: expected R_PAREN -ERROR@27641: expected SEMICOLON -ERROR@27642: expected command, found NOT_KW -ERROR@27646: expected command, found NULL_KW -ERROR@27650: expected command, found COMMA -ERROR@27686: expected command, found IDENT -ERROR@27697: expected command, found TEXT_KW -ERROR@27702: expected command, found PATH_KW -ERROR@27707: expected command, found STRING -ERROR@27719: expected command, found COMMA -ERROR@27755: expected command, found IDENT -ERROR@27765: expected command, found INT_KW -ERROR@27769: expected command, found PATH_KW -ERROR@27774: expected command, found STRING -ERROR@27785: expected command, found COMMA -ERROR@27821: expected command, found IDENT -ERROR@27826: expected command, found FLOAT_KW -ERROR@27832: expected command, found PATH_KW -ERROR@27837: expected command, found STRING -ERROR@27843: expected command, found COMMA -ERROR@27879: expected command, found IDENT -ERROR@27884: expected command, found TEXT_KW -ERROR@27889: expected command, found PATH_KW -ERROR@27894: expected command, found STRING -ERROR@27906: expected command, found COMMA -ERROR@27942: expected command, found IDENT -ERROR@27955: expected command, found TEXT_KW -ERROR@27960: expected command, found PATH_KW -ERROR@27965: expected command, found STRING -ERROR@27980: expected command, found DEFAULT_KW -ERROR@27988: expected command, found STRING -ERROR@28003: expected command, found R_PAREN -ERROR@28007: expected command, found WHERE_KW -ERROR@28013: expected command, found IDENT -ERROR@28023: expected command, found EQ -ERROR@28025: expected command, found INT_NUMBER -ERROR@28182: expected PASSING_KW -ERROR@28365: expected R_PAREN -ERROR@28365: expected SEMICOLON -ERROR@28366: expected command, found NOT_KW -ERROR@28370: expected command, found NULL_KW -ERROR@28374: expected command, found COMMA -ERROR@28410: expected command, found IDENT -ERROR@28421: expected command, found TEXT_KW -ERROR@28426: expected command, found PATH_KW -ERROR@28431: expected command, found STRING -ERROR@28443: expected command, found COMMA -ERROR@28479: expected command, found IDENT -ERROR@28489: expected command, found INT_KW -ERROR@28493: expected command, found PATH_KW -ERROR@28498: expected command, found STRING -ERROR@28509: expected command, found COMMA -ERROR@28545: expected command, found IDENT -ERROR@28550: expected command, found FLOAT_KW -ERROR@28556: expected command, found PATH_KW -ERROR@28561: expected command, found STRING -ERROR@28568: expected command, found NOT_KW -ERROR@28572: expected command, found NULL_KW -ERROR@28576: expected command, found COMMA -ERROR@28612: expected command, found IDENT -ERROR@28617: expected command, found TEXT_KW -ERROR@28622: expected command, found PATH_KW -ERROR@28627: expected command, found STRING -ERROR@28639: expected command, found COMMA -ERROR@28675: expected command, found IDENT -ERROR@28688: expected command, found TEXT_KW -ERROR@28693: expected command, found PATH_KW -ERROR@28698: expected command, found STRING -ERROR@28713: expected command, found DEFAULT_KW -ERROR@28721: expected command, found STRING -ERROR@28736: expected command, found R_PAREN -ERROR@29427: expected PASSING_KW -ERROR@30535: expected PASSING_KW -ERROR@31283: expected PASSING_KW -ERROR@31423: expected PASSING_KW -ERROR@31541: expected PASSING_KW -ERROR@31566: expected R_PAREN -ERROR@31566: expected SEMICOLON -ERROR@31567: expected command, found DEFAULT_KW -ERROR@31575: expected command, found IDENT -ERROR@31581: expected R_PAREN -ERROR@31581: expected SEMICOLON -ERROR@31581: expected command, found IDENT -ERROR@31586: expected command, found R_PAREN -ERROR@31588: expected command, found MINUS -ERROR@31590: expected command, found INT_NUMBER -ERROR@31592: expected command, found R_PAREN -ERROR@31686: expected PASSING_KW -ERROR@31694: expected COLUMNS_KW -ERROR@31915: expected PASSING_KW -ERROR@31923: expected COLUMNS_KW -ERROR@31996: expected PASSING_KW + diff --git a/crates/squawk_syntax/src/ast/generated/nodes.rs b/crates/squawk_syntax/src/ast/generated/nodes.rs index e1bfce78..db9d33d7 100644 --- a/crates/squawk_syntax/src/ast/generated/nodes.rs +++ b/crates/squawk_syntax/src/ast/generated/nodes.rs @@ -8798,6 +8798,90 @@ impl WithoutTimezone { } } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct XmlColumnOption { + pub(crate) syntax: SyntaxNode, +} +impl XmlColumnOption { + #[inline] + pub fn expr(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn default_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::DEFAULT_KW) + } + #[inline] + pub fn ident_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::IDENT) + } + #[inline] + pub fn not_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::NOT_KW) + } + #[inline] + pub fn null_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::NULL_KW) + } + #[inline] + pub fn path_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::PATH_KW) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct XmlColumnOptionList { + pub(crate) syntax: SyntaxNode, +} +impl XmlColumnOptionList { + #[inline] + pub fn xml_column_option(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn xml_column_options(&self) -> AstChildren { + support::children(&self.syntax) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct XmlTableColumn { + pub(crate) syntax: SyntaxNode, +} +impl XmlTableColumn { + #[inline] + pub fn name(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn ty(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn xml_column_option_list(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn for_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::FOR_KW) + } + #[inline] + pub fn ordinality_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::ORDINALITY_KW) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct XmlTableColumnList { + pub(crate) syntax: SyntaxNode, +} +impl XmlTableColumnList { + #[inline] + pub fn xml_table_columns(&self) -> AstChildren { + support::children(&self.syntax) + } +} + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AlterColumnOption { AddGenerated(AddGenerated), @@ -17044,6 +17128,78 @@ impl AstNode for WithoutTimezone { &self.syntax } } +impl AstNode for XmlColumnOption { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == SyntaxKind::XML_COLUMN_OPTION + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} +impl AstNode for XmlColumnOptionList { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == SyntaxKind::XML_COLUMN_OPTION_LIST + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} +impl AstNode for XmlTableColumn { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == SyntaxKind::XML_TABLE_COLUMN + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} +impl AstNode for XmlTableColumnList { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == SyntaxKind::XML_TABLE_COLUMN_LIST + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} impl AstNode for AlterColumnOption { #[inline] fn can_cast(kind: SyntaxKind) -> bool { diff --git a/crates/squawk_syntax/src/postgresql.ungram b/crates/squawk_syntax/src/postgresql.ungram index d0446aba..eb987152 100644 --- a/crates/squawk_syntax/src/postgresql.ungram +++ b/crates/squawk_syntax/src/postgresql.ungram @@ -957,6 +957,23 @@ FromClause = (FromItem (',' FromItem)*)? (JoinExpr (',' JoinExpr)*)? +XmlTableColumnList = + (XmlTableColumn (',' XmlTableColumn)*) + +XmlTableColumn = + Name Type XmlColumnOptionList? +| Name 'for' 'ordinality' + +XmlColumnOptionList = + (XmlColumnOption (XmlColumnOption*)) + +XmlColumnOption = + '#ident' Expr +| 'default' Expr +| 'not' 'null' +| 'null' +| 'path' Expr + ConstraintIndexMethod = 'using'