From ca62bd159389d33c0f6a9407cff3e149ea528a87 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 16 Oct 2022 11:25:46 -0400 Subject: [PATCH] Start simple string at quote mark --- parser/src/lexer.rs | 2 +- .../rustpython_parser__parser__tests__parse_class.snap | 6 +++--- .../rustpython_parser__parser__tests__parse_kwargs.snap | 5 ++--- .../rustpython_parser__parser__tests__parse_print_2.snap | 5 ++--- ...stpython_parser__parser__tests__parse_print_hello.snap | 4 ++-- .../rustpython_parser__parser__tests__parse_string.snap | 6 +++--- ...on_parser__string__tests__parse_f_string_concat_1.snap | 8 ++++---- ...on_parser__string__tests__parse_f_string_concat_2.snap | 8 ++++---- ...on_parser__string__tests__parse_f_string_concat_3.snap | 8 ++++---- ...python_parser__string__tests__parse_string_concat.snap | 6 +++--- ...on_parser__string__tests__parse_u_string_concat_1.snap | 6 +++--- 11 files changed, 31 insertions(+), 33 deletions(-) diff --git a/parser/src/lexer.rs b/parser/src/lexer.rs index 5e5264f..2f72cf7 100644 --- a/parser/src/lexer.rs +++ b/parser/src/lexer.rs @@ -492,9 +492,9 @@ where is_unicode: bool, is_fstring: bool, ) -> LexResult { + let start_pos = self.get_pos(); let quote_char = self.next_char().unwrap(); let mut string_content = String::new(); - let start_pos = self.get_pos(); // If the next two characters are also the quote character, then we have a triple-quoted // string; consume those two characters and ensure that we require a triple-quote to close diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_class.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_class.snap index 869669e..327da51 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_class.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_class.snap @@ -1,6 +1,6 @@ --- -source: parser/src/parser.rs -expression: parse_program(&source).unwrap() +source: compiler/parser/src/parser.rs +expression: "parse_program(source, \"\").unwrap()" --- [ Located { @@ -126,7 +126,7 @@ expression: parse_program(&source).unwrap() Located { location: Location { row: 4, - column: 37, + column: 36, }, custom: (), node: Constant { diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_kwargs.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_kwargs.snap index d31a392..1b8a545 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_kwargs.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_kwargs.snap @@ -1,7 +1,6 @@ --- -source: parser/src/parser.rs +source: compiler/parser/src/parser.rs expression: parse_ast - --- [ Located { @@ -33,7 +32,7 @@ expression: parse_ast Located { location: Location { row: 1, - column: 10, + column: 9, }, custom: (), node: Constant { diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_2.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_2.snap index 6fe4cad..3f828de 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_2.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_2.snap @@ -1,7 +1,6 @@ --- -source: parser/src/parser.rs +source: compiler/parser/src/parser.rs expression: parse_ast - --- [ Located { @@ -33,7 +32,7 @@ expression: parse_ast Located { location: Location { row: 1, - column: 8, + column: 7, }, custom: (), node: Constant { diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_hello.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_hello.snap index b4e78d8..aae345a 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_hello.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_hello.snap @@ -1,5 +1,5 @@ --- -source: parser/src/parser.rs +source: compiler/parser/src/parser.rs expression: parse_ast --- [ @@ -32,7 +32,7 @@ expression: parse_ast Located { location: Location { row: 1, - column: 8, + column: 7, }, custom: (), node: Constant { diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_string.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_string.snap index b808f28..efbf32f 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_string.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_string.snap @@ -1,19 +1,19 @@ --- -source: parser/src/parser.rs +source: compiler/parser/src/parser.rs expression: parse_ast --- [ Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Expr { value: Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Constant { diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_1.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_1.snap index 687ee96..a486e11 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_1.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_1.snap @@ -1,19 +1,19 @@ --- -source: parser/src/string.rs +source: compiler/parser/src/string.rs expression: parse_ast --- [ Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Expr { value: Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: JoinedStr { @@ -21,7 +21,7 @@ expression: parse_ast Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Constant { diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_2.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_2.snap index 687ee96..a486e11 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_2.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_2.snap @@ -1,19 +1,19 @@ --- -source: parser/src/string.rs +source: compiler/parser/src/string.rs expression: parse_ast --- [ Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Expr { value: Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: JoinedStr { @@ -21,7 +21,7 @@ expression: parse_ast Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Constant { diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_3.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_3.snap index a41e765..ccddd2a 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_3.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_3.snap @@ -6,14 +6,14 @@ expression: parse_ast Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Expr { value: Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: JoinedStr { @@ -21,7 +21,7 @@ expression: parse_ast Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Constant { @@ -41,7 +41,7 @@ expression: parse_ast value: Located { location: Location { row: 1, - column: 3, + column: 2, }, custom: (), node: Constant { diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_string_concat.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_string_concat.snap index 25ed233..380a1fc 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_string_concat.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_string_concat.snap @@ -1,19 +1,19 @@ --- -source: parser/src/string.rs +source: compiler/parser/src/string.rs expression: parse_ast --- [ Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Expr { value: Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Constant { diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_1.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_1.snap index 25ed233..380a1fc 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_1.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_1.snap @@ -1,19 +1,19 @@ --- -source: parser/src/string.rs +source: compiler/parser/src/string.rs expression: parse_ast --- [ Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Expr { value: Located { location: Location { row: 1, - column: 2, + column: 1, }, custom: (), node: Constant {