Repository navigation
Implement CPython-like implicit string concatenation in parser #4097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8b45dee
Implement CPython-like implicit string concatenation in parser
e32959a
Add three-part test
9502bae
Move more logic into parse_implicit_concatenation
728614e
Remove extern crate
2ff3d0f
Reorder tests
e9907d4
Remove newline
07a4332
Remove unused import
4878848
Move Ok
0d0f5a2
Remove one match; sort Cargo.toml
7c377ca
Rename parse_strings
853da19
fix style
youknowone f12082c
refactoring
youknowone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,4 +30,5 @@ pub mod mode; | |
| pub mod parser; | ||
| #[rustfmt::skip] | ||
| mod python; | ||
| mod string; | ||
| pub mod token; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
parser/src/snapshots/rustpython_parser__parser__tests__parse_f_string.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| --- | ||
| source: parser/src/parser.rs | ||
| expression: parse_ast | ||
| --- | ||
| [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 3, | ||
| }, | ||
| custom: (), | ||
| node: Expr { | ||
| value: Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 3, | ||
| }, | ||
| custom: (), | ||
| node: JoinedStr { | ||
| values: [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 3, | ||
| }, | ||
| custom: (), | ||
| node: Constant { | ||
| value: Str( | ||
| "Hello world", | ||
| ), | ||
| kind: None, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ] |
28 changes: 28 additions & 0 deletions
28
parser/src/snapshots/rustpython_parser__parser__tests__parse_string.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| source: parser/src/parser.rs | ||
| expression: parse_ast | ||
| --- | ||
| [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: Expr { | ||
| value: Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: Constant { | ||
| value: Str( | ||
| "Hello world", | ||
| ), | ||
| kind: None, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ] |
39 changes: 39 additions & 0 deletions
39
parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_1.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| --- | ||
| source: parser/src/string.rs | ||
| expression: parse_ast | ||
| --- | ||
| [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: Expr { | ||
| value: Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: JoinedStr { | ||
| values: [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: Constant { | ||
| value: Str( | ||
| "Hello world", | ||
| ), | ||
| kind: None, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ] |
39 changes: 39 additions & 0 deletions
39
parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_2.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| --- | ||
| source: parser/src/string.rs | ||
| expression: parse_ast | ||
| --- | ||
| [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: Expr { | ||
| value: Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: JoinedStr { | ||
| values: [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: Constant { | ||
| value: Str( | ||
| "Hello world", | ||
| ), | ||
| kind: None, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ] |
63 changes: 63 additions & 0 deletions
63
parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_3.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| --- | ||
| source: parser/src/string.rs | ||
| expression: parse_ast | ||
| --- | ||
| [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: Expr { | ||
| value: Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: JoinedStr { | ||
| values: [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: Constant { | ||
| value: Str( | ||
| "Hello world", | ||
| ), | ||
| kind: None, | ||
| }, | ||
| }, | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 12, | ||
| }, | ||
| custom: (), | ||
| node: FormattedValue { | ||
| value: Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 3, | ||
| }, | ||
| custom: (), | ||
| node: Constant { | ||
| value: Str( | ||
| "!", | ||
| ), | ||
| kind: None, | ||
| }, | ||
| }, | ||
| conversion: 0, | ||
| format_spec: None, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ] |
28 changes: 28 additions & 0 deletions
28
parser/src/snapshots/rustpython_parser__string__tests__parse_string_concat.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| source: parser/src/string.rs | ||
| expression: parse_ast | ||
| --- | ||
| [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: Expr { | ||
| value: Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 2, | ||
| }, | ||
| custom: (), | ||
| node: Constant { | ||
| value: Str( | ||
| "Hello world", | ||
| ), | ||
| kind: None, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ] |
41 changes: 41 additions & 0 deletions
41
parser/src/snapshots/rustpython_parser__string__tests__parse_u_f_string_concat_1.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- | ||
| source: parser/src/string.rs | ||
| expression: parse_ast | ||
| --- | ||
| [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 3, | ||
| }, | ||
| custom: (), | ||
| node: Expr { | ||
| value: Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 3, | ||
| }, | ||
| custom: (), | ||
| node: JoinedStr { | ||
| values: [ | ||
| Located { | ||
| location: Location { | ||
| row: 1, | ||
| column: 3, | ||
| }, | ||
| custom: (), | ||
| node: Constant { | ||
| value: Str( | ||
| "Hello world", | ||
| ), | ||
| kind: Some( | ||
| "u", | ||
| ), | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.