41 releases

0.1.31 Jun 2, 2024
0.1.29 Feb 18, 2024
0.1.25 Aug 2, 2023
0.1.24 Aug 23, 2022
0.1.1 Apr 30, 2021

#1172 in Parser implementations

Download history 31/week @ 2024-08-08 28/week @ 2024-08-15 22/week @ 2024-08-22 92/week @ 2024-08-29 40/week @ 2024-09-05 42/week @ 2024-09-12 84/week @ 2024-09-19 83/week @ 2024-09-26 39/week @ 2024-10-03 40/week @ 2024-10-10 28/week @ 2024-10-17 27/week @ 2024-10-24 58/week @ 2024-10-31 29/week @ 2024-11-07 9/week @ 2024-11-14 23/week @ 2024-11-21

122 downloads per month
Used in 5 crates

MIT license

33KB
998 lines

Cirru Parser in Rust

Usages

Found on crate .

Rust Docs.

cargo install cirru_parser
use cirru_parser::{parse};

parse("defn f (x)\n  x"); // returns Result<Vec<Cirru>, String>

use writer:

use cirru_parser::{format, CirruWriterOptions, escape_cirru_leaf}

let writer_options = CirruWriterOptions { use_inline: false };
format(tree, writer_options); // tree is Vec<Cirru>

escape_cirru_leaf("a b");

License

MIT


lib.rs:

Cirru Parser

This tiny parser parses indentation based syntax into nested a vector, then it could used as S-Expressions for evaluation or codegen.

defn fib (x)
if (<= x 2) 1
+
fib $ dec x
fib $ - x 2

parses to:

[ ["defn" "fib" [ "x" ]
[ "if" [ "<=" "x" "2" ] "1"
[ "+" [ "fib" ["dec" "x"] ] [ "fib" ["-" "x" "2"] ] ]
]
] ]

find more on http://text.cirru.org/ .

Dependencies

~255–550KB
~12K SLoC