aboutsummaryrefslogtreecommitdiff
path: root/build2/token.cxx
blob: b14fc00eb65dab059efe980c6b3bf9e1579980d7 (plain)
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
// file      : build2/token.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#include <build2/token>

#include <ostream>

using namespace std;

namespace build2
{
  ostream&
  operator<< (ostream& os, const token& t)
  {
    switch (t.type)
    {
    case token_type::eos:            os << "<end-of-file>"; break;
    case token_type::newline:        os << "<newline>"; break;
    case token_type::pair_separator: os << "<pair separator>"; break;
    case token_type::colon:          os << ":"; break;
    case token_type::lcbrace:        os << "{"; break;
    case token_type::rcbrace:        os << "}"; break;
    case token_type::equal:          os << "="; break;
    case token_type::equal_plus:     os << "=+"; break;
    case token_type::plus_equal:     os << "+="; break;
    case token_type::dollar:         os << "$"; break;
    case token_type::lparen:         os << "("; break;
    case token_type::rparen:         os << ")"; break;
    case token_type::name:           os << t.value; break;
    }

    return os;
  }
}