2 unstable releases
0.8.1 | Aug 19, 2024 |
---|---|
0.1.1 | Aug 19, 2024 |
#106 in Parser tooling
21KB
246 lines
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.
Dependencies
~2.1–2.8MB
~57K SLoC