LCOV - code coverage report
Current view: top level - usr/include/antlr4-runtime - BailErrorStrategy.h (source / functions) Hit Total Coverage
Test: ROSE Lines: 0 1 0.0 %
Date: 2022-12-08 13:48:47 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
       2             :  * Use of this file is governed by the BSD 3-clause license that
       3             :  * can be found in the LICENSE.txt file in the project root.
       4             :  */
       5             : 
       6             : #pragma once
       7             : 
       8             : #include "DefaultErrorStrategy.h"
       9             : 
      10             : namespace antlr4 {
      11             : 
      12             :   /**
      13             :    * This implementation of {@link ANTLRErrorStrategy} responds to syntax errors
      14             :    * by immediately canceling the parse operation with a
      15             :    * {@link ParseCancellationException}. The implementation ensures that the
      16             :    * {@link ParserRuleContext#exception} field is set for all parse tree nodes
      17             :    * that were not completed prior to encountering the error.
      18             :    *
      19             :    * <p>
      20             :    * This error strategy is useful in the following scenarios.</p>
      21             :    *
      22             :    * <ul>
      23             :    * <li><strong>Two-stage parsing:</strong> This error strategy allows the first
      24             :    * stage of two-stage parsing to immediately terminate if an error is
      25             :    * encountered, and immediately fall back to the second stage. In addition to
      26             :    * avoiding wasted work by attempting to recover from errors here, the empty
      27             :    * implementation of {@link BailErrorStrategy#sync} improves the performance of
      28             :    * the first stage.</li>
      29             :    * <li><strong>Silent validation:</strong> When syntax errors are not being
      30             :    * reported or logged, and the parse result is simply ignored if errors occur,
      31             :    * the {@link BailErrorStrategy} avoids wasting work on recovering from errors
      32             :    * when the result will be ignored either way.</li>
      33             :    * </ul>
      34             :    *
      35             :    * <p>
      36             :    * {@code myparser.setErrorHandler(new BailErrorStrategy());}</p>
      37             :    *
      38             :    * @see Parser#setErrorHandler(ANTLRErrorStrategy)
      39             :    */
      40           0 :   class ANTLR4CPP_PUBLIC BailErrorStrategy : public DefaultErrorStrategy {
      41             :     /// <summary>
      42             :     /// Instead of recovering from exception {@code e}, re-throw it wrapped
      43             :     ///  in a <seealso cref="ParseCancellationException"/> so it is not caught by the
      44             :     ///  rule function catches.  Use <seealso cref="Exception#getCause()"/> to get the
      45             :     ///  original <seealso cref="RecognitionException"/>.
      46             :     /// </summary>
      47             :   public:
      48             :     virtual void recover(Parser *recognizer, std::exception_ptr e) override;
      49             : 
      50             :     /// Make sure we don't attempt to recover inline; if the parser
      51             :     ///  successfully recovers, it won't throw an exception.
      52             :     virtual Token* recoverInline(Parser *recognizer) override;
      53             : 
      54             :     /// <summary>
      55             :     /// Make sure we don't attempt to recover from problems in subrules. </summary>
      56             :     virtual void sync(Parser *recognizer) override;
      57             :   };
      58             : 
      59             : } // namespace antlr4

Generated by: LCOV version 1.14