Documentation
¶
Index ¶
- Constants
- Variables
- func NewCallStack() *[]Frame
- 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) GetColumn() int
- func (b *Boolean) GetLine() int
- 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
- func (b *Boolean) Sub(other Object) (Object, error)
- func (b *Boolean) Type() string
- func (b *Boolean) Value() interface{}
- type Callable
- type Error
- type Evaluator
- type Expression
- 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) GetColumn() int
- func (f *Float) GetLine() int
- 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
- func (f *Float) Sub(other Object) (Object, error)
- func (f *Float) Type() string
- func (f *Float) Value() interface{}
- 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) GetColumn() int
- func (f *Function) GetLine() int
- 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
- 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) GetColumn() int
- func (f *GoFunction) GetLine() int
- 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
- func (f *GoFunction) Sub(other Object) (Object, error)
- func (f *GoFunction) Type() string
- func (f *GoFunction) Value() interface{}
- type IdentifierLiteral
- type IfNode
- 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) GetColumn() int
- func (i *Integer) GetLine() int
- 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
- func (i *Integer) Sub(other Object) (Object, error)
- func (i *Integer) Type() string
- func (i *Integer) Value() interface{}
- type Lexer
- 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) GetColumn() int
- func (n *Nil) GetLine() int
- 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
- 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) GetColumn() int
- func (s *String) GetLine() int
- 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
- func (s *String) Sub(other Object) (Object, error)
- func (s *String) Type() string
- func (s *String) Value() interface{}
- type SufixNode
- 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 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 Boolean ¶
type Boolean struct {
// contains filtered or unexported fields
}
func (*Boolean) GreaterThanOrEqual ¶
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
func NewEvaluator ¶
type Expression ¶
type ForNode ¶
type Function ¶
type Function struct {
Name string
Arguments []*IdentifierLiteral
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
Arguments []*IdentifierLiteral
Body *BlockStatement
Line int
Column int
}
func NewFunctionLiteral ¶
func NewFunctionLiteral(name string, parameters []*IdentifierLiteral, 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) GetColumn ¶
func (f *GoFunction) GetColumn() int
func (*GoFunction) GetLine ¶
func (f *GoFunction) GetLine() int
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
func (*GoFunction) Type ¶
func (f *GoFunction) Type() string
func (*GoFunction) Value ¶
func (f *GoFunction) 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 InfixNode ¶
func NewInfixNode ¶
type Integer ¶
type Integer struct {
// contains filtered or unexported fields
}
func (*Integer) GreaterThanOrEqual ¶
type Object ¶
type Object interface {
Type() string
Value() interface{}
String() *String
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 String ¶
type String struct {
// contains filtered or unexported fields
}
func (*String) GreaterThanOrEqual ¶
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.