block:
"{" { //push scope;}
multi_stmt
"}" {
//pop scope
$$=new ASTNode_Block($2,..........)
}
I'm trying to implement block structures in bison. However, I am having troubles here to access $2 (returned value from multi_stmt)
ps: It's intended to not using "|" to separate them, thus i can have them executed in orders.
Mid-rule actions also have numbers (but not, by default, return types). So the value of multi_stmt
is $3
, not $2
.
$1
is the open brace (which I think should be '{'
, not "{"
-- in bison, they are different --), $2
is the mid-rule action, $3
is multi_stmt
and $4
is the close brace.
Try with removing second {
in line "{" {
. If I understand correctly you intend to define a grammar rule { multi_stmt }
, so the second {
is a mistake here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.