Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Init/Data/String/Pattern/Pred.lean
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ instance : Std.Iterators.Finite (ForwardCharPredSearcher p s) Id :=
instance : Std.Iterators.IteratorLoop (ForwardCharPredSearcher p s) Id Id :=
.defaultImplementation

@[default_instance]
instance {p : Char → Bool} : ToForwardSearcher p (ForwardCharPredSearcher p) where
toSearcher := iter p

@[default_instance]
instance {p : Char → Bool} : ForwardPattern p := .defaultImplementation

instance {p : Char → Prop} [DecidablePred p] : ToForwardSearcher p (ForwardCharPredSearcher p) where
Expand Down Expand Up @@ -153,9 +155,11 @@ instance : Std.Iterators.Finite (BackwardCharPredSearcher s) Id :=
instance : Std.Iterators.IteratorLoop (BackwardCharPredSearcher s) Id Id :=
.defaultImplementation

@[default_instance]
instance {p : Char → Bool} : ToBackwardSearcher p BackwardCharPredSearcher where
toSearcher := iter p

@[default_instance]
instance {p : Char → Bool} : BackwardPattern p := ToBackwardSearcher.defaultImplementation

instance {p : Char → Prop} [DecidablePred p] : ToBackwardSearcher p BackwardCharPredSearcher where
Expand Down
2 changes: 1 addition & 1 deletion src/Lean/Data/Xml/Parser.lean
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def SystemLiteral : Parser String :=
/-- https://www.w3.org/TR/xml/#NT-PubidChar -/
def PubidChar : Parser LeanChar :=
asciiLetter <|> digit <|> endl <|> attempt do
let c ← any
let c : _root_.Char := ← any
if "-'()+,./:=?;!*#@$_%".contains c then pure c else fail "PublidChar expected"

/-- https://www.w3.org/TR/xml/#NT-PubidLiteral -/
Expand Down
9 changes: 9 additions & 0 deletions tests/lean/run/string_slice.lean
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,12 @@ end

#guard ("".toSlice.split "").toList == ["".toSlice, "".toSlice]
#guard ("abc".toSlice.split "").toList == ["".toSlice, "a".toSlice, "b".toSlice, "c".toSlice, "".toSlice]

#guard " ".find (·.isWhitespace) = " ".startPos
#guard " ".find (· = ' ') = " ".startPos
#guard " ".startsWith (·.isWhitespace) = true
#guard " ".startsWith (· = ' ') = true
#guard " ".revFind? (·.isWhitespace) = some " ".startPos
#guard " ".revFind? (· = ' ') = some " ".startPos
#guard " ".endsWith (·.isWhitespace) = true
#guard " ".endsWith (· = ' ') = true
Loading