main.lua

Sat, 05 Sep 2015 14:42:23 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 05 Sep 2015 14:42:23 +0100
changeset 0
2e31b584f8d9
child 3
3cc860a893d2
permissions
-rwxr-xr-x

It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler

#!/usr/bin/env lua5.1

local parser = require "scansion.parser";

io.input(arg[1]);
local script_data = io.read("*a");

local script = assert(parser.parse(script_data));

local c = 0;
for name, object in pairs(script.objects) do
	local o = require("scansion.objects."..object.type);
	object.handler = o;
	o._validate(object);
	c = c + 1;
end

print("Script defines "..c.." objects, and "..#script.actions.." actions");

for _, action in pairs(script.actions) do
	local object = script.objects[action.object_name];
	local handler = object.handler;
	assert(handler[action.action], "Objects of type '"..object.type.."' do not support action '"..action.action.."'");
		
	handler[action.action](object, action.extra);
end

mercurial