parser

package
v0.0.0-...-0d6e601 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

author: Tristan Hilbert date: 10/02/2023 filename: parser.go desc: Parsing Grammar to Build AST for assembly files of all languages

Currently supporting:
- x86

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAsmParser

func GetAsmParser() (*participle.Parser[Assembly], error)

Types

type Argument

type Argument interface {
	Argument()
	Pos() lexer.Position
}

type Assembly

type Assembly struct {
	Pos lexer.Position

	Terms []Term `@@*`
}

type Decimal

type Decimal struct {
	Position lexer.Position

	Value string `@DECIMAL`
}

func (Decimal) Argument

func (decimal Decimal) Argument()

func (Decimal) Pos

func (decimal Decimal) Pos() lexer.Position

type Expression

type Expression interface {
	Expression()
	Pos() lexer.Position
}

type HexArg

type HexArg struct {
	Position lexer.Position

	Value string `@HEX`
}

func (HexArg) Argument

func (hexArg HexArg) Argument()

func (HexArg) Pos

func (hexArg HexArg) Pos() lexer.Position

type Identifier

type Identifier struct {
	Position lexer.Position

	Value string `@IDENTIFIER (?! LABEL_OP)`
}

func (Identifier) Argument

func (identifier Identifier) Argument()

func (Identifier) Pos

func (identifier Identifier) Pos() lexer.Position

type Instruction

type Instruction struct {
	Position lexer.Position

	Prefix *Label   `@@? (?= IDENTIFIER)`
	Name   string   `@IDENTIFIER (?! LABEL_OP)`
	Args   Argument `@@? (ARG_SEP @@)*`
}

func (Instruction) Pos

func (instruction Instruction) Pos() lexer.Position

func (Instruction) Term

func (instruction Instruction) Term()

type Integer

type Integer struct {
	Position lexer.Position

	Value string `@INTEGER`
}

func (Integer) Argument

func (integer Integer) Argument()

func (Integer) Pos

func (integer Integer) Pos() lexer.Position

type Label

type Label struct {
	Position lexer.Position

	Name string `@IDENTIFIER LABEL_OP`
}

func (Label) Pos

func (label Label) Pos() lexer.Position

func (Label) Term

func (label Label) Term()

type Operator

type Operator struct {
	Position lexer.Position

	Symbol  string   `@OPERATOR`
	Operand Argument `@@`
}

type Section

type Section struct {
	Position lexer.Position

	Name string `"section" SECTION_PREFIX @IDENTIFIER (?! LABEL_OP)`
}

func (Section) Pos

func (section Section) Pos() lexer.Position

func (Section) Term

func (section Section) Term()

type String

type String struct {
	Posotion lexer.Position

	Value string `(@SNGL_QUOTED_VAL | @DBL_QUOTED_VAL)`
}

func (String) Argument

func (str String) Argument()

func (String) Pos

func (str String) Pos() lexer.Position

type SubAddress

type SubAddress struct {
	Position lexer.Position

	Sub        Argument   `SUB_ADDR_BEGIN @@`
	Operations []Operator `@@* SUB_ADDR_END`
}

func (SubAddress) Argument

func (subAddress SubAddress) Argument()

func (SubAddress) Pos

func (subAddress SubAddress) Pos() lexer.Position

type SubExpression

type SubExpression struct {
	Position lexer.Position

	Sub        Argument   `SUB_EXPR_BEGIN @@`
	Operations []Operator `@@* SUB_EXPR_END`
}

func (SubExpression) Argument

func (subExpression SubExpression) Argument()

func (SubExpression) Pos

func (subExpression SubExpression) Pos() lexer.Position

type Term

type Term interface {
	Term()
	Pos() lexer.Position
}

Jump to

Keyboard shortcuts

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