[Yaml] fixed parsing of simple inline documents

This commit is contained in:
Fabien Potencier 2010-11-29 21:09:02 +01:00
parent 97cafc7218
commit 6e18a2c529
2 changed files with 16 additions and 2 deletions

View File

@ -80,7 +80,7 @@ class Parser
} else {
if (isset($values['leadspaces'])
&& ' ' == $values['leadspaces']
&& preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches)
&& preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches)
) {
// this is a compact notation element, add to next block and parse
$c = $this->getRealCurrentLineNb();
@ -97,7 +97,7 @@ class Parser
$data[] = $this->parseValue($values['value']);
}
}
} else if (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
} else if (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
$key = Inline::parseScalar($values['key']);
if ('<<' === $key) {

View File

@ -143,3 +143,17 @@ yaml: |
0123
php: |
array('foo' => "0123\n")
---
test: Document as a simple hash
brief: Document as a simple hash
yaml: |
{ foo: bar }
php: |
array('foo' => 'bar')
---
test: Document as a simple array
brief: Document as a simple array
yaml: |
[ foo, bar ]
php: |
array('foo', 'bar')