Closed patrickfeltes closed 6 years ago
Thanks didn't notice that when I was making it, I was also thinking that exponent should be after postfix too (so right before call). So maybe if you could change that? Also noticed operator precedence table is a bit out of date.
So, you want exponent to have higher precedence than postfix, so that something like
var x = 1;
print x++**2;
would be invalid without proper parentheses around x++?
I fixed the precedence table and added the change that you requested. Now the above code will not work unless the x++ is surrounded by parentheses.
Looking at this doesn't seem to be right either. I think think the right thing to do is to keep the first version but split the unary to unary and prefix operators so prefix and postfix have seperate precedenes higher than the exponent operator while exponent having higher precedence than unary. (so from lower to higher: unary<exponent<prefix<postfix)
Will do! Thanks for the feedback
Here are the changes. Now x++^2 and ++x^2 should work correctly, along with the other fixes.
merged
This should fix associativity issues with exponentiation. 2^2^4 = 65536.
A few extra additions:
I also updated the readme to add my additions to the grammar.
I hope you decide to add this!
Should fix #7