Documentation
¶
Overview ¶
Package astcodec writes syntax trees to a pack stream and reads them back. Nodes form a table, grouped by type, and refer to each other by table index.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownNode = errors.New("astcodec: node of a type the codec does not know")
ErrUnknownNode reports a node of a type the codec does not know, which it refuses to encode rather than drop.
Functions ¶
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads one node table: Allocate creates the nodes, Fill reads their fields, and Node may hand out addresses while Fill runs elsewhere.
func NewDecoder ¶
NewDecoder returns a Decoder reading from r.
func (*Decoder) Allocate ¶
func (d *Decoder) Allocate()
Allocate reads the node counts, allocates every node in one block per type, and moves the reader past the table; the nodes' fields are zero until Fill.
func (*Decoder) Decode ¶
func (d *Decoder) Decode()
Decode reads the node table Encode wrote: Allocate then Fill. Errors are left on the reader for the caller to check.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder writes one node table.
func NewEncoder ¶
NewEncoder returns an Encoder writing to w.