1
1
mirror of https://github.com/kanaka/mal.git synced 2024-10-26 14:22:25 +03:00
mal/impls/vb/step1_read_print.vb
Joel Martin 8a19f60386 Move implementations into impls/ dir
- Reorder README to have implementation list after "learning tool"
  bullet.

- This also moves tests/ and libs/ into impls. It would be preferrable
  to have these directories at the top level.  However, this causes
  difficulties with the wasm implementations which need pre-open
  directories and have trouble with paths starting with "../../". So
  in lieu of that, symlink those directories to the top-level.

- Move the run_argv_test.sh script into the tests directory for
  general hygiene.
2020-02-10 23:50:16 -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