Support terminating commas before the closing bracket in arrays

This commit is contained in:
Leonel Quinteros 2013-02-27 13:29:57 -03:00
parent 66b7720028
commit c2f86aea0a
3 changed files with 8 additions and 5 deletions

View File

@ -18,7 +18,6 @@ Supports commit: f68d014bfd4a84a64fb5f6a7c1a83a4162415d4b
TODO
----
- Support terminating commas before the closing bracket in arrays
- Throw exception on extra chars after keygroup definition
- Throw exception on mixed data type arrays
- Throw exception on key or keygroup overwriting

View File

@ -307,7 +307,11 @@ class Toml
if($openBrackets == 0)
{
$result[] = self::parseValue( trim($buffer) );
// Allow terminating commas before the closing bracket
if(trim($buffer) != '')
{
$result[] = self::parseValue( trim($buffer) );
}
// Skip first and las brackets. We're finish.
return $result;

View File

@ -11,7 +11,7 @@ dob = 1979-05-27T07:32:00Z # First class dates? Why not?
[database]
server = "192.168.1.1"
ports = [ 8001, 8001, 8002 ]
ports = [ 8001, 8001, 8002, ]
connection_max = 5000
enabled = true
@ -38,11 +38,11 @@ key = [
],
[
"10.0.0.1", "Escaped \" quote"
]
],
]
# Line breaks are OK when inside arrays
hosts = [
"alpha # Try this hash", # Comment here, after string hash.
"omega"
"omega",
]