[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] ltokenp, a token processor for Lua
- From: Russell Haley <russ.haley@...>
- Date: Sat, 18 Nov 2017 19:26:36 -0800
On Fri, Nov 17, 2017 at 2:46 AM, Luiz Henrique de Figueiredo
>> Late night thought. I want to implement a way to tell Lua to wrap a
>> segment of text and run it as the arguments of os.execute(). Could you
>> give me a hint on how I would do that with ltokenp?
> ltokenp does not see whitespace. This could be a problem for this application.
> If you don't mind putting the text inside quotes, then something like this
> works with ltokenp:
> `"ls *.lua"
> Here is the filter:
> -- replace ` with os.execute
> function FILTER(line,token,text,value)
> local t=text
> if t=="<file>" or t=="<eof>" then return end
> if t=="<string>" then value=string.format("%q",value) end
> if t=="`" then value="os.execute" end
> io.write(value," ")
Thank you, I look forward to the rabbit hole I just fell down.
>> A safe table navigator symbol would be a fun thing to implement too.
> What do you mean?