Skip to content

Commit

Permalink
Fix handling of % and ! in the REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
tizoc committed May 12, 2024
1 parent a5d86c7 commit 4273240
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions sources/toplevel.shen
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,20 @@
Ss -> Ss)

(define evaluate-lineread
[_] ["!!" S | History] TC -> (let Y (read-from-string S)
NewHistory (set *history* [S S | History])
Print (output "~A~%" S)
(evaluate-lineread Y NewHistory TC))
[_] [(@s "%" S) | History] TC -> (let Read (hd (read-from-string S))
Peek (peek-history Read S History)
NewHistory (set *history* History)
(abort))
[_] [(@s "!" S) | History] TC -> (let Read (hd (read-from-string S))
Match (use-history Read S History)
Print (output "~A~%" Match)
Y (read-from-string Match)
NewHistory (set *history* [Match | History])
(evaluate-lineread Y NewHistory TC))
[_] [(@s "%" S) | History] TC -> (let Read (hd (read-from-string S))
Peek (peek-history Read S History)
NewHistory (set *history* History)
(abort))
[_] [(@s "!!" _) S | History] TC -> (let Y (read-from-string S)
NewHistory (set *history* [S S | History])
Print (output "~A~%" S)
(evaluate-lineread Y NewHistory TC))
[_] [(@s "!" S) | History] TC -> (let Read (if (= S "") [] (hd (read-from-string S)))
Match (use-history Read S History)
Print (output "~A~%" Match)
Y (read-from-string Match)
NewHistory (set *history* [Match | History])
(evaluate-lineread Y NewHistory TC))
[_] [(@s "%" S) | History] TC -> (let Read (if (= S "") [] (hd (read-from-string S)))
Peek (peek-history Read S History)
NewHistory (set *history* History)
(abort))
X _ true -> (check-eval-and-print X)
X _ false -> (eval-and-print X)
_ _ _ -> (simple-error "implementation error in shen.evaluate-lineread"))
Expand Down

0 comments on commit 4273240

Please sign in to comment.