From 51058b18d3cfd223401079902b0fb609dd7262fd Mon Sep 17 00:00:00 2001 From: Pekka Laiho Date: Sun, 31 May 2020 11:50:53 +0700 Subject: [PATCH] shortcut for quote --- src/Reader.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Reader.php b/src/Reader.php index 5882b9e..9724255 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -17,7 +17,14 @@ class Reader 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); } elseif ($tokens[$index] == '[') { return $this->readVector($tokens, $index);