Documentation ¶
Overview ¶
Package ast implements an abstract syntax tree for BIT.
Index ¶
- func CanAddr(expr Expr) bool
- func CanAssign(expr Expr) bool
- func CanDeref(expr Expr) bool
- func CanVal(expr Expr) bool
- type AddressOf
- type Bit
- type Bits
- type Constant
- type Equals
- type Expr
- type JumpRegister
- type Line
- type Nand
- type Print
- type Program
- type Read
- type Stmt
- type ValueAt
- type ValueBeyond
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
type Bits ¶
type Bits []Bit
Bits is a series of ZERO and ONE.
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.
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 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.
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.