Saturday, May 1, 2010

New Scripting Engine in Progress

Yup, I'm currently working on a scripting engine, named Shintaz, which is the name of another character in Rusher's series. You can check out the complete character lineup here.

The motivation is twofold: first, it is my term project for the compiler course I'm taking this semester; second, my ultimate purpose is to integrate this scripting engine with Rusher Game Framework, so that you may open a console, like those where you can enter cheat codes in many Valve games, and enter scripts. This is mostly for testing and debugging purposes.

The project SVN is already opened on Google Code. Here's the source folder and the documentation. I use the ASUnit framework for unit testing Shintaz. You can check out the testing project here.

The scripting engine is still a work in progress. So far, I've finished the scanner. There's still a long way to go, with the parser and virtual machine to be finished.

Here I'll show some code snippets for the scanner.

This is how a scanner is initialized. The parameter passed to the constructor is a string of script, or code.

Tokens of the code can be obtained by repeatedly calling the IScanner.getToken() method until the method returns null. Each token is consisted of a token type, an integer value, and a token value, whose data type depends of the token type. Here's what a piece of actual scanner code would look like.

The Token.toString() method is overridden to show both the token type and token value. This is what will be displayed on the output panel.

That's it. This is my current progress on Shintaz. I'll begin to work on the parser as soon as I can. Hopefully, the entire engine can be completed by the end of this month.

No comments: