I wanted to make an expression parser tool that can help with that. Make changes quickly, visually, simplify (strip excess parenthesis). Maybe it will handle associative and commutative properties. Maybe make transformations, inversions (such as De Morgan's laws). I'm not sure if I want to work on those though. It would already be really useful if it could do parenthesis insertion/deletion.
I don't know yet how this one will go.
A typical example here this tool might come in handy is in the following scenario:
a & 1 << b - 1
Wishing to mask off an integer with a bit-mask of dynamic size - the mask is generated by (1 << b) - 1. And of course I want to NOT use excessive parentheses.
What will the interpreter / compiler do?
a & ((1 << b) - 1) <------- what I want
a & (1 << (b - 1)) <-------- or this? This is default precedence without parentheses.
(a & 1) << (b - 1) <-------- or this?
((a & 1) << b) - 1 <-------- or this?
(a & (1 << b)) - 1 <-------- or this?
This would make a good interview question. I doubt many seasoned programmers could pass it.
Here is a screenshot of the program so far
Work in progress.
Revised 6 Oct 2019