syn

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2025 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TermTagWidth    byte = 4
	ConstTagWidth   byte = 4
	BuiltinTagWidth byte = 7
)

Widths

View Source
const (
	VarTag      byte = 0
	DelayTag    byte = 1
	LambdaTag   byte = 2
	ApplyTag    byte = 3
	ConstantTag byte = 4
	ForceTag    byte = 5
	ErrorTag    byte = 6
	BuiltinTag  byte = 7
	ConstrTag   byte = 8
	CaseTag     byte = 9
)

Term Tags

View Source
const (
	IntegerTag        byte = 0
	ByteStringTag     byte = 1
	StringTag         byte = 2
	UnitTag           byte = 3
	BoolTag           byte = 4
	DataTag           byte = 8
	ProtoListOneTag   byte = 7
	ProtoListTwoTag   byte = 5
	ProtoPairOneTag   byte = 7
	ProtoPairTwoTag   byte = 7
	ProtoPairThreeTag byte = 6
)

Constant Tags

Variables

This section is empty.

Functions

func DecodeList

func DecodeList[T any](
	d *decoder,
	decoderFunc func(*decoder) (T, error),
) ([]T, error)

Decode a list of items with a decoder function. This is byte alignment agnostic. Decode a bit from the buffer. If 0 then stop. Otherwise we decode an item in the list with the decoder function passed in. Then decode the next bit in the buffer and repeat above. Returns a list of items decoded with the decoder function.

func Encode

func Encode[T Binder](program *Program[T]) ([]byte, error)

func EncodeList

func EncodeList[T any](
	e *encoder,
	items []T,
	itemEncoder func(*encoder, T) error,
) error

func EncodeTerm

func EncodeTerm[T Binder](e *encoder, term Term[T]) error

func Pretty

func Pretty[T Binder](p *Program[T]) string

Pretty Print a Program

func PrettyTerm

func PrettyTerm[T Binder](t Term[T]) string

Pretty Print a Program

Types

type Apply

type Apply[T any] struct {
	Function Term[T]
	Argument Term[T]
}

[ (lam x x) (con integer 1) ]

type Binder

type Binder interface {
	VarEncode(e *encoder) error
	VarDecode(d *decoder) (Binder, error)

	ParameterEncode(e *encoder) error
	ParameterDecode(d *decoder) (Binder, error)

	TextName() string

	fmt.Stringer
}

type Bls12_381G1Element

type Bls12_381G1Element struct {
	Inner *bls.G1Jac
}

func (Bls12_381G1Element) Typ

func (Bls12_381G1Element) Typ() Typ

type Bls12_381G2Element

type Bls12_381G2Element struct {
	Inner *bls.G2Jac
}

func (Bls12_381G2Element) Typ

func (Bls12_381G2Element) Typ() Typ

type Bls12_381MlResult

type Bls12_381MlResult struct {
	Inner *bls.GT
}

func (Bls12_381MlResult) Typ

func (Bls12_381MlResult) Typ() Typ

type Bool

type Bool struct {
	Inner bool
}

(con bool True)

func (Bool) Typ

func (b Bool) Typ() Typ

type Builtin

type Builtin struct {
	builtin.DefaultFunction
}

(builtin addInteger)

type ByteString

type ByteString struct {
	Inner []byte
}

(con bytestring #aaBB)

func (ByteString) Typ

func (bs ByteString) Typ() Typ

type Case

type Case[T any] struct {
	Constr   Term[T]
	Branches []Term[T]
}

(case (constr 0) (constr 1 (con integer 1)))

type Constant

type Constant struct {
	Con IConstant
}

(con integer 1)

type Constr

type Constr[T any] struct {
	Tag    uint
	Fields []Term[T]
}

(constr 0 (con integer 1) (con string "1234"))

type Data

type Data struct {
	Inner data.PlutusData
}

func (Data) Typ

func (Data) Typ() Typ

type DeBruijn

type DeBruijn int

An index into the Machine's environment which powers var lookups

func (DeBruijn) LookupIndex

func (n DeBruijn) LookupIndex() int

func (DeBruijn) ParameterDecode

func (n DeBruijn) ParameterDecode(d *decoder) (Binder, error)

func (DeBruijn) ParameterEncode

func (n DeBruijn) ParameterEncode(e *encoder) error

func (DeBruijn) String

func (n DeBruijn) String() string

func (DeBruijn) TextName

func (n DeBruijn) TextName() string

func (DeBruijn) VarDecode

func (n DeBruijn) VarDecode(d *decoder) (Binder, error)

func (DeBruijn) VarEncode

func (n DeBruijn) VarEncode(e *encoder) error

type Delay

type Delay[T any] struct {
	Term Term[T]
}

(delay x)

type Error

type Error struct{}

(error )

type Eval

type Eval interface {
	Binder
	LookupIndex() int
}

type Force

type Force[T any] struct {
	Term Term[T]
}

(force x)

type IConstant

type IConstant interface {
	Typ() Typ
	// contains filtered or unexported methods
}

func DecodeConstant

func DecodeConstant(d *decoder) (IConstant, error)

type Integer

type Integer struct {
	Inner *big.Int
}

(con integer 1)

func (Integer) Typ

func (i Integer) Typ() Typ

type Lambda

type Lambda[T any] struct {
	ParameterName T
	Body          Term[T]
}

(lam x x)

type Name

type Name struct {
	Text   string
	Unique Unique
}

func NewName

func NewName(text string, unique Unique) Name

NewName creates a new Name with the provided text and a default Unique value of 0.

func NewRawName

func NewRawName(text string) Name

NewRawName creates a new Name with the provided text and a default Unique value of 0.

func (Name) ParameterDecode

func (n Name) ParameterDecode(d *decoder) (Binder, error)

func (Name) ParameterEncode

func (n Name) ParameterEncode(e *encoder) error

func (Name) String

func (n Name) String() string

func (Name) TextName

func (n Name) TextName() string

func (Name) VarDecode

func (n Name) VarDecode(d *decoder) (Binder, error)

func (Name) VarEncode

func (n Name) VarEncode(e *encoder) error

type NamedDeBruijn

type NamedDeBruijn struct {
	Text  string
	Index DeBruijn
}

func (NamedDeBruijn) LookupIndex

func (n NamedDeBruijn) LookupIndex() int

func (NamedDeBruijn) ParameterDecode

func (n NamedDeBruijn) ParameterDecode(d *decoder) (Binder, error)

func (NamedDeBruijn) ParameterEncode

func (n NamedDeBruijn) ParameterEncode(e *encoder) error

func (NamedDeBruijn) String

func (n NamedDeBruijn) String() string

func (NamedDeBruijn) TextName

func (n NamedDeBruijn) TextName() string

func (NamedDeBruijn) VarDecode

func (n NamedDeBruijn) VarDecode(d *decoder) (Binder, error)

func (NamedDeBruijn) VarEncode

func (n NamedDeBruijn) VarEncode(e *encoder) error

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(input string) *Parser

func (*Parser) ParseProgram

func (p *Parser) ParseProgram() (*Program[Name], error)

func (*Parser) ParseTerm

func (p *Parser) ParseTerm() (Term[Name], error)

type PrettyPrinter

type PrettyPrinter struct {
	// contains filtered or unexported fields
}

PrettyPrinter manages the state for pretty-printing AST nodes

func NewPrettyPrinter

func NewPrettyPrinter(indentSize int) *PrettyPrinter

NewPrettyPrinter creates a new PrettyPrinter with the specified indent size

type Program

type Program[T any] struct {
	Version [3]uint32
	Term    Term[T]
}

(program 1.0.0 (con integer 1))

func Decode

func Decode[T Binder](bytes []byte) (*Program[T], error)

func NameToDeBruijn

func NameToDeBruijn(p *Program[Name]) (*Program[DeBruijn], error)

func NameToNamedDeBruijn

func NameToNamedDeBruijn(p *Program[Name]) (*Program[NamedDeBruijn], error)

func NewProgram

func NewProgram(version [3]uint32, term Term[Name]) *Program[Name]

func Parse

func Parse(input string) (*Program[Name], error)

type ProtoList

type ProtoList struct {
	LTyp Typ
	List []IConstant
}

func (ProtoList) Typ

func (pl ProtoList) Typ() Typ

type ProtoPair

type ProtoPair struct {
	FstType Typ
	SndType Typ
	First   IConstant
	Second  IConstant
}

func (ProtoPair) Typ

func (pp ProtoPair) Typ() Typ

type String

type String struct {
	Inner string
}

(con string "hello world")

func (String) Typ

func (s String) Typ() Typ

type TBls12_381G1Element

type TBls12_381G1Element struct{}

type TBls12_381G2Element

type TBls12_381G2Element struct{}

type TBls12_381MlResult

type TBls12_381MlResult struct{}

type TBool

type TBool struct{}

type TByteString

type TByteString struct{}

type TData

type TData struct{}

type TInteger

type TInteger struct{}

type TList

type TList struct {
	Typ
}

type TPair

type TPair struct {
	First  Typ
	Second Typ
}

type TString

type TString struct{}

type TUnit

type TUnit struct{}

type Term

type Term[T any] interface {
	// contains filtered or unexported methods
}

func AddInteger

func AddInteger() Term[Name]

func DecodeTerm

func DecodeTerm[T Binder](d *decoder) (Term[T], error)

func IfThenElse

func IfThenElse() Term[Name]

func Intern

func Intern(term Term[Name]) Term[Name]

func NewApply

func NewApply(function Term[Name], argument Term[Name]) Term[Name]

func NewBool

func NewBool(value bool) Term[Name]

func NewBuiltin

func NewBuiltin(fn builtin.DefaultFunction) Term[Name]

func NewConstant

func NewConstant(con IConstant) Term[Name]

func NewDelay

func NewDelay(term Term[Name]) Term[Name]

func NewForce

func NewForce(term Term[Name]) Term[Name]

func NewInteger

func NewInteger(value *big.Int) Term[Name]

func NewLambda

func NewLambda(parameterName Name, body Term[Name]) Term[Name]

func NewRawVar

func NewRawVar(name string) Term[Name]

func NewSimpleInteger

func NewSimpleInteger(value int) Term[Name]

func NewVar

func NewVar(name string, unique Unique) Term[Name]

func SubtractInteger

func SubtractInteger() Term[Name]

type Typ

type Typ interface {
	// contains filtered or unexported methods
}

type Unique

type Unique uint64

type Unit

type Unit struct{}

(con unit ())

func (Unit) Typ

func (u Unit) Typ() Typ

type Var

type Var[T any] struct {
	Name T
}

x

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL