1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

remove subtraction

This commit is contained in:
schaeff 2018-12-17 18:19:05 +01:00
parent acad5d8db8
commit 302d75a501
7 changed files with 24 additions and 27 deletions

View file

@ -442,10 +442,7 @@ impl Flattener {
statements_flattened,
exp,
);
let id = self.use_sym();
let e = FlatExpression::Sub(box FlatExpression::Number(T::one()), box x);
statements_flattened.push(FlatStatement::Definition(id, e));
FlatExpression::Identifier(id)
FlatExpression::Sub(box FlatExpression::Number(T::one()), box x)
}
BooleanExpression::Value(b) => FlatExpression::Number(match b {
true => T::from(1),
@ -520,7 +517,7 @@ impl Flattener {
.into_iter()
.map(|x| x.apply_direct_substitution(&replacement_map))
.collect(),
}
};
}
FlatStatement::Definition(var, rhs) => {
let new_var = self.issue_new_variable();

View file

@ -179,7 +179,7 @@ impl Importer {
return Err(CompileError::ImportError(Error::new(format!(
"Gadget {} not found",
s
))))
))));
}
}
}
@ -207,7 +207,7 @@ impl Importer {
return Err(CompileError::ImportError(Error::new(format!(
"Packing helper {} not found",
s
))))
))));
}
}
} else {
@ -226,7 +226,7 @@ impl Importer {
Err(err) => return Err(CompileError::ImportError(err.into())),
},
None => {
return Err(Error::new("Can't resolve import without a resolver").into())
return Err(Error::new("Can't resolve import without a resolver").into());
}
}
}

View file

@ -374,7 +374,7 @@ pub fn parse_function_call<T: Field>(
expected: vec![Token::Comma, Token::Close],
got: t2,
pos: p2,
})
});
}
}
}
@ -422,7 +422,7 @@ pub fn parse_inline_array<T: Field>(
expected: vec![Token::Comma, Token::RightBracket],
got: t2,
pos: p2,
})
});
}
}
}

View file

@ -42,7 +42,7 @@ fn parse_function_header<T: Field>(
expected: vec![Token::Close],
got: t3,
pos: p3,
})
});
}
},
Err(e) => return Err(e),
@ -52,7 +52,7 @@ fn parse_function_header<T: Field>(
expected: vec![Token::Open],
got: t1,
pos: p1,
})
});
}
}?;
@ -67,7 +67,7 @@ fn parse_function_header<T: Field>(
expected: vec![Token::Close],
got: t3,
pos: p3,
})
});
}
},
Err(e) => return Err(e),
@ -77,7 +77,7 @@ fn parse_function_header<T: Field>(
expected: vec![Token::Open],
got: t1,
pos: p1,
})
});
}
},
(t0, _, p0) => {
@ -85,7 +85,7 @@ fn parse_function_header<T: Field>(
expected: vec![Token::Arrow],
got: t0,
pos: p0,
})
});
}
}?;
@ -103,7 +103,7 @@ fn parse_function_header<T: Field>(
expected: vec![Token::Unknown("".to_string())],
got: t6,
pos: p6,
})
});
}
},
(t5, _, p5) => {
@ -111,7 +111,7 @@ fn parse_function_header<T: Field>(
expected: vec![Token::Colon],
got: t5,
pos: p5,
})
});
}
}
}
@ -167,7 +167,7 @@ fn parse_function_arguments<T: Field>(
expected: vec![Token::Comma, Token::Close],
got: t3,
pos: p3,
})
});
}
}
}
@ -188,7 +188,7 @@ fn parse_function_arguments<T: Field>(
expected: vec![Token::Comma, Token::Close],
got: t3,
pos: p3,
})
});
}
}
}
@ -202,7 +202,7 @@ fn parse_function_arguments<T: Field>(
],
got: t4,
pos: p4,
})
});
}
}
}
@ -231,7 +231,7 @@ fn parse_function_return_types<T: Field>(
expected: vec![Token::Comma, Token::Close],
got: t3,
pos: p3,
})
});
}
}
}
@ -245,7 +245,7 @@ fn parse_function_return_types<T: Field>(
],
got: t4,
pos: p4,
})
});
}
}
}

View file

@ -16,14 +16,14 @@ pub fn parse_import<T: Field>(
(Token::Path(code_path), s2, p2) => match next_token::<T>(&s2, &p2) {
(Token::As, s3, p3) => match next_token(&s3, &p3) {
(Token::Ide(id), _, p4) => {
return Ok((Import::new_with_alias(code_path, &id), p4))
return Ok((Import::new_with_alias(code_path, &id), p4));
}
(t4, _, p4) => {
return Err(Error {
expected: vec![Token::Ide("ide".to_string())],
got: t4,
pos: p4,
})
});
}
},
(Token::Unknown(_), _, p3) => return Ok((Import::new(code_path), p3)),
@ -35,7 +35,7 @@ pub fn parse_import<T: Field>(
],
got: t3,
pos: p3,
})
});
}
},
(t2, _, p2) => Err(Error {

View file

@ -47,7 +47,7 @@ pub fn parse_program<T: Field, R: BufRead>(reader: &mut R) -> Result<Prog<T>, Er
expected: vec![Token::Def],
got: t1,
pos: p1,
})
});
}
},
None => break,

View file

@ -201,7 +201,7 @@ impl Checker {
"Duplicate definition for function {} with signature {}",
funct.id, funct.signature
),
})
});
}
0 => {}
_ => panic!("duplicate function declaration should have been caught"),