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

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

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

4条回答
  •  囚心锁ツ
    2020-12-21 00:07

    It's legal and parsed as x-- - y.

    I believe the first two minus signs are interpreted as a post-decrement operator because it's the longest token following x that is legal to appear. This leaves the third minus to play the role of subtraction. This is in accordance with the Maximal Much Rule[1]

    [1]. http://en.wikipedia.org/wiki/Maximal_munch

提交回复
热议问题