Fixed bug with complex keys (and simplified the parsing for flow maps)
This commit is contained in:
parent
e7ac6b3bf1
commit
5217149ed4
13
src/map.cpp
13
src/map.cpp
@ -123,16 +123,13 @@ namespace YAML
|
||||
break;
|
||||
}
|
||||
|
||||
// now it better be a key
|
||||
if(token.type != Token::KEY)
|
||||
throw ParserException(token.mark, ErrorMsg::END_OF_MAP_FLOW);
|
||||
|
||||
pScanner->pop();
|
||||
|
||||
std::auto_ptr <Node> pKey(new Node), pValue(new Node);
|
||||
|
||||
// grab key
|
||||
pKey->Parse(pScanner, state);
|
||||
// grab key (if non-null)
|
||||
if(token.type == Token::KEY) {
|
||||
pScanner->pop();
|
||||
pKey->Parse(pScanner, state);
|
||||
}
|
||||
|
||||
// now grab value (optional)
|
||||
if(!pScanner->empty() && pScanner->peek().type == Token::VALUE) {
|
||||
|
@ -182,9 +182,6 @@ namespace YAML
|
||||
// Value
|
||||
void Scanner::ScanValue()
|
||||
{
|
||||
// just in case we have an empty key
|
||||
InsertPotentialSimpleKey();
|
||||
|
||||
// and check that simple key
|
||||
bool isSimpleKey = VerifySimpleKey();
|
||||
|
||||
|
@ -325,8 +325,8 @@ namespace Test {
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
YAML_ASSERT(doc.size() == 2);
|
||||
YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago Cubs")].size() == 1);
|
||||
YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago Cubs")][0] == "2001-07-23");
|
||||
YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago cubs")].size() == 1);
|
||||
YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago cubs")][0] == "2001-07-23");
|
||||
YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")].size() == 3);
|
||||
YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][0] == "2001-07-02");
|
||||
YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][1] == "2001-08-12");
|
||||
|
Loading…
Reference in New Issue
Block a user