Commit 1d9df971 authored by Victor Yacovlev's avatar Victor Yacovlev

Improved bool expressions parsing

WARNING must be completele tested!
parent 69cb3443
......@@ -3331,8 +3331,18 @@ AST::Expression * SyntaxAnalizerPrivate::parseExpression(
} // end if (blockType==Function)
else if (blockType==Simple) {
if (block.isEmpty() && notFlag) {
notFlag->error = _("Extra 'not'");
return 0;
bool isUnaryOperatorAfterNot =
lexems[curPos]->type==LxOperPlus ||
lexems[curPos]->type==LxOperMinus ;
if (curPos==lexems.length()-1 || !isUnaryOperatorAfterNot) {
notFlag->error = _("Extra 'not'");
return 0;
}
else {
subexpression << notFlag;
subexpression << lexems[curPos];
continue;
}
}
AST::Expression * operand = parseSimpleName(block.toStdList(), mod, alg);
if (!operand) {
......@@ -3531,7 +3541,9 @@ AST::Expression * SyntaxAnalizerPrivate::parseExpression(
bool isBooleanComparision =
i>0 && subexpression[i-1].e && subexpression[i-1].e->baseType.kind == AST::TypeBoolean
||
i<subexpression.size()-1 && subexpression[i+1].e && subexpression[i+1].e->baseType.kind == AST::TypeBoolean;
i<subexpression.size()-1 && subexpression[i+1].e && subexpression[i+1].e->baseType.kind == AST::TypeBoolean
||
i<subexpression.size()-1 && subexpression[i+1].o && subexpression[i+1].o->type==LxSecNot;
if (isBooleanComparision) {
if (el.o->type = LxOperEqual)
el.o->type = LxOperBoolEqual;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment