maja42 / goval

Expression evaluation in golang
MIT License
157 stars 24 forks source link

Ternary operator #9

Closed llonchj closed 3 years ago

llonchj commented 3 years ago

fixes #8

llonchj commented 3 years ago

@maja42 possibly more tests are required and have no previous goyacc experience. Can you please help me understand how to get it working for cases other than bool?

maja42 commented 3 years ago

Thanks for your pull-request. I finished ternary-support which is now available in the new v1.2.+.

Note: Your pull-request contained a bug in the operator-ordering. The ternary-operator has the highest precedence of all operators (see http://en.cppreference.com/w/c/language/operator_precedence, also referenced in the source-code). Therefore, the %left '?' ':' has to stay at the top.

In addition to that, the associativity should be right-to-left (as in C / C++), not left-to-right.

I also added the relevant tests and readme.

llonchj commented 3 years ago

Thanks