slang::syntax::SyntaxNode class

Base class for all syntax nodes.

Derived classes

struct ActionBlockSyntax
Concrete syntax definition for an ActionBlock.
struct ArgumentListSyntax
Concrete syntax definition for an ArgumentList.
struct ArgumentSyntax
Concrete syntax definition for an Argument.
struct AssertionItemPortListSyntax
Concrete syntax definition for an AssertionItemPortList.
struct AssertionItemPortSyntax
Concrete syntax definition for an AssertionItemPort.
struct AssignmentPatternItemSyntax
Concrete syntax definition for an AssignmentPatternItem.
struct AssignmentPatternSyntax
Concrete syntax definition for an AssignmentPattern.
struct AttributeInstanceSyntax
Concrete syntax definition for an AttributeInstance.
struct AttributeSpecSyntax
Concrete syntax definition for an AttributeSpec.
struct BindTargetListSyntax
Concrete syntax definition for a BindTargetList.
struct BinsSelectExpressionSyntax
Concrete syntax definition for a BinsSelectExpression.
struct BlockCoverageEventSyntax
Concrete syntax definition for a BlockCoverageEvent.
struct BlockEventExpressionSyntax
Concrete syntax definition for a BlockEventExpression.
struct CaseItemSyntax
Concrete syntax definition for a CaseItem.
struct ClockingDirectionSyntax
Concrete syntax definition for a ClockingDirection.
struct ClockingSkewSyntax
Concrete syntax definition for a ClockingSkew.
struct ColonExpressionClauseSyntax
Concrete syntax definition for a ColonExpressionClause.
struct CompilationUnitSyntax
Concrete syntax definition for a CompilationUnit.
struct ConditionalPatternSyntax
Concrete syntax definition for a ConditionalPattern.
struct ConditionalPredicateSyntax
Concrete syntax definition for a ConditionalPredicate.
struct ConfigCellIdentifierSyntax
Concrete syntax definition for a ConfigCellIdentifier.
struct ConfigInstanceIdentifierSyntax
Concrete syntax definition for a ConfigInstanceIdentifier.
struct ConfigRuleClauseSyntax
Concrete syntax definition for a ConfigRuleClause.
struct ConfigRuleSyntax
Concrete syntax definition for a ConfigRule.
struct ConstraintItemSyntax
Concrete syntax definition for a ConstraintItem.
struct CoverageBinInitializerSyntax
Concrete syntax definition for a CoverageBinInitializer.
struct CoverageBinsArraySizeSyntax
Concrete syntax definition for a CoverageBinsArraySize.
struct CoverageIffClauseSyntax
Concrete syntax definition for a CoverageIffClause.
struct DeclaratorSyntax
Concrete syntax definition for a Declarator.
struct DefParamAssignmentSyntax
Concrete syntax definition for a DefParamAssignment.
struct DeferredAssertionSyntax
Concrete syntax definition for a DeferredAssertion.
struct DelayedSequenceElementSyntax
Concrete syntax definition for a DelayedSequenceElement.
struct DimensionSpecifierSyntax
Concrete syntax definition for a DimensionSpecifier.
struct DirectiveSyntax
Concrete syntax definition for a Directive.
struct DisableIffSyntax
Concrete syntax definition for a DisableIff.
struct DistConstraintListSyntax
Concrete syntax definition for a DistConstraintList.
struct DistItemSyntax
Concrete syntax definition for a DistItem.
struct DistWeightSyntax
Concrete syntax definition for a DistWeight.
struct DividerClauseSyntax
Concrete syntax definition for a DividerClause.
struct DotMemberClauseSyntax
Concrete syntax definition for a DotMemberClause.
struct EdgeControlSpecifierSyntax
Concrete syntax definition for an EdgeControlSpecifier.
struct EdgeDescriptorSyntax
Concrete syntax definition for an EdgeDescriptor.
struct ElementSelectSyntax
Concrete syntax definition for an ElementSelect.
struct ElseClauseSyntax
Concrete syntax definition for an ElseClause.
struct ElseConstraintClauseSyntax
Concrete syntax definition for an ElseConstraintClause.
struct ElsePropertyClauseSyntax
Concrete syntax definition for an ElsePropertyClause.
struct EqualsAssertionArgClauseSyntax
Concrete syntax definition for an EqualsAssertionArgClause.
struct EqualsTypeClauseSyntax
Concrete syntax definition for an EqualsTypeClause.
struct EqualsValueClauseSyntax
Concrete syntax definition for an EqualsValueClause.
struct ExpressionSyntax
Concrete syntax definition for an Expression.
struct ExtendsClauseSyntax
Concrete syntax definition for an ExtendsClause.
struct FilePathSpecSyntax
Concrete syntax definition for a FilePathSpec.
struct ForVariableDeclarationSyntax
Concrete syntax definition for a ForVariableDeclaration.
struct ForeachLoopListSyntax
Concrete syntax definition for a ForeachLoopList.
struct FunctionPortListSyntax
Concrete syntax definition for a FunctionPortList.
struct FunctionPortSyntax
Concrete syntax definition for a FunctionPort.
struct FunctionPrototypeSyntax
Concrete syntax definition for a FunctionPrototype.
struct HierarchicalInstanceSyntax
Concrete syntax definition for a HierarchicalInstance.
struct IffEventClauseSyntax
Concrete syntax definition for an IffEventClause.
struct ImplementsClauseSyntax
Concrete syntax definition for an ImplementsClause.
struct InstanceNameSyntax
Concrete syntax definition for an InstanceName.
struct IntersectClauseSyntax
Concrete syntax definition for an IntersectClause.
struct LibraryIncDirClauseSyntax
Concrete syntax definition for a LibraryIncDirClause.
struct LibraryMapSyntax
Concrete syntax definition for a LibraryMap.
struct MacroActualArgumentListSyntax
Concrete syntax definition for a MacroActualArgumentList.
struct MacroActualArgumentSyntax
Concrete syntax definition for a MacroActualArgument.
struct MacroArgumentDefaultSyntax
Concrete syntax definition for a MacroArgumentDefault.
struct MacroFormalArgumentListSyntax
Concrete syntax definition for a MacroFormalArgumentList.
struct MacroFormalArgumentSyntax
Concrete syntax definition for a MacroFormalArgument.
struct MatchesClauseSyntax
Concrete syntax definition for a MatchesClause.
struct MemberSyntax
Concrete syntax definition for a Member.
struct ModportItemSyntax
Concrete syntax definition for a ModportItem.
struct ModportPortSyntax
Concrete syntax definition for a ModportPort.
struct ModuleHeaderSyntax
Concrete syntax definition for a ModuleHeader.
struct NamedBlockClauseSyntax
Concrete syntax definition for a NamedBlockClause.
struct NamedLabelSyntax
Concrete syntax definition for a NamedLabel.
struct NetStrengthSyntax
Concrete syntax definition for a NetStrength.
struct NonAnsiPortSyntax
Concrete syntax definition for a NonAnsiPort.
struct OpenRangeListSyntax
Concrete syntax definition for an OpenRangeList.
struct PackageImportItemSyntax
Concrete syntax definition for a PackageImportItem.
struct ParamAssignmentSyntax
Concrete syntax definition for a ParamAssignment.
struct ParameterDeclarationBaseSyntax
Concrete syntax definition for a ParameterDeclarationBase.
struct ParameterPortListSyntax
Concrete syntax definition for a ParameterPortList.
struct ParameterValueAssignmentSyntax
Concrete syntax definition for a ParameterValueAssignment.
struct ParenExpressionListSyntax
Concrete syntax definition for a ParenExpressionList.
struct PathDescriptionSyntax
Concrete syntax definition for a PathDescription.
struct PathSuffixSyntax
Concrete syntax definition for a PathSuffix.
struct PatternSyntax
Concrete syntax definition for a Pattern.
struct PortConnectionSyntax
Concrete syntax definition for a PortConnection.
struct PortExpressionSyntax
Concrete syntax definition for a PortExpression.
struct PortHeaderSyntax
Concrete syntax definition for a PortHeader.
struct PortListSyntax
Concrete syntax definition for a PortList.
struct PragmaExpressionSyntax
Concrete syntax definition for a PragmaExpression.
struct ProductionSyntax
Concrete syntax definition for a Production.
struct PropertyCaseItemSyntax
Concrete syntax definition for a PropertyCaseItem.
struct PropertyExprSyntax
Concrete syntax definition for a PropertyExpr.
struct PropertySpecSyntax
Concrete syntax definition for a PropertySpec.
struct RandCaseItemSyntax
Concrete syntax definition for a RandCaseItem.
struct RandJoinClauseSyntax
Concrete syntax definition for a RandJoinClause.
struct RsCaseItemSyntax
Concrete syntax definition for a RsCaseItem.
struct RsElseClauseSyntax
Concrete syntax definition for a RsElseClause.
struct RsProdSyntax
Concrete syntax definition for a RsProd.
struct RsRuleSyntax
Concrete syntax definition for a RsRule.
struct RsWeightClauseSyntax
Concrete syntax definition for a RsWeightClause.
struct SelectorSyntax
Concrete syntax definition for a Selector.
struct SequenceExprSyntax
Concrete syntax definition for a SequenceExpr.
struct SequenceMatchListSyntax
Concrete syntax definition for a SequenceMatchList.
struct SequenceRepetitionSyntax
Concrete syntax definition for a SequenceRepetition.
struct SpecparamDeclaratorSyntax
Concrete syntax definition for a SpecparamDeclarator.
struct StatementSyntax
Concrete syntax definition for a Statement.
struct StreamExpressionSyntax
Concrete syntax definition for a StreamExpression.
struct StreamExpressionWithRangeSyntax
Concrete syntax definition for a StreamExpressionWithRange.
struct StructUnionMemberSyntax
Concrete syntax definition for a StructUnionMember.
struct StructurePatternMemberSyntax
Concrete syntax definition for a StructurePatternMember.
class SyntaxListBase
A base class for syntax nodes that represent a list of items.
struct TimingCheckArgSyntax
Concrete syntax definition for a TimingCheckArg.
struct TimingCheckEventConditionSyntax
Concrete syntax definition for a TimingCheckEventCondition.
struct TimingControlSyntax
Concrete syntax definition for a TimingControl.
struct TransRangeSyntax
Concrete syntax definition for a TransRange.
struct TransRepeatRangeSyntax
Concrete syntax definition for a TransRepeatRange.
struct TransSetSyntax
Concrete syntax definition for a TransSet.
struct TypeAssignmentSyntax
Concrete syntax definition for a TypeAssignment.
struct UdpBodySyntax
Concrete syntax definition for an UdpBody.
struct UdpEntrySyntax
Concrete syntax definition for an UdpEntry.
struct UdpFieldBaseSyntax
Concrete syntax definition for an UdpFieldBase.
struct UdpInitialStmtSyntax
Concrete syntax definition for an UdpInitialStmt.
struct UdpPortDeclSyntax
Concrete syntax definition for an UdpPortDecl.
struct UdpPortListSyntax
Concrete syntax definition for an UdpPortList.
struct VariableDimensionSyntax
Concrete syntax definition for a VariableDimension.
struct WithClauseSyntax
Concrete syntax definition for a WithClause.
struct WithFunctionClauseSyntax
Concrete syntax definition for a WithFunctionClause.
struct WithFunctionSampleSyntax
Concrete syntax definition for a WithFunctionSample.

