lua-users home
lua-l archive

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

> I was thinking of having the essential language construct be a syntax
> like this
>   (name="Bush" job="president")   ,
> which looks an awful lot like
>   {name="Bush", job="president"}   !

Like I said, in this case the easiest thing is to prepend "return" to the
file (or change the lexer to start with this token, a one-line change [*]).

The user writes things like

 {name="Bush", job="president"},

or better, with constructors:

 person{name="Bush", job="president"},

where "person" is a "internal function", which the user sees as a primitive.
Lua then sees this as
 return person{name="Bush", job="president"},

The prepended "return" forces that no procedural constructs can appear in
the configuration file. (Except for calling anonymous functions, which can
be flagged at run time.)

I'm sorry to repeat my suggestion; I'm probably missing something.

[*] llex.c
<   LS->lookahead.token = TK_EOS;  /* no look-ahead token */
>   LS->lookahead.token = TK_RETURN;  /* start with return */