syntax

package
v0.0.0-...-685f982 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestEqualsIsReducable

func TestEqualsIsReducable(t *testing.T)

func TestEqualsReduce

func TestEqualsReduce(t *testing.T)

func TestEqualsValue

func TestEqualsValue(t *testing.T)

Types

type AddExpr

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

Add

func Add

func Add(left Expression, right Expression) *AddExpr

func (AddExpr) Evaluate

func (a AddExpr) Evaluate(env *Environment) Expression

Add

func (AddExpr) IsReducable

func (a AddExpr) IsReducable() bool

func (AddExpr) Reduce

func (a AddExpr) Reduce(env *Environment) Expression

func (AddExpr) String

func (a AddExpr) String() string

func (AddExpr) Value

func (a AddExpr) Value() any

type AndExpr

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

And

func And

func And(left Expression, right Expression) *AndExpr

func (AndExpr) Evaluate

func (a AndExpr) Evaluate(env *Environment) Expression

And

func (AndExpr) IsReducable

func (a AndExpr) IsReducable() bool

And

func (AndExpr) Reduce

func (a AndExpr) Reduce(env *Environment) Expression

func (AndExpr) String

func (a AndExpr) String() string

func (AndExpr) Value

func (a AndExpr) Value() any

type AssignStmt

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

func Assign

func Assign(name string, exp Expression) *AssignStmt

func (AssignStmt) Evaluate

func (a AssignStmt) Evaluate(env *Environment) *Environment

Assign

func (AssignStmt) IsReducable

func (a AssignStmt) IsReducable() bool

Assign

func (AssignStmt) Reduce

func (a AssignStmt) Reduce(env *Environment) (Statement, *Environment)

func (AssignStmt) String

func (a AssignStmt) String() string

type BooleanValue

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

Boolean

func Boolean

func Boolean(v bool) *BooleanValue

func (BooleanValue) Evaluate

func (b BooleanValue) Evaluate(env *Environment) Expression

Boolean

func (BooleanValue) IsReducable

func (b BooleanValue) IsReducable() bool

Boolean

func (BooleanValue) Reduce

func (b BooleanValue) Reduce(env *Environment) Expression

func (BooleanValue) String

func (b BooleanValue) String() string

func (BooleanValue) Value

func (b BooleanValue) Value() any

type DoNothingStmt

type DoNothingStmt struct {
}

func DoNothing

func DoNothing() *DoNothingStmt

func (DoNothingStmt) Evaluate

func (a DoNothingStmt) Evaluate(env *Environment) *Environment

func (DoNothingStmt) IsReducable

func (a DoNothingStmt) IsReducable() bool

func (DoNothingStmt) Reduce

func (a DoNothingStmt) Reduce(env *Environment) (Statement, *Environment)

func (DoNothingStmt) String

func (a DoNothingStmt) String() string

type Environment

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

func NewEnvironment

func NewEnvironment() *Environment

func (Environment) Add

func (e Environment) Add(name string, exp Expression)

func (Environment) Merge

func (e Environment) Merge(name string, exp Expression) *Environment

func (Environment) String

func (e Environment) String() string

type EqualsExpr

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

func Equals

func Equals(left Expression, right Expression) *EqualsExpr

func (EqualsExpr) Evaluate

func (e EqualsExpr) Evaluate(env *Environment) Expression

func (EqualsExpr) IsReducable

func (e EqualsExpr) IsReducable() bool

func (EqualsExpr) Reduce

func (e EqualsExpr) Reduce(env *Environment) Expression

func (EqualsExpr) String

func (e EqualsExpr) String() string

func (EqualsExpr) Value

func (e EqualsExpr) Value() any

type Expression

type Expression interface {
	IsReducable() bool
	Reduce(env *Environment) Expression
	Value() any
	Evaluate(env *Environment) Expression
}

Interface

type GreaterThanExpr

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

func GreaterThan

func GreaterThan(left Expression, right Expression) *GreaterThanExpr

func (GreaterThanExpr) Evaluate

func (g GreaterThanExpr) Evaluate(env *Environment) Expression

func (GreaterThanExpr) IsReducable

func (g GreaterThanExpr) IsReducable() bool

func (GreaterThanExpr) Reduce

func (g GreaterThanExpr) Reduce(env *Environment) Expression

func (GreaterThanExpr) String

func (g GreaterThanExpr) String() string

func (GreaterThanExpr) Value

func (g GreaterThanExpr) Value() any

type IfStmt

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

func If

func If(cond Expression, cons Statement, alt Statement) *IfStmt

func (IfStmt) Evaluate

func (i IfStmt) Evaluate(env *Environment) *Environment

func (IfStmt) IsReducable

func (a IfStmt) IsReducable() bool

func (IfStmt) Reduce

func (i IfStmt) Reduce(env *Environment) (Statement, *Environment)

