Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More tutorial.

  • Loading branch information...
commit 9690407232167dd6486ba03a0f2ff3859fd4a55f 1 parent d2eaada
@dahlia dahlia authored
Showing with 21 additions and 8 deletions.
  1. +17 −7 README.markdown
  2. +4 −1 lis.php
View
24 README.markdown
@@ -40,19 +40,29 @@ Simple tutorial
---------------
>>> (+ 12 34)
- 46
+ ==> 46
>>> (- 1 2)
- -1
+ ==> -1
>>> (* 5 6)
- 30
+ ==> 30
>>> (/ 30 5)
- 6
+ ==> 6
>>> (/ 30 4)
- 7.5
+ ==> 7.5
>>> (% 30 4)
- 2
+ ==> 2
>>> (. "hello" "world")
- 'helloworld'
+ ==> 'helloworld'
+ >>> (define pi 3.14)
+ ==> 3.14
+ >>> pi
+ ==> 3.14
+ >>> (float? pi)
+ ==> true
+ >>> (string? "abc")
+ ==> true
+ >>> (* pi 10 10)
+ ==> 314
Embed in your app
View
5 lis.php
@@ -3,6 +3,8 @@
define('LISPHP_COLUMN', 80);
define('LISPHP_REPL_PROMPT', '>>> ');
+define('LISPHP_REPL_VALUE_PROMPT', '==> ');
+define('LISPHP_REPL_EXCEPTION_PROMPT', '!!! ');
function Lisphp_usage() {
static $commands = array(
@@ -102,12 +104,13 @@ class Lisphp_EnterREPL extends Exception {}
else if (trim($code) == '') continue;
try {
$form = Lisphp_Parser::parseForm($code, $_);
+ echo LISPHP_REPL_VALUE_PROMPT;
var_export($form->evaluate($scope));
echo "\n";
} catch (Lisphp_ParsingException $e) {
Lisphp_printParsingError($e);
} catch (Exception $e) {
- echo '!!! ', $e->getMessage(), "\n",
+ echo LISPHP_REPL_EXCEPTION_PROMPT, $e->getMessage(), "\n",
preg_replace('/^|\n/', '\\0 ', $e->getTraceAsString()),
"\n";
}
Please sign in to comment.
Something went wrong with that request. Please try again.