Documentation
¶
Index ¶
- Constants
- func GetGrammer() string
- func InjectRuntime(context *Context)
- func REPL()
- func RunProgram(source string, debug bool) (*string, error)
- type Addition
- type Assignment
- type BoolValue
- type Break
- type BreakValue
- type Call
- type CallChain
- type Comparison
- type Context
- type Continue
- type ContinueValue
- type DataLiteral
- type DictEntry
- type DictLiteral
- type DictValue
- type ElseIf
- type Equality
- type Expression
- type ExpressionList
- type For
- type ForKeyValue
- type ForValue
- type ForWhile
- type FunctionLiteral
- type FunctionValue
- type IdentifierValue
- type If
- type ListLiteral
- type ListValue
- type LogicAnd
- type LogicOr
- type Multiplication
- type NativeFunctionValue
- type NilValue
- type NumberValue
- type Primary
- type ReferenceValue
- type Return
- type ReturnValue
- type StackFrame
- type StringValue
- type Unary
- type Value
Constants ¶
View Source
const VERSION = 0.1
Variables ¶
This section is empty.
Functions ¶
func GetGrammer ¶
func GetGrammer() string
func InjectRuntime ¶
func InjectRuntime(context *Context)
Types ¶
type Addition ¶
type Addition struct { Pos lexer.Position Multiplication *Multiplication `@@` Op string `( @( "-" | "+" )` Next *Addition ` @@ )?` }
type Assignment ¶
type Assignment struct { Pos lexer.Position LogicAnd *LogicAnd `@@` Op string `( @"="` Next *LogicAnd ` @@ )?` }
func (Assignment) Eval ¶
func (assignment Assignment) Eval(frame *StackFrame) (Value, error)
func (Assignment) String ¶
func (assignment Assignment) String() string
type BreakValue ¶
type BreakValue struct {
// contains filtered or unexported fields
}
func (BreakValue) Error ¶
func (breakValue BreakValue) Error() string
type Call ¶
type Call struct { Pos lexer.Position Ident *string `( @Ident` SubExpression *Expression `| "(" @@ ")" )` CallChain *CallChain `@@` }
type CallChain ¶
type CallChain struct { Parameters *[]Expression `( "(" ( @@ ( "," @@ )* )? ")" ` Access *string ` | "." @Ident` ComputedAccess *Expression ` | "[" @@ "]" )` Next *CallChain `@@?` }
type Comparison ¶
type Comparison struct { Pos lexer.Position Addition *Addition `@@` Op string `( @( ">" "=" | ">" | "<" "=" | "<" )` Next *Comparison ` @@ )?` }
func (Comparison) Eval ¶
func (comparison Comparison) Eval(frame *StackFrame) (Value, error)
func (Comparison) String ¶
func (comparison Comparison) String() string
type ContinueValue ¶
type ContinueValue struct {
// contains filtered or unexported fields
}
func (ContinueValue) Error ¶
func (continueValue ContinueValue) Error() string
type DataLiteral ¶
type DataLiteral struct { FunctionLiteral *FunctionLiteral `@@` ListLiteral *ListLiteral `| @@` DictLiteral *DictLiteral `| @@` }
type DictEntry ¶
type DictEntry struct { Pos lexer.Position Ident *string `( @Ident` Key *Expression `| @@ ) ":" ` Value *Expression `@@` }
type DictLiteral ¶
type DictLiteral struct { Pos lexer.Position DictEntry *[]DictEntry `"{" ( @@ ("," @@)* ","? )? "}"` }
func (DictLiteral) Eval ¶
func (dictLiteral DictLiteral) Eval(frame *StackFrame) (Value, error)
func (DictLiteral) String ¶
func (dictLiteral DictLiteral) String() string
type DictValue ¶
type DictValue struct {
// contains filtered or unexported fields
}
type ElseIf ¶
type ElseIf struct { Condition *Expression `"else" "if" @@` IfBody []*Expression `"{" @@* "}"` Next *ElseIf `@@*` }
type Equality ¶
type Equality struct { Pos lexer.Position Comparison *Comparison `@@` Op string `( @( "!" "=" | "=" "=" )` Next *Equality ` @@ )?` }
type Expression ¶
type Expression struct { Pos lexer.Position Assignment *Assignment `@@` NativeFunctionValue *NativeFunctionValue }
func (Expression) Eval ¶
func (expr Expression) Eval(frame *StackFrame) (Value, error)
func (Expression) String ¶
func (expr Expression) String() string
type ExpressionList ¶
type ExpressionList struct { Pos lexer.Position Expressions []*Expression `@@*` }
func GenerateAST ¶
func GenerateAST(source string) (*ExpressionList, error)
func (ExpressionList) String ¶
func (exprList ExpressionList) String() string
type For ¶
type For struct { Pos lexer.Position Init []*Assignment `"for" ( @@ ";"` Condition *Expression `@@ ";"` Post *Expression `@@` Body []*Expression `"{" @@* "}" )` }
type ForKeyValue ¶
type ForKeyValue struct { Pos lexer.Position Key *string `( "for" @Ident ","` Value *string `@Ident "in"` Collection *string `( @Ident` CollectionExpression *Expression `| @@) ` Body []*Expression `"{" @@* "}" )` }
type ForValue ¶
type ForValue struct { Pos lexer.Position Value *string `( "for" @Ident "in"` Collection *string `( @Ident` CollectionExpression *Expression `| @@) ` Body []*Expression `"{" @@* "}" )` }
type ForWhile ¶
type ForWhile struct { Pos lexer.Position Init []*Assignment `"for" (` Condition *Expression `@@?` Post *Expression `` Body []*Expression `"{" @@* "}" )` }
type FunctionLiteral ¶
type FunctionLiteral struct { Pos lexer.Position Parameters []string `( "(" ( @Ident ( "," @Ident )* )? ")" | @Ident )` Body []*Expression `"=" ">" ( "{" @@* "}" | @@ )` }
func (FunctionLiteral) Equals ¶
func (functionLiteral FunctionLiteral) Equals(other Value) (bool, error)
func (FunctionLiteral) Eval ¶
func (functionLiteral FunctionLiteral) Eval(frame *StackFrame) (Value, error)
func (FunctionLiteral) String ¶
func (functionLiteral FunctionLiteral) String() string
type FunctionValue ¶
type FunctionValue struct {
// contains filtered or unexported fields
}
func (FunctionValue) String ¶
func (functionValue FunctionValue) String() string
type IdentifierValue ¶
type IdentifierValue struct {
// contains filtered or unexported fields
}
func (IdentifierValue) Equals ¶
func (identifierValue IdentifierValue) Equals(other Value) (bool, error)
func (IdentifierValue) Eval ¶
func (idValue IdentifierValue) Eval(frame *StackFrame) (Value, error)
func (IdentifierValue) String ¶
func (identifierValue IdentifierValue) String() string
type If ¶
type If struct { Pos lexer.Position Condition *Expression `"if" @@` IfBody []*Expression `"{" @@* "}"` ElseIf *ElseIf `@@*` ElseBody []*Expression `( "else" "{" @@* "}" )?` }
type ListLiteral ¶
type ListLiteral struct { Pos lexer.Position Expressions *[]Expression `"[" ( @@ ( "," @@ )* )? "]"` }
func (ListLiteral) Eval ¶
func (listLiteral ListLiteral) Eval(frame *StackFrame) (Value, error)
func (ListLiteral) String ¶
func (listLiteral ListLiteral) String() string
type LogicAnd ¶
type LogicOr ¶
type Multiplication ¶
type Multiplication struct { Pos lexer.Position Unary *Unary `@@` Op string `( @( "/" | "*" | "%")` Next *Multiplication ` @@ )?` }
func (Multiplication) Equals ¶
func (multiplication Multiplication) Equals(other Value) (bool, error)
func (Multiplication) Eval ¶
func (multiplication Multiplication) Eval(frame *StackFrame) (Value, error)
func (Multiplication) String ¶
func (multiplication Multiplication) String() string
type NativeFunctionValue ¶
type NativeFunctionValue struct { Pos lexer.Position Exec func([]Value) (Value, error) // contains filtered or unexported fields }
func (NativeFunctionValue) Equals ¶
func (nativeFunctionValue NativeFunctionValue) Equals(other Value) (bool, error)
func (NativeFunctionValue) String ¶
func (nativeFunctionValue NativeFunctionValue) String() string
type NumberValue ¶
type NumberValue struct {
// contains filtered or unexported fields
}
func (NumberValue) String ¶
func (numberValue NumberValue) String() string
type Primary ¶
type Primary struct { Pos lexer.Position If *If `@@` DataLiteral *DataLiteral `| @@` SubExpression *Expression `| "(" @@ ")"` Call *Call `| @@` // TODO: `for {}` is a parser error ForKeyValue *ForKeyValue `| @@` ForValue *ForValue `| @@` For *For `| @@` ForWhile *ForWhile `| @@` Return *Return `| @@` Break *Break `| @@` Continue *Continue `| @@` Number *float64 `| @Float | @Int` Str *string `| @String` True *bool `| @"true"` False *bool `| @"false"` Nil *bool `| @"nil"` Ident *string `| @Ident` }
type ReferenceValue ¶
type ReferenceValue struct {
// contains filtered or unexported fields
}
func (ReferenceValue) String ¶
func (_ ReferenceValue) String() string
type Return ¶
type Return struct { Pos lexer.Position Return *string `( "return" ` Expression *Expression `@@ )` }
type ReturnValue ¶
type ReturnValue struct {
// contains filtered or unexported fields
}
func (ReturnValue) Error ¶
func (returnValue ReturnValue) Error() string
type StackFrame ¶
type StackFrame struct {
// contains filtered or unexported fields
}
func (*StackFrame) GetChild ¶
func (frame *StackFrame) GetChild() *StackFrame
func (*StackFrame) Set ¶
func (frame *StackFrame) Set(key string, value Value)
func (*StackFrame) String ¶
func (frame *StackFrame) String() string
type StringValue ¶
type StringValue struct {
// contains filtered or unexported fields
}
func (StringValue) String ¶
func (stringValue StringValue) String() string
Click to show internal directories.
Click to hide internal directories.