Generic Shunting Yard
The gyard crate is a generic implementation of the shunting yard algorythm with support for funtions. Not more not less.
use ;
// 5 + 2 * sin(123)
let infix = ;
let postfix = to_postfix;
assert_eq!;
The gyard crate is a generic implementation of the shunting yard algorythm with support for funtions. Not more not less.
use gyard::{InputToken, OutputToken, op::Math, to_postfix};
// 5 + 2 * sin(123)
let infix = [
InputToken::Value(5),
InputToken::Operator(Math::Add),
InputToken::Value(2),
InputToken::Operator(Math::Mul),
InputToken::Function("sin"),
InputToken::LeftParen,
InputToken::Value(123),
InputToken::RightParen,
];
let postfix = to_postfix(infix);
assert_eq!(postfix, Ok(vec![
OutputToken::Value(5),
OutputToken::Value(2),
OutputToken::Value(123),
OutputToken::Function("sin"),
OutputToken::Operator(Math::Mul),
OutputToken::Operator(Math::Add),
]));