Fixed null key/value bug, added tests

This commit is contained in:
jbeder
2009-07-30 06:49:09 +00:00
parent 49265fa12b
commit cb2b5783fa
8 changed files with 87 additions and 16 deletions

View File

@@ -61,17 +61,21 @@ namespace YAML
throw ParserException(Mark::null(), ErrorMsg::END_OF_MAP);
Token token = pScanner->peek();
if(token.type != TT_KEY && token.type != TT_BLOCK_END)
if(token.type != TT_KEY && token.type != TT_VALUE && token.type != TT_BLOCK_END)
throw ParserException(token.mark, ErrorMsg::END_OF_MAP);
pScanner->pop();
if(token.type == TT_BLOCK_END)
if(token.type == TT_BLOCK_END) {
pScanner->pop();
break;
}
std::auto_ptr <Node> pKey(new Node), pValue(new Node);
// grab key
pKey->Parse(pScanner, state);
// grab key (if non-null)
if(token.type == TT_KEY) {
pScanner->pop();
pKey->Parse(pScanner, state);
}
// now grab value (optional)
if(!pScanner->empty() && pScanner->peek().type == TT_VALUE) {