#peg-parser #peg #parser #ast #grammar #parser-generator

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

#54 in #peg


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.5–11MB
~74K SLoC