tutorials or introductions to writing a simple scripting language?

Kalisme picture Kalisme · Jan 15, 2012 · Viewed 12k times · Source

I know there are a few questions floating around here on the subject, but it was hard to find anything useful to what I'm after...

I also know it will probably end up being quite the task to complete, but I really want to make a simple scripting language for gaming engines... I want to use it in C++ and my Android Java game engines... but I don't know where to start... I've tried looking for tutorials online, but alot require converting things to byte code, virtual machines and such...

I really just want to create a simple scripting language which can be read from the engine, have some simple "if/else" logic... simple functions that can be called from other scripts and so on... Maybe even simpler for early versions... I really don't know where to start, but I do know this is something I need to start studying and understanding.

If anyone could point me in the right direction and point out some links to very simple "making a simple scripting language for games" kind of tutorial or even point out some key concepts that I should look into... I'd be really thankful.

I'd prefer a minimalist C based scripting language, but I guess the specifics will come into it once I've actually learnt more about it.

Thanks for any help anyone can give.

Answer

Miguel picture Miguel · Jan 15, 2012

I've tried looking for tutorials online, but alot require converting things to byte code, virtual machines and such

Yes. This is really the approach, even for a dead simple language. Executing the source code directly will be way more complicated, the way this is done is first you parse the source code and digest it into byte code, then have a virtual machine interpret the byte code.

You may want to look at existing languages to learn about their design.

This tutorial from flipcode builds a simple language and includes all the code, so it might be useful.

You can also take a look at the Lua source code.