-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
67 additions
and
0 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,25 @@ | ||
import Monkey.Lexer.Lexer | ||
import Monkey.Token.Token | ||
|
||
open IO Token | ||
|
||
/-- REPL を表す。 | ||
`lake env lean --run Monkey/Repl/Repl.lean` で実行できる。 | ||
標準入力に入れた Monkey のコードを読みこむ。 -/ | ||
partial def main : IO Unit := do | ||
IO.print ">> " | ||
let inputStream ← getStdin | ||
let input ← inputStream.getLine | ||
if input.trim = "" then return () | ||
|
||
let mut l : Lexer := Lexer.new input | ||
let mut tokens : Array Token := #[] | ||
|
||
while True do | ||
let ⟨tok, l'⟩ := l.nextToken |>.run | ||
l := l' | ||
tokens := tokens.push tok | ||
if tok = EOF then break | ||
|
||
IO.println tokens | ||
main |
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