Documentation
¶
Index ¶
- func NewAssignExpression(name api.IToken, eValue api.IExpression) api.IExpression
- func NewBinaryExpression(left api.IExpression, operator api.IToken, right api.IExpression) api.IExpression
- func NewCallExpression(callee api.IExpression, paren api.IToken, arguments []api.IExpression) api.IExpression
- func NewClockCallable() api.ICallable
- func NewEnvironment() api.IEnvironment
- func NewEnvironmentEnclosing(enclosing api.IEnvironment) api.IEnvironment
- func NewFunctionCallable(declaration api.IStatement, closure api.IEnvironment) api.ICallable
- func NewGroupingExpression(expression api.IExpression) api.IExpression
- func NewInterpreter() api.IInterpreter
- func NewLiteralExpression(name api.IToken, value api.ILiteral) api.IExpression
- func NewLogicExpression(left api.IExpression, operator api.IToken, right api.IExpression) api.IExpression
- func NewUnaryExpression(operator api.IToken, right api.IExpression) api.IExpression
- func NewVariableExpression(name api.IToken) api.IExpression
- type AssignExpression
- type AstPrinter
- type BaseExpression
- func (e *BaseExpression) Arguments() []api.IExpression
- func (e *BaseExpression) Callee() api.IExpression
- func (e *BaseExpression) Expression() api.IExpression
- func (e *BaseExpression) Left() api.IExpression
- func (e *BaseExpression) Name() api.IToken
- func (e *BaseExpression) Operator() api.IToken
- func (e *BaseExpression) Paren() api.IToken
- func (e *BaseExpression) Right() api.IExpression
- func (e *BaseExpression) Type() api.ExpressionType
- func (e *BaseExpression) Value() interface{}
- type BinaryExpression
- func (e *BinaryExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
- func (e *BinaryExpression) Left() api.IExpression
- func (e *BinaryExpression) Operator() api.IToken
- func (e *BinaryExpression) Right() api.IExpression
- func (e *BinaryExpression) Type() api.ExpressionType
- type CallExpression
- func (e *CallExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
- func (e *CallExpression) Arguments() []api.IExpression
- func (e *CallExpression) Callee() api.IExpression
- func (e *CallExpression) Paren() api.IToken
- func (e *CallExpression) Type() api.ExpressionType
- type ClockCallable
- type Environment
- func (e *Environment) Assign(name api.IToken, value interface{}) (err api.IRuntimeError)
- func (e *Environment) AssignAt(distance int, name api.IToken, value interface{}) (err api.IRuntimeError)
- func (e *Environment) Define(name string, obj interface{}) (err api.IRuntimeError)
- func (e *Environment) Enclosing() api.IEnvironment
- func (e *Environment) Get(name api.IToken) (value interface{}, err api.IRuntimeError)
- func (e *Environment) GetAt(distance int, name api.IToken) (obj interface{}, err api.IRuntimeError)
- func (e *Environment) Values() map[string]interface{}
- type FunctionCallable
- type GroupingExpression
- type Interpreter
- func (i *Interpreter) ExecuteBlock(statements []api.IStatement, parentEnv api.IEnvironment) (err api.IRuntimeError)
- func (i *Interpreter) Globals() api.IEnvironment
- func (i *Interpreter) Interpret(statements []api.IStatement) api.IRuntimeError
- func (i *Interpreter) Resolve(expr api.IExpression, depth int) (err api.IRuntimeError)
- func (i *Interpreter) VisitAssignExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
- func (i *Interpreter) VisitBinaryExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
- func (i *Interpreter) VisitBlockStatement(statement api.IStatement) (err api.IRuntimeError)
- func (i *Interpreter) VisitCallExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
- func (i *Interpreter) VisitExpressionStatement(statement api.IStatement) (err api.IRuntimeError)
- func (i *Interpreter) VisitFunctionStatement(statement api.IStatement) (err api.IRuntimeError)
- func (i *Interpreter) VisitGroupingExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
- func (i *Interpreter) VisitIfStatement(statement api.IStatement) (err api.IRuntimeError)
- func (i *Interpreter) VisitInterruptStatement(statement api.IStatement) (err api.IRuntimeError)
- func (i *Interpreter) VisitLiteralExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
- func (i *Interpreter) VisitLogicalExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
- func (i *Interpreter) VisitPrintStatement(statement api.IStatement) (err api.IRuntimeError)
- func (i *Interpreter) VisitReturnStatement(statement api.IStatement) (err api.IRuntimeError)
- func (i *Interpreter) VisitUnaryExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
- func (i *Interpreter) VisitVariableExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
- func (i *Interpreter) VisitVariableStatement(statement api.IStatement) (err api.IRuntimeError)
- func (i *Interpreter) VisitWhileStatement(statement api.IStatement) (err api.IRuntimeError)
- type LiteralExpression
- type LogicExpression
- func (e *LogicExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
- func (e *LogicExpression) Left() api.IExpression
- func (e *LogicExpression) Operator() api.IToken
- func (e *LogicExpression) Right() api.IExpression
- func (e *LogicExpression) Type() api.ExpressionType
- type UnaryExpression
- type VariableExpression
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAssignExpression ¶
func NewAssignExpression(name api.IToken, eValue api.IExpression) api.IExpression
func NewBinaryExpression ¶
func NewBinaryExpression(left api.IExpression, operator api.IToken, right api.IExpression) api.IExpression
func NewCallExpression ¶
func NewCallExpression(callee api.IExpression, paren api.IToken, arguments []api.IExpression) api.IExpression
func NewClockCallable ¶
func NewEnvironmentEnclosing ¶
func NewEnvironmentEnclosing(enclosing api.IEnvironment) api.IEnvironment
local scope nested inside the given outer one
func NewFunctionCallable ¶
func NewFunctionCallable(declaration api.IStatement, closure api.IEnvironment) api.ICallable
func NewGroupingExpression ¶
func NewGroupingExpression(expression api.IExpression) api.IExpression
func NewInterpreter ¶
func NewInterpreter() api.IInterpreter
func NewLiteralExpression ¶
func NewLogicExpression ¶
func NewLogicExpression(left api.IExpression, operator api.IToken, right api.IExpression) api.IExpression
func NewUnaryExpression ¶
func NewUnaryExpression(operator api.IToken, right api.IExpression) api.IExpression
func NewVariableExpression ¶
func NewVariableExpression(name api.IToken) api.IExpression
Types ¶
type AssignExpression ¶
type AssignExpression struct { BaseExpression // contains filtered or unexported fields }
--------------------------------------------------- Assignment "=" ---------------------------------------------------
func (*AssignExpression) Accept ¶
func (e *AssignExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
func (*AssignExpression) Expression ¶
func (e *AssignExpression) Expression() api.IExpression
func (*AssignExpression) Name ¶
func (e *AssignExpression) Name() api.IToken
func (*AssignExpression) Type ¶
func (e *AssignExpression) Type() api.ExpressionType
type AstPrinter ¶
type AstPrinter struct { }
type BaseExpression ¶
type BaseExpression struct { }
func (*BaseExpression) Arguments ¶
func (e *BaseExpression) Arguments() []api.IExpression
func (*BaseExpression) Callee ¶
func (e *BaseExpression) Callee() api.IExpression
func (*BaseExpression) Expression ¶
func (e *BaseExpression) Expression() api.IExpression
func (*BaseExpression) Left ¶
func (e *BaseExpression) Left() api.IExpression
func (*BaseExpression) Name ¶
func (e *BaseExpression) Name() api.IToken
func (*BaseExpression) Operator ¶
func (e *BaseExpression) Operator() api.IToken
func (*BaseExpression) Paren ¶
func (e *BaseExpression) Paren() api.IToken
func (*BaseExpression) Right ¶
func (e *BaseExpression) Right() api.IExpression
func (*BaseExpression) Type ¶
func (e *BaseExpression) Type() api.ExpressionType
func (*BaseExpression) Value ¶
func (e *BaseExpression) Value() interface{}
type BinaryExpression ¶
type BinaryExpression struct { BaseExpression // contains filtered or unexported fields }
--------------------------------------------------- Binary ---------------------------------------------------
func (*BinaryExpression) Accept ¶
func (e *BinaryExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
func (*BinaryExpression) Left ¶
func (e *BinaryExpression) Left() api.IExpression
func (*BinaryExpression) Operator ¶
func (e *BinaryExpression) Operator() api.IToken
func (*BinaryExpression) Right ¶
func (e *BinaryExpression) Right() api.IExpression
func (*BinaryExpression) Type ¶
func (e *BinaryExpression) Type() api.ExpressionType
type CallExpression ¶
type CallExpression struct { BaseExpression // contains filtered or unexported fields }
--------------------------------------------------- "call" ---------------------------------------------------
func (*CallExpression) Accept ¶
func (e *CallExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
func (*CallExpression) Arguments ¶
func (e *CallExpression) Arguments() []api.IExpression
func (*CallExpression) Callee ¶
func (e *CallExpression) Callee() api.IExpression
func (*CallExpression) Paren ¶
func (e *CallExpression) Paren() api.IToken
func (*CallExpression) Type ¶
func (e *CallExpression) Type() api.ExpressionType
type ClockCallable ¶
type ClockCallable struct { }
~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~--- Clock ~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~---
func (*ClockCallable) Arity ¶
func (c *ClockCallable) Arity() int
func (*ClockCallable) Call ¶
func (c *ClockCallable) Call(interpreter api.IInterpreter, arguments []interface{}) (obj interface{}, err api.IRuntimeError)
func (ClockCallable) String ¶
func (c ClockCallable) String() string
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
func (*Environment) Assign ¶
func (e *Environment) Assign(name api.IToken, value interface{}) (err api.IRuntimeError)
func (*Environment) AssignAt ¶
func (e *Environment) AssignAt(distance int, name api.IToken, value interface{}) (err api.IRuntimeError)
func (*Environment) Define ¶
func (e *Environment) Define(name string, obj interface{}) (err api.IRuntimeError)
func (*Environment) Enclosing ¶
func (e *Environment) Enclosing() api.IEnvironment
func (*Environment) Get ¶
func (e *Environment) Get(name api.IToken) (value interface{}, err api.IRuntimeError)
func (*Environment) GetAt ¶
func (e *Environment) GetAt(distance int, name api.IToken) (obj interface{}, err api.IRuntimeError)
func (*Environment) Values ¶
func (e *Environment) Values() map[string]interface{}
type FunctionCallable ¶
type FunctionCallable struct {
// contains filtered or unexported fields
}
~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~--- Function ~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~---~~~---
func (*FunctionCallable) Arity ¶
func (c *FunctionCallable) Arity() int
func (*FunctionCallable) Call ¶
func (c *FunctionCallable) Call(interpreter api.IInterpreter, arguments []interface{}) (obj interface{}, err api.IRuntimeError)
func (FunctionCallable) String ¶
func (c FunctionCallable) String() string
type GroupingExpression ¶
type GroupingExpression struct { BaseExpression // contains filtered or unexported fields }
--------------------------------------------------- Grouping ---------------------------------------------------
func (*GroupingExpression) Accept ¶
func (e *GroupingExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
func (*GroupingExpression) Expression ¶
func (e *GroupingExpression) Expression() api.IExpression
func (*GroupingExpression) Type ¶
func (e *GroupingExpression) Type() api.ExpressionType
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
func (*Interpreter) ExecuteBlock ¶
func (i *Interpreter) ExecuteBlock(statements []api.IStatement, parentEnv api.IEnvironment) (err api.IRuntimeError)
func (*Interpreter) Globals ¶
func (i *Interpreter) Globals() api.IEnvironment
func (*Interpreter) Interpret ¶
func (i *Interpreter) Interpret(statements []api.IStatement) api.IRuntimeError
IInterpreter interface method
func (*Interpreter) Resolve ¶
func (i *Interpreter) Resolve(expr api.IExpression, depth int) (err api.IRuntimeError)
func (*Interpreter) VisitAssignExpression ¶
func (i *Interpreter) VisitAssignExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
func (*Interpreter) VisitBinaryExpression ¶
func (i *Interpreter) VisitBinaryExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
func (*Interpreter) VisitBlockStatement ¶
func (i *Interpreter) VisitBlockStatement(statement api.IStatement) (err api.IRuntimeError)
func (*Interpreter) VisitCallExpression ¶
func (i *Interpreter) VisitCallExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
func (*Interpreter) VisitExpressionStatement ¶
func (i *Interpreter) VisitExpressionStatement(statement api.IStatement) (err api.IRuntimeError)
-- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- IVisitorStatement implementations -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ --
func (*Interpreter) VisitFunctionStatement ¶
func (i *Interpreter) VisitFunctionStatement(statement api.IStatement) (err api.IRuntimeError)
func (*Interpreter) VisitGroupingExpression ¶
func (i *Interpreter) VisitGroupingExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
func (*Interpreter) VisitIfStatement ¶
func (i *Interpreter) VisitIfStatement(statement api.IStatement) (err api.IRuntimeError)
func (*Interpreter) VisitInterruptStatement ¶
func (i *Interpreter) VisitInterruptStatement(statement api.IStatement) (err api.IRuntimeError)
func (*Interpreter) VisitLiteralExpression ¶
func (i *Interpreter) VisitLiteralExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
-- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- IVisitorExpression interface -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ --
func (*Interpreter) VisitLogicalExpression ¶
func (i *Interpreter) VisitLogicalExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
func (*Interpreter) VisitPrintStatement ¶
func (i *Interpreter) VisitPrintStatement(statement api.IStatement) (err api.IRuntimeError)
func (*Interpreter) VisitReturnStatement ¶
func (i *Interpreter) VisitReturnStatement(statement api.IStatement) (err api.IRuntimeError)
func (*Interpreter) VisitUnaryExpression ¶
func (i *Interpreter) VisitUnaryExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
func (*Interpreter) VisitVariableExpression ¶
func (i *Interpreter) VisitVariableExpression(exprV api.IExpression) (obj interface{}, err api.IRuntimeError)
func (*Interpreter) VisitVariableStatement ¶
func (i *Interpreter) VisitVariableStatement(statement api.IStatement) (err api.IRuntimeError)
func (*Interpreter) VisitWhileStatement ¶
func (i *Interpreter) VisitWhileStatement(statement api.IStatement) (err api.IRuntimeError)
type LiteralExpression ¶
type LiteralExpression struct { BaseExpression // contains filtered or unexported fields }
--------------------------------------------------- Literal ---------------------------------------------------
func (*LiteralExpression) Accept ¶
func (e *LiteralExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
func (*LiteralExpression) Name ¶
func (e *LiteralExpression) Name() api.IToken
func (*LiteralExpression) Type ¶
func (e *LiteralExpression) Type() api.ExpressionType
func (*LiteralExpression) Value ¶
func (e *LiteralExpression) Value() interface{}
type LogicExpression ¶
type LogicExpression struct { BaseExpression // contains filtered or unexported fields }
--------------------------------------------------- Logic "or", "and" ---------------------------------------------------
func (*LogicExpression) Accept ¶
func (e *LogicExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
func (*LogicExpression) Left ¶
func (e *LogicExpression) Left() api.IExpression
func (*LogicExpression) Operator ¶
func (e *LogicExpression) Operator() api.IToken
func (*LogicExpression) Right ¶
func (e *LogicExpression) Right() api.IExpression
func (*LogicExpression) Type ¶
func (e *LogicExpression) Type() api.ExpressionType
type UnaryExpression ¶
type UnaryExpression struct { BaseExpression // contains filtered or unexported fields }
--------------------------------------------------- Unary ---------------------------------------------------
func (*UnaryExpression) Accept ¶
func (e *UnaryExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
func (*UnaryExpression) Operator ¶
func (e *UnaryExpression) Operator() api.IToken
func (*UnaryExpression) Right ¶
func (e *UnaryExpression) Right() api.IExpression
func (*UnaryExpression) Type ¶
func (e *UnaryExpression) Type() api.ExpressionType
type VariableExpression ¶
type VariableExpression struct { BaseExpression // contains filtered or unexported fields }
--------------------------------------------------- Variable ---------------------------------------------------
func (*VariableExpression) Accept ¶
func (e *VariableExpression) Accept(visitor api.IVisitorExpression) (obj interface{}, err api.IRuntimeError)
func (*VariableExpression) Name ¶
func (e *VariableExpression) Name() api.IToken
func (*VariableExpression) Type ¶
func (e *VariableExpression) Type() api.ExpressionType