How is the expression x---y parsed? Is it a legal expression?

后端 未结 4 1257
失恋的感觉
失恋的感觉 2020-12-20 23:25

How is the expression x---y parsed? Is it a legal expression?

4条回答
  •  独厮守ぢ
    2020-12-21 00:04

    This is related to operator precedence. Have a look at this table.

    The decrement/increment operator has precedence over the arithmetic operations. It will be parsed as x-- - y.

    To correct my answer: The parser matches the longest token first, so -- is chosen over the arithmetic -. Resulting in the expression being parsed as x-- - y

提交回复
热议问题