lua-users home
lua-l archive

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


> I'd be interested to hear again why a hand written parser was adopted.

There were several reasons. As far as I remember, the main ones were these
(in decreasing relevance):

- Better control over code quality. The skeletons from yacc/bison
frequently use system #ifdefs, malloc.h, etc.

- Better control over static and extern variables. We were already
planning "stateless Lua".

- Possibility of using the C stack to hold some data structures. For
instance, with nested functions, we need one structure (with lots of
fields) for each function being compiled. With a recursive descendent
parser, it is trivial to allocate them as local variables. (To use
dynamic allocation for them is tricky, because in case of errors we must
be able to free them correctly...)

- Better error messages.

On the other hand, the syntax of Lua was already quite stable, so one of the
main advantages of yacc (easy of change) was not that important.

-- Roberto