Expression Cleaner

When I program I like to cram a lot of stuff into an expression - reducing line count (ah, APL days!). Calculations, assignments, more calculations. Of course with JavaScript or C programming languages operator precedence always gets in the way. Some are downright counter-intuitive. They never seem to be the way that I expect. I find myself needing to look up a Operator precedence chart. There are 20 levels! Even using the chart is cumbersome to use, read and interpret. 

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