the code has some bug, see below:
plugins\codecompletion\parser\expression.cpp
long ExpressionNode::GetNodeTypePriority(ExpressionNodeType type)
{
switch (type)
{
case LParenthesis:
case RParenthesis:
return 9;
case Not:
return 8;
case Mod:
return 7;
case MultiPly:
case Divide:
case Power:
return 6;
case Plus:
case Subtract:
return 5;
case LShift:
case RShift:
return 4;
case BitwiseAnd:
case BitwiseOr:
return 3;
case Equal:
case Unequal:
case GT:
case LT:
case GTOrEqual:
case LTOrEqual:
return 2;
case And:
case Or:
return 1;
default:
return 0;
}
}
The "And" and "Or" should have different precedence.
see:
http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B
BTW, I'm implementing some similar code (I think it was much simpler, in my quex parser tester)
see:
Yesterday, I have implement a quite simple expression parser by shunting yard algorithm combined with Quex lexer. it was very much like the yacc calculator in the demo folders.
The source code was:
http://code.google.com/p/quexparser/source/browse/trunk/cppparser/expression_eval.cpp
http://code.google.com/p/quexparser/source/browse/trunk/cppparser/expression_main.cpp
and the reference was:
http://en.literateprograms.org/Shunting_yard_algorithm_%28C%29
seems no one was interested on this issue.... :(
Here is the test code to produce this issue:
#if 1 || 1 && 0
int main();
#endif
Now, the cc will skip the "main" function.
But the conditional expression value is "true".