ast

package
v0.0.0-...-a432ce2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssignmentExpr

type AssignmentExpr struct {
	Name  token.Token
	Value Expr
}

func (*AssignmentExpr) Accept

func (a *AssignmentExpr) Accept(visitor ExprVisitor) (any, error)

type BinaryExpr

type BinaryExpr struct {
	Left     Expr
	Operator token.Token
	Right    Expr
}

func (*BinaryExpr) Accept

func (b *BinaryExpr) Accept(visitor ExprVisitor) (any, error)

type BlockStmt

type BlockStmt struct {
	Statements []Stmt
}

func (*BlockStmt) Accept

func (b *BlockStmt) Accept(visitor StmtVisitor) (any, error)

type CallExpr

type CallExpr struct {
	Callee    Expr
	Paren     token.Token
	Arguments []Expr
}

func (*CallExpr) Accept

func (c *CallExpr) Accept(visitor ExprVisitor) (any, error)

type ClassStmt

type ClassStmt struct {
	Name       token.Token
	SuperClass *VariableExpr
	Methods    []*FunctionStmt
}

func (*ClassStmt) Accept

func (c *ClassStmt) Accept(visitor StmtVisitor) (any, error)

type Expr

type Expr interface {
	Accept(ExprVisitor) (any, error)
}

type ExprVisitor

type ExprVisitor interface {
	VisitBinaryExpr(*BinaryExpr) (any, error)
	VisitLogicalExpr(*LogicalExpr) (any, error)
	VisitGroupingExpr(*GroupingExpr) (any, error)
	VisitLiteralExpr(*LiteralExpr) (any, error)
	VisitUnaryExpr(*UnaryExpr) (any, error)
	VisitCallExpr(*CallExpr) (any, error)
	VisitGetExpr(*GetExpr) (any, error)
	VisitSetExpr(*SetExpr) (any, error)
	VisitSuperExpr(*SuperExpr) (any, error)
	VisitThisExpr(*ThisExpr) (any, error)
	VisitVariableExpr(*VariableExpr) (any, error)
	VisitAssignmentExpr(*AssignmentExpr) (any, error)
}

type ExpressionStmt

type ExpressionStmt struct {
	Expression Expr
}

func (*ExpressionStmt) Accept

func (e *ExpressionStmt) Accept(visitor StmtVisitor) (any, error)

type FunctionStmt

type FunctionStmt struct {
	Name       token.Token
	Parameters []token.Token
	Body       []Stmt
}

func (*FunctionStmt) Accept

func (f *FunctionStmt) Accept(visitor StmtVisitor) (any, error)

type GetExpr

type GetExpr struct {
	Object Expr
	Name   token.Token
}

func (*GetExpr) Accept

func (g *GetExpr) Accept(visitor ExprVisitor) (any, error)

type GroupingExpr

type GroupingExpr struct {
	Expression Expr
}

func (*GroupingExpr) Accept

func (g *GroupingExpr) Accept(visitor ExprVisitor) (any, error)

type IfStmt

type IfStmt struct {
	Condition  Expr
	ThenBranch Stmt
	ElseBranch Stmt
}

func (*IfStmt) Accept

func (i *IfStmt) Accept(visitor StmtVisitor) (any, error)

type LiteralExpr

type LiteralExpr struct {
	Value any
}

func (*LiteralExpr) Accept

func (l *LiteralExpr) Accept(visitor ExprVisitor) (any, error)

type LogicalExpr

type LogicalExpr struct {
	Left     Expr
	Operator token.Token
	Right    Expr
}

func (*LogicalExpr) Accept

func (l *LogicalExpr) Accept(visitor ExprVisitor) (any, error)

type PrintStmt

type PrintStmt struct {
	Expression Expr
}

func (*PrintStmt) Accept

func (p *PrintStmt) Accept(visitor StmtVisitor) (any, error)

type Printer

type Printer struct{}

func NewPrinter

func NewPrinter() Printer

func (Printer) Print

func (p Printer) Print(expr Expr) (string, error)

func (Printer) VisitAssignmentExpr

func (p Printer) VisitAssignmentExpr(expr *AssignmentExpr) (any, error)

func (Printer) VisitBinaryExpr

func (p Printer) VisitBinaryExpr(expr *BinaryExpr) (any, error)

func (Printer) VisitCallExpr

func (p Printer) VisitCallExpr(expr *CallExpr) (any, error)

func (Printer) VisitGetExpr

func (p Printer) VisitGetExpr(expr *GetExpr) (any, error)

func (Printer) VisitGroupingExpr

func (p Printer) VisitGroupingExpr(expr *GroupingExpr) (any, error)

func (Printer) VisitLiteralExpr

func (p Printer) VisitLiteralExpr(expr *LiteralExpr) (any, error)

func (Printer) VisitLogicalExpr

func (p Printer) VisitLogicalExpr(expr *LogicalExpr) (any, error)

func (Printer) VisitSetExpr

func (p Printer) VisitSetExpr(expr *SetExpr) (any, error)

func (Printer) VisitSuperExpr

func (p Printer) VisitSuperExpr(expr *SuperExpr) (any, error)

func (Printer) VisitThisExpr

func (p Printer) VisitThisExpr(expr *ThisExpr) (any, error)

func (Printer) VisitUnaryExpr

func (p Printer) VisitUnaryExpr(expr *UnaryExpr) (any, error)

func (Printer) VisitVariableExpr

func (p Printer) VisitVariableExpr(expr *VariableExpr) (any, error)

type ReturnStmt

type ReturnStmt struct {
	Keyword token.Token
	Value   Expr
}

func (*ReturnStmt) Accept

func (r *ReturnStmt) Accept(visitor StmtVisitor) (any, error)

type SetExpr

type SetExpr struct {
	Object Expr
	Name   token.Token
	Value  Expr
}

func (*SetExpr) Accept

func (s *SetExpr) Accept(visitor ExprVisitor) (any, error)

type Stmt

type Stmt interface {
	Accept(StmtVisitor) (any, error)
}

type StmtVisitor

type StmtVisitor interface {
	VisitBlockStmt(*BlockStmt) (any, error)
	VisitClassStmt(*ClassStmt) (any, error)
	VisitExpressionStmt(*ExpressionStmt) (any, error)
	VisitWhileStmt(*WhileStmt) (any, error)
	VisitIfStmt(*IfStmt) (any, error)
	VisitPrintStmt(*PrintStmt) (any, error)
	VisitReturnStmt(*ReturnStmt) (any, error)
	VisitVarStmt(*VarStmt) (any, error)
	VisitFunctionStmt(*FunctionStmt) (any, error)
}

type SuperExpr

type SuperExpr struct {
	Keyword token.Token
	Method  token.Token
}

func (*SuperExpr) Accept

func (s *SuperExpr) Accept(visitor ExprVisitor) (any, error)

type ThisExpr

type ThisExpr struct {
	Keyword token.Token
}

func (*ThisExpr) Accept

func (t *ThisExpr) Accept(visitor ExprVisitor) (any, error)

type UnaryExpr

type UnaryExpr struct {
	Operator token.Token
	Right    Expr
}

func (*UnaryExpr) Accept

func (u *UnaryExpr) Accept(visitor ExprVisitor) (any, error)

type VarStmt

type VarStmt struct {
	Name        token.Token
	Initializer Expr
}

func (*VarStmt) Accept

func (v *VarStmt) Accept(visitor StmtVisitor) (any, error)

type VariableExpr

type VariableExpr struct {
	Name token.Token
}

func (*VariableExpr) Accept

func (v *VariableExpr) Accept(visitor ExprVisitor) (any, error)

type WhileStmt

type WhileStmt struct {
	Condition Expr
	Body      Stmt
}

func (*WhileStmt) Accept

func (w *WhileStmt) Accept(visitor StmtVisitor) (any, error)

Jump to

Keyboard shortcuts

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