Slide 15
Slide 15 text
ΠϯλϓϦλͱʁ
ࠓճͷαϯϓϧϓϩάϥϜͩͱ
// impl Token ͷதͰ͢
pub fn reduce(&self, env: &HashMap) -> Token {
use Token::*;
match self {
(…)
&Add(ref blv, ref brv) if blv.is_reducible() => {
Add(Box::new(blv.reduce(env)), brv.clone())
}
&Add(ref blv, ref brv) if brv.is_reducible() => {
Add(blv.clone(), Box::new(brv.reduce(env)))
}
&Add(ref blv, ref brv) => match **blv {
Number(left_value) => match **brv {
Number(right_value) => Number(left_value +
right_value),
_ => panic!("Unexpected error in Add!"),
},
_ => panic!("Unexpected error in Add!"),
},
(…)