diff --git a/kclvm/parser/src/parser/expr.rs b/kclvm/parser/src/parser/expr.rs index ea726f4b6..9283f2d28 100644 --- a/kclvm/parser/src/parser/expr.rs +++ b/kclvm/parser/src/parser/expr.rs @@ -18,7 +18,7 @@ use kclvm_ast::token::{BinOpToken, DelimToken, TokenKind, VALID_SPACES_LENGTH}; use kclvm_span::symbol::kw; /// Parser implementation of expressions, which consists of sub-expressions, -/// operand and tokens. Like the general LL1 paser, parser constantly looking for +/// operand and tokens. Like the general LL1 parser, parser constantly looking for /// left-side derivation, priority is specified by matching code explicitly. /// The entrances of expression parsing are `parse_exprlist` and `parse_expr`. /// TODO: operand design is quite complex, can be simplified later. @@ -427,11 +427,28 @@ impl<'a> Parser<'a> { ), } + let has_newline = if self.token.kind == TokenKind::Newline { + self.skip_newlines(); + self.clean_all_indentations(); + if self.token.kind == TokenKind::CloseDelim(DelimToken::Paren) { + // bump bracket close delim token `)` + self.bump(); + return CallExpr { + func, + args: vec![], + keywords: vec![], + }; + } + true + } else { + false + }; + // arguments or empty let (args, keywords) = if self.token.kind == TokenKind::CloseDelim(DelimToken::Paren) { (Vec::new(), Vec::new()) } else { - self.parse_arguments_expr() + self.parse_arguments_expr(has_newline) }; // [COMMA] @@ -2011,17 +2028,36 @@ impl<'a> Parser<'a> { /// Syntax: /// arguments: argument (COMMA argument)* - fn parse_arguments_expr(&mut self) -> (Vec>, Vec>) { + fn parse_arguments_expr( + &mut self, + has_newline: bool, + ) -> (Vec>, Vec>) { let mut args: Vec> = Vec::new(); let mut keywords: Vec> = Vec::new(); let mut has_keyword = false; + let is_terminator = |token: &kclvm_ast::token::Token| match &token.kind { + TokenKind::CloseDelim(DelimToken::Paren) | TokenKind::Eof => true, + TokenKind::Newline if !has_newline => true, + _ => token.is_keyword(kw::For), + }; loop { + let marker = self.mark(); + self.clean_all_indentations(); + if is_terminator(&self.token) { + break; + } // Record the argument expression start token. let token = self.token; match self.parse_argument_expr() { Either::Left(expr) => { - args.push(Box::new(expr)); + if matches!(expr.node, Expr::Missing(_)) { + self.sess + .struct_token_error(&[TokenKind::Comma.into()], self.token); + self.bump(); + } else { + args.push(Box::new(expr)); + } if has_keyword { self.sess.struct_span_error( "positional argument follows keyword argument", @@ -2037,9 +2073,11 @@ impl<'a> Parser<'a> { if self.token.kind == TokenKind::Comma { self.bump(); - } else { - break; } + if has_newline { + self.skip_newlines(); + } + self.drop(marker); } (args, keywords) diff --git a/kclvm/parser/src/tests/error_recovery.rs b/kclvm/parser/src/tests/error_recovery.rs index b27706e1e..00bf54555 100644 --- a/kclvm/parser/src/tests/error_recovery.rs +++ b/kclvm/parser/src/tests/error_recovery.rs @@ -143,6 +143,31 @@ parse_expr_snapshot! { call_recovery_4, r#"a(a.ba=1,2)"# } parse_expr_snapshot! { call_recovery_5, r#"a(a.b+a=1,2)"# } parse_expr_snapshot! { call_recovery_6, r#"a(a-1.b=1)"# } parse_expr_snapshot! { call_recovery_7, r#"a(type="list", "key")"# } +parse_expr_snapshot! { call_recovery_8, r#"a( + 1,2 +)"# } +parse_expr_snapshot! { call_recovery_9, r#"a(1,2 +)"# } +parse_expr_snapshot! { call_recovery_10, r#"a( + 1, + 2 +)"# } +parse_expr_snapshot! { call_recovery_11, r#"a( + 1, +2, +)"# } +parse_expr_snapshot! { call_recovery_12, r#"a( + 1, +2, +)"# } +parse_expr_snapshot! { call_recovery_13, r#"a( + 1,, +2, +)"# } +parse_expr_snapshot! { call_recovery_14, r#"a( + 1, + 2, +]"# } parse_expr_snapshot! { schema_recovery_0, r#"s {"# } parse_expr_snapshot! { schema_recovery_1, r#"s {a=1"# } parse_expr_snapshot! { schema_recovery_2, r#"s.0 {a=1}"# } diff --git a/kclvm/parser/src/tests/snapshots/Makefile b/kclvm/parser/src/tests/snapshots/Makefile deleted file mode 100644 index b72f999d0..000000000 --- a/kclvm/parser/src/tests/snapshots/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -default: - python3 mv_new_snapshot.py diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_0.snap index 765f62e31..dea4d3cfd 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_0.snap @@ -28,18 +28,7 @@ Node { end_line: 1, end_column: 1, }, - args: [ - Node { - node: Missing( - MissingExpr, - ), - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 2, - }, - ], + args: [], keywords: [], }, ), @@ -49,4 +38,3 @@ Node { end_line: 1, end_column: 2, } - diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_10.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_10.snap new file mode 100644 index 000000000..431ffacfc --- /dev/null +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_10.snap @@ -0,0 +1,71 @@ +--- +source: parser/src/tests/error_recovery.rs +expression: "crate::tests::parsing_expr_string(r#\"a(\n 1,\n 2\n)\"#)" +--- +Node { + node: Call( + CallExpr { + func: Node { + node: Identifier( + Identifier { + names: [ + Node { + node: "a", + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + ], + pkgpath: "", + ctx: Load, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + args: [ + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 1, + ), + }, + ), + filename: "", + line: 2, + column: 4, + end_line: 2, + end_column: 5, + }, + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 2, + ), + }, + ), + filename: "", + line: 3, + column: 4, + end_line: 3, + end_column: 5, + }, + ], + keywords: [], + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 4, + end_column: 1, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_11.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_11.snap new file mode 100644 index 000000000..1cb2cce40 --- /dev/null +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_11.snap @@ -0,0 +1,71 @@ +--- +source: parser/src/tests/error_recovery.rs +expression: "crate::tests::parsing_expr_string(r#\"a(\n 1,\n2,\n)\"#)" +--- +Node { + node: Call( + CallExpr { + func: Node { + node: Identifier( + Identifier { + names: [ + Node { + node: "a", + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + ], + pkgpath: "", + ctx: Load, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + args: [ + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 1, + ), + }, + ), + filename: "", + line: 2, + column: 4, + end_line: 2, + end_column: 5, + }, + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 2, + ), + }, + ), + filename: "", + line: 3, + column: 0, + end_line: 3, + end_column: 1, + }, + ], + keywords: [], + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 4, + end_column: 1, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_12.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_12.snap new file mode 100644 index 000000000..1cb2cce40 --- /dev/null +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_12.snap @@ -0,0 +1,71 @@ +--- +source: parser/src/tests/error_recovery.rs +expression: "crate::tests::parsing_expr_string(r#\"a(\n 1,\n2,\n)\"#)" +--- +Node { + node: Call( + CallExpr { + func: Node { + node: Identifier( + Identifier { + names: [ + Node { + node: "a", + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + ], + pkgpath: "", + ctx: Load, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + args: [ + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 1, + ), + }, + ), + filename: "", + line: 2, + column: 4, + end_line: 2, + end_column: 5, + }, + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 2, + ), + }, + ), + filename: "", + line: 3, + column: 0, + end_line: 3, + end_column: 1, + }, + ], + keywords: [], + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 4, + end_column: 1, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_13.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_13.snap new file mode 100644 index 000000000..c3099f749 --- /dev/null +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_13.snap @@ -0,0 +1,71 @@ +--- +source: parser/src/tests/error_recovery.rs +expression: "crate::tests::parsing_expr_string(r#\"a(\n 1,,\n2,\n)\"#)" +--- +Node { + node: Call( + CallExpr { + func: Node { + node: Identifier( + Identifier { + names: [ + Node { + node: "a", + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + ], + pkgpath: "", + ctx: Load, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + args: [ + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 1, + ), + }, + ), + filename: "", + line: 2, + column: 4, + end_line: 2, + end_column: 5, + }, + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 2, + ), + }, + ), + filename: "", + line: 3, + column: 0, + end_line: 3, + end_column: 1, + }, + ], + keywords: [], + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 4, + end_column: 1, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_14.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_14.snap new file mode 100644 index 000000000..1e37e5050 --- /dev/null +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_14.snap @@ -0,0 +1,71 @@ +--- +source: parser/src/tests/error_recovery.rs +expression: "crate::tests::parsing_expr_string(r#\"a(\n 1,\n 2,\n]\"#)" +--- +Node { + node: Call( + CallExpr { + func: Node { + node: Identifier( + Identifier { + names: [ + Node { + node: "a", + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + ], + pkgpath: "", + ctx: Load, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + args: [ + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 1, + ), + }, + ), + filename: "", + line: 2, + column: 4, + end_line: 2, + end_column: 5, + }, + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 2, + ), + }, + ), + filename: "", + line: 3, + column: 4, + end_line: 3, + end_column: 5, + }, + ], + keywords: [], + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 4, + end_column: 1, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_2.snap index f6572f600..80b7358cc 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_2.snap @@ -52,26 +52,6 @@ Node { end_line: 1, end_column: 3, }, - Node { - node: Missing( - MissingExpr, - ), - filename: "", - line: 1, - column: 4, - end_line: 1, - end_column: 5, - }, - Node { - node: Missing( - MissingExpr, - ), - filename: "", - line: 1, - column: 5, - end_line: 1, - end_column: 6, - }, ], keywords: [], }, @@ -82,4 +62,3 @@ Node { end_line: 1, end_column: 6, } - diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_8.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_8.snap new file mode 100644 index 000000000..3451c9c7c --- /dev/null +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_8.snap @@ -0,0 +1,71 @@ +--- +source: parser/src/tests/error_recovery.rs +expression: "crate::tests::parsing_expr_string(r#\"a(\n 1,2\n)\"#)" +--- +Node { + node: Call( + CallExpr { + func: Node { + node: Identifier( + Identifier { + names: [ + Node { + node: "a", + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + ], + pkgpath: "", + ctx: Load, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + args: [ + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 1, + ), + }, + ), + filename: "", + line: 2, + column: 4, + end_line: 2, + end_column: 5, + }, + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 2, + ), + }, + ), + filename: "", + line: 2, + column: 6, + end_line: 2, + end_column: 7, + }, + ], + keywords: [], + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 3, + end_column: 1, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_9.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_9.snap new file mode 100644 index 000000000..7610c0fe1 --- /dev/null +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__call_recovery_9.snap @@ -0,0 +1,71 @@ +--- +source: parser/src/tests/error_recovery.rs +expression: "crate::tests::parsing_expr_string(r#\"a(1,2\n)\"#)" +--- +Node { + node: Call( + CallExpr { + func: Node { + node: Identifier( + Identifier { + names: [ + Node { + node: "a", + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + ], + pkgpath: "", + ctx: Load, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 1, + }, + args: [ + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 1, + ), + }, + ), + filename: "", + line: 1, + column: 2, + end_line: 1, + end_column: 3, + }, + Node { + node: NumberLit( + NumberLit { + binary_suffix: None, + value: Int( + 2, + ), + }, + ), + filename: "", + line: 1, + column: 4, + end_line: 1, + end_column: 5, + }, + ], + keywords: [], + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 5, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_20.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_20.snap index f25921168..812f92d46 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_20.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_20.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 239 expression: "crate::tests::parsing_module_string(r#\"@deprecated(\nschema A:\n a: \"#)" --- Module { @@ -8,117 +7,6 @@ Module { pkg: "", doc: None, name: "", - body: [ - Node { - node: Schema( - SchemaStmt { - doc: None, - name: Node { - node: "A", - filename: "", - line: 2, - column: 7, - end_line: 2, - end_column: 8, - }, - parent_name: None, - for_host_name: None, - is_mixin: false, - is_protocol: false, - args: None, - mixins: [], - body: [ - Node { - node: SchemaAttr( - SchemaAttr { - doc: "", - name: Node { - node: "a", - filename: "", - line: 3, - column: 4, - end_line: 3, - end_column: 5, - }, - op: None, - value: None, - is_optional: false, - decorators: [], - ty: Node { - node: Any, - filename: "", - line: 3, - column: 7, - end_line: 3, - end_column: 7, - }, - }, - ), - filename: "", - line: 3, - column: 4, - end_line: 3, - end_column: 7, - }, - ], - decorators: [ - Node { - node: CallExpr { - func: Node { - node: Identifier( - Identifier { - names: [ - Node { - node: "deprecated", - filename: "", - line: 1, - column: 1, - end_line: 1, - end_column: 11, - }, - ], - pkgpath: "", - ctx: Load, - }, - ), - filename: "", - line: 1, - column: 1, - end_line: 1, - end_column: 11, - }, - args: [ - Node { - node: Missing( - MissingExpr, - ), - filename: "", - line: 1, - column: 12, - end_line: 2, - end_column: 0, - }, - ], - keywords: [], - }, - filename: "", - line: 1, - column: 1, - end_line: 1, - end_column: 12, - }, - ], - checks: [], - index_signature: None, - }, - ), - filename: "", - line: 2, - column: 0, - end_line: 3, - end_column: 7, - }, - ], + body: [], comments: [], } - diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_21.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_21.snap index f5fc62b5c..812f92d46 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_21.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_21.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 242 expression: "crate::tests::parsing_module_string(r#\"@deprecated(\nschema A:\n a: \"#)" --- Module { @@ -8,117 +7,6 @@ Module { pkg: "", doc: None, name: "", - body: [ - Node { - node: Schema( - SchemaStmt { - doc: None, - name: Node { - node: "A", - filename: "", - line: 2, - column: 7, - end_line: 2, - end_column: 8, - }, - parent_name: None, - for_host_name: None, - is_mixin: false, - is_protocol: false, - args: None, - mixins: [], - body: [ - Node { - node: SchemaAttr( - SchemaAttr { - doc: "", - name: Node { - node: "a", - filename: "", - line: 3, - column: 4, - end_line: 3, - end_column: 5, - }, - op: None, - value: None, - is_optional: false, - decorators: [], - ty: Node { - node: Any, - filename: "", - line: 3, - column: 7, - end_line: 3, - end_column: 7, - }, - }, - ), - filename: "", - line: 3, - column: 4, - end_line: 3, - end_column: 7, - }, - ], - decorators: [ - Node { - node: CallExpr { - func: Node { - node: Identifier( - Identifier { - names: [ - Node { - node: "deprecated", - filename: "", - line: 1, - column: 1, - end_line: 1, - end_column: 11, - }, - ], - pkgpath: "", - ctx: Load, - }, - ), - filename: "", - line: 1, - column: 1, - end_line: 1, - end_column: 11, - }, - args: [ - Node { - node: Missing( - MissingExpr, - ), - filename: "", - line: 1, - column: 12, - end_line: 2, - end_column: 0, - }, - ], - keywords: [], - }, - filename: "", - line: 1, - column: 1, - end_line: 1, - end_column: 12, - }, - ], - checks: [], - index_signature: None, - }, - ), - filename: "", - line: 2, - column: 0, - end_line: 3, - end_column: 7, - }, - ], + body: [], comments: [], } - diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_23.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_23.snap index 71c00d226..8104ea428 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_23.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_23.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 248 expression: "crate::tests::parsing_module_string(r#\"@deprecated(a,\nschema A:\n a: \"#)" --- Module { @@ -111,16 +110,6 @@ Module { end_line: 1, end_column: 13, }, - Node { - node: Missing( - MissingExpr, - ), - filename: "", - line: 1, - column: 14, - end_line: 2, - end_column: 0, - }, ], keywords: [], }, @@ -144,4 +133,3 @@ Module { ], comments: [], } - diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_24.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_24.snap index 0bb76d007..a7d461870 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_24.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_24.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 251 expression: "crate::tests::parsing_module_string(r#\"@deprecated((),\nschema A:\n a: \"#)" --- Module { @@ -109,16 +108,6 @@ Module { end_line: 1, end_column: 14, }, - Node { - node: Missing( - MissingExpr, - ), - filename: "", - line: 1, - column: 15, - end_line: 2, - end_column: 0, - }, ], keywords: [], }, @@ -142,4 +131,3 @@ Module { ], comments: [], } - diff --git a/kclvm/parser/src/tests/snapshots/mv_new_snapshot.py b/kclvm/parser/src/tests/snapshots/mv_new_snapshot.py deleted file mode 100644 index 545caf3e9..000000000 --- a/kclvm/parser/src/tests/snapshots/mv_new_snapshot.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python3 -import os -import shutil -import pathlib - -count = 0 -dir = os.path.dirname(os.path.abspath(__file__)) -for file in os.listdir(dir): - file = os.path.join(dir, file) - if file.endswith(".new"): - to_file_name = file[0 : len(file) - len(".new")] - print(f"to mv file {file} to {to_file_name}") - shutil.move(file, to_file_name) - print(f"moved file {file} to {to_file_name} done") - count += 1 - -print(f"moved {count} files done")