This project aims to implement a fully functional AsciiMath parser for rust. It's part of the snekdown parser project.
See the spec.
```rust use asciimath_rs::format::mathml::ToMathML;
fn main() { let expression = asciimathrs::parse("sin(2x) + 3".tostring()); let mathmlstring = expression.tomathml(); } ```
```rust use asciimathrs::parsing::tokenizer::Tokenizer; use asciimathrs::parsing::treeparser::TreeParser; use asciimathrs::format::mathml::ToMathML;
fn main() { let mut tokenizer = Tokenizer::new("cos(2) - alpha".tostring()); let tokens = tokenizer.parse(); let mut treeparser = TreeParser::new(tokens); let expression = treeparser.parse(); let mathmlstring = expression.to_mathml(); } ```
As seen in the less simple example the parsing works in two steps. In the first step the raw input string is analyzed and converted into Tokens that represent the syntactic meaning of a sequence of characters. The second step takes the flat vector of tokens and converts it into a tree in a depth first way.
The resulting expression can then be converted into MathML with the default ToMathML
trait implementation.
This project is Apache 2.0 licensed.