The Lambda Lab
/
projects
/
scheme.forth.jl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ab2c14c
)
Fiddling with parser (reader?)
author
Tim Vaughan
<tgvaughan@gmail.com>
Sun, 12 Jun 2016 08:28:59 +0000
(20:28 +1200)
committer
Tim Vaughan
<tgvaughan@gmail.com>
Sun, 12 Jun 2016 08:28:59 +0000
(20:28 +1200)
scheme.4th
patch
|
blob
|
history
diff --git
a/scheme.4th
b/scheme.4th
index
65c64a8
..
48ab564
100644
(file)
--- a/
scheme.4th
+++ b/
scheme.4th
@@
-19,6
+19,16
@@
create types memsize allot
variable nextfree
0 nextfree !
variable nextfree
0 nextfree !
+: make-bool
+ nextfree @
+
+ car nextfree @ + !
+ cdr nextfree @ + 0 !
+ types nextfree @ + bool-type !
+
+ 1 nextfree +!
+;
+
: stack
create here 1+ , allot ;
: stack
create here 1+ , allot ;
@@
-80,25
+90,36
@@
variable parse-str
: parsebool
: parsebool
- nextchar emit cr
- trace
-
- false
- nextchar [char] # <> if exit then
+ nextchar [char] # <> if false exit then
1 inc-parse-idx
nextchar dup [char] t = swap [char] f = or
not if
1 dec-parse-idx
1 inc-parse-idx
nextchar dup [char] t = swap [char] f = or
not if
1 dec-parse-idx
- exit
+
false
exit
then
1 inc-parse-idx
?delim not if
2 dec-parse-idx
then
1 inc-parse-idx
?delim not if
2 dec-parse-idx
- exit
+ false exit
+ else
+ 1 dec-parse-idx
+ nextchar [char] t = make-bool
+ 1 inc-parse-idx
+ true exit
+ then
+;
+
+\ Set cdr at i to j, leaving j on the stack
+: append ( i j -- j )
+ dup rot
+ dup 0> if
+ cdr + !
+ else
+ 2drop
then
;
then
;
@@
-119,8
+140,9
@@
variable parse-str
then
parsebool if
then
parsebool if
+ append
exit
exit
- exit
+ then
;
\ Parse a counted string into a scheme expression
;
\ Parse a counted string into a scheme expression