mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 14:01:25 +12:00
68 lines
1.3 KiB
C++
68 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <ios>
|
|
#include <string>
|
|
#include <queue>
|
|
#include <stack>
|
|
#include <set>
|
|
#include "regex.h"
|
|
#include "stream.h"
|
|
|
|
namespace YAML
|
|
{
|
|
struct Token;
|
|
|
|
class Scanner
|
|
{
|
|
public:
|
|
Scanner(std::istream& in);
|
|
~Scanner();
|
|
|
|
Token *GetNextToken();
|
|
void Scan();
|
|
|
|
private:
|
|
// scanning
|
|
void ScanNextToken();
|
|
void ScanToNextToken();
|
|
Token *PushIndentTo(int column, bool sequence);
|
|
void PopIndentTo(int column);
|
|
|
|
// checking input
|
|
void InsertSimpleKey();
|
|
bool VerifySimpleKey();
|
|
void VerifyAllSimpleKeys();
|
|
|
|
bool IsWhitespaceToBeEaten(char ch);
|
|
|
|
struct SimpleKey {
|
|
SimpleKey(int pos_, int line_, int column_, int flowLevel_);
|
|
|
|
void Validate();
|
|
void Invalidate();
|
|
|
|
int pos, line, column, flowLevel;
|
|
bool required;
|
|
Token *pMapStart, *pKey;
|
|
};
|
|
|
|
template <typename T> void ScanAndEnqueue(T *pToken);
|
|
template <typename T> T *ScanToken(T *pToken);
|
|
|
|
private:
|
|
// the stream
|
|
Stream INPUT;
|
|
|
|
// the output (tokens)
|
|
std::queue <Token *> m_tokens;
|
|
std::set <Token *> m_limboTokens;
|
|
|
|
// state info
|
|
bool m_startedStream, m_endedStream;
|
|
bool m_simpleKeyAllowed;
|
|
int m_flowLevel; // number of unclosed '[' and '{' indicators
|
|
bool m_isLastKeyValid;
|
|
std::stack <SimpleKey> m_simpleKeys;
|
|
std::stack <int> m_indents;
|
|
};
|
|
}
|