slang::syntax::CSTSerializer class

Converts concrete syntax trees to JSON format for debugging and analysis.

Public functions

void serialize(const SyntaxTree& tree)
Serialize a syntax tree to JSON.
void serialize(const SyntaxNode& node, const SourceManager* sourceManager = nullptr)
Serialize a syntax node to JSON.

Function documentation

void slang::syntax::CSTSerializer::serialize(const SyntaxNode& node, const SourceManager* sourceManager = nullptr)

Serialize a syntax node to JSON.

If provided, the source manager is used to annotate tokens that originate from macro expansions or included files with a "fromExpansion": true property. Such tokens are serialized in addition to the directive that produced them, so the annotation lets consumers avoid double-counting the text.