forked from leanprover/lean4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Rust-style raw string literals (leanprover#2929)
For example, `r"\n"` and `r#"The word "this" is in quotes."#`. Implements leanprover#1422
- Loading branch information
Showing
7 changed files
with
218 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,5 @@ | ||
/-! | ||
# Testing an unterminated raw string literal | ||
-/ | ||
|
||
#check r###"this is a raw string, unterminated"## |
This file contains 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 @@ | ||
rawStringEOF.lean:5:7: error: unterminated raw string literal |
This file contains 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,72 @@ | ||
/-! | ||
# Testing raw string literals | ||
Implemented in PR #2929 for issue #1422. | ||
-/ | ||
|
||
/-! | ||
Empty raw string | ||
-/ | ||
example : r"" = "" := rfl | ||
|
||
/-! | ||
Empty raw string with at least one `#` | ||
-/ | ||
example : r#""# = "" := rfl | ||
|
||
/-! | ||
A nonempty raw string | ||
-/ | ||
example : r"hi" = "hi" := rfl | ||
|
||
/-! | ||
A nonempty raw string with at least one `#` | ||
-/ | ||
example : r#"hi"# = "hi" := rfl | ||
|
||
/-! | ||
A nonempty raw string with `#`, testing embedded `"`'s | ||
-/ | ||
example : r#""hello""# = "\"hello\"" := rfl | ||
|
||
/-! | ||
A nonempty raw string with `#`, testing embedded `"`'s, one not at the end of the string | ||
-/ | ||
example : r#""hello" said the world"# = "\"hello\" said the world" := rfl | ||
|
||
/-! | ||
A nonempty raw string for just `"` | ||
-/ | ||
example : r#"""# = "\"" := rfl | ||
|
||
/-! | ||
A raw string with a `\`, which does not get interpreted as an escape | ||
-/ | ||
example : r"\n" = "\\n" := rfl | ||
|
||
/-! | ||
A raw string for just `\`, and it doesn't escape the final `"` | ||
-/ | ||
example : r"\" = "\\" := rfl | ||
/-! | ||
A raw string with `#` inside, testing that the first `"` doesn't get double-interpreted | ||
as both the start and end. | ||
-/ | ||
example : r#"#"# = "#" := rfl | ||
|
||
/-! | ||
Testing using `##` raw strings to allow `"#` inside the string. | ||
-/ | ||
example : r##"need two #'s in "# to close"## = "need two #'s in \"# to close" := rfl | ||
|
||
/-! | ||
From Rust reference | ||
-/ | ||
example : r##"foo #"# bar"## = "foo #\"# bar" := rfl | ||
|
||
/-! | ||
Testing that we are conservative when counting closing `#`s. | ||
-/ | ||
infix:100 " # " => Prod.mk | ||
example : r#"a"##"b" = ("a", "b") := rfl |