可以仅使用一个堆栈来实现类似Forth的语言吗? [英] Can a Forth-like language be implemented with just one stack?

查看:103
本文介绍了可以仅使用一个堆栈来实现类似Forth的语言吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Forth有一个堆栈和一个返回堆栈.

Forth has a stack and a return-stack.

据我了解,返回堆栈的重点是存储程序计数器的先前值.

As far as I understand, the point of the return-stack is to store the previous values of the program counter.

C程序将程序计数器的先前值放在堆栈上,并且不使用返回堆栈.

C programs put the previous value of program counter on the stack, and use no return stack.

Forth是否仅需要返回堆栈,因为它返回了堆栈上的结果,因此程序计数器的先前值可以被掩埋?

Does Forth only need a return-stack because it returns result(s) on the stack, and thus the previous value of the program counter could be buried?

推荐答案

便携式汇编语言"应该关闭.对于与标准/传统Forth几乎相同的语言而言,这是一个编译器的概念.可以编写哪种程序有一些限制.通常,您必须避免无法静态确定堆栈深度的情况.

The "Portable Assembly Language" should be close. It's a concept for a compiler for a language which is almost identical to standard/traditional Forth. There are some restrictions for which kind of programs can be written. Mostly, you have to avoid situations where the depth of the stack can't be statically determined.

可以只需要一个堆栈的方式编译该语言.

This language can be compiled in a way that only requires one stack.

http://www.complang. tuwien.ac.at/anton/euroforth/ef13/papers/ertl-paf.pdf

这篇关于可以仅使用一个堆栈来实现类似Forth的语言吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