Documentation
¶
Index ¶
- func TestEqualsIsReducable(t *testing.T)
- func TestEqualsReduce(t *testing.T)
- func TestEqualsValue(t *testing.T)
- type AddExpr
- type AndExpr
- type AssignStmt
- type BooleanValue
- type DoNothingStmt
- type Environment
- type EqualsExpr
- type Expression
- type GreaterThanExpr
- type IfStmt
- type LessThanExpr
- type MultiplyExpr
- type NotExpr
- type NumberValue
- type OrExpr
- type SequenceStmt
- type Statement
- type SubtractExpr
- type VariableExpr
- type WhileStmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestEqualsIsReducable ¶
func TestEqualsReduce ¶
func TestEqualsValue ¶
Types ¶
type AddExpr ¶
type AddExpr struct {
// contains filtered or unexported fields
}
Add
func Add ¶
func Add(left Expression, right Expression) *AddExpr
func (AddExpr) IsReducable ¶
func (AddExpr) Reduce ¶
func (a AddExpr) Reduce(env *Environment) Expression
type AndExpr ¶
type AndExpr struct {
// contains filtered or unexported fields
}
And
func And ¶
func And(left Expression, right Expression) *AndExpr
func (AndExpr) Reduce ¶
func (a AndExpr) Reduce(env *Environment) Expression
type AssignStmt ¶
type AssignStmt struct {
// contains filtered or unexported fields
}
func Assign ¶
func Assign(name string, exp Expression) *AssignStmt
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) 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 (IfStmt) Evaluate ¶
func (i IfStmt) Evaluate(env *Environment) *Environment
func (IfStmt) IsReducable ¶
func (IfStmt) Reduce ¶
func (i IfStmt) Reduce(env *Environment) (Statement, *Environment)
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 (NotExpr) Reduce ¶
func (n NotExpr) Reduce(env *Environment) Expression
type NumberValue ¶
type NumberValue struct {
// contains filtered or unexported fields
}
func Number ¶
func Number(i int) *NumberValue
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 (OrExpr) Reduce ¶
func (o OrExpr) Reduce(env *Environment) Expression
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 (WhileStmt) Reduce ¶
func (w WhileStmt) Reduce(env *Environment) (Statement, *Environment)
Click to show internal directories.
Click to hide internal directories.