shortcut for quote

This commit is contained in:
Pekka Laiho 2020-05-31 11:50:53 +07:00
parent 9e03179650
commit 51058b18d3

View File

@ -17,7 +17,14 @@ class Reader
private function readForm(array $tokens, int &$index) private function readForm(array $tokens, int &$index)
{ {
if ($tokens[$index] == '(') { if ($tokens[$index] == "'") {
$index++;
$contents = [new Symbol('quote')];
if ($index < count($tokens) && !in_array($tokens[$index], [')', ']', '}'])) {
$contents[] = $this->readForm($tokens, $index);
}
return new MList($contents);
} elseif ($tokens[$index] == '(') {
return $this->readList($tokens, $index); return $this->readList($tokens, $index);
} elseif ($tokens[$index] == '[') { } elseif ($tokens[$index] == '[') {
return $this->readVector($tokens, $index); return $this->readVector($tokens, $index);