Menu

[94f52a]: / parser / choice.hpp  Maximize  Restore  History

Download this file

50 lines (39 with data), 1.1 kB

 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
#ifndef CHILON_PARSER_CHOICE_HPP
#define CHILON_PARSER_CHOICE_HPP
#include <chilon/parser/parse.hpp>
#include <chilon/parser/detail/choice.hpp>
#include <chilon/meta/flatten.hpp>
namespace chilon { namespace parser {
/**
* Ordered choice (| in grammar)
*/
template <class... Matches>
struct choice;
template <>
struct choice<> {
template <class Stream>
inline static bool skip(Stream& stream) {
return false;
}
template <class Stream>
inline static bool match(Stream const& stream) {
return false;
}
};
template <class Head, class... Tail>
struct choice<Head, Tail...>
: parse_base<detail::parse_choice<Head, Tail...>>
{
template <class Stream>
inline static bool skip(Stream& stream) {
return Head::skip(stream) || choice<Tail...>::skip(stream);
}
template <class Stream>
inline static bool match(Stream const& stream) {
return Head::match(stream) || choice<Tail...>::match(stream);
}
};
template <class... T>
struct parse<detail::parse_choice<T...>> : detail::parse_choice<T...> {};
} }
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.