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:
0740fc6
)
Added READ-LINE
author
Tim Vaughan
<tgvaughan@gmail.com>
Sun, 2 Oct 2016 00:12:42 +0000
(13:12 +1300)
committer
Tim Vaughan
<tgvaughan@gmail.com>
Sun, 2 Oct 2016 00:12:42 +0000
(13:12 +1300)
src/forth.jl
patch
|
blob
|
history
diff --git
a/src/forth.jl
b/src/forth.jl
index
d911e21
..
aa93c2d
100644
(file)
--- a/
src/forth.jl
+++ b/
src/forth.jl
@@
-665,6
+665,22
@@
CLOSE_FILES_CFA = defPrimWord("CLOSE-FILES", () -> begin
end)
READ_LINE_CFA = defPrimWord("READ-LINE", () -> begin
+ fid = popPS()
+ maxSize = popPS()
+ addr = popPS()
+
+ fh = openFiles[fid]
+ line = readline(fh)
+
+ eofFlag = endswith(line, '\n') ? 0 : -1
+ line = chomp(line)
+
+ putString(line, addr, maxSize)
+
+ pushPS(length(line))
+ pushPS(eofFlag)
+ pushPS(0)
+
return NEXT
end)