#ocaml #parser #file-format #parser-implementations #opam

已删除 opam-file-parser

Rust编写的opam文件语法的解析器和打印器

0.1.0 2021年2月15日

#7#parser-implementations

MIT 许可证

26KB
713

opam-file-rs: 使用Rust编写的opam文件语法的解析器和打印器

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

解析OPAM

解析OPAM文件。

use opam_file_rs;
fn main () {
  let opam = r#"
    opam-verion: "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 <[email protected]>"
    depends: [
      "lalrpop-util" {>= "0.19.4"}
      "thiserror" {>= "1.0.23"}
    ]
  "#;
  assert!(opam_file_rs::parse(opam).is_ok());
}

转换为OPAM文件格式。

可以通过 value::format_opam_file 将数据结构转换为OPAM文件格式。

use opam_file_rs;
fn main() {
  let opam_str = r#"
    opam-verion: "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 <[email protected]>"
    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 (又名 "puripuri2100")

依赖关系

~0.3–2.4MB
~40K SLoC