summaryrefslogtreecommitdiff
path: root/cli/cli/token.ixx
blob: 77ab225374ca09b425d5125c021f628b202e87b1 (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
77
78
79
80
81
82
83
84
85
86
87
88
// file      : cli/token.ixx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// license   : MIT; see accompanying LICENSE file

inline token::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_type token::
keyword () const
{
  return type_ == t_keyword ? keyword_ : k_invalid;
}

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

inline token::punctuation_type 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),
      keyword_ (k_invalid),
      punctuation_ (p_invalid)
{
}

inline token::
token (keyword_type k, std::size_t l, std::size_t c)
    : l_ (l), c_ (c),
      type_ (t_keyword),
      keyword_ (k),
      punctuation_ (p_invalid)
{
}

inline token::
token (punctuation_type p, std::size_t l, std::size_t c)
    : l_ (l), c_ (c),
      type_ (t_punctuation),
      keyword_ (k_invalid),
      punctuation_ (p)
{
}

inline token::
token (token_type t, std::string const& s, std::size_t l, std::size_t c)
    : l_ (l), c_ (c),
      type_ (t),
      keyword_ (k_invalid),
      punctuation_ (p_invalid),
      str_ (s)
{
}