text.hpp
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
#ifndef CRUCIBLE_PARSING_TEXT_HPP #define CRUCIBLE_PARSING_TEXT_HPP #include "crucible/parsing/errors.inl" #include "crucible/core/none.hpp" #include <cstddef> #include <string_view> namespace crucible::parsing::text { class TextState final { public: explicit TextState(std::string_view const &input); TextState(std::string_view const &input, std::size_t const code_unit_offset); [[nodiscard]] auto is_finished() const -> bool; [[nodiscard]] auto get_remaining_code_units_in_input() const -> std::string_view; [[nodiscard]] auto advance_by_code_units(std::size_t const code_unit_count) const -> TextState; [[nodiscard]] auto format_location() const -> std::string; private: std::string_view my_input {}; std::size_t my_code_unit_offset { 0 }; }; class CharacterSequence final { public: using StateType = TextState; using ValueType = core::none::None; using ResultType = errors::ParsingResult<StateType, ValueType>; explicit CharacterSequence(std::string_view character_sequence); [[nodiscard]] auto operator()(StateType const &state) const -> ResultType; private: std::string my_character_sequence {}; }; } #endif // CRUCIBLE_PARSING_TEXT_HPP