ast

package
v0.0.0-...-47a6bde Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2017 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ast declares the types used to represent syntax trees for mathematical expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryExpr

type BinaryExpr struct {
	Op string
	X  Expr
	Y  Expr
}

BinaryExpr represents a binary expression.

func (*BinaryExpr) Eval

func (expr *BinaryExpr) Eval() float64

Eval calculates the value of a binary expression.

type Expr

type Expr interface {
	Eval() float64
}

Expr represents a node in the syntax tree.

type Number

type Number struct {
	Value float64
}

Number represents a number.

func (*Number) Eval

func (expr *Number) Eval() float64

Eval returns the value of a number.

type UnaryExpr

type UnaryExpr struct {
	Op string
	X  Expr
}

UnaryExpr represents a unary expression.

func (*UnaryExpr) Eval

func (expr *UnaryExpr) Eval() float64

Eval calculates the value of a unary expression.

Jump to

Keyboard shortcuts

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