| Crates.io | xdl-matlab |
| lib.rs | xdl-matlab |
| version | 0.1.1 |
| created_at | 2025-12-31 18:33:24.435726+00 |
| updated_at | 2025-12-31 22:19:10.131965+00 |
| description | Extended Data Language (XDL) - Rust implementation |
| homepage | https://turingworks.github.io/xdl |
| repository | https://github.com/turingworks/xdl |
| max_upload_size | |
| id | 2015119 |
| size | 124,939 |
This crate provides MATLAB/Octave compatibility for XDL, enabling:
Converts MATLAB code to XDL-compatible syntax:
% → ;for i = 1:10 → for i = 0, 9.* → *, ./ → /, .^ → ^| MATLAB | XDL | Notes |
|---|---|---|
zeros(n) |
FLTARR(n) |
Array creation |
sin(x) |
SIN(x) |
Trig functions |
mean(x) |
MEAN(x) |
Statistics |
plot(x, y) |
PLOT, y, x |
Plotting |
disp(x) |
PRINT, x |
I/O |
See function_map.rs for complete list.
use xdl_matlab::transpile_matlab_to_xdl;
let matlab_code = r#"
x = zeros(10, 1);
for i = 1:10
x(i) = sin(i * 0.1);
end
"#;
let xdl_code = transpile_matlab_to_xdl(matlab_code)?;
println!("{}", xdl_code);
use xdl_matlab::load_matlab_file;
let xdl_code = load_matlab_file(Path::new("script.m"))?;
// Execute with XDL interpreter
Input MATLAB:
% Calculate mean
x = zeros(10, 1);
for i = 1:10
x(i) = i * 2;
end
mean_x = mean(x);
disp('Mean value:');
disp(mean_x);
Output XDL:
; Calculate mean
x = FLTARR ( 10 , 1 )
for i = 0, 9
x [ i ] = i * 2
endfor
mean_x = MEAN ( x )
PRINT , 'Mean value:'
PRINT , mean_x
{} syntax not yet supportedMATLAB uses 1-based indexing, XDL uses 0-based:
x(1) % MATLAB: first element
x[0] % XDL: first element
The transpiler automatically adjusts simple numeric indices.
cargo test -p xdl-matlab
Function mappings and syntax rules are in:
function_map.rs - Add new MATLAB→XDL function mappingstranspiler.rs - Extend syntax transpilation ruleslexer.rs - Handle new token typesSame as parent XDL project.