1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-10 12:47:45 +03:00
mal/vb/step1_read_print.vb
2015-01-09 16:16:47 -06:00

60 lines
1.7 KiB
VB.net

Imports System
Imports System.IO
Imports Mal
Imports MalVal = Mal.types.MalVal
Namespace Mal
Class step1_read_print
' read
Shared Function READ(str As String) As MalVal
Return reader.read_str(str)
End Function
' eval
Shared Function EVAL(ast As MalVal, env As String) As MalVal
Return ast
End Function
' print
Shared Function PRINT(exp As MalVal) As String
return printer._pr_str(exp, TRUE)
End Function
' repl
Shared Function REP(str As String) As String
Return PRINT(EVAL(READ(str), ""))
End Function
Shared Function Main As Integer
Dim args As String() = Environment.GetCommandLineArgs()
If args.Length > 1 AndAlso args(1) = "--raw" Then
Mal.readline.SetMode(Mal.readline.Modes.Raw)
End If
' repl loop
Dim line As String
Do
Try
line = Mal.readline.Readline("user> ")
If line is Nothing Then
Exit Do
End If
If line = "" Then
Continue Do
End If
Catch e As IOException
Console.WriteLine("IOException: " & e.Message)
End Try
Try
Console.WriteLine(REP(line))
Catch e as Exception
Console.WriteLine("Error: " & e.Message)
Console.WriteLine(e.StackTrace)
Continue Do
End Try
Loop While True
End function
End Class
End Namespace