GitHub Viewer
#ifndef CPP2REGEX_H_CPP2
#define CPP2REGEX_H_CPP2
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
#line 1 "cpp2regex.h2"
#line 22 "cpp2regex.h2"
namespace cpp2 {
namespace regex {
#line 38 "cpp2regex.h2"
template class match_group;
#line 48 "cpp2regex.h2"
template class match_return;
#line 56 "cpp2regex.h2"
template class match_context;
#line 117 "cpp2regex.h2"
class true_end_func;
#line 125 "cpp2regex.h2"
class no_reset;
#line 132 "cpp2regex.h2"
template class on_return;
#line 159 "cpp2regex.h2"
template class single_class_entry;
#line 168 "cpp2regex.h2"
template class range_class_entry;
#line 177 "cpp2regex.h2"
template class combined_class_entry;
#line 186 "cpp2regex.h2"
template class list_class_entry;
#line 195 "cpp2regex.h2"
template class named_class_entry;
#line 202 "cpp2regex.h2"
template class negated_class_entry;
#line 211 "cpp2regex.h2"
template class shorthand_class_entry;
#line 259 "cpp2regex.h2"
template class alternative_token_matcher;
#line 337 "cpp2regex.h2"
template class class_token_matcher;
#line 492 "cpp2regex.h2"
class range_flags;
#line 501 "cpp2regex.h2"
template class range_token_matcher;
#line 673 "cpp2regex.h2"
template class regular_expression;
#line 756 "cpp2regex.h2"
}
}
//=== Cpp2 type definitions and function declarations ===========================
#line 1 "cpp2regex.h2"
// Copyright 2022-2024 Herb Sutter
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// Part of the Cppfront Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/hsutter/cppfront/blob/main/LICENSE for license information.
//===========================================================================
// Regex support
//===========================================================================
#ifndef CPP2_CPP2REGEX_H
#define CPP2_CPP2REGEX_H
template
using matcher_wrapper_type = typename matcher_wrapper::template wrap;
template
using matcher_context_type = typename matcher::context;
#line 22 "cpp2regex.h2"
namespace cpp2 {
namespace regex {
template using bstring = std::basic_string;
template using bview = std::basic_string_view;
//-----------------------------------------------------------------------
//
// Helper structures for the expression matching.
//
//-----------------------------------------------------------------------
//
// Structure for storing group information.
//
template class match_group
{
public: Iter start {};
public: Iter end {};
public: bool matched {false};
public: match_group(auto const& start_, auto const& end_, auto const& matched_);
public: match_group();
#line 44 "cpp2regex.h2"
};
// Return value for every matcher.
//
template class match_return
{
public: bool matched {false};
public: Iter pos {};
public: match_return(auto const& matched_, auto const& pos_);
public: match_return();
#line 52 "cpp2regex.h2"
};
// Modifiable state during matching.
//
template class match_context
{
public: Iter begin;
public: Iter end;
private: std::array groups {};
public: match_context(Iter const& begin_, Iter const& end_);
#line 68 "cpp2regex.h2"
public: match_context(match_context const& that);
#line 68 "cpp2regex.h2"
public: auto operator=(match_context const& that) -> match_context& ;
#line 68 "cpp2regex.h2"
public: match_context(match_context&& that) noexcept;
#line 68 "cpp2regex.h2"
public: auto operator=(match_context&& that) noexcept -> match_context& ;
// Getter and setter for groups
//
public: [[nodiscard]] auto get_group(auto const& group) const& -> decltype(auto);
public: [[nodiscard]] auto get_group_end(auto const& group) const& -> int;
#line 80 "cpp2regex.h2"
public: [[nodiscard]] auto get_group_start(auto const& group) const& -> int;
#line 86 "cpp2regex.h2"
public: [[nodiscard]] auto get_group_string(auto const& group) const& -> std::string;
#line 93 "cpp2regex.h2"
public: auto set_group_end(auto const& group, auto const& pos) & -> void;
#line 98 "cpp2regex.h2"
public: auto set_group_invalid(auto const& group) & -> void;
#line 102 "cpp2regex.h2"
public: auto set_group_start(auto const& group, auto const& pos) & -> void;
#line 106 "cpp2regex.h2"
public: [[nodiscard]] auto size() const& -> decltype(auto);
// Misc functions
//
public: [[nodiscard]] auto fail() const& -> decltype(auto);
public: [[nodiscard]] auto pass(cpp2::impl::in cur) const& -> decltype(auto);
};
#line 115 "cpp2regex.h2"
// End function that returns a valid match.
//
class true_end_func
{
public: [[nodiscard]] auto operator()(auto const& cur, auto& ctx) const& -> decltype(auto);
};
#line 123 "cpp2regex.h2"
// Empty group reset function.
//
class no_reset
{
public: auto operator()([[maybe_unused]] auto& unnamed_param_2) const& -> void;
};
#line 131 "cpp2regex.h2"
// Evaluate func on destruction of the handle.
template class on_return
{
private: Func func;
public: on_return(Func const& f);
#line 136 "cpp2regex.h2"
public: auto operator=(Func const& f) -> on_return& ;
#line 140 "cpp2regex.h2"
public: ~on_return() noexcept;
public: on_return(on_return const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(on_return const&) -> void = delete;
#line 143 "cpp2regex.h2"
};
#line 146 "cpp2regex.h2"
// Helper for auto deduction of the Func type.
template [[nodiscard]] auto make_on_return(Func const& func) -> decltype(auto);
#line 150 "cpp2regex.h2"
//-----------------------------------------------------------------------
//
// Character classes for regular expressions.
//
//-----------------------------------------------------------------------
//
// Class syntax: Example: a
//
template class single_class_entry
{
public: [[nodiscard]] static auto includes(cpp2::impl::in c) -> decltype(auto);
public: [[nodiscard]] static auto to_string() -> decltype(auto);
public: single_class_entry() = default;
public: single_class_entry(single_class_entry const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(single_class_entry const&) -> void = delete;
#line 163 "cpp2regex.h2"
};
#line 166 "cpp2regex.h2"
// Class syntax: - Example: a-c
//
template class range_class_entry
{
public: [[nodiscard]] static auto includes(cpp2::impl::in c) -> decltype(auto);
public: [[nodiscard]] static auto to_string() -> decltype(auto);
public: range_class_entry() = default;
public: range_class_entry(range_class_entry const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(range_class_entry const&) -> void = delete;
#line 172 "cpp2regex.h2"
};
#line 175 "cpp2regex.h2"
// Helper for combining two character classes
//
template class combined_class_entry
{
public: [[nodiscard]] static auto includes(cpp2::impl::in c) -> decltype(auto);
public: [[nodiscard]] static auto to_string() -> decltype(auto);
public: combined_class_entry() = default;
public: combined_class_entry(combined_class_entry const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(combined_class_entry const&) -> void = delete;
#line 181 "cpp2regex.h2"
};
#line 184 "cpp2regex.h2"
// Class syntax: Example: abcd
//
template class list_class_entry
{
public: [[nodiscard]] static auto includes(cpp2::impl::in c) -> decltype(auto);
public: [[nodiscard]] static auto to_string() -> decltype(auto);
public: list_class_entry() = default;
public: list_class_entry(list_class_entry const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(list_class_entry const&) -> void = delete;
#line 190 "cpp2regex.h2"
};
#line 193 "cpp2regex.h2"
// Class syntax: [: decltype(auto);
public: [[nodiscard]] static auto to_string() -> decltype(auto);
public: named_class_entry() = default;
public: named_class_entry(named_class_entry const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(named_class_entry const&) -> void = delete;
#line 199 "cpp2regex.h2"
};
#line 202 "cpp2regex.h2"
template class negated_class_entry
: public Inner {
public: [[nodiscard]] static auto includes(cpp2::impl::in c) -> decltype(auto);
public: negated_class_entry() = default;
public: negated_class_entry(negated_class_entry const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(negated_class_entry const&) -> void = delete;
#line 206 "cpp2regex.h2"
};
#line 209 "cpp2regex.h2"
// Short class syntax: \ Example: \w
//
template class shorthand_class_entry
{
public: [[nodiscard]] static auto includes(cpp2::impl::in c) -> decltype(auto);
public: [[nodiscard]] static auto to_string() -> decltype(auto);
public: shorthand_class_entry() = default;
public: shorthand_class_entry(shorthand_class_entry const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(shorthand_class_entry const&) -> void = delete;
#line 215 "cpp2regex.h2"
};
#line 218 "cpp2regex.h2"
// Named basic character classes
//
template using digits_class = named_class_entry;
template using lower_class = named_class_entry;
template using upper_class = named_class_entry;
// Named other classes
//
template using alnum_class = named_class_entry;
template using alpha_class = named_class_entry;
template using ascii_class = named_class_entry;
template using blank_class = named_class_entry;
template using cntrl_class = named_class_entry;
template using graph_class = named_class_entry;
template using hor_space_class = named_class_entry;
template using print_class = named_class_entry;
template using punct_class = named_class_entry