mirror of
https://github.com/rm-dr/daisy
synced 2025-08-02 09:44:45 -07:00
Improved tuple parsing
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
use std::collections::VecDeque;
|
||||
use crate::parser::LineLocation;
|
||||
use crate::quantity::Quantity;
|
||||
use crate::parser::Operator;
|
||||
@ -59,32 +58,6 @@ pub fn eval_operator(g: &Expression, context: &mut Context) -> Result<Option<Exp
|
||||
return Ok(Some(r));
|
||||
},
|
||||
|
||||
Operator::Tuple => {
|
||||
if args.len() != 2 { panic!() };
|
||||
let a = &args[0];
|
||||
let b = &args[1];
|
||||
|
||||
let mut loc = *op_loc;
|
||||
let mut vec: VecDeque<Expression> = VecDeque::new();
|
||||
if let Expression::Tuple(l, v) = a {
|
||||
loc += *l;
|
||||
for i in v { vec.push_back(i.clone()) }
|
||||
} else {
|
||||
loc += a.get_linelocation();
|
||||
vec.push_back(a.clone())
|
||||
}
|
||||
|
||||
if let Expression::Tuple(l, v) = b {
|
||||
loc += *l;
|
||||
for i in v { vec.push_back(i.clone()) }
|
||||
} else {
|
||||
loc += b.get_linelocation();
|
||||
vec.push_back(b.clone())
|
||||
}
|
||||
|
||||
return Ok(Some(Expression::Tuple(loc, vec)))
|
||||
}
|
||||
|
||||
Operator::Negative => {
|
||||
if args.len() != 1 { panic!() };
|
||||
let args = &args[0];
|
||||
|
Reference in New Issue
Block a user