batch (non-wysiwyg, non-interactive) spreadsheet line-oriented commands cell names: 1 or 2 letters (A-Za-z, case insensitive) plus 1 to 3 digits 0-9 26*27 = 702 possible columns: A, B, ..., Z, AA, AB, ..., AZ, BA, BB, ..., BZ, ..., ZA, ZB, ..., ZZ 256 columns if IV is last allowed column. 1000 possible rows: 0, 1, ..., 999 cell row and column references are relative to current cell, unless fixed. fixed column: $AA23, fixed row: AA$23, fixed column and row: $AA$23 range: cell:cell (cell and range parsed by lexer and returned as struct's with int vals) expr: number, cell, = * / % + - (), func, unary{-} ! && || ?: < <= == != >= > same prec/assoc as C - ref: C-grammar *** DO NOT USE %left, %right, %nonassoc, follow C-grammar spec style *** #...comment-to-end-of-line -- stripped by lexer cell assignment: cell = expr cell = string (no escape chars, maybe "<..." or ">..." for justify) (compiled expr or string placed in cell at compile time) range commands: copy to_range from_range (executed at compile time) fill to_range start inc (executed at compile time) numeric functions: abs( expr) (executed at run time...) sqrt( expr) range functions: avg( range) (executed at run time...) count( range) max( range) min( range) prod( range) stdev( range) sum( range) other commands or maybe command-line options: display formulas (set flag or global at compile time...) display values format %10.2g --- Example: amortization schedule # 100000 balance, 0.5% monthly interest, 1200 monthly payment a0 = "month" fill a2:a13 1 1 b0 = "balance" b1 = 100000 b2 = b1*1.005-1200 c0 = "total paid" c2 = c1 + 1200 copy b3:c13 b2:c12 result, cell formulas: A B C 0 month balance total paid 1 100000 2 1 b1*1.005-1200 c1+1200 3 2 b2*1.005-1200 c2+1200 4 3 b3*1.005-1200 c3+1200 5 4 b4*1.005-1200 c4+1200 6 5 b5*1.005-1200 c5+1200 7 6 b6*1.005-1200 c6+1200 8 7 b7*1.005-1200 c7+1200 9 8 b8*1.005-1200 c8+1200 10 9 b9*1.005-1200 c9+1200 11 10 b10*1.005-1200 c10+1200 12 11 b11*1.005-1200 c11+1200 13 12 b12*1.005-1200 c12+1200 result, values: month balance total paid 100000 1 99300 1200 2 98596 2400 3 97889 3600 4 97179 4800 5 96465 6000 6 95747 7200 7 95026 8400 8 94301 9600 9 93573 10800 10 92840 12000 11 92105 13200 12 91365 14400 # using fixed cells for interest and payment # changes from above example: d0 = "interest" e0 = "payment" d1 = 1.005 e1=1200 b2 = b1*$d$1-$e$1 c2 = c1 + $e$1 result, cell formulas: A B C D E 0 month balance total paid interest payment 1 100000 1.005 1200 2 1 b1*$d$1-$e$1 c1+$e$1 3 2 b2*$d$1-$e$1 c2+$e$1 4 3 b3*$d$1-$e$1 c3+$e$1 5 4 b4*$d$1-$e$1 c4+$e$1 ... --- YYSTYPE, union of semantic values from lexer number string cell range int? - operators, functions, commands --- No user-defined names (just user-specified cells) so don't need symbol table, yylex() will set yylval cell or range struct --- ss nodes, 2D array of type/union: type union string number expr_tree ---