1use general_parser::{Adjacency, BinaryOperator, Configuration, Expression, UnaryOperator};
2
3fn main() {
4 let multiply_operator = BinaryOperator { representation: "*", precedence: 4 };
5 let sources = &["3xy+rx", "3*x*y+r*x", "(x + t)(x + z)", "sin(-x)"];
6 let configuration = Configuration {
7 prefix_unary_operators: vec![UnaryOperator { representation: "-", precedence: 2 }],
8 binary_operators: vec![
9 BinaryOperator { representation: "^", precedence: 5 },
10 BinaryOperator { representation: "*", precedence: 4 },
11 multiply_operator,
12 BinaryOperator { representation: "+", precedence: 3 },
13 ],
14 adjacency: Some(Adjacency { operator: multiply_operator, functions: vec!["sin"] }),
15 ..Default::default()
16 };
17
18 for source in sources {
19 let allocator = bumpalo::Bump::new();
20 let expression: Expression<&str> =
21 Expression::from_string(source, &configuration, &allocator);
22 eprintln!("{expression:#?}");
23 }
24}