parse

package
v0.0.0-...-718ef90 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeScript   = "script"
	ModePipeline = "pipeline"
	ModeCube     = "cube"
	ModeCommand  = "command"
	ModeFormula  = "formula"
)

Variables

This section is empty.

Functions

func DumpExpr

func DumpExpr(expr Expr) string

Types

type Access

type Access struct {
	Position
	// contains filtered or unexported fields
}

func (Access) Accept

func (a Access) Accept(v Visitor) error

func (Access) KindOf

func (Access) KindOf() string

func (Access) Object

func (a Access) Object() Expr

func (Access) Property

func (a Access) Property() string

func (Access) String

func (a Access) String() string

type And

type And struct {
	Position
	// contains filtered or unexported fields
}

func (And) Accept

func (a And) Accept(v Visitor) error

func (And) Left

func (a And) Left() Expr

func (And) Right

func (a And) Right() Expr

func (And) String

func (a And) String() string

type Assignment

type Assignment struct {
	Position
	// contains filtered or unexported fields
}

func (Assignment) Accept

func (a Assignment) Accept(v Visitor) error

func (Assignment) Expr

func (a Assignment) Expr() Expr

func (Assignment) Ident

func (a Assignment) Ident() Expr

func (Assignment) String

func (a Assignment) String() string

type Binary

type Binary struct {
	Position
	// contains filtered or unexported fields
}

func (Binary) Accept

func (b Binary) Accept(v Visitor) error

func (Binary) CloneWithOffset

func (b Binary) CloneWithOffset(pos layout.Position) Expr

func (Binary) Left

func (b Binary) Left() Expr

func (Binary) Op

func (b Binary) Op() op.Op

func (Binary) Right

func (b Binary) Right() Expr

func (Binary) String

func (b Binary) String() string

type Call

type Call struct {
	Position
	// contains filtered or unexported fields
}

func (Call) Accept

func (c Call) Accept(v Visitor) error

func (Call) Args

func (c Call) Args() []Expr

func (Call) CloneWithOffset

func (c Call) CloneWithOffset(pos layout.Position) Expr

func (Call) Name

func (c Call) Name() Expr

func (Call) String

func (c Call) String() string

type CellAddr

type CellAddr struct {
	layout.Position
	AbsCol bool
	AbsRow bool
}

func (CellAddr) Accept

func (a CellAddr) Accept(v Visitor) error

func (CellAddr) CloneWithOffset

func (a CellAddr) CloneWithOffset(pos layout.Position) Expr

func (CellAddr) KindOf

func (CellAddr) KindOf() string

func (CellAddr) String

func (a CellAddr) String() string

type Clear

type Clear struct {
	Position
	// contains filtered or unexported fields
}

func (Clear) Accept

func (c Clear) Accept(v Visitor) error

func (Clear) String

func (c Clear) String() string

type Clonable

type Clonable interface {
	CloneWithOffset(layout.Position) Expr
}

type ConfigEntry

type ConfigEntry struct {
	Path  []string
	Value any
}

type Deferred

type Deferred struct {
	Position
	// contains filtered or unexported fields
}

func (Deferred) Accept

func (d Deferred) Accept(v Visitor) error

func (Deferred) Expr

func (d Deferred) Expr() Expr

func (Deferred) Kind

func (d Deferred) Kind() value.ValueKind

func (Deferred) KindOf

func (Deferred) KindOf() string

func (Deferred) String

func (d Deferred) String() string

func (Deferred) Type

func (d Deferred) Type() string

type ExportRef

type ExportRef struct {
	Position
	// contains filtered or unexported fields
}

func (ExportRef) Accept

func (e ExportRef) Accept(v Visitor) error

func (ExportRef) String

func (e ExportRef) String() string

type Expr

type Expr interface {
	fmt.Stringer
}

func NewAccess

func NewAccess(expr Expr, prop string) Expr

func NewAnd

func NewAnd(left, right Expr) Expr

func NewAssignment

func NewAssignment(ident, expr Expr) Expr

func NewBinary

func NewBinary(left, right Expr, oper op.Op) Expr

func NewCall

func NewCall(id Expr, args []Expr) Expr

func NewCellAddr

func NewCellAddr(pos layout.Position, col, row bool) Expr

func NewDeferred

func NewDeferred(expr Expr) Expr

func NewIdentifier

func NewIdentifier(id string) Expr

func NewInterval

func NewInterval(from, to, step Expr) Expr

func NewIntervalList

func NewIntervalList(expr []Expr) Expr

func NewLiteral

func NewLiteral(value string) Expr

func NewNot

func NewNot(expr Expr) Expr

func NewNumber

func NewNumber(value float64) Expr

func NewOr

func NewOr(left, right Expr) Expr

func NewPostfix

