parser

package
v1.0.1-0...-764e6f0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(s string) ([]byte, error)

func Lookup

func Lookup(t interface{}, v string) (ret interface{})

Lookup type t by string v, will upper case v.

Return nil if not found

Types

type Assembler

type Assembler struct {
	Lines   []Assembly
	Symbols map[string]*Symbol
	Labels  map[string]int
}

func (*Assembler) Assemble

func (asm *Assembler) Assemble() ([]byte, error)

type Assembly

type Assembly interface {
	SetComment(string)
	GetComment() string

	// Len Byte code length of this asm
	Len() int
	// Assembly To assembly string
	Assembly() string
}

func Parse

func Parse(s string) ([]Assembly, error)

func ParseLine

func ParseLine(s string) (Assembly, error)

type BBAsm

type BBAsm struct {
	Buffer string

	Parse  func(rule ...int) error
	Reset  func()
	Pretty bool
	// contains filtered or unexported fields
}

func NewParser

func NewParser(s string) *BBAsm

func (*BBAsm) AST

func (t *BBAsm) AST() *node32

func (*BBAsm) Add

func (t *BBAsm) Add(rule pegRule, begin, end, depth uint32, index int)

func (*BBAsm) AddAssembly

func (p *BBAsm) AddAssembly() Assembly

func (*BBAsm) AddComment

func (p *BBAsm) AddComment()

func (*BBAsm) AddInteger

func (p *BBAsm) AddInteger()

func (*BBAsm) AddOperand

func (p *BBAsm) AddOperand(direct bool)

func (*BBAsm) AddPseudoDataValue

func (p *BBAsm) AddPseudoDataValue()

func (*BBAsm) Error

func (t *BBAsm) Error() []token32

func (*BBAsm) Execute

func (p *BBAsm) Execute()

func (*BBAsm) Expand

func (t *BBAsm) Expand(index int)

func (*BBAsm) Highlighter

func (p *BBAsm) Highlighter()

func (*BBAsm) Init

func (p *BBAsm) Init()

func (*BBAsm) Order

func (t *BBAsm) Order() [][]token32

func (*BBAsm) Pop

func (p *BBAsm) Pop() interface{}

func (*BBAsm) PreOrder

func (t *BBAsm) PreOrder() (<-chan state32, [][]token32)

func (*BBAsm) Print

func (t *BBAsm) Print()

func (*BBAsm) PrintSyntax

func (t *BBAsm) PrintSyntax()

func (*BBAsm) PrintSyntaxTree

func (p *BBAsm) PrintSyntaxTree()

func (*BBAsm) Push

func (p *BBAsm) Push(v interface{})

func (*BBAsm) PushInst

func (p *BBAsm) PushInst(op bbasm.Opcode)

func (*BBAsm) Tokens

func (t *BBAsm) Tokens() <-chan token32

type Comment

type Comment struct {
	Content string
	Line    int
}

func (*Comment) Assembly

func (a *Comment) Assembly() string

func (*Comment) GetComment

func (a *Comment) GetComment() string

func (*Comment) Len

func (*Comment) Len() int

func (*Comment) SetComment

func (a *Comment) SetComment(v string)

type Label

type Label struct {
	Name string

	Line    int
	Comment string
}

func (*Label) Assembly

func (a *Label) Assembly() string

func (*Label) GetComment

func (a *Label) GetComment() string

func (*Label) Len

func (a *Label) Len() int

func (*Label) SetComment

func (a *Label) SetComment(v string)

type PseudoBlock

type PseudoBlock struct {
	Size int
	Byte byte

	Line    int
	Comment string
}

func (PseudoBlock) Assembly

func (a PseudoBlock) Assembly() string

func (*PseudoBlock) GetComment

func (a *PseudoBlock) GetComment() string

func (*PseudoBlock) Len

func (a *PseudoBlock) Len() int

func (*PseudoBlock) MarshalBinary

func (a *PseudoBlock) MarshalBinary() (data []byte, err error)

func (*PseudoBlock) SetComment

func (a *PseudoBlock) SetComment(v string)

type PseudoData

type PseudoData struct {
	Label  string
	Values []PseudoDataValue

	Line    int
	Comment string
}

func (PseudoData) Assembly

func (a PseudoData) Assembly() string

func (*PseudoData) GetComment

func (a *PseudoData) GetComment() string

func (*PseudoData) Len

func (a *PseudoData) Len() int

func (PseudoData) MarshalBinary

func (a PseudoData) MarshalBinary() (data []byte, err error)

func (*PseudoData) SetComment

func (a *PseudoData) SetComment(v string)

type PseudoDataValue

type PseudoDataValue interface {
	encoding.BinaryMarshaler
	Len() int         // Byte length
	Assembly() string // Assembly represent
}

type Symbol

type Symbol struct {
	Name      string
	Address   int
	Reference []func(int) // Referenced this symbol's address
}

Symbol represent a label of a location

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL