Quickly processing "Lua" files

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Quickly processing "Lua" files

Soni "They/Them" L.
Hello!

I need a simple and quick way to process valid Lua files. Namely, I need
to look at the space between freeform text (strings, comments, etc), and
potentially modify it. However, one must note that such freeform text
may appear in tables, or in indexing operations, or in function calls,
and so on, and I need to be able to handle that as well.

Is there an easy way to scan "Lua" files for lexical tokens and being
able to rearrange them without going with a full parser?

Reply | Threaded
Open this post in threaded view
|

Re: Quickly processing "Lua" files

Luiz Henrique de Figueiredo
> Is there an easy way to scan "Lua" files for lexical tokens and being
> able to rearrange them without going with a full parser?

Try my ltokenp at http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/

Reply | Threaded
Open this post in threaded view
|

Re: Quickly processing "Lua" files

Soni "They/Them" L.


On 2019-03-24 8:43 p.m., Luiz Henrique de Figueiredo wrote:
>> Is there an easy way to scan "Lua" files for lexical tokens and being
>> able to rearrange them without going with a full parser?
> Try my ltokenp at http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/
>

This looks more like a patched Lua interpreter. Is there any way to
build this as a Lua module for Lua 5.1/5.2/5.3/LuaJIT and use it from,
say, LÖVE or something? I'd like to package the original sources rather
than ltokenp-processed files.

Sorry, I think I forgot to specify that I wanna do this from Lua, not
with an external tool. .-.

Reply | Threaded
Open this post in threaded view
|

Re: Quickly processing "Lua" files

dyngeccetor8
In reply to this post by Soni "They/Them" L.
On 25/03/2019 02.21, Soni "They/Them" L. wrote:

> Hello!
>
> I need a simple and quick way to process valid Lua files. Namely, I need to look
> at the space between freeform text (strings, comments, etc), and potentially
> modify it. However, one must note that such freeform text may appear in tables,
> or in indexing operations, or in function calls, and so on, and I need to be
> able to handle that as well.
>
> Is there an easy way to scan "Lua" files for lexical tokens and being able to
> rearrange them without going with a full parser?
>
> [...]
>
> Sorry, I think I forgot to specify that I wanna do this from Lua, not with an
> external tool. .-.

I don't know such.

Snow-like information injection is not too common task in this lands.

You may use full Lua parser from my "lcf" rock. It's command "lua.get_ast"
returns full syntax tree for given Lua file. With comments and whitespaces
folded hierarchically. After modification you need to compile tree back
to string. Which is easy, just DFS and concat all string items.

-- Martin

Reply | Threaded
Open this post in threaded view
|

Re: Quickly processing "Lua" files

Egor Skriptunoff-2
In reply to this post by Soni "They/Them" L.
On Mon, Mar 25, 2019 at 2:27 AM Soni "They/Them" L. <[hidden email]> wrote:
Hello!

I need a simple and quick way to process valid Lua files. Namely, I need
to look at the space between freeform text (strings, comments, etc), and
potentially modify it. However, one must note that such freeform text
may appear in tables, or in indexing operations, or in function calls,
and so on, and I need to be able to handle that as well.

Is there an easy way to scan "Lua" files for lexical tokens and being
able to rearrange them without going with a full parser?



Look at