Refactoring. Delete repetitive code.
--HG-- branch : feature
This commit is contained in:
parent
aa1b67d093
commit
ec44c57c34
|
@ -1450,19 +1450,19 @@ void QmuParserBase::CreateRPN() const
|
|||
case cmIF:
|
||||
m_nIfElseCounter++;
|
||||
// fallthrough intentional (no break!)
|
||||
case cmLAND:
|
||||
case cmLOR:
|
||||
case cmLT:
|
||||
case cmGT:
|
||||
case cmLE:
|
||||
case cmGE:
|
||||
case cmNEQ:
|
||||
case cmEQ:
|
||||
case cmLT:
|
||||
case cmGT:
|
||||
case cmADD:
|
||||
case cmSUB:
|
||||
case cmMUL:
|
||||
case cmDIV:
|
||||
case cmPOW:
|
||||
case cmLAND:
|
||||
case cmLOR:
|
||||
case cmASSIGN:
|
||||
case cmOPRT_BIN:
|
||||
// A binary operator (user defined or built in) has been found.
|
||||
|
|
|
@ -384,25 +384,8 @@ bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok )
|
|||
int len = pOprtDef.at ( i ).length();
|
||||
if ( pOprtDef.at ( i ) == m_strFormula.mid ( m_iPos, len ) )
|
||||
{
|
||||
switch ( i )
|
||||
if (i >= cmLE && i <= cmASSIGN)
|
||||
{
|
||||
//case cmAND:
|
||||
//case cmOR:
|
||||
//case cmXOR:
|
||||
case cmLAND:
|
||||
case cmLOR:
|
||||
case cmLT:
|
||||
case cmGT:
|
||||
case cmLE:
|
||||
case cmGE:
|
||||
case cmNEQ:
|
||||
case cmEQ:
|
||||
case cmADD:
|
||||
case cmSUB:
|
||||
case cmMUL:
|
||||
case cmDIV:
|
||||
case cmPOW:
|
||||
case cmASSIGN:
|
||||
//if (len!=sTok.length())
|
||||
// continue;
|
||||
|
||||
|
@ -431,9 +414,9 @@ bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok )
|
|||
|
||||
m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE;
|
||||
m_iSynFlags |= ( ( i != cmEND ) && ( i != cmBC ) ) ? noEND : 0;
|
||||
break;
|
||||
|
||||
case cmBO:
|
||||
}
|
||||
else if (i == cmBO)
|
||||
{
|
||||
if ( m_iSynFlags & noBO )
|
||||
{
|
||||
Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) );
|
||||
|
@ -449,9 +432,9 @@ bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok )
|
|||
}
|
||||
|
||||
++m_iBrackets;
|
||||
break;
|
||||
|
||||
case cmBC:
|
||||
}
|
||||
else if (i == cmBC)
|
||||
{
|
||||
if ( m_iSynFlags & noBC )
|
||||
{
|
||||
Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) );
|
||||
|
@ -463,29 +446,29 @@ bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok )
|
|||
{
|
||||
Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case cmELSE:
|
||||
}
|
||||
else if (i == cmELSE)
|
||||
{
|
||||
if ( m_iSynFlags & noELSE )
|
||||
{
|
||||
Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) );
|
||||
}
|
||||
|
||||
m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE;
|
||||
break;
|
||||
|
||||
case cmIF:
|
||||
}
|
||||
else if (i == cmIF)
|
||||
{
|
||||
if ( m_iSynFlags & noIF )
|
||||
{
|
||||
Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) );
|
||||
}
|
||||
|
||||
m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE;
|
||||
break;
|
||||
|
||||
default: // The operator is listed in c_DefaultOprt, but not here. This is a bad thing...
|
||||
}
|
||||
else // The operator is listed in c_DefaultOprt, but not here. This is a bad thing...
|
||||
{
|
||||
Error ( ecINTERNAL_ERROR );
|
||||
} // switch operator id
|
||||
}
|
||||
|
||||
m_iPos += len;
|
||||
a_Tok.Set ( static_cast<ECmdCode>(i), pOprtDef.at ( i ) );
|
||||
|
|
Loading…
Reference in New Issue
Block a user