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

This commit is contained in:
Jesse Beder 2009-09-06 21:52:56 +00:00
parent e7ac6b3bf1
commit 5217149ed4
3 changed files with 10 additions and 16 deletions

View File

@ -123,16 +123,13 @@ namespace YAML
break; 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); std::auto_ptr <Node> pKey(new Node), pValue(new Node);
// grab key // grab key (if non-null)
pKey->Parse(pScanner, state); if(token.type == Token::KEY) {
pScanner->pop();
pKey->Parse(pScanner, state);
}
// now grab value (optional) // now grab value (optional)
if(!pScanner->empty() && pScanner->peek().type == Token::VALUE) { if(!pScanner->empty() && pScanner->peek().type == Token::VALUE) {

View File

@ -182,9 +182,6 @@ namespace YAML
// Value // Value
void Scanner::ScanValue() void Scanner::ScanValue()
{ {
// just in case we have an empty key
InsertPotentialSimpleKey();
// and check that simple key // and check that simple key
bool isSimpleKey = VerifySimpleKey(); bool isSimpleKey = VerifySimpleKey();

View File

@ -325,8 +325,8 @@ namespace Test {
parser.GetNextDocument(doc); parser.GetNextDocument(doc);
YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc.size() == 2);
YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago Cubs")].size() == 1); 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")][0] == "2001-07-23");
YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")].size() == 3); 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")][0] == "2001-07-02");
YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][1] == "2001-08-12"); YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][1] == "2001-08-12");