@@ -560,7 +560,7 @@ Finds the tail position of the trailing whitespace of the first `SourceInfo` fro
560560If no `SourceInfo` can be found or the first `SourceInfo` from the back of `stx` contains
561561no trailing whitespace and lacks a tail position, the result is `none`.
562562-/
563- def getTrailingTailPos ? (stx : Syntax) (canonicalOnly := false) : Option String.Pos :=
563+ def getTrailingTailPos ? (stx : Syntax) (canonicalOnly := false) : Option String.Pos.Raw :=
564564 stx.getTailInfo.getTrailingTailPos? canonicalOnly
565565
566566/--
@@ -818,7 +818,7 @@ def mkNameLit (val : String) (info := SourceInfo.none) : NameLit :=
818818 in binary, octal, decimal and hexadecimal format. `isNatLit` implements a "decoder"
819819 for Syntax objects representing these numerals. -/
820820
821- private partial def decodeBinLitAux (s : String) (i : String.Pos) (val : Nat) : Option Nat :=
821+ private partial def decodeBinLitAux (s : String) (i : String.Pos.Raw ) (val : Nat) : Option Nat :=
822822 if String.Internal.atEnd s i then some val
823823 else
824824 let c := String.Internal.get s i
@@ -827,31 +827,31 @@ private partial def decodeBinLitAux (s : String) (i : String.Pos) (val : Nat) :
827827 else if c == '_' then decodeBinLitAux s (String.Internal.next s i) val
828828 else none
829829
830- private partial def decodeOctalLitAux (s : String) (i : String.Pos) (val : Nat) : Option Nat :=
830+ private partial def decodeOctalLitAux (s : String) (i : String.Pos.Raw ) (val : Nat) : Option Nat :=
831831 if String.Internal.atEnd s i then some val
832832 else
833833 let c := String.Internal.get s i
834834 if '0' ≤ c && c ≤ '7' then decodeOctalLitAux s (String.Internal.next s i) (8 *val + c.toNat - '0' .toNat)
835835 else if c == '_' then decodeOctalLitAux s (String.Internal.next s i) val
836836 else none
837837
838- private def decodeHexDigit (s : String) (i : String.Pos) : Option (Nat × String.Pos) :=
838+ private def decodeHexDigit (s : String) (i : String.Pos.Raw ) : Option (Nat × String.Pos.Raw ) :=
839839 let c := String.Internal.get s i
840840 let i := String.Internal.next s i
841841 if '0' ≤ c && c ≤ '9' then some (c.toNat - '0' .toNat, i)
842842 else if 'a' ≤ c && c ≤ 'f' then some (10 + c.toNat - 'a' .toNat, i)
843843 else if 'A' ≤ c && c ≤ 'F' then some (10 + c.toNat - 'A' .toNat, i)
844844 else none
845845
846- private partial def decodeHexLitAux (s : String) (i : String.Pos) (val : Nat) : Option Nat :=
846+ private partial def decodeHexLitAux (s : String) (i : String.Pos.Raw ) (val : Nat) : Option Nat :=
847847 if String.Internal.atEnd s i then some val
848848 else match decodeHexDigit s i with
849849 | some (d, i) => decodeHexLitAux s i (16 *val + d)
850850 | none =>
851851 if String.Internal.get s i == '_' then decodeHexLitAux s (String.Internal.next s i) val
852852 else none
853853
854- private partial def decodeDecimalLitAux (s : String) (i : String.Pos) (val : Nat) : Option Nat :=
854+ private partial def decodeDecimalLitAux (s : String) (i : String.Pos.Raw ) (val : Nat) : Option Nat :=
855855 if String.Internal.atEnd s i then some val
856856 else
857857 let c := String.Internal.get s i
@@ -911,7 +911,7 @@ partial def decodeScientificLitVal? (s : String) : Option (Nat × Bool × Nat) :
911911 decode 0 0
912912 else none
913913where
914- decodeAfterExp (i : String.Pos) (val : Nat) (e : Nat) (sign : Bool) (exp : Nat) : Option (Nat × Bool × Nat) :=
914+ decodeAfterExp (i : String.Pos.Raw ) (val : Nat) (e : Nat) (sign : Bool) (exp : Nat) : Option (Nat × Bool × Nat) :=
915915 if String.Internal.atEnd s i then
916916 if sign then
917917 some (val, sign, exp + e)
@@ -928,7 +928,7 @@ where
928928 else
929929 none
930930
931- decodeExp (i : String.Pos) (val : Nat) (e : Nat) : Option (Nat × Bool × Nat) :=
931+ decodeExp (i : String.Pos.Raw ) (val : Nat) (e : Nat) : Option (Nat × Bool × Nat) :=
932932 if String.Internal.atEnd s i then none else
933933 let c := String.Internal.get s i
934934 if c == '-' then
@@ -938,7 +938,7 @@ where
938938 else
939939 decodeAfterExp i val e false 0
940940
941- decodeAfterDot (i : String.Pos) (val : Nat) (e : Nat) : Option (Nat × Bool × Nat) :=
941+ decodeAfterDot (i : String.Pos.Raw ) (val : Nat) (e : Nat) : Option (Nat × Bool × Nat) :=
942942 if String.Internal.atEnd s i then
943943 some (val, true, e)
944944 else
@@ -952,7 +952,7 @@ where
952952 else
953953 none
954954
955- decode (i : String.Pos) (val : Nat) : Option (Nat × Bool × Nat) :=
955+ decode (i : String.Pos.Raw ) (val : Nat) : Option (Nat × Bool × Nat) :=
956956 if String.Internal.atEnd s i then
957957 none
958958 else
@@ -983,7 +983,7 @@ def toNat (stx : Syntax) : Nat :=
983983 | some val => val
984984 | none => 0
985985
986- def decodeQuotedChar (s : String) (i : String.Pos) : Option (Char × String.Pos) := do
986+ def decodeQuotedChar (s : String) (i : String.Pos.Raw ) : Option (Char × String.Pos.Raw ) := do
987987 let c := String.Internal.get s i
988988 let i := String.Internal.next s i
989989 if c == '\\ ' then pure ('\\ ' , i)
@@ -1011,11 +1011,11 @@ Note that this function matches `"\" whitespace+` rather than
10111011the more restrictive `"\" newline whitespace*` since this simplifies the implementation.
10121012Justification: this does not overlap with any other sequences beginning with `\`.
10131013-/
1014- def decodeStringGap (s : String) (i : String.Pos) : Option String.Pos := do
1014+ def decodeStringGap (s : String) (i : String.Pos.Raw ) : Option String.Pos.Raw := do
10151015 guard <| (String.Internal.get s i).isWhitespace
10161016 some <| String.Internal.nextWhile s Char.isWhitespace (String.Internal.next s i)
10171017
1018- partial def decodeStrLitAux (s : String) (i : String.Pos) (acc : String) : Option String := do
1018+ partial def decodeStrLitAux (s : String) (i : String.Pos.Raw ) (acc : String) : Option String := do
10191019 let c := String.Internal.get s i
10201020 let i := String.Internal.next s i
10211021 if c == '\" ' then
@@ -1038,7 +1038,7 @@ The position `i` should start at `1`, which is the character after the leading `
10381038The algorithm is simple: we are given `r##...#"...string..."##...#` with zero or more `#`s.
10391039By counting the number of leading `#`'s, we can extract the `...string...`.
10401040-/
1041- partial def decodeRawStrLitAux (s : String) (i : String.Pos) (num : Nat) : String :=
1041+ partial def decodeRawStrLitAux (s : String) (i : String.Pos.Raw ) (num : Nat) : String :=
10421042 let c := String.Internal.get s i
10431043 let i := String.Internal.next s i
10441044 if c == '#' then
@@ -1097,7 +1097,7 @@ private partial def splitNameLitAux (ss : Substring) (acc : List Substring) : Li
10971097 let curr := Substring.Internal.front ss
10981098 if isIdBeginEscape curr then
10991099 let escapedPart := Substring.Internal.takeWhile ss (!isIdEndEscape ·)
1100- let escapedPart := { escapedPart with stopPos := String.Pos.Internal.min ss.stopPos (String.Internal.next escapedPart.str escapedPart.stopPos) }
1100+ let escapedPart := { escapedPart with stopPos := String.Pos.Raw. Internal.min ss.stopPos (String.Internal.next escapedPart.str escapedPart.stopPos) }
11011101 if !isIdEndEscape (Substring.Internal.get escapedPart <| Substring.Internal.prev escapedPart ⟨escapedPart.bsize⟩) then []
11021102 else splitRest (Substring.Internal.extract ss ⟨escapedPart.bsize⟩ ⟨ss.bsize⟩) (escapedPart :: acc)
11031103 else if isIdFirst curr then
@@ -1462,7 +1462,7 @@ end Lean.Syntax
14621462
14631463namespace Lean.Syntax
14641464
1465- private def decodeInterpStrQuotedChar (s : String) (i : String.Pos) : Option (Char × String.Pos) := do
1465+ private def decodeInterpStrQuotedChar (s : String) (i : String.Pos.Raw ) : Option (Char × String.Pos.Raw ) := do
14661466 match decodeQuotedChar s i with
14671467 | some r => some r
14681468 | none =>
@@ -1472,7 +1472,7 @@ private def decodeInterpStrQuotedChar (s : String) (i : String.Pos) : Option (Ch
14721472 else none
14731473
14741474private partial def decodeInterpStrLit (s : String) : Option String :=
1475- let rec loop (i : String.Pos) (acc : String) : Option String :=
1475+ let rec loop (i : String.Pos.Raw ) (acc : String) : Option String :=
14761476 let c := String.Internal.get s i
14771477 let i := String.Internal.next s i
14781478 if c == '\" ' || c == '{' then
@@ -1533,7 +1533,7 @@ def expandInterpolatedStr (interpStr : TSyntax interpolatedStrKind) (type : Term
15331533
15341534def getDocString (stx : TSyntax `Lean .Parser.Command.docComment) : String :=
15351535 match stx.raw[1 ] with
1536- | Syntax.atom _ val => String.Internal.extract val 0 (String.Pos.Internal.sub val.endPos ⟨2 ⟩)
1536+ | Syntax.atom _ val => String.Internal.extract val 0 (String.Pos.Raw. Internal.sub val.endPos ⟨2 ⟩)
15371537 | _ => " "
15381538
15391539end TSyntax
0 commit comments