#parser #grammar #ast #peg

macro peginator_macro

Convenience macros for using peginator (a PEG parser generator)

12 releases

0.7.0 Feb 11, 2024
0.6.0 Nov 28, 2022
0.5.1 Nov 28, 2022
0.2.0 Jul 17, 2022

#61 in #peg

Download history 41/week @ 2023-10-29 15/week @ 2023-11-05 18/week @ 2023-11-12 16/week @ 2023-11-19 30/week @ 2023-11-26 66/week @ 2023-12-03 8/week @ 2023-12-10 25/week @ 2023-12-17 43/week @ 2023-12-24 6/week @ 2023-12-31 14/week @ 2024-01-07 13/week @ 2024-01-14 20/week @ 2024-01-21 37/week @ 2024-01-28 16/week @ 2024-02-04 106/week @ 2024-02-11

181 downloads per month
Used in 3 crates (via bpf-script)

MIT license

275KB
6.5K SLoC

Peginator macro

Proc-macro support for peginator. Please find documentation and other goodies on the main project.

Usage:

use peginator_macro::peginate;
use peginator::PegParser;

peginate!("
@export
PizzaRule =
    'Pizza' 'with'
    toppings:Topping
    {',' toppings:Topping}
    ['and' toppings:Topping]
;
@string
Topping = 'sausage' | 'pineapple' | 'bacon' | 'cheese';
");

fn main() {
    let result = PizzaRule::parse("Pizza with sausage, bacon and cheese").unwrap();
    println!("{:?}", result.toppings);
}

Dependencies

~0.6–9.5MB
~73K SLoC