Change matrices to be at least 1x2 or 2x1

pull/1/head
trivernis 4 years ago
parent 386412f021
commit 19ed9e918b

@ -35,7 +35,6 @@ mod tests {
use crate::parse;
use crate::parsing::tokenizer::Tokenizer;
use crate::parsing::tree_parser::TreeParser;
use crate::tokens::Function::Exp;
use crate::tokens::{Function, Grouping, Misc, Operation, Relation, Text, Token};
use crate::utils::Boxed;
use std::fs;
@ -272,6 +271,24 @@ mod tests {
}))]
}
);
assert_eq!(
parse("[[1]]".to_string()),
Expression {
children: vec![Element::Group(Group::Brackets(Brackets {
inner: Expression {
children: vec![Element::Group(Group::Brackets(Brackets {
inner: Expression {
children: vec![Element::Literal(Literal::Number(Number {
number: "1".to_string()
})),]
}
.boxed()
})),]
}
.boxed()
}))]
}
);
}
#[test]
@ -340,7 +357,8 @@ mod tests {
"color(red)(a) * b^4 - c(c-2) [[1, 3, 2 + 2],[3 - x, 4] ((2),(3))".to_string()
)
),
);
)
.unwrap();
}
#[bench]

@ -1,4 +1,3 @@
use crate::elements::Element;
use crate::tokens::constants::accents::G_COLOR;
use crate::tokens::constants::grouping::T_LPAREN;
use crate::tokens::constants::misc::{A_TEXT, G_NUMALLOWED};
@ -8,7 +7,6 @@ use crate::tokens::mappings::{
get_greek_mappings, get_grouping_mappings, get_logical_mappings, get_misc_mappings,
get_operation_mappings, get_relation_mapping,
};
use crate::tokens::Grouping::MatrixEnd;
use crate::tokens::{
Accent, Arrow, FontCommand, Function, Greek, Grouping, Logical, Misc, Operation, Relation,
Text, Token,

@ -451,7 +451,11 @@ impl TreeParser {
false
} else {
let first_length = matrix.first().unwrap().len();
matrix.iter().all(|e| e.len() == first_length)
if first_length * matrix.len() == 1 {
false
} else {
matrix.iter().all(|e| e.len() == first_length)
}
}
}
}

@ -152,10 +152,6 @@ pub enum Grouping {
Floor,
Ceil,
Norm,
MatrixBegin,
MatrixEnd,
VecBegin,
VecEnd,
MSep,
}

Loading…
Cancel
Save