f8-engine 0.3.0__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. {f8_engine-0.3.0 → f8_engine-0.3.2}/Cargo.lock +2 -2
  2. {f8_engine-0.3.0 → f8_engine-0.3.2}/Cargo.toml +8 -1
  3. {f8_engine-0.3.0 → f8_engine-0.3.2}/PKG-INFO +11 -2
  4. {f8_engine-0.3.0 → f8_engine-0.3.2}/README.md +10 -1
  5. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/compiled/mod.rs +1 -1
  6. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/emission/workbook.rs +43 -8
  7. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/eval/context.rs +11 -2
  8. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/eval/expr.rs +13 -3
  9. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/eval/model.rs +5 -2
  10. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/graph/resolve.rs +1 -1
  11. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/ir/cell.rs +1 -1
  12. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/ir/expand.rs +1 -1
  13. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/ir/symbol.rs +1 -1
  14. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/layout/a1.rs +1 -1
  15. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/lowering/mod.rs +1 -1
  16. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/expr/ast.rs +3 -1
  17. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/expr/parser.rs +131 -72
  18. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/common.rs +3 -1
  19. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/date/serial.rs +1 -1
  20. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/logical/branching.rs +3 -1
  21. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/lookup/index.rs +3 -1
  22. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/lookup/search.rs +18 -6
  23. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/math/conditional.rs +22 -10
  24. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/math/criteria.rs +34 -12
  25. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/model/table.rs +4 -4
  26. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/value/format.rs +1 -1
  27. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/value/mod.rs +4 -4
  28. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-python/src/error.rs +10 -2
  29. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-python/src/model.rs +4 -1
  30. {f8_engine-0.3.0 → f8_engine-0.3.2}/LICENSE +0 -0
  31. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/Cargo.toml +0 -0
  32. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/compiled/error.rs +0 -0
  33. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/compiled/model.rs +0 -0
  34. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/emission/error.rs +0 -0
  35. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/emission/format.rs +0 -0
  36. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/emission/mod.rs +0 -0
  37. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/error.rs +0 -0
  38. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/eval/error.rs +0 -0
  39. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/eval/mod.rs +0 -0
  40. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/graph/cycle.rs +0 -0
  41. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/graph/dependency.rs +0 -0
  42. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/graph/error.rs +0 -0
  43. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/graph/mod.rs +0 -0
  44. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/ir/error.rs +0 -0
  45. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/ir/id.rs +0 -0
  46. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/ir/mod.rs +0 -0
  47. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/layout/error.rs +0 -0
  48. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/layout/mod.rs +0 -0
  49. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/lowering/address.rs +0 -0
  50. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/lowering/error.rs +0 -0
  51. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/compiler/mod.rs +0 -0
  52. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/expr/error.rs +0 -0
  53. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/expr/mod.rs +0 -0
  54. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/date/constructors.rs +0 -0
  55. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/date/mod.rs +0 -0
  56. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/date/parts.rs +0 -0
  57. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/date/yearfrac.rs +0 -0
  58. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/error.rs +0 -0
  59. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/financial/annuity.rs +0 -0
  60. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/financial/discounting.rs +0 -0
  61. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/financial/irr.rs +0 -0
  62. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/financial/mod.rs +0 -0
  63. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/logical/boolean.rs +0 -0
  64. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/logical/error_handling.rs +0 -0
  65. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/logical/mod.rs +0 -0
  66. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/lookup/mod.rs +0 -0
  67. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/lookup/xlookup.rs +0 -0
  68. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/lookup/xmatch.rs +0 -0
  69. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/math/aggregation.rs +0 -0
  70. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/math/basic.rs +0 -0
  71. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/math/mod.rs +0 -0
  72. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/math/product.rs +0 -0
  73. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/math/rounding.rs +0 -0
  74. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/mod.rs +0 -0
  75. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/registry.rs +0 -0
  76. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/functions/traits.rs +0 -0
  77. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/lib.rs +0 -0
  78. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/model/error.rs +0 -0
  79. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/model/format.rs +0 -0
  80. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/model/id.rs +0 -0
  81. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/model/manifest.rs +0 -0
  82. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/model/mod.rs +0 -0
  83. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/model/theme.rs +0 -0
  84. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-core/src/value/error.rs +0 -0
  85. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-python/Cargo.toml +0 -0
  86. {f8_engine-0.3.0 → f8_engine-0.3.2}/crates/f8-python/src/lib.rs +0 -0
  87. {f8_engine-0.3.0 → f8_engine-0.3.2}/pyproject.toml +0 -0
  88. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/__init__.py +0 -0
  89. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/__main__.py +0 -0
  90. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/_core.pyi +0 -0
  91. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/audit.py +0 -0
  92. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/builder.py +0 -0
  93. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/cli.py +0 -0
  94. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/py.typed +0 -0
  95. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/skills/f8-modeling/SKILL.md +0 -0
  96. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/skills/f8-modeling/references/auditing-and-repair.md +0 -0
  97. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/skills/f8-modeling/references/functions.md +0 -0
  98. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/skills/f8-modeling/references/syntax-and-grid.md +0 -0
  99. {f8_engine-0.3.0 → f8_engine-0.3.2}/python/f8/types.py +0 -0
