diff options
author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2025-05-21 18:23:35 -0500 |
---|---|---|
committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2025-05-30 19:54:17 -0500 |
commit | 4cb7e4eb4a9213304ee5b83c9aaa0427e9a8fe31 (patch) | |
tree | 827c42e6823aca0705962c62d3aacfda75580c43 /src/main/java/sevenUnits/unit/UnitlikeValue.java | |
parent | 779bf983226f9799dc19d84a3f2cb9a3e26cd540 (diff) |
ExpressionParser: use correct operand order
Most of the internal problems with the expression parser happened
because I was accepting the arguments for binary operators in the wrong
order. For example, '2 - 1' became '1 2 -', not '2 1 -'.
The likely cause of this error is the following sequence of events:
- In commit 6dbd32cd, I created the code for interpreting RPN. I
accepted two arguments from the stack (o1 and o2), then performed o1
<op> o2. However, because stacks are in LIFO order, I should have
actually done o2 <op> o1.
- Later, in commit 94349688, I created the code for converting an infix
expression to RPN. Creating the expressions in the correct order did
not work, because my interpreter used the incorrect order. To 'fix'
this problem, I created the expressions in the incorrect order. I did
not notice any discrepancy, probably because I was not testing the
individual methods, only the two-step whole (which found no errors).
Diffstat (limited to 'src/main/java/sevenUnits/unit/UnitlikeValue.java')
0 files changed, 0 insertions, 0 deletions