lua-users home
lua-l archive

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

Hi all,
 being my first post on this mailing list I'd like to thank everyone
(team and community) for Lua itself and the great load of useful Lua
code around.

To the point: I have modified Lua code to change the parser. The
result is that it that parses differently from Lua (but generates the
same bytecode and has the same API). The main changes are quite small
(with one exception) so that most Lua code will compile anyway.

Precisely the changes are:
- short comments are not allowed (the BIG change) and '--' is
considered as an identifier
- '.' to access table objects only works if not preceeded by a space
otherwise is considered as an identifier
- in a statement, the first token is always interpreted as an
identifier (so that ? = 1 is valid) if it is not a keyword
- every statement which starts with an identifier not followed by a
list of ',' and other identifiers, plus an assignment does not
generate an error but translates in a call of that identifier instead.
The remaining characters until subsequent '\n', '\r', or';' (and, of
course, EOS/EOZ) are absorbed in a literal string and passed as an
argument to the call. Thus "foo bar" is equivalent to foo(' bar') and
"foo" is foo(nil).

Why so strange? I'll explain in a minute. Before that I'd like to say
that it was an easy task. I had to touch three files only and diff is
about 260 total lines (mostly commented out development code). Lua is
wonderfully coded!

I have now a complete Lua-like shell, written on top of this patch.
Some fun things I could do are:
- dynamic prompt (a function in Lua that returns a string) that
supports escape sequences (e.g. colors)
- callbacks to override history behaviour
- binding of keystrokes to different actions (not actually Lua
callbacks as of now, but a predefined set) through Lua function "bind"
- I have the feeling that it uses POSIX only, but cannot be sure
- and most of all, bash-like completion. Obviously, it is written in
Lua! so it should be easy to extend from present PATH/currentdir file
- and clearly accepts Lua code so it has full introspection and all
the wonderful things that Lua provides.

For non bash-power-users should be very similar to bash (I had to
prefix my prompt with "LSH: " to tell the difference). I hope it to be
at least as powerful as soon as possible.

I think the possibilities are so many. I have lots of ideas which
could be useful (or not)but I will not list here for brevity.

I need help on a few issues.

First and foremost I need to understand all license issues around the
code I used. I'd very appreciate any help on this. I used this Lua
patch I described above (I assume modifying code and not
redistributing is allowed :P ) and this light replacement of readline:

which is under MIT license and seems discontinued from 2004. I'd like
to release this under a permissive license. Perfect would be the same
as Lua (whichever). Is it possible? How?

If it is ok I'll post patches to Lua 5.1.2. I hope someone is interested.

As I'm a bad programmer you'd better be advised that the code is not
well indented and contains lot of commented out code. Sorry, I can't
help. If you _really_ want you could point out things which do not
work as intended above (and bugs: there should be plenty of them), I'd
The patched Lua should work in every way as vanilla one but for
parsing. (this would allow compiling plain Lua script to be loaded
during initialization)

As soon as possible I will pack the lsh code and put it somewhere (I
don't know where).

I strongly hope this is of some interest for someone. If so, please
tell me. I'm developing in spare time, thus knowing it is not wasted
time helps. If you mind, let me know, please.

Thanks to all,

Mauro Iazzi