- #1
Jamin2112
- 986
- 12
I'm making a program that interprets and evaluates equations. I won't go into all the specifications, but basically it would take a statement like
~1^(2~&3) 0x3FFE 0x2FCE 0xFCC1
and returns
4926 (0x133E).
As you may have guessed, the 1, 2 and 3 are where the parameters 0x3FFE, 0x2FCE and 0xFCC1 are substituted.
I'm right now working on a function that determines whether the equation is valid in the first place. For instance, there can't be any unbalanced parentheses, any of the numbers cannot exceed the number of parameters, there cannot be any invalid characters like '#', a left-facing paranthesis must always be followed by an operator, etc.
For that function function alone, I've already written 225 lines of code, probably 150 if you exclude comments. It's very tricky. And I'm only iterating through characters of the equation once and I've carefully eliminated redundancies.
Or am I inevitably going about this wrong if I'm having to write so much?
~1^(2~&3) 0x3FFE 0x2FCE 0xFCC1
and returns
4926 (0x133E).
As you may have guessed, the 1, 2 and 3 are where the parameters 0x3FFE, 0x2FCE and 0xFCC1 are substituted.
I'm right now working on a function that determines whether the equation is valid in the first place. For instance, there can't be any unbalanced parentheses, any of the numbers cannot exceed the number of parameters, there cannot be any invalid characters like '#', a left-facing paranthesis must always be followed by an operator, etc.
For that function function alone, I've already written 225 lines of code, probably 150 if you exclude comments. It's very tricky. And I'm only iterating through characters of the equation once and I've carefully eliminated redundancies.
Or am I inevitably going about this wrong if I'm having to write so much?