expressions

package
v0.0.0-...-e98e1b7 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assgin

type Assgin struct {
	Token Token
	Value Experssion
}

has variable being assigned to, and an expression for the new value

func (Assgin) Accept

func (a Assgin) Accept(visitor ExpressionVisitor) (interface{}, error)

type Binary

type Binary struct {
	Experssion
	Left     Experssion
	Right    Experssion
	Operator Token
}

func (Binary) Accept

func (b Binary) Accept(visitor ExpressionVisitor) (interface{}, error)

type Call

type Call struct {
	Callee  Experssion
	Parenth Token
	Args    []Experssion
}

stores the callee expression and a list of expressions for the arguments. It also stores the token for the closing parenthesis. it use that token’s location when it report a runtime error caused by a function call.

func (Call) Accept

func (c Call) Accept(visitor ExpressionVisitor) (interface{}, error)

type Experssion

type Experssion interface {
	Accept(ExpressionVisitor) (interface{}, error)
}

type ExpressionVisitor

type ExpressionVisitor interface {
	VisitBinary(Binary) (interface{}, error)
	VisitGrouping(Grouping) (interface{}, error)
	VisitLiteral(Literal) (interface{}, error)
	VisitUnary(Unary) (interface{}, error)
	VisitVairable(Variable) (interface{}, error)
	VisitAssgin(Assgin) (interface{}, error)
	VisitLogical(Logical) (interface{}, error)
	VisitCall(Call) (interface{}, error)
	VisitPropertyAccess(PropertyAccess) (interface{}, error)
	VisitPropertyAssignment(PropertyAssignment) (interface{}, error)
	VisitThis(This) (interface{}, error)
	VisitSuper(Super) (interface{}, error)
}

type Grouping

type Grouping struct {
	Expr Experssion
}

func (Grouping) Accept

func (g Grouping) Accept(visitor ExpressionVisitor) (interface{}, error)

type Literal

type Literal struct {
	Experssion
	Value interface{}
}

func (Literal) Accept

func (l Literal) Accept(visitor ExpressionVisitor) (interface{}, error)

type Logical

type Logical struct {
	Left     Experssion
	Right    Experssion
	Operator Token
}

represent 'and', 'or' operators

func (Logical) Accept

func (l Logical) Accept(visitor ExpressionVisitor) (interface{}, error)

type PropertyAccess

type PropertyAccess struct {
	Name Token
	Obj  Experssion
}

func (PropertyAccess) Accept

func (p PropertyAccess) Accept(visitor ExpressionVisitor) (interface{}, error)

type PropertyAssignment

type PropertyAssignment struct {
	Name  Token
	Obj   Experssion
	Value Experssion
}

func (PropertyAssignment) Accept

func (p PropertyAssignment) Accept(visitor ExpressionVisitor) (interface{}, error)

type Super

type Super struct {
	Keyword Token
	Method  Token
}

func (Super) Accept

func (s Super) Accept(visitor ExpressionVisitor) (interface{}, error)

type This

type This struct {
	Keywork Token
}

func (This) Accept

func (t This) Accept(visitor ExpressionVisitor) (interface{}, error)

type Token

type Token struct {
	Kind    TokenType
	Lexeme  string
	Literal Literal
	Line    int
}

func (Token) String

func (tok Token) String() string

type TokenType

type TokenType int

type Unary

type Unary struct {
	Experssion
	Right    Experssion
	Operator Token
}

func (Unary) Accept

func (u Unary) Accept(visitor ExpressionVisitor) (interface{}, error)

type Variable

type Variable struct {
	Token Token
	Uuid  int
}

wrapper around the token for the variable name

func (Variable) Accept

func (v Variable) Accept(visitor ExpressionVisitor) (interface{}, error)

Jump to

Keyboard shortcuts

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