Public static functions

static auto isKind(SyntaxKind) -> bool
A base implemention of the method that checks correctness of dynamic casting.

Public functions

auto toString() const -> std::string
Print the node and all of its children to a string.
auto getFirstToken() const -> Token
Get the first leaf token in this subtree.
auto getLastToken() const -> Token
Get the last leaf token in this subtree.
auto getFirstTokenPtr() -> Token*
Get the first leaf token as a mutable pointer in this subtree.
auto getLastTokenPtr() -> Token*
Get the last leaf token a mutable pointer in this subtree.
auto sourceRange() const -> SourceRange
Get the source range of the node.
auto childNode(size_t index) const -> const SyntaxNode*
Gets the child syntax node at the specified index.
auto childNode(size_t index) -> SyntaxNode*
Gets the child syntax node at the specified index.
auto childToken(size_t index) const -> Token
Gets the child token at the specified index.
auto childTokenPtr(size_t index) -> Token*
Gets a pointer to the child token at the specified index.
auto getChildCount() const -> size_t
Gets the number of (direct) children underneath this node in the tree.
auto isEquivalentTo(const SyntaxNode& other) const -> bool
Returns true if this syntax node is "equivalent" to the other provided syntax node.
template<typename T>
auto as() -> T&
Reinterprets this node as being of type T.
template<typename T>
auto as() const -> const T&
Reinterprets this node as being of type T.
template<typename TVisitor, typename... Args>
auto visit(TVisitor& visitor, Args && ... args) -> decltype(auto)
Applies a visitor object to this node by dispatching based on the dynamic kind.
template<typename TVisitor, typename... Args>
auto visit(TVisitor& visitor, Args && ... args) const -> decltype(auto)
Applies a visitor object to this node by dispatching based on the dynamic kind.

Public variables

SyntaxNode* parent
The parent node of this syntax node.
SyntaxKind kind
The kind of syntax node.

Function documentation

static bool slang::syntax::SyntaxNode::isKind(SyntaxKind)

A base implemention of the method that checks correctness of dynamic casting.

Derived nodes should reimplement this and return true if the provided syntax kind is compatible with the static type of the object.

const SyntaxNode* slang::syntax::SyntaxNode::childNode(size_t index) const

Gets the child syntax node at the specified index.

If the child at the given index is not a node (probably a token) then this returns null.

SyntaxNode* slang::syntax::SyntaxNode::childNode(size_t index)

Gets the child syntax node at the specified index.

If the child at the given index is not a node (probably a token) then this returns null.

Token slang::syntax::SyntaxNode::childToken(size_t index) const

Gets the child token at the specified index.

If the child at the given index is not a token (probably a node) then this returns an empty Token.

Token* slang::syntax::SyntaxNode::childTokenPtr(size_t index)

Gets a pointer to the child token at the specified index.

If the child at the given index is not a token (probably a node) then this returns null.

bool slang::syntax::SyntaxNode::isEquivalentTo(const SyntaxNode& other) const

Returns true if this syntax node is "equivalent" to the other provided syntax node.

Equivalence here is determined by the entire subtrees having the same kinds of syntax nodes in the same order and all leaf tokens having the same kinds and value text.

template<typename T>
T& slang::syntax::SyntaxNode::as()

Reinterprets this node as being of type T.

In debug this will assert that the dynamic kind is appropriate for the specified static type.

template<typename T>
const T& slang::syntax::SyntaxNode::as() const

Reinterprets this node as being of type T.

In debug this will assert that the dynamic kind is appropriate for the specified static type.

template<typename TVisitor, typename... Args>
decltype(auto) slang::syntax::SyntaxNode::visit(TVisitor& visitor, Args && ... args)

Applies a visitor object to this node by dispatching based on the dynamic kind.

The given args are forwarded to the visitor.

template<typename TVisitor, typename... Args>
decltype(auto) slang::syntax::SyntaxNode::visit(TVisitor& visitor, Args && ... args) const

Applies a visitor object to this node by dispatching based on the dynamic kind.

The given args are forwarded to the visitor.

Variable documentation

SyntaxNode* slang::syntax::SyntaxNode::parent

The parent node of this syntax node.

The root of the syntax tree does not have a parent (will be nullptr).