Скачиваний:
11
Добавлен:
01.05.2014
Размер:
1.49 Кб
Скачать
#ifndef _TOKEN_H_
#define _TOKEN_H_
//-----------------------------------------------------------------------------
#include <vector>
#include "Tokens.h"
//-----------------------------------------------------------------------------

class CToken
{
    ENUM_TOKENS      m_tok;
    //ENUM_TOKEN_TYPES m_type;    // determines table
    unsigned         m_index;   // determines position in table
    unsigned         m_line;

public:
    CToken(ENUM_TOKENS tok, unsigned index, unsigned line)
        : m_tok(tok), m_index(index), m_line(line) { }

    //ENUM_TOKEN_TYPES Type()  { return m_type;  }

    operator   ENUM_TOKENS() { return m_tok;   }
    unsigned         Index() { return m_index; }
    unsigned         Line()  { return m_line;  }
};

//-----------------------------------------------------------------------------

// Вот это у нас и будет "поток токенов" :) 

class CTokenStream
{
public:
    typedef std::vector<CToken> container;
    typedef container::iterator iterator;

private:
    container m_Container;

public:

    CTokenStream() {};

    iterator begin()   { return m_Container.begin(); }
    iterator end()     { return m_Container.end();   }

    bool empty() const { return m_Container.empty(); }
    void clear()       { m_Container.clear();        }

    void Add(CToken &Tok) { m_Container.push_back(Tok); }

};

//-----------------------------------------------------------------------------
#endif
Соседние файлы в папке Курсовая работа2