Documentation
¶
Index ¶
- func ExpToString(e Exp) string
- func FactorToString(f Factor) string
- type AddExp
- type BaseExp
- type BaseFactor
- type BaseStatement
- type CharFactor
- type ConfigStmt
- type ConfigType
- type DataType
- type DeclareStmt
- type Env
- type Exp
- type ExportSymStmt
- type ExternSymStmt
- type Factor
- type HexFactor
- type IdentFactor
- type ImmExp
- type JumpType
- type LabelStmt
- type MemoryAddrExp
- type MnemonicStmt
- type MultExp
- type Node
- type NumberExp
- type NumberFactor
- type OpcodeStmt
- type Prog
- type Program
- type SegmentExp
- type Statement
- type StringFactor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpToString ¶
func FactorToString ¶
Types ¶
type AddExp ¶
func (*AddExp) TokenLiteral ¶
type BaseFactor ¶
type BaseFactor struct{}
func (BaseFactor) Type ¶
func (b BaseFactor) Type() string
type BaseStatement ¶
type BaseStatement struct{}
func (BaseStatement) Type ¶
func (b BaseStatement) Type() string
type CharFactor ¶
type CharFactor struct {
BaseFactor
Value string
}
func NewCharFactor ¶
func NewCharFactor(baseFactor BaseFactor, value string) *CharFactor
NewCharFactor Create a new CharFactor
func (CharFactor) TokenLiteral ¶
func (c CharFactor) TokenLiteral() string
type ConfigStmt ¶
type ConfigStmt struct {
BaseStatement
ConfigType ConfigType
Factor Factor
}
func NewConfigStmt ¶
func NewConfigStmt(baseStatement BaseStatement, configType ConfigType, factor Factor) *ConfigStmt
NewConfigStmt Create a new ConfigStmt
func (ConfigStmt) TokenLiteral ¶
func (c ConfigStmt) TokenLiteral() string
type ConfigType ¶
type ConfigType string
TODO: go generateで作成できないか
const ( Bits ConfigType = "BITS" InstrSet ConfigType = "INSTRSET" Optimize ConfigType = "OPTIMIZE" Format ConfigType = "FORMAT" Padding ConfigType = "PADDING" PadSet ConfigType = "PADSET" Section ConfigType = "SECTION" Absolute ConfigType = "ABSOLUTE" File ConfigType = "FILE" )
func NewConfigType ¶
func NewConfigType(s string) (ConfigType, bool)
type DeclareStmt ¶
type DeclareStmt struct {
BaseStatement
Id *IdentFactor
Value Exp // interfaceはポインタにしない
}
func NewDeclareStmt ¶
func NewDeclareStmt(baseStatement BaseStatement, id *IdentFactor, value Exp) *DeclareStmt
NewDeclareStmt Create a new DeclareStmt
func (DeclareStmt) TokenLiteral ¶
func (d DeclareStmt) TokenLiteral() string
type Env ¶
type Env interface {
LookupMacro(name string) (Exp, bool)
// GetLOC は '$' 評価に必要な現在のロケーションカウンタ値を返します。
GetLOC() int32
// GetConstValue は、式が定数である場合に整数値を抽出します。
// これは通常、環境 (例: Pass1) によって実装されます。
GetConstValue(exp Exp) (int, bool)
}
Env は評価中に必要な環境のインターフェースを定義します。 マクロやその他の定義を検索するメソッドを提供します。
type Exp ¶
type Exp interface {
Node
Type() string
// Eval は指定された環境内で式を評価します。
// 評価/簡約された式と、評価が簡約をもたらしたかどうか (true)
// そうでないか (false) を示すブール値を返します。
// 評価が不可能な場合 (例: 未解決の識別子を含む)、
// 元の式ノードと false を返す必要があります。
Eval(env Env) (Exp, bool)
// contains filtered or unexported methods
}
Exp は AST 内の式ノードを表します。
type ExportSymStmt ¶
type ExportSymStmt struct {
BaseStatement
Symbols []*IdentFactor
}
func NewExportSymStmt ¶
func NewExportSymStmt(baseStatement BaseStatement, symbols []*IdentFactor) *ExportSymStmt
NewExportSymStmt Create a new ExportSymStmt
func (ExportSymStmt) TokenLiteral ¶
func (es ExportSymStmt) TokenLiteral() string
type ExternSymStmt ¶
type ExternSymStmt struct {
BaseStatement
Symbols []*IdentFactor
}
func NewExternSymStmt ¶
func NewExternSymStmt(baseStatement BaseStatement, symbols []*IdentFactor) *ExternSymStmt
NewExternSymStmt Create a new ExternSymStmt
func (ExternSymStmt) TokenLiteral ¶
func (es ExternSymStmt) TokenLiteral() string
type HexFactor ¶
type HexFactor struct {
BaseFactor
Value string
}
func NewHexFactor ¶
func NewHexFactor(baseFactor BaseFactor, value string) *HexFactor
NewHexFactor Create a new HexFactor
func (HexFactor) TokenLiteral ¶
type IdentFactor ¶
type IdentFactor struct {
BaseFactor
Value string
}
func NewIdentFactor ¶
func NewIdentFactor(baseFactor BaseFactor, value string) *IdentFactor
NewIdentFactor Create a new IdentFactor
func (IdentFactor) TokenLiteral ¶
func (i IdentFactor) TokenLiteral() string
type LabelStmt ¶
type LabelStmt struct {
BaseStatement
Label *IdentFactor
}
func NewLabelStmt ¶
func NewLabelStmt(baseStatement BaseStatement, label *IdentFactor) *LabelStmt
NewLabelStmt Create a new LabelStmt
func (LabelStmt) TokenLiteral ¶
type MemoryAddrExp ¶
type MemoryAddrExp struct {
BaseExp
DataType DataType
JumpType JumpType
Left *AddExp
Right *AddExp // nullable (nil許容)
}
func NewMemoryAddrExp ¶
func NewMemoryAddrExp(baseExp BaseExp, dataType DataType, jumpType JumpType, left *AddExp, right *AddExp) *MemoryAddrExp
NewMemoryAddrExp Create a new MemoryAddrExp
func (*MemoryAddrExp) TokenLiteral ¶
func (m *MemoryAddrExp) TokenLiteral() string
type MnemonicStmt ¶
type MnemonicStmt struct {
BaseStatement
Opcode *IdentFactor
Operands []Exp
}
func NewMnemonicStmt ¶
func NewMnemonicStmt(baseStatement BaseStatement, opcode *IdentFactor, operands []Exp) *MnemonicStmt
NewMnemonicStmt Create a new MnemonicStmt
func (MnemonicStmt) TokenLiteral ¶
func (ms MnemonicStmt) TokenLiteral() string
type MultExp ¶
type MultExp struct {
BaseExp
HeadExp Exp // Exp インターフェースに戻しました
Operators []string
TailExps []Exp // Exp インターフェースに戻しました
}
func NewMultExp ¶
NewMultExp Create a new MultExp
func (*MultExp) TokenLiteral ¶
type NumberExp ¶
NumberExp は完全に評価された数値定数式を表します。
func NewNumberExp ¶
NewNumberExp は新しい NumberExp を作成します。
func (*NumberExp) TokenLiteral ¶
TokenLiteral は数値の文字列表現を返します。
type NumberFactor ¶
type NumberFactor struct {
BaseFactor
Value int
}
func NewNumberFactor ¶
func NewNumberFactor(baseFactor BaseFactor, value int) *NumberFactor
NewNumberFactor Create a new NumberFactor
func (NumberFactor) TokenLiteral ¶
func (n NumberFactor) TokenLiteral() string
type OpcodeStmt ¶
type OpcodeStmt struct {
BaseStatement
Opcode *IdentFactor
}
func NewOpcodeStmt ¶
func NewOpcodeStmt(baseStatement BaseStatement, opcode *IdentFactor) *OpcodeStmt
NewOpcodeStmt Create a new OpcodeStmt
func (OpcodeStmt) TokenLiteral ¶
func (os OpcodeStmt) TokenLiteral() string
type SegmentExp ¶
func NewSegmentExp ¶
func NewSegmentExp(baseExp BaseExp, dataType DataType, left *AddExp, right *AddExp) *SegmentExp
NewSegmentExp Create a new SegmentExp
func (*SegmentExp) TokenLiteral ¶
func (s *SegmentExp) TokenLiteral() string
type StringFactor ¶
type StringFactor struct {
BaseFactor
Value string
}
func NewStringFactor ¶
func NewStringFactor(baseFactor BaseFactor, value string) *StringFactor
NewStringFactor Create a new StringFactor
func (StringFactor) TokenLiteral ¶
func (s StringFactor) TokenLiteral() string