[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/32bitmicro/cppfront/main/include/cpp2regex.h [Back]  [Original]

#ifndef CPP2REGEX_H_CPP2
#define CPP2REGEX_H_CPP2


//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"

#line 1 "cpp2regex.h2"

#line 20 "cpp2regex.h2"
namespace cpp2 {

namespace regex {

#line 36 "cpp2regex.h2"
template class match_group;

#line 46 "cpp2regex.h2"
template class match_return;

#line 54 "cpp2regex.h2"
template class match_context;

#line 125 "cpp2regex.h2"
template class reverse_match_context;

#line 194 "cpp2regex.h2"
class true_end_func;

#line 202 "cpp2regex.h2"
class no_reset;

#line 209 "cpp2regex.h2"
template class on_return;

#line 236 "cpp2regex.h2"
template class single_class_entry;

#line 245 "cpp2regex.h2"
template class range_class_entry;

#line 254 "cpp2regex.h2"
template class combined_class_entry;

#line 263 "cpp2regex.h2"
template class list_class_entry;

#line 272 "cpp2regex.h2"
template class named_class_entry;

#line 279 "cpp2regex.h2"
template class negated_class_entry;

#line 288 "cpp2regex.h2"
template class shorthand_class_entry;

#line 336 "cpp2regex.h2"
template class alternative_token_matcher;

#line 427 "cpp2regex.h2"
template class class_token_matcher;

#line 604 "cpp2regex.h2"
class range_flags;
    

#line 613 "cpp2regex.h2"
template class range_token_matcher;

#line 785 "cpp2regex.h2"
template class regular_expression;

#line 921 "cpp2regex.h2"
}
}


//=== Cpp2 type definitions and function declarations ===========================

#line 1 "cpp2regex.h2"

//  Copyright 2022-2026 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_context_type = typename matcher::template context;

#line 20 "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 42 "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 50 "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 66 "cpp2regex.h2"
    public: match_context(match_context const& that);
#line 66 "cpp2regex.h2"
    public: auto operator=(match_context const& that) -> match_context& ;
#line 66 "cpp2regex.h2"
    public: match_context(match_context&& that) noexcept;
#line 66 "cpp2regex.h2"
    public: auto operator=(match_context&& that) noexcept -> match_context& ;

    // String end and start positions
    //
    public: [[nodiscard]] auto get_string_start() const& -> decltype(auto);
    public: [[nodiscard]] auto get_string_end() const& -> decltype(auto);

    //  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 83 "cpp2regex.h2"
    public: [[nodiscard]] auto get_group_start(auto const& group) const& -> int;

#line 89 "cpp2regex.h2"
    public: [[nodiscard]] auto get_group_string(auto const& group) const& -> std::string;

#line 96 "cpp2regex.h2"
    public: auto set_group_end(auto const& group, auto const& pos) & -> void;

#line 101 "cpp2regex.h2"
    public: auto set_group_invalid(auto const& group) & -> void;

#line 105 "cpp2regex.h2"
    public: auto set_group_start(auto const& group, auto const& pos) & -> void;

#line 109 "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);

    public: auto reset() & -> void;

#line 121 "cpp2regex.h2"
};

//  Wrapper of context for reverse matches. Implements only the minimal interface for matching.
//
template class reverse_match_context
 {
    public: using ReverseIter = std::reverse_iterator;
    public: match_context* forward_context; 

            public: ReverseIter begin; 
            public: ReverseIter end; 

    public: reverse_match_context(auto const& forward_context_);
#line 133 "cpp2regex.h2"
    public: auto operator=(auto const& forward_context_) -> reverse_match_context& ;

#line 139 "cpp2regex.h2"
    public: reverse_match_context(reverse_match_context const& that);
#line 139 "cpp2regex.h2"
    public: auto operator=(reverse_match_context const& that) -> reverse_match_context& ;
#line 139 "cpp2regex.h2"
    public: reverse_match_context(reverse_match_context&& that) noexcept;
#line 139 "cpp2regex.h2"
    public: auto operator=(reverse_match_context&& that) noexcept -> reverse_match_context& ;

    // String end and start positions
    //
    public: [[nodiscard]] auto get_string_start() const& -> decltype(auto);
    public: [[nodiscard]] auto get_string_end() const& -> decltype(auto);

    //  Getter and setter for groups
    //
    public: auto set_group_end(auto const& group, auto const& pos) & -> void;

#line 152 "cpp2regex.h2"
    public: auto set_group_invalid(auto const& group) & -> void;

#line 156 "cpp2regex.h2"
    public: auto set_group_start(auto const& group, auto const& pos) & -> void;

#line 160 "cpp2regex.h2"
    //  Misc functions
    //
    public: [[nodiscard]] auto fail() const& -> decltype(auto);
    public: [[nodiscard]] auto pass(cpp2::impl::in cur) const& -> decltype(auto);
};

//  Helpers for creating wrappers of the match context.
//
template [[nodiscard]] auto make_forward_match_context(match_context& ctx) -> decltype(auto);

#line 172 "cpp2regex.h2"
template [[nodiscard]] auto make_forward_match_context(reverse_match_context& ctx) -> decltype(auto);

#line 176 "cpp2regex.h2"
template [[nodiscard]] auto make_reverse_match_context(match_context& ctx) -> auto;

#line 180 "cpp2regex.h2"
template [[nodiscard]] auto make_reverse_match_context(reverse_match_context& ctx) -> decltype(auto);

#line 184 "cpp2regex.h2"
//  Helpers for creating wrappers of the iterators.
//
template                     [[nodiscard]] auto cpp2_make_forward_iterator(Iter const& pos) -> auto;
template [[nodiscard]] auto cpp2_make_forward_iterator(std::reverse_iterator const& pos) -> auto;
template                     [[nodiscard]] auto cpp2_make_reverse_iterator(Iter const& pos) -> auto;
template [[nodiscard]] auto cpp2_make_reverse_iterator(std::reverse_iterator const& pos) -> auto;

#line 192 "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 200 "cpp2regex.h2"
//  Empty group reset function.
//
class no_reset
 {
    public: auto operator()([[maybe_unused]] auto& unnamed_param_2) const& -> void;
};

#line 208 "cpp2regex.h2"
//  Evaluate func on destruction of the handle.
template class on_return
 {
    private: Func func; 

    public: on_return(Func const& f);
#line 213 "cpp2regex.h2"
    public: auto operator=(Func const& f) -> on_return& ;

#line 217 "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 220 "cpp2regex.h2"
};

#line 223 "cpp2regex.h2"
//  Helper for auto deduction of the Func type.
template [[nodiscard]] auto make_on_return(Func const& func) -> decltype(auto);

#line 227 "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 240 "cpp2regex.h2"
};

#line 243 "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 249 "cpp2regex.h2"
};

#line 252 "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 258 "cpp2regex.h2"
};

#line 261 "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 267 "cpp2regex.h2"
};

#line 270 "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 276 "cpp2regex.h2"
};

#line 279 "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 283 "cpp2regex.h2"
};

#line 286 "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 292 "cpp2regex.h2"
};

#line 295 "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

Web Proxy Viewer  |  New URL  |  Original Page