ast

package
v0.0.0-...-402e600 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2017 License: GPL-3.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgumentDeclaration

type ArgumentDeclaration struct {
	Name *IdentExpression
	Type types.Type
}

func (*ArgumentDeclaration) First

func (e *ArgumentDeclaration) First() lexer.Token

func (*ArgumentDeclaration) Last

func (e *ArgumentDeclaration) Last() lexer.Token

type AssignmentStatement

type AssignmentStatement struct {
	Left   Expression
	Assign lexer.Token
	Right  Expression
}

AssignmentStatement is a statement in the form: expression = expression

func (*AssignmentStatement) First

func (e *AssignmentStatement) First() lexer.Token

func (*AssignmentStatement) Last

func (e *AssignmentStatement) Last() lexer.Token

type Ast

type Ast struct {
	Scope     *Scope
	Functions []*FunctionDeclaration
}

type BinaryExpression

type BinaryExpression struct {
	IsFp     bool
	Left     Expression
	Operator lexer.Token
	Right    Expression
}

BinaryExpression is an expression in the form: expression operator expression

func (*BinaryExpression) First

func (e *BinaryExpression) First() lexer.Token

func (*BinaryExpression) Last

func (e *BinaryExpression) Last() lexer.Token

type BlockStatement

type BlockStatement struct {
	Scope      *Scope
	LeftBrace  lexer.Token
	Statements []Statement
	RightBrace lexer.Token
}

BlockStatement is a statement in the form: {statement; statement; ...}

func (*BlockStatement) First

func (e *BlockStatement) First() lexer.Token

func (*BlockStatement) Last

func (e *BlockStatement) Last() lexer.Token

type BraceLiteralExpression

type BraceLiteralExpression struct {
	Type       types.Type
	LeftBrace  lexer.Token
	Elements   []Expression
	RightBrace lexer.Token
}

BraceLiteralExpression is an expression in the form: type{expression, expression, ...}

func (*BraceLiteralExpression) First

func (e *BraceLiteralExpression) First() lexer.Token

func (*BraceLiteralExpression) Last

type CallExpression

type CallExpression struct {
	Function  Expression
	Arguments *ParenLiteralExpression
}

CallExpression is an expression in the form: expression(expression, expression, ...)

func (*CallExpression) First

func (e *CallExpression) First() lexer.Token

func (*CallExpression) Last

func (e *CallExpression) Last() lexer.Token

type CastExpression

type CastExpression struct {
	LeftParen  lexer.Token
	Type       types.Type
	RightParen lexer.Token
	Expression Expression
}

CastExpression is an expression in the form: (type)expression

func (*CastExpression) First

func (e *CastExpression) First() lexer.Token

func (*CastExpression) Last

func (e *CastExpression) Last() lexer.Token

type Declare

type Declare interface {
	Node
	// contains filtered or unexported methods
}

type DeclareStatement

type DeclareStatement struct {
	Statement Declare
}

func (*DeclareStatement) First

func (e *DeclareStatement) First() lexer.Token

func (*DeclareStatement) Last

func (e *DeclareStatement) Last() lexer.Token

type Expression

type Expression interface {
	Node
	// contains filtered or unexported methods
}

type ForStatement

type ForStatement struct {
	For       lexer.Token
	Index     Statement
	Semi1     lexer.Token
	Condition Expression
	Semi2     lexer.Token
	Increment Statement
	Body      *BlockStatement
}

ForStatement is a statement in the form: for statement; expression; statement {statement; ...}

func (*ForStatement) First

func (e *ForStatement) First() lexer.Token

func (*ForStatement) Last

func (e *ForStatement) Last() lexer.Token

type FunctionDeclaration

type FunctionDeclaration struct {
	Name        *IdentExpression
	DoubleColon lexer.Token
	Arguments   []*ArgumentDeclaration
	Return      types.Type
	Body        *BlockStatement
}

FunctionDeclaration is a declare node in the form: ident :: type ident, ... -> type { statement; ... }

func (*FunctionDeclaration) First

func (e *FunctionDeclaration) First() lexer.Token

func (*FunctionDeclaration) Last

func (e *FunctionDeclaration) Last() lexer.Token

type IdentExpression

type IdentExpression struct {
	Value lexer.Token
}

IdentExpression is any identifier

func (*IdentExpression) First

