Crates.io | pkl-parser |
lib.rs | pkl-parser |
version | 0.8.1 |
source | src |
created_at | 2024-08-19 18:10:36.572913 |
updated_at | 2024-08-19 18:12:06.802948 |
description | A rust Pkl Parser! |
homepage | |
repository | https://github.com/DevYatsu/pkl_parser |
max_upload_size | |
id | 1344295 |
size | 69,974 |
This crate exports a parser for Apple's Pkl language.
All the Pkl syntax is supported.
When in your rust project, simply run: cargo add pkl-parser
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(())
}
This project is licensed under the MIT License. See the LICENSE file for details.