lua-users home
lua-l archive

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


On 06/12/2012 07:47, steve donovan wrote:
On Thu, Dec 6, 2012 at 7:52 AM, Vasiliy Tolstov <v.tolstov@selfip.ru> wrote:
can be possible via base lua or using lpeg.

The advantage of lpeg of course is that your DSL is defined exactly
and does not suffer from the problems of being a fully-executable Lua
script (much as JavaScript people would never parse JSON by simply
interpreting it).

An entertaining project (or maybe it already exists?) would be a
lpeg-based DSL generation tool

You would give it something like:

MUST directory STRING {
   owner IDEN
   group IDEN
   mode STRING
   action IDEN
}

which would match this syntax (there MUST be a directory clause)

directory "/etc/" {
   owner root
   group wheel
   mode "0755"
   action create
}

and create a parser that brings this in as a table structure. ( It
would issue sensible errors at the right place, which is a tricky
thing with lpeg)

steve d.

I did this once (around the WML language of Wesnoth). It is in fact, in my view, just like a semantic schema, but at the (meta-)level of language/grammar def instead of language usage. If I did it again, I would use plain s-exps as the base, fondamental meta-grammar: it is the only case I know where absence of any distinction actually is an advantage.

Denis