[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: DSL in lua
- From: Philipp Janda <siffiejoe@...>
- Date: Mon, 10 Dec 2012 06:31:56 +0100
Am 10.12.2012 05:22, schrieb Vasiliy Tolstov:
2012/12/7 Philipp Janda <siffiejoe@gmx.net>:
- add +V"file" after V"directory inside the parentheses in the startrule
Does it possible to rewrite example to avoid this big line in case of
many block/rules ?
If all your blocks look the same, sure:
local btype = C( W"directory" + W"file" + W"link" + W"socket" )
-- or even: local btype = ID
startrule( "dsl", _ * (V"block")^0 * eof )
rule( "block", btype * _ * (str_E) * _ * (P"{"+E"{ expected") * _ *
(V"owner" + V"group" + V"mode" + V"action")^0 *
(P"}"+E"owner|group|mode|action|} expected") * _ )
Your ast nodes look slightly different then:
- the node id is "block" instead of "file", "directory", etc.
- the first sub-element is the type of the block -> "file", etc.
- all other sub-elements are shifted by one.
HTH,
Philipp