无限循环或if语句的第四语言EBNF规则 [英] Forth language EBNF rule for an infinite loop or if statement

查看:185
本文介绍了无限循环或if语句的第四语言EBNF规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在 EBNF 规则,该规则描述了Forth无限循环或如果声明?

Is there an EBNF rule that describes a Forth infinite loop or if statement?

推荐答案

EBNF用于描述语法.循环是无限循环或其他情况通常不会落入它所描述的范围内.这样,您可能会在EBNF中看到一个不确定的循环,看起来像:

EBNF is used to describe syntax. A loop being infinite or otherwise wouldn't normally fall within what it would describe. As such, you'd be looking at the EBNF for an indefinite loop, which looks something like:

indefinite_loop ::= 'BEGIN' statements cond 'UNTIL'

通常,cond将在堆栈上压入0或1,以确定是否继续循环(0表示继续循环,1表示退出).这样,如果您直接插入0,则循环将永远执行:

Normally the cond will be something that pushes a 0 or 1 on the stack to determine whether to continue the loop (0 means continue the loop, 1 means exit). As such, if you just insert a 0 directly, the loop will execute forever:

: infinite_loop BEGIN do_whatever 0 UNTIL ;

这篇关于无限循环或if语句的第四语言EBNF规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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