diff --git a/crates/squawk_parser/src/generated/syntax_kind.rs b/crates/squawk_parser/src/generated/syntax_kind.rs index ad215842..4de4c164 100644 --- a/crates/squawk_parser/src/generated/syntax_kind.rs +++ b/crates/squawk_parser/src/generated/syntax_kind.rs @@ -851,6 +851,7 @@ pub enum SyntaxKind { PARAM_OUT, PARAM_VARIADIC, PAREN_EXPR, + PAREN_SELECT, PATH, PATH_SEGMENT, PATH_TYPE, diff --git a/crates/squawk_parser/src/grammar.rs b/crates/squawk_parser/src/grammar.rs index 6f806310..ce43f617 100644 --- a/crates/squawk_parser/src/grammar.rs +++ b/crates/squawk_parser/src/grammar.rs @@ -89,7 +89,7 @@ fn paren_select(p: &mut Parser<'_>) -> Option { } } p.expect(R_PAREN); - Some(m.complete(p, PAREN_EXPR)) + Some(m.complete(p, PAREN_SELECT)) } const SELECT_FIRST: TokenSet = TokenSet::new(&[SELECT_KW, TABLE_KW, WITH_KW, VALUES_KW]); @@ -889,6 +889,18 @@ 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() { + p.error("expected expression"); + } + opt_xml_passing_mech(p); +} + // XMLEXISTS '(' c_expr xmlexists_argument ')' // xmlexists_argument: // | PASSING c_expr @@ -901,15 +913,7 @@ fn opt_xml_passing_mech(p: &mut Parser<'_>) -> bool { 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"); - } - p.expect(PASSING_KW); - opt_xml_passing_mech(p); - if expr(p).is_none() { - p.error("expected expression"); - } - opt_xml_passing_mech(p); + xmlexists_arg(p); }) } @@ -2765,6 +2769,22 @@ fn data_source(p: &mut Parser<'_>) { json_table_fn(p); opt_alias(p); } + XMLTABLE_KW => { + p.bump(XMLTABLE_KW); + p.expect(L_PAREN); + if p.eat(XMLNAMESPACES_KW) { + p.expect(L_PAREN); + xml_namespace_list(p); + p.expect(R_PAREN); + } + if expr(p).is_none() { + p.error("expected expression"); + } + xmlexists_arg(p); + p.expect(COLUMNS_KW); + xmltable_column_list(p); + p.expect(R_PAREN); + } ROWS_KW if p.nth_at(1, FROM_KW) => { p.bump(ROWS_KW); p.expect(FROM_KW); @@ -2788,7 +2808,79 @@ fn data_source(p: &mut Parser<'_>) { opt_alias(p); } _ if p.at_ts(FROM_ITEM_KEYWORDS_FIRST) => from_item_name(p), - _ => {} + + _ => { + p.error("expected table reference"); + } + } +} + +fn xmltable_column_list(p: &mut Parser<'_>) { + xmltable_column_el(p); + while !p.at(EOF) && p.eat(COMMA) { + xmltable_column_el(p); + } +} + +fn xmltable_column_el(p: &mut Parser<'_>) { + name(p); + if p.eat(FOR_KW) { + p.expect(ORDINALITY_KW); + } else { + type_name(p); + opt_xmltable_column_option_list(p); + } +} + +fn opt_xmltable_column_option_list(p: &mut Parser<'_>) { + if opt_xmltable_column_option_el(p) { + return; + } + while !p.at(EOF) && p.eat(COMMA) { + if !opt_xmltable_column_option_el(p) { + p.error("expected column option"); + } + } +} + +fn opt_xmltable_column_option_el(p: &mut Parser<'_>) -> bool { + match p.current() { + DEFAULT_KW | PATH_KW | IDENT => { + p.bump_any(); + if expr(p).is_none() { + p.error("expected expression"); + } + } + NOT_KW => { + p.bump(NOT_KW); + p.expect(NULL_KW); + } + NULL_KW => { + p.bump(NULL_KW); + } + _ => return false, + } + true +} + +fn xml_namespace_list(p: &mut Parser<'_>) { + xml_namespace_element(p); + while !p.at(EOF) && p.eat(COMMA) { + xml_namespace_element(p); + } +} + +fn xml_namespace_element(p: &mut Parser<'_>) { + if p.eat(DEFAULT_KW) { + if expr(p).is_none() { + p.error("expected expression"); + } + } else { + if expr(p).is_none() { + p.error("expected expression"); + } + p.expect(AS_KW); + col_label(p); } } @@ -2801,7 +2893,7 @@ fn paren_data_source(p: &mut Parser<'_>) -> CompletedMarker { if p.at_ts(SELECT_FIRST) { if select(p, None).is_some() { p.expect(R_PAREN); - return m.complete(p, PAREN_EXPR); + return m.complete(p, PAREN_SELECT); } } @@ -2809,12 +2901,10 @@ fn paren_data_source(p: &mut Parser<'_>) -> CompletedMarker { if opt_from_item(p) { p.expect(R_PAREN); return m.complete(p, PAREN_EXPR); + } else { + p.error("expected table name or SELECT"); } - // Fall back to general expression parsing - if expr(p).is_none() { - p.error("expected an expression"); - } p.expect(R_PAREN); m.complete(p, PAREN_EXPR) } @@ -9774,7 +9864,7 @@ fn explain(p: &mut Parser<'_>) -> CompletedMarker { | CREATE_TABLE_AS | CREATE_MATERIALIZED_VIEW // TODO: we need a validation to check inside this - | PAREN_EXPR => (), + | PAREN_SELECT => (), kind => { p.error(format!( "expected SELECT, INSERT, UPDATE, DELETE, MERGE, or VALUES statement, got {:?}", diff --git a/crates/squawk_parser/tests/snapshots/tests__create_view_extra_parens_ok.snap b/crates/squawk_parser/tests/snapshots/tests__create_view_extra_parens_ok.snap index 141560fa..d13ed00e 100644 --- a/crates/squawk_parser/tests/snapshots/tests__create_view_extra_parens_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__create_view_extra_parens_ok.snap @@ -35,7 +35,7 @@ SOURCE_FILE PAREN_EXPR L_PAREN "(" FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" WHITESPACE " " SELECT diff --git a/crates/squawk_parser/tests/snapshots/tests__delete_ok.snap b/crates/squawk_parser/tests/snapshots/tests__delete_ok.snap index 9b6342a4..5ff69a75 100644 --- a/crates/squawk_parser/tests/snapshots/tests__delete_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__delete_ok.snap @@ -272,7 +272,7 @@ SOURCE_FILE COMMA "," WHITESPACE "\n " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE diff --git a/crates/squawk_parser/tests/snapshots/tests__explain_ok.snap b/crates/squawk_parser/tests/snapshots/tests__explain_ok.snap index 18040bb7..950ef180 100644 --- a/crates/squawk_parser/tests/snapshots/tests__explain_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__explain_ok.snap @@ -572,15 +572,15 @@ SOURCE_FILE WHITESPACE " " ANALYZE_KW "analyze" WHITESPACE " " - PAREN_EXPR + PAREN_SELECT L_PAREN "(" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -604,15 +604,15 @@ SOURCE_FILE WHITESPACE " " ANALYZE_KW "analyze" WHITESPACE " " - PAREN_EXPR + PAREN_SELECT L_PAREN "(" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" VALUES VALUES_KW "values" diff --git a/crates/squawk_parser/tests/snapshots/tests__merge_ok.snap b/crates/squawk_parser/tests/snapshots/tests__merge_ok.snap index d9924057..4558de72 100644 --- a/crates/squawk_parser/tests/snapshots/tests__merge_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__merge_ok.snap @@ -341,7 +341,7 @@ SOURCE_FILE USING_CLAUSE USING_KW "using" WHITESPACE " " - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -406,7 +406,7 @@ SOURCE_FILE USING_CLAUSE USING_KW "using" WHITESPACE " " - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -509,7 +509,7 @@ SOURCE_FILE USING_CLAUSE USING_KW "using" WHITESPACE " " - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE diff --git a/crates/squawk_parser/tests/snapshots/tests__merge_pg17_ok.snap b/crates/squawk_parser/tests/snapshots/tests__merge_pg17_ok.snap index 0e57410f..3a51dc3f 100644 --- a/crates/squawk_parser/tests/snapshots/tests__merge_pg17_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__merge_pg17_ok.snap @@ -1036,7 +1036,7 @@ SOURCE_FILE USING_CLAUSE USING_KW "USING" WHITESPACE " " - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE diff --git a/crates/squawk_parser/tests/snapshots/tests__misc_ok.snap b/crates/squawk_parser/tests/snapshots/tests__misc_ok.snap index dffc8ec6..c92a5e04 100644 --- a/crates/squawk_parser/tests/snapshots/tests__misc_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__misc_ok.snap @@ -5293,7 +5293,7 @@ SOURCE_FILE FROM_KW "FROM" WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" WHITESPACE "\n " SELECT @@ -5363,7 +5363,7 @@ SOURCE_FILE FROM_KW "FROM" WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" WHITESPACE "\n " SELECT diff --git a/crates/squawk_parser/tests/snapshots/tests__precedence_ok.snap b/crates/squawk_parser/tests/snapshots/tests__precedence_ok.snap index 28733235..81c48759 100644 --- a/crates/squawk_parser/tests/snapshots/tests__precedence_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__precedence_ok.snap @@ -1,7 +1,6 @@ --- source: crates/squawk_parser/tests/tests.rs input_file: crates/squawk_parser/tests/data/ok/precedence.sql -snapshot_kind: text --- SOURCE_FILE COMMENT "-- see: https://github.com/postgres/postgres/blob/028b4b21df26fee67b3ce75c6f14fcfd3c7cf2ee/src/backend/parser/gram.y#L12699" @@ -108,7 +107,7 @@ SOURCE_FILE WHITESPACE "\n" COMMENT "-- equal to:" WHITESPACE "\n" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" COMPOUND_SELECT SELECT 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 c0617003..ba5e50ab 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_suite_errors.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_suite_errors.snap @@ -33,4 +33,4 @@ tests/snapshots/tests__regression_update.snap:29 tests/snapshots/tests__regression_vacuum.snap:15 tests/snapshots/tests__regression_window.snap:72 tests/snapshots/tests__regression_with.snap:9 -tests/snapshots/tests__regression_xml.snap:623 +tests/snapshots/tests__regression_xml.snap:393 diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap b/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap index 448853c5..99a098f2 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap @@ -33,21 +33,9 @@ ERROR@8758: expected command, found IDENT ERROR@9037: expected R_PAREN ERROR@9041: expected SEMICOLON ERROR@9041: expected command, found R_PAREN -ERROR@18387: expected COMMA -ERROR@18420: expected COMMA -ERROR@18425: expected COMMA -ERROR@18458: expected COMMA -ERROR@18461: expected COMMA -ERROR@18465: expected COMMA -ERROR@18515: expected R_PAREN -ERROR@18519: expected UPDATE_KW -ERROR@18519: expected SEMICOLON -ERROR@18520: expected command, found ORDINALITY_KW -ERROR@18530: expected command, found COMMA -ERROR@18566: expected command, found IDENT -ERROR@18579: expected command, found TEXT_KW -ERROR@18584: expected command, found PATH_KW -ERROR@18589: expected command, found STRING +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 @@ -78,21 +66,9 @@ 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@19098: expected COMMA -ERROR@19131: expected COMMA -ERROR@19136: expected COMMA -ERROR@19169: expected COMMA -ERROR@19172: expected COMMA -ERROR@19176: expected COMMA -ERROR@19226: expected R_PAREN -ERROR@19230: expected UPDATE_KW -ERROR@19230: expected SEMICOLON -ERROR@19231: expected command, found ORDINALITY_KW -ERROR@19241: expected command, found COMMA -ERROR@19277: expected command, found IDENT -ERROR@19290: expected command, found TEXT_KW -ERROR@19295: expected command, found PATH_KW -ERROR@19300: expected command, found STRING +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 @@ -123,72 +99,33 @@ 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@19866: expected COMMA -ERROR@19874: expected COMMA -ERROR@19879: expected COMMA -ERROR@19887: expected COMMA -ERROR@19890: expected COMMA -ERROR@19948: expected COMMA -ERROR@19956: expected COMMA -ERROR@19961: expected COMMA -ERROR@19969: expected COMMA -ERROR@19972: expected COMMA -ERROR@19982: expected COMMA -ERROR@20000: expected COMMA -ERROR@20088: expected R_PAREN -ERROR@20088: expected R_PAREN -ERROR@20094: expected SEMICOLON -ERROR@20094: expected command, found R_PAREN -ERROR@20095: expected command, found COMMA -ERROR@20119: expected command, found STRING -ERROR@20159: expected command, found PASSING_KW -ERROR@20167: expected command, found STRING -ERROR@20244: expected command, found COLUMNS_KW -ERROR@20252: expected command, found IDENT -ERROR@20254: expected command, found INT_KW -ERROR@20258: expected command, found PATH_KW -ERROR@20263: expected command, found STRING -ERROR@20269: expected command, found R_PAREN -ERROR@20351: expected R_PAREN -ERROR@20351: expected R_PAREN -ERROR@20359: expected SEMICOLON -ERROR@20359: expected command, found R_PAREN -ERROR@20360: expected command, found COMMA -ERROR@20384: expected command, found STRING -ERROR@20424: expected command, found PASSING_KW -ERROR@20432: expected command, found STRING -ERROR@20509: expected command, found COLUMNS_KW -ERROR@20517: expected command, found IDENT -ERROR@20519: expected command, found INT_KW -ERROR@20523: expected command, found PATH_KW -ERROR@20528: expected command, found STRING -ERROR@20534: expected command, found R_PAREN -ERROR@20613: expected COMMA -ERROR@20662: expected COMMA -ERROR@20747: expected COMMA -ERROR@20777: expected COMMA -ERROR@20779: expected COMMA -ERROR@20783: expected COMMA -ERROR@20822: expected COMMA -ERROR@20862: expected COMMA -ERROR@20893: expected COMMA -ERROR@20895: expected COMMA -ERROR@20900: expected COMMA -ERROR@21070: expected COMMA -ERROR@21103: expected COMMA -ERROR@21108: expected COMMA -ERROR@21141: expected COMMA -ERROR@21144: expected COMMA -ERROR@21148: expected COMMA -ERROR@21198: expected R_PAREN -ERROR@21202: expected UPDATE_KW -ERROR@21202: expected SEMICOLON -ERROR@21203: expected command, found ORDINALITY_KW -ERROR@21213: expected command, found COMMA -ERROR@21249: expected command, found IDENT -ERROR@21262: expected command, found TEXT_KW -ERROR@21267: expected command, found PATH_KW -ERROR@21272: expected command, found STRING +ERROR@19874: expected PASSING_KW +ERROR@19901: expected SEMICOLON +ERROR@19902: expected command, found AS_KW +ERROR@19905: expected command, found IDENT +ERROR@19907: expected command, found L_PAREN +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@20009: expected command, found L_PAREN +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 @@ -219,106 +156,36 @@ 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@21771: expected COMMA -ERROR@21779: expected COMMA -ERROR@21784: expected COMMA -ERROR@21792: expected COMMA -ERROR@21807: expected COMMA -ERROR@21825: expected COMMA -ERROR@21938: expected COMMA -ERROR@21946: expected COMMA -ERROR@21951: expected COMMA -ERROR@21959: expected COMMA -ERROR@21962: expected R_PAREN -ERROR@21966: expected UPDATE_KW -ERROR@21966: expected SEMICOLON -ERROR@21967: expected command, found ORDINALITY_KW -ERROR@21977: expected command, found COMMA -ERROR@21979: expected command, found IDENT -ERROR@21994: expected command, found TEXT_KW -ERROR@21998: expected command, found COMMA -ERROR@22000: expected command, found IDENT -ERROR@22012: expected command, found INT_KW -ERROR@22015: expected command, found R_PAREN -ERROR@22124: expected COMMA -ERROR@22132: expected COMMA -ERROR@22137: expected COMMA -ERROR@22145: expected COMMA -ERROR@22148: expected COMMA -ERROR@22152: expected COMMA -ERROR@22179: expected COMMA -ERROR@22197: expected COMMA -ERROR@22310: expected COMMA -ERROR@22318: expected COMMA -ERROR@22323: expected COMMA -ERROR@22331: expected COMMA -ERROR@22334: expected COMMA -ERROR@22338: expected COMMA -ERROR@22458: expected COMMA -ERROR@22466: expected COMMA -ERROR@22471: expected COMMA -ERROR@22479: expected COMMA -ERROR@22482: expected R_PAREN -ERROR@22486: expected UPDATE_KW -ERROR@22486: expected SEMICOLON -ERROR@22487: expected command, found ORDINALITY_KW -ERROR@22497: expected command, found R_PAREN -ERROR@22606: expected COMMA -ERROR@22614: expected COMMA -ERROR@22619: expected COMMA -ERROR@22627: expected COMMA -ERROR@22630: expected COMMA -ERROR@22634: expected COMMA -ERROR@22661: expected COMMA -ERROR@22679: expected COMMA -ERROR@22692: expected COMMA -ERROR@22696: expected COMMA -ERROR@22814: expected COMMA -ERROR@22822: expected COMMA -ERROR@22827: expected COMMA -ERROR@22835: expected COMMA -ERROR@22838: expected COMMA -ERROR@22842: expected COMMA -ERROR@22869: expected COMMA -ERROR@22887: expected COMMA -ERROR@22900: expected COMMA -ERROR@22904: expected COMMA -ERROR@22949: expected COMMA -ERROR@23049: expected COMMA -ERROR@23057: expected COMMA -ERROR@23065: expected COMMA -ERROR@23103: expected COMMA -ERROR@23203: expected COMMA -ERROR@23211: expected COMMA -ERROR@23219: expected COMMA -ERROR@23224: expected COMMA -ERROR@23307: expected COMMA -ERROR@23389: expected COMMA -ERROR@23397: expected COMMA -ERROR@23399: expected COMMA -ERROR@23461: expected COMMA -ERROR@23594: expected COMMA -ERROR@23602: expected COMMA -ERROR@23606: expected COMMA -ERROR@23643: expected COMMA -ERROR@23776: expected COMMA -ERROR@23784: expected COMMA -ERROR@23788: expected COMMA -ERROR@23918: expected COMMA -ERROR@23951: expected COMMA -ERROR@23956: expected COMMA -ERROR@23989: expected COMMA -ERROR@23992: expected COMMA -ERROR@23996: expected COMMA -ERROR@24046: expected R_PAREN -ERROR@24050: expected UPDATE_KW -ERROR@24050: expected SEMICOLON -ERROR@24051: expected command, found ORDINALITY_KW -ERROR@24061: expected command, found COMMA -ERROR@24097: expected command, found IDENT -ERROR@24110: expected command, found TEXT_KW -ERROR@24115: expected command, found PATH_KW -ERROR@24120: expected command, found STRING +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 @@ -349,39 +216,26 @@ 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@24619: expected COMMA -ERROR@24627: expected COMMA -ERROR@24632: expected COMMA -ERROR@24640: expected COMMA -ERROR@24655: expected COMMA -ERROR@24673: expected COMMA -ERROR@24840: expected COMMA -ERROR@24848: expected COMMA -ERROR@24853: expected COMMA -ERROR@24861: expected COMMA -ERROR@24876: expected COMMA -ERROR@24894: expected COMMA -ERROR@25079: expected COMMA -ERROR@25087: expected COMMA -ERROR@25092: expected COMMA -ERROR@25100: expected COMMA -ERROR@25115: expected COMMA -ERROR@25133: expected COMMA -ERROR@26024: expected COMMA -ERROR@26057: expected COMMA -ERROR@26062: expected COMMA -ERROR@26095: expected COMMA -ERROR@26098: expected COMMA -ERROR@26102: expected COMMA -ERROR@26152: expected R_PAREN -ERROR@26156: expected UPDATE_KW -ERROR@26156: expected SEMICOLON -ERROR@26157: expected command, found ORDINALITY_KW -ERROR@26167: expected command, found COMMA -ERROR@26203: expected command, found IDENT -ERROR@26216: expected command, found TEXT_KW -ERROR@26221: expected command, found PATH_KW -ERROR@26226: expected command, found STRING +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 @@ -412,21 +266,9 @@ 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@26699: expected COMMA -ERROR@26732: expected COMMA -ERROR@26737: expected COMMA -ERROR@26770: expected COMMA -ERROR@26773: expected COMMA -ERROR@26777: expected COMMA -ERROR@26827: expected R_PAREN -ERROR@26831: expected UPDATE_KW -ERROR@26831: expected SEMICOLON -ERROR@26832: expected command, found ORDINALITY_KW -ERROR@26842: expected command, found COMMA -ERROR@26878: expected command, found IDENT -ERROR@26891: expected command, found TEXT_KW -ERROR@26896: expected command, found PATH_KW -ERROR@26901: expected command, found STRING +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 @@ -461,21 +303,9 @@ 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@27425: expected COMMA -ERROR@27458: expected COMMA -ERROR@27463: expected COMMA -ERROR@27496: expected COMMA -ERROR@27499: expected COMMA -ERROR@27503: expected COMMA -ERROR@27553: expected R_PAREN -ERROR@27557: expected UPDATE_KW -ERROR@27557: expected SEMICOLON -ERROR@27558: expected command, found ORDINALITY_KW -ERROR@27568: expected command, found COMMA -ERROR@27604: expected command, found IDENT -ERROR@27617: expected command, found TEXT_KW -ERROR@27622: expected command, found PATH_KW -ERROR@27627: expected command, found STRING +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 @@ -510,21 +340,9 @@ 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@28149: expected COMMA -ERROR@28182: expected COMMA -ERROR@28187: expected COMMA -ERROR@28220: expected COMMA -ERROR@28223: expected COMMA -ERROR@28227: expected COMMA -ERROR@28277: expected R_PAREN -ERROR@28281: expected UPDATE_KW -ERROR@28281: expected SEMICOLON -ERROR@28282: expected command, found ORDINALITY_KW -ERROR@28292: expected command, found COMMA -ERROR@28328: expected command, found IDENT -ERROR@28341: expected command, found TEXT_KW -ERROR@28346: expected command, found PATH_KW -ERROR@28351: expected command, found STRING +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 @@ -557,71 +375,23 @@ 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@29419: expected COMMA -ERROR@29427: expected COMMA -ERROR@29432: expected COMMA -ERROR@29473: expected COMMA -ERROR@29481: expected COMMA -ERROR@29537: expected COMMA -ERROR@29591: expected COMMA -ERROR@29648: expected COMMA -ERROR@29706: expected COMMA -ERROR@29765: expected COMMA -ERROR@30527: expected COMMA -ERROR@30535: expected COMMA -ERROR@30539: expected COMMA -ERROR@30580: expected COMMA -ERROR@30588: expected COMMA -ERROR@30644: expected COMMA -ERROR@30698: expected COMMA -ERROR@30755: expected COMMA -ERROR@30813: expected COMMA -ERROR@30872: expected COMMA -ERROR@31275: expected COMMA -ERROR@31283: expected COMMA -ERROR@31285: expected COMMA -ERROR@31293: expected COMMA -ERROR@31295: expected COMMA -ERROR@31299: expected COMMA -ERROR@31415: expected COMMA -ERROR@31423: expected COMMA -ERROR@31425: expected COMMA -ERROR@31433: expected COMMA -ERROR@31435: expected COMMA -ERROR@31439: expected COMMA -ERROR@31533: expected COMMA -ERROR@31541: expected COMMA -ERROR@31543: expected COMMA -ERROR@31551: expected COMMA -ERROR@31553: expected COMMA -ERROR@31557: expected COMMA -ERROR@31566: expected COMMA -ERROR@31574: expected COMMA -ERROR@31667: expected COMMA -ERROR@31686: expected COMMA -ERROR@31694: expected COMMA -ERROR@31696: expected COMMA -ERROR@31700: expected COMMA -ERROR@31712: expected COMMA -ERROR@31717: expected COMMA -ERROR@31729: expected COMMA -ERROR@31734: expected COMMA -ERROR@31749: expected COMMA -ERROR@31757: expected COMMA -ERROR@31775: expected COMMA -ERROR@31783: expected COMMA -ERROR@31836: expected COMMA -ERROR@31915: expected COMMA -ERROR@31923: expected COMMA -ERROR@31925: expected COMMA -ERROR@31929: expected COMMA -ERROR@31945: expected COMMA -ERROR@31949: expected COMMA -ERROR@31988: expected COMMA -ERROR@31996: expected COMMA -ERROR@32015: expected COMMA -ERROR@32023: expected COMMA -ERROR@32025: expected COMMA -ERROR@32037: expected COMMA -ERROR@32056: expected COMMA -ERROR@32060: expected COMMA +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@31580: expected command, found L_PAREN +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_parser/tests/snapshots/tests__select_ok.snap b/crates/squawk_parser/tests/snapshots/tests__select_ok.snap index 845f1766..6265d6f9 100644 --- a/crates/squawk_parser/tests/snapshots/tests__select_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__select_ok.snap @@ -5,7 +5,7 @@ input_file: crates/squawk_parser/tests/data/ok/select.sql SOURCE_FILE COMMENT "-- parens_and_unions" WHITESPACE "\n" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -18,9 +18,9 @@ SOURCE_FILE R_PAREN ")" SEMICOLON ";" WHITESPACE "\n\n" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -100,7 +100,7 @@ SOURCE_FILE SEMICOLON ";" WHITESPACE "\n\n" COMPOUND_SELECT - PAREN_EXPR + PAREN_SELECT L_PAREN "(" COMPOUND_SELECT SELECT @@ -152,7 +152,7 @@ SOURCE_FILE FROM_KW "from" WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -236,7 +236,7 @@ SOURCE_FILE FROM_KW "from" WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -326,7 +326,7 @@ SOURCE_FILE FROM_KW "from" WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -1651,7 +1651,7 @@ SOURCE_FILE FROM_KW "from" WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -1678,7 +1678,7 @@ SOURCE_FILE FROM_ITEM LATERAL_KW "lateral" WHITESPACE " " - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -2615,7 +2615,7 @@ SOURCE_FILE FROM_ITEM LATERAL_KW "lateral" WHITESPACE " " - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -2662,7 +2662,7 @@ SOURCE_FILE FROM_KW "from" WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -2709,7 +2709,7 @@ SOURCE_FILE FROM_KW "from" WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE @@ -2738,7 +2738,7 @@ SOURCE_FILE FROM_KW "from" WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" SELECT SELECT_CLAUSE diff --git a/crates/squawk_parser/tests/snapshots/tests__values_ok.snap b/crates/squawk_parser/tests/snapshots/tests__values_ok.snap index 5d6f1140..eaa16aba 100644 --- a/crates/squawk_parser/tests/snapshots/tests__values_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__values_ok.snap @@ -197,7 +197,7 @@ SOURCE_FILE COMMA "," WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" VALUES VALUES_KW "VALUES" @@ -315,7 +315,7 @@ SOURCE_FILE FROM_KW "FROM" WHITESPACE " " FROM_ITEM - PAREN_EXPR + PAREN_SELECT L_PAREN "(" VALUES VALUES_KW "VALUES" diff --git a/crates/squawk_syntax/src/ast/generated/nodes.rs b/crates/squawk_syntax/src/ast/generated/nodes.rs index 12231f26..6c3f3a9f 100644 --- a/crates/squawk_syntax/src/ast/generated/nodes.rs +++ b/crates/squawk_syntax/src/ast/generated/nodes.rs @@ -6221,6 +6221,25 @@ impl ParenExpr { } } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct ParenSelect { + pub(crate) syntax: SyntaxNode, +} +impl ParenSelect { + #[inline] + pub fn select(&self) -> Option