ast

package
v0.0.0-...-441c9b0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayLiteral

type ArrayLiteral struct {
	Op     string       `json:"op"`
	Values []Expression `json:"values"`
}

func NewArrayLiteral

func NewArrayLiteral(vals []Expression) *ArrayLiteral

type AssignmentStatement

type AssignmentStatement struct {
	Op    string     `json:"op"`
	Var   string     `json:"var"`
	Value Expression `json:"value"`
}

func NewAssignmentStatement

func NewAssignmentStatement(varName string, value Expression) *AssignmentStatement

type BlockStatement

type BlockStatement struct {
	Op  string      `json:"op"`
	Seq []Statement `json:"seq"`
}

func NewBlockStatement

func NewBlockStatement(seq ...Statement) *BlockStatement

type Boolean

type Boolean bool

type Case

type Case struct {
	Op        string     `json:"op"`
	Condition Expression `json:"condidion"` // This typo is present in the language definition
	Result    Statement  `json:"result"`
}

type Conditional

type Conditional struct {
	Condition   Expression      `json:"if"`
	Consequence *BlockStatement `json:"then"`
}

type Expression

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

Expression denotes an internal node, such as numeric or string literals, infix operator expressions, or identifier expressions

func NewFunctionCall

func NewFunctionCall(fName string, args ...Expression) Expression

func NewFunctionCallNamedArgs

func NewFunctionCallNamedArgs(fName string, args map[string]Expression) Expression

func NewInfixExpression

func NewInfixExpression(tok token.Type, left, right Expression) Expression

func NewPrefixExpression

func NewPrefixExpression(tok token.Type, right Expression) Expression

type FloatLiteral

type FloatLiteral float64

type FunctionCallManyArgs

type FunctionCallManyArgs struct {
	Values []Expression `json:"values"`
	Op     string       `json:"op"`
}

type FunctionCallNoArgs

type FunctionCallNoArgs struct {
	Op string `json:"op"`
}

type FunctionCallOneArg

type FunctionCallOneArg struct {
	Value Expression `json:"value"`
	Op    string     `json:"op"`
}

type Identifier

type Identifier struct {
	Op  string `json:"op"`
	Var string `json:"var"`
}

func NewIdentifierExpression

func NewIdentifierExpression(varName string) *Identifier

type IfStatement

type IfStatement struct {
	Op   string        `json:"op"`
	Cond []Conditional `json:"cond"`
}

func NewIfStatement

func NewIfStatement(cond ...Conditional) *IfStatement

type IndexExpression

type IndexExpression struct {
	Op    string     `json:"op"`
	Base  Expression `json:"base"`
	Index Expression `json:"index"`
}

func NewIndexExpression

func NewIndexExpression(base, index Expression) *IndexExpression

type InfixExpressionLeftRight

type InfixExpressionLeftRight struct {
	Op    string     `json:"op"`
	Left  Expression `json:"left"`
	Right Expression `json:"right"`
}

type InfixExpressionValues

type InfixExpressionValues struct {
	Op     string        `json:"op"`
	Values [2]Expression `json:"values"`
}

type IntegerLiteral

type IntegerLiteral int64

type JSONLiteral

type JSONLiteral struct {
	Op    string      `json:"op"`
	Value interface{} `json:"value"`
}

JSONLiteral can be a JSON array, map, string, or number

func NewJSONLiteral

func NewJSONLiteral(val interface{}) *JSONLiteral

type NamedArgs

type NamedArgs map[string]Expression

type NullLiteral

type NullLiteral struct{}

func NewNull

func NewNull() *NullLiteral

func (*NullLiteral) MarshalJSON

func (nl *NullLiteral) MarshalJSON() ([]byte, error)

type PrefixExpression

type PrefixExpression struct {
	Op    string     `json:"op"`
	Value Expression `json:"value"`
}

type Program

type Program struct {
	Op  string      `json:"op"`
	Seq []Statement `json:"seq"`
}

func NewProgram

func NewProgram() *Program

type ReturnStatement

type ReturnStatement struct {
	Op    string     `json:"op"`
	Value Expression `json:"value"`
}

func NewReturnStatement

func NewReturnStatement(value Expression) *ReturnStatement

type Statement

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

Statement denotes a top-level node such as an if statement, assignment statement, or return statement

type StringLiteral

type StringLiteral string

type SwitchStatement

type SwitchStatement struct {
	Op    string `json:"op"`
	Cases []Case `json:"cases"`
}

func NewSwitchStatement

func NewSwitchStatement(cases ...Case) *SwitchStatement

Jump to

Keyboard shortcuts

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