lua-users home
lua-l archive

Re: [ANN] ltokenp, a token processor for Lua

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


> 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," ")
end
> A safe table navigator symbol would be a fun thing to implement too.
What do you mean?

AltStyle によって変換されたページ (->オリジナル) /