Exemplo n.º 1
0
<?php

require_once 'symbol.php';
require_once 'reader.php';
$buf = "";
while (!feof(STDIN)) {
    $buf .= fgets(STDIN);
}
$x = Reader::tok($buf);
$x = Reader::read($x);
function gensym()
{
    static $FUNCTIONAL_TABLE = array();
    $x = rand_str(5);
    for ($x = rand_str(5); in_array($x, $FUNCTIONAL_TABLE); $x = rand_str()) {
    }
    array_push($FUNCTIONAL_TABLE, $x);
    return $x;
}
function compile($expr, &$oob)
{
    global $ENVIRONMENT;
    if (is_array($expr)) {
        switch ($expr[0] . "") {
            case "def":
                return compile_def($expr, $oob);
            case "define":
                return compile_def($expr, $oob);
            case "fn":
                return compile_fn($expr, $oob);
            case "λ":