| Crates.io | oak-wolfram |
| lib.rs | oak-wolfram |
| version | 0.0.1 |
| created_at | 2025-10-21 13:39:07.210205+00 |
| updated_at | 2026-01-23 05:37:56.8662+00 |
| description | Wolfram Language parser with support for Mathematica syntax and symbolic computation. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1893809 |
| size | 70,898 |
High-performance incremental Wolfram Language parser for the oak ecosystem with flexible configuration, optimized for mathematical computation and symbolic analysis.
Oak Wolfram is a robust parser for the Wolfram Language, designed to handle complete Wolfram syntax including mathematical expressions, symbolic computations, and functional programming constructs. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for mathematical analysis and code generation.
Basic example:
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_wolfram::{WolframParser, WolframLanguage};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut session = ParseSession::<WolframLanguage>::default();
let parser = WolframParser::new();
let source = SourceText::new(r#"
f[x_] := x^2 + 2*x + 1
Plot[f[x], {x, -10, 10}]
"#);
let result = parser.parse(&source, &[], &mut session);
println!("Parsed Wolfram successfully.");
Ok(())
}
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_wolfram::{WolframParser, WolframLanguage};
let mut session = ParseSession::<WolframLanguage>::default();
let parser = WolframParser::new();
let source = SourceText::new(r#"
factorial[n_] := If[n <= 1, 1, n * factorial[n - 1]]
"#);
let result = parser.parse(&source, &[], &mut session);
println!("Function parsed successfully.");
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_wolfram::{WolframParser, WolframLanguage};
let mut session = ParseSession::<WolframLanguage>::default();
let parser = WolframParser::new();
let source = SourceText::new(r#"
Integrate[Sin[x], {x, 0, Pi}]
"#);
let result = parser.parse(&source, &[], &mut session);
println!("Expression parsed successfully.");
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_wolfram::{WolframParser, WolframLanguage};
let mut session = ParseSession::<WolframLanguage>::default();
let parser = WolframParser::new();
let source = SourceText::new("f[x_] := x^2");
let result = parser.parse(&source, &[], &mut session);
println!("Token parsing completed.");
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_wolfram::{WolframParser, WolframLanguage};
let mut session = ParseSession::<WolframLanguage>::default();
let parser = WolframParser::new();
let source = SourceText::new(r#"
f[x_ := x^2 + 1
(* Missing closing bracket *)
"#);
let result = parser.parse(&source, &[], &mut session);
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 Wolfram 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.