local CHAR_CLASSES = {
SPACE = "[%s]",
VARIABLE = "[%w_%-%.]",
- INTEGER = "[-]?[%d]",
- FLOAT = "[-]?[%d%.]",
+ INTEGER = "[+-]?[%d]",
+ FLOAT = "[+-]?[%d%.]",
FLAGS = "[%w_%-%.,]",
}
-- so we can later strip it from the rest of the line
.. "("
.. "([" .. CHAR_CLASSES.VARIABLE .. "+)" -- variable name
- .. CHAR_CLASSES.SPACE
+ .. CHAR_CLASSES.SPACE .. "*"
.. "%(([^%)]*)%)" -- readable name
- .. CHAR_CLASSES.SPACE
+ .. CHAR_CLASSES.SPACE .. "*"
.. "(" .. CHAR_CLASSES.VARIABLE .. "+)" -- type
- .. CHAR_CLASSES.SPACE .. "?"
+ .. CHAR_CLASSES.SPACE .. "*"
.. ")")
if not first_part then
if setting_type == "int" then
local default, min, max = remaining_line:match("^"
-- first int is required, the last 2 are optional
- .. "(" .. CHAR_CLASSES.INTEGER .. "+)" .. CHAR_CLASSES.SPACE .. "?"
- .. "(" .. CHAR_CLASSES.INTEGER .. "*)" .. CHAR_CLASSES.SPACE .. "?"
+ .. "(" .. CHAR_CLASSES.INTEGER .. "+)" .. CHAR_CLASSES.SPACE .. "*"
+ .. "(" .. CHAR_CLASSES.INTEGER .. "*)" .. CHAR_CLASSES.SPACE .. "*"
.. "(" .. CHAR_CLASSES.INTEGER .. "*)"
.. "$")
if setting_type == "float" then
local default, min, max = remaining_line:match("^"
-- first float is required, the last 2 are optional
- .. "(" .. CHAR_CLASSES.FLOAT .. "+)" .. CHAR_CLASSES.SPACE .. "?"
- .. "(" .. CHAR_CLASSES.FLOAT .. "*)" .. CHAR_CLASSES.SPACE .. "?"
+ .. "(" .. CHAR_CLASSES.FLOAT .. "+)" .. CHAR_CLASSES.SPACE .. "*"
+ .. "(" .. CHAR_CLASSES.FLOAT .. "*)" .. CHAR_CLASSES.SPACE .. "*"
.. "(" .. CHAR_CLASSES.FLOAT .. "*)"
.."$")
end
if setting_type == "enum" then
- local default, values = remaining_line:match("^(.+)" .. CHAR_CLASSES.SPACE .. "(.+)$")
+ local default, values = remaining_line:match("^"
+ -- first value (default) may be empty (i.e. is optional)
+ .. "(" .. CHAR_CLASSES.VARIABLE .. "*)" .. CHAR_CLASSES.SPACE .. "*"
+ .. "(" .. CHAR_CLASSES.FLAGS .. "+)"
+ .. "$")
if not default or values == "" then
return "Invalid enum setting"
if setting_type == "flags" then
local default, possible = remaining_line:match("^"
- .. "(" .. CHAR_CLASSES.FLAGS .. "+)" .. CHAR_CLASSES.SPACE .. ""
- .. "(" .. CHAR_CLASSES.FLAGS .. "+)"
+ -- first value (default) may be empty (i.e. is optional)
+ -- this is implemented by making the last value optional, and
+ -- swapping them around if it turns out empty.
+ .. "(" .. CHAR_CLASSES.FLAGS .. "+)" .. CHAR_CLASSES.SPACE .. "*"
+ .. "(" .. CHAR_CLASSES.FLAGS .. "*)"
.. "$")
if not default or not possible then
return "Invalid flags setting"
end
+ if possible == "" then
+ possible = default
+ default = ""
+ end
+
table.insert(settings, {
name = name,
readable_name = readable_name,