parser

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Add

type Add struct {
	Source *Param `yaml:"source" parser:"@@"`
}

type Instruction

type Instruction struct {
	SimpleOp *SimpleOp `yaml:"simpleOp,omitempty" parser:"( @('NOP'|'SWP'|'SAV'|'NEG')"`
	Add      *Add      `yaml:"add,omitempty" parser:"| 'ADD' @@"`
	Mov      *Mov      `yaml:"mov,omitempty" parser:"| 'MOV' @@"`
	Jmp      *Jmp      `yaml:"jmp,omitempty" parser:"| 'JMP' @@"`
	Jez      *Jez      `yaml:"jez,omitempty" parser:"| 'JEZ' @@"`
	Jnz      *Jnz      `yaml:"jnz,omitempty" parser:"| 'JNZ' @@"`
	Jgz      *Jgz      `yaml:"jgz,omitempty" parser:"| 'JGZ' @@"`
	Jlz      *Jlz      `yaml:"jlz,omitempty" parser:"| 'JLZ' @@"`
	Jro      *Jro      `yaml:"jro,omitempty" parser:"| 'JRO' @@"`
	Sub      *Sub      `yaml:"sub,omitempty" parser:"| 'SUB' @@"`
	Label    string    `yaml:"label,omitempty" parser:"| @(Ident) Colon)"`
}

type Jez

type Jez struct {
	Label string `yaml:"label" parser:"@Ident"`
}

type Jgz

type Jgz struct {
	Label string `yaml:"label" parser:"@Ident"`
}

type Jlz

type Jlz struct {
	Label string `yaml:"label" parser:"@Ident"`
}

type Jmp

type Jmp struct {
	Label string `yaml:"label" parser:"@Ident"`
}

type Jnz

type Jnz struct {
	Label string `yaml:"label" parser:"@Ident"`
}

type Jro

type Jro struct {
	Source *Param `yaml:"source" parser:"@@"`
}

type Mov

type Mov struct {
	Source      *Param `yaml:"source" parser:"@@ ParamSep"`
	Destination *Param `yaml:"destination" parser:"@@"`
}

type Param

type Param struct {
	Register *Register `yaml:"register,omitempty" parser:"( @('ACC'|'BAK'|'NIL'|'LEFT'|'UP'|'RIGHT'|'DOWN'|'ANY'|'LAST') |"`
	Literal  *int      `yaml:"literal,omitempty" parser:"@Literal |"`
	Label    *string   `yaml:"label,omitempty" parser:"@Ident )"`
}

type Program

type Program struct {
	Instructions []*Instruction `yaml:"instructions" parser:"@@*"`
}

func Parse

func Parse(r io.Reader, name string) (*Program, error)

type Register

type Register string
const (
	RegisterAcc   Register = "ACC"
	RegisterBak   Register = "BAK"
	RegisterNil   Register = "NIL"
	RegisterLeft  Register = "LEFT"
	RegisterUp    Register = "UP"
	RegisterRight Register = "RIGHT"
	RegisterDown  Register = "DOWN"
	RegisterAny   Register = "ANY"
	RegisterLast  Register = "LAST"
)

type SimpleOp

type SimpleOp string
const (
	OpNop SimpleOp = "NOP"
	OpSwp SimpleOp = "SWP"
	OpSav SimpleOp = "SAV"
	OpNeg SimpleOp = "NEG"
)

type Sub

type Sub struct {
	Source *Param `yaml:"source" parser:"@@"`
}

Jump to

Keyboard shortcuts

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