internal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvaluatePostfix

func EvaluatePostfix(tokens []*Token) (float64, error)

func ValidateTokens

func ValidateTokens(tokens []*Token) []error

Types

type ParseError

type ParseError struct {
	Message  string
	Position int
	Got      string
	Expected string
}

func (*ParseError) Error

func (e *ParseError) Error() string

type Token

type Token struct {
	Type     TokenType
	Value    string
	Position int
}

func NewToken

func NewToken(t TokenType, v string, p int) *Token

func ToPostfix

func ToPostfix(tokens []*Token) []*Token

func Tokenize

func Tokenize(expression string) []*Token

func (*Token) String

func (t *Token) String() string

type TokenType

type TokenType string
const (
	NUMBER_TOKEN   TokenType = "Number"
	OPERATOR_TOKEN TokenType = "Operator"
	LPAREN_TOKEN   TokenType = "Left parenthesis"
	RPAREN_TOKEN   TokenType = "Right parenthesis"
	INVALID_TOKEN  TokenType = "Invalid"
)

Jump to

Keyboard shortcuts

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