Documentation
¶
Index ¶
- Constants
- func ErrLabelAlreadyDef(firstDef, secondDef *LabelDefSt) error
- func IsGlobal(name string) bool
- type ArithExpr
- type ArithOp
- type AssembleSt
- type BytesSt
- type Document
- func (doc *Document) CreationString() string
- func (doc *Document) GlobalExprMacros() []*ExpressionMacroDef
- func (doc *Document) GlobalInstrMacros() []*InstructionMacroDef
- func (doc *Document) GlobalLabels() []*LabelDefSt
- func (doc *Document) InstrMacros() []*InstructionMacroDef
- func (doc *Document) LookupExprMacro(name string) (*ExpressionMacroDef, *Document)
- func (doc *Document) LookupInstrMacro(name string) (*InstructionMacroDef, *Document)
- func (doc *Document) LookupLabel(lref *LabelRefExpr) (*LabelDefSt, *Document)
- type Expr
- type ExpressionMacroDef
- type IncludeSt
- type InstructionMacroDef
- type LabelDefSt
- type LabelRefExpr
- type LiteralExpr
- type MacroCallExpr
- type MacroCallSt
- type OpcodeSt
- type ParseError
- type Parser
- type Position
- type PragmaSt
- type Statement
- type UnaryArithExpr
- type VariableExpr
Constants ¶
const ( ArithPlus = ArithOp(iota + 1) // + ArithMinus // - ArithMul // * ArithDiv // / ArithMod // % ArithLshift // << ArithRshift // >> ArithAnd // & ArithOr // | ArithXor // ^ ArithMax = ArithXor )
Variables ¶
This section is empty.
Functions ¶
func ErrLabelAlreadyDef ¶
func ErrLabelAlreadyDef(firstDef, secondDef *LabelDefSt) error
Types ¶
type AssembleSt ¶
toplevel statement types
func (*AssembleSt) Description ¶
func (inst *AssembleSt) Description() string
func (*AssembleSt) Position ¶
func (inst *AssembleSt) Position() Position
type BytesSt ¶ added in v0.3.0
type BytesSt struct {
Value Expr
Label *LabelDefSt
// contains filtered or unexported fields
}
toplevel statement types
func (*BytesSt) Description ¶ added in v0.3.0
type Document ¶
type Document struct {
File string
Statements []Statement
// The document that contains/encloses this document.
Parent *Document
// The statement that created this document.
// This is filled in for instruction macros, #include/#assemble, etc.
Creation Statement
// contains filtered or unexported fields
}
Document is the toplevel of the AST. It represents a list of abstract instructions and macro definitions.
func (*Document) CreationString ¶
func (*Document) GlobalExprMacros ¶
func (doc *Document) GlobalExprMacros() []*ExpressionMacroDef
GlobalExprMacros returns the list of global expression macro definitions in the docment.
func (*Document) GlobalInstrMacros ¶
func (doc *Document) GlobalInstrMacros() []*InstructionMacroDef
GlobalInstrMacros returns the list of global instruction macro definitions in the docment.
func (*Document) GlobalLabels ¶
func (doc *Document) GlobalLabels() []*LabelDefSt
GlobalLabels returns the list of global label definitions in the docment.
func (*Document) InstrMacros ¶
func (doc *Document) InstrMacros() []*InstructionMacroDef
InstrMacros returns the list of all instruction macro definitions in the docment.
func (*Document) LookupExprMacro ¶
func (doc *Document) LookupExprMacro(name string) (*ExpressionMacroDef, *Document)
LookupExprMacro finds the definition of an expression macro.
func (*Document) LookupInstrMacro ¶
func (doc *Document) LookupInstrMacro(name string) (*InstructionMacroDef, *Document)
LookupInstrMacro finds the definition of an instruction macro.
func (*Document) LookupLabel ¶
func (doc *Document) LookupLabel(lref *LabelRefExpr) (*LabelDefSt, *Document)
LookupLabel finds the definition of a label.
type ExpressionMacroDef ¶
type ExpressionMacroDef struct {
Name string
Params []string
Body Expr
// contains filtered or unexported fields
}
definitions
func (*ExpressionMacroDef) Description ¶
func (def *ExpressionMacroDef) Description() string
func (*ExpressionMacroDef) Position ¶
func (def *ExpressionMacroDef) Position() Position
type InstructionMacroDef ¶
type InstructionMacroDef struct {
Name string
Params []string
Body *Document
// contains filtered or unexported fields
}
definitions
func (*InstructionMacroDef) Description ¶
func (def *InstructionMacroDef) Description() string
func (*InstructionMacroDef) Position ¶
func (def *InstructionMacroDef) Position() Position
type LabelDefSt ¶
type LabelDefSt struct {
Src *Document
Dotted bool
Global bool
// contains filtered or unexported fields
}
toplevel statement types
func (*LabelDefSt) Description ¶
func (inst *LabelDefSt) Description() string
func (*LabelDefSt) Name ¶
func (l *LabelDefSt) Name() string
func (*LabelDefSt) Position ¶
func (inst *LabelDefSt) Position() Position
func (*LabelDefSt) String ¶
func (l *LabelDefSt) String() string
type LabelRefExpr ¶
type LabelRefExpr struct {
Ident string
Dotted bool
Global bool
// contains filtered or unexported fields
}
expression types
func (*LabelRefExpr) Position ¶ added in v0.3.0
func (l *LabelRefExpr) Position() Position
func (*LabelRefExpr) String ¶
func (l *LabelRefExpr) String() string
type LiteralExpr ¶
type LiteralExpr struct {
// contains filtered or unexported fields
}
expression types
func MakeNumber ¶ added in v0.3.0
func MakeNumber(v *lzint.Value) *LiteralExpr
MakeNumber creates a number literal with the given value.
func MakeString ¶ added in v0.3.0
func MakeString(v string) *LiteralExpr
MakeString creates a string literal with the given value.
func (*LiteralExpr) Position ¶ added in v0.3.0
func (l *LiteralExpr) Position() Position
func (*LiteralExpr) Text ¶
func (e *LiteralExpr) Text() string
Text returns the text content of the literal as-written. Note this does not include the quotes for string literals.
func (*LiteralExpr) Value ¶
func (e *LiteralExpr) Value() *lzint.Value
Value returns the parsed value of the literal.
type MacroCallExpr ¶
type MacroCallExpr struct {
Ident string
Builtin bool
Args []Expr
// contains filtered or unexported fields
}
expression types
func (*MacroCallExpr) Position ¶ added in v0.3.0
func (e *MacroCallExpr) Position() Position
type MacroCallSt ¶
type MacroCallSt struct {
Ident string
Src *Document
Args []Expr
// contains filtered or unexported fields
}
toplevel statement types
func (*MacroCallSt) Description ¶
func (inst *MacroCallSt) Description() string
func (*MacroCallSt) Position ¶
func (inst *MacroCallSt) Position() Position
type OpcodeSt ¶
type OpcodeSt struct {
Op string
Src *Document
Arg Expr // Immediate argument for PUSH* / JUMP*.
PushSize byte // For PUSH<n>, this is n+1.
// contains filtered or unexported fields
}
toplevel statement types
func (*OpcodeSt) Description ¶
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError is an error that happened during parsing.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) IsWarning ¶
func (e *ParseError) IsWarning() bool
func (*ParseError) Position ¶
func (e *ParseError) Position() Position
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser performs parsing of the token stream.
func (*Parser) Parse ¶
func (p *Parser) Parse() (*Document, []*ParseError)
Parse runs the parser, outputting a document.
func (*Parser) ParseExpression ¶
ParseExpression parses the input as a single expression. This is used in evaluator tests.
type UnaryArithExpr ¶ added in v0.3.0
expression types
func (*UnaryArithExpr) Position ¶ added in v0.3.0
func (e *UnaryArithExpr) Position() Position
type VariableExpr ¶
type VariableExpr struct {
Ident string
// contains filtered or unexported fields
}
expression types
func (*VariableExpr) Position ¶ added in v0.3.0
func (e *VariableExpr) Position() Position