|
SciLex
A header-only C++20 lexer built on REAL
|
Forward (single-pass) iterator yielding one token at a time. More...
#include <lexer.hpp>
Public Types | |
| using | iterator_category = std::input_iterator_tag |
| Single-pass. | |
| using | value_type = token |
| Yielded element. | |
| using | difference_type = std::ptrdiff_t |
| Required typedef. | |
| using | pointer = const token * |
| Pointer to current. | |
| using | reference = const token & |
| Reference to current. | |
Public Member Functions | |
| token_iterator ()=default | |
| Constructs the end sentinel. | |
| token_iterator (const lexer &owner, std::string_view source, eof_policy policy) | |
Constructs a begin iterator over source for owner. | |
| reference | operator* () const |
| Returns the current token. | |
| pointer | operator-> () const |
| Member access to the current token. | |
| token_iterator & | operator++ () |
| Advances to the next token. | |
| void | operator++ (int) |
| Post-increment (single-pass: no useful copy is returned). | |
| bool | operator== (const token_iterator &other) const |
| Equality: both exhausted, or both at the same offset. | |
| bool | operator!= (const token_iterator &other) const |
| Inequality. | |
Private Member Functions | |
| void | advance () |
| Produces the next token, or marks the iterator exhausted. | |
Private Attributes | |
| const lexer * | owner_ {nullptr} |
| Rules provider (not owned). | |
| std::string_view | source_ |
| Text being scanned. | |
| position | cursor_ {0, 1, 1} |
| Current scan position. | |
| std::vector< frame > | stack_ {frame {.mode_id = 0, .entry_pos = position {0, 1, 1}}} |
| Mode stack (top = active). | |
| token | current_ {} |
| The current token. | |
| eof_policy | policy_ {eof_policy::omit} |
| End-of-input policy. | |
| bool | eof_done_ {false} |
| End-of-input token already yielded. | |
| bool | done_ {true} |
| True once exhausted (end sentinel). | |
Forward (single-pass) iterator yielding one token at a time.
A default-constructed iterator is the end sentinel. Each increment runs the lexer just far enough to produce the next non-skipped token; a lex_error thrown by the lexer propagates out of the increment.
| using scilex::token_iterator::difference_type = std::ptrdiff_t |
| using scilex::token_iterator::iterator_category = std::input_iterator_tag |
| using scilex::token_iterator::pointer = const token* |
| using scilex::token_iterator::reference = const token& |
|
default |
Constructs the end sentinel.
|
inline |
Constructs a begin iterator over source for owner.
| [in] | owner | The lexer providing the rules. |
| [in] | source | The text to scan. |
| [in] | policy | Whether to yield a terminal end_of_input token. |
|
inlineprivate |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |