In which I comment on things
)in Forth. Make
(read words until
)and do nothing with them. This is how Forth implements comments.
I didn’t quite follow the prescription above. I found that gforth will happily parse things like
3 ( 4 hgfd) . and (in this case) return
3. So it is not a case of just ignoring words until you get the
) but ignoring characters until you see the
My implementation endows
InputParser with a comment character, which if not
nil causes it to discard all characters in its input stream up to and including the comment character. It then emits
) to close the comment. The words
\ simply set an appropriate comment character and the word
) sets the comment character to
The code is tagged blog-1061.
You will notice from the commits the I have made some other changes. For example, I added code in to allow me to dump the contents of the dictionary for debugging purposes. I’ve also finally made words case insensitive, so you can now type
dUp which is in line with many Forth implementations.