Home | History | Annotate | Download | only in java
      1 #set( $symbol_pound = '#' )
      2 #set( $symbol_dollar = '$' )
      3 #set( $symbol_escape = '\' )
      4 package ${package};
      5 
      6 import org.antlr.runtime.*;
      7 
      8 /**
      9  * The super class of the generated parser. It is extended by the generated
     10  * code because of the superClass optoin in the .g file.
     11  *
     12  * This class contains any helper functions used within the parser
     13  * grammar itself, as well as any overrides of the standard ANTLR Java
     14  * runtime methods, such as an implementation of a custom error reporting
     15  * method, symbol table populating methods and so on.
     16  *
     17  * @author Jim Idle - Temporal Wave LLC - jimi (at) temporal-wave.com
     18  */
     19 public abstract class AbstractTParser
     20 
     21         extends Parser
     22 
     23 {
     24     /**
     25      * Create a new parser instance, pre-supplying the input token stream.
     26      *
     27      * @param input The stream of tokens that will be pulled from the lexer
     28      */
     29     protected AbstractTParser(TokenStream input) {
     30         super(input);
     31     }
     32 
     33     /**
     34      * Create a new parser instance, pre-supplying the input token stream
     35      * and the shared state.
     36      *
     37      * This is only used when a grammar is imported into another grammar, but
     38      * we must supply this constructor to satisfy the super class contract.
     39      *
     40      * @param input The stream of tokesn that will be pulled from the lexer
     41      * @param state The shared state object created by an interconnectd grammar
     42      */
     43     protected AbstractTParser(TokenStream input, RecognizerSharedState state) {
     44         super(input, state);
     45     }
     46 
     47 
     48     /**
     49      * Creates the error/warning message that we need to show users/IDEs when
     50      * ANTLR has found a parsing error, has recovered from it and is now
     51      * telling us that a parsing exception occurred.
     52      *
     53      * @param tokenNames token names as known by ANTLR (which we ignore)
     54      * @param e The exception that was thrown
     55      */
     56     @Override
     57     public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
     58 
     59         // This is just a place holder that shows how to override this method
     60         //
     61         super.displayRecognitionError(tokenNames, e);
     62     }
     63 }
     64 
     65