diff options
author | Nadrieril | 2019-04-15 17:43:39 +0200 |
---|---|---|
committer | Nadrieril | 2019-04-15 17:43:39 +0200 |
commit | 6ef11130281a16e5ca23250ac78bcd27c777a14e (patch) | |
tree | 95c60869904bb858f0ea31aba6a21e81faafe0d2 | |
parent | 52615794bfe69a3ad14bff0044ade776028c08cd (diff) |
Keep rule order in `abnf_to_pest`
Closes #79
Diffstat (limited to '')
-rw-r--r-- | Cargo.lock | 7 | ||||
-rw-r--r-- | abnf_to_pest/Cargo.toml | 1 | ||||
-rw-r--r-- | abnf_to_pest/src/lib.rs | 4 |
3 files changed, 10 insertions, 2 deletions
@@ -13,6 +13,7 @@ name = "abnf_to_pest" version = "0.1.0" dependencies = [ "abnf 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -150,6 +151,11 @@ name = "improved_slice_patterns" version = "1.0.1" [[package]] +name = "indexmap" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "itertools" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -419,6 +425,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum half 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9353c2a89d550b58fa0061d8ed8d002a7d8cdf2494eb0e432859bd3a9e543836" +"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43" diff --git a/abnf_to_pest/Cargo.toml b/abnf_to_pest/Cargo.toml index fc9fe66..cd6aa10 100644 --- a/abnf_to_pest/Cargo.toml +++ b/abnf_to_pest/Cargo.toml @@ -10,5 +10,6 @@ doctest = false [dependencies] abnf = "0.1.2" +indexmap = "1.0.2" itertools = "0.8.0" pretty = "0.5.2" diff --git a/abnf_to_pest/src/lib.rs b/abnf_to_pest/src/lib.rs index 46bd79d..f1a167f 100644 --- a/abnf_to_pest/src/lib.rs +++ b/abnf_to_pest/src/lib.rs @@ -8,7 +8,7 @@ pub use abnf::abnf::{ }; use itertools::Itertools; use pretty::{BoxDoc, Doc}; -use std::collections::HashMap; +use indexmap::map::IndexMap; trait Pretty { fn pretty(&self) -> Doc<'static, BoxDoc<'static, ()>>; @@ -146,7 +146,7 @@ impl Pretty for (String, PestyRule) { /// Parse an abnf file. Returns a map of rules. pub fn parse_abnf( data: &[u8], -) -> Result<HashMap<String, PestyRule>, std::io::Error> { +) -> Result<IndexMap<String, PestyRule>, std::io::Error> { let make_err = |e| std::io::Error::new(std::io::ErrorKind::Other, format!("{}", e)); let rules: Vec<Rule> = |