Iros
Loading...
Searching...
No Matches
match_one.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
di/meta/relation.h
"
4
#include "
di/parser/basic/code_point_parser.h
"
5
#include "
di/parser/combinator/and_then.h
"
6
#include "
di/parser/concepts/parser.h
"
7
#include "
di/parser/concepts/parser_context.h
"
8
#include "
di/vocab/expected/prelude.h
"
9
10
namespace
di::parser
{
11
namespace
detail
{
12
struct
MatchOneFunction
{
13
template
<concepts::Predicate<c32> Pred>
14
requires
(
concepts::DecayConstructible<Pred>
)
15
constexpr
auto
operator
()(Pred&& predicate)
const
{
16
return
code_point
() << [predicate =
auto
(util::forward<Pred>(predicate))]<
concepts::ParserContext
Context>(
17
Context& context,
c32
code_point
) ->
meta::ParserContextResult<c32, Context>
{
18
if
(!predicate(
code_point
)) {
19
return
Unexpected
(context.make_error());
20
}
21
return
code_point
;
22
};
23
}
24
};
25
}
26
27
constexpr
inline
auto
match_one
=
detail::MatchOneFunction
{};
28
}
and_then.h
di::vocab::Unexpected
Definition
unexpected.h:14
code_point_parser.h
di::concepts::DecayConstructible
Definition
util.h:65
di::concepts::ParserContext
Definition
parser_context.h:12
prelude.h
di::meta::ParserContextResult
vocab::Expected< T, meta::ParserContextError< Context > > ParserContextResult
Definition
parser_context_result.h:8
di::parser::detail
Definition
zstring_parser.h:10
di::parser
Definition
zstring_parser.h:9
di::parser::code_point
constexpr auto code_point
Definition
code_point_parser.h:35
di::parser::match_one
constexpr auto match_one
Definition
match_one.h:27
di::types::c32
char32_t c32
Definition
char.h:6
parser.h
parser_context.h
relation.h
di::parser::detail::MatchOneFunction
Definition
match_one.h:12
libs
di
include
di
parser
basic
match_one.h
Generated by
1.13.0