diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-19 13:04:09 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-19 13:04:09 -0500 |
| commit | 86b689f3d7111a9fa13da389a30f3dfdf877d1a4 (patch) | |
| tree | d72b065f9f987e291f892ceee5a8640363bfd9df /cs | |
| parent | 718887c3019c49fc807bc18fbd5feb975ec03c85 (diff) | |
| download | mal-86b689f3d7111a9fa13da389a30f3dfdf877d1a4.tar.gz mal-86b689f3d7111a9fa13da389a30f3dfdf877d1a4.zip | |
All: *ARGV* and *host-language*. Misc syncing/fixes.
Diffstat (limited to 'cs')
| -rw-r--r-- | cs/Makefile | 2 | ||||
| -rw-r--r-- | cs/step0_repl.cs | 2 | ||||
| -rw-r--r-- | cs/step1_read_print.cs | 2 | ||||
| -rw-r--r-- | cs/step2_eval.cs | 2 | ||||
| -rw-r--r-- | cs/step3_env.cs | 4 | ||||
| -rw-r--r-- | cs/step4_if_fn_do.cs | 4 | ||||
| -rw-r--r-- | cs/step5_tco.cs | 4 | ||||
| -rw-r--r-- | cs/step6_file.cs | 14 | ||||
| -rw-r--r-- | cs/step7_quote.cs | 13 | ||||
| -rw-r--r-- | cs/step8_macros.cs | 13 | ||||
| -rw-r--r-- | cs/stepA_more.cs | 14 |
11 files changed, 51 insertions, 23 deletions
diff --git a/cs/Makefile b/cs/Makefile index f8aefcc..b7eb023 100644 --- a/cs/Makefile +++ b/cs/Makefile @@ -34,7 +34,7 @@ mal.dll: $(LIB_SRCS) mcs $(FLAGS) -r:mal.dll $< clean: - rm -f *.dll *.exe *.mbd + rm -f *.dll *.exe *.mdb .PHONY: stats tests $(TESTS) diff --git a/cs/step0_repl.cs b/cs/step0_repl.cs index de7a6de..616e154 100644 --- a/cs/step0_repl.cs +++ b/cs/step0_repl.cs @@ -19,7 +19,7 @@ namespace Mal { return exp; } - // REPL + // repl static string RE(string env, string str) { return EVAL(READ(str), env); } diff --git a/cs/step1_read_print.cs b/cs/step1_read_print.cs index 62cd7ad..1b427c8 100644 --- a/cs/step1_read_print.cs +++ b/cs/step1_read_print.cs @@ -20,7 +20,7 @@ namespace Mal { return printer._pr_str(exp, true); } - // REPL + // repl static MalVal RE(string env, string str) { return EVAL(READ(str), env); } diff --git a/cs/step2_eval.cs b/cs/step2_eval.cs index dc467de..1a95a81 100644 --- a/cs/step2_eval.cs +++ b/cs/step2_eval.cs @@ -69,7 +69,7 @@ namespace Mal { return printer._pr_str(exp, true); } - // REPL + // repl static MalVal RE(Dictionary<string, MalVal> env, string str) { return EVAL(READ(str), env); } diff --git a/cs/step3_env.cs b/cs/step3_env.cs index ba859eb..2be7992 100644 --- a/cs/step3_env.cs +++ b/cs/step3_env.cs @@ -92,7 +92,7 @@ namespace Mal { return printer._pr_str(exp, true); } - // REPL + // repl static MalVal RE(Env env, string str) { return EVAL(READ(str), env); } @@ -119,6 +119,8 @@ namespace Mal { if (args.Length > 0 && args[0] == "--raw") { Mal.readline.mode = Mal.readline.Mode.Raw; } + + // repl loop while (true) { string line; try { diff --git a/cs/step4_if_fn_do.cs b/cs/step4_if_fn_do.cs index 2383c31..659fc18 100644 --- a/cs/step4_if_fn_do.cs +++ b/cs/step4_if_fn_do.cs @@ -116,7 +116,7 @@ namespace Mal { return printer._pr_str(exp, true); } - // REPL + // repl static MalVal RE(Env env, string str) { return EVAL(READ(str), env); } @@ -136,6 +136,8 @@ namespace Mal { if (args.Length > 0 && args[0] == "--raw") { Mal.readline.mode = Mal.readline.Mode.Raw; } + + // repl loop while (true) { string line; try { diff --git a/cs/step5_tco.cs b/cs/step5_tco.cs index b04d16e..95df860 100644 --- a/cs/step5_tco.cs +++ b/cs/step5_tco.cs @@ -128,7 +128,7 @@ namespace Mal { return printer._pr_str(exp, true); } - // REPL + // repl static MalVal RE(Env env, string str) { return EVAL(READ(str), env); } @@ -148,6 +148,8 @@ namespace Mal { if (args.Length > 0 && args[0] == "--raw") { Mal.readline.mode = Mal.readline.Mode.Raw; } + + // repl loop while (true) { string line; try { diff --git a/cs/step6_file.cs b/cs/step6_file.cs index cb2157e..db1a7b2 100644 --- a/cs/step6_file.cs +++ b/cs/step6_file.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Collections.Generic; using Mal; using MalVal = Mal.types.MalVal; +using MalString = Mal.types.MalString; using MalSymbol = Mal.types.MalSymbol; using MalInteger = Mal.types.MalInteger; using MalList = Mal.types.MalList; @@ -128,7 +129,7 @@ namespace Mal { return printer._pr_str(exp, true); } - // REPL + // repl static MalVal RE(Env env, string str) { return EVAL(READ(str), env); } @@ -142,6 +143,11 @@ namespace Mal { repl_env.set(entry.Key, entry.Value); } repl_env.set("eval", new MalFunction(a => EVAL(a[0], repl_env))); + MalList _argv = new MalList(); + for (int i=1; i < args.Length; i++) { + _argv.conj_BANG(new MalString(args[i])); + } + repl_env.set("*ARGV*", _argv); // core.mal: defined using the language itself RE(repl_env, "(def! not (fn* (a) (if a false true)))"); @@ -153,11 +159,11 @@ namespace Mal { fileIdx = 1; } if (args.Length > fileIdx) { - for(int i=fileIdx; i<args.Length; i++) { - RE(repl_env, "(load-file \"" + args[i] + "\")"); - } + RE(repl_env, "(load-file \"" + args[fileIdx] + "\")"); return; } + + // repl loop while (true) { string line; try { diff --git a/cs/step7_quote.cs b/cs/step7_quote.cs index 6f08abb..d803ac2 100644 --- a/cs/step7_quote.cs +++ b/cs/step7_quote.cs @@ -160,7 +160,7 @@ namespace Mal { return printer._pr_str(exp, true); } - // REPL + // repl static MalVal RE(Env env, string str) { return EVAL(READ(str), env); } @@ -174,6 +174,11 @@ namespace Mal { repl_env.set(entry.Key, entry.Value); } repl_env.set("eval", new MalFunction(a => EVAL(a[0], repl_env))); + MalList _argv = new MalList(); + for (int i=1; i < args.Length; i++) { + _argv.conj_BANG(new MalString(args[i])); + } + repl_env.set("*ARGV*", _argv); // core.mal: defined using the language itself RE(repl_env, "(def! not (fn* (a) (if a false true)))"); @@ -185,11 +190,11 @@ namespace Mal { fileIdx = 1; } if (args.Length > fileIdx) { - for(int i=fileIdx; i<args.Length; i++) { - RE(repl_env, "(load-file \"" + args[i] + "\")"); - } + RE(repl_env, "(load-file \"" + args[fileIdx] + "\")"); return; } + + // repl loop while (true) { string line; try { diff --git a/cs/step8_macros.cs b/cs/step8_macros.cs index caa8f0a..af98fe9 100644 --- a/cs/step8_macros.cs +++ b/cs/step8_macros.cs @@ -197,7 +197,7 @@ namespace Mal { return printer._pr_str(exp, true); } - // REPL + // repl static MalVal RE(Env env, string str) { return EVAL(READ(str), env); } @@ -211,6 +211,11 @@ namespace Mal { repl_env.set(entry.Key, entry.Value); } repl_env.set("eval", new MalFunction(a => EVAL(a[0], repl_env))); + MalList _argv = new MalList(); + for (int i=1; i < args.Length; i++) { + _argv.conj_BANG(new MalString(args[i])); + } + repl_env.set("*ARGV*", _argv); // core.mal: defined using the language itself RE(repl_env, "(def! not (fn* (a) (if a false true)))"); @@ -224,11 +229,11 @@ namespace Mal { fileIdx = 1; } if (args.Length > fileIdx) { - for(int i=fileIdx; i<args.Length; i++) { - RE(repl_env, "(load-file \"" + args[i] + "\")"); - } + RE(repl_env, "(load-file \"" + args[fileIdx] + "\")"); return; } + + // repl loop while (true) { string line; try { diff --git a/cs/stepA_more.cs b/cs/stepA_more.cs index dbbf53d..4fa8387 100644 --- a/cs/stepA_more.cs +++ b/cs/stepA_more.cs @@ -218,7 +218,7 @@ namespace Mal { return printer._pr_str(exp, true); } - // REPL + // repl static MalVal RE(Env env, string str) { return EVAL(READ(str), env); } @@ -232,6 +232,11 @@ namespace Mal { repl_env.set(entry.Key, entry.Value); } repl_env.set("eval", new MalFunction(a => EVAL(a[0], repl_env))); + MalList _argv = new MalList(); + for (int i=1; i < args.Length; i++) { + _argv.conj_BANG(new MalString(args[i])); + } + repl_env.set("*ARGV*", _argv); // core.mal: defined using the language itself RE(repl_env, "(def! *host-language* \"c#\")"); @@ -246,11 +251,12 @@ namespace Mal { fileIdx = 1; } if (args.Length > fileIdx) { - for(int i=fileIdx; i<args.Length; i++) { - RE(repl_env, "(load-file \"" + args[i] + "\")"); - } + RE(repl_env, "(load-file \"" + args[fileIdx] + "\")"); return; } + + // repl loop + RE(repl_env, "(println (str \"Mal [\" *host-language* \"]\"))"); while (true) { string line; try { |
