Regex 野牛:$1/stmt';没有声明的类型
有人能告诉我们为什么它在声明类型时显示错误。好吧,错误消息几乎准确地告诉您发生了什么。对于第一行,第46行是:Regex 野牛:$1/stmt';没有声明的类型,regex,bison,Regex,Bison,有人能告诉我们为什么它在声明类型时显示错误。好吧,错误消息几乎准确地告诉您发生了什么。对于第一行,第46行是: calc.y:46.44-45: $1 of `stmt' has no declared type calc.y:51.43-44: $3 of `stmt' has no declared type calc.y:65.47-48: $2 of `expr' has no declared type calc.y:66.47-48: $2 of `expr' has no decl
calc.y:46.44-45: $1 of `stmt' has no declared type
calc.y:51.43-44: $3 of `stmt' has no declared type
calc.y:65.47-48: $2 of `expr' has no declared type
calc.y:66.47-48: $2 of `expr' has no declared type
make: *** [calc] Error 1
这是stmt
的规则,错误告诉您$1
(来自TOK_LPARA
)没有类型。从它的三角洲可以看出:
| TOK_LPARA stmts TOK_RPARA { if($1=="{")
如果您希望能够从这里的TOK_LPARA
访问一个值,您需要给它一个类型,可能是
。然后您会遇到这样的问题,==
将比较指针,而不是指向字符串。其他错误都表明存在类似的问题
您在
stmt
操作中没有设置$$
(您为stmt
声明了一个类型)也有问题,这会导致它们具有垃圾值。有人能帮我吗???
| TOK_LPARA stmts TOK_RPARA { if($1=="{")
%left TOK_LPARA TOK_RPARA