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:
parent
ca9d6ee043
commit
a416719a57
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user