OpcUaCanOpen
CANopen OPC-UA server
muParserError.h
Go to the documentation of this file.
1
/*
2
__________
3
_____ __ __\______ \_____ _______ ______ ____ _______
4
/ \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5
| Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6
|__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7
\/ \/ \/ \/
8
Copyright (C) 2004-2011 Ingo Berg
9
10
Permission is hereby granted, free of charge, to any person obtaining a copy of this
11
software and associated documentation files (the "Software"), to deal in the Software
12
without restriction, including without limitation the rights to use, copy, modify,
13
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14
permit persons to whom the Software is furnished to do so, subject to the following conditions:
15
16
The above copyright notice and this permission notice shall be included in all copies or
17
substantial portions of the Software.
18
19
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
20
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
*/
25
26
#ifndef MU_PARSER_ERROR_H
27
#define MU_PARSER_ERROR_H
28
29
#include <cassert>
30
#include <stdexcept>
31
#include <string>
32
#include <sstream>
33
#include <vector>
34
#include <memory>
35
36
#include "
muParserDef.h
"
37
42
namespace
mu
43
{
44
46
enum
EErrorCodes
47
{
48
// Formula syntax errors
49
ecUNEXPECTED_OPERATOR
= 0,
50
ecUNASSIGNABLE_TOKEN
= 1,
51
ecUNEXPECTED_EOF
= 2,
52
ecUNEXPECTED_ARG_SEP
= 3,
53
ecUNEXPECTED_ARG
= 4,
54
ecUNEXPECTED_VAL
= 5,
55
ecUNEXPECTED_VAR
= 6,
56
ecUNEXPECTED_PARENS
= 7,
57
ecUNEXPECTED_STR
= 8,
58
ecSTRING_EXPECTED
= 9,
59
ecVAL_EXPECTED
= 10,
60
ecMISSING_PARENS
= 11,
61
ecUNEXPECTED_FUN
= 12,
62
ecUNTERMINATED_STRING
= 13,
63
ecTOO_MANY_PARAMS
= 14,
64
ecTOO_FEW_PARAMS
= 15,
65
ecOPRT_TYPE_CONFLICT
= 16,
66
ecSTR_RESULT
= 17,
67
68
// Invalid Parser input Parameters
69
ecINVALID_NAME
= 18,
70
ecINVALID_BINOP_IDENT
= 19,
71
ecINVALID_INFIX_IDENT
= 20,
72
ecINVALID_POSTFIX_IDENT
= 21,
73
74
ecBUILTIN_OVERLOAD
= 22,
75
ecINVALID_FUN_PTR
= 23,
76
ecINVALID_VAR_PTR
= 24,
77
ecEMPTY_EXPRESSION
= 25,
78
ecNAME_CONFLICT
= 26,
79
ecOPT_PRI
= 27,
80
//
81
ecDOMAIN_ERROR
= 28,
82
ecDIV_BY_ZERO
= 29,
83
ecGENERIC
= 30,
84
ecLOCALE
= 31,
85
86
ecUNEXPECTED_CONDITIONAL
= 32,
87
ecMISSING_ELSE_CLAUSE
= 33,
88
ecMISPLACED_COLON
= 34,
89
90
ecUNREASONABLE_NUMBER_OF_COMPUTATIONS
= 35,
91
92
// internal errors
93
ecINTERNAL_ERROR
= 36,
94
95
// The last two are special entries
96
ecCOUNT
,
97
ecUNDEFINED
= -1
98
};
99
100
//---------------------------------------------------------------------------
103
class
ParserErrorMsg
104
{
105
public
:
106
static
const
ParserErrorMsg
&
Instance
();
107
string_type
operator[]
(
unsigned
a_iIdx)
const
;
108
109
private
:
110
ParserErrorMsg
&
operator=
(
const
ParserErrorMsg
&) =
delete
;
111
ParserErrorMsg
(
const
ParserErrorMsg
&) =
delete
;
112
ParserErrorMsg
();
113
114
~ParserErrorMsg
() =
default
;
115
116
std::vector<string_type>
m_vErrMsg
;
117
};
118
119
//---------------------------------------------------------------------------
125
class
API_EXPORT_CXX
ParserError
126
{
127
private
:
128
130
void
ReplaceSubString(
string_type
&strSource,
131
const
string_type
&strFind,
132
const
string_type
&strReplaceWith);
133
void
Reset();
134
135
public
:
136
137
ParserError
();
138
explicit
ParserError
(
EErrorCodes
a_iErrc);
139
explicit
ParserError
(
const
string_type
&sMsg);
140
ParserError
(
EErrorCodes
a_iErrc,
141
const
string_type
&sTok,
142
const
string_type
&sFormula =
string_type
(),
143
int
a_iPos = -1);
144
ParserError
(
EErrorCodes
a_iErrc,
145
int
a_iPos,
146
const
string_type
&sTok);
147
ParserError
(
const
char_type
*a_szMsg,
148
int
a_iPos = -1,
149
const
string_type
&sTok =
string_type
());
150
ParserError
(
const
ParserError
&a_Obj);
151
ParserError
& operator=(
const
ParserError
&a_Obj);
152
~
ParserError
();
153
154
void
SetFormula(
const
string_type
&a_strFormula);
155
const
string_type
& GetExpr()
const
;
156
const
string_type
& GetMsg()
const
;
157
int
GetPos()
const
;
158
const
string_type
& GetToken()
const
;
159
EErrorCodes
GetCode()
const
;
160
161
private
:
162
string_type
m_strMsg
;
163
string_type
m_strFormula
;
164
string_type
m_strTok
;
165
int
m_iPos
;
166
EErrorCodes
m_iErrc
;
167
const
ParserErrorMsg
&
m_ErrMsg
;
168
};
169
170
}
// namespace mu
171
172
#endif
173
muparser
include
muParserError.h
Generated on Fri Sep 11 2020 14:30:12 for OpcUaCanOpen by
1.8.14