🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Untitled

posted in DruinkJournal
Published November 03, 2006
Advertisement
Ok, I've leaving the debugger for now. I may come back to it later on.

I'm now working on the compiler. I also want to add support for globabl variables in DruinkScript, which should be easy - globals can just be stuffed in at the base of the stack.

Anyway, DruinkScript is going to be strongly typed, and look pretty much like C / C++. Here's my current script:
// Test.dsc Test fileconst int g_nConst = 10 * 5;int Add(int a, int b){   return a + b;}void _Main(){   int foo = Add(5, 0x1f & 1111b) + g_nConst;   string pies = "I like " "pies" + "lots";   pies += ". Really.";   string foo = pies.left(6);}

The only two things valid at global scope are functions and the declaration of constants. Constants get evaluated at compile time on the first pass of the code, when they get added to the symbol table.
"Member functions" will be a bit of a hack. Since the compiler will know the type of the variable to the left of the . operator, it can convert the function call into an opcode. In the above case, it'll see that pies is a string, and lookup string's list of members. Left() will resolve to a strleft opcode.
I can also add members to float and int (The other two types supported) for things like absolute value and other hilarity. Although that's likely to get confusing...

I need to re-read the bit in Game Scripting mastery about making expressions ("1 + 5 * 7 / 4 + 7" and the like), so I can use that all over the place. I also need to read up on BNF notation a little to define a formal grammar for DruinkScript.


P.S. I have a pinecone where my penis should be.
Previous Entry Untitled
Next Entry Untitled
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement