parser

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryExpression

type BinaryExpression struct {
	A         Node
	Operation string
	B         Node
}

func (BinaryExpression) GetType

func (b BinaryExpression) GetType() ValueType

type Block

type Block struct {
	Statements []Node
}

type Constant

type Constant struct {
	Value string
	Type  ValueType
}

func (Constant) GetType

func (c Constant) GetType() ValueType

type FunctionDecl

type FunctionDecl struct {
	Type            ValueType
	Name            string
	Body            Block
	SymbolTable     map[string]Symbol
	NextSymbolIndex int
}

func (*FunctionDecl) DefineSymbol

func (f *FunctionDecl) DefineSymbol(name string, typeName ValueType, constant bool) Symbol

func (*FunctionDecl) GetSymbol

func (f *FunctionDecl) GetSymbol(name string) (Symbol, bool)

func (*FunctionDecl) GetVariableCounts

func (f *FunctionDecl) GetVariableCounts() (intCount int, floatCount int)

type Node

type Node interface {
	GetType() ValueType
}

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func New

func New(tokens []lexer.Token) *Parser

func (*Parser) Parse

func (p *Parser) Parse() (Program, error)

type Program

type Program struct {
	Functions []FunctionDecl
}

type ReturnStmt

type ReturnStmt struct {
	Value Node
}

func (ReturnStmt) GetType

func (r ReturnStmt) GetType() ValueType

type Symbol

type Symbol struct {
	Index    int
	Type     ValueType
	Constant bool
}

type UnaryExpression

type UnaryExpression struct {
	Value     Node
	Operation string
}

func (UnaryExpression) GetType

func (u UnaryExpression) GetType() ValueType

type ValueType

type ValueType = string
const (
	TypeInt   ValueType = "int"
	TypeFloat ValueType = "float"
	TypeChar  ValueType = "char"
)

type VariableAccess

type VariableAccess struct {
	Index int
	Type  ValueType
}

func (VariableAccess) GetType

func (v VariableAccess) GetType() ValueType

type VariableDefineStmt

type VariableDefineStmt struct {
	Symbol   Symbol
	Value    Node
	Type     ValueType
	Constant bool
}

func (VariableDefineStmt) GetType

func (v VariableDefineStmt) GetType() ValueType

type VariableUpdateStmt

type VariableUpdateStmt struct {
	Index int
	Value Node
	Type  ValueType
}

func (VariableUpdateStmt) GetType

func (v VariableUpdateStmt) GetType() ValueType

Jump to

Keyboard shortcuts

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