#pest #fmt

bin+lib pest_fmt

A formatter tool for pest

6 releases

0.2.4 Mar 14, 2023
0.2.3 Mar 4, 2023
0.2.1 Feb 28, 2023
0.2.0 Feb 6, 2020
0.1.1 Feb 28, 2020
Download history 52/week @ 2023-06-08 115/week @ 2023-06-15 100/week @ 2023-06-22 89/week @ 2023-06-29 87/week @ 2023-07-06 80/week @ 2023-07-13 95/week @ 2023-07-20 86/week @ 2023-07-27 70/week @ 2023-08-03 82/week @ 2023-08-10 70/week @ 2023-08-17 62/week @ 2023-08-24 134/week @ 2023-08-31 161/week @ 2023-09-07 131/week @ 2023-09-14 90/week @ 2023-09-21

531 downloads per month
Used in pest-language-server

MPL-2.0 license

44KB
900 lines

Pest Formatter

Test Crate

Pest Formatter is a tool to format Pest grammar files.

Installation

cargo install pest_fmt

Usage

Then use the pestfmt command to format your .pest files.

pestfmt .

It will find all .pest files in the current directory and format them.

Output:

Pest Formatter
-------------------------------------
2 files formatted.

Usage as a library

Add pest_fmt into your Cargo.toml:

cargo add pest_fmt

Then use the Formatter struct to format pest grammar.

use pest_fmt::Formatter;

let mut fmt = Formatter::new("a={ASCII_DIGIT}");
let out = fmt.format().unwrap();
println!("{out}");
// a = { ASCII_DIGIT }

Development Tool Integration

VS Code

https://github.com/pest-parser/pest-ide-tools

Benchmark

Based on MacBook Pro (Apple M1 2020)

format (json.pest)                time:   [89.403 µs 89.632 µs 89.878 µs]
format (grammar.pest)             time:   [1.6018 ms 1.6054 ms 1.6105 ms]

License

Mozilla Public License 2.0

Dependencies

~6–8.5MB
~149K SLoC