sheet/

directory
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

README

NAME

sheet -- demo of a spreadsheet engine

DESCRIPTION

Sheet demonstrates a minimal engine to support spreadsheets, a table of cells with formulas:

s.Set("A1", "1")
s.Set("B1", "=SUM(A1:A5, 7-6)")
s.Set("B3", "=IF(B1 > 3, 10, 20)")
s.Calculate()
s.VisitAll(func(id, val string, res float64) bool {
	fmt.Printf("%s %3.1f\t%s\n", id, res, val)
	return true
})

The expected output is:

A1 1.0  1
B1 2.0  =SUM(A1:A5, 7-6)
B3 20.0 =IF(B1 > 3, 10, 20)

Engines

It supports two engines to drive cell parsing and fromula calculation:

  • AST: parse formulas into Abstrast Syntax Tree (AST). Walk the three in postorder traversal.

  • VM: parse formulas into AST, then compile it into instructions. Use a Virtual Machine (VM) to execute the instruction to get the value.

Directories

Path Synopsis
cmd
sheet command
Sheet demonstrates an Excel-like engine to drive a table of cells.
Sheet demonstrates an Excel-like engine to drive a table of cells.
wasm command
Wasm runs spreadsheets in browser using WebAssembler.
Wasm runs spreadsheets in browser using WebAssembler.
internal
ast
Package ast defines Abstract Syntax Tree (AST) nodes for a sheet cell.
Package ast defines Abstract Syntax Tree (AST) nodes for a sheet cell.
lex
Package lex implements formula lexical analysis of cells.
Package lex implements formula lexical analysis of cells.
sheet
Package sheet implements a cells table.
Package sheet implements a cells table.
vm
Package vm implements a virtual machine (VM) to generate an instructions set from parsed cell's Abstract Syntax Tree (AST) for Intermediate Representation (IR) and execute these to calculate the cell value.
Package vm implements a virtual machine (VM) to generate an instructions set from parsed cell's Abstract Syntax Tree (AST) for Intermediate Representation (IR) and execute these to calculate the cell value.

Jump to

Keyboard shortcuts

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