Home » Community » Forums » » Creating a Scripting System in C++ Part IV: The Stack and Program Flow
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic

Page:   1 2 3 »»

 Last Thread Next Thread 
 Creating a Scripting System in C++ Part IV: The Stack and Program Flow
Post Reply 
Good article!

I think the STL has a stack template though, so you probably didn't need to roll your own.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions


 User Rating: 1071   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Nice work Greg - it's good to see things coming together.

 User Rating: 1903   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Thanks.

"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Straight from the article:
quote:
One of the first things that come to mind when thinking about stack implementations is that simple containers that could be used are already implemented as part of the standard library. They certainly are. However there will be certain features we need that they do not provide on their own.


Nice article

||--------------------------||
Black Hole Productions
http://bhp.e-chrono.net/
Resident expert on stuff
max621@barrysworld.com
||--------------------------||

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Friggin wonderful article :D

 User Rating: 1168   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Thanks guys.
btw daerid, how's legends going?

"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Is it possible to save a complied script into a file?

 User Rating: 1015    Report this Post to a Moderator | Link

Is it possible to save a complied script into a file?

 User Rating: 1015    Report this Post to a Moderator | Link

When does the next part come?? =I
Very nice work, looking forward to the next article!

 User Rating: 1049   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link


Because this article didn't mention another data type,
would u give me any idea about this script with float type consideration?
I think it will be more helpful to me.



 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

You could:
a) Separate floats completely, giving them their own stack etc.
b) Hide float data on a stack with a type that has the same size as a float. To store and extract you would have to preserve the bits, and not simply perform a cast.


"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Great article, I'm waiting eagerly for the next one...

// Dalle

 User Rating: 1149   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link


I already implement a mix-type for handling int and float data type.
I think My mix-type is a stupid implementation.The mix-type is a class with 4 bytes data bits and some bytes for distinguishing between int and float.I implement all operator like '+''>='..etc and take care about type casting.
Would you give me any idea about string data type?
Although I can also create a mix-type for int,float and string, I think maybe there is the better method that I didn't find.



 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

To keep the concepts simple, you probably would be best off going for a separate stack for each primitive type, and actually treating a string as a primitive type as well. As a result, you'd of course have to have separate instructions for dealing with different primitive types.

For strings I'd recommend using a ScopeStack of std::string.

"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Why not create an Object with a typeOf member, and have different classes inheriting from it? Then could not a std::stack(Object) be used, and then later, based on the return of typeOf, cast each Object to it's rightful type?

I don't think I explained that too well, but I'm sure that someone understands what I'm trying to say.

Chris 'coldacid' Charabaruk ccharabaruk@meldstar.com http://www.meldstar.com/~ccharabaruk/
Meldstar Studios http://www.meldstar.com/ - Creation, cubed.

This message double ROT-13 encrypted for additional security.

Edited by Gaiiden: coldacid, you can't use html brackets in your post without screwing things up. I replaced them with paranethesis. No harm done although if you can find a better way to represent them that would be fine too.

 User Rating: 1407   |  Rate This User  Send Private MessageView ProfileView JournalView GD Showcase Entries Report this Post to a Moderator | Link

I believe that's what siugar was referring to when he mentioned his "mix-type" concept. While you could do it that way, and are certainly welcome to, I prefer not to introduce that kind of overhead for the primitive data-types.

"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

By the way, you really ought to fix your html, so that it doesn't mess up the rest of the thread's formatting.

"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Hi,
I've been working a compiler for a couple months now, so I figured I'd post a link. It supports chars, ints, doubles, floats, uchars, uints, pointers, pointer pointers (I think...in theory at least). Right now the only functions that are built in to it are int CINI(), void COUTI(int i), void COUTC(char c), char CINC(), so the programs still have to be kinda simple. Here's the link http://www.geocities.com/chsnick/Compiler.html.

I'd love to hear your thoughts.

Thanks.

Nick

P.S. I'm not a professional programmer and haven't read any on compiler theory, so some parts of the site might seem a little ignorant at times

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

The next part will be out as soon as I finish with it. I always have a plan, however the rate at which I can churn these out is mainly limited by my free time (or lack thereof) unfortunately.

And yes, of course you can save a compiled script to file. To put it simply, use some consistent serialization process that you can reverse when you then want to load that same script again. I will be covering this topic eventually.

"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

naj: Despite not being a professional and not having any formal knowledge of compiler theory, it looks really good and well thought out.

"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

So how long until we get functions and variable scope?

Oh and if you need these braces < > you can do them with &lt; &gt;, yeah a little round about way of doing it, just think of them as \", and \n

 User Rating: 261   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

That comes in the next article.

"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Great article! I enjoyed it very much. I've been thinking of using a scripting language for various things in my programs; so certain the behaviour can be customized without recompiling.
I just might get off my arse and do it now Hurry with the next one!

 User Rating: 1015    Report this Post to a Moderator | Link

As time permits, I'm doing my best!

"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link
Page:   1 2 3 »»
All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: