/usr/include/lexertl/parser/tokeniser/re_tokeniser_state.hpp is in libpuma-dev 1:2.1-2+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | // tokeniser_state.hpp
// Copyright (c) 2005-2015 Ben Hanson (http://www.benhanson.net/)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file licence_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef LEXERTL_RE_TOKENISER_STATE_HPP
#define LEXERTL_RE_TOKENISER_STATE_HPP
#include "../../char_traits.hpp"
#include "../../enums.hpp"
#include <locale>
#include "../../narrow.hpp"
#include "../../size_t.hpp"
#include <stack>
namespace lexertl
{
namespace detail
{
template<typename ch_type, typename id_type>
struct basic_re_tokeniser_state
{
typedef ch_type char_type;
typedef typename basic_char_traits<char_type>::index_type index_type;
const char_type * const _start;
const char_type * const _end;
const char_type *_curr;
id_type _id;
std::size_t _flags;
std::stack<std::size_t> _flags_stack;
std::locale _locale;
const char_type *_macro_name;
long _paren_count;
bool _in_string;
id_type _nl_id;
basic_re_tokeniser_state(const char_type *start_,
const char_type * const end_, id_type id_, const std::size_t flags_,
const std::locale locale_, const char_type *macro_name_) :
_start(start_),
_end(end_),
_curr(start_),
_id(id_),
_flags(flags_),
_flags_stack(),
_locale(locale_),
_macro_name(macro_name_),
_paren_count(0),
_in_string(false),
_nl_id(~static_cast<id_type>(0))
{
}
basic_re_tokeniser_state(const basic_re_tokeniser_state &rhs_)
{
assign(rhs_);
}
// prevent VC++ 7.1 warning:
const basic_re_tokeniser_state &operator =
(const basic_re_tokeniser_state &rhs_)
{
assign(rhs_);
}
void assign(const basic_re_tokeniser_state &rhs_)
{
_start = rhs_._start;
_end = rhs_._end;
_curr = rhs_._curr;
_id = rhs_._id;
_flags = rhs_._flags;
_flags_stack = rhs_._flags_stack;
_locale = rhs_._locale;
_macro_name = rhs_._macro_name;
_paren_count = rhs_._paren_count;
_in_string = rhs_._in_string;
_nl_id = rhs_._nl_id;
return this;
}
inline bool next(char_type &ch_)
{
if (_curr >= _end)
{
ch_ = 0;
return true;
}
else
{
ch_ = *_curr;
increment();
return false;
}
}
inline void increment()
{
++_curr;
}
inline std::size_t index()
{
return _curr - _start;
}
inline bool eos()
{
return _curr >= _end;
}
inline void unexpected_end(std::ostringstream &ss_)
{
ss_ << "Unexpected end of regex";
}
inline void error(std::ostringstream &ss_)
{
ss_ << " in ";
if (_macro_name)
{
ss_ << "MACRO '";
narrow(_macro_name, ss_);
ss_ << "'.";
}
else
{
ss_ << "rule id " << _id << '.';
}
}
};
}
}
#endif
|