func NewPostfix(expr Expr, oper op.Op) Expr

func NewQualifiedAddr

func NewQualifiedAddr(path, addr Expr) Expr

func NewRangeAddr

func NewRangeAddr(start, end Expr) Expr

func NewScript

func NewScript(body []Expr) Expr

func NewSlice

func NewSlice(view, expr Expr) Expr

func NewTemplate

func NewTemplate(list []Expr) Expr

func NewUnary

func NewUnary(expr Expr, oper op.Op) Expr

func ParseFormula

func ParseFormula(str string) (Expr, error)

type ExprKind

type ExprKind interface {
	Kind() Kind
}

type Grammar

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

func FormulaGrammar

func FormulaGrammar() *Grammar

func LambdaGrammar

func LambdaGrammar() *Grammar

func NewGrammar

func NewGrammar(name string, mode ScanMode) *Grammar

func ScriptGrammar

func ScriptGrammar() *Grammar

func SliceGrammar

func SliceGrammar() *Grammar

func (*Grammar) Context

func (g *Grammar) Context() string

func (*Grammar) Infix

func (g *Grammar) Infix(tok Token) (InfixFunc, error)

func (*Grammar) IsTerminator

func (g *Grammar) IsTerminator(tok Token) bool

func (*Grammar) Isolated

func (g *Grammar) Isolated() bool

func (*Grammar) Postfix

func (g *Grammar) Postfix(tok Token) (InfixFunc, error)

func (*Grammar) Pow

func (g *Grammar) Pow(kind op.Op) int

func (*Grammar) Prefix

func (g *Grammar) Prefix(tok Token) (PrefixFunc, error)

func (*Grammar) RegisterBinding

func (g *Grammar) RegisterBinding(kd op.Op, pow int)

func (*Grammar) RegisterInfix

func (g *Grammar) RegisterInfix(kd op.Op, fn InfixFunc)

func (*Grammar) RegisterInfixKeyword

func (g *Grammar) RegisterInfixKeyword(kw string, fn InfixFunc)

func (*Grammar) RegisterPostfix

func (g *Grammar) RegisterPostfix(kd op.Op, fn InfixFunc)

func (*Grammar) RegisterPrefix

func (g *Grammar) RegisterPrefix(kd op.Op, fn PrefixFunc)

func (*Grammar) RegisterPrefixKeyword

func (g *Grammar) RegisterPrefixKeyword(kw string, fn PrefixFunc)

func (*Grammar) UnregisterInfix

func (g *Grammar) UnregisterInfix(kd op.Op)

func (*Grammar) UnregisterInfixKeyword

func (g *Grammar) UnregisterInfixKeyword(kw string)

func (*Grammar) UnregisterPostfix

func (g *Grammar) UnregisterPostfix(kd op.Op)

func (*Grammar) UnregisterPrefix

func (g *Grammar) UnregisterPrefix(kd op.Op)

func (*Grammar) UnregisterPrefixKeyword

func (g *Grammar) UnregisterPrefixKeyword(kw string)

type GrammarScope

type GrammarScope int
const (
	GrammarDefault GrammarScope = iota
	GrammarIsolated
)

type GrammarStack

type GrammarStack []*Grammar

func (*GrammarStack) Context

func (gs *GrammarStack) Context() string

func (*GrammarStack) Infix

func (gs *GrammarStack) Infix(tok Token) (InfixFunc, error)

func (*GrammarStack) IsTermintor

func (gs *GrammarStack) IsTermintor(tok Token) bool

func (*GrammarStack) Mode

func (gs *GrammarStack) Mode() ScanMode

func (*GrammarStack) Pop

func (gs *GrammarStack) Pop()

func (*GrammarStack) Postfix

func (gs *GrammarStack) Postfix(tok Token) (InfixFunc, error)

func (*GrammarStack) Pow

func (gs *GrammarStack) Pow(kind op.Op) int

func (*GrammarStack) Prefix

func (gs *GrammarStack) Prefix(tok Token) (PrefixFunc, error)

func (*GrammarStack) Push

func (gs *GrammarStack) Push(g *Grammar) error

func (*GrammarStack) Top

func (gs *GrammarStack) Top() *Grammar

type Identifier

type Identifier struct {
	Position
	// contains filtered or unexported fields
}

func (Identifier) Accept

func (i Identifier) Accept(v Visitor) error

func (Identifier) Ident

func (i Identifier) Ident() string

func (Identifier) KindOf

func (Identifier) KindOf() string

func (Identifier) Selection

func (i Identifier) Selection() (layout.Selection, error)

func (Identifier) String

func (i Identifier) String() string

type ImportFile

type ImportFile struct {
	Position
	// contains filtered or unexported fields
}

func (ImportFile) Accept

func (i ImportFile) Accept(v Visitor) error

