|
||||||||||||||||||
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 |
|
![]() siaspete Member since: 10/10/2001 From: Edinburgh, United Kingdom |
||||
|
|
||||
| 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 |
||||
|
||||
![]() LessBread Moderator Member since: 12/19/2001 From: Fresno, CA, United States |
||||
|
|
||||
| Nice work Greg - it's good to see things coming together. |
||||
|
||||
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| Thanks. "Don't be afraid to dream, for out of such fragile things come miracles." |
||||
|
||||
![]() max621 Member since: 2/9/2000 From: Riverside, USA |
||||
|
|
||||
Straight from the article:quote: Nice article ||--------------------------|| Black Hole Productions http://bhp.e-chrono.net/ Resident expert on stuff max621@barrysworld.com ||--------------------------|| |
||||
|
||||
![]() daerid Member since: 8/13/2001 From: Sunland, CA, United States |
||||
|
|
||||
| Friggin wonderful article :D |
||||
|
||||
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| Thanks guys. btw daerid, how's legends going? "Don't be afraid to dream, for out of such fragile things come miracles." |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Is it possible to save a complied script into a file? |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Is it possible to save a complied script into a file? |
||||
|
||||
![]() Taharez GDNet+ Member since: 6/18/2000 From: Stockholm, Sweden |
||||
|
|
||||
| When does the next part come?? =I Very nice work, looking forward to the next article! |
||||
|
||||
![]() siugar Member since: 4/18/2002 From: Taiwan |
||||
|
|
||||
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. |
||||
|
||||
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| 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." |
||||
|
||||
![]() dalleboy Member since: 4/14/2002 From: Umea, Sweden |
||||
|
|
||||
| Great article, I'm waiting eagerly for the next one... // Dalle |
||||
|
||||
![]() siugar Member since: 4/18/2002 From: Taiwan |
||||
|
|
||||
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. |
||||
|
||||
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| 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." |
||||
|
||||
![]() coldacid Member since: 6/4/2001 From: Pickering, Canada |
||||
|
|
||||
| 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. |
||||
|
||||
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| 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." |
||||
|
||||
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| 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." |
||||
|
||||
![]() naj Member since: 4/25/2002 |
||||
|
|
||||
| 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 |
||||
|
||||
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| 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." |
||||
|
||||
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| 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." |
||||
|
||||
![]() DakeDesu Member since: 7/12/2001 From: Edmonton, Canada |
||||
|
|
||||
| So how long until we get functions and variable scope? Oh and if you need these braces < > you can do them with < >, yeah a little round about way of doing it, just think of them as \", and \n |
||||
|
||||
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| That comes in the next article. "Don't be afraid to dream, for out of such fragile things come miracles." |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| 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 |
||||
|
||||
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| As time permits, I'm doing my best! "Don't be afraid to dream, for out of such fragile things come miracles." |
||||
|
||||
|
Page: 1 2 3 »» All times are ET (US) ![]() |
Last Thread Next Thread ![]() |
|