ast

package
v0.0.0-...-747230a Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ast implements an abstract syntax tree for BIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanAddr

func CanAddr(expr Expr) bool

CanAddr returns true if the expression is an addressable BIT value.

func CanAssign

func CanAssign(expr Expr) bool

CanAssign returns true if the expression points to a mutable value.

func CanDeref

func CanDeref(expr Expr) bool

CanDeref returns true if the expression is a pointer value.

func CanVal

func CanVal(expr Expr) bool

CanVal returns true if the expression can be read as BIT value.

Types

type AddressOf

type AddressOf struct {
	Val Expr
}

AddressOf is the THE ADDRESS OF operator. It can be used on variables and on the result of dereferencing a pointer using THE VALUE AT or THE VALUE BEYOND.

func (*AddressOf) String

func (a *AddressOf) String() string

type Bit

type Bit bool

Bit is a single ZERO or ONE.

const (
	// Zero is the ZERO bit.
	Zero Bit = false
	// One is the ONE bit.
	One Bit = true
)

func (Bit) String

func (b Bit) String() string

String implements fmt.Stringer.

type Bits

type Bits []Bit

Bits is a series of ZERO and ONE.

func (Bits) Set

func (b Bits) Set(z *big.Int) *big.Int

Set copies the numeric value of this Bits to a *big.Int. It returns the *big.Int for convenience.

func (Bits) String

func (b Bits) String() string

String implements fmt.Stringer.

type Constant

type Constant struct {
	Val Bit
}

Constant is a bit value constant.

func (*Constant) String

func (c *Constant) String() string

type Equals

type Equals struct {
	Left, Right Expr
}

Equals is the EQUALS command, which assigns the value generated by Right to the variable, register, or dereferenced pointer in Left. The values must be of the same type.

type Expr

type Expr interface {
	String() string
	// contains filtered or unexported methods
}

Expr is the interface all expressions implement.

type JumpRegister

type JumpRegister struct {
}

JumpRegister is the jump register. It can be written to, but not read from.

func (*JumpRegister) String

func (*JumpRegister) String() string

type Line

type Line struct {
	// Num is the line number.
	Num Bits
	// Stmt is the command on this line of code.
	Stmt Stmt
	// Goto0 is the line to go to next if the jump register is ZERO.
	// If Goto0 is nil, the program terminates.
	Goto0 Bits
	// Goto1 is the line to go to next if the jump register is ONE.
	// If Goto1 is nil, the program terminates.
	Goto1 Bits
}

Line is a single line of code in a BIT program.

type Nand

type Nand struct {
	Left, Right Expr
}

Nand is the NAND operator. It is left-associative and returns ONE if either expression is ZERO or ZERO if both expressions are ONE. The expressions must not result in pointer-to-a-bit values.

func (*Nand) String

func (n *Nand) String() string

type Print

type Print struct {
	Val Bit
}

Print outputs a bit to the standard output. The bit is written in uppercase ASCII letters and is followed by a line feed.

type Program

type Program struct {
	Lines []*Line
}

Program is a BIT program.

type Read

type Read struct {
}

Read reads the next bit from the standard input. The bit is written in uppercase ASCII letters and may contain whitespace but no other characters.

type Stmt

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

Stmt is the interface all statements implement.

type ValueAt

type ValueAt struct {
	Ptr Expr
}

ValueAt is the THE VALUE AT operator. It can be used on pointers, either stored in a variable or from the THE ADDRESS OF operator.

func (*ValueAt) String

func (v *ValueAt) String() string

type ValueBeyond

type ValueBeyond struct {
	Ptr Expr
}

ValueBeyond is the THE VALUE BEYOND operator. It can be used on pointers, either stored in a variable or from the THE ADDRESS OF operator.

func (*ValueBeyond) String

func (v *ValueBeyond) String() string

type Variable

type Variable struct {
	Num Bits
}

Variable is a numbered variable slot.

Each variable can either hold a bit or a pointer-to-a-bit. Changing the type of a variable within a program is an error. Bit variables are stored in isolated memory spaces, so there is no way to get from one bit variable to another with THE VALUE BEYOND or any other operator.

func (*Variable) String

func (v *Variable) String() string

Jump to

Keyboard shortcuts

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