Documentation ¶
Index ¶
- type ArrayLiteral
- type BlockStmt
- type BooleanLiteral
- type CallExpr
- type Expr
- type ExpressionStmt
- type FunctionLiteral
- type HashLiteral
- type Identifier
- type IfExpr
- type IndexExpression
- type InfixExpr
- type IntegerLiteral
- type LetStmt
- type Node
- type PrefixExpr
- type Program
- type ReturnStmt
- type Stmt
- type StringLiteral
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayLiteral ¶
func (*ArrayLiteral) GetTokenLiteral ¶
func (al *ArrayLiteral) GetTokenLiteral() string
func (*ArrayLiteral) String ¶
func (al *ArrayLiteral) String() string
type BlockStmt ¶
BlockStmt defines a block statement. Used in conditional expressions - if, and function definitions
func (*BlockStmt) GetTokenLiteral ¶
type BooleanLiteral ¶
func (*BooleanLiteral) GetTokenLiteral ¶
func (b *BooleanLiteral) GetTokenLiteral() string
func (*BooleanLiteral) String ¶
func (b *BooleanLiteral) String() string
type CallExpr ¶
type CallExpr struct { Token token.Token // '(' left parenthesis Function Expr // either an identifier or a function literal Arguments []Expr }
CallExpr identifies a callable expression. call expressions are of this structure: <expression>(<comma separated expressions>) sum(1, 2) sum(1 + 2, 3 + 4) fn(x, y) { x + y; }(1, 2)
func (*CallExpr) GetTokenLiteral ¶
type Expr ¶
type Expr interface { Node // contains filtered or unexported methods }
Expression is a type of node which provides expression functionality Expressions produce values. E.g: 6; sum(6,6)
type ExpressionStmt ¶
ExpressionStmt defines an expression statement. The previous 2 types were either only expr or stmt, but now we have both. Most scripting languages support this type of statements, so will gohil. E.g: let x = 6; // we said that this was a let statement x + 6; // this is an expression statement This type implements the Stmt interface, therefore we can use it in the Program type, which holds a slice of statements, which in turn means that gohil now supports expression statements
func (*ExpressionStmt) GetTokenLiteral ¶
func (e *ExpressionStmt) GetTokenLiteral() string
func (*ExpressionStmt) String ¶
func (e *ExpressionStmt) String() string
type FunctionLiteral ¶
type FunctionLiteral struct { Token token.Token Parameters []*Identifier Body *BlockStmt // reminder: 1 block statement has many statements }
func (*FunctionLiteral) GetTokenLiteral ¶
func (f *FunctionLiteral) GetTokenLiteral() string
func (*FunctionLiteral) String ¶
func (f *FunctionLiteral) String() string
type HashLiteral ¶
func (*HashLiteral) GetTokenLiteral ¶
func (hl *HashLiteral) GetTokenLiteral() string
func (*HashLiteral) String ¶
func (hl *HashLiteral) String() string
type Identifier ¶
Identifier represents identifiers that are used in statements and expressions. x is an identifier and to represent it we need a token - token.Identifier and a value in our case, the value is "x"
func (*Identifier) GetTokenLiteral ¶
func (i *Identifier) GetTokenLiteral() string
func (*Identifier) String ¶
func (i *Identifier) String() string
type IfExpr ¶
type IfExpr struct { Token token.Token // if Condition Expr Consequence *BlockStmt Alternative *BlockStmt }
func (*IfExpr) GetTokenLiteral ¶
type IndexExpression ¶
type IndexExpression struct { Token token.Token // The [ token Left Expr // the left side of an index expression is an expr: arr[4] Index Expr // the index is also an expression arr[3+4] is valid syntax in gohil }
func (*IndexExpression) GetTokenLiteral ¶
func (ie *IndexExpression) GetTokenLiteral() string
func (*IndexExpression) String ¶
func (ie *IndexExpression) String() string
type InfixExpr ¶
InfixExpr describes infix expressions. There are many infix expressions supported by gohil. All of the arithmetic operations are considered infix expressions. E.g: 6 + 8 Should result in: Token: + Left: IntegerLiteral(6) Operator: + Right: IntegerLiteral(8)
func (*InfixExpr) GetTokenLiteral ¶
type IntegerLiteral ¶
func (*IntegerLiteral) GetTokenLiteral ¶
func (il *IntegerLiteral) GetTokenLiteral() string
func (*IntegerLiteral) String ¶
func (il *IntegerLiteral) String() string
type LetStmt ¶
type LetStmt struct { Token token.Token Name *Identifier Value Expr }
LetStmt defines a let statement. E.g: let x = 6 This means that we need a token that identifies this statement - token.Let. We need an identifier - x. We also need a value - 6.
func (*LetStmt) GetTokenLiteral ¶
type PrefixExpr ¶
type PrefixExpr struct { Token token.Token // The prefix token, e.g. ! or - Operator string Right Expr }
PrefixExpr describes prefix expressions in gohil. There are 2 types of prefix expressions in the language: ! and - E.g: -66 Token: - Operation: - Right: 66
func (*PrefixExpr) GetTokenLiteral ¶
func (p *PrefixExpr) GetTokenLiteral() string
func (*PrefixExpr) String ¶
func (p *PrefixExpr) String() string
type ReturnStmt ¶
ReturnStmt defines a return statement. E.g: return 6; return keyword and expression. This means that we need a token that identifies this statement - token.Return. We also need a return value - 6, which is an expression.
func (*ReturnStmt) GetTokenLiteral ¶
func (r *ReturnStmt) GetTokenLiteral() string
func (*ReturnStmt) String ¶
func (r *ReturnStmt) String() string
type Stmt ¶
type Stmt interface { Node // contains filtered or unexported methods }
Statement is a type of node which provides statement functionality. Statements do not produce values. E.g: bind a value to a name: let x = 6;
type StringLiteral ¶
func (*StringLiteral) GetTokenLiteral ¶
func (sl *StringLiteral) GetTokenLiteral() string
func (*StringLiteral) String ¶
func (sl *StringLiteral) String() string