-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththoughts.txt
44 lines (35 loc) · 2.34 KB
/
thoughts.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Technologies:
Vanilla Js, Jquery:
Actual app logic, jquery for a few utility functions, easier html selectors
Html:
To build the gui
Css,Foundation:
Foundation cause I hate CSS and it makes it much easier to rapidly build the gui.
Font Awesome:
Great icons for added meaning wihtout resorting to images that take more resources to load, and don't scale with display size well.
Reasons : I used web technologies for the rapid development of the gui as well as to re framiliarize myself with the technologies.
Actual flow of app:
Input gets caught in the app.js listener and passed to input.js handleInput()
Once equals is intercepted, the combined input is passed into squishers
The squishers function as follows.
First squish numbers takes an array of say [1, 2, +, 3] and makes the array [12, +, 3]
This array is then thrown into a recursive pemdas squisher, the first being the parenthesis squisher
It squishes the parenthesis into expressions together until none are left by throwing it's return into itsself recursively until there are no more parenthesis ops left then throws them into the squisher for exponents
this follows the same pattern, of calling it'sself till there are no more exponent ops, then calls the mult/divide squisher
that squishes into expressions all the multiplications and division operators until there are no more of that class of ops then calls the add/sub squisher
Finally when there are no more add/sub ops, it returns its self as one giant expression.
That then get's checked to be sure there is only one expression, and that value is displayed
after you can work off that value or clear the buffer
//do after comment issue is done.
//explain squishing
Challenging parts:
Minus and Negative. Determining if a minus sign represents a negative or actual subtraction was a bit more challenging than expected.
Parenthesis. First approach was matching the farthest parenthesis from the front with the closest one to the front, that failed. Then tried using the clsoest closing parenthesis to the first one, that one failed as well. Finally, used the first one after no more opening ones were found.
Key listener. This is far less trivial than it should be I want to die.
REmaining bugs:
Flaoting point math inaccuracies.
undo and syntax checking/after equals
foundation issue with error span
Remaining features to add:
key listener
voice input/readback