mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-10 08:51:28 +12:00
Small refactoring.
This commit is contained in:
parent
72b443375c
commit
2e27c5d9c3
4 changed files with 20 additions and 42 deletions
|
@ -12,6 +12,7 @@ namespace YAML
|
||||||
class IllegalMapValue: public Exception {};
|
class IllegalMapValue: public Exception {};
|
||||||
class IllegalScalar: public Exception {};
|
class IllegalScalar: public Exception {};
|
||||||
class IllegalTabInScalar: public Exception {};
|
class IllegalTabInScalar: public Exception {};
|
||||||
|
class IllegalFlowEnd: public Exception {};
|
||||||
class DocIndicatorInQuote: public Exception {};
|
class DocIndicatorInQuote: public Exception {};
|
||||||
class EOFInQuote: public Exception {};
|
class EOFInQuote: public Exception {};
|
||||||
class RequiredSimpleKeyNotFound: public Exception {};
|
class RequiredSimpleKeyNotFound: public Exception {};
|
||||||
|
|
16
scanner.cpp
16
scanner.cpp
|
@ -288,22 +288,6 @@ namespace YAML
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IncreaseFlowLevel
|
|
||||||
void Scanner::IncreaseFlowLevel()
|
|
||||||
{
|
|
||||||
// TODO: Push simple key
|
|
||||||
m_flowLevel++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DecreaseFlowLevel
|
|
||||||
void Scanner::DecreaseFlowLevel()
|
|
||||||
{
|
|
||||||
if(m_flowLevel > 0) {
|
|
||||||
m_flowLevel--;
|
|
||||||
// TODO: Pop simple key
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetNextToken
|
// GetNextToken
|
||||||
// . Returns the next token on the queue, and scans if only we need to.
|
// . Returns the next token on the queue, and scans if only we need to.
|
||||||
Token *Scanner::GetNextToken()
|
Token *Scanner::GetNextToken()
|
||||||
|
|
|
@ -22,8 +22,6 @@ namespace YAML
|
||||||
void ScanToNextToken();
|
void ScanToNextToken();
|
||||||
Token *PushIndentTo(int column, bool sequence);
|
Token *PushIndentTo(int column, bool sequence);
|
||||||
void PopIndentTo(int column);
|
void PopIndentTo(int column);
|
||||||
void IncreaseFlowLevel();
|
|
||||||
void DecreaseFlowLevel();
|
|
||||||
|
|
||||||
void InsertSimpleKey();
|
void InsertSimpleKey();
|
||||||
bool ValidateSimpleKey();
|
bool ValidateSimpleKey();
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace YAML
|
||||||
{
|
{
|
||||||
// flow sequences can be simple keys
|
// flow sequences can be simple keys
|
||||||
InsertSimpleKey();
|
InsertSimpleKey();
|
||||||
IncreaseFlowLevel();
|
m_flowLevel++;
|
||||||
m_simpleKeyAllowed = true;
|
m_simpleKeyAllowed = true;
|
||||||
|
|
||||||
// eat
|
// eat
|
||||||
|
@ -76,7 +76,7 @@ namespace YAML
|
||||||
{
|
{
|
||||||
// flow maps can be simple keys
|
// flow maps can be simple keys
|
||||||
InsertSimpleKey();
|
InsertSimpleKey();
|
||||||
IncreaseFlowLevel();
|
m_flowLevel++;
|
||||||
m_simpleKeyAllowed = true;
|
m_simpleKeyAllowed = true;
|
||||||
|
|
||||||
// eat
|
// eat
|
||||||
|
@ -87,8 +87,10 @@ namespace YAML
|
||||||
// FlowSeqEndToken
|
// FlowSeqEndToken
|
||||||
template <> FlowSeqEndToken *Scanner::ScanToken(FlowSeqEndToken *pToken)
|
template <> FlowSeqEndToken *Scanner::ScanToken(FlowSeqEndToken *pToken)
|
||||||
{
|
{
|
||||||
// ValidateSimpleKey();
|
if(m_flowLevel == 0)
|
||||||
DecreaseFlowLevel();
|
throw IllegalFlowEnd();
|
||||||
|
|
||||||
|
m_flowLevel--;
|
||||||
m_simpleKeyAllowed = false;
|
m_simpleKeyAllowed = false;
|
||||||
|
|
||||||
// eat
|
// eat
|
||||||
|
@ -99,8 +101,10 @@ namespace YAML
|
||||||
// FlowMapEndToken
|
// FlowMapEndToken
|
||||||
template <> FlowMapEndToken *Scanner::ScanToken(FlowMapEndToken *pToken)
|
template <> FlowMapEndToken *Scanner::ScanToken(FlowMapEndToken *pToken)
|
||||||
{
|
{
|
||||||
//ValidateSimpleKey();
|
if(m_flowLevel == 0)
|
||||||
DecreaseFlowLevel();
|
throw IllegalFlowEnd();
|
||||||
|
|
||||||
|
m_flowLevel--;
|
||||||
m_simpleKeyAllowed = false;
|
m_simpleKeyAllowed = false;
|
||||||
|
|
||||||
// eat
|
// eat
|
||||||
|
@ -111,7 +115,6 @@ namespace YAML
|
||||||
// FlowEntryToken
|
// FlowEntryToken
|
||||||
template <> FlowEntryToken *Scanner::ScanToken(FlowEntryToken *pToken)
|
template <> FlowEntryToken *Scanner::ScanToken(FlowEntryToken *pToken)
|
||||||
{
|
{
|
||||||
//ValidateSimpleKey();
|
|
||||||
m_simpleKeyAllowed = true;
|
m_simpleKeyAllowed = true;
|
||||||
|
|
||||||
// eat
|
// eat
|
||||||
|
@ -122,19 +125,15 @@ namespace YAML
|
||||||
// BlockEntryToken
|
// BlockEntryToken
|
||||||
template <> BlockEntryToken *Scanner::ScanToken(BlockEntryToken *pToken)
|
template <> BlockEntryToken *Scanner::ScanToken(BlockEntryToken *pToken)
|
||||||
{
|
{
|
||||||
//ValidateSimpleKey();
|
|
||||||
|
|
||||||
// we better be in the block context!
|
// we better be in the block context!
|
||||||
if(m_flowLevel == 0) {
|
if(m_flowLevel > 0)
|
||||||
// can we put it here?
|
throw IllegalBlockEntry();
|
||||||
if(!m_simpleKeyAllowed)
|
|
||||||
throw IllegalBlockEntry();
|
|
||||||
|
|
||||||
PushIndentTo(m_column, true); // , -1
|
// can we put it here?
|
||||||
} else {
|
if(!m_simpleKeyAllowed)
|
||||||
// TODO: throw?
|
throw IllegalBlockEntry();
|
||||||
}
|
|
||||||
|
|
||||||
|
PushIndentTo(m_column, true);
|
||||||
m_simpleKeyAllowed = true;
|
m_simpleKeyAllowed = true;
|
||||||
|
|
||||||
// eat
|
// eat
|
||||||
|
@ -145,7 +144,7 @@ namespace YAML
|
||||||
// KeyToken
|
// KeyToken
|
||||||
template <> KeyToken *Scanner::ScanToken(KeyToken *pToken)
|
template <> KeyToken *Scanner::ScanToken(KeyToken *pToken)
|
||||||
{
|
{
|
||||||
// are we in block context?
|
// handle keys diffently in the block context (and manage indents)
|
||||||
if(m_flowLevel == 0) {
|
if(m_flowLevel == 0) {
|
||||||
if(!m_simpleKeyAllowed)
|
if(!m_simpleKeyAllowed)
|
||||||
throw IllegalMapKey();
|
throw IllegalMapKey();
|
||||||
|
@ -153,8 +152,6 @@ namespace YAML
|
||||||
PushIndentTo(m_column, false);
|
PushIndentTo(m_column, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: "remove simple key"
|
|
||||||
|
|
||||||
// can only put a simple key here if we're in block context
|
// can only put a simple key here if we're in block context
|
||||||
if(m_flowLevel == 0)
|
if(m_flowLevel == 0)
|
||||||
m_simpleKeyAllowed = true;
|
m_simpleKeyAllowed = true;
|
||||||
|
@ -170,13 +167,11 @@ namespace YAML
|
||||||
template <> ValueToken *Scanner::ScanToken(ValueToken *pToken)
|
template <> ValueToken *Scanner::ScanToken(ValueToken *pToken)
|
||||||
{
|
{
|
||||||
// does this follow a simple key?
|
// does this follow a simple key?
|
||||||
// bool isValidKey = ValidateSimpleKey();
|
|
||||||
|
|
||||||
if(m_isLastKeyValid) {
|
if(m_isLastKeyValid) {
|
||||||
// can't follow a simple key with another simple key (dunno why, though - it seems fine)
|
// can't follow a simple key with another simple key (dunno why, though - it seems fine)
|
||||||
m_simpleKeyAllowed = false;
|
m_simpleKeyAllowed = false;
|
||||||
} else {
|
} else {
|
||||||
// are we in block context?
|
// handle values diffently in the block context (and manage indents)
|
||||||
if(m_flowLevel == 0) {
|
if(m_flowLevel == 0) {
|
||||||
if(!m_simpleKeyAllowed)
|
if(!m_simpleKeyAllowed)
|
||||||
throw IllegalMapValue();
|
throw IllegalMapValue();
|
||||||
|
@ -393,7 +388,7 @@ namespace YAML
|
||||||
|
|
||||||
// set the initial indentation
|
// set the initial indentation
|
||||||
int indent = info.increment;
|
int indent = info.increment;
|
||||||
if(info.increment && m_indents.top() >= 0)
|
if(info.increment && m_indents.top() >= 0)
|
||||||
indent += m_indents.top();
|
indent += m_indents.top();
|
||||||
|
|
||||||
// finally, grab that scalar
|
// finally, grab that scalar
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue