[muparser] Remove m_strFormula from the ParserError

This commit is contained in:
ridiculousfish 2017-12-18 11:38:55 -08:00
parent 409173e0f0
commit e728bf45de
5 changed files with 7 additions and 76 deletions

View File

@ -308,8 +308,7 @@ class ParserError {
ParserError();
explicit ParserError(EErrorCodes a_iErrc);
explicit ParserError(const string_type &sMsg);
ParserError(EErrorCodes a_iErrc, const string_type &sTok,
const string_type &sFormula = string_type(), int a_iPos = -1);
ParserError(EErrorCodes a_iErrc, const string_type &sTok, int a_iPos = -1);
ParserError(EErrorCodes a_iErrc, int a_iPos, const string_type &sTok);
ParserError(const char_type *a_szMsg, int a_iPos = -1, const string_type &sTok = string_type());
ParserError(ParserError &&) = default;
@ -327,7 +326,6 @@ class ParserError {
private:
string_type m_strMsg; ///< The message string
string_type m_strFormula; ///< Formula string
string_type m_strTok; ///< Token related with the error
int m_iPos = -1; ///< Formula position related to the error
EErrorCodes m_iErrc = ecUNDEFINED; ///< Error code

View File

@ -187,61 +187,6 @@ ValueOrError Help() {
return 0;
}
//---------------------------------------------------------------------------
/*
void CheckLocale()
{
// Local names:
// "C" - the classic C locale
// "de_DE" - not for Windows?
// "en_US" - not for Windows?
// "German_germany" - For MSVC8
try
{
std::locale loc("German_germany");
console() << _T("Locale settings:\n");
console() << _T(" Decimal point: '") << std::use_facet<numpunct<char_type>
>(loc).decimal_point() << _T("'\n");
console() << _T(" Thousands sep: '") << std::use_facet<numpunct<char_type>
>(loc).thousands_sep() << _T("'\n");
console() << _T(" Grouping: '") << std::use_facet<numpunct<char_type> >(loc).grouping()
<< _T("'\n");
console() << _T(" True is named: '") << std::use_facet<numpunct<char_type> >(loc).truename()
<< _T("'\n");
console() << _T(" False is named: '") << std::use_facet<numpunct<char_type> >(loc).falsename()
<< _T("'\n");
console() << _T("-----------------------------------------------------------\n");
}
catch(...)
{
console() << _T("Locale settings:\n");
console() << _T(" invalid locale name\n");
console() << _T("-----------------------------------------------------------\n");
}
}
//---------------------------------------------------------------------------
void CheckDiff()
{
mu::Parser parser;
value_type x = 1,
v1,
v2,
v3,
eps(pow(std::numeric_limits<value_type>::epsilon(), 0.2));
parser.DefineVar(_T("x"), &x);
parser.SetExpr(_T("_e^-x*sin(x)"));
v1 = parser.Diff(&x, 1),
v2 = parser.Diff(&x, 1, eps);
v3 = cos((value_type)1.0)/exp((value_type)1) - sin((value_type)1.0)/exp((value_type)1);
//-0.110793765307;
mu::console() << parser.GetExpr() << _T("\n");
mu::console() << _T("v1 = ") << v1 << _T("; v1-v3 = ") << v1-v3 << _T("\n");
mu::console() << _T("v2 = ") << v2 << _T("; v2-v3 = ") << v2-v3 << _T("\n");
}
*/
//---------------------------------------------------------------------------
/** \brief Check for external keywords.
*/
@ -371,7 +316,6 @@ void Calc() {
mu::console() << _T("\nError:\n");
mu::console() << _T("------\n");
mu::console() << _T("Message: ") << e.GetMsg() << _T("\n");
mu::console() << _T("Expression: \"") << e.GetExpr() << _T("\"\n");
mu::console() << _T("Token: \"") << e.GetToken() << _T("\"\n");
mu::console() << _T("Position: ") << (int)e.GetPos() << _T("\n");
mu::console() << _T("Errc: ") << std::dec << e.GetCode() << _T("\n");

View File

@ -1130,7 +1130,7 @@ ValueOrError ParserBase::BuildAndExecuteRPN() const {
\param a_strTok [in] The token string representation associated with the error.
*/
ParserError ParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const string_type &a_sTok) const {
return ParserError(a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos);
return ParserError(a_iErrc, a_sTok, a_iPos);
}
//------------------------------------------------------------------------------

View File

@ -142,12 +142,10 @@ ParserError::ParserError(const string_type &sMsg) {
/** \brief Construct an error object.
\param [in] a_iErrc the error code.
\param [in] sTok The token string related to this error.
\param [in] sExpr The expression related to the error.
\param [in] a_iPos the position in the expression where the error occurred.
*/
ParserError::ParserError(EErrorCodes iErrc, const string_type &sTok, const string_type &sExpr,
int iPos)
: m_strMsg(), m_strFormula(sExpr), m_strTok(sTok), m_iPos(iPos), m_iErrc(iErrc) {
ParserError::ParserError(EErrorCodes iErrc, const string_type &sTok, int iPos)
: m_strTok(sTok), m_iPos(iPos), m_iErrc(iErrc) {
m_strMsg = parser_error_for_code(m_iErrc);
stringstream_type stream;
stream << (int)m_iPos;
@ -162,7 +160,7 @@ ParserError::ParserError(EErrorCodes iErrc, const string_type &sTok, const strin
\param [in] sTok The token string related to this error.
*/
ParserError::ParserError(EErrorCodes iErrc, int iPos, const string_type &sTok)
: m_strMsg(), m_strFormula(), m_strTok(sTok), m_iPos(iPos), m_iErrc(iErrc) {
: m_strMsg(), m_strTok(sTok), m_iPos(iPos), m_iErrc(iErrc) {
m_strMsg = parser_error_for_code(m_iErrc);
stringstream_type stream;
stream << (int)m_iPos;
@ -177,7 +175,7 @@ ParserError::ParserError(EErrorCodes iErrc, int iPos, const string_type &sTok)
\param [in] sTok The token string related to this error.
*/
ParserError::ParserError(const char_type *szMsg, int iPos, const string_type &sTok)
: m_strMsg(szMsg), m_strFormula(), m_strTok(sTok), m_iPos(iPos), m_iErrc(ecGENERIC) {
: m_strMsg(szMsg), m_strTok(sTok), m_iPos(iPos), m_iErrc(ecGENERIC) {
stringstream_type stream;
stream << (int)m_iPos;
ReplaceSubString(m_strMsg, _T("$POS$"), stream.str());
@ -214,20 +212,11 @@ void ParserError::ReplaceSubString(string_type &strSource, const string_type &st
/** \brief Reset the erro object. */
void ParserError::Reset() {
m_strMsg = _T("");
m_strFormula = _T("");
m_strTok = _T("");
m_iPos = -1;
m_iErrc = ecUNDEFINED;
}
//------------------------------------------------------------------------------
/** \brief Set the expression related to this error. */
void ParserError::SetFormula(const string_type &a_strFormula) { m_strFormula = a_strFormula; }
//------------------------------------------------------------------------------
/** \brief gets the expression related tp this error.*/
const string_type &ParserError::GetExpr() const { return m_strFormula; }
//------------------------------------------------------------------------------
/** \brief Returns the message string for this error. */
const string_type &ParserError::GetMsg() const { return m_strMsg; }

View File

@ -1202,7 +1202,7 @@ int ParserTester::EqnTestInt(const string_type &a_str, double a_fRes, bool a_fPa
}
} catch (Parser::exception_type &e) {
if (a_fPass) {
mu::console() << _T("\n fail: ") << e.GetExpr() << _T(" : ") << e.GetMsg();
mu::console() << _T("\n fail: ") << e.GetMsg();
iRet = 1;
}
} catch (...) {