lex

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package lex implements formula lexical analysis of cells.

Index

Constants

This section is empty.

Variables

View Source
var ErrLex = errors.New("lex error")

ErrLex means lexican analysis failed.

Functions

func Lex

func Lex(b []byte) iter.Seq[Token]

Lex runs lexical analysis on the formula and generates a sequence of tokens.

Types

type Token

type Token struct {
	Type TokenType // token type
	Text string    // token value
	Err  error     // only set for TokenError
}

Token is a single item in the formula.

type TokenType

type TokenType int

TokenType enumerates different tokens.

const (

	// keep-sorted start
	TokenComma          TokenType // comma
	TokenDivide                   // divide
	TokenEqual                    // equal
	TokenError                    // error
	TokenGreater                  // greater
	TokenGreaterOrEqual           // greaterorequal
	TokenIdent                    // identifier
	TokenLess                     // less
	TokenLessOrEqual              // lessorequal
	TokenLpar                     // rpar
	TokenMinus                    // minus
	TokenMultiply                 // multiply
	TokenNotEqual                 // notequal
	TokenNumber                   // number
	TokenPlus                     // plus
	TokenRange                    // range
	TokenRpar                     // lpar

)

func (TokenType) String

func (i TokenType) String() string

Jump to

Keyboard shortcuts

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