If a postfix and an infix operator have the same token, one would have to look ahead to figure out which one it actually is. That's very cringe, so we won't be doing it.
Instead, we just disallow that sort of ambiguity.
Well, it's not simply cringe, it actually has to do with parser design. When I have f(a,b), then I treat the f as a variable, and the (a,b) as a postfix operator. (function application)
Same idea goes for arr[0]. (array indexing)
If a postfix and an infix operator have the same token, one would have to look ahead to figure out which one it actually is. That's very cringe, so we won't be doing it. Instead, we just disallow that sort of ambiguity.
Well, it's not simply cringe, it actually has to do with parser design. When I have
f(a,b)
, then I treat thef
as a variable, and the(a,b)
as a postfix operator. (function application) Same idea goes forarr[0]
. (array indexing)