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.
fix: make pretty printer escape identifiers that are tokens (leanprov…
…er#4979) For example, if `forall` is a variable, it now pretty prints as `«forall»`. Closes leanprover#4686
- Loading branch information
1 parent
041c426
commit 5ab1191
Showing
3 changed files
with
95 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import Lean | ||
/-! | ||
# Escaping names that are tokens when pretty printing | ||
-/ | ||
|
||
|
||
/-! | ||
Variable that's a token. | ||
-/ | ||
section | ||
variable («forall» : Nat) | ||
|
||
/-- info: «forall» + 1 : Nat -/ | ||
#guard_msgs in #check «forall» + 1 | ||
end | ||
|
||
|
||
/-! | ||
Constant that's a token | ||
-/ | ||
def «forall» := 1 | ||
|
||
/-- info: «forall» + 1 : Nat -/ | ||
#guard_msgs in #check «forall» + 1 | ||
|
||
|
||
/-! | ||
Don't escape name components that are tokens if the prefix is not a token. | ||
-/ | ||
def Exists.forall := 1 | ||
|
||
/-- info: Exists.forall : Nat -/ | ||
#guard_msgs in #check Exists.forall | ||
|
||
|
||
/-! | ||
Overly cautious for tokens that are prefixes. | ||
-/ | ||
def forall.congr := 1 | ||
|
||
/-- info: «forall».congr : Nat -/ | ||
#guard_msgs in #check forall.congr | ||
|
||
|
||
/-! | ||
Escape the last name component to avoid a token. | ||
-/ | ||
notation "Exists.forall" => true | ||
|
||
/-- info: Exists.«forall» : Nat -/ | ||
#guard_msgs in #check «Exists».forall | ||
/-- info: Exists.forall : Bool -/ | ||
#guard_msgs in #check Exists.forall |