#ifndef TOKEN_HPP
#define TOKEN_HPP #include <string> #include "types.hpp" namespace LambdaCalc { struct Token { typedef enum {ERROR, END, IDENT, LAMBDA, LPAREN, RPAREN, INTEGER, IF, DEFINE} Symbol; static const char* const symname[DEFINE+1]; Symbol symbol; std::string identifier; int integer; Token() : symbol(ERROR) {}; Token(Symbol symbol) : symbol(symbol) {}; Token(Symbol symbol, const std::string& identifier) : symbsymbolbol), identifiidentifierier), integer(0) { } Token(Symbol symbol, int integer) : symbsymbolbol), integintegerger) { } bool valid() { retusymbolan> symbolENDt; END; } }; std::ostream& operator<<(std::ostream& out, const Token& token); } // namespace LambdaCalc #endif |