1
0
Fork 0

Fixed parse_keyword() from making null -> false

master
rxi 2015-08-11 21:10:17 +01:00
parent 8b9c820218
commit 157fa12fae
1 changed files with 7 additions and 1 deletions

View File

@ -125,6 +125,12 @@ local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",")
local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u") local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
local keywords = create_set("true", "false", "null") local keywords = create_set("true", "false", "null")
local keyword_map = {
[ "true" ] = true,
[ "false" ] = false,
[ "null" ] = nil,
}
local function next_char(str, idx, set, negate) local function next_char(str, idx, set, negate)
for i = idx, #str do for i = idx, #str do
@ -216,7 +222,7 @@ local function parse_keyword(str, i, chr)
if not keywords[word] then if not keywords[word] then
decode_error(str, i, "invalid keyword '" .. word .. "'") decode_error(str, i, "invalid keyword '" .. word .. "'")
end end
return (chr == "t") and true or (chr == "f") and false, x return keyword_map[word], x
end end