lua-users home
lua-l archive

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

i have written a lua table / variable serializer (as i suppose many others have)

but it doesn't
a/   preserve order of named fields
2/   preserve comments on read/re-write
III/ preserve blank lines

i can see how to do a/ , but before i do any work on this i thought i would ask...

requirements :

a routine that can read a text file similar to :

-- this is a dummy config file
-- general prefs
name = "fred"
age = 12
colour = "red"

-- favorite things
prefers = {"fish", "wine", "tobacco" }

-- end config

into a table (that's easy), and then a routine to write it back (also easy), in source-file order (harder), with the comments (line comments only is good enough).

has someone done this ? it would seem to be a generally useful utility.

i'll probably end up writing it myself soon if not.

(why serialise via xml if you can do it in lua)