ast

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package ast declares abstract syntax tree types for acc programs.

Index

Constants

View Source
const (
	LowestPrec  = 0
	HighestPrec = 4
)

Operator precedence range.

Variables

This section is empty.

Functions

func Fprint

func Fprint(w io.Writer, n interface{}) error

Fprint writes the AST node n to w.

func IsOp

func IsOp(e Expr) bool

IsOp reports whether the expression is the result of an operator.

func Print

func Print(n interface{}) error

Print an AST node to standard out.

Types

type Add

type Add struct {
	X, Y Expr
}

Add expression.

func (Add) Precedence

func (Add) Precedence() int

Precedence of this expression type.

type Chain

type Chain struct {
	Statements []Statement
}

Chain represents a sequence of acc statements for an addition chain computation.

type Double

type Double struct {
	X Expr
}

Double expression.

func (Double) Precedence

func (Double) Precedence() int

Precedence of this expression type.

type Expr

type Expr interface {
	Precedence() int
}

Expr is an expression.

type Identifier

type Identifier string

Identifier is a variable reference.

func (Identifier) Precedence

func (Identifier) Precedence() int

Precedence of this expression type.

type Operand

type Operand int

Operand is an index into an addition chain.

func (Operand) Precedence

func (Operand) Precedence() int

Precedence of this expression type.

type Shift

type Shift struct {
	X Expr
	S uint
}

Shift (repeated doubling) expression.

func (Shift) Precedence

func (Shift) Precedence() int

Precedence of this expression type.

type Statement

type Statement struct {
	Name Identifier
	Expr Expr
}

Statement assigns the result of an expression to a variable.

Jump to

Keyboard shortcuts

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