mathtoken

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 4 Imported by: 1

README

mathtoken

-- import "github.com/darylnwk/mathtoken"

Usage

type Associativity
type Associativity uint

Associativity defines token associativity data type

const (
	// AssociativityNone defines a token has no associativity
	AssociativityNone Associativity = iota
	// AssociativityLeft defines a token is left associative
	AssociativityLeft
	// AssociativityRight defines a token is right associative
	AssociativityRight
)
type Token
type Token struct {
	Type          Type
	Value         string
	Associativity Associativity
	Precedence    uint
}

Token defines a mathematical expression token

type Tokens
type Tokens []Token

Tokens defines a list of Token

func Parse
func Parse(s string) (tokens Tokens, err error)

Parse mathematical expression in infix format to Tokens and returns error if unknown token found

type Type
type Type uint

Type defines token type data type

const (
	TypeUnknown Type = iota
	TypeSpace
	TypeLParent
	TypeRParent
	TypeConstant
	TypeVariable
	TypeOperator
)

List of token types

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Associativity added in v1.1.0

type Associativity uint

Associativity defines token associativity data type

const (
	// AssociativityNone defines a token has no associativity
	AssociativityNone Associativity = iota
	// AssociativityLeft defines a token is left associative
	AssociativityLeft
	// AssociativityRight defines a token is right associative
	AssociativityRight
)

type Token

type Token struct {
	Type          Type
	Value         string
	Associativity Associativity
	Precedence    uint
}

Token defines a mathematical expression token

type Tokens

type Tokens []Token

Tokens defines a list of `Token`

func Parse

func Parse(s string) (tokens Tokens, err error)

Parse mathematical expression in infix format to `Tokens` and returns error if unknown token found

type Type

type Type uint

Type defines token type data type

const (
	TypeUnknown Type = iota
	TypeSpace
	TypeLParent
	TypeRParent
	TypeConstant
	TypeVariable
	TypeOperator
)

List of token types

Jump to

Keyboard shortcuts

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