Some refactoring, renaming, and debug assertions for clarity and safety

- Add more `assume()` checks in the lexer
- Replace double negative "`disable* = false`" with "`enable* = true`"
- Naming convention of "`std::deque<> *Stack`" when relying on
  `.push_front()` and `.pop_back()`
This commit is contained in:
Rangi42
2026-04-27 18:47:06 +02:00
parent 9fd0c0297f
commit 3c7488c131
5 changed files with 40 additions and 40 deletions
+5 -5
View File
@@ -87,16 +87,16 @@ struct LexerState {
int lastToken;
int nextToken;
std::deque<IfStackEntry> ifStack;
std::deque<IfStackEntry> ifStack; // Front is the innermost `IF` block
bool capturing; // Whether the text being lexed should be captured
size_t captureSize; // Amount of text captured
std::shared_ptr<std::vector<char>> captureBuf; // Buffer to send the captured text to if set
bool disableExpansions;
size_t expansionScanDistance; // Max distance already scanned for expansions
bool expandStrings;
std::deque<Expansion> expansions; // Front is the innermost current expansion
bool enableExpansions;
bool enableStringExpansions;
size_t expansionScanDistance; // Max distance already scanned for expansions
std::deque<Expansion> expansionStack; // Front is the innermost current expansion
std::variant<std::monostate, ViewedContent, BufferedContent> content;
+1 -1
View File
@@ -36,7 +36,7 @@ ReversedIterable<IterableT> reversed(IterableT &&_iterable) {
// A map from `std::string` keys to `ItemT` items, iterable in the order the items were inserted.
template<typename ItemT>
class InsertionOrderedMap {
std::deque<ItemT> list;
std::deque<ItemT> list; // `deque` does not invalidate item references
std::unordered_map<std::string, size_t> map; // Indexes into `list`
public: