# Circuit Representation and Construction API

`parseroutput.h`/`parseroutput.cpp` define the "PT" (Parse Tree) node types the [parser](dflparser.md) builds while reading a netlist, plus `ParserTables`, the toplevel container that owns all of them for one parse. These are a plain, mostly move-only data model - not the simulation-ready `Circuit` structure elaboration later builds from them - meant to be assembled once, either by parsing netlist text or directly by a C++ caller building a circuit programmatically, and consumed once during elaboration.

## The fluent `add()` pattern

Almost every type here exposes the same "fluent" `add()` pattern: overloads qualified separately for lvalue and rvalue `*this` (`Type& add(...) & { ...; return *this; }` and `Type&& add(...) && { return std::move(this->add(...)); }`), so the same object can be built either as a named local (`obj.add(x); obj.add(y);`) or chained inline (`PTInstance(...).add(x).add(y)`) without the rvalue chain silently downgrading a move into a copy at each step - every `&&` overload forwards into the `&` one and moves the whole, already-modified object back out.

## Key concepts

**[PTParsedIdentifier and PTIdentifierList](ptidentifier.md)** - a parsed name plus its source location, and the list type built from them (terminal lists, global/ground nodes).

**[PTParameterValue and PTParameterExpression](ptparametervalue.md)** - the two ways a `name = expr` parameter can be represented, depending on whether the parser could constant-fold it.

**[PTParameters and PTParameterMap](ptparameters.md)** - the parameter list attached to instances/models/etc., and a separate name-keyed lookup structure built from one or more of them.

**[PTModel and PTInstance](ptmodel.md)** - a `model` statement and an instance placement.

**[PTBlock and PTBlockSequence](ptblock.md)** - the contents of one netlist scope, and the arm-by-arm representation of an `@if`/`@elseif`/`@else` chain.

**[PTSubcircuitDefinition](ptsubckt.md)** - a `subckt`/`ends` definition, which doubles as the representation of the toplevel netlist itself.

**[PTLoad, PTSaves, and PTEmbed](ptload.md)** - `load`, `save`, and `embed` directives.

**[PTSweep and PTAnalysis](ptanalysis.md)** - `sweep` clauses and the `analysis` statement they precede.

**[PTCommand](ptcommand.md)** - the generic representation for every other control-block statement.

**[ParserTables](parsertables.md)** - the toplevel container one parse (or hand-built circuit) accumulates into, including its verification levels and embedded-file writing.

**[PVv and PEv Helpers](ptvectorhelpers.md)** - small constructor helpers for building parameter vectors inline when using this API directly from C++.

**[PTBehavioral](ptbehavioral.md)** - a behavioral source instance (`name (n1 n2) v=expr`/`i=expr`), consumed by `ParserTables::processBehaviorals()` and turned into an auto-generated Verilog-A module plus an ordinary model/instance pair.
