aboutsummaryrefslogtreecommitdiff
path: root/libbutl/char-scanner.mxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-05-23 23:33:57 +0300
committerBoris Kolpackov <boris@codesynthesis.com>2020-05-25 14:25:05 +0200
commit813c483a312e1b1b4fa5a02234009ec546a0cc8c (patch)
tree8cbe1568270f49fa13caf0ca92948695c8fac386 /libbutl/char-scanner.mxx
parent095beb64a0752317a9a1d9777284a6c9343417cc (diff)
Add putback depth char_scanner template parameter
Diffstat (limited to 'libbutl/char-scanner.mxx')
-rw-r--r--libbutl/char-scanner.mxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/libbutl/char-scanner.mxx b/libbutl/char-scanner.mxx
index e57245b..60994cf 100644
--- a/libbutl/char-scanner.mxx
+++ b/libbutl/char-scanner.mxx
@@ -9,6 +9,7 @@
#ifndef __cpp_lib_modules_ts
#include <string> // char_traits
+#include <cstddef> // size_t
#include <cstdint> // uint64_t
#include <climits> // INT_*
#include <utility> // pair, make_pair()
@@ -46,11 +47,12 @@ LIBBUTL_MODEXPORT namespace butl
// Low-level character stream scanner. Normally used as a base for
// higher-level lexers.
//
- template <typename V = noop_validator>
+ template <typename V = noop_validator, std::size_t N = 1>
class char_scanner
{
public:
using validator_type = V;
+ static constexpr const std::size_t unget_depth = N;
// If the crlf argument is true, then recognize Windows newlines (0x0D
// 0x0A) and convert them to just '\n' (0x0A). Note that a standalone
@@ -119,7 +121,7 @@ LIBBUTL_MODEXPORT namespace butl
: char_type (0);
}
- xchar (int_type v,
+ xchar (int_type v = 0,
std::uint64_t l = 0,
std::uint64_t c = 0,
std::uint64_t p = 0)
@@ -247,10 +249,10 @@ LIBBUTL_MODEXPORT namespace butl
bool crlf_;
bool eos_ = false;
- bool unget_ = false;
- bool unpeek_ = false;
+ std::size_t ungetn_ = 0;
+ xchar ungetb_[N];
- xchar ungetc_ = '\0';
+ bool unpeek_ = false;
xchar unpeekc_ = '\0';
};
}