[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua code pretty-printer
- From: David Manura <dm.lua@...>
- Date: Tue, 21 Sep 2010 19:59:17 -0400
On Tue, Sep 21, 2010 at 8:33 AM, Philippe Lhoste <PhiLho@gmx.net> wrote:
> I see that Lua Fish <http://lua-users.org/wiki/LuaFish> 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
beautification.