[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: DSL in lua
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 6 Dec 2012 08:15:14 +0200
On Thu, Dec 6, 2012 at 7:52 AM, Vasiliy Tolstov <v.tolstov@selfip.ru> wrote:
> directory "/etc/" {
> owner "root";
> group "wheel";
> mode "0755";
> action "create";
> }
Here is how to make this valid Lua:
0) use semicolons or commas as delimiters (my edit!)
1) directory is a function that takes a path string and returns a function
2) which takes a table argument
3) owner, group, etc are functions that take strings.
(Because of Lua call syntax sugar, we can leave out parens when there
is a single argument which is a string literal or a table constructor)
Alternative to 3), set table keys (since presumably order is not
important here?)
directory "/etc/" {
owner="root";
group="wheel";
mode="0755";
action="create";
}
If you don't want delimiters, the code can be converted into valid Lua
by a suitable string transformation, e.g a simple-minded replacement
of strings at end-of-line with the string plus semi-colon.
When executing such configuration Lua, run it in your own environment
that will contain the directory, etc functions and have no references
to dangerous global functions
steve d.