Jet Brains test task; making table editor with parser.
- Parsing
- Functions
- Reference to cells and cell ranges (only absolute cells)
root/
| TableEditorApp.java - the main entry point for the app
| model/
|---- utils/
| |---- CycleDetector.java
|---- CellModel.java - the data and methods included
|---- TableModel.java - the data of the table
| parser/
|---- functions/
| |---- Function - abstract functions
| |---- SumFunction - functions inherited
| |---- ConcatFunction - functions inherit
| ...
|---- utils/
| |---- GeneralUtils.java - utils for parser
|---- Evaluator.java - a wrapper class for parser.
|---- Lexer.java - lexer component. Handles tokenization.
|---- Parser.java - Main parser. Handles parsing and evaluation.
|---- Token.java - Token class
|---- TokenType.java - Token types.
| ui/
|---- utils/
| |---- Popupmenu
|---- CustomTableCellEditor.java - Customized cell editor.
|---- CustomTableCellRenderer.java - Customized cell renderer.
|---- MainFrame.java - Wrapper for table.
|---- TablePanel.java - Table rendering UIs.
Brief overview of the functionalities and usage.
A1:C2. Use cell Labels for range with colon. Support functions SUM, AVG, POW(arg, arg), COUNT, MIN, MAX, CONCAT.
CTRL+C -> CTRL + V
Mouse two on any cell.
My parser consist of Lexer and Parser. Lexer tokenizes the input and also has some sanitization for the expression. Parser is LL(1) parser implemented in recursive descent way.
Precedence | Operator | Description | Associativity |
---|---|---|---|
1 | : |
Cell Scope resolution | Left-to-right |
2 | () |
Function call | Left-to-right |
3 | + - |
Unary plus and minus | Right-to-left |
4 | * / |
Multiplication, division | Left-to-right |
5 | + - |
Addition, subtraction | Left-to-right |
As in the code, https://github.com/bilguudeiblgd/table-editor/blob/main/src/main/java/parser/Parser.java I use L1, L2, L3, L4, L5 functions which corresponds to this precendence.