Sign in to follow this  
  • entries
    570
  • comments
    2427
  • views
    216029

Untitled

Sign in to follow this  
Mushu

65 views

Unforseen troubles.

So, I wrote that piece of #(%*)# #)(%*)( #*&% )#&%)# %)*#. It took all day, pain in the #)%**) but it appears to work. That is, it parses something like

(2+((3^2)*3))

Into a nice little tree which can be evaluated. But get this -

INPUT: 10^2-100+200/10^2
OUTPUT: = -2


See what's going on here? The actual output should be positive 2, not negative. For those of you who don't see it yet - lets examine the expanded output (first parse step) -

INPUT: 10^2-100+200/10^2
OUTPUT: ((10^2)-(100+(200/(10^2))))


See the bugger? the + operation is taking precidence over the - operation instead of being evaluated right-to-left with equal precidence. The culpret?
string pawn::equ::expand( string equ ) {
// ...
equ = expand( equ, "+" );
equ = expand( equ, "-" );
// ...

return equ;
}

Yeah. Shit.

I never ever thought that I should be evaluating multiple symbols at the same time. Which is bad. Very very bad. Because, well, it doesn't work.

But the good news is that the expander works by searching to searching for the token string in something something, yadda yadda its one giant hack.

Oddly enough, two wrongs may not make a right, but too hacks certainly do make a solution:
string pawn::equ::expand( string equ ) {
// ...
equ = expand( equ, "+|-" );
// ...

return equ;
}

Do I know why it works? No. In fact it shouldn't work at all. But it does so I'm not going to bother with it.

INFINITE IMPROBABILITY GOOO!!!!
Sign in to follow this  


2 Comments


Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now