30 const ParserErrorMsg ParserErrorMsg::m_Instance;
33 const ParserErrorMsg& ParserErrorMsg::Instance()
39 string_type ParserErrorMsg::operator[](
unsigned a_iIdx)
const
41 return (a_iIdx<m_vErrMsg.size()) ? m_vErrMsg[a_iIdx] :
string_type();
45 ParserErrorMsg::~ParserErrorMsg()
62 ParserErrorMsg::ParserErrorMsg()
69 m_vErrMsg[
ecINVALID_NAME] =
_T(
"Invalid function-, variable- or constant name: \"$TOK$\".");
81 m_vErrMsg[
ecUNEXPECTED_VAL] =
_T(
"Unexpected value \"$TOK$\" found at position $POS$");
82 m_vErrMsg[
ecUNEXPECTED_VAR] =
_T(
"Unexpected variable \"$TOK$\" found at position $POS$");
83 m_vErrMsg[
ecUNEXPECTED_ARG] =
_T(
"Function arguments used without a function (position: $POS$)");
85 m_vErrMsg[
ecTOO_MANY_PARAMS] =
_T(
"Too many parameters for function \"$TOK$\" at expression position $POS$");
86 m_vErrMsg[
ecTOO_FEW_PARAMS] =
_T(
"Too few parameters for function \"$TOK$\" at expression position $POS$");
90 m_vErrMsg[
ecOPT_PRI] =
_T(
"Invalid value for operator priority (must be greater or equal to zero).");
91 m_vErrMsg[
ecBUILTIN_OVERLOAD] =
_T(
"user defined binary operator \"$TOK$\" conflicts with a built in operator.");
94 m_vErrMsg[
ecSTRING_EXPECTED] =
_T(
"String function called with a non string type of argument.");
95 m_vErrMsg[
ecVAL_EXPECTED] =
_T(
"String value used where a numerical argument is expected.");
99 m_vErrMsg[
ecLOCALE] =
_T(
"Decimal separator is identic to function argument separator.");
100 m_vErrMsg[ecUNEXPECTED_CONDITIONAL] =
_T(
"The \"$TOK$\" operator must be preceeded by a closing bracket.");
101 m_vErrMsg[ecMISSING_ELSE_CLAUSE] =
_T(
"If-then-else operator is missing an else clause");
102 m_vErrMsg[ecMISPLACED_COLON] =
_T(
"Misplaced colon at position $POS$");
103 m_vErrMsg[ecUNREASONABLE_NUMBER_OF_COMPUTATIONS] =
_T(
"Number of computations to small for bulk mode. (Vectorisation overhead too costly)");
107 if (!m_vErrMsg[i].length())
142 m_strMsg = m_ErrMsg[m_iErrc];
144 stream << (int)m_iPos;
145 ReplaceSubString(m_strMsg,
_T(
"$POS$"), stream.str());
146 ReplaceSubString(m_strMsg,
_T(
"$TOK$"), m_strTok);
176 m_strMsg = m_ErrMsg[m_iErrc];
178 stream << (int)m_iPos;
179 ReplaceSubString(m_strMsg,
_T(
"$POS$"), stream.str());
180 ReplaceSubString(m_strMsg,
_T(
"$TOK$"), m_strTok);
197 m_strMsg = m_ErrMsg[m_iErrc];
199 stream << (int)m_iPos;
200 ReplaceSubString(m_strMsg,
_T(
"$POS$"), stream.str());
201 ReplaceSubString(m_strMsg,
_T(
"$TOK$"), m_strTok);
219 stream << (int)m_iPos;
220 ReplaceSubString(m_strMsg,
_T(
"$POS$"), stream.str());
221 ReplaceSubString(m_strMsg,
_T(
"$TOK$"), m_strTok);
227 :m_strMsg(a_Obj.m_strMsg)
228 ,m_strFormula(a_Obj.m_strFormula)
229 ,m_strTok(a_Obj.m_strTok)
230 ,m_iPos(a_Obj.m_iPos)
231 ,m_iErrc(a_Obj.m_iErrc)
243 m_strMsg = a_Obj.m_strMsg;
244 m_strFormula = a_Obj.m_strFormula;
245 m_strTok = a_Obj.m_strTok;
246 m_iPos = a_Obj.m_iPos;
247 m_iErrc = a_Obj.m_iErrc;
252 ParserError::~ParserError()
260 void ParserError::ReplaceSubString(
string_type &strSource,
265 string_type::size_type iPos(0), iNext(0);
269 iNext = strSource.find(strFind, iPos);
270 strResult.append(strSource, iPos, iNext-iPos);
272 if( iNext==string_type::npos )
275 strResult.append(strReplaceWith);
276 iPos = iNext + strFind.length();
279 strSource.swap(strResult);
284 void ParserError::Reset()
287 m_strFormula =
_T(
"");
297 m_strFormula = a_strFormula;
A class that handles the error messages.
#define _T(x)
Activate this option in order to compile with OpenMP support.
const string_type & GetExpr() const
gets the expression related tp this error.
binary operators may only be applied to value items of the same type
An unexpected comma has been found. (Example: "1,23")
Token cant be identified.
An unexpected argument has been found.
Division by zero (currently unused)
Internal error of any kind.
unterminated string constant. (Example: "3*valueof("hello)")
Trying to overload builtin operator.
Undefined message, placeholder to detect unassigned error messages.
ParserErrorMsg & operator=(const ParserErrorMsg &)
Assignement operator is deactivated.
Unexpected function found. (Example: "sin(8)cos(9)")
std::basic_stringstream< char_type, std::char_traits< char_type >, std::allocator< char_type > > stringstream_type
Typedef for easily using stringstream that respect the parser stringtype.
This is no error code, It just stores just the total number of error codes.
An unexpected value token has been found.
Conflict with current locale.
catch division by zero, sqrt(-1), log(0) (currently unused)
An unexpected variable token has been found.
Invalid variable pointer.
Invalid function, variable or constant name.
void SetFormula(const string_type &a_strFormula)
Set the expression related to this error.
Error class of the parser.
Too many function parameters.
A numerical function has been called with a non value type of argument.
Namespace for mathematical applications.
Unexpected end of formula. (Example: "2+sin(")
Too few function parameters. (Example: "ite(1<2,2)")
A string function has been called with a different type of argument.
EErrorCodes GetCode() const
Return the error code.
ParserError()
Default constructor.
string_type::value_type char_type
The character type used by the parser.
int GetPos() const
Return the formula position related to the error.
Unexpected binary operator found.
MUP_STRING_TYPE string_type
The stringtype used by the parser.
Invalid operator priority.
Unexpected Parenthesis, opening or closing.
Invalid function, variable or constant name.
Invalid callback function pointer.
const string_type & GetToken() const
Return string related with this token (if available).
Missing parens. (Example: "3*sin(3")
const string_type & GetMsg() const
Returns the message string for this error.
A string has been found at an inapropriate position.
Invalid function, variable or constant name.
ParserError & operator=(const ParserError &a_Obj)
Assignment operator.
Invalid binary operator identifier.
This file defines the error class used by the parser.