Skip to content

Commit

Permalink
io: implement DEBUG-EVAL
Browse files Browse the repository at this point in the history
  • Loading branch information
asarhaddon committed Oct 25, 2024
1 parent 3b16c39 commit 46adc4b
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions impls/io/step2_eval.io
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ eval_ast := method(ast, env,
)

EVAL := method(ast, env,

// ("EVAL: " .. PRINT(ast)) println

if(ast type != "MalList", return(eval_ast(ast, env)))
if(ast isEmpty, return ast)
el := eval_ast(ast, env)
Expand Down
7 changes: 7 additions & 0 deletions impls/io/step3_env.io
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ eval_ast := method(ast, env,
)
)

debugEvalSymbol := MalSymbol with("DEBUG-EVAL")

EVAL := method(ast, env,

debugEvalEnv := env find(debugEvalSymbol)
if((debugEvalEnv isNil not) and (debugEvalEnv get(debugEvalSymbol)),
("EVAL: " .. PRINT(ast)) println)

if(ast type != "MalList", return(eval_ast(ast, env)))
if(ast isEmpty, return ast)
if(ast at(0) type == "MalSymbol",
Expand Down
7 changes: 7 additions & 0 deletions impls/io/step4_if_fn_do.io
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ eval_ast := method(ast, env,
)
)

debugEvalSymbol := MalSymbol with("DEBUG-EVAL")

EVAL := method(ast, env,

debugEvalEnv := env find(debugEvalSymbol)
if((debugEvalEnv isNil not) and (debugEvalEnv get(debugEvalSymbol)),
("EVAL: " .. PRINT(ast)) println)

if(ast type != "MalList", return(eval_ast(ast, env)))
if(ast isEmpty, return ast)
if(ast at(0) type == "MalSymbol",
Expand Down
7 changes: 7 additions & 0 deletions impls/io/step5_tco.io
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ eval_ast := method(ast, env,
)
)

debugEvalSymbol := MalSymbol with("DEBUG-EVAL")

EVAL := method(ast, env,
loop(

debugEvalEnv := env find(debugEvalSymbol)
if((debugEvalEnv isNil not) and (debugEvalEnv get(debugEvalSymbol)),
("EVAL: " .. PRINT(ast)) println)

if(ast type != "MalList", return(eval_ast(ast, env)))
if(ast isEmpty, return ast)
if(ast at(0) type == "MalSymbol",
Expand Down
7 changes: 7 additions & 0 deletions impls/io/step6_file.io
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ eval_ast := method(ast, env,
)
)

debugEvalSymbol := MalSymbol with("DEBUG-EVAL")

EVAL := method(ast, env,
loop(

debugEvalEnv := env find(debugEvalSymbol)
if((debugEvalEnv isNil not) and (debugEvalEnv get(debugEvalSymbol)),
("EVAL: " .. PRINT(ast)) println)

if(ast type != "MalList", return(eval_ast(ast, env)))
if(ast isEmpty, return ast)
if(ast at(0) type == "MalSymbol",
Expand Down
7 changes: 7 additions & 0 deletions impls/io/step7_quote.io
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ eval_ast := method(ast, env,
)
)

debugEvalSymbol := MalSymbol with("DEBUG-EVAL")

EVAL := method(ast, env,
loop(

debugEvalEnv := env find(debugEvalSymbol)
if((debugEvalEnv isNil not) and (debugEvalEnv get(debugEvalSymbol)),
("EVAL: " .. PRINT(ast)) println)

if(ast type != "MalList", return(eval_ast(ast, env)))
if(ast isEmpty, return ast)
if(ast at(0) type == "MalSymbol",
Expand Down
7 changes: 7 additions & 0 deletions impls/io/step8_macros.io
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ eval_ast := method(ast, env,
)
)

debugEvalSymbol := MalSymbol with("DEBUG-EVAL")

EVAL := method(ast, env,
loop(

debugEvalEnv := env find(debugEvalSymbol)
if((debugEvalEnv isNil not) and (debugEvalEnv get(debugEvalSymbol)),
("EVAL: " .. PRINT(ast)) println)

if(ast type != "MalList", return(eval_ast(ast, env)))

ast = macroexpand(ast, env)
Expand Down
7 changes: 7 additions & 0 deletions impls/io/step9_try.io
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ eval_ast := method(ast, env,
)
)

debugEvalSymbol := MalSymbol with("DEBUG-EVAL")

EVAL := method(ast, env,
loop(

debugEvalEnv := env find(debugEvalSymbol)
if((debugEvalEnv isNil not) and (debugEvalEnv get(debugEvalSymbol)),
("EVAL: " .. PRINT(ast)) println)

if(ast type != "MalList", return(eval_ast(ast, env)))

ast = macroexpand(ast, env)
Expand Down
7 changes: 7 additions & 0 deletions impls/io/stepA_mal.io
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ eval_ast := method(ast, env,
)
)

debugEvalSymbol := MalSymbol with("DEBUG-EVAL")

EVAL := method(ast, env,
loop(

debugEvalEnv := env find(debugEvalSymbol)
if((debugEvalEnv isNil not) and (debugEvalEnv get(debugEvalSymbol)),
("EVAL: " .. PRINT(ast)) println)

if(ast type != "MalList", return(eval_ast(ast, env)))

ast = macroexpand(ast, env)
Expand Down

0 comments on commit 46adc4b

Please sign in to comment.