summaryrefslogtreecommitdiff
path: root/CIAO/CCF/CCF/CompilerElements/PreprocessorToken.cpp
blob: 5f3e629243e7114bf210bc6162a3eb5eff8f3406 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// file      : CCF/CompilerElements/PreprocessorToken.cpp
// author    : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id    : $Id$

#include "CCF/CompilerElements/PreprocessorToken.hpp"

namespace CCF
{
  namespace CompilerElements
  {
    namespace CPP
    {
      Token const Token::eos;

      Token::
      Token (char c, unsigned long line)
          : c_ (traits::to_int_type (c)), line_ (line)
      {
      }

      Token::
      Token ()
          : c_ (traits::eof ()), line_ (0)
      {
      }

      Token::
      operator char () const throw (EOS)
      {
        if (*this == eos) throw EOS ();

        return traits::to_char_type (c_);
      }


      unsigned long Token::
      line () const throw (EOS)
      {
        if (*this == eos) throw EOS ();

        return line_;
      }

      bool
      operator== (Token const& a, Token const& b)
      {
        return a.c_ == b.c_;
      }

      bool
      operator!= (Token const& a, Token const& b)
      {
        return a.c_ != b.c_;
      }
    }
  }
}