Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
664 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...