-
Notifications
You must be signed in to change notification settings - Fork 17
support for index expressions and SUM builtin
#70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #70 +/- ##
==========================================
+ Coverage 72.86% 77.68% +4.81%
==========================================
Files 25 28 +3
Lines 6166 8079 +1913
==========================================
+ Hits 4493 6276 +1783
- Misses 1673 1803 +130 ☔ View full report in Codecov by Sentry. |
91a50eb to
4e6d550
Compare
4e6d550 to
dfaf219
Compare
292a7b2 to
45139a4
Compare
45139a4 to
9904509
Compare
858719d to
60e1d64
Compare
077b3df to
b667b0d
Compare
b667b0d to
24eaab7
Compare
42701d3 to
ee3d815
Compare
This commit implements comprehensive array transposition functionality according
to the XMILE specification, which defines the transpose operator (') as having
the highest arithmetic precedence and reversing all array dimensions.
## Key Changes
### AST and Parser Support
- Added `Transpose` variant to `UnaryOp` enum in ast.rs
- Added `'` (apostrophe) token to lexer and parser (equation.lalrpop, token/mod.rs)
- Implemented `transpose()` method on `DimensionVec` that reverses dimension order
- Updated dimension inference to handle transpose operations correctly
### Compiler and VM Support
- Added AST lowering support for `ast::UnaryOp::Transpose` -> `UnaryOp::Transpose`
- Added `Transpose` opcode to bytecode.rs with VM execution support
- Implemented transpose evaluation in tree-walking interpreter (scalars remain unchanged)
- Updated expression evaluation and array substitution logic
- Added transpose support to pretty printing (outputs `expr'`)
### LaTeX Rendering
- Updated LatexVisitor to handle transpose operations with `expr'` format
- Restructured unary operation handling to support both prefix and suffix operators
### Units Support
- Added transpose handling to units system (transpose preserves units)
### Comprehensive Tests
- Added 5 dimension-level tests: basic 2D transpose, scalar, 1D, 3D, and double transpose
- Added parsing tests for transpose syntax (`a'`)
- Added LaTeX rendering tests
- All tests pass with proper dimension reversal validation
## Technical Details
The implementation follows XMILE v1.0 specification section 3.7.1 which defines
three ways to transpose arrays:
1. Transposition operator (`'`) - implemented here
2. Dimension name reordering - already supported via existing dimension system
3. Dimension position operator (`@`) - future work
For scalars and 1D arrays, transpose is identity operation. For multi-dimensional
arrays, transpose reverses the dimension order (e.g., [A,B,C] becomes [C,B,A]).
## Compliance
This implementation provides the foundation for XMILE-compliant array transposition
while maintaining full backward compatibility with existing functionality.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Split monolithic ast.rs (2,477 lines) into logical modules: - ast/expr0.rs: Initial parsed expressions (Expr0, IndexExpr0) - ast/expr1.rs: Builtin-resolved expressions (Expr1, IndexExpr1) - ast/expr2.rs: Dimension-annotated expressions (Expr, IndexExpr) + dimension types - ast/mod.rs: Visitors, utilities, and re-exports for backward compatibility Benefits: - Improved code organization and navigation - Logical separation of AST transformation stages - Dimension types co-located with final expression stage - Maintained complete API compatibility - all existing imports work unchanged - All 97 tests continue passing Updated design/full-array-support.md to document the refactoring and mark array transposition (item #5) as completed with comprehensive test coverage. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
two major pieces here: expanding the lexer + parser to support the full array indexing syntax. Second is supporting the array version of
minandmaxbuiltins, along with the array-onlyrank,size,stddev, andsum.