[poincare/parser] 0→0→c should not be parsable

This commit is contained in:
Léa Saviot
2020-02-06 10:42:22 +01:00
parent 681ab5429a
commit 1e3294139d
2 changed files with 3 additions and 2 deletions

View File

@@ -306,8 +306,8 @@ void Parser::parseRightwardsArrow(Expression & leftHandSide, Token::Type stoppin
if (m_status != Status::Progress) {
return;
}
if (!m_nextToken.is(Token::EndOfStream) || rightHandSide.isUninitialized()) {
m_status = Status::Error; // Store and UnitConvert expect a unit on the right.
if (!m_nextToken.is(Token::EndOfStream) || rightHandSide.isUninitialized() || rightHandSide.type() == ExpressionNode::Type::Store || rightHandSide.type() == ExpressionNode::Type::UnitConvert) {
m_status = Status::Error; // UnitConvert expect a unit on the right.
return;
}
leftHandSide = UnitConvert::Builder(leftHandSide, rightHandSide);

View File

@@ -419,6 +419,7 @@ QUIZ_CASE(poincare_parsing_parse_store) {
Expression m0[] = {Symbol::Builder('x')};
assert_parsed_expression_is("[[x]]→f(x)", Store::Builder(BuildMatrix(1,1,m0), Function::Builder("f", 1, Symbol::Builder('x'))));
assert_text_not_parsable("a→b→c");
assert_text_not_parsable("0→0→c");
assert_text_not_parsable("1→");
assert_text_not_parsable("→2");
assert_text_not_parsable("(1→a)");