lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello!

I'm developing a hardware testing framework, and I'm using Lua to
define test scripts. Test scripts are mostly declaration that handled
by C++ side, but I allow to add pure Lua functions as data processing
routines.

The very simple test description, in way it currently looks like is shown below.
The problem problem I have with the current syntax of my test
description, is that I have to put commas or colons after each entry,
which seems to be the main source of syntax errors, because they are
often forgotten. I'm seeking the way to make them optional, to make
user's  Is this involves modifying lua parser or there some other ways
to achieve the effect? If yes, would it be difficult (I've never
before modified Lua parser)?

How the current test looks like:
--cut--
test
{
	name = "An example test";
	description = "Just an example test";
	duration = "20s";

	main {		
		on_timer {
			interval = "3s";

			write { ioe = "IO_MCN_ATTN_LIGHT_YELLOW_SEL"; value = 0; tag="some
write operation"; };
			read { ioe = "IO_MCN_REAR_DOOR_UTIL_UNLOCKED"; };
			read { ioe = "IO_DIAG_MCN_ENCODER_ANGLE"; tag="some read operation"; };
		};

		on_timer {
			interval = "1s";
			delay = "15s";
			ntimes = 3;
			
			read { ioe = "IO_MCN_FPGA_SELECT"; check{ min = 10; max = 20; };
tag="main_on_timer2_1"; };
			read { ioe = "IO_MCN_REAR_DOOR_UTIL_UNLOCKED"; tag="main_on_timer2_2"; };
		};
	};
};
--end of cut--

Constructors for test sections are simple function adding type to the
table and returning it:
--cut--
local function initEntryContructors()
	local entryTypes =
			Set{ 	"node", 			"on_angle", 	"on_start",
					"on_stop", 			"on_timer", 	"read",
					"write", 			"array",		"return_array",
					"report_errors", 	"init",			"check", 			
					"main",				"sleep" }
	
	for entry in pairs(entryTypes) do
		_G[entry] = function(tb)
						tb.__type = entry;
						return tb;
					end
	end
end
--end of cut--


--
Best regards,
Zigmar