Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Neo Genesis10

Nested IF Scripting

This topic is 5325 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have created a simplistic scripting language for my game, but it lacks a little finesse and flexibility at the moment. What I need at the moment is a fairly easy method to read and act on nested IF statements within the script. Previous attempts have had little luck, unfortunately. Does anyone have any ideas, or a link to a site with this sort of design? Worship the holy trinity that is Blitz, Babes and Beers!

Share this post


Link to post
Share on other sites
Advertisement
Going to take a shot in the dark with the bullet of theory here...

Your going through your code, and you encounter a IF statement.

If it's true:

Increase "if depth" we will call it - by one.
Execute all statements with a if depth of 1.
You arive at nested IF, and it turns out to be false - increase if depth.
You don't execute anything with a if depth of 2 or more.
That if ends, and your back to if depth 1.
A 2nd nested IF shows up. This time true.
So, exec those thing with if depth 2 now.
All IFs end, and you move on.

Now that I think about it all I have done is explain how nested if statements work to you. I'm sure you already know this, and I'm sure somebody else can be of more help. Hopefully you can benifit from my view on the matter though.

Also hate seeing peoples questions go unanswered.

G'Luck.

[edited by - Cyber-Ace on April 14, 2004 4:16:50 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Neo Genesis10
I have created a simplistic scripting language for my game, but it lacks a little finesse and flexibility at the moment. What I need at the moment is a fairly easy method to read and act on nested IF statements within the script.

All this stuff becomes quite easy once you''ve built your AST. How familiar are you with language theory and parsing?


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
Actually, doing nested IF statements is a piece of cake. What I should have mentioned was im also including the ELSE function. Its this which is throwing off my code. At the moment, I have an ugly workaround which simply cycles down the code until it encounters the matching Else or EndIf, but im certain there are better ways to handle it.

Worship the holy trinity that is Blitz, Babes and Beers!

Share this post


Link to post
Share on other sites
Again, it all comes down to the parser. Languages which have optional ELSE clauses necessarily introduce an ambiguity into the language which needs to be clarified. (In LR parser terminology, the presence of the construct results in a "shift-reduce conflict".) What are you currently using for parsing?


"Sneftel is correct, if rather vulgar." --Flarelocke

[edited by - sneftel on April 14, 2004 8:24:02 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!