mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +12:00
Beginning of first attempt to parse.
Will be completely wiped, I think, in favor of a Scanner (to tokens), then Parser mechanism.
This commit is contained in:
parent
4ed7f62431
commit
bcbca461de
11 changed files with 247 additions and 9 deletions
55
parser.h
Normal file
55
parser.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
#pragma once
|
||||
|
||||
#include <ios>
|
||||
#include <string>
|
||||
#include <stack>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
|
||||
const std::string DocStart = "---";
|
||||
const std::string DocEnd = "...";
|
||||
|
||||
const char SeqToken = '-';
|
||||
|
||||
enum CONTEXT { C_BLOCK, C_FLOW };
|
||||
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
struct State
|
||||
{
|
||||
State(CONTEXT context_, int indent_, bool startingNewLine_)
|
||||
: context(context_), indent(indent_), startingNewLine(startingNewLine_) {}
|
||||
|
||||
CONTEXT context;
|
||||
int indent;
|
||||
bool startingNewLine;
|
||||
};
|
||||
|
||||
public:
|
||||
Parser(std::istream& in);
|
||||
~Parser();
|
||||
|
||||
operator bool () const;
|
||||
bool operator !() const;
|
||||
|
||||
// parse helpers
|
||||
static bool IsWhitespace(char ch);
|
||||
void Putback(const std::string& str);
|
||||
void StripWhitespace(int n = -1);
|
||||
int GetNumOfSpaces();
|
||||
bool SeqContinues();
|
||||
|
||||
// readers
|
||||
Node *ReadNextNode();
|
||||
std::string ReadNextToken();
|
||||
|
||||
private:
|
||||
bool m_ok;
|
||||
|
||||
std::istream& INPUT;
|
||||
std::stack <State> m_state;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue