LCOV - code coverage report
Current view: top level - src/plugins/yanlr - error_listener.hpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 1 1 100.0 %
Date: 2019-09-12 12:28:41 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief an error listener reacting to mismatches of the grammar defined in `YAML.g4`
       5             :  *
       6             :  * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
       7             :  */
       8             : 
       9             : // -- Imports ------------------------------------------------------------------
      10             : 
      11             : #include <antlr4-runtime.h>
      12             : 
      13             : namespace yanlr
      14             : {
      15             : 
      16             : // -- Class --------------------------------------------------------------------
      17             : 
      18             : /**
      19             :  * @brief This class specifies methods to alter error messages.
      20             :  */
      21         124 : class ErrorListener : public antlr4::BaseErrorListener
      22             : {
      23             :         /** This variable stores the last error message emitted via the function `syntaxError`. */
      24             :         std::string errorMessage;
      25             : 
      26             :         /** This attribute stores the source, for which the error listener reports an error. */
      27             :         std::string source;
      28             : 
      29             : public:
      30             :         /**
      31             :          * @brief This constructor creates a new error listener using the given arguments.
      32             :          *
      33             :          * @param errorSource This text stores an identifier, usually the filename, that identifies the source of an error.
      34             :          */
      35             :         ErrorListener (std::string const & errorSource);
      36             : 
      37             :         /**
      38             :          * @brief This method will be called if the parsing process fails.
      39             :          *
      40             :          * @param recognizer This parameter stores the current recognizer used to
      41             :          *                   parse the input.
      42             :          * @param offendingSymbol This token caused the failure of the parsing
      43             :          *                        process.
      44             :          * @param line This number specifies the line where the parsing process
      45             :          *             failed.
      46             :          * @param charPositionInLine This number specifies the character position in
      47             :          *                           `line`, where the parsing process failed.
      48             :          * @param message This text describes the parsing failure.
      49             :          * @param error This parameter stores the exception caused by the parsing
      50             :          *              failure.
      51             :          */
      52             :         void syntaxError (antlr4::Recognizer * recognizer, antlr4::Token * offendingSymbol, size_t line, size_t charPositionInLine,
      53             :                           const std::string & message, std::exception_ptr error);
      54             : 
      55             :         /**
      56             :          * @brief This method returns the last error message saved by the error listener.
      57             :          *
      58             :          * @return A string containing an error message produced by the parser
      59             :          */
      60             :         char const * message ();
      61             : };
      62             : }

Generated by: LCOV version 1.13