[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua DSL for configuration
- From: Vaughan McAlley <ockegheim@...>
- Date: Wed, 28 Apr 2010 21:51:01 +1000
Depending on how regular the declarations are, pattern matching seems
easier than messing with syntax:
local file = [[
VARIABLE "MyVar" = "Hello"
VARIABLE "OtherVar"="Goodbye"
]]
for name, value in string.gmatch(file,
"VARIABLE%s*\"([%w_]+)\"%s*=%s*\"([^\"]*)\"") do
_G[name] = value
end
print(MyVar, OtherVar)
--> Hello Goodbye
Vaughan