forth - 如何在 Forth (gforth) 的数据堆栈上获取单词字符串表示形式?

标签 forth gforth

在 gforth 中,我可以使用 see wordname 查看单词的定义,甚至可以使用 ' wordname 获取其执行 token ,还可以使用 see 子词(例如 )获取其执行 token 。 ' 字名 seecol

我无法找到一种方法将 see wordname 的输出转换为字符串。我尝试摆弄 stdout 和 stdin 单词,但找不到正确的单词。

有人可以帮我吗?

最佳答案

Gforth 提供了 word >string-execute ( i*x xt – j*x c-addr u )typeemit 的输出重定向到字符串.

交互式使用示例

"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/

相关文章:

lisp - Common Lisp 宏和 Forth 元编程能力的比较

forth - GForth:将 float 转换为字符串

programming-languages - Forth 还在使用吗?如果是这样,如何以及在哪里?

forth - 为什么 Skia 包含一个 Forth 解释器?

include - 如何在 Forth 中包含 C 库

windows - 如何在 GForth (GNU Forth) 的文件名中包含空格?

arrays - Forth 中的多字节存储和获取 - 如何实现?

forth - 使用循环反转数据堆栈

programming-languages - 这个旧程序是用什么语言编写的?

function - 如何读取用户输入的整数并在 Forth 中提供函数?