Commit 619dcbb7 authored by Victor Yacovlev's avatar Victor Yacovlev

Implemented flexible bool comparision

WARNING: This requres complete testing!!!
parent 29de2717
......@@ -3432,7 +3432,21 @@ AST::Expression * SyntaxAnalizerPrivate::parseExpression(
}
}
for (int i=0; i<subexpression.size(); i++) {
const SubexpressionElement & el = subexpression.at(i);
if (el.o && (el.o->type==LxOperEqual || el.o->type==LxOperNotEqual) ) {
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;
if (isBooleanComparision) {
if (el.o->type = LxOperEqual)
el.o->type = LxOperBoolEqual;
else
el.o->type = LxOperBoolNotEqual;
}
}
}
result = makeExpressionTree(subexpression);
if (result)
result->lexems = lexems;
......@@ -4195,8 +4209,9 @@ int findOperatorByPriority(const QList<SubexpressionElement> & s)
static const QList<QSet <LexemType> > Omega = QList<QSet<LexemType> >()
<< ( QSet<LexemType>() << LxSecOr )
<< ( QSet<LexemType>() << LxSecAnd )
<< ( QSet<LexemType>() << LxOperNotEqual << LxOperEqual << LxOperGreater << LxOperGreaterOrEqual << LxOperLess << LxOperLessOrEqual << LxPriAssign)
<< ( QSet<LexemType>() << LxOperBoolEqual << LxOperBoolNotEqual )
<< ( QSet<LexemType>() << LxSecNot )
<< ( QSet<LexemType>() << LxOperNotEqual << LxOperEqual << LxOperGreater << LxOperGreaterOrEqual << LxOperLess << LxOperLessOrEqual << LxPriAssign)
<< ( QSet<LexemType>() << LxOperPlus << LxOperMinus )
<< ( QSet<LexemType>() << LxOperAsterisk << LxOperSlash )
<< ( QSet<LexemType>() << LxOperPower );
......@@ -4260,9 +4275,9 @@ AST::ExpressionOperator operatorByLexem(const Lexem * lx)
return AST::OpAnd;
else if (lx->type==LxSecOr)
return AST::OpOr;
else if (lx->type==LxOperEqual)
else if (lx->type==LxOperEqual || lx->type==LxOperBoolEqual)
return AST::OpEqual;
else if (lx->type==LxOperNotEqual)
else if (lx->type==LxOperNotEqual || lx->type==LxOperBoolNotEqual)
return AST::OpNotEqual;
else if (lx->type==LxOperLess)
return AST::OpLess;
......
......@@ -102,12 +102,14 @@ namespace Shared {
LxOperComa = 0x1800000,
LxOperLess = 0x1a00000,
LxOperGreater = 0x1c00000,
LxOperLessOrEqual = 0x1e00000,
LxOperLessOrEqual = 0x1e00000,
LxOperGreaterOrEqual = 0x2000000,
LxOperNotEqual = 0x2200000,
LxOperSemicolon = 0x2400000,
LxOperLeftBrace = 0x2600000,
LxOperRightBrace = 0x2800000
LxOperRightBrace = 0x2800000,
LxOperBoolEqual = 0x3000000,
LxOperBoolNotEqual = 0x3200000
};
}
......
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