Documentation ¶
Index ¶
- Constants
- func WriteListing(inputs []string, linker *Linker) error
- type BytesLiteral
- type CharLiteral
- type DefineByteStatement
- type DefineSpaceStatement
- type DefineWordStatement
- type EquateStatement
- type Expr
- type ExprBinary
- type ExprIdent
- type ExprUnary
- type FpParam
- type FunctionStatement
- type ImportStatement
- type Input
- type InstructionStatement
- type IntLiteral
- type LabelStatement
- type Lexer
- type Linker
- type Message
- type Messages
- func (m *Messages) AddMessage(messageType int, file string, line, column int, message string)
- func (m *Messages) Error(file string, line int, column int, message string)
- func (m *Messages) Info(file string, line int, column int, message string)
- func (m *Messages) Print()
- func (m *Messages) Warn(file string, line int, column int, message string)
- type Node
- func (n *Node) BlockComment() []string
- func (n *Node) EolComment() string
- func (n *Node) File() string
- func (n *Node) Line() int
- func (n *Node) NewlineBefore() bool
- func (n *Node) Next() Statement
- func (n *Node) PcEnd() int
- func (n *Node) PcStart() int
- func (n *Node) SetBlockComment(blockComment []string)
- func (n *Node) SetEolComment(eolComment string)
- func (n *Node) SetFile(file string)
- func (n *Node) SetLine(line int)
- func (n *Node) SetNewlineBefore(newlineBefore bool)
- func (n *Node) SetNext(next Statement)
- func (n *Node) SetPcEnd(pcEnd int)
- func (n *Node) SetPcStart(pcStart int)
- func (n *Node) String() string
- type Operand
- type OrgStatement
- type Parser
- type Printer
- type Source
- type Statement
- type Symbol
- type SymbolTable
- type TokenReader
- type TokenType
- type VarStatement
Constants ¶
const ( MessageError = iota MessageWarning = iota MessageInfo = iota )
const ( OpColumn = 16 CommentColumn = 32 )
Variables ¶
This section is empty.
Functions ¶
func WriteListing ¶
WriteListing prints the generated bytes next to the original source, ie an assembly listing.
Types ¶
type BytesLiteral ¶
type BytesLiteral struct {
// contains filtered or unexported fields
}
type CharLiteral ¶
type CharLiteral struct {
// contains filtered or unexported fields
}
type DefineByteStatement ¶
type DefineByteStatement struct { Node // contains filtered or unexported fields }
type DefineSpaceStatement ¶
type DefineSpaceStatement struct { Node // contains filtered or unexported fields }
type DefineWordStatement ¶
type DefineWordStatement struct { Node // contains filtered or unexported fields }
type EquateStatement ¶
type EquateStatement struct { Node // contains filtered or unexported fields }
type ExprBinary ¶
type ExprBinary struct {
// contains filtered or unexported fields
}
type ExprUnary ¶
type ExprUnary struct {
// contains filtered or unexported fields
}
ExprUnary is a unary operation (+, -) on an expression.
type FunctionStatement ¶
type FunctionStatement struct { Node // contains filtered or unexported fields }
type ImportStatement ¶
type ImportStatement struct { Node // contains filtered or unexported fields }
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
Input implements TokenReader but delegates to a list of underlying TokenReaders, reading each in order until EOF and then moving to the next. Copied from Go's asm/lexer/stack except this one is in order rather than stack based. Need it in order because the first source file will establish the org, all others must be libraries with relocatable code.
func NewInput ¶
func NewInput(readers []TokenReader) *Input
func (*Input) Append ¶
func (i *Input) Append(r TokenReader)
type InstructionStatement ¶
type InstructionStatement struct { Node // contains filtered or unexported fields }
type IntLiteral ¶
type IntLiteral struct {
// contains filtered or unexported fields
}
type LabelStatement ¶
type LabelStatement struct { Node // contains filtered or unexported fields }
type Linker ¶
type Linker struct {
// contains filtered or unexported fields
}
func (*Linker) Link ¶
func (l *Linker) Link()
Link uses two passes to try to resolve all references and generate code into l.code.
func (*Linker) PrintMessages ¶
func (l *Linker) PrintMessages()
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message describes a compiler error, warning, or informational message.
type Messages ¶
type Messages struct {
// contains filtered or unexported fields
}
Messages is a collection of compiler messages.
func (*Messages) AddMessage ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node defines the common fields that all statements share.
func (*Node) BlockComment ¶
func (*Node) EolComment ¶
func (*Node) NewlineBefore ¶
func (*Node) SetBlockComment ¶
func (*Node) SetEolComment ¶
func (*Node) SetNewlineBefore ¶
func (*Node) SetPcStart ¶
type OrgStatement ¶
type OrgStatement struct { Node // contains filtered or unexported fields }
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) PrintErrors ¶
func (p *Parser) PrintErrors()
func (*Parser) SetProcessImport ¶
func (*Parser) Statements ¶
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer pretty-prints statements to a writer.
func NewPrinter ¶
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source represents a source file and the current state of lexing it.
func (*Source) GetTokenImage ¶
GetTokenImage gets the marked token as a string.
func (*Source) MarkEnd ¶
func (s *Source) MarkEnd()
MarkEnd sets the last read character as the end of the current token.
type Statement ¶
type Statement interface { Next() Statement SetNext(next Statement) File() string SetFile(file string) Line() int SetLine(line int) NewlineBefore() bool SetNewlineBefore(newlineBefore bool) BlockComment() []string SetBlockComment(blockComment []string) EolComment() string SetEolComment(eolComment string) PcStart() int SetPcStart(pcStart int) PcEnd() int SetPcEnd(pcEnd int) }
Statement is an interface of Node just so all my types can implement the same interface?
type SymbolTable ¶
type SymbolTable struct {
// contains filtered or unexported fields
}
func NewSymbolTable ¶
func NewSymbolTable() *SymbolTable
func (*SymbolTable) AddFpSymbol ¶
func (s *SymbolTable) AddFpSymbol(file string, line int, text string, offset int)
func (*SymbolTable) Define ¶
func (s *SymbolTable) Define(text string, value int)
func (*SymbolTable) GetSymbol ¶
func (s *SymbolTable) GetSymbol(text string) *Symbol
type TokenReader ¶
type TokenType ¶
type TokenType int
const ( TokNone TokenType = iota TokEOF TokIdent TokInt TokChar TokString TokDot TokColon TokHash TokStar TokComma TokPlus TokMinus TokPipe TokCaret TokSlash TokPercent TokLeftShift TokRightShift TokLeftParen TokRightParen TokLeftBracket TokRightBracket TokEquals TokOrg TokDw TokDb TokDs TokLocal TokAdd TokSub TokMul TokDiv TokCmp TokAnd TokOr TokXor TokCpy TokPsh TokPop TokJmp TokJeq TokJne TokJge TokJlt TokInc TokDec TokJsr TokRet TokClc TokSec TokClb TokSeb TokJcc TokJcs TokSav TokRst TokHlt TokFunction TokImport TokVar TokComment TokEOL )
type VarStatement ¶
type VarStatement struct { Node // contains filtered or unexported fields }