Skip to content

Commit

Permalink
handling comments and newlines; quick-fixes for #11 and #8
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhartha-gadgil committed Nov 20, 2024
1 parent 86d0d05 commit d7caecc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
2 changes: 2 additions & 0 deletions LeanSearchClient/LoogleSyntax.lean
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ initialize loogleCache :

def getLoogleQueryJson (s : String) (num_results : Nat := 6) :
CoreM <| LoogleResult:= do
let s := s.splitOn "/-" |>.getD 0 s |>.trim
let s := s.replace "\n" " "
let cache ← loogleCache.get
match cache.get? (s, num_results) with
| some r => return r
Expand Down
39 changes: 30 additions & 9 deletions LeanSearchClientTest/LoogleExamples.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,38 @@ import LeanSearchClient.LoogleSyntax
Examples of using the Loogle API. The search is triggered by the word at the end of the query.
-/

#loogle List ?a → ?a
-- #loogle List ?a → ?a

example := #loogle List ?a → ?a
-- example := #loogle List ?a → ?a


set_option loogle.queries 1
-- set_option loogle.queries 1

example : 35 := by
#loogle Nat.succ_le_succ
sorry
-- example : 3 ≤ 5 := by
-- #loogle Nat.succ_le_succ
-- sorry

example : 35 := by
#loogle
decide
-- example : 3 ≤ 5 := by
-- #loogle
-- decide

/-!
More examples to test comments do not interfere with the search or caching.
-/

#loogle ?a * _ < ?a * _ ↔ _
#loogle ?a * _ < ?a * _ ↔ _ /- foo -/
#loogle ?a * _ < ?a * _ ↔ _


-- comment
#loogle ?a * _ < ?a * _ ↔ _

/--
info: Loogle Search Results
• #check Option.get!
-/
#guard_msgs in
#loogle Option ?a → ?a, "get!"

/- hello -/

0 comments on commit d7caecc

Please sign in to comment.