🎉 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!

scripting engines

Started by
15 comments, last by nhatkthanh 19 years, 11 months ago
a couple days ago i started writing a custom script engine for the game project im working on. so far, i've completed a lexer, that takes the char stream script, and produces a linked list of tokens: works flawlessly with absolutely no memory leaks (any1 interested in how the lexer works, tell me) my problem arises in the parsing part, for i have no idea how and where to begin. any suggestions?
Cartman's definition of sexual harrasement:"When you are trying to have intercourse with a lady friend, and some other guy comes up and tickles your balls from behind"(watch South Park, it rocks)
Advertisement
instead of writing your own-new scripting language, embed to your program one, which is already ready :-) e.g. Lua or Python.

however, if you are sure, that you need to write one on yourself, try bison and flex, it's all you need :-)
Triglav - Member of TAJGA Team
I agree; unless you are writing this scripting engine because you want to you should use an existing one. I recommend looking at SpiderMonkey (Mozilla's &#106avascript engine), Lua and Small. I'm using Lua myself.
Moved to the Scripting forum.
Have a look at Peroxide's PXDScript tutorials or Flipcode's scripting language series for some info about how to design your system.

I personally liked the book Game Scripting Mastery by Alex Varanese, as it explains the parsing well without the horrible Lex/Yacc tools.

But then again, it's good to use another language if you need quick development of scripts, there's many popular ones; Python, Lua, Small and my personal favourite &#106avascript (via <a href="http://www.mozilla.org/js/spidermonkey">SpiderMonkey</a>).
lua, python, ... are not options for they do not provide the necessary debug functionality.

thx for the links, but i had already checkd them out, and they provided absolutely nothing besides yacc
currently im getting the game scripting mastery book, but itll take a week before it finishes dlding

in the meantime, any other links to parser howto's will be really helpfull
Cartman's definition of sexual harrasement:"When you are trying to have intercourse with a lady friend, and some other guy comes up and tickles your balls from behind"(watch South Park, it rocks)
Quote: Original post by caesar4
lua, python, ... are not options for they do not provide the necessary debug functionality.
How so? What debug functionality do you think they're missing?
desired debug features: monitoring of current scope and global variables in realtime, stack, current line of execution, memory usage, variable/function use counters, ..

reasons for a custom engine:
1) it will be tightly integrated with the other components of the game engine

2) lua, python, ... are well known, and may be hacked/exploited even with proper security measures

3) we are trying to use as few external libraries as possible (so far, only DX9, libogg and devIL)

4) i want to know how compilers work, for it might come in handy in college
Cartman's definition of sexual harrasement:"When you are trying to have intercourse with a lady friend, and some other guy comes up and tickles your balls from behind"(watch South Park, it rocks)
Quote: Original post by caesar4
desired debug features: monitoring of current scope and global variables in realtime, stack, current line of execution, memory usage, variable/function use counters, ..
Pretty much all of those are available, at least for Lua. I'm not sure about python, but I would assume it's the same way.
Quote: 1) it will be tightly integrated with the other components of the game engine
Lua's great for this sort of thing, because of how extensible the syntax is.
Quote: 2) lua, python, ... are well known, and may be hacked/exploited even with proper security measures
What exactly do you mean? If you're allowing random people to execute scripts, you're already hosed... and if you think you'll get better security performance from a custom-written solution than a language that's been tested and vetted for five years.... it seems unlikely.
Quote: 3) we are trying to use as few external libraries as possible (so far, only DX9, libogg and devIL)
Ok..why?
Quote: 4) i want to know how compilers work, for it might come in handy in college
Well, this reason is valid. IMHO, it's one of the very few valid reasons for someone to write their own scripting language. But if I were you, I'd separate it out as a different project. It's a complex enough project without having to balance it against other engine functionality.
Since this was first posted in my forum I'll take the oportunity to mention my own scripting language as an alternative to the other well-known ones.

AngelScript is a free open-source scripting library that have been in the works for about one and a half year. It is already quite powerful, and I'm constantly improving upon it. There are already quite a few projects using it as you can see from the site.

As to your questions, I have a couple of links that might interest you:

Compiler Construction: A Practical Approach

Implementing a Scripting Engine

Writing a Compiler

Other than that you could take a look at the compiler that I've written in AngelScript.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement