lua-users home
lua-l archive

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



Le 26 mai 08 à 21:55, Luiz Henrique de Figueiredo a écrit :
DATETIME
VARCHAR(10)
FLOAT(10,2)

Why do you need to parse those expressions with patterns?
Why not execute them, given that they are valid Lua code?
Try this:

setmetatable(_G,{ __index= function(t,v)
		return function (...) print(v,...) end
	end })

function try(s)
	assert(loadstring(s))()
end

try"DATETIME()"		-- had to add () here...
try"VARCHAR(10)"
try"FLOAT(10,2)"

Hehe, this is interesting ! It won't work for what I am doing now because there can be more data after the initial data like "FLOAT(10,2) UNSIGNED DEFAULT '0.0'", but for sure I'll keep the idea somewhere in my brain. That's really what I like with Lua, but it takes time to think this way... Thank you :)


--
Bertrand Mansion
Mamasam
Work : http://www.mamasam.com
Blog : http://golgote.freeflux.net