shift_stmt_expr grammar question
Just noticed that the production for right shifts differs from the production for left shifts (src/parser_bison.y, ll. 3020ff.):
shift_stmt_expr : primary_stmt_expr
| shift_stmt_expr LSHIFT primary_stmt_expr
{
$$ = binop_expr_alloc(&@$, OP_LSHIFT, $1, $3);
}
| shift_stmt_expr RSHIFT primary_rhs_expr
{
$$ = binop_expr_alloc(&@$, OP_RSHIFT, $1, $3);
}
;Is there a reason why the RHS of LSHIFT is primary_stmt_expr, but the RHS of RSHIFT is primary_rhs_expr?
J.
Pablo Neira Ayuso
maintainerHi Jeremy,
Quoted 14 lines · Jeremy Sowden
Just noticed that the production for right shifts differs from the production for left shifts (src/parser_bison.y, ll. 3020ff.):
shift_stmt_expr : primary_stmt_expr | shift_stmt_expr LSHIFT primary_stmt_expr { $$ = binop_expr_alloc(&@$, OP_LSHIFT, $1, $3); } | shift_stmt_expr RSHIFT primary_rhs_expr { $$ = binop_expr_alloc(&@$, OP_RSHIFT, $1, $3); } ;
Quoted 2 lines
Is there a reason why the RHS of LSHIFT is
primary_stmt_expr, but the RHS of RSHIFT isprimary_rhs_expr?
It's likely a leftover. The rhs rule was introduced to reduce chances of hitting shift/reduce conflicts, and to restrict syntax on the rhs.