diff options
Diffstat (limited to 'antlr-3.4/antlr3-maven-archetype/src/main/resources/archetype-resources/src/main/java/AbstractTParser.java')
-rw-r--r-- | antlr-3.4/antlr3-maven-archetype/src/main/resources/archetype-resources/src/main/java/AbstractTParser.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/antlr-3.4/antlr3-maven-archetype/src/main/resources/archetype-resources/src/main/java/AbstractTParser.java b/antlr-3.4/antlr3-maven-archetype/src/main/resources/archetype-resources/src/main/java/AbstractTParser.java new file mode 100644 index 0000000..53b294f --- /dev/null +++ b/antlr-3.4/antlr3-maven-archetype/src/main/resources/archetype-resources/src/main/java/AbstractTParser.java @@ -0,0 +1,64 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import org.antlr.runtime.*; + +/** + * The super class of the generated parser. It is extended by the generated + * code because of the superClass optoin in the .g file. + * + * This class contains any helper functions used within the parser + * grammar itself, as well as any overrides of the standard ANTLR Java + * runtime methods, such as an implementation of a custom error reporting + * method, symbol table populating methods and so on. + * + * @author Jim Idle - Temporal Wave LLC - jimi@temporal-wave.com + */ +public abstract class AbstractTParser + + extends Parser + +{ + /** + * Create a new parser instance, pre-supplying the input token stream. + * + * @param input The stream of tokens that will be pulled from the lexer + */ + protected AbstractTParser(TokenStream input) { + super(input); + } + + /** + * Create a new parser instance, pre-supplying the input token stream + * and the shared state. + * + * This is only used when a grammar is imported into another grammar, but + * we must supply this constructor to satisfy the super class contract. + * + * @param input The stream of tokesn that will be pulled from the lexer + * @param state The shared state object created by an interconnectd grammar + */ + protected AbstractTParser(TokenStream input, RecognizerSharedState state) { + super(input, state); + } + + + /** + * Creates the error/warning message that we need to show users/IDEs when + * ANTLR has found a parsing error, has recovered from it and is now + * telling us that a parsing exception occurred. + * + * @param tokenNames token names as known by ANTLR (which we ignore) + * @param e The exception that was thrown + */ + @Override + public void displayRecognitionError(String[] tokenNames, RecognitionException e) { + + // This is just a place holder that shows how to override this method + // + super.displayRecognitionError(tokenNames, e); + } +} + |