func (ImportFile) Alias

func (i ImportFile) Alias() string

func (ImportFile) Default

func (i ImportFile) Default() bool

func (ImportFile) File

func (i ImportFile) File() string

func (ImportFile) Format

func (i ImportFile) Format() string

func (ImportFile) Kind

func (ImportFile) Kind() Kind

func (ImportFile) Options

func (i ImportFile) Options() map[string]any

func (ImportFile) ReadOnly

func (i ImportFile) ReadOnly() bool

func (ImportFile) Specifier

func (i ImportFile) Specifier() string

func (ImportFile) String

func (i ImportFile) String() string

type InfixFunc

type InfixFunc func(*Parser, Expr) (Expr, error)

type IntervalExpr

type IntervalExpr struct {
	Position
	// contains filtered or unexported fields
}

func (IntervalExpr) Selection

func (e IntervalExpr) Selection() (layout.Selection, error)

func (IntervalExpr) String

func (e IntervalExpr) String() string

type IntervalList

type IntervalList struct {
	Position
	// contains filtered or unexported fields
}

func (IntervalList) Count

func (i IntervalList) Count() int

func (IntervalList) Selection

func (i IntervalList) Selection() (layout.Selection, error)

func (IntervalList) String

func (i IntervalList) String() string

type Kind

type Kind int8
const (
	KindStmt Kind = 1 << iota
	KindImport
	KindUse
)

type Literal

type Literal struct {
	Position
	// contains filtered or unexported fields
}

func (Literal) Accept

func (i Literal) Accept(v Visitor) error

func (Literal) KindOf

func (Literal) KindOf() string

func (Literal) String

func (i Literal) String() string

func (Literal) Text

func (i Literal) Text() string

type LockRef

type LockRef struct {
	Position
	// contains filtered or unexported fields
}

func (LockRef) String

func (k LockRef) String() string

type Mode

type Mode string

type Not

type Not struct {
	Position
	// contains filtered or unexported fields
}

func (Not) Accept

func (n Not) Accept(v Visitor) error

func (Not) Expr

func (n Not) Expr() Expr

func (Not) String

func (n Not) String() string

type Number

type Number struct {
	Position
	// contains filtered or unexported fields
}

func (Number) Accept

func (n Number) Accept(v Visitor) error

func (Number) Float

func (n Number) Float() float64

func (Number) KindOf

func (Number) KindOf() string

func (Number) String

func (n Number) String() string

type Or

type Or struct {
	Position
	// contains filtered or unexported fields
}

func (Or) Accept

func (o Or) Accept(v Visitor) error

func (Or) Left

func (o Or) Left() Expr

func (Or) Right

func (o Or) Right() Expr

func (Or) String

func (o Or) String() string

type Parser

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

func NewParser

func NewParser(scan *Scanner) (*Parser, error)

func (*Parser) ExtractConfigEntries

func (p *Parser) ExtractConfigEntries() ([]ConfigEntry, error)

func (*Parser) Mode

func (p *Parser) Mode() Mode

func (*Parser) Parse

func (p *Parser) Parse() (Expr, error)

func (*Parser) ParseNext

func (p *Parser) ParseNext() (Expr, error)

type Pop

type Pop struct {
	Position
}

func (Pop) String

func (Pop) String() string

type Position

type Position struct {
	Line   int
	Column int
}

func (Position) String

func (p Position) String() string

type Postfix

type Postfix struct {
	Position
	// contains filtered or unexported fields
}

func (Postfix) Accept

func (p Postfix) Accept(v Visitor) error

func (Postfix) CloneWithOffset

func (p Postfix) CloneWithOffset(pos layout.Position) Expr

func (Postfix) Expr

func (p Postfix) Expr() Expr

func (Postfix) Op

func (p Postfix) Op() op.Op

func (Postfix) String

func (p Postfix) String() string

type PrefixFunc

type PrefixFunc func(*Parser) (Expr, error)

type PrintRef

type PrintRef struct {
	Position
	// contains filtered or unexported fields
}

func (PrintRef) Accept

func (p PrintRef) Accept(v Visitor) error

func (PrintRef) Expr

func (p PrintRef) Expr() Expr

func (PrintRef) Pattern

func (p PrintRef) Pattern() string

func (PrintRef) String

func (p PrintRef) String() string

type Push

type Push struct {
	Position
	// contains filtered or unexported fields
}

func (Push) String

func (Push) String() string

type QualifiedCellAddr

type QualifiedCellAddr struct {
	Position
	// contains filtered or unexported fields
}

func (QualifiedCellAddr) Accept

func (q QualifiedCellAddr) Accept(v Visitor) error

func (QualifiedCellAddr) Addr

func (a QualifiedCellAddr) Addr() Expr

func (QualifiedCellAddr) KindOf

