summaryrefslogtreecommitdiff
path: root/cli/lexer.ixx
blob: f7ff77e3429d2050b23d3b6383e0101645ab5d3f (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
// file      : cli/lexer.ixx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009 Code Synthesis Tools CC
// license   : MIT; see accompanying LICENSE file

// Lexer::Char
//
inline Lexer::Char::
Char (IntType v, std::size_t l, std::size_t c)
    : v_ (v), l_ (l), c_ (c)
{
}

inline Lexer::Char::
operator CharType () const
{
  return Traits::to_char_type (v_);
}

inline Lexer::Char::IntType Lexer::Char::
value () const
{
  return v_;
}

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

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

// Lexer
//
inline bool Lexer::
is_alpha (char c) const
{
  return std::isalpha (c, loc_);
}

inline bool Lexer::
is_oct_digit (char c) const
{
  return std::isdigit (c, loc_) && c != '8' && c != '9';
}

inline bool Lexer::
is_dec_digit (char c) const
{
  return std::isdigit (c, loc_);
}

inline bool Lexer::
is_hex_digit (char c) const
{
  return std::isxdigit (c, loc_);
}

inline bool Lexer::
is_alnum (char c) const
{
  return std::isalnum (c, loc_);
}

inline bool Lexer::
is_space (char c) const
{
  return std::isspace (c, loc_);
}

inline bool Lexer::
is_eos (Char const& c) const
{
  return  c.value () == Char::Traits::eof ();
}

inline char Lexer::
to_upper (char c) const
{
  return std::toupper (c, loc_);
}