Mercurial > repo
view interps/sadol/Source.cpp @ 11562:6b0304dcec5c draft
<oerjan> ` cd bin; cp welcome \xd0\xb4\xd0\xbe\xd0\xb1\xd1\x80\xd0\xbe-\xd0\xbf\xd0\xbe\xd0\xb6\xd0\xb0\xd0\xbb\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd1\x8c; sled \xd0\xb4\xd0\xbe\xd0\xb1\xd1\x80\xd0\xbe-\xd0\xbf\xd0\xbe\xd0\xb6\xd0\xb0\xd0\xbb\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd1\x8c//s,welcome,welcome.ru,
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Wed, 16 May 2018 04:46:17 +0100 |
parents | 859f9b4339e6 |
children |
line wrap: on
line source
/* * BDSM2 * Author: Adam Sawicki * http://www.regedit.risp.pl * mailto:regedit@risp.pl */ #include "pch.hpp" #include <sstream> #include "Source.hpp" string Source::Iterator::ToString() const { std::ostringstream ss; ss << "index: " << (unsigned)Index << ", row: " << Row << ", col: " << Col; return ss.str(); } void Source::Forward() { if (Peek() == '\r') { } else if (Peek() == '\n') { m_Index.Row++; m_Index.Col = 1; } else m_Index.Col++; m_Index.Index++; } char Source::Get() { char ch = Peek(); Forward(); return ch; } Source::Source(const string *Src) : m_Src(Src), m_ErrIndexSaved(false) { m_Index.Index = 0; m_Index.Row = 1; m_Index.Col = 1; } char Source::GetS() { if (End()) SrcError("Unexpected end of file", ERR_PARSE); return Get(); } void Source::Skip() { char ch; while (!End()) { ch = Peek(); // Whitespace if (ch == ' ' || ch == '\t' || ch == '\v' || ch == '\r' || ch == '\n') Forward(); // Comment else if (ch == '{') { Forward(); for (;;) { if (End()) SrcError("Unexpected end of comment", ERR_PARSE); ch = Peek(); Forward(); if (ch == '}') break; } } else break; } } void Source::SrcError(const string &msg, ERR_PLACE place) { Error(msg + " (" + GetIterator().ToString() + ')', place); }