summaryrefslogtreecommitdiff
path: root/abnf_to_pest/src
diff options
context:
space:
mode:
authorNadrieril2019-04-16 22:23:40 +0200
committerNadrieril2019-04-16 22:23:40 +0200
commite5d40d38735afb4252d6f25ee8f834f9b097e0f7 (patch)
tree5c3cf45d07c71e049eebc0b5a0ba70b0812d0678 /abnf_to_pest/src
parent47d5dbcfffa7842466187197513ffa403a0fdb59 (diff)
Tiny rename to save myself a lot of pain
Diffstat (limited to '')
-rw-r--r--abnf_to_pest/src/lib.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/abnf_to_pest/src/lib.rs b/abnf_to_pest/src/lib.rs
index 625798b..d460bf9 100644
--- a/abnf_to_pest/src/lib.rs
+++ b/abnf_to_pest/src/lib.rs
@@ -25,9 +25,9 @@ use abnf::abnf::Rule;
pub use abnf::abnf::{
Alternation, Concatenation, Element, Range, Repeat, Repetition,
};
+use indexmap::map::IndexMap;
use itertools::Itertools;
use pretty::{BoxDoc, Doc};
-use indexmap::map::IndexMap;
trait Pretty {
fn pretty(&self) -> Doc<'static, BoxDoc<'static, ()>>;
@@ -116,6 +116,7 @@ impl Pretty for Range {
///
/// Replaces e.g. `if` with `if_`, and `rule-name` with `rule_name`.
/// Also changes `whitespace` to `whitespace_` because of https://github.com/pest-parser/pest/pull/374
+/// Also changes `Some` and `None` to `Some_` and `None_`, because it was such a pain to work around.
pub fn escape_rulename(x: &str) -> String {
let x = x.replace("-", "_");
if x == "if"
@@ -124,6 +125,9 @@ pub fn escape_rulename(x: &str) -> String {
|| x == "let"
|| x == "in"
|| x == "fn"
+ // Not required but such a pain
+ || x == "Some"
+ || x == "None"
// TODO: remove when https://github.com/pest-parser/pest/pull/375 gets into a release
|| x == "whitespace"
{
@@ -147,6 +151,7 @@ fn format_char(x: u32) -> String {
}
/// Allow control over some of the pest properties of the outputted rule
+#[derive(Debug, Clone)]
pub struct PestyRule {
pub silent: bool,
pub elements: Alternation,