summaryrefslogtreecommitdiff
path: root/src/lower
diff options
context:
space:
mode:
authorGreg Brown <gmb60@cam.ac.uk>2021-01-07 12:44:06 +0000
committerGreg Brown <gmb60@cam.ac.uk>2021-01-07 12:44:06 +0000
commitfe2eac31d9dbec772796c3ea75be32e9cd01b810 (patch)
treead0c0ad42ce986d3dd915512de8c18968194c15a /src/lower
parenteb280a903f8f20d0b0c0ef5acae955a20929d100 (diff)
Add first steps of AutoChomp
Diffstat (limited to 'src/lower')
-rw-r--r--src/lower/rust.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lower/rust.rs b/src/lower/rust.rs
index c236bdd..fab040b 100644
--- a/src/lower/rust.rs
+++ b/src/lower/rust.rs
@@ -66,6 +66,7 @@ impl Backend for RustBackend {
);
let tokens = quote! {
#[doc=#doc_name]
+ #[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct #name;
impl Parse for #name {
@@ -128,6 +129,7 @@ impl Backend for RustBackend {
let right_ty = self.data[right].0.clone();
let name = format_ident!("Alt{}", id);
let mut tokens = quote! {
+ #[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum #name {
Left(#left_ty),
Right(#right_ty),
@@ -170,7 +172,7 @@ impl Backend for RustBackend {
match input.peek().ok_or(TakeError::EndOfStream)? {
#(#iter_left)|* => input.take().map(Self::Left),
#(#iter_right)|* => input.take().map(Self::Right),
- c => input.error(TakeError::BadBranch(c, &[#(#iter_first),*]))
+ c => Err(TakeError::BadBranch(c, &[#(#iter_first),*]))
}
}
}
@@ -204,11 +206,12 @@ impl Backend for RustBackend {
let inner = inner.gen(self);
let inner_ty = self.data[inner].0.clone();
let tokens = quote! {
+ #[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct #name(#inner_ty);
impl Parse for #name {
fn take<P: Parser + ?Sized>(input: &mut P) -> Result<Self, TakeError> {
- input.parse().map(Self)
+ input.take().map(Self)
}
}
};