Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


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


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.

Sign in to follow this  


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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!