Forth 無限ループまたは if ステートメントを記述するEBNFルールはありますか?
1645 次
2 に答える
4
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'
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 ;
于 2011-05-19T03:30:22.880 に答える
1
以下も使用できます。
infinite_loop ::= 'BEGIN' statements 'AGAIN'
このAGAIN
単語は、無条件分岐を に戻すために使用されますBEGIN
。例えば:
: main-loop BEGIN listen-for-event process-event AGAIN ;
于 2015-10-01T18:10:00.507 に答える