pkl-parser

Crates.iopkl-parser
lib.rspkl-parser
version0.8.1
sourcesrc
created_at2024-08-19 18:10:36.572913
updated_at2024-08-19 18:12:06.802948
descriptionA rust Pkl Parser!
homepage
repositoryhttps://github.com/DevYatsu/pkl_parser
max_upload_size
id1344295
size69,974
Yatsu (DevYatsu)

documentation

https://docs.rs/new-pkl

README

pkl-parser

This crate exports a parser for Apple's Pkl language.

Features

All the Pkl syntax is supported.

Installation

When in your rust project, simply run: cargo add pkl-parser

Usage

Here's an example of how to parse a PKL string:

use pkl_parser::{parse, pratt, Rule, Error, Pairs};

fn main() -> Result<Pairs<Rule>, Error<Rule>> {
    let source = "//some pkl code";

    let pairs = parse(source)?;
    let file = result.next().unwrap().into_inner();

    for element in file {
        match element.as_rule() {
            // then take care of each stmt separately
            Rule::stmt => (),
            // then take care of each comment/annotation separately
            Rule::COMMENT => (),
            Rule::EOI => (),
            _ => unreachable!(),
        }
    }

    Ok(())
}

LICENSE

This project is licensed under the MIT License. See the LICENSE file for details.

Commit count: 0

cargo fmt