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/step9_try.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/step9_try.vb')
| -rw-r--r-- | vb/step9_try.vb | 14 |
1 files changed, 6 insertions, 8 deletions
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> ") |
