aboutsummaryrefslogtreecommitdiff
path: root/php
diff options
context:
space:
mode:
Diffstat (limited to 'php')
-rw-r--r--php/step0_repl.php8
-rw-r--r--php/step1_read_print.php4
-rw-r--r--php/step2_eval.php4
-rw-r--r--php/step3_env.php4
-rw-r--r--php/step4_if_fn_do.php4
-rw-r--r--php/step5_tco.php4
-rw-r--r--php/step6_file.php4
-rw-r--r--php/step7_quote.php4
-rw-r--r--php/step8_macros.php4
-rw-r--r--php/step9_try.php4
-rw-r--r--php/stepA_mal.php4
11 files changed, 24 insertions, 24 deletions
diff --git a/php/step0_repl.php b/php/step0_repl.php
index eecb052..421173c 100644
--- a/php/step0_repl.php
+++ b/php/step0_repl.php
@@ -9,12 +9,12 @@ function READ($str) {
// eval
function MAL_EVAL($ast, $env) {
- return eval($ast);
+ return $ast;
}
// print
function MAL_PRINT($exp) {
- return var_export($exp, true) . "\n";
+ return $exp;
}
// repl
@@ -26,8 +26,8 @@ function rep($str) {
do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
- if (!empty($line)) {
- print(rep($line));
+ if ($line !== "") {
+ print(rep($line) . "\n");
}
} while (true);
diff --git a/php/step1_read_print.php b/php/step1_read_print.php
index c9c5267..b1f18a8 100644
--- a/php/step1_read_print.php
+++ b/php/step1_read_print.php
@@ -17,7 +17,7 @@ function MAL_EVAL($ast, $env) {
// print
function MAL_PRINT($exp) {
- return _pr_str($exp, True) . "\n";
+ return _pr_str($exp, True);
}
// repl
@@ -31,7 +31,7 @@ do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
if ($line !== "") {
- print(rep($line));
+ print(rep($line) . "\n");
}
} catch (BlankException $e) {
continue;
diff --git a/php/step2_eval.php b/php/step2_eval.php
index b9d2e8e..e96e8fd 100644
--- a/php/step2_eval.php
+++ b/php/step2_eval.php
@@ -46,7 +46,7 @@ function MAL_EVAL($ast, $env) {
// print
function MAL_PRINT($exp) {
- return _pr_str($exp, True) . "\n";
+ return _pr_str($exp, True);
}
// repl
@@ -67,7 +67,7 @@ do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
if ($line !== "") {
- print(rep($line));
+ print(rep($line) . "\n");
}
} catch (BlankException $e) {
continue;
diff --git a/php/step3_env.php b/php/step3_env.php
index a31c298..9da2fd2 100644
--- a/php/step3_env.php
+++ b/php/step3_env.php
@@ -63,7 +63,7 @@ function MAL_EVAL($ast, $env) {
// print
function MAL_PRINT($exp) {
- return _pr_str($exp, True) . "\n";
+ return _pr_str($exp, True);
}
// repl
@@ -84,7 +84,7 @@ do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
if ($line !== "") {
- print(rep($line));
+ print(rep($line) . "\n");
}
} catch (BlankException $e) {
continue;
diff --git a/php/step4_if_fn_do.php b/php/step4_if_fn_do.php
index 7266261..4601112 100644
--- a/php/step4_if_fn_do.php
+++ b/php/step4_if_fn_do.php
@@ -81,7 +81,7 @@ function MAL_EVAL($ast, $env) {
// print
function MAL_PRINT($exp) {
- return _pr_str($exp, True) . "\n";
+ return _pr_str($exp, True);
}
// repl
@@ -105,7 +105,7 @@ do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
if ($line !== "") {
- print(rep($line));
+ print(rep($line) . "\n");
}
} catch (BlankException $e) {
continue;
diff --git a/php/step5_tco.php b/php/step5_tco.php
index a3785cf..283e47e 100644
--- a/php/step5_tco.php
+++ b/php/step5_tco.php
@@ -93,7 +93,7 @@ function MAL_EVAL($ast, $env) {
// print
function MAL_PRINT($exp) {
- return _pr_str($exp, True) . "\n";
+ return _pr_str($exp, True);
}
// repl
@@ -117,7 +117,7 @@ do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
if ($line !== "") {
- print(rep($line));
+ print(rep($line) . "\n");
}
} catch (BlankException $e) {
continue;
diff --git a/php/step6_file.php b/php/step6_file.php
index a27acb8..eaa765a 100644
--- a/php/step6_file.php
+++ b/php/step6_file.php
@@ -93,7 +93,7 @@ function MAL_EVAL($ast, $env) {
// print
function MAL_PRINT($exp) {
- return _pr_str($exp, True) . "\n";
+ return _pr_str($exp, True);
}
// repl
@@ -131,7 +131,7 @@ do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
if ($line !== "") {
- print(rep($line));
+ print(rep($line) . "\n");
}
} catch (BlankException $e) {
continue;
diff --git a/php/step7_quote.php b/php/step7_quote.php
index 37903d0..cb98825 100644
--- a/php/step7_quote.php
+++ b/php/step7_quote.php
@@ -117,7 +117,7 @@ function MAL_EVAL($ast, $env) {
// print
function MAL_PRINT($exp) {
- return _pr_str($exp, True) . "\n";
+ return _pr_str($exp, True);
}
// repl
@@ -155,7 +155,7 @@ do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
if ($line !== "") {
- print(rep($line));
+ print(rep($line) . "\n");
}
} catch (BlankException $e) {
continue;
diff --git a/php/step8_macros.php b/php/step8_macros.php
index c7e0175..d3d22d8 100644
--- a/php/step8_macros.php
+++ b/php/step8_macros.php
@@ -142,7 +142,7 @@ function MAL_EVAL($ast, $env) {
// print
function MAL_PRINT($exp) {
- return _pr_str($exp, True) . "\n";
+ return _pr_str($exp, True);
}
// repl
@@ -182,7 +182,7 @@ do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
if ($line !== "") {
- print(rep($line));
+ print(rep($line) . "\n");
}
} catch (BlankException $e) {
continue;
diff --git a/php/step9_try.php b/php/step9_try.php
index 0470763..bb7fd27 100644
--- a/php/step9_try.php
+++ b/php/step9_try.php
@@ -160,7 +160,7 @@ function MAL_EVAL($ast, $env) {
// print
function MAL_PRINT($exp) {
- return _pr_str($exp, True) . "\n";
+ return _pr_str($exp, True);
}
// repl
@@ -200,7 +200,7 @@ do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
if ($line !== "") {
- print(rep($line));
+ print(rep($line) . "\n");
}
} catch (BlankException $e) {
continue;
diff --git a/php/stepA_mal.php b/php/stepA_mal.php
index 1dc3b04..bac0f97 100644
--- a/php/stepA_mal.php
+++ b/php/stepA_mal.php
@@ -174,7 +174,7 @@ function MAL_EVAL($ast, $env) {
// print
function MAL_PRINT($exp) {
- return _pr_str($exp, True) . "\n";
+ return _pr_str($exp, True);
}
// repl
@@ -216,7 +216,7 @@ do {
$line = mal_readline("user> ");
if ($line === NULL) { break; }
if ($line !== "") {
- print(rep($line));
+ print(rep($line) . "\n");
}
} catch (BlankException $e) {
continue;