[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua AST and Parsing a "C" Like language
- From: Michal Kottman <k0mpjut0r@...>
- Date: Tue, 23 Aug 2011 00:19:42 +0200
On Tue, 2011-08-23 at 00:07 +0200, Axel Kittenberger wrote:
> This _is_ valid lua code, suppsing "WIDGET", "TILE", "TYPE",
> "ELEMENTS" etc have been declared as functions:
>
> WIDGET mywidget
> {
> TITLE "My widget";
> TYPE WIDGET_TYPE;
> ELEMENTS
> {
> element1,
> element2,
> element3
> }
> }
You need to change it to following (translation with fewest changes) to
be valid Lua code (the definition of necessary functions and their
semantics is up to you):
WIDGET "myWidget"
{
TITLE "My widget";
TYPE(WIDGET_TYPE);
ELEMENTS
{
element1, element2, element3
}
}
But I think the following is more "Lua-zen":
myWidget = WIDGET {
TITLE = "MyWidget",
TYPE = WIDGET_TYPE,
ELEMENTS = { element1, element2, element3 }
}
Also:
> IMPORT WIDGET mywidget
> {
> REFINE widget_name{
> REDEFINE TITLE "Your widget";
> }
> }
This is not valid Lua code...
> if YOUR_WIDGET_ALLOWED then
> ...
> endif
Lua has only 'end', therefore:
if YOUR_WIDGET_ALLOWED then ... end
Just my 2c.