In your first grammar, the precedence declarations do absolutely nothing. Precedence only applies to the alternatives containing the terminal with the precedence; in your first grammar, that would be the productions for binop
and unop
. But the alternatives for those productions are completely unambiguous; precedence is not required to decide to reduce PLUS
to binop
.
In your second grammar, the precedence relationships do have an effect because the competing ambiguous alternatives (the productions for binops
and unops
) directly include the terminals.
In other words, precedence does not "look into" a non-terminal.