shuntingyard

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Operator

type Operator interface {
	IsUnary() bool
	IsBinary() bool
	EvaluatesBefore(Operator) bool

	Precedence() int
	IsSentinel() bool
	Symbol() string
}
var Sentinel Operator = NewWithDefault("S", 0)

func New

func New(symbol string, precedence int, operandCount int, leftAssociative bool) Operator

func NewWithDefault

func NewWithDefault(symbol string, precedence int) Operator

type OperatorImpl

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

func (OperatorImpl) EvaluatesBefore

func (thisOp OperatorImpl) EvaluatesBefore(other Operator) bool

func (OperatorImpl) IsBinary

func (o OperatorImpl) IsBinary() bool

func (OperatorImpl) IsSentinel

func (o OperatorImpl) IsSentinel() bool

func (OperatorImpl) IsUnary

func (o OperatorImpl) IsUnary() bool

func (OperatorImpl) Precedence

func (o OperatorImpl) Precedence() int

func (OperatorImpl) Symbol

func (o OperatorImpl) Symbol() string

type ShuntingYardState

type ShuntingYardState[T any] struct {
	Operands  Stack[T]
	Operators Stack[Operator]
}

func NewShuntingYardState

func NewShuntingYardState[T any]() ShuntingYardState[T]

type Stack

type Stack[T any] interface {
	Push(T)
	Pop() (T, bool)
	Top() (T, bool)
}

func NewStack

func NewStack[T any]() Stack[T]

type StackImpl

type StackImpl[T any] struct {
	// contains filtered or unexported fields
}

func (*StackImpl[T]) Pop

func (s *StackImpl[T]) Pop() (T, bool)

func (*StackImpl[T]) Push

func (s *StackImpl[T]) Push(v T)

func (StackImpl[T]) Top

func (s StackImpl[T]) Top() (T, bool)

Jump to

Keyboard shortcuts

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