| Crates.io | oak-matlab |
| lib.rs | oak-matlab |
| version | 0.0.1 |
| created_at | 2025-10-21 02:41:36.910702+00 |
| updated_at | 2026-01-23 04:41:48.982247+00 |
| description | MATLAB numerical computing language parser with support for scientific computing, data analysis, and visualization. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1893183 |
| size | 85,662 |
High-performance incremental MATLAB parser for the oak ecosystem with flexible configuration, optimized for scientific computing and data analysis.
Oak MATLAB is a robust parser for MATLAB, designed to handle complete MATLAB syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for static analysis and code generation.
Basic example:
use oak_matlab::{Parser, MatlabLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
function result = add(a, b)
result = a + b;
end
disp('Hello, MATLAB!');
"#);
let result = parser.parse(&source);
println!("Parsed MATLAB successfully.");
Ok(())
}
use oak_matlab::{Parser, MatlabLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
function result = factorial(n)
if n <= 1
result = 1;
else
result = n * factorial(n - 1);
end
end
"#);
let result = parser.parse(&source);
println!("Function parsed successfully.");
use oak_matlab::{Parser, MatlabLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
A = [1, 2, 3; 4, 5, 6; 7, 8, 9];
B = A';
C = A .* B;
D = A \ B;
E = det(A);
F = eig(A);
"#);
let result = parser.parse(&source);
println!("Matrix operations parsed successfully.");
use oak_matlab::{Parser, MatlabLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("x = 42;");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_matlab::{Parser, MatlabLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
% Invalid MATLAB code example
function broken_function(
disp('Hello'
% Missing closing parenthesis and end
"#);
let result = parser.parse(&source);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed successfully.");
}
The parser generates a comprehensive AST with the following main structures:
Oak MATLAB integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.