File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6363 $tryIdent = $script :luaString.Substring ($script :luaPos , $tryPos - $script :luaPos )
6464 # Check it's not a keyword that starts a value (true/false/nil)
6565 if ($tryIdent -notin ' true' , ' false' , ' nil' ) {
66- # Skip whitespace after identifier to check for '='
67- $peekPos = $tryPos
68- while ($peekPos -lt $script :luaString.Length -and
69- $script :luaString [$peekPos ] -match ' \s' ) {
70- $peekPos ++
71- }
66+ # Skip whitespace and comments after identifier to check for '='
67+ # Use Skip-LuaWhitespace with save/restore to handle comments
68+ $peekSavedPos = $script :luaPos
69+ $script :luaPos = $tryPos
70+ Skip-LuaWhitespace
71+ $peekPos = $script :luaPos
72+ $script :luaPos = $peekSavedPos
7273 # Check for '=' but not '=='
7374 if ($peekPos -lt $script :luaString.Length -and
7475 $script :luaString [$peekPos ] -eq ' =' -and
112113 $value = Read-LuaValue
113114 $assignments [$varName ] = $value
114115
116+ # Consume optional semicolons between assignment statements
115117 Skip-LuaWhitespace
118+ while ($script :luaPos -lt $script :luaString.Length -and
119+ $script :luaString [$script :luaPos ] -eq ' ;' ) {
120+ $script :luaPos ++
121+ Skip-LuaWhitespace
122+ }
116123 }
117124
118125 if ($script :luaAsPSCustomObject ) {
Original file line number Diff line number Diff line change @@ -452,6 +452,25 @@ B = { val = 2 }
452452 $result.My_Addon_DB.enabled | Should - BeTrue
453453 }
454454
455+ It ' Parses semicolon-separated assignment statements' {
456+ $lua = ' A = 1; B = 2; C = "three"'
457+ $result = ConvertFrom-Lua - InputObject $lua - AsHashtable
458+ $result.A | Should - Be 1
459+ $result.B | Should - Be 2
460+ $result.C | Should - Be ' three'
461+ }
462+
463+ It ' Parses assignments with comment between identifier and equals' {
464+ $lua = @'
465+ A --[[ comment ]]
466+ = { val = 1 }
467+ B = { val = 2 }
468+ '@
469+ $result = ConvertFrom-Lua - InputObject $lua - AsHashtable
470+ $result.A.val | Should - Be 1
471+ $result.B.val | Should - Be 2
472+ }
473+
455474 It ' Does not treat true/false/nil as assignments' {
456475 $result = ConvertFrom-Lua - InputObject ' true'
457476 $result | Should - BeTrue
You can’t perform that action at this time.
0 commit comments