Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arg ¶
type Arg struct {
Range parser.Range
Label string // empty for positional args; "account", "cap", etc. for labeled
Value Value
}
Arg is a single argument to an instruction.
type Const ¶
type Const struct {
Range parser.Range
Kind ConstKind
// Exactly one is set:
StrVal *string // raw quoted literal
IntVal *string // raw numeric string
BoolVal *bool
}
Const is a constant literal: a string, an integer or a bool.
type Dest ¶
type Dest struct {
Range parser.Range
Kind DestKind
Regs []RegRef // non-empty for DestReg and DestList
}
Dest is the LHS of an assignment.
type InstrCall ¶
type InstrCall struct {
Range parser.Range
Name string // e.g. "mk_monetary", "pull_account"
TypeParam string // "" if none, else "int", "str", etc.
Args []Arg // may be empty
}
InstrCall is a function-call instruction: name(args).
type InstrStmt ¶
type InstrStmt struct {
Range parser.Range
// Dest is the destination; nil when the instruction has no dest (e.g. "set_current_asset($r3)").
Dest *Dest
// One of these is set:
Call *InstrCall // e.g. "mk_monetary($r0, $r1)"
Const *Const // e.g. "$r0 = \"USD/2\"" or "$r0 = 42"
Infix *Infix // e.g. "$r3 = $r1 + $r2"
CompoundAssign *Infix // e.g. "$r5 += $r9" (Left is implicit from Dest)
}
InstrStmt represents one instruction line.
type ParseResult ¶
type ParseResult struct {
Value Program
Errors []ParserError
}
func Parse ¶
func Parse(input string) ParseResult
Parse parses an IR textual program and returns the AST.
type ParserError ¶
ParserError is a parse error with range information.
func (ParserError) Error ¶
func (e ParserError) Error() string
type Stmt ¶
type Stmt interface {
// contains filtered or unexported methods
}
Stmt is either a LabelStmt or an InstrStmt.
type Value ¶
type Value struct {
Range parser.Range
Kind ValueKind
// Exactly one of these is set, depending on Kind:
Reg *RegRef // ValReg
Label *string // ValLabel: the label name without '#'
Int *string // ValInt: raw numeric string
Regs *[]RegRef // ValRegList
}
Value is a value that can appear as an argument.
Click to show internal directories.
Click to hide internal directories.