@@ -19,7 +19,7 @@ local record tinytoml
1919 _LICENSE : string
2020end
2121
22- tinytoml._VERSION = " tinytoml 0.0.1 "
22+ tinytoml._VERSION = " tinytoml 0.0.4 "
2323tinytoml._DESCRIPTION = " a single-file pure Lua TOML parser"
2424tinytoml._URL = " https://github.com/FourierTransformer/tinytoml"
2525tinytoml._LICENSE = " MIT"
@@ -298,7 +298,7 @@ local function handle_backslash_escape(sm: StateMachine): string, boolean
298298
299299 -- unicode escape sequences
300300 -- hex escapes coming in toml 1.1.0, will need to update
301- sm._ , sm.end_seq , sm.match , sm.ext = sm.input :find (" ^(u)([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])" , sm.i + 1 ) as (integer, integer, string)
301+ sm._ , sm.end_seq , sm.match , sm.ext = sm.input :find (" ^(u)([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])" , sm.i + 1 ) as (integer, integer, string, string )
302302 if not sm.match then
303303 sm._ , sm.end_seq , sm.match , sm.ext = sm.input :find (" ^(U)([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])" , sm.i + 1 ) as (integer, integer, string, string)
304304 end
@@ -326,6 +326,7 @@ local function close_string(sm: StateMachine)
326326
327327 -- check for multiline and setup accordingly
328328 if second == chars.DOUBLE_QUOTE and third == chars.DOUBLE_QUOTE then
329+ if sm.mode == " table" then _error (sm, " Cannot have multiline strings as table keys" , " table" ) end
329330 sm.multiline_string = true
330331 start_field = sm.i + 3
331332 -- toml allows a newline at the beginning of a triple quote
@@ -411,6 +412,7 @@ local function close_literal_string(sm: StateMachine)
411412
412413 -- check for multiline and setup accordingly
413414 if second == chars.SINGLE_QUOTE and third == chars.SINGLE_QUOTE then
415+ if sm.mode == " table" then _error (sm, " Cannot have multiline strings as table keys" , " table" ) end
414416 sm.multiline_string = true
415417 start_field = sm.i + 3
416418 -- toml allows a newline at the beginning of a triple quote
@@ -619,18 +621,18 @@ local function validate_datetime(sm: StateMachine, value: string): boolean
619621 --TODO: maybe refactor at some point?
620622 if sm.ext :find (" ^%.%d+$" ) then
621623 sm.value_type = " datetime-local"
622- sm.value = sm.type_conversion [sm.value_type ](sm.match .. sm.ext : sub ( 1 , 4 ) )
624+ sm.value = sm.type_conversion [sm.value_type ](sm.match .. sm.ext )
623625 return true
624626 elseif sm.ext :find (" ^%.%d+Z$" ) then
625627 sm.value_type = " datetime"
626- sm.value = sm.type_conversion [sm.value_type ](sm.match .. sm.ext : sub ( 1 , 4 ) )
628+ sm.value = sm.type_conversion [sm.value_type ](sm.match .. sm.ext )
627629 return true
628630 elseif sm.ext :find (" ^%.%d+[+-]%d%d:%d%d$" ) then
629631 sm._ , sm.end_seq , hour, min = sm.ext :find (" ^%.%d+[+-](%d%d):(%d%d)$" ) as (integer, integer, string, string)
630632 if _tointeger (hour) > 23 then _error (sm, " Hours must be less than 24. Found hour: " .. hour .. " in: " .. sm.match , " offset-date-time" ) end
631633 if _tointeger (min) > 59 then _error (sm, " Minutes must be less than 60. Found minute: " .. min .. " in: " .. sm.match , " offset-date-time" ) end
632634 sm.value_type = " datetime"
633- sm.value = sm.type_conversion [sm.value_type ](sm.match .. sm.ext : sub ( 1 , 4 ) )
635+ sm.value = sm.type_conversion [sm.value_type ](sm.match .. sm.ext )
634636 return true
635637 elseif sm.ext :find (" ^[Zz]$" ) then
636638 sm.value_type = " datetime"
0 commit comments