parser

package
v0.0.0-...-e1a96a7 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedToken = errors.New("unexpected token")

Functions

This section is empty.

Types

type AssignNode

type AssignNode struct {
	Name  tokens.Token
	Value Node
}

func (*AssignNode) Eval

func (n *AssignNode) Eval(env *Env) (*unified.Real, error)

type BinaryNode

type BinaryNode struct {
	Op    tokens.Token
	Left  Node
	Right Node
}

func (*BinaryNode) Eval

func (n *BinaryNode) Eval(env *Env) (*unified.Real, error)

type CommentNode

type CommentNode struct {
	Text string
	Tok  tokens.Token
	Expr Node
}

func (*CommentNode) Eval

func (n *CommentNode) Eval(env *Env) (*unified.Real, error)

type Env

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

func NewEnv

func NewEnv() *Env

NewEnv creates a new environment with default precision (-100).

func (*Env) Get

func (e *Env) Get(name string) (*unified.Real, bool)

func (*Env) Set

func (e *Env) Set(name string, val *unified.Real) error

func (*Env) SetDecimalPlaces

func (e *Env) SetDecimalPlaces(decimalPlaces int)

func (*Env) SetPrecision

func (e *Env) SetPrecision(precision int)

func (*Env) SetTrace

func (e *Env) SetTrace(enabled bool)

func (*Env) SetTraceOutput

func (e *Env) SetTraceOutput(w io.Writer)

type IdentNode

type IdentNode struct {
	Name tokens.Token
}

func (*IdentNode) Eval

func (n *IdentNode) Eval(env *Env) (*unified.Real, error)

type Node

type Node interface {
	Eval(*Env) (*unified.Real, error)
}

func Parse

func Parse(name, src string) (Node, error)

type NumberNode

type NumberNode struct {
	Value *unified.Real
}

func (*NumberNode) Eval

func (n *NumberNode) Eval(_ *Env) (*unified.Real, error)

type P

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

func New

func New(name, src string) *P

func (*P) Parse

func (p *P) Parse() (Node, error)

type UnaryNode

type UnaryNode struct {
	Op   tokens.Token
	Expr Node
}

func (*UnaryNode) Eval

func (n *UnaryNode) Eval(env *Env) (*unified.Real, error)

Jump to

Keyboard shortcuts

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