aboutsummaryrefslogtreecommitdiff
path: root/vb/step0_repl.vb
blob: 388059852313abadc110e4eeb1164817c38670ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Imports System
Imports Mal

Namespace Mal
    Class step0_repl
        ' read
        Shared Function READ(str As String) As String
            Return str
        End Function

        ' eval
        Shared Function EVAL(ast As String, env As String) As String
            Return ast
        End Function
        
        ' print
        Shared Function PRINT(exp As String) As String
            Return exp
        End Function

        ' repl
        Shared Function REP(str As String, env As String) As String
            Return PRINT(EVAL(READ(str), env))
        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
                line = Mal.readline.Readline("user> ")
                If line is Nothing Then
                    Exit Do
                End If
                If line = "" Then
                    Continue Do
                End If
                Console.WriteLine(REP(line, ""))
            Loop While True
            Return 0
        End function
    End Class
End Namespace