|
mupp 1.1.0
|
The PErrorHandler struct handles parsing and semantic errors. More...
#include <PErrorHandler.hpp>
Public Member Functions | |
| PErrorHandler (Iterator first, Iterator last) | |
| Constructor that stores the source code range. | |
| template<typename Message, typename What> | |
| void | operator() (Message const &message, What const &what, Iterator err_pos) const |
| Function call operator that logs an error to file. | |
| Iterator | get_pos (Iterator err_pos, int &line) const |
| Finds the start of the line containing an error and computes line number. | |
| std::string | get_line (Iterator err_pos) const |
| Extracts the complete line containing an error. | |
Public Attributes | |
| Iterator | first |
| Iterator to the beginning of the source code. | |
| Iterator | last |
| Iterator to the end of the source code. | |
| std::vector< Iterator > | iters |
| Vector mapping AST node IDs to source positions (used by PAnnotation) | |
The PErrorHandler struct handles parsing and semantic errors.
This error handler logs detailed error information to a file, including the error message, line number, source line, and a visual pointer to the error position. It integrates with the Boost.Spirit X3 parser error handling mechanism and works in conjunction with the PAnnotation handler to map AST node IDs back to source positions.
Errors are appended to: ~/.musrfit/mupp/mupp_err.log
| Iterator | the iterator type for the source code (typically std::string::const_iterator) |
Definition at line 59 of file PErrorHandler.hpp.
|
inline |
Constructor that stores the source code range.
| first | iterator pointing to the beginning of the source code |
| last | iterator pointing to the end of the source code |
Definition at line 67 of file PErrorHandler.hpp.
|
inline |
Extracts the complete line containing an error.
Returns the substring from the start of the line to the next line break.
| err_pos | iterator pointing to the start of the line |
Definition at line 149 of file PErrorHandler.hpp.
|
inline |
Finds the start of the line containing an error and computes line number.
Scans from the beginning of the source to the error position, counting line breaks (CR, LF, or CRLF) to determine the line number.
| err_pos | iterator pointing to the error position |
| line | output parameter that will contain the 1-based line number |
Definition at line 118 of file PErrorHandler.hpp.
|
inline |
Function call operator that logs an error to file.
Determines the line number and position of the error, formats a user-friendly error message with a visual indicator (^~~), and appends it to the error log file. Handles both mid-file errors and unexpected end-of-file errors.
| Message | the message type (typically std::string) |
| What | the expected element type (typically std::string) |
| message | the error message prefix (e.g., "**ERROR** Expecting ") |
| what | description of what was expected at the error position |
| err_pos | iterator pointing to the position where the error occurred |
Definition at line 85 of file PErrorHandler.hpp.
| Iterator mupp::PErrorHandler< Iterator >::first |
Iterator to the beginning of the source code.
Definition at line 158 of file PErrorHandler.hpp.
| std::vector<Iterator> mupp::PErrorHandler< Iterator >::iters |
Vector mapping AST node IDs to source positions (used by PAnnotation)
Definition at line 160 of file PErrorHandler.hpp.
| Iterator mupp::PErrorHandler< Iterator >::last |
Iterator to the end of the source code.
Definition at line 159 of file PErrorHandler.hpp.