func (QualifiedCellAddr) KindOf() string

func (QualifiedCellAddr) Path

func (a QualifiedCellAddr) Path() Expr

func (QualifiedCellAddr) String

func (a QualifiedCellAddr) String() string

type RangeAddr

type RangeAddr struct {
	Position
	// contains filtered or unexported fields
}

func (RangeAddr) Accept

func (a RangeAddr) Accept(v Visitor) error

func (RangeAddr) CloneWithOffset

func (a RangeAddr) CloneWithOffset(pos layout.Position) Expr

func (RangeAddr) EndAt

func (a RangeAddr) EndAt() CellAddr

func (RangeAddr) KindOf

func (RangeAddr) KindOf() string

func (RangeAddr) Range

func (a RangeAddr) Range() *layout.Range

func (RangeAddr) StartAt

func (a RangeAddr) StartAt() CellAddr

func (RangeAddr) String

func (a RangeAddr) String() string

type ScanMode

type ScanMode int8
const (
	ScanFormula ScanMode = 1 << iota
	ScanScript
)

type Scanner

type Scanner struct {
	Position
	// contains filtered or unexported fields
}

func Scan

func Scan(r io.Reader, mode ScanMode) (*Scanner, error)

func (*Scanner) Peek

func (s *Scanner) Peek() Token

func (*Scanner) Restore

func (s *Scanner) Restore(state ScannerState)

func (*Scanner) Save

func (s *Scanner) Save() ScannerState

func (*Scanner) Scan

func (s *Scanner) Scan() Token

func (*Scanner) SkipNL

func (s *Scanner) SkipNL()

type ScannerState

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

type Script

type Script struct {
	Body []Expr
	Position
}

func (Script) Accept

func (s Script) Accept(v Visitor) error

func (Script) String

func (Script) String() string

type Selectable

type Selectable interface {
	Selection() (layout.Selection, error)
}

type Slice

type Slice struct {
	Position
	// contains filtered or unexported fields
}

func (Slice) Accept

func (s Slice) Accept(v Visitor) error

func (Slice) Expr

func (s Slice) Expr() Expr

func (Slice) KindOf

func (Slice) KindOf() string

func (Slice) String

func (s Slice) String() string

func (Slice) View

func (s Slice) View() Expr

type Template

type Template struct {
	Position
	// contains filtered or unexported fields
}

func (Template) Accept

func (t Template) Accept(v Visitor) error

func (Template) KindOf

func (Template) KindOf() string

func (Template) Parts

func (t Template) Parts() []Expr

func (Template) String

func (t Template) String() string

type Token

type Token struct {
	Literal string
	Type    op.Op
	Position
}

func (Token) String

func (t Token) String() string

type Unary

type Unary struct {
	Position
	// contains filtered or unexported fields
}

func (Unary) Accept

func (u Unary) Accept(v Visitor) error

func (Unary) CloneWithOffset

func (u Unary) CloneWithOffset(pos layout.Position) Expr

func (Unary) Expr

func (u Unary) Expr() Expr

func (Unary) Op

func (u Unary) Op() op.Op

func (Unary) String

func (u Unary) String() string

type UnlockRef

type UnlockRef struct {
	Position
	// contains filtered or unexported fields
}

func (UnlockRef) String

func (k UnlockRef) String() string

type UseRef

type UseRef struct {
	Position
	// contains filtered or unexported fields
}

func (UseRef) Accept

func (u UseRef) Accept(v Visitor) error

func (UseRef) Identifier

func (u UseRef) Identifier() string

func (UseRef) ReadOnly

func (u UseRef) ReadOnly() bool

func (UseRef) String

func (u UseRef) String() string

type VisitableExpr

type VisitableExpr interface {
	Accept(Visitor) error
}

type Visitor

type Visitor interface {
	VisitScript(Script) error

	VisitImportFile(ImportFile) error
	VisitExportRef(ExportRef) error
	VisitPrintRef(PrintRef) error
	VisitUseRef(UseRef) error
	VisitClear(Clear) error

	VisitIdentifier(Identifier) error
	VisitLiteral(Literal) error
	VisitNumber(Number) error
	VisitQualifiedCellAddr(QualifiedCellAddr) error
	VisitCellAddr(CellAddr) error
	VisitRangeAddr(RangeAddr) error
	VisitTemplate(Template) error
	VisitAccess(Access) error
	VisitDeferred(Deferred) error
	VisitCall(Call) error
	VisitSlice(Slice) error

	VisitBinary(Binary) error
	VisitAssignment(Assignment) error
	VisitPostfix(Postfix) error
	VisitNot(Not) error
	VisitAnd(And) error
	VisitOr(Or) error
	VisitUnary(Unary) error
}

Jump to

Keyboard shortcuts

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