mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 21:35:03 +00:00
add support for vectors to quasiquote
This commit is contained in:
parent
25ba08a6e7
commit
dae6fe455f
@ -358,6 +358,25 @@ class Evaller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->quasiquoteLoop($data);
|
||||||
|
} elseif ($ast instanceof Vector) {
|
||||||
|
return new MList([
|
||||||
|
new Symbol('ltov'),
|
||||||
|
$this->quasiquoteLoop($ast->getData())
|
||||||
|
]);
|
||||||
|
} elseif ($ast instanceof Symbol || $ast instanceof Hash) {
|
||||||
|
// Quote other forms which are affected by evaluation
|
||||||
|
return new MList([
|
||||||
|
new Symbol('quote'),
|
||||||
|
$ast
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return $ast;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function quasiquoteLoop(array $data): MList
|
||||||
|
{
|
||||||
$result = new MList();
|
$result = new MList();
|
||||||
|
|
||||||
for ($i = count($data) - 1; $i >= 0; $i--) {
|
for ($i = count($data) - 1; $i >= 0; $i--) {
|
||||||
@ -383,11 +402,5 @@ class Evaller
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
} elseif ($ast instanceof Symbol || $ast instanceof Collection) {
|
|
||||||
// Quote other forms which are affected by evaluation
|
|
||||||
return new MList([new Symbol('quote'), $ast]);
|
|
||||||
} else {
|
|
||||||
return $ast;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user