Module ast

Module ast 

Source
Expand description

Abstract syntax tree representation of hugr modules.

This module defines the abstract syntax tree for hugr graphs. The AST types implement Display and FromStr for pretty printing into and parsing from the s-expression based hugr text form. This is useful for debugging and writing hugr modules by hand. For a more performant serialization format, see binary instead.

The data types in this module logically mirror those of the table representation, but are encoded differently. Instead of using ids, the AST data structure is recursive and uses names for symbols, variables and links. Terms, Nodes and Regions can be referred to individually in this form, whereas the table form requires them to be seen in the context of a module. An AST module can be translated into a table module via Module::resolve. This representation makes different efficiency tradeoffs than the table form by using standard heap based data structures instead of a bump allocated arena. This is slower but considerably more ergonomic.

Structs§

Module
A module in the hugr AST.
Node
A node in the hugr AST.
Package
A package in the hugr AST.
Param
A parameter of a Symbol in the hugr AST.
ParseError
An error that occurred during parsing.
Region
A region in the hugr AST.
Symbol
A symbol declaration in the hugr AST.

Enums§

Operation
The operation of a Node in the hugr AST.
ResolveError
Error that may occur in Module::resolve.
SeqPart
A part of a tuple/list Term in the hugr AST.
Term
A term in the hugr AST.