Documentation ¶
Overview ¶
Package ws parses Whitespace source files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyLabelMap ¶
ApplyLabelMap adds label names from mapping to tokens.
func ParseLabelMap ¶
ParseLabelMap reads a label source map and parses it into mappings from label name to integer value.
Types ¶
type Program ¶
Program is a sequence of Whitespace tokens with file information.
func (*Program) DumpCommented ¶
DumpCommented formats a program as Whitesapce assembly with comments interspersed.
func (*Program) DumpPos ¶
DumpPos formats a program as Whitespace assembly with source position information.
type SyntaxError ¶
SyntaxError identifies the location of a syntactic error.
func (*SyntaxError) Error ¶
func (err *SyntaxError) Error() string
type Token ¶
type Token struct { Type Type Arg *big.Int ArgString string // Label string, if exists Pos token.Pos // Start position in source End token.Pos // End position in source (exclusive) }
Token is a lexical token in Whitespace.
type TokenError ¶
TokenError is an error emitted while lowering to SSA form.
func (*TokenError) Error ¶
func (err *TokenError) Error() string
type Type ¶
type Type uint8
Type is the instruction type of a Whitespace token.
const ( Illegal Type = iota // Stack manipulation instructions Push Dup Copy Swap Drop Slide Shuffle // non-standard; from Harold Lee's whitespace-0.4 // Arithmetic instructions Add Sub Mul Div Mod // Heap access instructions Store Retrieve // Control flow instructions Label Call Jmp Jz Jn Ret End // I/O instructions Printc Printi Readc Readi // Debug instructions (non-standard) Trace // from Phillip Bradbury's pywhitespace DumpStack // from Oliver Burghard's interpreter DumpHeap // from Oliver Burghard's interpreter )
Instruction types.
func (Type) IsControl ¶
IsControl returns true for tokens corresponding to control flow instructions.