Yet another scripting language

Published July 18, 2011
Advertisement
I've got to the point where I'm thinking about plug-in support for Opus and after many hours sitting in a cafe scribbling notes about the pros and cons of DLLs, I decided that a scripted solution was the way forward. I've been looking into various options and, as per usual with a hobby project, became interested in writing my own. Again.

I've written lots and lots of scripting languages (compiled to byte-code and executed on a stack-based VM) in the past and wanted to do something a bit different this time.

Lua's tables interested me greatly. So I've been working on a language that borrows a little from this concept, but hopefully introduces some interesting concepts.

I've written a parser that can build an abstract syntax tree for syntax like the following:

[source]
[10,a=3,(a){ b=a; }][c.method[3]];

main=(args)
{
f=[4,func=(x){ x=10; },9];
g=f.func();
};
[/source]

Looks like gibberish, I know, but the basic idea is that any entity, including constants, are basically lists and can be subscripted with indices, subscripted with method names as string literals or have their members accessed via member name with a . operator.

The main interesting feature I'm going for is that an actual function, declared with the (){ /* ... */ } syntax, is just a value like any other and can be assigned to a variable. Internally, a function is just a list of parameter names and a list of statements, which can obviously contain other functions.

[EDIT - after I posted, realised going to have to rethink that syntax as an expression could start with an opening parenthesis. May have to accept a function keyword to start the declaration instead.]

I'm thinking that the VM is going to create and maintain reference-counted list of actual list instances. So even just a literal decimal will still be created as a list with one item in it. Not to sure how this is going to work really.

Variables will be dynamically typed and basically just references to list instances. Lists will be able to contain other lists and so on and the VM instruction set will be heavily geared up to making list access as efficient as possible.

Huge numbers of potential issues ahead, I'm sure, but its a fun project. Probably not going to have much time to work on it as real life comes crashing back in.

----------------------------------------------

Got a month's sobriety behind me on Saturday and appear to have achieved my dream job out of nowhere. Funny how this stuff works. Not too sure how much I can say about it at the moment out of professional etiquette but I'm pretty excited in my own way.

----------------------------------------------

So being an Outstanding Forum Member didn't last long then :). Oh well, that was nice while it lasted. Just have to be happy being an Owner of Outstanding Buns instead.
Previous Entry Er
Next Entry New job begins
0 likes 4 comments

Comments

Deyja
What's wrong with DLL-based plugins, so they can be written in many different languages? (And then you implement your scripting language plugins using a DLL wrapper.)
July 19, 2011 02:56 AM
Aardvajk
Good question. Er, dunno. Hadn't really thought of implementing scripting via a DLL plugin. Could even then support different scripting languages via different plugins as well.

Ping! Thank you for the lightbulb moment. :)
July 19, 2011 09:06 AM
Gaiiden
I still see Outstanding Forum Member credited to you under Awards in your profile...
July 23, 2011 03:20 AM
Aardvajk
Oh yeah. Doh! Just lost my little badge thingy. Not to worry.
July 23, 2011 10:54 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement