mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 22:11:26 +12:00
Finished parsing of basic data types (scalar, sequence, map).
This commit is contained in:
parent
c1966ba3fc
commit
121c2e577f
20 changed files with 434 additions and 221 deletions
34
document.cpp
34
document.cpp
|
@ -1,5 +1,7 @@
|
|||
#include "document.h"
|
||||
#include "node.h"
|
||||
#include "token.h"
|
||||
#include "scanner.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
|
@ -17,4 +19,36 @@ namespace YAML
|
|||
delete m_pRoot;
|
||||
m_pRoot = 0;
|
||||
}
|
||||
|
||||
void Document::Parse(Scanner *pScanner)
|
||||
{
|
||||
Clear();
|
||||
|
||||
// we better have some tokens in the queue
|
||||
if(!pScanner->PeekNextToken())
|
||||
return;
|
||||
|
||||
// first eat doc start (optional)
|
||||
if(pScanner->PeekNextToken()->type == TT_DOC_START)
|
||||
pScanner->EatNextToken();
|
||||
|
||||
// now create our root node and parse it
|
||||
m_pRoot = new Node;
|
||||
m_pRoot->Parse(pScanner);
|
||||
|
||||
// and finally eat any doc ends we see
|
||||
while(pScanner->PeekNextToken() && pScanner->PeekNextToken()->type == TT_DOC_END)
|
||||
pScanner->EatNextToken();
|
||||
}
|
||||
|
||||
std::ostream& operator << (std::ostream& out, const Document& doc)
|
||||
{
|
||||
if(!doc.m_pRoot) {
|
||||
out << "{empty node}\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
doc.m_pRoot->Write(out, 0);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue