summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Brown <gmb60@cam.ac.uk>2021-01-19 22:37:35 +0000
committerGreg Brown <gmb60@cam.ac.uk>2021-01-19 22:38:45 +0000
commit8f7a17e0f48e3586fae619be08351c6761b07596 (patch)
tree0fe2c78b93cdfcbe7b6621c272c8b73eacfc53c4
parentf6916209d57682493288ab42e695204b95d0ba23 (diff)
Remove usage of `extra-traits` feature of syn.
-rw-r--r--Cargo.toml5
-rw-r--r--src/chomp/ast/mod.rs9
-rw-r--r--src/chomp/typed/infer.rs8
-rw-r--r--src/nibble/convert.rs16
-rw-r--r--src/nibble/cst.rs24
5 files changed, 29 insertions, 33 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 182c046..29a4509 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,11 +10,8 @@ members = ["autochomp", "chewed", "chomp-macro"]
[dependencies]
heck = "0.3.2"
quote = "1.0.8"
+syn = "1.0.58"
[dependencies.proc-macro2]
version = "1.0.24"
features = ["span-locations"]
-
-[dependencies.syn]
-version = "1.0.58"
-features = ["extra-traits"]
diff --git a/src/chomp/ast/mod.rs b/src/chomp/ast/mod.rs
index 9a159e4..e4ed2fc 100644
--- a/src/chomp/ast/mod.rs
+++ b/src/chomp/ast/mod.rs
@@ -1,7 +1,6 @@
use std::fmt::{self, Display};
use proc_macro2::Span;
-use syn::Token;
use super::Name;
@@ -16,9 +15,9 @@ pub type Literal = String;
#[derive(Clone, Debug)]
pub struct Cat {
pub first: Box<NamedExpression>,
- pub punct: Option<Token![.]>,
+ pub punct: Option<Span>,
pub second: Box<NamedExpression>,
- pub rest: Vec<(Option<Token![.]>, NamedExpression)>,
+ pub rest: Vec<(Option<Span>, NamedExpression)>,
}
impl Display for Cat {
@@ -49,9 +48,9 @@ impl Eq for Cat {}
#[derive(Clone, Debug)]
pub struct Alt {
pub first: Box<NamedExpression>,
- pub punct: Option<Token![|]>,
+ pub punct: Option<Span>,
pub second: Box<NamedExpression>,
- pub rest: Vec<(Option<Token![|]>, NamedExpression)>
+ pub rest: Vec<(Option<Span>, NamedExpression)>
}
impl Display for Alt {
diff --git a/src/chomp/typed/infer.rs b/src/chomp/typed/infer.rs
index 0161471..8095103 100644
--- a/src/chomp/typed/infer.rs
+++ b/src/chomp/typed/infer.rs
@@ -48,11 +48,11 @@ impl Folder for TypeInfer<'_> {
let rest = rest
.into_iter()
.map(|(punct, term)| -> Result<_, TypeError> {
- Ok((punct.map(|p| p.span), term.fold(&mut infer)?))
+ Ok((punct, term.fold(&mut infer)?))
})
.collect::<Result<Vec<_>, _>>()?;
Ok(TypedExpression {
- inner: super::Cat::new(first, punct.map(|p| p.span), second, rest)?.into(),
+ inner: super::Cat::new(first, punct, second, rest)?.into(),
name,
span,
})
@@ -71,11 +71,11 @@ impl Folder for TypeInfer<'_> {
let rest = rest
.into_iter()
.map(|(punct, term)| -> Result<_, TypeError> {
- Ok((punct.map(|p| p.span), term.fold(&mut infer)?))
+ Ok((punct, term.fold(&mut infer)?))
})
.collect::<Result<Vec<_>, _>>()?;
Ok(TypedExpression {
- inner: super::Alt::new(first, punct.map(|p| p.span), second, rest)?.into(),
+ inner: super::Alt::new(first, punct, second, rest)?.into(),
name,
span,
})
diff --git a/src/nibble/convert.rs b/src/nibble/convert.rs
index e3c8bfc..f7c20be 100644
--- a/src/nibble/convert.rs
+++ b/src/nibble/convert.rs
@@ -206,25 +206,25 @@ impl Convert for Cat {
let mut iter = self.0.into_pairs();
let (first, punct) = match iter.next().unwrap() {
- Pair::Punctuated(t, p) => (t.convert(context)?, Some(p)),
+ Pair::Punctuated(t, p) => (t.convert(context)?, Some(p.span)),
Pair::End(t) => (t.convert(context)?, None),
};
let mut rest = Vec::new();
let (span, _) = iter.try_fold(
(
- first.span.and_then(|s| punct.and_then(|p| s.join(p.span))),
+ first.span.and_then(|s| punct.and_then(|p| s.join(p))),
punct,
),
|(span, punct), pair| {
let (snd, p) = match pair {
- Pair::Punctuated(t, p) => (t.convert(context)?, Some(p)),
+ Pair::Punctuated(t, p) => (t.convert(context)?, Some(p.span)),
Pair::End(t) => (t.convert(context)?, None),
};
let span = span
.and_then(|s| snd.span.and_then(|t| s.join(t)))
- .and_then(|s| p.and_then(|p| s.join(p.span)));
+ .and_then(|s| p.and_then(|p| s.join(p)));
rest.push((punct, snd));
Ok((span, p))
},
@@ -268,25 +268,25 @@ impl Convert for Alt {
let mut iter = self.0.into_pairs();
let (first, punct) = match iter.next().unwrap() {
- Pair::Punctuated(t, p) => (t.convert(context)?, Some(p)),
+ Pair::Punctuated(t, p) => (t.convert(context)?, Some(p.span)),
Pair::End(t) => (t.convert(context)?, None),
};
let mut rest = Vec::new();
let (span, _) = iter.try_fold(
(
- first.span.and_then(|s| punct.and_then(|p| s.join(p.span))),
+ first.span.and_then(|s| punct.and_then(|p| s.join(p))),
punct,
),
|(span, punct), pair| {
let (snd, p) = match pair {
- Pair::Punctuated(t, p) => (t.convert(context)?, Some(p)),
+ Pair::Punctuated(t, p) => (t.convert(context)?, Some(p.span)),
Pair::End(t) => (t.convert(context)?, None),
};
let span = span
.and_then(|s| snd.span.and_then(|t| s.join(t)))
- .and_then(|s| p.and_then(|p| s.join(p.span)));
+ .and_then(|s| p.and_then(|p| s.join(p)));
rest.push((punct, snd));
Ok((span, p))
},
diff --git a/src/nibble/cst.rs b/src/nibble/cst.rs
index 2fcc99f..fc698e8 100644
--- a/src/nibble/cst.rs
+++ b/src/nibble/cst.rs
@@ -19,7 +19,7 @@ pub type Ident = syn::Ident;
pub type Literal = LitStr;
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct ArgList<T> {
paren_token: Paren,
args: Punctuated<T, Comma>,
@@ -58,7 +58,7 @@ impl<T: Parse> Parse for ArgList<T> {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct Call {
pub name: Ident,
pub args: ArgList<Expression>,
@@ -78,7 +78,7 @@ impl Parse for Call {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct Fix {
bracket_token: Bracket,
pub arg: Ident,
@@ -109,7 +109,7 @@ impl Parse for Fix {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct ParenExpression {
paren_token: Paren,
pub expr: Expression,
@@ -124,7 +124,7 @@ impl Parse for ParenExpression {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub enum Term {
Epsilon(Epsilon),
Ident(Ident),
@@ -173,7 +173,7 @@ impl Parse for Term {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct Cat(pub Punctuated<Term, Token![.]>);
impl Parse for Cat {
@@ -200,7 +200,7 @@ impl Cat {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct Label {
colon_tok: Token![:],
pub label: Ident,
@@ -220,7 +220,7 @@ impl Parse for Label {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct Labelled {
pub cat: Cat,
pub label: Option<Label>,
@@ -248,7 +248,7 @@ impl Parse for Labelled {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct Alt(pub Punctuated<Labelled, Token![|]>);
impl Parse for Alt {
@@ -259,7 +259,7 @@ impl Parse for Alt {
pub type Expression = Alt;
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct LetStatement {
let_token: Token![let],
name: Ident,
@@ -299,7 +299,7 @@ impl Parse for LetStatement {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct GoalStatement {
match_token: Token![match],
expr: Expression,
@@ -320,7 +320,7 @@ impl Parse for GoalStatement {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone)]
pub struct File {
lets: Vec<LetStatement>,
goal: GoalStatement,