lua-users home
lua-l archive

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

On Tue, Sep 21, 2010 at 8:33 AM, Philippe Lhoste <> wrote:
> I see that Lua Fish <> is able to do that
> although I don't know what is the quality (raw or pretty-printed) of the
> output code.

Some assembly will likely be required.  LuaFish hasn't been designed
much as a code beautifier, it hasn't been maintained recently, and
many of the non-Lpeg aspects of it have been superseded by LuaInspect.

For code beautification, you may want to work on the lexical token
level rather than or in addition to the AST level, especially if
there's any original formatting you do want to preserve.  A decision
was made in LuaInspect to diverge from the stock Metalua parser AST
output to maintain three structures (source string, ordered token list
with character positions, and Metalua AST), and provide functions for
navigating between these three levels and mutating them.  The same
might be useful in a code beautifier.  There are no immediate
implementation plans, but one desired future enhancement to LuaInspect
is to support lexical-level coding style checks, as well as additional
refactorings (e.g. selecting a region of Lua code in a text editor and
telling it to reformat).  This is very much in the same realm as code