@@ -37,7 +37,7 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
37
37
 
38
38
  [[package]]
39
39
  name = "f8-core"
40
- version = "0.3.0"
40
+ version = "0.3.2"
41
41
  dependencies = [
42
42
  "indexmap",
43
43
  "petgraph",
@@ -50,7 +50,7 @@ dependencies = [
50
50
 
51
51
  [[package]]
52
52
  name = "f8-python"
53
- version = "0.3.0"
53
+ version = "0.3.2"
54
54
  dependencies = [
55
55
  "f8-core",
56
56
  "pyo3",
@@ -3,7 +3,7 @@ resolver = "3"
3
3
  members = ["crates/f8-core", "crates/f8-python"]
4
4
 
5
5
  [workspace.package]
6
- version = "0.3.0"
6
+ version = "0.3.2"
7
7
  edition = "2024"
8
8
  description = "Financial modeling engine with compiler verification and live Excel formulas"
9
9
  authors = ["Michael (Chencheng) Hu, CFA"]
@@ -25,3 +25,10 @@ pythonize = "0.24"
25
25
  [workspace.lints.clippy]
26
26
  unwrap_used = "deny"
27
27
  expect_used = "deny"
28
+ wildcard_imports = "deny"
29
+ wildcard_enum_match_arm = "deny"
30
+ allow_attributes_without_reason = "deny"
31
+ todo = "deny"
32
+ unimplemented = "deny"
33
+ dbg_macro = "deny"
34
+ fn_params_excessive_bools = "warn"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: f8-engine
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: Intended Audience :: Financial and Insurance Industry
@@ -119,10 +119,19 @@ Output:
119
119
 
120
120
  ## Sample deliverables
121
121
 
122
- Inspect compiled deliverables generated from a real-world model:
122
+ Inspect compiled deliverables generated from real-world models:
123
123
 
124
124
  - [costco_financial_model.xlsx](https://github.com/mhcfa/f8/releases/latest/download/costco_financial_model.xlsx): Compiled financial model with live Excel formulas.
125
125
  - [costco_valuation_report.pdf](https://github.com/mhcfa/f8/releases/latest/download/costco_valuation_report.pdf): Valuation report rendered directly from the compiled `f8` model using Quarto, Typst, and Matplotlib.
126
+ - [lbo_model.xlsx](https://github.com/mhcfa/f8/releases/latest/download/lbo_model.xlsx): Multi-sheet leveraged buyout (LBO) model with transaction structuring, debt waterfall, and returns analysis.
127
+
128
+ ### LBO model demo
129
+
130
+ Complete model repo: https://github.com/mhcfa/f8-demo
131
+
132
+ ![LBO Executive Dashboard](https://github.com/mhcfa/f8/releases/latest/download/lbo-dashboard.png)
133
+
134
+ ![LBO Transaction Balance Sheet Bridge](https://github.com/mhcfa/f8/releases/latest/download/lbo-transaction.png)
126
135
 
127
136
  > Disclaimer: Sample deliverables are AI-generated technical demonstrations and do not constitute financial analysis or investment advice.
128
137
 
@@ -93,10 +93,19 @@ Output:
93
93
 
94
94
  ## Sample deliverables
95
95
 
96
- Inspect compiled deliverables generated from a real-world model:
96
+ Inspect compiled deliverables generated from real-world models:
97
97
 
98
98
  - [costco_financial_model.xlsx](https://github.com/mhcfa/f8/releases/latest/download/costco_financial_model.xlsx): Compiled financial model with live Excel formulas.
99
99
  - [costco_valuation_report.pdf](https://github.com/mhcfa/f8/releases/latest/download/costco_valuation_report.pdf): Valuation report rendered directly from the compiled `f8` model using Quarto, Typst, and Matplotlib.
100
+ - [lbo_model.xlsx](https://github.com/mhcfa/f8/releases/latest/download/lbo_model.xlsx): Multi-sheet leveraged buyout (LBO) model with transaction structuring, debt waterfall, and returns analysis.
101
+
102
+ ### LBO model demo
103
+
104
+ Complete model repo: https://github.com/mhcfa/f8-demo
105
+
106
+ ![LBO Executive Dashboard](https://github.com/mhcfa/f8/releases/latest/download/lbo-dashboard.png)
107
+
108
+ ![LBO Transaction Balance Sheet Bridge](https://github.com/mhcfa/f8/releases/latest/download/lbo-transaction.png)
100
109
 
101
110
  > Disclaimer: Sample deliverables are AI-generated technical demonstrations and do not constitute financial analysis or investment advice.
102
111
 
@@ -1278,7 +1278,7 @@ pub fn parse_coordinate_tokens(
1278
1278
  }
1279
1279
 
1280
1280
  #[cfg(test)]
1281
- #[allow(clippy::unwrap_used, clippy::expect_used)]
1281
+ #[allow(clippy::unwrap_used, clippy::expect_used, reason = "test code")]
1282
1282
  mod tests {
1283
1283
  use super::*;
1284
1284
 
@@ -12,8 +12,9 @@ use super::format::{CellFormatKey, FormatCache, parse_hex_color};
12
12
  use crate::compiler::eval::EvaluatedModel;
13
13
  use crate::compiler::ir::cell::{CellGrid, CellPayload};
14
14
  use crate::compiler::ir::id::CellId;
15
- use crate::compiler::layout::LayoutMap;
15
+ use crate::compiler::layout::{LayoutMap, StyleRole};
16
16
  use crate::compiler::lowering::LoweredFormulaMap;
17
+ use crate::model::format::SemanticStyle;
17
18
  use crate::model::id::SheetId;
18
19
  use crate::model::manifest::ProjectManifest;
19
20
  use crate::model::table::{ColumnSpec, RowSpec, TableSpec, ValueLiteral};
@@ -80,7 +81,7 @@ impl WorkbookEmitter {
80
81
  /// # Errors
81
82
  /// Returns [`EmissionError`] if any worksheet, table, or cell coordinate is missing
82
83
  /// from the spatial layout, or if an OpenXML format or packaging error occurs.
83
- #[allow(clippy::too_many_arguments)]
84
+ #[allow(clippy::too_many_arguments, reason = "explicit pass outputs")]
84
85
  pub fn emit_to_buffer(
85
86
  manifest: &ProjectManifest,
86
87
  tables: &[TableSpec],
@@ -106,7 +107,7 @@ impl WorkbookEmitter {
106
107
  }
107
108
 
108
109
  /// Assembles an OpenXML workbook with worksheets, formatting, outlines, and cells.
109
- #[allow(clippy::too_many_arguments)]
110
+ #[allow(clippy::too_many_arguments, reason = "explicit pass outputs")]
110
111
  fn assemble_workbook(
111
112
  manifest: &ProjectManifest,
112
113
  tables: &[TableSpec],
@@ -274,7 +275,15 @@ impl WorkbookEmitter {
274
275
  let col_idx = (placement.start_col + c_idx as u32) as u16;
275
276
  match col_spec {
276
277
  ColumnSpec::Gutter => {
277
- // Gutter column: blank unstyled cell across all header tiers
278
+ // Gutter column: continue header bottom border and fill across gutter
279
+ if is_bottom_tier || format_cache.has_col_header_fill() {
280
+ let fmt = if is_bottom_tier {
281
+ format_cache.col_header_format(false)
282
+ } else {
283
+ format_cache.col_header_upper_format(false)
284
+ };
285
+ worksheet.write_blank(tier_row, col_idx, &fmt)?;
286
+ }
278
287
  }
279
288
  ColumnSpec::Data(d) => {
280
289
  if t == 0 && d.group.is_some() {
@@ -349,10 +358,36 @@ impl WorkbookEmitter {
349
358
  }
350
359
  }
351
360
  RowSpec::Data(row_data) => {
352
- for col_spec in &table.columns {
353
- let ColumnSpec::Data(col_data) = col_spec else {
354
- // Column gutter: remains blank without borders
355
- continue;
361
+ for (c_idx, col_spec) in table.columns.iter().enumerate() {
362
+ let col_data = match col_spec {
363
+ ColumnSpec::Data(d) => d,
364
+ ColumnSpec::Gutter => {
365
+ // Gutter column: continue row formatting (horizontal borders, shade, highlight)
366
+ let role = StyleRole {
367
+ horizontal: row_data
368
+ .style
369
+ .unwrap_or(SemanticStyle::Data),
370
+ vertical: SemanticStyle::Data,
371
+ is_highlight: row_data.highlight.unwrap_or(false),
372
+ shade: row_data.shade.filter(|s| !s.is_none()),
373
+ };
374
+
375
+ if role != StyleRole::data() {
376
+ let format_key = CellFormatKey::new(
377
+ role, None, None, None, false, false, 0,
378
+ );
379
+ let cell_format =
380
+ format_cache.get_cell_format(&format_key)?;
381
+ let phys_col =
382
+ (placement.start_col + c_idx as u32) as u16;
383
+ worksheet.write_blank(
384
+ current_phys_row,
385
+ phys_col,
386
+ &cell_format,
387
+ )?;
388
+ }
389
+ continue;
390
+ }
356
391
  };
357
392
 
358
393
  let cell_id = CellId::new(
@@ -51,7 +51,12 @@ impl<'a> EvalContext for CellEvalContext<'a> {
51
51
  )
52
52
  .map_err(|err| match err {
53
53
  EvalError::Function { source, .. } => *source,
54
- other => FunctionError::EvaluationFailure {
54
+ other @ (EvalError::CellNotFound(_)
55
+ | EvalError::UnevaluatedDependency(_)
56
+ | EvalError::Resolve(_)
57
+ | EvalError::UnexpectedOmitted(_)
58
+ | EvalError::TableNotFound(_)
59
+ | EvalError::RowNotFound { .. }) => FunctionError::EvaluationFailure {
55
60
  function: "eval_expr",
56
61
  message: other.to_string(),
57
62
  },
@@ -84,7 +89,11 @@ impl<'a> EvalContext for CellEvalContext<'a> {
84
89
 
85
90
  Ok((slice.rows, slice.cols, values))
86
91
  }
87
- _ => {
92
+ Expr::Literal(_)
93
+ | Expr::Unary { .. }
94
+ | Expr::Binary { .. }
95
+ | Expr::FunctionCall { .. }
96
+ | Expr::Omitted => {
88
97
  let val = self.eval_expr(expr)?;
89
98
  Ok((1, 1, vec![val]))
90
99
  }
@@ -85,7 +85,10 @@ pub fn eval_expr(
85
85
 
86
86
  let normalized = match result {
87
87
  CellValue::Number(n) => CellValue::Number(normalize_zero(n)),
88
- other => other,
88
+ other @ (CellValue::Text(_)
89
+ | CellValue::Boolean(_)
90
+ | CellValue::Empty
91
+ | CellValue::Error(_)) => other,
89
92
  };
90
93
  Ok(normalized)
91
94
  }
@@ -162,7 +165,12 @@ fn eval_arithmetic_op(
162
165
  }
163
166
  lhs.powf(rhs)
164
167
  }
165
- _ => unreachable!("non-arithmetic operator passed to eval_arithmetic_op"),
168
+ BinaryOp::Eq
169
+ | BinaryOp::NotEq
170
+ | BinaryOp::Lt
171
+ | BinaryOp::Lte
172
+ | BinaryOp::Gt
173
+ | BinaryOp::Gte => unreachable!("non-arithmetic operator passed to eval_arithmetic_op"),
166
174
  };
167
175
 
168
176
  if result.is_nan() || result.is_infinite() {
@@ -194,7 +202,9 @@ fn eval_comparison_op(
194
202
  BinaryOp::Lte => ord != Ordering::Greater,
195
203
  BinaryOp::Gt => ord == Ordering::Greater,
196
204
  BinaryOp::Gte => ord != Ordering::Less,
197
- _ => unreachable!("non-comparison operator passed to eval_comparison_op"),
205
+ BinaryOp::Pow | BinaryOp::Mul | BinaryOp::Div | BinaryOp::Add | BinaryOp::Sub => {
206
+ unreachable!("non-comparison operator passed to eval_comparison_op")
207
+ }
198
208
  };
199
209
 
200
210
  Ok(CellValue::Boolean(outcome))
@@ -79,7 +79,10 @@ impl EvaluatedModel {
79
79
  .iter()
80
80
  .filter_map(|(id, val)| match val {
81
81
  CellValue::Error(err) => Some((id, err)),
82
- _ => None,
82
+ CellValue::Number(_)
83
+ | CellValue::Text(_)
84
+ | CellValue::Boolean(_)
85
+ | CellValue::Empty => None,
83
86
  })
84
87
  .collect()
85
88
  }
@@ -130,7 +133,7 @@ impl<'a> IntoIterator for &'a EvaluatedModel {
130
133
  }
131
134
 
132
135
  #[cfg(test)]
133
- #[allow(clippy::unwrap_used, clippy::expect_used)]
136
+ #[allow(clippy::unwrap_used, clippy::expect_used, reason = "test code")]
134
137
  mod tests {
135
138
  use super::*;
136
139
  use crate::model::id::SheetId;
@@ -416,7 +416,7 @@ pub fn resolve_cell_dependencies(
416
416
  }
417
417
 
418
418
  #[cfg(test)]
419
- #[allow(clippy::unwrap_used, clippy::expect_used)]
419
+ #[allow(clippy::unwrap_used, clippy::expect_used, reason = "test code")]
420
420
  mod tests {
421
421
  use super::*;
422
422
  use crate::model::id::{SheetId, TableId};
@@ -272,7 +272,7 @@ impl<'a> IntoIterator for &'a CellGrid {
272
272
  }
273
273
 
274
274
  #[cfg(test)]
275
- #[allow(clippy::unwrap_used, clippy::expect_used)]
275
+ #[allow(clippy::unwrap_used, clippy::expect_used, reason = "test code")]
276
276
  mod tests {
277
277
  use super::*;
278
278
 
@@ -438,7 +438,7 @@ pub fn expand_workbook(
438
438
  }
439
439
 
440
440
  #[cfg(test)]
441
- #[allow(clippy::unwrap_used, clippy::expect_used)]
441
+ #[allow(clippy::unwrap_used, clippy::expect_used, reason = "test code")]
442
442
  mod tests {
443
443
  use super::*;
444
444
  use crate::model::format::FormatPreset;
@@ -181,7 +181,7 @@ impl SymbolTable {
181
181
  }
182
182
 
183
183
  #[cfg(test)]
184
- #[allow(clippy::unwrap_used, clippy::expect_used)]
184
+ #[allow(clippy::unwrap_used, clippy::expect_used, reason = "test code")]
185
185
  mod tests {
186
186
  use super::*;
187
187
 
@@ -58,7 +58,7 @@ pub fn coordinate_to_a1(col: u32, row: u32) -> Result<String, LayoutError> {
58
58
  }
59
59
 
60
60
  #[cfg(test)]
61
- #[allow(clippy::unwrap_used, clippy::expect_used)]
61
+ #[allow(clippy::unwrap_used, clippy::expect_used, reason = "test code")]
62
62
  mod tests {
63
63
  use super::*;
64
64
 
@@ -288,7 +288,7 @@ fn format_binary_operand(
288
288
  Expr::Unary { op: child_op, .. } => {
289
289
  is_right || child_op.precedence() < parent_op.precedence()
290
290
  }
291
- _ => false,
291
+ Expr::Literal(_) | Expr::Reference(_) | Expr::FunctionCall { .. } | Expr::Omitted => false,
292
292
  };
293
293
 
294
294
  if wrap {
@@ -40,7 +40,9 @@ impl Expr {
40
40
  match self {
41
41
  Self::Binary { op, .. } => Some(op.precedence()),
42
42
  Self::Unary { op, .. } => Some(op.precedence()),
43
- _ => None,
43
+ Self::Literal(_) | Self::Reference(_) | Self::FunctionCall { .. } | Self::Omitted => {
44
+ None
45
+ }
44
46
  }
45
47
  }
46
48
  }
@@ -80,7 +80,20 @@ impl<'a> Token<'a> {
80
80
  Self::Lte => Some(BinaryOp::Lte),
81
81
  Self::Gt => Some(BinaryOp::Gt),
82
82
  Self::Gte => Some(BinaryOp::Gte),
83
- _ => None,
83
+ Self::Number(_)
84
+ | Self::String(_)
85
+ | Self::Boolean(_)
86
+ | Self::Ident(_)
87
+ | Self::Underscore
88
+ | Self::LParen
89
+ | Self::RParen
90
+ | Self::LBracket
91
+ | Self::RBracket
92
+ | Self::Comma
93
+ | Self::Dot
94
+ | Self::DotDot
95
+ | Self::AtCol
96
+ | Self::AtRow => None,
84
97
  }
85
98
  }
86
99
  }
@@ -681,7 +694,24 @@ fn parse_prefix(stream: &mut TokenStream<'_>) -> Result<Expr, ParseError> {
681
694
  }),
682
695
  }
683
696
  }
684
- other => {
697
+ other @ (Token::Underscore
698
+ | Token::RParen
699
+ | Token::LBracket
700
+ | Token::RBracket
701
+ | Token::Comma
702
+ | Token::Dot
703
+ | Token::DotDot
704
+ | Token::AtCol
705
+ | Token::AtRow
706
+ | Token::Star
707
+ | Token::Slash
708
+ | Token::Caret
709
+ | Token::Eq
710
+ | Token::NotEq
711
+ | Token::Lt
712
+ | Token::Lte
713
+ | Token::Gt
714
+ | Token::Gte) => {
685
715
  let found = other.to_string();
686
716
  Err(ParseError::UnexpectedToken {
687
717
  expected: "expression",
@@ -834,16 +864,20 @@ fn parse_relative_offset(
834
864
  let k = if stream.peek_token() == Some(&Token::LParen) {
835
865
  stream.advance();
836
866
  let k = match stream.consume() {
837
- Some(num_st) => match num_st.token {
838
- Token::Number(n) if n.fract() == 0.0 && n >= 0.0 => n as u32,
839
- ref other => {
867
+ Some(num_st) => {
868
+ if let Token::Number(n) = num_st.token
869
+ && n.fract() == 0.0
870
+ && n >= 0.0
871
+ {
872
+ n as u32
873
+ } else {
840
874
  return Err(ParseError::UnexpectedToken {
841
875
  expected: "integer offset",
842
- found: other.to_string(),
876
+ found: num_st.token.to_string(),
843
877
  offset: num_st.offset,
844
878
  });
845
879
  }
846
- },
880
+ }
847
881
  None => {
848
882
  return Err(ParseError::UnexpectedEof {
849
883
  expected: expected_rparen,
@@ -895,7 +929,27 @@ fn parse_row_endpoint(stream: &mut TokenStream<'_>) -> Result<RowEndpoint, Parse
895
929
  stream.advance();
896
930
  Err(ParseError::UnquotedCoordinateKey { found, offset })
897
931
  }
898
- other => {
932
+ other @ (Token::Boolean(_)
933
+ | Token::Underscore
934
+ | Token::LParen
935
+ | Token::RParen
936
+ | Token::LBracket
937
+ | Token::RBracket
938
+ | Token::Comma
939
+ | Token::Dot
940
+ | Token::DotDot
941
+ | Token::AtCol
942
+ | Token::Plus
943
+ | Token::Minus
944
+ | Token::Star
945
+ | Token::Slash
946
+ | Token::Caret
947
+ | Token::Eq
948
+ | Token::NotEq
949
+ | Token::Lt
950
+ | Token::Lte
951
+ | Token::Gt
952
+ | Token::Gte) => {
899
953
  let found = other.to_string();
900
954
  Err(ParseError::UnexpectedToken {
901
955
  expected: "row selector ('@row', quoted string key, 'row.prev', or 'row.next')",
@@ -949,7 +1003,27 @@ fn parse_col_endpoint(stream: &mut TokenStream<'_>) -> Result<ColEndpoint, Parse
949
1003
  stream.advance();
950
1004
  Err(ParseError::UnquotedCoordinateKey { found, offset })
951
1005
  }
952
- other => {
1006
+ other @ (Token::Boolean(_)
1007
+ | Token::Underscore
1008
+ | Token::LParen
1009
+ | Token::RParen
1010
+ | Token::LBracket
1011
+ | Token::RBracket
1012
+ | Token::Comma
1013
+ | Token::Dot
1014
+ | Token::DotDot
1015
+ | Token::AtRow
1016
+ | Token::Plus
1017
+ | Token::Minus
1018
+ | Token::Star
1019
+ | Token::Slash
1020
+ | Token::Caret
1021
+ | Token::Eq
1022
+ | Token::NotEq
1023
+ | Token::Lt
1024
+ | Token::Lte
1025
+ | Token::Gt
1026
+ | Token::Gte) => {
953
1027
  let found = other.to_string();
954
1028
  Err(ParseError::UnexpectedToken {
955
1029
  expected: "column selector ('@col', quoted string key, 'col.prev', or 'col.next')",
@@ -972,7 +1046,7 @@ fn parse_col_spec(stream: &mut TokenStream<'_>) -> Result<ColSelector, ParseErro
972
1046
  }
973
1047
 
974
1048
  #[cfg(test)]
975
- #[allow(clippy::unwrap_used, clippy::expect_used)]
1049
+ #[allow(clippy::unwrap_used, clippy::expect_used, reason = "test code")]
976
1050
  mod tests {
977
1051
  use super::*;
978
1052
  use crate::model::id::{ColId, RowId, TableId};
@@ -1119,27 +1193,25 @@ mod tests {
1119
1193
  #[test]
1120
1194
  fn test_function_calls() {
1121
1195
  let expr = parse_expr_str("IF(Assumptions[\"flag\", \"active\"] = 1, 100, 0)").unwrap();
1122
- match expr {
1123
- Expr::FunctionCall { name, args } => {
1124
- assert_eq!(name, "IF");
1125
- assert_eq!(args.len(), 3);
1126
- assert_eq!(
1127
- args[0],
1128
- Expr::Binary {
1129
- op: BinaryOp::Eq,
1130
- left: Box::new(Expr::Reference(TableRef::new(
1131
- "Assumptions",
1132
- RowSelector::Key(RowId::new("flag")),
1133
- ColSelector::Key(ColId::new("active")),
1134
- ))),
1135
- right: Box::new(Expr::number(1.0)),
1136
- }
1137
- );
1138
- assert_eq!(args[1], Expr::number(100.0));
1139
- assert_eq!(args[2], Expr::number(0.0));
1196
+ let Expr::FunctionCall { name, args } = expr else {
1197
+ panic!("Expected FunctionCall, got {expr:?}");
1198
+ };
1199
+ assert_eq!(name, "IF");
1200
+ assert_eq!(args.len(), 3);
1201
+ assert_eq!(
1202
+ args[0],
1203
+ Expr::Binary {
1204
+ op: BinaryOp::Eq,
1205
+ left: Box::new(Expr::Reference(TableRef::new(
1206
+ "Assumptions",
1207
+ RowSelector::Key(RowId::new("flag")),
1208
+ ColSelector::Key(ColId::new("active")),
1209
+ ))),
1210
+ right: Box::new(Expr::number(1.0)),
1140
1211
  }
1141
- other => panic!("Expected FunctionCall, got {other:?}"),
1142
- }
1212
+ );
1213
+ assert_eq!(args[1], Expr::number(100.0));
1214
+ assert_eq!(args[2], Expr::number(0.0));
1143
1215
 
1144
1216
  let nullary = parse_expr_str("PI()").unwrap();
1145
1217
  assert_eq!(
@@ -1295,81 +1367,68 @@ mod tests {
1295
1367
  fn test_reject_dot_access() {
1296
1368
  // Dot access with active column
1297
1369
  let err_dot = parse_expr_str("IncomeStatement.revenue[@col]").unwrap_err();
1298
- match err_dot {
1299
- ParseError::UnexpectedToken { found, offset, .. } => {
1300
- assert_eq!(found, ".");
1301
- assert_eq!(offset, 15);
1302
- }
1303
- other => panic!("Expected UnexpectedToken for dot, got {other:?}"),
1304
- }
1370
+ let ParseError::UnexpectedToken { found, offset, .. } = err_dot else {
1371
+ panic!("Expected UnexpectedToken for dot, got {err_dot:?}");
1372
+ };
1373
+ assert_eq!(found, ".");
1374
+ assert_eq!(offset, 15);
1305
1375
 
1306
1376
  // Dot access with row identifier only
1307
1377
  let err_dot_bare = parse_expr_str("IncomeStatement.revenue").unwrap_err();
1308
- match err_dot_bare {
1309
- ParseError::UnexpectedToken { found, offset, .. } => {
1310
- assert_eq!(found, ".");
1311
- assert_eq!(offset, 15);
1312
- }
1313
- other => panic!("Expected UnexpectedToken for dot, got {other:?}"),
1314
- }
1378
+ let ParseError::UnexpectedToken { found, offset, .. } = err_dot_bare else {
1379
+ panic!("Expected UnexpectedToken for dot, got {err_dot_bare:?}");
1380
+ };
1381
+ assert_eq!(found, ".");
1382
+ assert_eq!(offset, 15);
1315
1383
  }
1316
1384
 
1317
1385
  #[test]
1318
1386
  fn test_reject_unquoted_coordinate_keys() {
1319
1387
  let err1 = parse_expr_str("IncomeStatement[\"revenue\", 2024E]").unwrap_err();
1320
- match err1 {
1321
- ParseError::UnquotedCoordinateKey { found, .. } => assert_eq!(found, "2024E"),
1322
- other => panic!("Expected UnquotedCoordinateKey, got {other:?}"),
1323
- }
1388
+ let ParseError::UnquotedCoordinateKey { found, .. } = err1 else {
1389
+ panic!("Expected UnquotedCoordinateKey, got {err1:?}");
1390
+ };
1391
+ assert_eq!(found, "2024E");
1324
1392
 
1325
1393
  let err2 = parse_expr_str("Opex[r_and_d, @col]").unwrap_err();
1326
- match err2 {
1327
- ParseError::UnquotedCoordinateKey { found, .. } => assert_eq!(found, "r_and_d"),
1328
- other => panic!("Expected UnquotedCoordinateKey, got {other:?}"),
1329
- }
1394
+ let ParseError::UnquotedCoordinateKey { found, .. } = err2 else {
1395
+ panic!("Expected UnquotedCoordinateKey, got {err2:?}");
1396
+ };
1397
+ assert_eq!(found, "r_and_d");
1330
1398
  }
1331
1399
 
1332
1400
  #[test]
1333
1401
  fn test_reject_lowercase_function_name() {
1334
1402
  let err = parse_expr_str("sum(1, 2)").unwrap_err();
1335
- match err {
1336
- ParseError::InvalidFunctionName { name, .. } => assert_eq!(name, "sum"),
1337
- other => panic!("Expected InvalidFunctionName, got {other:?}"),
1338
- }
1403
+ let ParseError::InvalidFunctionName { name, .. } = err else {
1404
+ panic!("Expected InvalidFunctionName, got {err:?}");
1405
+ };
1406
+ assert_eq!(name, "sum");
1339
1407
  }
1340
1408
 
1341
1409
  #[test]
1342
1410
  fn test_reject_bare_identifiers() {
1343
1411
  // Bare table identifier without access operator
1344
1412
  let err_table = parse_expr_str("IncomeStatement").unwrap_err();
1345
- match err_table {
1346
- ParseError::UnexpectedToken { found, .. } => assert_eq!(found, "IncomeStatement"),
1347
- other => panic!("Expected UnexpectedToken, got {other:?}"),
1348
- }
1413
+ let ParseError::UnexpectedToken { found, .. } = err_table else {
1414
+ panic!("Expected UnexpectedToken, got {err_table:?}");
1415
+ };
1416
+ assert_eq!(found, "IncomeStatement");
1349
1417
  }
1350
1418
 
1351
1419
  #[test]
1352
1420
  fn test_keyword_boundary_validation() {
1353
1421
  // col.prevent should not parse as col.prev
1354
1422
  let err = parse_expr_str("Table[\"row\", col.prevent]").unwrap_err();
1355
- match err {
1356
- ParseError::UnexpectedToken { .. } => {}
1357
- other => panic!("Expected unexpected token error, got {other:?}"),
1358
- }
1423
+ assert!(matches!(err, ParseError::UnexpectedToken { .. }));
1359
1424
 
1360
1425
  // row.prevent should not parse as row.prev
1361
1426
  let err_row = parse_expr_str("Table[row.prevent, \"col\"]").unwrap_err();
1362
- match err_row {
1363
- ParseError::UnexpectedToken { .. } => {}
1364
- other => panic!("Expected unexpected token error, got {other:?}"),
1365
- }
1427
+ assert!(matches!(err_row, ParseError::UnexpectedToken { .. }));
1366
1428
 
1367
1429
  // col.nextly should not parse as col.next
1368
1430
  let err = parse_expr_str("Table[\"row\", col.nextly]").unwrap_err();
1369
- match err {
1370
- ParseError::UnexpectedToken { .. } => {}
1371
- other => panic!("Expected unexpected token error, got {other:?}"),
1372
- }
1431
+ assert!(matches!(err, ParseError::UnexpectedToken { .. }));
1373
1432
 
1374
1433
  // Bare @ is retired
1375
1434
  let err_at = parse_expr_str("Table[\"row\", @]").unwrap_err();
@@ -452,6 +452,8 @@ pub fn extract_scalar_number(arg: &FunctionArg<'_>) -> Result<f64, ExcelError> {
452
452
  match arg {
453
453
  FunctionArg::Scalar(val) => val.coerce_to_number(),
454
454
  FunctionArg::Array { values, .. } if values.len() == 1 => values[0].coerce_to_number(),
455
- _ => Err(ExcelError::Value),
455
+ FunctionArg::Array { .. } | FunctionArg::Lazy(_) | FunctionArg::Omitted => {
456
+ Err(ExcelError::Value)
457
+ }
456
458
  }
457
459
  }