Skip to content
Snippets Groups Projects
Commit 5217149e authored by Jesse Beder's avatar Jesse Beder
Browse files

Fixed bug with complex keys (and simplified the parsing for flow maps)

parent e7ac6b3b
No related branches found
Tags release-0.2.7
No related merge requests found
......@@ -122,24 +122,21 @@ namespace YAML
pScanner->pop();
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) {
pScanner->pop();
pValue->Parse(pScanner, state);
}
// now eat the separator (or could be a map end, which we ignore - but if it's neither, then it's a bad node)
Token& nextToken = pScanner->peek();
if(nextToken.type == Token::FLOW_ENTRY)
......
......@@ -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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment