Documentation
¶
Index ¶
- Variables
- type AssignStatement
- type BlockStatement
- type BooleanLiteral
- type CallExpression
- type Contract
- type DataStructure
- type Expression
- type ExpressionStatement
- type FunctionLiteral
- type Identifier
- type IfStatement
- type InfixExpression
- type IntegerLiteral
- type Node
- type Operator
- type ParameterLiteral
- type PrefixExpression
- type ReassignStatement
- type ReturnStatement
- type Statement
- type StringLiteral
Constants ¶
This section is empty.
Variables ¶
var DataStructureMap = map[DataStructure]string{ IntType: "int", StringType: "string", BoolType: "bool", VoidType: "void", }
Functions ¶
This section is empty.
Types ¶
type AssignStatement ¶
type AssignStatement struct { Type DataStructure Variable Identifier Value Expression }
Represent assign statement
func (*AssignStatement) String ¶
func (a *AssignStatement) String() string
type BlockStatement ¶
type BlockStatement struct {
Statements []Statement
}
Represent block statement
func (*BlockStatement) String ¶
func (b *BlockStatement) String() string
type BooleanLiteral ¶
type BooleanLiteral struct {
Value bool
}
Represent Boolean expression
func (*BooleanLiteral) String ¶
func (b *BooleanLiteral) String() string
type CallExpression ¶
type CallExpression struct { Function Expression Arguments []Expression }
Represent Call expression
func (*CallExpression) String ¶
func (c *CallExpression) String() string
type Contract ¶
type Contract struct {
Functions []*FunctionLiteral
}
Represent Contract. Contract consists of multiple functions.
type DataStructure ¶
type DataStructure int
DataStructure represent identifier's data structure e.g. string, int, bool
const ( IntType DataStructure StringType BoolType VoidType )
func (DataStructure) String ¶
func (ds DataStructure) String() string
type Expression ¶
type Expression interface { Node // contains filtered or unexported methods }
Represent Expression
type ExpressionStatement ¶
type ExpressionStatement struct {
Expr Expression
}
Represent function statement
func (*ExpressionStatement) String ¶
func (e *ExpressionStatement) String() string
type FunctionLiteral ¶
type FunctionLiteral struct { Name *Identifier Parameters []*ParameterLiteral Body *BlockStatement ReturnType DataStructure }
FunctionLiteral represents function definition e.g. func foo(int a) { ... }
func (*FunctionLiteral) Signature ¶
func (f *FunctionLiteral) Signature() string
func (*FunctionLiteral) String ¶
func (f *FunctionLiteral) String() string
type Identifier ¶
type Identifier struct {
Name string
}
Represent identifier
func (*Identifier) String ¶
func (i *Identifier) String() string
type IfStatement ¶
type IfStatement struct { Condition Expression Consequence *BlockStatement Alternative *BlockStatement }
Represent if statement
func (*IfStatement) String ¶
func (i *IfStatement) String() string
type InfixExpression ¶
type InfixExpression struct { Left Expression Operator Right Expression }
Repersent Infix expression
func (*InfixExpression) String ¶
func (i *InfixExpression) String() string
type IntegerLiteral ¶
type IntegerLiteral struct {
Value int64
}
Represent integer literal
func (*IntegerLiteral) String ¶
func (i *IntegerLiteral) String() string
type Operator ¶
type Operator int
Operator represent operator between expression
const ( Plus Operator // + Minus // - Bang // ! Asterisk // * Slash // / Mod // % LT // < GT // > LTE // <= GTE // >= EQ // == NOT_EQ // != LAND // && LOR // || )
type ParameterLiteral ¶
type ParameterLiteral struct { Identifier *Identifier Type DataStructure }
Represent Function Parameter expression
func (*ParameterLiteral) String ¶
func (p *ParameterLiteral) String() string
type PrefixExpression ¶
type PrefixExpression struct { Operator Right Expression }
Represent prefix expression
func (*PrefixExpression) String ¶
func (p *PrefixExpression) String() string
type ReassignStatement ¶
type ReassignStatement struct { Variable *Identifier Value Expression }
ReassignStatement is used when we want re-assign value to variable
func (*ReassignStatement) String ¶
func (r *ReassignStatement) String() string
type ReturnStatement ¶
type ReturnStatement struct {
ReturnValue Expression
}
Represent return statement
func (*ReturnStatement) String ¶
func (r *ReturnStatement) String() string
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
Represent Statement
type StringLiteral ¶
type StringLiteral struct {
Value string
}
Represent string literal
func (*StringLiteral) String ¶
func (s *StringLiteral) String() string