Documentation ¶
Index ¶
- Constants
- Variables
- func NewCallStack() *[]Frame
- type Array
- func (a Array) Add(other Object) (Object, error)
- func (a Array) Divide(other Object) (Object, error)
- func (a Array) Equal(other Object) (Object, error)
- func (a Array) GreaterThan(other Object) (Object, error)
- func (a Array) GreaterThanOrEqual(other Object) (Object, error)
- func (a Array) LessThan(other Object) (Object, error)
- func (a Array) LessThanOrEqual(other Object) (Object, error)
- func (a Array) Modulo(other Object) (Object, error)
- func (a Array) Multiply(other Object) (Object, error)
- func (a Array) NotEqual(other Object) (Object, error)
- func (a Array) String() (String, error)
- func (a Array) Sub(other Object) (Object, error)
- func (a Array) Type() string
- func (a Array) Value() interface{}
- type ArrayLiteral
- type BlockStatement
- type Boolean
- func (b Boolean) Add(other Object) (Object, error)
- func (b Boolean) Divide(other Object) (Object, error)
- func (b Boolean) Equal(other Object) (Object, error)
- func (b Boolean) GreaterThan(other Object) (Object, error)
- func (b Boolean) GreaterThanOrEqual(other Object) (Object, error)
- func (b Boolean) LessThan(other Object) (Object, error)
- func (b Boolean) LessThanOrEqual(other Object) (Object, error)
- func (b Boolean) Modulo(other Object) (Object, error)
- func (b Boolean) Multiply(other Object) (Object, error)
- func (b Boolean) NotEqual(other Object) (Object, error)
- func (b Boolean) String() (String, error)
- func (b Boolean) Sub(other Object) (Object, error)
- func (b Boolean) Type() string
- func (b Boolean) Value() interface{}
- type BooleanLiteral
- type Callable
- type DecrementNode
- type DotNotationNode
- type Error
- type Evaluator
- type Float
- func (f Float) Add(other Object) (Object, error)
- func (f Float) Divide(other Object) (Object, error)
- func (f Float) Equal(other Object) (Object, error)
- func (f Float) GreaterThan(other Object) (Object, error)
- func (f Float) GreaterThanOrEqual(other Object) (Object, error)
- func (f Float) LessThan(other Object) (Object, error)
- func (f Float) LessThanOrEqual(other Object) (Object, error)
- func (f Float) Modulo(other Object) (Object, error)
- func (f Float) Multiply(other Object) (Object, error)
- func (f Float) NotEqual(other Object) (Object, error)
- func (f Float) String() (String, error)
- func (f Float) Sub(other Object) (Object, error)
- func (f Float) Type() string
- func (f Float) Value() interface{}
- type FloatLiteral
- type ForNode
- type Frame
- type Function
- func (f *Function) Add(other Object) (Object, error)
- func (f *Function) Call(args []Object) (Object, error)
- func (f *Function) Divide(other Object) (Object, error)
- func (f *Function) Equal(other Object) (Object, error)
- func (f *Function) GetName() string
- func (f *Function) GreaterThan(other Object) (Object, error)
- func (f *Function) GreaterThanOrEqual(other Object) (Object, error)
- func (f *Function) LessThan(other Object) (Object, error)
- func (f *Function) LessThanOrEqual(other Object) (Object, error)
- func (f *Function) Modulo(other Object) (Object, error)
- func (f *Function) Multiply(other Object) (Object, error)
- func (f *Function) NotEqual(other Object) (Object, error)
- func (f *Function) String() (String, error)
- func (f *Function) Sub(other Object) (Object, error)
- func (f *Function) Type() string
- func (f *Function) Value() interface{}
- type FunctionCall
- type FunctionLiteral
- type GoFunction
- func (f *GoFunction) Add(other Object) (Object, error)
- func (f *GoFunction) Call(args []Object) (Object, error)
- func (f *GoFunction) Divide(other Object) (Object, error)
- func (f *GoFunction) Equal(other Object) (Object, error)
- func (f *GoFunction) GetName() string
- func (f *GoFunction) GreaterThan(other Object) (Object, error)
- func (f *GoFunction) GreaterThanOrEqual(other Object) (Object, error)
- func (f *GoFunction) LessThan(other Object) (Object, error)
- func (f *GoFunction) LessThanOrEqual(other Object) (Object, error)
- func (f *GoFunction) Modulo(other Object) (Object, error)
- func (f *GoFunction) Multiply(other Object) (Object, error)
- func (f *GoFunction) NotEqual(other Object) (Object, error)
- func (f *GoFunction) String() (String, error)
- func (f *GoFunction) Sub(other Object) (Object, error)
- func (f *GoFunction) Type() string
- func (f *GoFunction) Value() interface{}
- type HashLiteral
- type IdentifierLiteral
- type IfNode
- type IncrementNode
- type InfixNode
- type Integer
- func (i Integer) Add(other Object) (Object, error)
- func (i Integer) Divide(other Object) (Object, error)
- func (i Integer) Equal(other Object) (Object, error)
- func (i Integer) GreaterThan(other Object) (Object, error)
- func (i Integer) GreaterThanOrEqual(other Object) (Object, error)
- func (i Integer) LessThan(other Object) (Object, error)
- func (i Integer) LessThanOrEqual(other Object) (Object, error)
- func (i Integer) Modulo(other Object) (Object, error)
- func (i Integer) Multiply(other Object) (Object, error)
- func (i Integer) NotEqual(other Object) (Object, error)
- func (i Integer) String() (String, error)
- func (i Integer) Sub(other Object) (Object, error)
- func (i Integer) Type() string
- func (i Integer) Value() interface{}
- type IntegerLiteral
- type Lexer
- type Map
- type Module
- func (m *Module) Add(other Object) (Object, error)
- func (m *Module) Divide(other Object) (Object, error)
- func (m *Module) Equal(other Object) (Object, error)
- func (m *Module) GreaterThan(other Object) (Object, error)
- func (m *Module) GreaterThanOrEqual(other Object) (Object, error)
- func (m *Module) LessThan(other Object) (Object, error)
- func (m *Module) LessThanOrEqual(other Object) (Object, error)
- func (m *Module) Modulo(other Object) (Object, error)
- func (m *Module) Multiply(other Object) (Object, error)
- func (m *Module) NotEqual(other Object) (Object, error)
- func (m *Module) String() (String, error)
- func (m *Module) Sub(other Object) (Object, error)
- func (m *Module) Type() string
- func (m *Module) Value() interface{}
- type ModuleListNode
- type ModuleLiteral
- type Nil
- func (n Nil) Add(other Object) (Object, error)
- func (n Nil) Divide(other Object) (Object, error)
- func (n Nil) Equal(other Object) (Object, error)
- func (n Nil) GreaterThan(other Object) (Object, error)
- func (n Nil) GreaterThanOrEqual(other Object) (Object, error)
- func (n *Nil) Inspect() string
- func (n Nil) LessThan(other Object) (Object, error)
- func (n Nil) LessThanOrEqual(other Object) (Object, error)
- func (n Nil) Modulo(other Object) (Object, error)
- func (n Nil) Multiply(other Object) (Object, error)
- func (n Nil) NotEqual(other Object) (Object, error)
- func (n Nil) String() (String, error)
- func (n Nil) Sub(other Object) (Object, error)
- func (n Nil) Type() string
- func (n Nil) Value() interface{}
- type Node
- type Object
- type Parser
- type PrefixNode
- type ReturnStatement
- type String
- func (s String) Add(other Object) (Object, error)
- func (s String) Divide(other Object) (Object, error)
- func (s String) Equal(other Object) (Object, error)
- func (s String) GreaterThan(other Object) (Object, error)
- func (s String) GreaterThanOrEqual(other Object) (Object, error)
- func (s String) LessThan(other Object) (Object, error)
- func (s String) LessThanOrEqual(other Object) (Object, error)
- func (s String) Modulo(other Object) (Object, error)
- func (s String) Multiply(other Object) (Object, error)
- func (s String) NotEqual(other Object) (Object, error)
- func (s String) String() (String, error)
- func (s String) Sub(other Object) (Object, error)
- func (s String) Type() string
- func (s String) Value() interface{}
- type StringLiteral
- type StructLiteral
- type Token
- type TokenType
- type V1Lexer
- type V1Parser
- type VariableDeclaration
Constants ¶
View Source
const ( INT_TYPE int = iota FLOAT_TYPE STRING_TYPE FUNC_TYPE )
View Source
const ( LOWEST int ASSIGN_P IF_P EQUALS // == LESSGREATER // > or < SUM // + PRODUCT // * PREFIX // -X or !X ARRAY_P CALL_P // foo(X) )
View Source
const CALL_STACK_SIZE = 10000
View Source
const SYNTAX_ERROR_MSG = "syntax error on line: %d"
Variables ¶
View Source
var TokenTypeStr = map[TokenType]string{ ERROR: "ERROR", ILLEGAL: "ILLEGAL", EOF: "EOF", WS: "WS", IDENT: "IDENT", INT: "INT", FLOAT: "FLOAT", STRING: "STRING", ARRAY: "ARRAY", BOOL: "BOOL", ADD: "+", SUB: "-", MUL: "*", DIV: "/", REM: "%", EXP: "^", ASSIGN: "=", ASSIGN_INF: ":=", LEFT_SHIFT: "<<", RIGHT_SHIFT: ">>", ADD_ASSIGN: "+=", SUB_ASSIGN: "-=", INC: "++", DEC: "--", EQ: "==", NOT_EQ: "!=", GT: ">", LT: "<", GT_EQ: ">=", LT_EQ: "<=", LPAREN: "(", RPAREN: ")", LBRACKET: "[", RBRACKET: "]", LBRACE: "{", RBRACE: "}", COMMA: ",", DOT: ".", COLON: ":", SEMICOLON: ";", FUNC: "FUNC", RETURN: "RETURN", IF: "IF", ELSE: "ELSE", FOR: "FOR", BREAK: "BREAK", CONTINUE: "CONTINUE", IMPORT: "IMPORT", TRUE: "TRUE", FALSE: "FALSE", NEWLINE: "NEWLINE", CALL: "CALL", }
Functions ¶
func NewCallStack ¶
func NewCallStack() *[]Frame
Types ¶
type ArrayLiteral ¶
func (*ArrayLiteral) GetColumn ¶
func (al *ArrayLiteral) GetColumn() int
func (*ArrayLiteral) GetLine ¶
func (al *ArrayLiteral) GetLine() int
func (*ArrayLiteral) String ¶
func (al *ArrayLiteral) String() string
func (*ArrayLiteral) Value ¶
func (al *ArrayLiteral) Value() interface{}
type BlockStatement ¶
func (*BlockStatement) GetColumn ¶
func (bs *BlockStatement) GetColumn() int
func (*BlockStatement) GetLine ¶
func (bs *BlockStatement) GetLine() int
func (*BlockStatement) String ¶
func (bs *BlockStatement) String() string
func (*BlockStatement) Value ¶
func (bs *BlockStatement) Value() interface{}
type BooleanLiteral ¶
func NewBooleanLiteral ¶
func NewBooleanLiteral(value bool, line, column int) *BooleanLiteral
func (*BooleanLiteral) GetColumn ¶
func (bl *BooleanLiteral) GetColumn() int
func (*BooleanLiteral) GetLine ¶
func (bl *BooleanLiteral) GetLine() int
func (*BooleanLiteral) String ¶
func (bl *BooleanLiteral) String() string
func (*BooleanLiteral) Value ¶
func (bl *BooleanLiteral) Value() interface{}
type DecrementNode ¶
type DecrementNode struct { Line int Column int Operand *IdentifierLiteral }
func (*DecrementNode) GetColumn ¶
func (d *DecrementNode) GetColumn() int
func (*DecrementNode) GetLine ¶
func (d *DecrementNode) GetLine() int
func (*DecrementNode) String ¶
func (dn *DecrementNode) String() string
func (*DecrementNode) Value ¶
func (d *DecrementNode) Value() interface{}
type DotNotationNode ¶
func (*DotNotationNode) GetColumn ¶
func (dn *DotNotationNode) GetColumn() int
func (*DotNotationNode) GetLine ¶
func (dn *DotNotationNode) GetLine() int
func (*DotNotationNode) String ¶
func (dn *DotNotationNode) String() string
func (*DotNotationNode) Value ¶
func (dn *DotNotationNode) Value() interface{}
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
func NewEvaluator ¶
type FloatLiteral ¶
func NewFloatLiteral ¶
func NewFloatLiteral(value float64, line, column int) *FloatLiteral
func (*FloatLiteral) GetColumn ¶
func (fl *FloatLiteral) GetColumn() int
func (*FloatLiteral) GetLine ¶
func (fl *FloatLiteral) GetLine() int
func (*FloatLiteral) String ¶
func (fl *FloatLiteral) String() string
func (*FloatLiteral) Value ¶
func (fl *FloatLiteral) Value() interface{}
type ForNode ¶
type Function ¶
type Function struct { Name string Parameters []string Body *BlockStatement }
func (*Function) GreaterThanOrEqual ¶
type FunctionCall ¶
func NewFunctionCall ¶
func NewFunctionCall(function Node, arguments []Node, line, column int) *FunctionCall
func (*FunctionCall) GetColumn ¶
func (fc *FunctionCall) GetColumn() int
func (*FunctionCall) GetLine ¶
func (fc *FunctionCall) GetLine() int
func (*FunctionCall) String ¶
func (fc *FunctionCall) String() string
func (*FunctionCall) Value ¶
func (fc *FunctionCall) Value() interface{}
type FunctionLiteral ¶
type FunctionLiteral struct { Name string Parameters []*VariableDeclaration Body *BlockStatement Line int Column int }
func NewFunctionLiteral ¶
func NewFunctionLiteral(name string, parameters []*VariableDeclaration, body *BlockStatement, line, column int) *FunctionLiteral
func (*FunctionLiteral) GetColumn ¶
func (fl *FunctionLiteral) GetColumn() int
func (*FunctionLiteral) GetLine ¶
func (fl *FunctionLiteral) GetLine() int
func (*FunctionLiteral) String ¶
func (fl *FunctionLiteral) String() string
func (*FunctionLiteral) Value ¶
func (fl *FunctionLiteral) Value() interface{}
type GoFunction ¶
type GoFunction struct { Name string Func func([]Object) (Object, error) // The actual Go function }
func (*GoFunction) GetName ¶
func (f *GoFunction) GetName() string
func (*GoFunction) GreaterThan ¶
func (f *GoFunction) GreaterThan(other Object) (Object, error)
func (*GoFunction) GreaterThanOrEqual ¶
func (f *GoFunction) GreaterThanOrEqual(other Object) (Object, error)
func (*GoFunction) LessThanOrEqual ¶
func (f *GoFunction) LessThanOrEqual(other Object) (Object, error)
func (*GoFunction) String ¶
func (f *GoFunction) String() (String, error)
func (*GoFunction) Type ¶
func (f *GoFunction) Type() string
func (*GoFunction) Value ¶
func (f *GoFunction) Value() interface{}
type HashLiteral ¶
func (*HashLiteral) GetColumn ¶
func (hl *HashLiteral) GetColumn() int
func (*HashLiteral) GetLine ¶
func (hl *HashLiteral) GetLine() int
func (*HashLiteral) String ¶
func (hl *HashLiteral) String() string
func (*HashLiteral) Value ¶
func (hl *HashLiteral) Value() interface{}
type IdentifierLiteral ¶
type IdentifierLiteral struct { Type int Line int Column int // contains filtered or unexported fields }
func NewIdentifierLiteral ¶
func NewIdentifierLiteral(value string, line, column int) *IdentifierLiteral
func (*IdentifierLiteral) GetColumn ¶
func (il *IdentifierLiteral) GetColumn() int
func (*IdentifierLiteral) GetLine ¶
func (il *IdentifierLiteral) GetLine() int
func (*IdentifierLiteral) String ¶
func (il *IdentifierLiteral) String() string
func (*IdentifierLiteral) Value ¶
func (il *IdentifierLiteral) Value() interface{}
type IncrementNode ¶
type IncrementNode struct { Line int Column int Operand *IdentifierLiteral }
func (*IncrementNode) GetColumn ¶
func (i *IncrementNode) GetColumn() int
func (*IncrementNode) GetLine ¶
func (i *IncrementNode) GetLine() int
func (*IncrementNode) String ¶
func (in *IncrementNode) String() string
func (*IncrementNode) Value ¶
func (i *IncrementNode) Value() interface{}
type InfixNode ¶
func NewInfixNode ¶
type IntegerLiteral ¶
func NewIntegerLiteral ¶
func NewIntegerLiteral(value int, line, column int) *IntegerLiteral
func (*IntegerLiteral) GetColumn ¶
func (il *IntegerLiteral) GetColumn() int
func (*IntegerLiteral) GetLine ¶
func (il *IntegerLiteral) GetLine() int
func (*IntegerLiteral) String ¶
func (il *IntegerLiteral) String() string
func (*IntegerLiteral) Value ¶
func (il *IntegerLiteral) Value() interface{}
type Module ¶
func (*Module) GreaterThanOrEqual ¶
type ModuleListNode ¶
func NewModuleListNode ¶
func NewModuleListNode(modules []Node, line, column int) *ModuleListNode
func (*ModuleListNode) GetColumn ¶
func (mle *ModuleListNode) GetColumn() int
func (*ModuleListNode) GetLine ¶
func (mle *ModuleListNode) GetLine() int
func (*ModuleListNode) String ¶
func (mle *ModuleListNode) String() string
func (*ModuleListNode) Value ¶
func (mle *ModuleListNode) Value() interface{}
type ModuleLiteral ¶
func NewModuleLiteral ¶
func NewModuleLiteral(name string, Nodes []Node, line, column int) *ModuleLiteral
func (*ModuleLiteral) GetColumn ¶
func (m *ModuleLiteral) GetColumn() int
func (*ModuleLiteral) GetLine ¶
func (m *ModuleLiteral) GetLine() int
func (*ModuleLiteral) String ¶
func (m *ModuleLiteral) String() string
func (*ModuleLiteral) Value ¶
func (m *ModuleLiteral) Value() interface{}
type Object ¶
type Object interface { Type() string Value() interface{} String() (String, error) Add(other Object) (Object, error) Sub(other Object) (Object, error) Multiply(other Object) (Object, error) Divide(other Object) (Object, error) Modulo(other Object) (Object, error) Equal(other Object) (Object, error) NotEqual(other Object) (Object, error) GreaterThan(other Object) (Object, error) LessThan(other Object) (Object, error) GreaterThanOrEqual(other Object) (Object, error) LessThanOrEqual(other Object) (Object, error) }
type Parser ¶
func NewV1Parser ¶
type PrefixNode ¶
func NewPrefixNode ¶
func NewPrefixNode(operator string, right Node, line, column int) *PrefixNode
func (*PrefixNode) GetColumn ¶
func (pe *PrefixNode) GetColumn() int
func (*PrefixNode) GetLine ¶
func (pe *PrefixNode) GetLine() int
func (*PrefixNode) String ¶
func (pe *PrefixNode) String() string
func (*PrefixNode) Value ¶
func (pe *PrefixNode) Value() interface{}
type ReturnStatement ¶
func NewReturnStatement ¶
func NewReturnStatement(returnValue Node, line, column int) *ReturnStatement
func (*ReturnStatement) GetColumn ¶
func (rs *ReturnStatement) GetColumn() int
func (*ReturnStatement) GetLine ¶
func (rs *ReturnStatement) GetLine() int
func (*ReturnStatement) String ¶
func (rs *ReturnStatement) String() string
func (*ReturnStatement) Value ¶
func (rs *ReturnStatement) Value() interface{}
type StringLiteral ¶
func NewStringLiteral ¶
func NewStringLiteral(value string, line, column int) *StringLiteral
func (*StringLiteral) GetColumn ¶
func (sl *StringLiteral) GetColumn() int
func (*StringLiteral) GetLine ¶
func (sl *StringLiteral) GetLine() int
func (*StringLiteral) String ¶
func (sl *StringLiteral) String() string
func (*StringLiteral) Value ¶
func (sl *StringLiteral) Value() interface{}
type StructLiteral ¶
func NewStructLiteral ¶
func NewStructLiteral(fields map[string]Node, line, column int) *StructLiteral
func (*StructLiteral) GetColumn ¶
func (sl *StructLiteral) GetColumn() int
func (*StructLiteral) GetLine ¶
func (sl *StructLiteral) GetLine() int
func (*StructLiteral) String ¶
func (sl *StructLiteral) String() string
func (*StructLiteral) Value ¶
func (sl *StructLiteral) Value() interface{}
type TokenType ¶
type TokenType int
const ( // Special tokens ERROR TokenType = iota ILLEGAL EOF WS NEWLINE // Literals IDENT // main, foo, bar, x, y, etc. INT // int FLOAT // 123.456 STRING // "abc", 'abc' BOOL // true ARRAY // [1, 2] STRUCT // { a int } // Operators ADD // + SUB // - MUL // * DIV // / REM // % EXP // ** ASSIGN // = ASSIGN_INF // := LEFT_SHIFT // << RIGHT_SHIFT // >> XOR //^ ADD_ASSIGN // += SUB_ASSIGN // -= INC // ++ DEC // -- // Comparators EQ // == NOT_EQ // != GT // > LT // < GT_EQ // >= LT_EQ // <= OR // Delimiters LPAREN // ( RPAREN // ) LBRACKET // [ RBRACKET // ] LBRACE // { RBRACE // } COMMA // , DOT // . COLON // : SEMICOLON // ; // Keywords FUNC VAR CLASS RETURN IF ELIF ELSE FOR FOREVER BREAK CONTINUE IMPORT TRUE FALSE CALL ASYNC AWAIT )
type V1Parser ¶
type V1Parser struct { Debug bool // contains filtered or unexported fields }
func (*V1Parser) ParseProgram ¶
type VariableDeclaration ¶
type VariableDeclaration struct { Identifier *IdentifierLiteral Type Token Line int Column int }
func (*VariableDeclaration) GetColumn ¶
func (vd *VariableDeclaration) GetColumn() int
func (*VariableDeclaration) GetLine ¶
func (vd *VariableDeclaration) GetLine() int
func (*VariableDeclaration) String ¶
func (vd *VariableDeclaration) String() string
func (*VariableDeclaration) Value ¶
func (vd *VariableDeclaration) Value() interface{}
Click to show internal directories.
Click to hide internal directories.