| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | #include "Token.h"#include "../Exception.h"#include <iostream>#include "TokenType.h"Token::Token(TokenType type, int line) : type(type){    this->line = line;    f = 0.0f;    s = "";}Token::~Token() {}void Token::setFloat(float f){    if(type != Tokens::FLOAT)    {        throw Exception("token contains no float");    }    this->f = f;}void Token::setString(string s){    if(type != Tokens::TEXT && type != Tokens::LABEL && type != Tokens::VAR)    {        throw Exception("token contains no string");    }    this->s.assign(s);}float Token::getFloat() const{    return f;}bool Token::getBool() const{    if(type == Tokens::TRUE)    {        return true;    }    return false;}string Token::getString() const{    return s;}int Token::getLine() const{    return line;}TokenType Token::getType() const{    return type;}std::ostream& operator<<(std::ostream& stream, const Token& t){    stream << t.getLine() << " ";    stream << t.getType();    string s = t.getString();    if(s.size() != 0)    {        stream << "(\"" << s << "\")";     }    if(t.getType() == Tokens::FLOAT)    {        stream << '(' << t.getFloat() << ')';     }    return stream;}
 |