Enable dimensionless primitive units

This commit is contained in:
Tiffany Bennett 2016-08-21 10:55:44 -04:00
parent 920fffe9ca
commit c9ad5d9ff0
3 changed files with 2 additions and 4 deletions

View file

@ -476,6 +476,7 @@ Hz hertz
# "You want:" prompt to tell the user the dimension of the unit.
#
dimensionless ? 1
length ? meter
area ? length^2
volume ? length^3

View file

@ -797,7 +797,6 @@ impl Context {
},
Def::Quantity(ref expr) => match ctx.eval(expr) {
Ok(Value::Number(v)) => {
println!("Added {}", name);
ctx.aliases.insert(v.1, name.clone());
},
Ok(_) => println!("Quantity {} is not a number", name),

View file

@ -278,9 +278,7 @@ pub fn parse(mut iter: &mut Iter) -> Defs {
if let Some(Token::Ident(ref _n)) = iter.peek().cloned() {
iter.next();
// dimensionless primitive unit
// not sure what to do with these
map.push((name.clone(), Rc::new(Def::Unit(Expr::Const(
"1".to_owned(), None, None)))));
map.push((name.clone(), Rc::new(Def::Dimension(name))));
} else {
map.push((name.clone(), Rc::new(Def::Dimension(name))));
}