A spreadsheet is an interactive table for storing, analyzing and processing data. A cell can contain numbers, operators, braces and references to other cells. A spreadsheet dynamically evaluates value in each cell.
The main window contains editable grid, text field to display entered formula in focused cell and button to toggle Formulas mode.
-
Addition '+'
-
Subtraction '-'
-
Multiplication '*'
-
Division '/'
-
Power '^'
-
Bitwise AND '&' and OR '|'
A reference is a latin letter, followed by number from 1 to 99.
Long arithmetic is used to avoid integer overflow.
Operators precedence are respected.
When Formulas Mode is toggled, cells display originally typed formula instead of evaluated value.
A Lexer is implemented in order to parse text. The Lexer uses regular expressions and named capturing groups to extract information from entered text.
- Tarjan's algorithm to detect cycled references
- Topological sorting to determine in what order evaluate cells
- Shunting-yard algorithm to evaluate expression and respect precedence and braces