@@ -102,8 +102,8 @@ VerilogBitstringGrammar::VerilogBitstringGrammar()
102
102
hex_value[([&](const std::string& tri_state_hex_string) {
103
103
if (tri_state_hex_string.size () != (number_of_bits + 3 ) / 4 ) {
104
104
throw std::invalid_argument (
105
- " Error while parsing the hexadecimal string" + input_string_ +
106
- " : Length mismatch" );
105
+ " Error while parsing the hexadecimal string" +
106
+ input_string_ + " : Length mismatch" );
107
107
}
108
108
for (char tri_state_hex_char : tri_state_hex_string) {
109
109
std::vector<TriStateBit> tri_state_bits =
@@ -125,8 +125,10 @@ std::vector<TriStateBit> VerilogBitstringGrammar::Parse(
125
125
is_inverted = false ;
126
126
127
127
if (!qi::phrase_parse (begin, end, *this , qi::space)) {
128
- throw std::invalid_argument (
129
- " Error while parsing the Verilog bitstring: Parsing failed" );
128
+ std::string error_message =
129
+ " Error while parsing the Verilog bitstring: \" " + tri_state_string +
130
+ " \" . Invalid syntax!" ;
131
+ throw std::invalid_argument (error_message);
130
132
}
131
133
132
134
std::reverse (result.begin (), result.end ());
@@ -187,8 +189,10 @@ InputAssignment InputAssignmentGrammar::Parse(
187
189
result_.signal_values_ .clear ();
188
190
189
191
if (!qi::phrase_parse (begin, end, *this , qi::space)) {
190
- throw std::invalid_argument (
191
- " Error while parsing an input assignment: Parsing failed" );
192
+ std::string error_message =
193
+ " Error while parsing the input assignment: \" " + input_assignment_string +
194
+ " \" . Invalid syntax!" ;
195
+ throw std::invalid_argument (error_message);
192
196
}
193
197
194
198
return result_;
@@ -214,7 +218,8 @@ IrreduciblePolynomialGrammar::IrreduciblePolynomialGrammar()
214
218
215
219
std::vector<uint64_t > IrreduciblePolynomialGrammar::Parse (
216
220
std::string& polynomial_string, uint64_t base, uint64_t exponent) {
217
- std::string error_context = " Error while parsing an irreducible polynomial: " ;
221
+ std::string error_context =
222
+ " Error while parsing the polynomial: " + polynomial_string + " . " ;
218
223
std::string galois_field =
219
224
" GF(" + std::to_string (base) + " ^" + std::to_string (exponent) + " )" ;
220
225
std::string::iterator begin, end;
@@ -224,7 +229,7 @@ std::vector<uint64_t> IrreduciblePolynomialGrammar::Parse(
224
229
end = polynomial_string.end ();
225
230
226
231
if (!qi::phrase_parse (begin, end, *this , qi::space, monomials)) {
227
- throw std::invalid_argument (error_context + " Parsing failed !" );
232
+ throw std::invalid_argument (error_context + " Invalid syntax !" );
228
233
}
229
234
230
235
for (uint64_t index = 0 ; index <= exponent; ++index) {
@@ -251,15 +256,15 @@ std::vector<uint64_t> IrreduciblePolynomialGrammar::Parse(
251
256
252
257
for (const std::pair<uint64_t , uint64_t >& monomial : monomials) {
253
258
if (monomial.first >= base) {
254
- throw std::invalid_argument (error_context + " Coefficient of term \" " +
259
+ throw std::invalid_argument (error_context + " Invalid coefficient: \" " +
255
260
std::to_string (monomial.first ) + " x^" +
256
- std::to_string (monomial.second ) +
257
- " \" is not allowed in " + galois_field + " !" );
261
+ std::to_string (monomial.second ) + " \" in " +
262
+ galois_field + " !" );
258
263
} else if (monomial.second > exponent) {
259
- throw std::invalid_argument (error_context + " Exponent of term \" " +
264
+ throw std::invalid_argument (error_context + " Invalid coefficient: \" " +
260
265
std::to_string (monomial.first ) + " x^" +
261
- std::to_string (monomial.second ) +
262
- " \" is not allowed in " + galois_field + " !" );
266
+ std::to_string (monomial.second ) + " \" in " +
267
+ galois_field + " !" );
263
268
} else {
264
269
coefficients.push_back (monomial.first );
265
270
}
@@ -321,8 +326,10 @@ std::vector<std::string> SignalNameGrammar::Parse(
321
326
bool success = qi::phrase_parse (begin, end, *this , qi::space);
322
327
323
328
if (!success || (begin != end)) {
324
- throw std::invalid_argument (
325
- " Error while parsing the signal names: Parsing failed" );
329
+ std::string error_message =
330
+ " Error while parsing signal name: \" " + signal_name_string +
331
+ " \" . Invalid syntax!" ;
332
+ throw std::invalid_argument (error_message);
326
333
}
327
334
328
335
return result;
@@ -335,7 +342,7 @@ std::ifstream OpenFile(const std::filesystem::path& path) {
335
342
std::string error_message =
336
343
" Error while opening the file located at path \" " + path.string () +
337
344
" \" : " ;
338
- throw std::runtime_error (error_message + " File not found. " );
345
+ throw std::runtime_error (error_message + " File not found! " );
339
346
}
340
347
341
348
return stream;
0 commit comments