ast

package
v0.0.0-...-2dc9ae7 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package ast defines the Abstract Syntax Tree for our language.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayLiteral

type ArrayLiteral struct {
	Token    token.Token // The '[' token
	Elements []Expression
}

ArrayLiteral represents a prefix expression.

func (*ArrayLiteral) String

func (al *ArrayLiteral) String() string

String returns the string representation of the Node.

func (*ArrayLiteral) TokenLiteral

func (al *ArrayLiteral) TokenLiteral() string

TokenLiteral returns the token literal.

type BlockStatement

type BlockStatement struct {
	Token      token.Token // The "if" token
	Statements []Statement
}

BlockStatement represents a block statement.

func (*BlockStatement) String

func (bs *BlockStatement) String() string

String returns the string representation of the Node.

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

TokenLiteral returns the token literal.

type BooleanLiteral

type BooleanLiteral struct {
	Token token.Token
	Value bool
}

BooleanLiteral represents a boolean literal.

func (*BooleanLiteral) String

func (bl *BooleanLiteral) String() string

String returns the string representation of the Node.

func (*BooleanLiteral) TokenLiteral

func (bl *BooleanLiteral) TokenLiteral() string

TokenLiteral returns the token literal.

type CallExpression

type CallExpression struct {
	Token     token.Token // The "(" token
	Function  Expression
	Arguments []Expression
}

CallExpression represents a call expression.

func (*CallExpression) String

func (ce *CallExpression) String() string

String returns the string representation of the Node.

func (*CallExpression) TokenLiteral

func (ce *CallExpression) TokenLiteral() string

TokenLiteral returns the token literal.

type CirclePrimitive

type CirclePrimitive struct {
	Token     token.Token
	Arguments []Expression
}

CirclePrimitive represents a CSG primitive.

func (*CirclePrimitive) String

func (cp *CirclePrimitive) String() string

String returns the string representation of the Node.

func (*CirclePrimitive) TokenLiteral

