everything between ? and : is parsed as if grouped (just like ( ) and { }), so the parens can always be omitted from the middle expression.
The entire ? expr : is parsed as if it is one whole binary operator in relation to the expressions on either side of it, according to normal precedence rules, thus ?: gets its spot in the precedence table in the spec despite its more complex grammar.
The rules for how
? :
parse:?
and:
is parsed as if grouped (just like( )
and{ }
), so the parens can always be omitted from the middle expression.? expr :
is parsed as if it is one whole binary operator in relation to the expressions on either side of it, according to normal precedence rules, thus?:
gets its spot in the precedence table in the spec despite its more complex grammar.