From 794bfca1361fc6900f0ea0186d64111c3a02b0f8 Mon Sep 17 00:00:00 2001 From: Chouser Date: Mon, 16 Feb 2015 21:28:05 -0500 Subject: forth: Add step 7 --- forth/reader.fs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'forth/reader.fs') diff --git a/forth/reader.fs b/forth/reader.fs index 6547a79..1daa650 100644 --- a/forth/reader.fs +++ b/forth/reader.fs @@ -98,9 +98,15 @@ defer read-form ( str-addr str-len -- str-addr str-len mal-obj ) drop adv-str old-here here>MalList ; +s" deref" MalSymbol. constant deref-sym +s" quote" MalSymbol. constant quote-sym +s" quasiquote" MalSymbol. constant quasiquote-sym +s" splice-unquote" MalSymbol. constant splice-unquote-sym +s" unquote" MalSymbol. constant unquote-sym + : read-wrapped ( buf-addr buf-len quote-char sym-addr sym-len -- buf-addr buf-len char mal-list ) here { old-here } - MalSymbol. , ( buf-addr buf-len char ) + , ( buf-addr buf-len char ) read-form , ( buf-addr buf-len char ) old-here here>MalList ; @@ -112,13 +118,13 @@ defer read-form ( str-addr str-len -- str-addr str-len mal-obj ) dup [char] { = if [char] } read-list MalMap new tuck MalMap/list ! else dup [char] " = if read-string-literal else dup [char] : = if drop adv-str read-symbol-str MalKeyword. else - dup [char] @ = if drop adv-str s" deref" read-wrapped else - dup [char] ' = if drop adv-str s" quote" read-wrapped else - dup [char] ` = if drop adv-str s" quasiquote" read-wrapped else + dup [char] @ = if drop adv-str deref-sym read-wrapped else + dup [char] ' = if drop adv-str quote-sym read-wrapped else + dup [char] ` = if drop adv-str quasiquote-sym read-wrapped else dup [char] ~ = if drop adv-str - dup [char] @ = if drop adv-str s" splice-unquote" read-wrapped - else s" unquote" read-wrapped + dup [char] @ = if drop adv-str splice-unquote-sym read-wrapped + else unquote-sym read-wrapped endif else dup [char] ^ = if -- cgit v1.2.3