y9san9/calkt

Boolean Evaluator - support

Woren opened this issue · 3 comments

Add support for boolean expression parsing and evaluation. For example expression
( 0 == 1 && -10 > 11 ) || ( 10 <= 9 ) && ( -1.0 == 1.7 )
will return true/false
It would be nice to have support also for expressions without numbers like
(!true || false) || (false)

There is for example this stackoverflow post which is about this topic if it can be any help.
https://stackoverflow.com/questions/62218073/how-can-we-evaluate-a-boolean-expression-represented-by-a-string-in-kotlin
This example is in many ways limited. No support for negative or float numbers parsing, no <=, >= handling etc.

Why is this important? Be able to parse (simple) 3rd party scripting languages into kotlin code and execute them.

Thanks for considering supporting this!

This seems pretty reasonable to support. I will add this to ideas list that I wish to implement and as soon I have time to work on the project I will implement this. But first, I need to support function calls (line sin, cos)

This would probably be in a separate module like ":bool"

Great, nice to hear it. I really appreciate it.