From 220b2a4995fd6e10a255d19e138217eb16610c49 Mon Sep 17 00:00:00 2001 From: peefy Date: Tue, 23 May 2023 21:40:19 +0800 Subject: [PATCH] refactor: parser primary expr loc, ast pretty printer and add more tests. --- kclvm/ast_pretty/src/node.rs | 32 +++++++++++------ .../ast_pretty/src/test_data/codelayout.input | 9 +++-- .../src/test_data/codelayout.output | 6 ++++ kclvm/ast_pretty/src/test_data/lambda.input | 9 +++++ kclvm/ast_pretty/src/test_data/lambda.output | 7 ++++ kclvm/parser/src/parser/expr.rs | 30 ++++++++-------- kclvm/parser/src/parser/module.rs | 23 ++++++++----- kclvm/parser/src/parser/stmt.rs | 17 +--------- kclvm/parser/src/parser/tests.rs | 34 +++++++++---------- ...ror_recovery__assign_stmt_recovery_10.snap | 4 +-- ...ts__error_recovery__schema_recovery_3.snap | 4 +-- ...s__error_recovery__select_recovery_10.snap | 4 +-- ...s__error_recovery__select_recovery_11.snap | 6 ++-- ...ts__error_recovery__select_recovery_3.snap | 4 +-- ...ts__error_recovery__select_recovery_4.snap | 4 +-- ...ts__error_recovery__select_recovery_5.snap | 8 ++--- ...ts__error_recovery__select_recovery_6.snap | 4 +-- ...ts__error_recovery__select_recovery_7.snap | 6 ++-- ...ts__error_recovery__select_recovery_8.snap | 8 ++--- ..._error_recovery__subscript_recovery_0.snap | 4 +-- ..._error_recovery__subscript_recovery_1.snap | 3 +- ...error_recovery__subscript_recovery_10.snap | 6 ++-- ...error_recovery__subscript_recovery_12.snap | 6 ++-- ..._error_recovery__subscript_recovery_2.snap | 4 +-- ..._error_recovery__subscript_recovery_3.snap | 3 +- ..._error_recovery__subscript_recovery_4.snap | 4 +-- ..._error_recovery__subscript_recovery_5.snap | 4 +-- ..._error_recovery__subscript_recovery_6.snap | 4 +-- ..._error_recovery__subscript_recovery_7.snap | 4 +-- ..._error_recovery__subscript_recovery_8.snap | 6 ++-- ..._error_recovery__subscript_recovery_9.snap | 4 +-- 31 files changed, 150 insertions(+), 121 deletions(-) diff --git a/kclvm/ast_pretty/src/node.rs b/kclvm/ast_pretty/src/node.rs index 6b7ba65ac..efecaab25 100644 --- a/kclvm/ast_pretty/src/node.rs +++ b/kclvm/ast_pretty/src/node.rs @@ -39,6 +39,10 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { for comment in &module.comments { self.comments.push_back(comment.clone()); } + if !module.doc.is_empty() { + self.write(&module.doc); + self.write_newline(); + } self.stmts(&module.body); } @@ -443,11 +447,12 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { .map(|e| e.line) .collect::>(); // There are comments in the configuration block. - let has_comment = list_expr - .elts - .iter() - .map(|e| self.has_comments_on_node(e)) - .all(|r| r); + let has_comment = !list_expr.elts.is_empty() + && list_expr + .elts + .iter() + .map(|e| self.has_comments_on_node(e)) + .all(|r| r); // When there are comments in the configuration block, print them as multiline configurations. let mut in_one_line = line_set.len() <= 1 && !has_comment; if let Some(elt) = list_expr.elts.first() { @@ -605,11 +610,12 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { fn walk_config_expr(&mut self, config_expr: &'ctx ast::ConfigExpr) -> Self::Result { let line_set: HashSet = config_expr.items.iter().map(|item| item.line).collect(); // There are comments in the configuration block. - let has_comment = config_expr - .items - .iter() - .map(|item| self.has_comments_on_node(item)) - .all(|r| r); + let has_comment = !config_expr.items.is_empty() + && config_expr + .items + .iter() + .map(|item| self.has_comments_on_node(item)) + .all(|r| r); // When there are comments in the configuration block, print them as multiline configurations. let mut in_one_line = line_set.len() <= 1 && !has_comment; // When there are complex configuration blocks in the configuration block, print them as multiline configurations. @@ -729,10 +735,14 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { } fn walk_number_lit(&mut self, number_lit: &'ctx ast::NumberLit) -> Self::Result { - match number_lit.value { + match &number_lit.value { ast::NumberLitValue::Int(int_val) => self.write(&int_val.to_string()), ast::NumberLitValue::Float(float_val) => self.write(&float_val.to_string()), } + // Number suffix e.g., 1Gi + if let Some(binary_suffix) = &number_lit.binary_suffix { + self.write(&binary_suffix.value()) + } } fn walk_string_lit(&mut self, string_lit: &'ctx ast::StringLit) -> Self::Result { diff --git a/kclvm/ast_pretty/src/test_data/codelayout.input b/kclvm/ast_pretty/src/test_data/codelayout.input index b8eeb768d..46121bd5e 100644 --- a/kclvm/ast_pretty/src/test_data/codelayout.input +++ b/kclvm/ast_pretty/src/test_data/codelayout.input @@ -1,4 +1,6 @@ - +""" +Module documents +""" import math as alias_math @@ -73,4 +75,7 @@ aa = 1 assert aa == 1,"message" assert aa == 1 if aa,"message" aaaa = (1 + 2 / 2) if _a == 2 + + 134.3 else ("a"*3) -bbbb = "{}". format(a) \ No newline at end of file +bbbb = "{}". format(a) +empty_list = [] +empty_config = {} +number_suffix = 1Gi \ No newline at end of file diff --git a/kclvm/ast_pretty/src/test_data/codelayout.output b/kclvm/ast_pretty/src/test_data/codelayout.output index 28fa41ccc..d8253bd56 100644 --- a/kclvm/ast_pretty/src/test_data/codelayout.output +++ b/kclvm/ast_pretty/src/test_data/codelayout.output @@ -1,3 +1,6 @@ +""" +Module documents +""" import math as alias_math schema Person(Base): name: str @@ -77,3 +80,6 @@ assert aa == 1, "message" assert aa == 1 if aa, "message" aaaa = (1 + 2 / 2) if _a == 2 + +134.3 else ("a" * 3) bbbb = "{}".format(a) +empty_list = [] +empty_config = {} +number_suffix = 1Gi diff --git a/kclvm/ast_pretty/src/test_data/lambda.input b/kclvm/ast_pretty/src/test_data/lambda.input index 5402976ca..082f1f0f6 100644 --- a/kclvm/ast_pretty/src/test_data/lambda.input +++ b/kclvm/ast_pretty/src/test_data/lambda.input @@ -1,5 +1,7 @@ sumFunc1 = lambda x, y { + # Inline comments 1 z = x + y + # Inline comments 2 z + x } sumFunc2 = lambda x, y = 1 { @@ -18,3 +20,10 @@ x0 = sumFunc1(1, 2) x1 = sumFunc1(2, 3) x2 = sumFunc1(3, 4) x3 = sumFunc1(4, 5) + +x = lambda { + # Inline comments + 1 + +}() + diff --git a/kclvm/ast_pretty/src/test_data/lambda.output b/kclvm/ast_pretty/src/test_data/lambda.output index db23acee4..fde503ab9 100644 --- a/kclvm/ast_pretty/src/test_data/lambda.output +++ b/kclvm/ast_pretty/src/test_data/lambda.output @@ -1,5 +1,7 @@ sumFunc1 = lambda x, y { + # Inline comments 1 z = x + y + # Inline comments 2 z + x } @@ -19,3 +21,8 @@ x0 = sumFunc1(1, 2) x1 = sumFunc1(2, 3) x2 = sumFunc1(3, 4) x3 = sumFunc1(4, 5) +x = lambda { + # Inline comments + 1 + +}() diff --git a/kclvm/parser/src/parser/expr.rs b/kclvm/parser/src/parser/expr.rs index 728773521..d57493e39 100644 --- a/kclvm/parser/src/parser/expr.rs +++ b/kclvm/parser/src/parser/expr.rs @@ -236,13 +236,14 @@ impl<'a> Parser<'a> { /// primary_expr: operand | primary_expr select_suffix | primary_expr call_suffix | primary_expr slice_suffix /// Note: we need to look ahead 2 tokens to match select_suffix and slice_suffix, which actually breaks LL1 rule. fn parse_primary_expr(&mut self) -> NodeRef { + let lo = self.token; let mut operand = self.parse_operand_expr(); loop { match self.token.kind { TokenKind::Dot => { // select_suffix - operand = self.parse_selector_expr(operand) + operand = self.parse_selector_expr(operand, lo) } TokenKind::Question => { match self.cursor.peek() { @@ -250,11 +251,11 @@ impl<'a> Parser<'a> { match token.kind { TokenKind::Dot => { // select_suffix - operand = self.parse_selector_expr(operand) + operand = self.parse_selector_expr(operand, lo) } TokenKind::OpenDelim(DelimToken::Bracket) => { // slice_suffix - operand = self.parse_subscript_expr(operand) + operand = self.parse_subscript_expr(operand, lo) } _ => break operand, } @@ -266,11 +267,11 @@ impl<'a> Parser<'a> { match dt { DelimToken::Paren => { // call_suffix - operand = self.parse_call_expr(operand) + operand = self.parse_call_expr(operand, lo) } DelimToken::Bracket => { // slice_suffix - operand = self.parse_subscript_expr(operand) + operand = self.parse_subscript_expr(operand, lo) } _ => break operand, } @@ -301,8 +302,7 @@ impl<'a> Parser<'a> { /// Syntax: /// select_suffix: [QUESTION] DOT NAME - fn parse_selector_expr(&mut self, value: NodeRef) -> NodeRef { - let token = self.token; + fn parse_selector_expr(&mut self, value: NodeRef, lo: token::Token) -> NodeRef { let has_question = match self.token.kind { TokenKind::Question => { self.bump(); @@ -320,18 +320,17 @@ impl<'a> Parser<'a> { has_question, ctx: ExprContext::Load, }), - self.sess.struct_token_loc(token, self.prev_token), + self.sess.struct_token_loc(lo, self.prev_token), )) } /// Syntax: /// call_suffix: LEFT_PARENTHESES [arguments [COMMA]] RIGHT_PARENTHESES - fn parse_call_expr(&mut self, func: NodeRef) -> NodeRef { - let token = self.token; + fn parse_call_expr(&mut self, func: NodeRef, lo: token::Token) -> NodeRef { let call_expr = self.parse_call(func); Box::new(Node::node( Expr::Call(call_expr), - self.sess.struct_token_loc(token, self.prev_token), + self.sess.struct_token_loc(lo, self.prev_token), )) } @@ -375,8 +374,7 @@ impl<'a> Parser<'a> { /// Syntax: /// slice_suffix: [QUESTION] LEFT_BRACKETS (expr | [expr] COLON [expr] [COLON [expr]]) RIGHT_BRACKETS - fn parse_subscript_expr(&mut self, value: NodeRef) -> NodeRef { - let token = self.token; + fn parse_subscript_expr(&mut self, value: NodeRef, lo: token::Token) -> NodeRef { let mut has_question = false; // [QUESTION] if self.token.kind == TokenKind::Question { @@ -464,7 +462,7 @@ impl<'a> Parser<'a> { ctx: ExprContext::Load, has_question, }), - self.sess.struct_token_loc(token, self.prev_token), + self.sess.struct_token_loc(lo, self.prev_token), )) } else { if exprs[0].is_none() { @@ -488,7 +486,7 @@ impl<'a> Parser<'a> { ctx: ExprContext::Load, has_question, }), - self.sess.struct_token_loc(token, self.prev_token), + self.sess.struct_token_loc(lo, self.prev_token), )) } } @@ -2043,7 +2041,7 @@ impl<'a> Parser<'a> { TokenKind::OpenDelim(DelimToken::Paren) => { self.bump(); - self.parse_call_expr(func) + self.parse_call_expr(func, token) } _ => Box::new(Node::node( Expr::Call(CallExpr { diff --git a/kclvm/parser/src/parser/module.rs b/kclvm/parser/src/parser/module.rs index 870d98116..c8c978aae 100644 --- a/kclvm/parser/src/parser/module.rs +++ b/kclvm/parser/src/parser/module.rs @@ -19,17 +19,24 @@ impl<'a> Parser<'a> { } } - fn parse_doc(&mut self) -> String { - if let TokenKind::Literal(lit) = self.token.kind { - if let LitKind::Str { is_long_string, .. } = lit.kind { - if is_long_string { - let doc = format!("{:?}", self.token); - self.bump(); - return doc; + pub(crate) fn parse_doc(&mut self) -> String { + // doc string + match self.token.kind { + TokenKind::Literal(lit) => { + if let LitKind::Str { .. } = lit.kind { + let doc_expr = self.parse_str_expr(lit); + self.skip_newlines(); + match &doc_expr.node { + Expr::StringLit(str) => str.raw_value.clone(), + Expr::JoinedString(str) => str.raw_value.clone(), + _ => "".to_string(), + } + } else { + "".to_string() } } + _ => "".to_string(), } - "".to_string() } fn parse_body(&mut self) -> Vec> { diff --git a/kclvm/parser/src/parser/stmt.rs b/kclvm/parser/src/parser/stmt.rs index 74f81d104..2c2b56fd3 100644 --- a/kclvm/parser/src/parser/stmt.rs +++ b/kclvm/parser/src/parser/stmt.rs @@ -856,22 +856,7 @@ impl<'a> Parser<'a> { self.bump_token(TokenKind::Indent); // doc string - let body_doc = match self.token.kind { - TokenKind::Literal(lit) => { - if let LitKind::Str { .. } = lit.kind { - let doc_expr = self.parse_str_expr(lit); - self.skip_newlines(); - match &doc_expr.node { - Expr::StringLit(str) => str.raw_value.clone(), - Expr::JoinedString(str) => str.raw_value.clone(), - _ => "".to_string(), - } - } else { - "".to_string() - } - } - _ => "".to_string(), - }; + let body_doc = self.parse_doc(); // mixin let body_mixins = if self.token.is_keyword(kw::Mixin) { diff --git a/kclvm/parser/src/parser/tests.rs b/kclvm/parser/src/parser/tests.rs index 53e1c4c59..23d71d9aa 100644 --- a/kclvm/parser/src/parser/tests.rs +++ b/kclvm/parser/src/parser/tests.rs @@ -355,7 +355,7 @@ fn primary_expr_1() { check_parsing_expr( r####"'{}'.format(1)"####, expect![[r#" - Node { node: Call(CallExpr { func: Node { node: Selector(SelectorExpr { value: Node { node: StringLit(StringLit { is_long_string: false, raw_value: "'{}'", value: "{}" }), filename: "", line: 1, column: 0, end_line: 1, end_column: 4 }, attr: Node { node: Identifier { names: ["format"], pkgpath: "", ctx: Load }, filename: "", line: 1, column: 5, end_line: 1, end_column: 11 }, ctx: Load, has_question: false }), filename: "", line: 1, column: 4, end_line: 1, end_column: 11 }, args: [Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 12, end_line: 1, end_column: 13 }], keywords: [] }), filename: "", line: 1, column: 11, end_line: 1, end_column: 14 } + Node { node: Call(CallExpr { func: Node { node: Selector(SelectorExpr { value: Node { node: StringLit(StringLit { is_long_string: false, raw_value: "'{}'", value: "{}" }), filename: "", line: 1, column: 0, end_line: 1, end_column: 4 }, attr: Node { node: Identifier { names: ["format"], pkgpath: "", ctx: Load }, filename: "", line: 1, column: 5, end_line: 1, end_column: 11 }, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 11 }, args: [Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 12, end_line: 1, end_column: 13 }], keywords: [] }), filename: "", line: 1, column: 0, end_line: 1, end_column: 14 } "#]], ); } @@ -365,7 +365,7 @@ fn primary_expr_2() { check_parsing_expr( r####"str(1).isdigit()"####, expect![[r#" - Node { node: Call(CallExpr { func: Node { node: Selector(SelectorExpr { value: Node { node: Call(CallExpr { func: Node { node: Identifier(Identifier { names: ["str"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 3 }, args: [Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 4, end_line: 1, end_column: 5 }], keywords: [] }), filename: "", line: 1, column: 0, end_line: 1, end_column: 6 }, attr: Node { node: Identifier { names: ["isdigit"], pkgpath: "", ctx: Load }, filename: "", line: 1, column: 7, end_line: 1, end_column: 14 }, ctx: Load, has_question: false }), filename: "", line: 1, column: 6, end_line: 1, end_column: 14 }, args: [], keywords: [] }), filename: "", line: 1, column: 14, end_line: 1, end_column: 16 } + Node { node: Call(CallExpr { func: Node { node: Selector(SelectorExpr { value: Node { node: Call(CallExpr { func: Node { node: Identifier(Identifier { names: ["str"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 3 }, args: [Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 4, end_line: 1, end_column: 5 }], keywords: [] }), filename: "", line: 1, column: 0, end_line: 1, end_column: 6 }, attr: Node { node: Identifier { names: ["isdigit"], pkgpath: "", ctx: Load }, filename: "", line: 1, column: 7, end_line: 1, end_column: 14 }, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 14 }, args: [], keywords: [] }), filename: "", line: 1, column: 0, end_line: 1, end_column: 16 } "#]], ); } @@ -432,7 +432,7 @@ fn subscript_expr_0() { check_parsing_expr( r####"a[0]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(0) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), lower: None, upper: None, step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 4 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(0) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), lower: None, upper: None, step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 4 } "#]], ); } @@ -442,7 +442,7 @@ fn subscript_expr_1() { check_parsing_expr( r####"b["k"]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["b"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: Some(Node { node: StringLit(StringLit { is_long_string: false, raw_value: "\"k\"", value: "k" }), filename: "", line: 1, column: 2, end_line: 1, end_column: 5 }), lower: None, upper: None, step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 6 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["b"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: Some(Node { node: StringLit(StringLit { is_long_string: false, raw_value: "\"k\"", value: "k" }), filename: "", line: 1, column: 2, end_line: 1, end_column: 5 }), lower: None, upper: None, step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 6 } "#]], ); } @@ -452,7 +452,7 @@ fn subscript_expr_2() { check_parsing_expr( r####"c?[1]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["c"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 3, end_line: 1, end_column: 4 }), lower: None, upper: None, step: None, ctx: Load, has_question: true }), filename: "", line: 1, column: 1, end_line: 1, end_column: 5 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["c"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 3, end_line: 1, end_column: 4 }), lower: None, upper: None, step: None, ctx: Load, has_question: true }), filename: "", line: 1, column: 0, end_line: 1, end_column: 5 } "#]], ); } @@ -462,7 +462,7 @@ fn subscript_expr_3() { check_parsing_expr( r####"a[1:]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: None, step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 5 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: None, step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 5 } "#]], ); } @@ -472,7 +472,7 @@ fn subscript_expr_4() { check_parsing_expr( r####"a[:-1]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: None, upper: Some(Node { node: Unary(UnaryExpr { op: USub, operand: Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 4, end_line: 1, end_column: 5 } }), filename: "", line: 1, column: 3, end_line: 1, end_column: 5 }), step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 6 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: None, upper: Some(Node { node: Unary(UnaryExpr { op: USub, operand: Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 4, end_line: 1, end_column: 5 } }), filename: "", line: 1, column: 3, end_line: 1, end_column: 5 }), step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 6 } "#]], ); } @@ -482,7 +482,7 @@ fn subscript_expr_5() { check_parsing_expr( r####"a[1:len]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: Some(Node { node: Identifier(Identifier { names: ["len"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 4, end_line: 1, end_column: 7 }), step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 8 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: Some(Node { node: Identifier(Identifier { names: ["len"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 4, end_line: 1, end_column: 7 }), step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 8 } "#]], ); } @@ -492,7 +492,7 @@ fn subscript_expr_6() { check_parsing_expr( r####"a[0:-1]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(0) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: Some(Node { node: Unary(UnaryExpr { op: USub, operand: Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 5, end_line: 1, end_column: 6 } }), filename: "", line: 1, column: 4, end_line: 1, end_column: 6 }), step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 7 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(0) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: Some(Node { node: Unary(UnaryExpr { op: USub, operand: Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 5, end_line: 1, end_column: 6 } }), filename: "", line: 1, column: 4, end_line: 1, end_column: 6 }), step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 7 } "#]], ); } @@ -502,7 +502,7 @@ fn subscript_expr_7() { check_parsing_expr( r####"a[::]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: None, upper: None, step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 5 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: None, upper: None, step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 5 } "#]], ); } @@ -512,7 +512,7 @@ fn subscript_expr_8() { check_parsing_expr( r####"a[1::]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: None, step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 6 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: None, step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 6 } "#]], ); } @@ -522,7 +522,7 @@ fn subscript_expr_9() { check_parsing_expr( r####"a[:0:]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: None, upper: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(0) }), filename: "", line: 1, column: 3, end_line: 1, end_column: 4 }), step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 6 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: None, upper: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(0) }), filename: "", line: 1, column: 3, end_line: 1, end_column: 4 }), step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 6 } "#]], ); } @@ -532,7 +532,7 @@ fn subscript_expr_10() { check_parsing_expr( r####"a[::-1]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: None, upper: None, step: Some(Node { node: Unary(UnaryExpr { op: USub, operand: Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 5, end_line: 1, end_column: 6 } }), filename: "", line: 1, column: 4, end_line: 1, end_column: 6 }), ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 7 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: None, upper: None, step: Some(Node { node: Unary(UnaryExpr { op: USub, operand: Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 5, end_line: 1, end_column: 6 } }), filename: "", line: 1, column: 4, end_line: 1, end_column: 6 }), ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 7 } "#]], ); } @@ -542,7 +542,7 @@ fn subscript_expr_11() { check_parsing_expr( r####"a[1::2]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: None, step: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(2) }), filename: "", line: 1, column: 5, end_line: 1, end_column: 6 }), ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 7 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: None, step: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(2) }), filename: "", line: 1, column: 5, end_line: 1, end_column: 6 }), ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 7 } "#]], ); } @@ -552,7 +552,7 @@ fn subscript_expr_12() { check_parsing_expr( r####"a[:2:1]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: None, upper: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(2) }), filename: "", line: 1, column: 3, end_line: 1, end_column: 4 }), step: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 5, end_line: 1, end_column: 6 }), ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 7 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: None, upper: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(2) }), filename: "", line: 1, column: 3, end_line: 1, end_column: 4 }), step: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 5, end_line: 1, end_column: 6 }), ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 7 } "#]], ); } @@ -562,7 +562,7 @@ fn subscript_expr_13() { check_parsing_expr( r####"a[1:2:]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(2) }), filename: "", line: 1, column: 4, end_line: 1, end_column: 5 }), step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 7 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(2) }), filename: "", line: 1, column: 4, end_line: 1, end_column: 5 }), step: None, ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 7 } "#]], ); } @@ -572,7 +572,7 @@ fn subscript_expr_14() { check_parsing_expr( r####"a[1:3:1]"####, expect![[r#" - Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(3) }), filename: "", line: 1, column: 4, end_line: 1, end_column: 5 }), step: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 6, end_line: 1, end_column: 7 }), ctx: Load, has_question: false }), filename: "", line: 1, column: 1, end_line: 1, end_column: 8 } + Node { node: Subscript(Subscript { value: Node { node: Identifier(Identifier { names: ["a"], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 1 }, index: None, lower: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 2, end_line: 1, end_column: 3 }), upper: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(3) }), filename: "", line: 1, column: 4, end_line: 1, end_column: 5 }), step: Some(Node { node: NumberLit(NumberLit { binary_suffix: None, value: Int(1) }), filename: "", line: 1, column: 6, end_line: 1, end_column: 7 }), ctx: Load, has_question: false }), filename: "", line: 1, column: 0, end_line: 1, end_column: 8 } "#]], ); } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_10.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_10.snap index 451b2dd74..ed5445a68 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_10.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_10.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 155 +assertion_line: 171 expression: "crate::tests::parsing_module_string(r#\"a[0] -= 1\"#)" --- Module { @@ -20,7 +20,7 @@ Module { }, filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 4, }, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_recovery_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_recovery_3.snap index e17b40152..0193a494b 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_recovery_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_recovery_3.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 122 +assertion_line: 148 expression: "crate::tests::parsing_expr_string(r#\"s?.a {a=1}\"#)" --- Node { @@ -42,7 +42,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 4, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_10.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_10.snap index 7edd25007..cd8646e56 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_10.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_10.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 107 +assertion_line: 132 expression: "crate::tests::parsing_expr_string(r#\"a?.b?\"#)" --- Node { @@ -42,7 +42,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 4, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_11.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_11.snap index e615796c4..ab5eb759e 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_11.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_11.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 108 +assertion_line: 133 expression: "crate::tests::parsing_expr_string(r#\"a?.b?.c?\"#)" --- Node { @@ -45,7 +45,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 4, }, @@ -69,7 +69,7 @@ Node { ), filename: "", line: 1, - column: 4, + column: 0, end_line: 1, end_column: 7, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_3.snap index 6761e8691..950ffee84 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_3.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 100 +assertion_line: 125 expression: "crate::tests::parsing_expr_string(r#\"''.\"#)" --- Node { @@ -40,7 +40,7 @@ Node { ), filename: "", line: 1, - column: 2, + column: 0, end_line: 1, end_column: 3, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_4.snap index 8598d2274..2dba80df1 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_4.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 101 +assertion_line: 126 expression: "crate::tests::parsing_expr_string(r#\"''.lower\"#)" --- Node { @@ -40,7 +40,7 @@ Node { ), filename: "", line: 1, - column: 2, + column: 0, end_line: 1, end_column: 8, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_5.snap index 1e936736b..66985055c 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_5.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 102 +assertion_line: 127 expression: "crate::tests::parsing_expr_string(r#\"''.lower().\"#)" --- Node { @@ -46,7 +46,7 @@ Node { ), filename: "", line: 1, - column: 2, + column: 0, end_line: 1, end_column: 8, }, @@ -56,7 +56,7 @@ Node { ), filename: "", line: 1, - column: 8, + column: 0, end_line: 1, end_column: 10, }, @@ -80,7 +80,7 @@ Node { ), filename: "", line: 1, - column: 10, + column: 0, end_line: 1, end_column: 11, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_6.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_6.snap index 82867260a..92f80ac92 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_6.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_6.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 103 +assertion_line: 128 expression: "crate::tests::parsing_expr_string(r#\"a?.\"#)" --- Node { @@ -42,7 +42,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 3, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_7.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_7.snap index 3cf2e9bfc..8d2f9cf8b 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_7.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_7.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 104 +assertion_line: 129 expression: "crate::tests::parsing_expr_string(r#\"a?.b?.\"#)" --- Node { @@ -45,7 +45,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 4, }, @@ -69,7 +69,7 @@ Node { ), filename: "", line: 1, - column: 4, + column: 0, end_line: 1, end_column: 6, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_8.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_8.snap index 9ace06893..0b72f3c28 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_8.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__select_recovery_8.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 105 +assertion_line: 130 expression: "crate::tests::parsing_expr_string(r#\"a?.b?.c?.\"#)" --- Node { @@ -48,7 +48,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 4, }, @@ -72,7 +72,7 @@ Node { ), filename: "", line: 1, - column: 4, + column: 0, end_line: 1, end_column: 7, }, @@ -96,7 +96,7 @@ Node { ), filename: "", line: 1, - column: 7, + column: 0, end_line: 1, end_column: 9, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_0.snap index a6dd73078..d01279057 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_0.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 84 +assertion_line: 109 expression: "crate::tests::parsing_expr_string(r#\"a[b 1]\"#)" --- Node { @@ -48,7 +48,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 6, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_1.snap index a5e94d9c5..e70e97e1f 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_1.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 110 expression: "crate::tests::parsing_expr_string(r#\"a[1,b]\"#)" --- Node { @@ -42,7 +43,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 3, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_10.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_10.snap index de99933e9..387493556 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_10.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_10.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 94 +assertion_line: 119 expression: "crate::tests::parsing_expr_string(r#\"[0]?.[0]\"#)" --- Node { @@ -58,7 +58,7 @@ Node { ), filename: "", line: 1, - column: 3, + column: 0, end_line: 1, end_column: 5, }, @@ -88,7 +88,7 @@ Node { ), filename: "", line: 1, - column: 5, + column: 0, end_line: 1, end_column: 8, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_12.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_12.snap index bcdcfd8d5..c668bfa9f 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_12.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_12.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 96 +assertion_line: 121 expression: "crate::tests::parsing_expr_string(r#\"[0].?[0]\"#)" --- Node { @@ -58,7 +58,7 @@ Node { ), filename: "", line: 1, - column: 3, + column: 0, end_line: 1, end_column: 4, }, @@ -88,7 +88,7 @@ Node { ), filename: "", line: 1, - column: 4, + column: 0, end_line: 1, end_column: 8, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_2.snap index a6847a9ab..9c68da6f3 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_2.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 86 +assertion_line: 111 expression: "crate::tests::parsing_expr_string(r#\"a[b;;b]\"#)" --- Node { @@ -49,7 +49,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 7, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_3.snap index ee9c5696e..9c5a58260 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_3.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 112 expression: "crate::tests::parsing_expr_string(r#\"a[b[b]\"#)" --- Node { @@ -42,7 +43,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 6, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_4.snap index 7fc90435a..413332403 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_4.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 88 +assertion_line: 113 expression: "crate::tests::parsing_expr_string(r#\"a[:::]\"#)" --- Node { @@ -32,7 +32,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 6, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_5.snap index 8c9e8cf26..7b1b9eb23 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_5.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 89 +assertion_line: 114 expression: "crate::tests::parsing_expr_string(r#\"a[:1:2:]\"#)" --- Node { @@ -64,7 +64,7 @@ Node { ), filename: "", line: 1, - column: 1, + column: 0, end_line: 1, end_column: 8, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_6.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_6.snap index a5c26f008..6f6c74f97 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_6.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_6.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 90 +assertion_line: 115 expression: "crate::tests::parsing_expr_string(r#\"[][a:b:c:d]\"#)" --- Node { @@ -80,7 +80,7 @@ Node { ), filename: "", line: 1, - column: 2, + column: 0, end_line: 1, end_column: 8, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_7.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_7.snap index 81bd411ff..f9a7d62fc 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_7.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_7.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 91 +assertion_line: 116 expression: "crate::tests::parsing_expr_string(r#\"[][]\"#)" --- Node { @@ -29,7 +29,7 @@ Node { ), filename: "", line: 1, - column: 2, + column: 0, end_line: 1, end_column: 4, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_8.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_8.snap index c24edfbdc..5959e1822 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_8.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_8.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 92 +assertion_line: 117 expression: "crate::tests::parsing_expr_string(r#\"[][][]\"#)" --- Node { @@ -32,7 +32,7 @@ Node { ), filename: "", line: 1, - column: 2, + column: 0, end_line: 1, end_column: 4, }, @@ -46,7 +46,7 @@ Node { ), filename: "", line: 1, - column: 4, + column: 0, end_line: 1, end_column: 6, } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_9.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_9.snap index 40e1129ed..bd84fee9d 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_9.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__subscript_recovery_9.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 93 +assertion_line: 118 expression: "crate::tests::parsing_expr_string(r#\"[]?[]\"#)" --- Node { @@ -29,7 +29,7 @@ Node { ), filename: "", line: 1, - column: 2, + column: 0, end_line: 1, end_column: 5, }