slang::syntax::TokenList class

A container of tokens.

Base classes

template<typename Derived, typename Element>
class SyntaxListBase<TokenList, parsing::Token>
Common base for the three syntax-list container types.

Constructors, destructors, conversion operators

template<std::ranges::contiguous_range R>
TokenList(BumpAllocator& alloc, const R& src)
Constructs a token list by copying the elements of src into storage allocated from alloc.
TokenList(BumpAllocator& alloc, std::span<const TokenOrSyntax> children)
Constructs a token list from a span of TokenOrSyntax elements.

Public functions

size_t size() const noexcept
size_t getChildCount() const
Number of child items the list contributes to its parent's flattened child index space.
TokenOrSyntax getChild(size_t index)
Gets the i-th token as a (Const)TokenOrSyntax.
void setChild(size_t index, TokenOrSyntax child)
Replaces the i-th token with child.
SourceRange sourceRange() const
Compute the SourceRange spanning all tokens of this list.
bool empty() const noexcept

Function documentation

template<std::ranges::contiguous_range R>
slang::syntax::TokenList::TokenList(BumpAllocator& alloc, const R& src)

Constructs a token list by copying the elements of src into storage allocated from alloc.

The element type of the source range must be parsing::Token.

slang::syntax::TokenList::TokenList(BumpAllocator& alloc, std::span<const TokenOrSyntax> children)

Constructs a token list from a span of TokenOrSyntax elements.

Every such element must actually be a token.

size_t slang::syntax::TokenList::size() const noexcept

Returns the number of elements in the list.

SourceRange slang::syntax::TokenList::sourceRange() const

Compute the SourceRange spanning all tokens of this list.

If empty, returns a default SourceRange.

bool slang::syntax::TokenList::empty() const noexcept

Returns true if the list is empty, false otherwise.