JimmyCushnie / JECS

Jimmy's Epic Config System
Do What The F*ck You Want To Public License
154 stars 16 forks source link

Allow floats to use addition/subtraction to combine float literals #28

Open JimmyCushnie opened 4 years ago

JimmyCushnie commented 4 years ago

Today I had to write 0.5333333333. It would be much better to write 1/3 + 0.2.

JimmyCushnie commented 4 years ago

I worked on this for a while today, but I am unsatisfied with the neatness and reliability of the code. It also feels wrong to support addition/subtraction/division, but not multiplication, and not brackets.

I'm scrapping the work I've done so far on this feature. I think the proper implementation is to use some lightweight third party library that supports parsing a variety of mathematical operators.

I left the code I've written so far in the add-subtract-floats branch; see commit a165098.

JimmyCushnie commented 3 years ago

@ForLoveOfCats Kindly sent me this link today, and it seems like exactly what is needed for this feature: https://en.wikipedia.org/wiki/Shunting-yard_algorithm