#parser #kma #group #description

bin+lib my_parser_kma_group_8

A brief description of my crate

1 unstable release

0.1.1 Oct 31, 2024
0.1.0 Oct 31, 2024

#6 in #kma

MIT license

69KB

My Parser

Short Description

This parser analyzes and processes lists of numbers in string format. It uses the peg library for parsing input data, providing a simple interface for parsing numbers enclosed in square brackets.

Screenshot of the parser in action

Example

peg::parser! {
    pub grammar list_parser() for str {
        rule number() -> u32
            = n:$(['0'..='9']+) {? n.parse().or(Err("u32")) }

        pub rule list() -> Vec<u32>
            = "[" l:(number() ** ",") "]" { l }
    }
}

pub fn main() {
    println!("{:?}", list_parser::list("[1,1,2,3,5,8]"));
}

Dependencies

~140KB