#parser #cirru

cirru_parser

Parser for Cirru text syntax

34 releases

0.1.24 Aug 23, 2022
0.1.23 Jun 9, 2022
0.1.22 May 28, 2022
0.1.18 Mar 8, 2022
0.1.1 Apr 30, 2021
Download history 58/week @ 2023-01-25 89/week @ 2023-02-01 116/week @ 2023-02-08 170/week @ 2023-02-15 332/week @ 2023-02-22 58/week @ 2023-03-01 60/week @ 2023-03-08 123/week @ 2023-03-15 30/week @ 2023-03-22 29/week @ 2023-03-29 71/week @ 2023-04-05 60/week @ 2023-04-12 6/week @ 2023-04-19 70/week @ 2023-04-26 82/week @ 2023-05-03 68/week @ 2023-05-10

227 downloads per month
Used in 5 crates

MIT license

32KB
1K SLoC

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

~160KB