mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +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
62
node.cpp
62
node.cpp
|
@ -1,8 +1,11 @@
|
|||
#include "node.h"
|
||||
#include "token.h"
|
||||
#include "scanner.h"
|
||||
#include "content.h"
|
||||
#include "parser.h"
|
||||
#include "scalar.h"
|
||||
#include "sequence.h"
|
||||
#include "map.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
|
@ -20,4 +23,63 @@ namespace YAML
|
|||
delete m_pContent;
|
||||
m_pContent = 0;
|
||||
}
|
||||
|
||||
void Node::Parse(Scanner *pScanner)
|
||||
{
|
||||
ParseHeader(pScanner);
|
||||
|
||||
// now split based on what kind of node we should be
|
||||
Token *pToken = pScanner->PeekNextToken();
|
||||
if(pToken->type == TT_DOC_END)
|
||||
return;
|
||||
|
||||
switch(pToken->type) {
|
||||
case TT_SCALAR:
|
||||
m_pContent = new Scalar;
|
||||
m_pContent->Parse(pScanner);
|
||||
break;
|
||||
case TT_FLOW_SEQ_START:
|
||||
case TT_BLOCK_SEQ_START:
|
||||
case TT_BLOCK_ENTRY:
|
||||
m_pContent = new Sequence;
|
||||
m_pContent->Parse(pScanner);
|
||||
break;
|
||||
case TT_FLOW_MAP_START:
|
||||
case TT_BLOCK_MAP_START:
|
||||
m_pContent = new Map;
|
||||
m_pContent->Parse(pScanner);
|
||||
}
|
||||
}
|
||||
|
||||
// ParseHeader
|
||||
// . Grabs any tag, alias, or anchor tokens and deals with them.
|
||||
void Node::ParseHeader(Scanner *pScanner)
|
||||
{
|
||||
while(1) {
|
||||
Token *pToken = pScanner->PeekNextToken();
|
||||
if(!pToken || pToken->type != TT_TAG || pToken->type != TT_ANCHOR || pToken->type != TT_ALIAS)
|
||||
break;
|
||||
|
||||
pScanner->PopNextToken();
|
||||
switch(pToken->type) {
|
||||
case TT_TAG:
|
||||
break;
|
||||
case TT_ANCHOR:
|
||||
break;
|
||||
case TT_ALIAS:
|
||||
break;
|
||||
}
|
||||
delete pToken;
|
||||
}
|
||||
}
|
||||
|
||||
void Node::Write(std::ostream& out, int indent)
|
||||
{
|
||||
if(!m_pContent) {
|
||||
for(int i=0;i<indent;i++)
|
||||
out << " ";
|
||||
out << "{no content}\n";
|
||||
} else
|
||||
m_pContent->Write(out, indent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue