summaryrefslogtreecommitdiffstats
path: root/cli/token.ixx
blob: 93db6d8aeed101a0a266301ca9e613a44e1ee8a4 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// file      : cli/token.ixx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009 Code Synthesis Tools CC
// license   : MIT; see accompanying LICENSE file

inline Token::Type Token::
type () const
{
  return type_;
}

inline std::size_t Token::
line () const
{
  return l_;
}

inline std::size_t Token::
column () const
{
  return c_;
}

inline Token::Keyword Token::
keyword () const
{
  return type_ == t_keyword ? keyword_ : k_invalid;
}

inline std::string const& Token::
identifier () const
{
  return str_;
}

inline Token::Punctuation Token::
punctuation () const
{
  return type_ == t_punctuation ? punctuation_ : p_invalid;
}

inline std::string const& Token::
literal () const
{
  return str_;
}

inline std::string const& Token::
expression () const
{
  return str_;
}

inline Token::
Token (std::size_t l, std::size_t c)
    : l_ (l), c_ (c), type_ (t_eos)
{
}

inline Token::
Token (Keyword k, std::size_t l, std::size_t c)
    : l_ (l), c_ (c), type_ (t_keyword), keyword_ (k)
{
}

inline Token::
Token (Punctuation p, std::size_t l, std::size_t c)
    : l_ (l), c_ (c), type_ (t_punctuation), punctuation_ (p)
{
}

inline Token::
Token (Type t, std::string const& s, std::size_t l, std::size_t c)
    : l_ (l), c_ (c), type_ (t), str_ (s)
{
}