python: remove extraneous macroexpand call.
[jackhill/mal.git] / powershell / step1_read_print.ps1
CommitLineData
d7d197f9
JM
1$ErrorActionPreference = "Stop"
2
3Import-Module $PSScriptRoot/reader.psm1
4Import-Module $PSScriptRoot/printer.psm1
5
f6146aef 6# READ
d7d197f9
JM
7function READ([String] $str) {
8 return read_str($str)
9}
10
f6146aef 11# EVAL
d7d197f9
JM
12function EVAL($ast, $env) {
13 return $ast
14}
15
f6146aef 16# PRINT
d7d197f9
JM
17function PRINT($exp) {
18 return pr_str $exp $true
19}
20
f6146aef
JM
21# REPL
22function REP([String] $str) {
d7d197f9
JM
23 return PRINT (EVAL (READ $str) @{})
24}
25
26while ($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}