Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 野牛:$1/stmt';没有声明的类型_Regex_Bison - Fatal编程技术网

Regex 野牛:$1/stmt';没有声明的类型

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

有人能告诉我们为什么它在声明类型时显示错误。

好吧,错误消息几乎准确地告诉您发生了什么。对于第一行,第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 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