template<typename T>
slang::syntax::SyntaxList class

A container of syntax nodes.

Base classes

template<typename Derived, typename Element>
class SyntaxListBase<SyntaxList<T>, T*>
Common base for the three syntax-list container types.

Constructors, destructors, conversion operators

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

Public functions

size_t size() const noexcept
const T* operator[](size_t index) const
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 element as a (Const)TokenOrSyntax.
void setChild(size_t index, TokenOrSyntax child)
Replaces the i-th element with child.
SourceRange sourceRange() const
Compute the SourceRange spanning all the elements of this list.
bool empty() const noexcept

Function documentation

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

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

The element type of the source range must be T*.

template<typename T>
slang::syntax::SyntaxList<T>::SyntaxList(BumpAllocator& alloc, std::span<const TokenOrSyntax> children)

Constructs a syntax list from a span of TokenOrSyntax elements.

Every such element must actually be a syntax node of the correct concrete type.

template<typename T>
slang::syntax::SyntaxList<T>::operator std::span<const T*const>() const noexcept

Returns the elements as a std::span.

template<typename T>
size_t slang::syntax::SyntaxList<T>::size() const noexcept

Returns the number of elements in the list.

template<typename T>
const T* slang::syntax::SyntaxList<T>::operator[](size_t index) const

Returns a reference to the i-th element.

template<typename T>
SourceRange slang::syntax::SyntaxList<T>::sourceRange() const

Compute the SourceRange spanning all the elements of this list.

If the list is empty, returns an empty default SourceRange.

template<typename T>
bool slang::syntax::SyntaxList<T>::empty() const noexcept

Returns true if the list is empty, false otherwise.