diff options
| author | Joel Martin <github@martintribe.org> | 2014-11-15 23:51:59 -0600 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2015-01-09 16:16:47 -0600 |
| commit | aaba249304b184e12e2445ab22d66df1f39a51a5 (patch) | |
| tree | a3c7b1a0d683ef73ec030a390eca2922bfc9bc54 /vb | |
| parent | ee7cd5859e56423983f025088c8cef36b7ed09dd (diff) | |
| download | mal-aaba249304b184e12e2445ab22d66df1f39a51a5.tar.gz mal-aaba249304b184e12e2445ab22d66df1f39a51a5.zip | |
VB.Net, C#: fix cmd line arg handling with --raw
Diffstat (limited to 'vb')
| -rw-r--r-- | vb/step0_repl.vb | 4 | ||||
| -rw-r--r-- | vb/step1_read_print.vb | 4 | ||||
| -rw-r--r-- | vb/step2_eval.vb | 4 | ||||
| -rw-r--r-- | vb/step3_env.vb | 4 | ||||
| -rw-r--r-- | vb/step4_if_fn_do.vb | 4 | ||||
| -rw-r--r-- | vb/step5_tco.vb | 4 | ||||
| -rw-r--r-- | vb/step6_file.vb | 16 | ||||
| -rw-r--r-- | vb/step7_quote.vb | 16 | ||||
| -rw-r--r-- | vb/step8_macros.vb | 16 | ||||
| -rw-r--r-- | vb/step9_try.vb | 14 | ||||
| -rw-r--r-- | vb/stepA_interop.vb | 12 |
11 files changed, 48 insertions, 50 deletions
diff --git a/vb/step0_repl.vb b/vb/step0_repl.vb index ab8fe5e..f53f378 100644 --- a/vb/step0_repl.vb +++ b/vb/step0_repl.vb @@ -2,7 +2,7 @@ Imports System Imports Mal Namespace Mal - class step0_repl + Class step0_repl ' read Shared Function READ(str As String) As String Return str @@ -39,5 +39,5 @@ Namespace Mal Loop While True Return 0 End function - end class + End Class End Namespace diff --git a/vb/step1_read_print.vb b/vb/step1_read_print.vb index f8b47af..2734973 100644 --- a/vb/step1_read_print.vb +++ b/vb/step1_read_print.vb @@ -4,7 +4,7 @@ Imports Mal Imports MalVal = Mal.types.MalVal Namespace Mal - class step1_read_print + Class step1_read_print ' read Shared Function READ(str As String) As MalVal Return reader.read_str(str) @@ -55,5 +55,5 @@ Namespace Mal End Try Loop While True End function - end class + End Class End Namespace diff --git a/vb/step2_eval.vb b/vb/step2_eval.vb index 70bc5e3..6e45efe 100644 --- a/vb/step2_eval.vb +++ b/vb/step2_eval.vb @@ -11,7 +11,7 @@ Imports MalHashMap = Mal.types.MalHashMap Imports MalFunc = Mal.types.MalFunc Namespace Mal - class step2_eval + Class step2_eval ' read Shared Function READ(str As String) As MalVal Return reader.read_str(str) @@ -130,5 +130,5 @@ Namespace Mal End Try Loop While True End function - end class + End Class End Namespace diff --git a/vb/step3_env.vb b/vb/step3_env.vb index 2877ef1..5793fdb 100644 --- a/vb/step3_env.vb +++ b/vb/step3_env.vb @@ -12,7 +12,7 @@ Imports MalFunc = Mal.types.MalFunc Imports MalEnv = Mal.env.Env Namespace Mal - class step3_eval + Class step3_env ' read Shared Function READ(str As String) As MalVal Return reader.read_str(str) @@ -152,5 +152,5 @@ Namespace Mal End Try Loop While True End function - end class + End Class End Namespace diff --git a/vb/step4_if_fn_do.vb b/vb/step4_if_fn_do.vb index 2f5e16a..4cf8721 100644 --- a/vb/step4_if_fn_do.vb +++ b/vb/step4_if_fn_do.vb @@ -12,7 +12,7 @@ Imports MalFunc = Mal.types.MalFunc Imports MalEnv = Mal.env.Env Namespace Mal - class step4_if_fn_do + Class step4_if_fn_do ' read Shared Function READ(str As String) As MalVal Return reader.read_str(str) @@ -185,5 +185,5 @@ Namespace Mal End Try Loop While True End function - end class + End Class End Namespace diff --git a/vb/step5_tco.vb b/vb/step5_tco.vb index a379cf5..3c1f51c 100644 --- a/vb/step5_tco.vb +++ b/vb/step5_tco.vb @@ -12,7 +12,7 @@ Imports MalFunc = Mal.types.MalFunc Imports MalEnv = Mal.env.Env Namespace Mal - class step5_tco + Class step5_tco ' read Shared Function READ(str As String) As MalVal Return reader.read_str(str) @@ -194,5 +194,5 @@ Namespace Mal End Try Loop While True End function - end class + End Class End Namespace diff --git a/vb/step6_file.vb b/vb/step6_file.vb index 32cbe5b..58f8cd2 100644 --- a/vb/step6_file.vb +++ b/vb/step6_file.vb @@ -13,7 +13,7 @@ Imports MalFunc = Mal.types.MalFunc Imports MalEnv = Mal.env.Env Namespace Mal - class step6_file + Class step6_file ' read Shared Function READ(str As String) As MalVal Return reader.read_str(str) @@ -169,8 +169,13 @@ Namespace Mal repl_env.do_set(entry.Key, entry.Value) Next repl_env.do_set("eval", new MalFunc(AddressOf do_eval)) + Dim fileIdx As Integer = 1 + If args.Length > 1 AndAlso args(1) = "--raw" Then + Mal.readline.SetMode(Mal.readline.Modes.Raw) + fileIdx = 2 + End If Dim argv As New MalList() - For i As Integer = 0 To args.Length()-1 + For i As Integer = fileIdx+1 To args.Length-1 argv.conj_BANG(new MalString(args(i))) Next repl_env.do_set("*ARGV*", argv) @@ -179,11 +184,6 @@ Namespace Mal REP("(def! not (fn* (a) (if a false true)))") REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))") - Dim fileIdx As Integer = 1 - If args.Length > 1 AndAlso args(1) = "--raw" Then - Mal.readline.SetMode(Mal.readline.Modes.Raw) - fileIdx = 2 - End If If args.Length > fileIdx Then REP("(load-file """ & args(fileIdx) & """)") return 0 @@ -212,5 +212,5 @@ Namespace Mal End Try Loop While True End function - end class + End Class End Namespace diff --git a/vb/step7_quote.vb b/vb/step7_quote.vb index d3b6174..3f2d614 100644 --- a/vb/step7_quote.vb +++ b/vb/step7_quote.vb @@ -13,7 +13,7 @@ Imports MalFunc = Mal.types.MalFunc Imports MalEnv = Mal.env.Env Namespace Mal - class step7_quote + Class step7_quote ' read Shared Function READ(str As String) As MalVal Return reader.read_str(str) @@ -202,8 +202,13 @@ Namespace Mal repl_env.do_set(entry.Key, entry.Value) Next repl_env.do_set("eval", new MalFunc(AddressOf do_eval)) + Dim fileIdx As Integer = 1 + If args.Length > 1 AndAlso args(1) = "--raw" Then + Mal.readline.SetMode(Mal.readline.Modes.Raw) + fileIdx = 2 + End If Dim argv As New MalList() - For i As Integer = 0 To args.Length()-1 + For i As Integer = fileIdx+1 To args.Length-1 argv.conj_BANG(new MalString(args(i))) Next repl_env.do_set("*ARGV*", argv) @@ -212,11 +217,6 @@ Namespace Mal REP("(def! not (fn* (a) (if a false true)))") REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))") - Dim fileIdx As Integer = 1 - If args.Length > 1 AndAlso args(1) = "--raw" Then - Mal.readline.SetMode(Mal.readline.Modes.Raw) - fileIdx = 2 - End If If args.Length > fileIdx Then REP("(load-file """ & args(fileIdx) & """)") return 0 @@ -245,5 +245,5 @@ Namespace Mal End Try Loop While True End function - end class + End Class End Namespace diff --git a/vb/step8_macros.vb b/vb/step8_macros.vb index 5a5fc77..1a7f211 100644 --- a/vb/step8_macros.vb +++ b/vb/step8_macros.vb @@ -13,7 +13,7 @@ Imports MalFunc = Mal.types.MalFunc Imports MalEnv = Mal.env.Env Namespace Mal - class step8_macros + Class step8_macros ' read Shared Function READ(str As String) As MalVal Return reader.read_str(str) @@ -240,8 +240,13 @@ Namespace Mal repl_env.do_set(entry.Key, entry.Value) Next repl_env.do_set("eval", new MalFunc(AddressOf do_eval)) + Dim fileIdx As Integer = 1 + If args.Length > 1 AndAlso args(1) = "--raw" Then + Mal.readline.SetMode(Mal.readline.Modes.Raw) + fileIdx = 2 + End If Dim argv As New MalList() - For i As Integer = 0 To args.Length()-1 + For i As Integer = fileIdx+1 To args.Length-1 argv.conj_BANG(new MalString(args(i))) Next repl_env.do_set("*ARGV*", argv) @@ -252,11 +257,6 @@ Namespace Mal REP("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ""odd number of forms to cond"")) (cons 'cond (rest (rest xs)))))))") REP("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))") - Dim fileIdx As Integer = 1 - If args.Length > 1 AndAlso args(1) = "--raw" Then - Mal.readline.SetMode(Mal.readline.Modes.Raw) - fileIdx = 2 - End If If args.Length > fileIdx Then REP("(load-file """ & args(fileIdx) & """)") return 0 @@ -285,5 +285,5 @@ Namespace Mal End Try Loop While True End function - end class + End Class End Namespace diff --git a/vb/step9_try.vb b/vb/step9_try.vb index 0b888b7..5bf600d 100644 --- a/vb/step9_try.vb +++ b/vb/step9_try.vb @@ -263,24 +263,23 @@ Namespace Mal repl_env.do_set(entry.Key, entry.Value) Next repl_env.do_set("eval", new MalFunc(AddressOf do_eval)) + Dim fileIdx As Integer = 1 + If args.Length > 1 AndAlso args(1) = "--raw" Then + Mal.readline.SetMode(Mal.readline.Modes.Raw) + fileIdx = 2 + End If Dim argv As New MalList() - For i As Integer = 0 To args.Length()-1 + For i As Integer = fileIdx+1 To args.Length-1 argv.conj_BANG(new MalString(args(i))) Next repl_env.do_set("*ARGV*", argv) ' core.mal: defined using the language itself - REP("(def! *host-language* ""VB.NET"")") REP("(def! not (fn* (a) (if a false true)))") REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))") REP("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ""odd number of forms to cond"")) (cons 'cond (rest (rest xs)))))))") REP("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))") - Dim fileIdx As Integer = 1 - If args.Length > 1 AndAlso args(1) = "--raw" Then - Mal.readline.SetMode(Mal.readline.Modes.Raw) - fileIdx = 2 - End If If args.Length > fileIdx Then REP("(load-file """ & args(fileIdx) & """)") return 0 @@ -288,7 +287,6 @@ Namespace Mal ' repl loop Dim line As String - REP("(println (str ""Mal ["" *host-language* ""]""))") Do Try line = Mal.readline.Readline("user> ") diff --git a/vb/stepA_interop.vb b/vb/stepA_interop.vb index 713954d..01702fa 100644 --- a/vb/stepA_interop.vb +++ b/vb/stepA_interop.vb @@ -263,8 +263,13 @@ Namespace Mal repl_env.do_set(entry.Key, entry.Value) Next repl_env.do_set("eval", new MalFunc(AddressOf do_eval)) + Dim fileIdx As Integer = 1 + If args.Length > 1 AndAlso args(1) = "--raw" Then + Mal.readline.SetMode(Mal.readline.Modes.Raw) + fileIdx = 2 + End If Dim argv As New MalList() - For i As Integer = 0 To args.Length()-1 + For i As Integer = fileIdx+1 To args.Length-1 argv.conj_BANG(new MalString(args(i))) Next repl_env.do_set("*ARGV*", argv) @@ -276,11 +281,6 @@ Namespace Mal REP("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ""odd number of forms to cond"")) (cons 'cond (rest (rest xs)))))))") REP("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))") - Dim fileIdx As Integer = 1 - If args.Length > 1 AndAlso args(1) = "--raw" Then - Mal.readline.SetMode(Mal.readline.Modes.Raw) - fileIdx = 2 - End If If args.Length > fileIdx Then REP("(load-file """ & args(fileIdx) & """)") return 0 |
