在 gforth 中,我可以使用 see wordname
查看单词的定义,甚至可以使用 ' wordname
获取其执行 token ,还可以使用 see 子词(例如 )获取其执行 token 。 ' 字名 seecol
我无法找到一种方法将 see wordname
的输出转换为字符串。我尝试摆弄 stdout 和 stdin 单词,但找不到正确的单词。
有人可以帮我吗?
最佳答案
Gforth 提供了 word >string-execute ( i*x xt – j*x c-addr u )
将 type
和 emit
的输出重定向到字符串.
交互式使用示例
"see wordname" ' evaluate >string-execute type
' see >string-execute wordname type
"wordname" ' see ' execute-parsing >string-execute type
' wordname ' xt-see >string-execute type
辅助词
: dis-xt ( xt -- sd.disforth )
['] xt-see >string-execute
;
: dis-word ( sd.name -- sd.disforth )
['] see ['] execute-parsing >string-execute
;
数据类型符号sd
表示由单元对(c-addr u)
表示的字符串。
辅助词用法示例
' traverse-wordlist dis-xt type
"traverse-wordlist" dis-word type
关于forth - 如何在 Forth (gforth) 的数据堆栈上获取单词字符串表示形式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76348718/