Commit | Line | Data |
---|---|---|
d7d197f9 JM |
1 | $ErrorActionPreference = "Stop" |
2 | ||
3 | Import-Module $PSScriptRoot/reader.psm1 | |
4 | Import-Module $PSScriptRoot/printer.psm1 | |
5 | ||
f6146aef | 6 | # READ |
d7d197f9 JM |
7 | function READ([String] $str) { |
8 | return read_str($str) | |
9 | } | |
10 | ||
f6146aef | 11 | # EVAL |
d7d197f9 JM |
12 | function EVAL($ast, $env) { |
13 | return $ast | |
14 | } | |
15 | ||
f6146aef | 16 | |
d7d197f9 JM |
17 | function PRINT($exp) { |
18 | return pr_str $exp $true | |
19 | } | |
20 | ||
f6146aef JM |
21 | # REPL |
22 | function REP([String] $str) { | |
d7d197f9 JM |
23 | return PRINT (EVAL (READ $str) @{}) |
24 | } | |
25 | ||
26 | while ($true) { | |
27 | Write-Host "user> " -NoNewline | |
28 | $line = [Console]::ReadLine() | |
29 | if ($line -eq $null) { | |
30 | break | |
31 | } | |
32 | try { | |
f6146aef | 33 | Write-Host (REP($line)) |
d7d197f9 JM |
34 | } catch { |
35 | Write-Host "Exception: $($_.Exception.Message)" | |
36 | } | |
37 | } |