#ocaml #parser #file-format #opam

opam-file-rs

Parser and printer for the opam file syntax with Rust

4 releases

0.1.5 Jun 3, 2021
0.1.4 Jun 3, 2021
0.1.2 Feb 15, 2021
0.1.1 Feb 15, 2021

#1700 in Parser implementations

Download history 331/week @ 2024-11-16 371/week @ 2024-11-23 333/week @ 2024-11-30 441/week @ 2024-12-07 470/week @ 2024-12-14 348/week @ 2024-12-21 369/week @ 2024-12-28 379/week @ 2025-01-04 245/week @ 2025-01-11 247/week @ 2025-01-18 165/week @ 2025-01-25 476/week @ 2025-02-01 3190/week @ 2025-02-08 2163/week @ 2025-02-15 719/week @ 2025-02-22 4282/week @ 2025-03-01

10,461 downloads per month
Used in upstream-ontologist

MIT license

35KB
995 lines

opam-file-rs: Parser and printer for the opam file syntax with Rust

crates.io docs.rs Build Status source badge license badge

Parsing OPAM

Parse OPAM file.

use opam_file_rs;
fn main () {
  let opam = r#"
    opam-version: "2.0"
    version: "0.1.0"
    name: "opam-file-rs"
    dev-repo: "git+https://github.com/puripuri2100/opam-file-rs"
    license: "MIT"
    maintainer: "Naoki Kaneko <puripuri2100@gmail.com>"
    depends: [
      "lalrpop-util" {>= "0.19.4"}
      "thiserror" {>= "1.0.23"}
    ]
  "#;
  assert!(opam_file_rs::parse(opam).is_ok());
}

Convert to a OPAM file format.

A data structure can be converted to an OPAM file format by value::format_opam_file.

use opam_file_rs;
fn main() {
  let opam_str = r#"
    opam-version: "2.0"
    version: "0.1.0"
    name: "opam-file-rs"
    dev-repo: "git+https://github.com/puripuri2100/opam-file-rs"
    license: "MIT"
    maintainer: "Naoki Kaneko <puripuri2100@gmail.com>"
    depends: [
      "lalrpop-util" {>= "0.19.4"}
      "thiserror" {>= "1.0.23"}
    ]
  "#;
  let opam = opam_file_rs::parse(opam_str).unwrap();
  println!("{}", opam_file_rs::value::format_opam_file(opam));
}

(c) 2021 Naoki Kaneko (a.k.a. "puripuri2100")

Dependencies

~0.3–2.4MB
~40K SLoC