2011-04-17 19:01:57 +02:00
|
|
|
------------
|
|
|
|
-- A module containing tables.
|
|
|
|
-- Shows how Lua table definitions can be conveniently parsed.
|
2012-11-11 17:50:33 +01:00
|
|
|
--
|
|
|
|
-- There may be multiple comment lines per field/parameter, and
|
|
|
|
-- such comments may begin with `TYPE:`
|
|
|
|
--
|
|
|
|
-- Functions also can be commented in a similar way, and the last
|
|
|
|
-- parameter's comment may be outside the parens.
|
|
|
|
--
|
2011-04-17 19:01:57 +02:00
|
|
|
-- @alias M
|
|
|
|
|
|
|
|
local tables = {}
|
|
|
|
local M = tables
|
|
|
|
|
2012-11-11 17:50:33 +01:00
|
|
|
--- a function.
|
|
|
|
function M.one(
|
|
|
|
bonzo, -- dog
|
|
|
|
-- has its day!
|
|
|
|
frodo) --baggins
|
|
|
|
end
|
|
|
|
|
|
|
|
--- first table.
|
2011-04-17 19:01:57 +02:00
|
|
|
-- @table one
|
|
|
|
M.one = {
|
|
|
|
A = 1, -- alpha
|
|
|
|
B = 2; -- beta
|
|
|
|
}
|
|
|
|
|
2012-11-11 17:50:33 +01:00
|
|
|
--- second table.
|
|
|
|
-- we don't need an explicit table tag, since it
|
|
|
|
-- can be inferred from the context.
|
|
|
|
M.two = {
|
|
|
|
N = 10, -- int: no. of cases
|
|
|
|
L = 'label' -- string: case label
|
|
|
|
}
|
|
|
|
|
2011-04-17 19:01:57 +02:00
|
|
|
return M
|
|
|
|
|