1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
#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 charconst 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