Started the scanner.

This commit is contained in:
Jesse Beder 2008-06-26 09:05:28 +00:00
parent bcbca461de
commit 8ae7b48188
5 changed files with 358 additions and 4 deletions

55
scanner.h Normal file
View file

@ -0,0 +1,55 @@
#pragma once
#include <ios>
#include <string>
#include <queue>
#include <stack>
namespace YAML
{
class Token;
namespace Keys
{
const char Comment = '#';
}
class Scanner
{
public:
Scanner(std::istream& in);
~Scanner();
Token *ScanNextToken();
void ScanToNextToken();
void Scan();
private:
char GetChar();
void EatLineBreak();
void EatDocumentStart();
void EatDocumentEnd();
bool IsWhitespaceToBeEaten();
bool IsLineBreak();
bool IsBlank();
bool IsDocumentStart();
bool IsDocumentEnd();
template <typename T> T *ScanToken(T *pToken);
private:
// the stream
std::istream& INPUT;
int m_column;
// the output (tokens)
std::queue <Token *> m_tokens;
// state info
bool m_startedStream;
bool m_simpleKeyAllowed;
int m_flowLevel; // number of unclosed '[' and '{' indicators
std::stack <int> m_indents;
};
}