Debian Codegraph @

third_party/rust/winnow/examples/s_expression/main.rs

raw
1 //! In this example we build an [S-expression](https://en.wikipedia.org/wiki/S-expression)
2 //! parser and tiny [lisp](https://en.wikipedia.org/wiki/Lisp_(programming_language)) interpreter.
3 //! Lisp is a simple type of language made up of Atoms and Lists, forming easily parsable trees.
4
5 #![cfg(feature = "alloc")]
6
7 mod parser;
8
9 fn main() {
10 let expression_1 = "((if (= (+ 3 (/ 9 3))
11 (* 2 3))
12 *
13 /)
14 456 123)";
15 println!(
16 "\"{}\"\nevaled gives us: {:?}",
17 expression_1,
18 parser::eval_from_str(expression_1)
19 );
20 }