Commit cf662871 authored by Jeff Smits's avatar Jeff Smits

cargo fmt

parent 52200749
......@@ -75,10 +75,8 @@ pub fn interpret<'a>(factory: &'a ATermFactory,
let result = main.eval(&context, Vec::new(), Vec::new(), input);
match result {
Ok(_) |
Err(Error::InterpreterExit(_)) => {},
Err(_) => {
println!("Debug. Stacktrace: \n{}", *context.stack_tracer.borrow())
}
Err(Error::InterpreterExit(_)) => {}
Err(_) => println!("Debug. Stacktrace: \n{}", *context.stack_tracer.borrow()),
}
result
}
......@@ -214,48 +212,54 @@ fn eval_match<'a>(context: &MutContext<'a>,
eval_match(context, &*term, current)
}
Int(i) => {
current.get_int()
current
.get_int()
.and_then(|i2| if i == i2 { Some(()) } else { None })
.ok_or(Error::StrategyFailed)
}
Real(BrokenF32(f)) => {
eprintln!("pattern matching against floating point literal: very unlikely to match");
current.get_real()
current
.get_real()
.and_then(|f2| if f == f2 { Some(()) } else { None })
.ok_or(Error::StrategyFailed)
}
Str(ref s) => {
current.get_string()
current
.get_string()
.and_then(|s2| if *s == s2 { Some(()) } else { None })
.ok_or(Error::StrategyFailed)
}
Op(ref cons, ref children) => {
current.get_application()
current
.get_application()
.ok_or(Error::StrategyFailed)
.and_then(|(current_cons, current_children)| {
if cons == current_cons && children.len() == current_children.len() {
children
.iter()
.zip(current_children.into_iter())
.map(|(match_term, current_child)| {
eval_match(context, match_term, current_child)
})
.fold(Ok(()), Result::and)
} else {
Err(Error::StrategyFailed)
}
})
.and_then(|(current_cons, current_children)| if cons == current_cons &&
children.len() ==
current_children.len() {
children
.iter()
.zip(current_children.into_iter())
.map(|(match_term, current_child)| {
eval_match(context, match_term, current_child)
})
.fold(Ok(()), Result::and)
} else {
Err(Error::StrategyFailed)
})
}
Explode(ref cons, ref children) => {
current.get_application()
current
.get_application()
.ok_or(Error::StrategyFailed)
.and_then(|(current_cons, current_children)| {
let current_cons = &context.factory.string(current_cons.to_owned());
let () = eval_match(context, cons, current_cons)?;
let current_children = &to_cons_nil_list(context.factory,
current_children.into_iter().cloned());
eval_match(context, children, current_children)
})
let current_cons = &context.factory.string(current_cons.to_owned());
let () = eval_match(context, cons, current_cons)?;
let current_children =
&to_cons_nil_list(context.factory,
current_children.into_iter().cloned());
eval_match(context, children, current_children)
})
}
}
}
......@@ -309,8 +313,10 @@ fn eval_build_with_annos<'a, I>(context: &MutContext<'a>,
match b(&cons).as_inner().term {
Application(ref c, ref r) if r.is_empty() => {
let application =
context.factory.t_application(ctree::string_unescape(c), children.iter().cloned());
return Ok(context.factory.with_annos(application, annos))
context
.factory
.t_application(ctree::string_unescape(c), children.iter().cloned());
return Ok(context.factory.with_annos(application, annos));
}
// According to STR-626 non-string constructor term implosion should fail
// Which the STR/J does when interpreting, but the compiled version just does the
......
......@@ -100,7 +100,10 @@ impl TryFrom<ctree::Def> for SDefT {
})
}
ctree::Def::ExtSDef(_, _, _) => Err(Error::CTreeParse("Unknown behaviour: ExtSDef")),
ctree::Def::ExtSDefInl(_, _, _, _) => Err(Error::CTreeParse("Unknown behaviour: ExtSDefInl")),
ctree::Def::ExtSDefInl(_, _, _, _) => {
Err(Error::CTreeParse("Unknown behaviour: \
ExtSDefInl"))
}
ctree::Def::AnnoDef(_, sdeft) => {
eprintln!("WARNING: ignoring annotations on strategy definitions");
// TODO: support single annotations like in java-backend/trans/s2j.str
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment