mirror of
https://github.com/kanaka/mal.git
synced 2024-10-27 06:40:14 +03:00
8a19f60386
- 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.
42 lines
592 B
Plaintext
42 lines
592 B
Plaintext
import .Printer;
|
|
import .Reader;
|
|
import .Readline;
|
|
import .Types;
|
|
|
|
Val READ(string str)
|
|
{
|
|
return read_str(str);
|
|
}
|
|
|
|
Val EVAL(Val ast, string env)
|
|
{
|
|
return ast;
|
|
}
|
|
|
|
string PRINT(Val exp)
|
|
{
|
|
return pr_str(exp, true);
|
|
}
|
|
|
|
string rep(string str)
|
|
{
|
|
return PRINT(EVAL(READ(str), ""));
|
|
}
|
|
|
|
int main()
|
|
{
|
|
while(1)
|
|
{
|
|
string line = readline("user> ");
|
|
if(!line) break;
|
|
if(strlen(line) == 0) continue;
|
|
if(mixed err = catch { write(({ rep(line), "\n" })); } )
|
|
{
|
|
if(arrayp(err)) err = err[0];
|
|
write(({ "Error: ", err, "\n" }));
|
|
}
|
|
}
|
|
write("\n");
|
|
return 0;
|
|
}
|