LibWeb/CSS: Expose consumed tokens from TokenStream

In some situations we want to examine a sequence of tokens that have
been already consumed from a TokenStream. These methods let us do so:
- current_index() provides the current internal token index
- tokens_since() provides a span from the given index to the current one
This commit is contained in:
Sam Atkins 2025-12-01 14:13:45 +00:00
parent 8d5eac28a4
commit a8d0be4382
Notes: github-actions[bot] 2025-12-02 09:50:56 +00:00

View file

@ -177,6 +177,15 @@ public:
return 0;
}
size_t current_index() const { return m_index; }
ReadonlySpan<T> tokens_since(size_t start) const
{
if (start > m_index)
return {};
return m_tokens.slice(start, m_index - start);
}
void dump_all_tokens()
{
dbgln("Dumping all tokens:");