my_parser_kma_group_8

Crates.iomy_parser_kma_group_8
lib.rsmy_parser_kma_group_8
version0.1.1
sourcesrc
created_at2024-10-31 01:29:38.810709
updated_at2024-10-31 02:10:50.20406
descriptionA brief description of my crate
homepage
repository
max_upload_size
id1429489
size75,478
(bohdanaprokopchuk)

documentation

README

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]"));
}

Commit count: 0

cargo fmt