summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2020-10-30 20:51:29 +0000
committerNadrieril2020-10-30 20:51:29 +0000
commitcd1b47453e7d2b11bf489d8c286bdda86467426f (patch)
tree0f1e9433ea7756856efaee2bd89721dc82e7f0c5
parent90aea87a068625c09783c67ad5e879f3ee4deb2a (diff)
Update abnf dependency
Diffstat (limited to '')
-rw-r--r--Cargo.lock14
-rw-r--r--abnf_to_pest/Cargo.toml2
-rw-r--r--abnf_to_pest/src/lib.rs22
3 files changed, 24 insertions, 14 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 53db396..7765554 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,9 +2,19 @@
# It is not intended for manual editing.
[[package]]
name = "abnf"
-version = "0.6.1"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76d5f963d2236fd5701b660a9733bd22a5be300267955c71fa03bdf75ecb30b5"
+dependencies = [
+ "abnf-core",
+ "nom",
+]
+
+[[package]]
+name = "abnf-core"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "47feb9fbcef700639ef28e04ca2a87eab8161a01a075ee227b15c90143805462"
+checksum = "137c894fdb05ad3feb514cec800945cfebbb6435c73f9c2097b953e44a106273"
dependencies = [
"nom",
]
diff --git a/abnf_to_pest/Cargo.toml b/abnf_to_pest/Cargo.toml
index 6a4abc4..a2b1dbc 100644
--- a/abnf_to_pest/Cargo.toml
+++ b/abnf_to_pest/Cargo.toml
@@ -13,7 +13,7 @@ repository = "https://github.com/Nadrieril/dhall-rust"
doctest = false
[dependencies]
-abnf = "0.6.0"
+abnf = "0.9.0"
indexmap = "1.0.2"
itertools = "0.9.0"
pretty = "0.10.0"
diff --git a/abnf_to_pest/src/lib.rs b/abnf_to_pest/src/lib.rs
index 64672cc..deddf54 100644
--- a/abnf_to_pest/src/lib.rs
+++ b/abnf_to_pest/src/lib.rs
@@ -21,7 +21,7 @@
//!
//! [pest]: https://pest.rs
-use abnf::types::{Node, NumVal, Repeat, Rule};
+use abnf::types::{Node, Repeat, Rule, TerminalValues};
use indexmap::map::IndexMap;
use itertools::Itertools;
use pretty::BoxDoc;
@@ -43,7 +43,7 @@ impl Pretty for Node {
BoxDoc::space().append(BoxDoc::text("~ ")),
),
Repetition(rep) => {
- rep.get_node().pretty().append(rep.get_repeat().pretty())
+ rep.node().pretty().append(rep.repeat().pretty())
}
Rulename(s) => BoxDoc::text(escape_rulename(s)),
Group(n) => BoxDoc::text("(")
@@ -52,19 +52,19 @@ impl Pretty for Node {
Optional(n) => BoxDoc::text("(")
.append(n.pretty().nest(4).group())
.append(BoxDoc::text(")?")),
- CharVal(s) => BoxDoc::text(format!(
+ String(s) => BoxDoc::text(format!(
"^\"{}\"",
s.replace("\"", "\\\"").replace("\\", "\\\\")
)),
- NumVal(r) => r.pretty(),
- ProseVal(_) => unimplemented!(),
+ TerminalValues(r) => r.pretty(),
+ Prose(_) => unimplemented!(),
}
}
}
impl Pretty for Repeat {
fn pretty(&self) -> BoxDoc<'static> {
- BoxDoc::text(match (self.get_min().unwrap_or(0), self.get_max()) {
+ BoxDoc::text(match (self.min().unwrap_or(0), self.max()) {
(0, None) => "*".into(),
(1, None) => "+".into(),
(0, Some(1)) => "?".into(),
@@ -75,14 +75,14 @@ impl Pretty for Repeat {
}
}
-impl Pretty for NumVal {
+impl Pretty for TerminalValues {
fn pretty(&self) -> BoxDoc<'static> {
- use NumVal::*;
+ use TerminalValues::*;
BoxDoc::text(match self {
Range(x, y) => {
format!("'{}'..'{}'", format_char(*x), format_char(*y))
}
- Terminal(v) => {
+ Concatenation(v) => {
format!("\"{}\"", v.iter().map(|x| format_char(*x)).join(""))
}
})
@@ -160,10 +160,10 @@ pub fn parse_abnf(
.into_iter()
.map(|rule| {
(
- escape_rulename(rule.get_name()),
+ escape_rulename(rule.name()),
PestyRule {
silent: false,
- node: rule.get_node().clone(),
+ node: rule.node().clone(),
},
)
})