野牛:$变量($ 1 $ 2等)如何与非令牌一起使用? [英] Bison: How $ variables ($1 $2 etc) work with non-tokens?
本文介绍了野牛:$变量($ 1 $ 2等)如何与非令牌一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道$变量如何与非令牌(如代码块)一起使用.我的问题可以简化为:
I'm wondering how $ variables work with non-tokens, like blocks of code. And my question can be reduced to this:
我有这样一条规则,中间有一段代码.在这种情况下,$ 3和$ 4是谁?
I have a rule like this, with a block of code in the middle of it. In this case who is $3 and $4?
func-header: ret-type ID { strcpy(func_id,current_id); } LPAREN params RPAREN
推荐答案
在显示的规则中:
-
ret-type
是$1
. -
ID
是$2
. - 代码块为
$3
. -
LPAREN
是$4
. -
params
是$5
. -
RPAREN
是$6
.
ret-type
is$1
.ID
is$2
.- The code block is
$3
. LPAREN
is$4
.params
is$5
.RPAREN
is$6
.
换句话说,代码块充当非终端.
In other words, code blocks act as non-terminals.
这篇关于野牛:$变量($ 1 $ 2等)如何与非令牌一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文