func (cp *CirclePrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type ColorBlockPrimitive

type ColorBlockPrimitive struct {
	Token     token.Token
	Arguments []Expression
	Body      *BlockStatement
}

ColorBlockPrimitive represents a CSG block primitive.

func (*ColorBlockPrimitive) String

func (cbp *ColorBlockPrimitive) String() string

String returns the string representation of the Node.

func (*ColorBlockPrimitive) TokenLiteral

func (cbp *ColorBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type CubePrimitive

type CubePrimitive struct {
	Token     token.Token
	Arguments []Expression
}

CubePrimitive represents a CSG primitive.

func (*CubePrimitive) String

func (cp *CubePrimitive) String() string

String returns the string representation of the Node.

func (*CubePrimitive) TokenLiteral

func (cp *CubePrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type CylinderPrimitive

type CylinderPrimitive struct {
	Token     token.Token
	Arguments []Expression
}

CylinderPrimitive represents a CSG primitive.

func (*CylinderPrimitive) String

func (cp *CylinderPrimitive) String() string

String returns the string representation of the Node.

func (*CylinderPrimitive) TokenLiteral

func (cp *CylinderPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type DifferenceBlockPrimitive

type DifferenceBlockPrimitive struct {
	Token token.Token
	Body  *BlockStatement
}

DifferenceBlockPrimitive represents a CSG block primitive.

func (*DifferenceBlockPrimitive) String

func (dbp *DifferenceBlockPrimitive) String() string

String returns the string representation of the Node.

func (*DifferenceBlockPrimitive) TokenLiteral

func (dbp *DifferenceBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type Expression

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

Expression respresents an expression in our abstract syntax tree.

type ExpressionStatement

type ExpressionStatement struct {
	Token      token.Token // the first token of the expression
	Expression Expression
}

ExpressionStatement represents an expression statement.

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

String returns the string representation of the Node.

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

TokenLiteral returns the token literal.

type FloatLiteral

type FloatLiteral struct {
	Token token.Token
	Value float64
}

FloatLiteral represents a float literal.

func (*FloatLiteral) String

func (fl *FloatLiteral) String() string

String returns the string representation of the Node.

func (*FloatLiteral) TokenLiteral

func (fl *FloatLiteral) TokenLiteral() string

TokenLiteral returns the token literal.

type FunctionLiteral

type FunctionLiteral struct {
	Token      token.Token // The "function" token
	Parameters []*Identifier
	Body       *BlockStatement
}

FunctionLiteral represents a function literal.

func (*FunctionLiteral) String

func (fl *FunctionLiteral) String() string

String returns the string representation of the Node.

func (*FunctionLiteral) TokenLiteral

func (fl *FunctionLiteral) TokenLiteral() string

TokenLiteral returns the token literal.

type GroupBlockPrimitive

type GroupBlockPrimitive struct {
	Token token.Token
	Body  *BlockStatement
}

GroupBlockPrimitive represents a CSG block primitive.

func (*GroupBlockPrimitive) String

func (gbp *GroupBlockPrimitive) String() string

String returns the string representation of the Node.

func (*GroupBlockPrimitive) TokenLiteral

func (gbp *GroupBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type GroupPrimitive

type GroupPrimitive struct {
	Token     token.Token
	Arguments []Expression
}

GroupPrimitive represents a CSG primitive.

func (*GroupPrimitive) String

func (gp *GroupPrimitive) String() string

String returns the string representation of the Node.

func (*GroupPrimitive) TokenLiteral

func (gp *GroupPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type HashLiteral

type HashLiteral struct {
	Token token.Token // The '{' token
	Pairs map[Expression]Expression
}

HashLiteral represents a prefix expression.

func (*HashLiteral) String

func (hl *HashLiteral) String() string

String returns the string representation of the Node.

func (*HashLiteral) TokenLiteral

func (hl *HashLiteral) TokenLiteral() string

TokenLiteral returns the token literal.

type HullBlockPrimitive

type HullBlockPrimitive struct {
	Token token.Token
	Body  *BlockStatement
}

HullBlockPrimitive represents a CSG block primitive.

func (*HullBlockPrimitive) String

func (hbp *HullBlockPrimitive) String() string

String returns the string representation of the Node.

func (*HullBlockPrimitive) TokenLiteral

func (hbp *HullBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type Identifier

type Identifier struct {
	Token token.Token // the token.IDENT token
	Value string
}

Identifier represents an identifier.

func (*Identifier) String

func (i *Identifier) String() string

String returns the string representation of the Node.

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

TokenLiteral returns the token literal.

type IfExpression

type IfExpression struct {
	Token       token.Token // The "if" token
	Condition   Expression
	Consequence *BlockStatement
	Alternative *BlockStatement
}

IfExpression represents an "if" expression.

func (*IfExpression) String

func (ie *IfExpression) String() string

String returns the string representation of the Node.

func (*IfExpression) TokenLiteral

func (ie *IfExpression) TokenLiteral() string

TokenLiteral returns the token literal.

type IndexExpression

type IndexExpression struct {
	Token token.Token // The '[' token
	Left  Expression
	Index Expression
}

IndexExpression represents a prefix expression.

func (*IndexExpression) String

func (ie *IndexExpression) String() string

String returns the string representation of the Node.

func (*IndexExpression) TokenLiteral

func (ie *IndexExpression) TokenLiteral() string

TokenLiteral returns the token literal.

type InfixExpression

type InfixExpression struct {
	Token    token.Token // The infix token, e.g. ==
	Left     Expression
	Operator string
	Right    Expression
}

InfixExpression represents an infix expression.

func (*InfixExpression) String

func (pe *InfixExpression) String() string

String returns the string representation of the Node.

func (*InfixExpression) TokenLiteral

func (pe *InfixExpression) TokenLiteral() string

TokenLiteral returns the token literal.

type IntegerLiteral

type IntegerLiteral struct {
	Token token.Token
	Value int64
}

IntegerLiteral represents an integer literal.

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

String returns the string representation of the Node.

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

TokenLiteral returns the token literal.

type IntersectionBlockPrimitive

type IntersectionBlockPrimitive struct {
	Token token.Token
	Body  *BlockStatement
}

IntersectionBlockPrimitive represents a CSG block primitive.

func (*IntersectionBlockPrimitive) String

func (ibp *IntersectionBlockPrimitive) String() string

String returns the string representation of the Node.

func (*IntersectionBlockPrimitive) TokenLiteral

func (ibp *IntersectionBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type LetStatement

type LetStatement struct {
	Token token.Token // the token.LET token
	Name  *Identifier
	Value Expression
}

LetStatement represents a 'let' statement.

func (*LetStatement) String

func (ls *LetStatement) String() string

String returns the string representation of the Node.

func (*LetStatement) TokenLiteral

func (ls *LetStatement) TokenLiteral() string

TokenLiteral returns the token literal.

type LineComment

type LineComment struct {
	Token token.Token // the token.IDENT token
	Value string
}

LineComment represents a line comment.

func (*LineComment) String

func (i *LineComment) String() string

String returns the string representation of the Node.

func (*LineComment) TokenLiteral

func (i *LineComment) TokenLiteral() string

TokenLiteral returns the token literal.

type LinearExtrudeBlockPrimitive

type LinearExtrudeBlockPrimitive struct {
	Token     token.Token
	Arguments []Expression
	Body      *BlockStatement
}

LinearExtrudeBlockPrimitive represents a CSG block primitive.

func (*LinearExtrudeBlockPrimitive) String

func (lebp *LinearExtrudeBlockPrimitive) String() string

String returns the string representation of the Node.

func (*LinearExtrudeBlockPrimitive) TokenLiteral

func (lebp *LinearExtrudeBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type MinkowskiBlockPrimitive

type MinkowskiBlockPrimitive struct {
	Token     token.Token
	Arguments []Expression
	Body      *BlockStatement
}

MinkowskiBlockPrimitive represents a CSG block primitive.

func (*MinkowskiBlockPrimitive) String

func (mbp *MinkowskiBlockPrimitive) String() string

String returns the string representation of the Node.

func (*MinkowskiBlockPrimitive) TokenLiteral

func (mbp *MinkowskiBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type MultmatrixBlockPrimitive

type MultmatrixBlockPrimitive struct {
	Token     token.Token
	Arguments []Expression
	Body      *BlockStatement
}

MultmatrixBlockPrimitive represents a CSG block primitive.

func (*MultmatrixBlockPrimitive) String

func (mbp *MultmatrixBlockPrimitive) String() string

String returns the string representation of the Node.

func (*MultmatrixBlockPrimitive) TokenLiteral

func (mbp *MultmatrixBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type NamedArgument

type NamedArgument struct {
	Token token.Token
	Name  Expression
	Value Expression
}

NamedArgument represents a CSG named argument.

func (*NamedArgument) String

func (cp *NamedArgument) String() string

String returns the string representation of the Node.

func (*NamedArgument) TokenLiteral

func (cp *NamedArgument) TokenLiteral() string

TokenLiteral returns the token literal.

type Node

type Node interface {
	String() string
	TokenLiteral() string
}

Node represents a node in our abstract syntax tree.

type PolygonPrimitive

type PolygonPrimitive struct {
	Token     token.Token
	Arguments []Expression
}

PolygonPrimitive represents a CSG primitive.

func (*PolygonPrimitive) String

func (pp *PolygonPrimitive) String() string

String returns the string representation of the Node.

func (*PolygonPrimitive) TokenLiteral

func (pp *PolygonPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type PolyhedronPrimitive

type PolyhedronPrimitive struct {
	Token     token.Token
	Arguments []Expression
}

PolyhedronPrimitive represents a CSG primitive.

func (*PolyhedronPrimitive) String

func (pp *PolyhedronPrimitive) String() string

String returns the string representation of the Node.

func (*PolyhedronPrimitive) TokenLiteral

func (pp *PolyhedronPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type PrefixExpression

type PrefixExpression struct {
	Token    token.Token // The prefix token, e.g. !
	Operator string
	Right    Expression
}

PrefixExpression represents a prefix expression.

func (*PrefixExpression) String

func (pe *PrefixExpression) String() string

String returns the string representation of the Node.

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

TokenLiteral returns the token literal.

type Program

type Program struct {
	Statements []Statement
}

Program represents a program using our abstract syntax tree.

func (*Program) String

func (p *Program) String() string

String returns the string representation of the Node.

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

TokenLiteral returns the first token literal of the program.

type ProjectionBlockPrimitive

type ProjectionBlockPrimitive struct {
	Token     token.Token
	Arguments []Expression
	Body      *BlockStatement
}

ProjectionBlockPrimitive represents a CSG block primitive.

func (*ProjectionBlockPrimitive) String

func (pbp *ProjectionBlockPrimitive) String() string

String returns the string representation of the Node.

func (*ProjectionBlockPrimitive) TokenLiteral

func (pbp *ProjectionBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type ReturnStatement

type ReturnStatement struct {
	Token       token.Token // the token.RETURN token
	ReturnValue Expression
}

ReturnStatement respresents a 'return' statement.

func (*ReturnStatement) String

func (rs *ReturnStatement) String() string

String returns the string representation of the Node.

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

TokenLiteral returns the token literal.

type RotateExtrudeBlockPrimitive

type RotateExtrudeBlockPrimitive struct {
	Token     token.Token
	Arguments []Expression
	Body      *BlockStatement
}

RotateExtrudeBlockPrimitive represents a CSG block primitive.

func (*RotateExtrudeBlockPrimitive) String

func (rebp *RotateExtrudeBlockPrimitive) String() string

String returns the string representation of the Node.

func (*RotateExtrudeBlockPrimitive) TokenLiteral

func (rebp *RotateExtrudeBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type SpherePrimitive

type SpherePrimitive struct {
	Token     token.Token
	Arguments []Expression
}

SpherePrimitive represents a CSG primitive.

func (*SpherePrimitive) String

func (sp *SpherePrimitive) String() string

String returns the string representation of the Node.

func (*SpherePrimitive) TokenLiteral

func (sp *SpherePrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type SquarePrimitive

type SquarePrimitive struct {
	Token     token.Token
	Arguments []Expression
}

SquarePrimitive represents a CSG primitive.

func (*SquarePrimitive) String

func (sp *SquarePrimitive) String() string

String returns the string representation of the Node.

func (*SquarePrimitive) TokenLiteral

func (sp *SquarePrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type Statement

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

Statement represents a statement in our abstract syntax tree.

type StringLiteral

type StringLiteral struct {
	Token token.Token
	Value string
}

StringLiteral represents a string literal.

func (*StringLiteral) String

func (sl *StringLiteral) String() string

String returns the string representation of the Node.

func (*StringLiteral) TokenLiteral

func (sl *StringLiteral) TokenLiteral() string

TokenLiteral returns the token literal.

type TextPrimitive

type TextPrimitive struct {
	Token     token.Token
	Arguments []Expression
}

TextPrimitive represents a CSG primitive.

func (*TextPrimitive) String

func (tp *TextPrimitive) String() string

String returns the string representation of the Node.

func (*TextPrimitive) TokenLiteral

func (tp *TextPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

type UndefLiteral

type UndefLiteral struct {
	Token token.Token
}

UndefLiteral represents a undef literal.

func (*UndefLiteral) String

func (tp *UndefLiteral) String() string

String returns the string representation of the Node.

func (*UndefLiteral) TokenLiteral

func (tp *UndefLiteral) TokenLiteral() string

TokenLiteral returns the token literal.

type UnionBlockPrimitive

type UnionBlockPrimitive struct {
	Token token.Token
	Body  *BlockStatement
}

UnionBlockPrimitive represents a CSG block primitive.

func (*UnionBlockPrimitive) String

func (ubp *UnionBlockPrimitive) String() string

String returns the string representation of the Node.

func (*UnionBlockPrimitive) TokenLiteral

func (ubp *UnionBlockPrimitive) TokenLiteral() string

TokenLiteral returns the token literal.

Jump to

Keyboard shortcuts

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