The Lambda Lab
/
projects
/
forth.jl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fca502c
)
Slowly getting lib.4th to compile again.
author
Tim Vaughan
<tgvaughan@gmail.com>
Sat, 7 May 2016 11:51:40 +0000
(23:51 +1200)
committer
Tim Vaughan
<tgvaughan@gmail.com>
Sat, 7 May 2016 11:51:40 +0000
(23:51 +1200)
src/forth.jl
patch
|
blob
|
history
src/lib.4th
patch
|
blob
|
history
diff --git
a/src/forth.jl
b/src/forth.jl
index
3305d5e
..
0803b72
100644
(file)
--- a/
src/forth.jl
+++ b/
src/forth.jl
@@
-721,6
+721,7
@@
end)
# Outer interpreter
TRACE = defPrimWord("TRACE", () -> begin
# Outer interpreter
TRACE = defPrimWord("TRACE", () -> begin
+ println("Val: $(popPS())")
print("RS: "); printRS()
print("PS: "); printPS()
print("[paused]")
print("RS: "); printRS()
print("PS: "); printPS()
print("[paused]")
@@
-825,7
+826,7
@@
INTERPRET = defWord("INTERPRET",
DUP, FETCH, ZE, ZBRANCH, 3,
DROP, EXIT, # Exit if TIB is exhausted
DUP, FETCH, ZE, ZBRANCH, 3,
DROP, EXIT, # Exit if TIB is exhausted
- STATE_CFA, FETCH, ZBRANCH, 3
2
,
+ STATE_CFA, FETCH, ZBRANCH, 3
1
,
# Compiling
DUP, FIND, QDUP, ZBRANCH, 19,
# Compiling
DUP, FIND, QDUP, ZBRANCH, 19,
@@
-839,16
+840,16
@@
INTERPRET = defWord("INTERPRET",
COMMA, BRANCH, -36,
# No word found, parse number
COMMA, BRANCH, -36,
# No word found, parse number
- NUMBER, BTICK, LIT, COMMA, COMMA,
TRACE, BRANCH, -44
,
+ NUMBER, BTICK, LIT, COMMA, COMMA,
BRANCH, -43
,
# Interpreting
DUP, FIND, QDUP, ZBRANCH, 7,
# Found word. Execute!
# Interpreting
DUP, FIND, QDUP, ZBRANCH, 7,
# Found word. Execute!
- SWAP, DROP, TOCFA, EXECUTE, BRANCH, -5
5
,
+ SWAP, DROP, TOCFA, EXECUTE, BRANCH, -5
4
,
# No word found, parse number and leave on stack
# No word found, parse number and leave on stack
- NUMBER, BRANCH, -5
8
,
+ NUMBER, BRANCH, -5
7
,
EXIT]
)
EXIT]
)
diff --git
a/src/lib.4th
b/src/lib.4th
index
c9df3d9
..
68bb77b
100644
(file)
--- a/
src/lib.4th
+++ b/
src/lib.4th
@@
-1,6
+1,5
@@
: \ IMMEDIATE
: \ IMMEDIATE
- KEY
- 10 = 0BRANCH [ -5 , ]
+ #TIB @ >IN !
; \ We can now comment!
\ BASIC DEFINITIONS ----------------------------------------------------------------------
; \ We can now comment!
\ BASIC DEFINITIONS ----------------------------------------------------------------------
@@
-33,10
+32,7
@@
: LITERAL IMMEDIATE ['] LIT , , ;
: LITERAL IMMEDIATE ['] LIT , , ;
-: CHAR
- BL WORD
- DROP @
-;
+: CHAR BL WORD 1+ @ ;
: [CHAR] IMMEDIATE
CHAR
: [CHAR] IMMEDIATE
CHAR
@@
-59,9
+55,6
@@
, \ compile it
;
, \ compile it
;
-: DEBUGON TRUE DEBUG ! ;
-: DEBUGOFF FALSE DEBUG ! ;
-
\ CONTROL STRUCTURES ----------------------------------------------------------------------
: IF IMMEDIATE
\ CONTROL STRUCTURES ----------------------------------------------------------------------
: IF IMMEDIATE
@@
-220,11
+213,11
@@
: ( IMMEDIATE
1 \ allowed nested parens by keeping track of depth
BEGIN
: ( IMMEDIATE
1 \ allowed nested parens by keeping track of depth
BEGIN
- >IN
#TIB
>= IF \ End of TIB?
+ >IN
@ #TIB @
>= IF \ End of TIB?
QUERY \ Get next line
THEN
QUERY \ Get next line
THEN
-
>IN
@ 1 >IN +!
+
TIB >IN @ +
@ 1 >IN +!
DUP [CHAR] ( = IF \ open paren?
DROP \ drop the open paren
1+ \ depth increases
DUP [CHAR] ( = IF \ open paren?
DROP \ drop the open paren
1+ \ depth increases