//============================================================================// // // // artichoke programming language // // // // Copyright (C) 2025 Erick Saul Guzman Ramos, whoami.artichoke.dev // // // // // // This program is free software: you can redistribute it and/or modify // // it under the terms of the GNU Affero General Public License as published // // by the Free Software Foundation, either version 3 of the License, or // // (at your option) any later version. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU Affero General Public License for more details. // // // // You should have received a copy of the GNU Affero General Public License // // along with this program. If not, see . // // // //============================================================================// #pragma once #include #include namespace arti::lang { struct Tokenizer; struct [[nodiscard]] TokenizerRange { friend struct Tokenizer; struct Iterator; struct Sentinel; using iterator_type = Iterator; using sentinel_type = Sentinel; TokenizerRange(TokenizerRange &&) noexcept; TokenizerRange &operator=(TokenizerRange &&) noexcept; TokenizerRange(const TokenizerRange &) noexcept = delete; TokenizerRange &operator=(const TokenizerRange &) noexcept = delete; Iterator begin(); Sentinel end() const noexcept; struct Iterator { friend struct TokenizerRange; using iterator_category = std::input_iterator_tag; using difference_type = std::ptrdiff_t; using ValueType = Expected; using ReferenceType = ValueType &; using PointerType = ValueType *; using value_type = ValueType; using pointer_type = PointerType; Iterator(Iterator &&) noexcept; Iterator &operator=(Iterator &&) noexcept; Iterator(const Iterator &) noexcept = delete; Iterator &operator=(const Iterator &) noexcept = delete; Iterator &operator++(); void operator++(int); ReferenceType operator*() const noexcept; PointerType operator->() const noexcept; friend bool operator==(const Iterator &, Sentinel); friend bool operator==(Sentinel, const Iterator &); friend bool operator!=(const Iterator &, Sentinel); friend bool operator!=(Sentinel, const Iterator &); private: Iterator(Tokenizer *tokenizer) noexcept; Tokenizer *tokenizer; mutable Expected cvalue; }; struct Sentinel {}; private: TokenizerRange(Tokenizer *tokenizer); Tokenizer *tokenizer; }; }