func (e *IdentExpression) First() lexer.Token

func (*IdentExpression) Last

func (e *IdentExpression) Last() lexer.Token

type IfStatment

type IfStatment struct {
	If        lexer.Token
	Condition Expression
	Body      *BlockStatement
	Else      *IfStatment
}

IfStatment is a statement in the form: if expression {statement; ...} ...

func (*IfStatment) First

func (e *IfStatment) First() lexer.Token

func (*IfStatment) Last

func (e *IfStatment) Last() lexer.Token

type IndexExpression

type IndexExpression struct {
	Expression Expression
	LeftBrack  lexer.Token
	Index      Expression
	RightBrack lexer.Token
}

IndexExpression is an expression in the form: expression[expression]

func (*IndexExpression) First

func (e *IndexExpression) First() lexer.Token

func (*IndexExpression) Last

func (e *IndexExpression) Last() lexer.Token

type LiteralExpression

type LiteralExpression struct {
	Value lexer.Token
}

LiteralExpression is an expression in the form: interger || float || string

func (*LiteralExpression) First

func (e *LiteralExpression) First() lexer.Token

func (*LiteralExpression) Last

func (e *LiteralExpression) Last() lexer.Token

type Node

type Node interface {
	// First returns the first token beloning to the node
	First() lexer.Token
	// Last returnst the last token beloning to the node
	Last() lexer.Token
}

type ParenLiteralExpression

type ParenLiteralExpression struct {
	LeftParen  lexer.Token
	Elements   []Expression
	RightParen lexer.Token
}

ParenLiteralExpression is an expression in the form: (expression, expression, ...)

func (*ParenLiteralExpression) First

func (e *ParenLiteralExpression) First() lexer.Token

func (*ParenLiteralExpression) Last

type ReturnStatement

type ReturnStatement struct {
	Return lexer.Token
	Result Expression
}

ReturnStatement is a statement in the form: return expression

func (*ReturnStatement) First

func (e *ReturnStatement) First() lexer.Token

func (*ReturnStatement) Last

func (e *ReturnStatement) Last() lexer.Token

type Scope

type Scope struct {
	// contains filtered or unexported fields
}

func NewScope

func NewScope() *Scope

NewScope creates a new blank scope

func (*Scope) Enter

func (s *Scope) Enter() *Scope

Enter creates a new inner scope

func (*Scope) Exit

func (s *Scope) Exit() *Scope

Exit returns the outer scope

func (*Scope) Insert

func (s *Scope) Insert(name string, node Node)

Insert adds a new declaration to the current scope

func (*Scope) Lookup

func (s *Scope) Lookup(name string) Node

Lookup returns the node in the most inner scope

func (*Scope) Replace

func (s *Scope) Replace(name string, node Node) bool

type SliceExpression

type SliceExpression struct {
	Expression Expression
	LeftBrack  lexer.Token
	Low        Expression
	Colon      lexer.Token
	High       Expression
	RightBrack lexer.Token
}

SliceExpression represents an expression in the form: expression[expression:expression]

func (*SliceExpression) First

func (e *SliceExpression) First() lexer.Token

func (*SliceExpression) Last

func (e *SliceExpression) Last() lexer.Token

type Statement

type Statement interface {
	Node
	// contains filtered or unexported methods
}

type TypeExpression

type TypeExpression struct {
	Type types.Type
}

TypeExpression is a type

func (*TypeExpression) First

func (e *TypeExpression) First() lexer.Token

func (*TypeExpression) Last

func (e *TypeExpression) Last() lexer.Token

type UnaryExpression

type UnaryExpression struct {
	Operator   lexer.Token
	Expression Expression
}

UnaryExpression is an expression in the form: operator expression

func (*UnaryExpression) First

func (e *UnaryExpression) First() lexer.Token

func (*UnaryExpression) Last

func (e *UnaryExpression) Last() lexer.Token

type VaribleDeclaration

type VaribleDeclaration struct {
	Type  types.Type
	Name  *IdentExpression
	Value Expression
}

VaribleDeclaration is a declare node in the form: ident := expression || type ident = expression

func (*VaribleDeclaration) First

func (e *VaribleDeclaration) First() lexer.Token

func (*VaribleDeclaration) Last

func (e *VaribleDeclaration) Last() lexer.Token

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL