39 releases

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

#887 in Parser implementations

Download history 13/week @ 2023-12-24 3/week @ 2023-12-31 52/week @ 2024-01-07 20/week @ 2024-01-14 39/week @ 2024-01-21 58/week @ 2024-01-28 7/week @ 2024-02-04 10/week @ 2024-02-11 276/week @ 2024-02-18 102/week @ 2024-02-25 33/week @ 2024-03-03 64/week @ 2024-03-10 46/week @ 2024-03-17 20/week @ 2024-03-24 115/week @ 2024-03-31 6/week @ 2024-04-07

194 downloads per month
Used in 5 crates

MIT license

33KB
988 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–560KB
~13K SLoC