1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-11 13:55:55 +03:00

vbs: rewrite stepA & core with IOWrap

This commit is contained in:
老刘 2024-08-14 11:32:20 +08:00 committed by Joel Martin
parent ca9d6ee043
commit a416719a57
2 changed files with 13 additions and 15 deletions

View File

@ -207,7 +207,7 @@ Function MPrn(objArgs, objEnv)
Dim varRet
Dim objStr
Set objStr = MPrStr(objArgs, objEnv)
WScript.StdOut.WriteLine objStr.Value
IO.WriteLine objStr.Value
Set varRet = NewMalNil()
Set MPrn = varRet
End Function
@ -225,7 +225,7 @@ Function MPrintln(objArgs, objEnv)
strRes = strRes + " " + _
PrintMalType(objArgs.Item(i), False)
Next
WScript.StdOut.WriteLine strRes
IO.WriteLine strRes
Set varRet = NewMalNil()
Set MPrintln = varRet
End Function
@ -711,10 +711,9 @@ Function MReadLine(objArgs, objEnv)
CheckType objArgs.Item(1), TYPES.STRING
Dim strInput
WScript.Echo ""
WScript.StdOut.Write objArgs.Item(1).Value
IO.Write objArgs.Item(1).Value
On Error Resume Next
strInput = WScript.StdIn.ReadLine()
strInput = IO.ReadLine
If Err.Number <> 0 Then
Set varRes = NewMalNil()
Else

View File

@ -1,5 +1,6 @@
Option Explicit
Include "IO.vbs"
Include "Types.vbs"
Include "Reader.vbs"
Include "Printer.vbs"
@ -390,13 +391,13 @@ End Sub
Call REPL()
Sub REPL()
Dim strCode, strResult
Dim strCode
REP "(println (str ""Mal [""*host-language*""]""))"
While True
WScript.StdOut.Write "user> "
IO.Write "user> "
On Error Resume Next
strCode = WScript.StdIn.ReadLine()
strCode = IO.ReadLine
If Err.Number <> 0 Then WScript.Quit 0
On Error Goto 0
@ -405,18 +406,16 @@ Sub REPL()
strRes = REP(strCode)
If Err.Number <> 0 Then
If Err.Source = "MThrow" Then
'WScript.StdOut.WriteLine Err.Source + ": " + _
WScript.StdOut.WriteLine "Exception: " + _
IO.WriteErrLine "Exception: " + _
PrintMalType(objExceptions.Item(Err.Description), True)
objExceptions.Remove Err.Description
Else
'WScript.StdOut.WriteLine Err.Source + ": " + Err.Description
WScript.StdOut.WriteLine "Exception: " + Err.Description
IO.WriteErrLine "Exception: " + Err.Description
End If
Else
' If strRes <> "" Then
WScript.Echo strRes
' End If
If strRes <> "" Then
IO.WriteLine strRes
End If
End If
On Error Goto 0
Wend