func (IfStmt) String

func (i IfStmt) String() string

type LessThanExpr

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

func LessThan

func LessThan(left Expression, right Expression) *LessThanExpr

func (LessThanExpr) Evaluate

func (l LessThanExpr) Evaluate(env *Environment) Expression

func (LessThanExpr) IsReducable

func (l LessThanExpr) IsReducable() bool

func (LessThanExpr) Reduce

func (l LessThanExpr) Reduce(env *Environment) Expression

func (LessThanExpr) String

func (l LessThanExpr) String() string

func (LessThanExpr) Value

func (l LessThanExpr) Value() any

type MultiplyExpr

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

func Multiply

func Multiply(left Expression, right Expression) *MultiplyExpr

func (MultiplyExpr) Evaluate

func (m MultiplyExpr) Evaluate(env *Environment) Expression

func (MultiplyExpr) IsReducable

func (m MultiplyExpr) IsReducable() bool

func (MultiplyExpr) Reduce

func (m MultiplyExpr) Reduce(env *Environment) Expression

func (MultiplyExpr) String

func (m MultiplyExpr) String() string

func (MultiplyExpr) Value

func (m MultiplyExpr) Value() any

type NotExpr

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

func Not

func Not(value Expression) *NotExpr

func (NotExpr) Evaluate

func (n NotExpr) Evaluate(env *Environment) Expression

func (NotExpr) IsReducable

func (n NotExpr) IsReducable() bool

func (NotExpr) Reduce

func (n NotExpr) Reduce(env *Environment) Expression

func (NotExpr) String

func (n NotExpr) String() string

func (NotExpr) Value

func (n NotExpr) Value() any

type NumberValue

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

func Number

func Number(i int) *NumberValue

func (NumberValue) Evaluate

func (n NumberValue) Evaluate(env *Environment) Expression

Number

func (NumberValue) IsReducable

func (n NumberValue) IsReducable() bool

func (NumberValue) Reduce

func (n NumberValue) Reduce(env *Environment) Expression

func (NumberValue) String

func (n NumberValue) String() string

func (NumberValue) Value

func (n NumberValue) Value() any

type OrExpr

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

func Or

func Or(left Expression, right Expression) *OrExpr

func (OrExpr) Evaluate

func (o OrExpr) Evaluate(env *Environment) Expression

func (OrExpr) IsReducable

func (o OrExpr) IsReducable() bool

func (OrExpr) Reduce

func (o OrExpr) Reduce(env *Environment) Expression

func (OrExpr) String

func (o OrExpr) String() string

func (OrExpr) Value

func (o OrExpr) Value() any

type SequenceStmt

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

func Sequence

func Sequence(first Statement, second Statement) *SequenceStmt

func (SequenceStmt) Evaluate

func (s SequenceStmt) Evaluate(env *Environment) *Environment

func (SequenceStmt) IsReducable

func (s SequenceStmt) IsReducable() bool

func (SequenceStmt) Reduce

func (s SequenceStmt) Reduce(env *Environment) (Statement, *Environment)

func (SequenceStmt) String

func (s SequenceStmt) String() string

type Statement

type Statement interface {
	IsReducable() bool
	Reduce(env *Environment) (Statement, *Environment)
	Evaluate(env *Environment) *Environment
}

type SubtractExpr

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

func Subtract

func Subtract(left Expression, right Expression) *SubtractExpr

func (SubtractExpr) Evaluate

func (s SubtractExpr) Evaluate(env *Environment) Expression

func (SubtractExpr) IsReducable

func (s SubtractExpr) IsReducable() bool

func (SubtractExpr) Reduce

func (s SubtractExpr) Reduce(env *Environment) Expression

func (SubtractExpr) String

func (s SubtractExpr) String() string

func (SubtractExpr) Value

func (s SubtractExpr) Value() any

type VariableExpr

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

func Variable

func Variable(name string) *VariableExpr

func (VariableExpr) Evaluate

func (v VariableExpr) Evaluate(env *Environment) Expression

func (VariableExpr) IsReducable

func (v VariableExpr) IsReducable() bool

func (VariableExpr) Reduce

func (v VariableExpr) Reduce(env *Environment) Expression

func (VariableExpr) String

func (v VariableExpr) String() string

func (VariableExpr) Value

func (v VariableExpr) Value() any

type WhileStmt

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

func While

func While(cond Expression, body Statement) *WhileStmt

func (WhileStmt) Evaluate

func (w WhileStmt) Evaluate(env *Environment) *Environment

func (WhileStmt) IsReducable

func (w WhileStmt) IsReducable() bool

func (WhileStmt) Reduce

func (w WhileStmt) Reduce(env *Environment) (Statement, *Environment)

func (WhileStmt) String

func (w WhileStmt) String() string

Jump to

Keyboard shortcuts

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