src/main/java/com/acme/calculator/main/Calculator.java
/*
     * Helper method to create an ANTLRErrorListener.
     * Only the syntaxError() method is utilized.
     * todo: The other three methods below could be researched further to
     * determine if they may be of use for edge case(s).
     */
Helper method to create an ANTLRErrorListener.
Only the syntaxError() method is utilized.
todo: The other three methods below could be researched further to
determine if they may be of use for edge case(s).
Helper method to create an ANTLRErrorListener . Only the syntaxError () method is utilized . todo : The other three methods below could be researched further to determine if they may be of use for edge case ( s ) .
private ANTLRErrorListener createErrorListener() {
        return new ANTLRErrorListener() {
            public void syntaxError(final Recognizer<?, ?> arg0, final Object obj, final int line,
                                    final int position, final String message, final RecognitionException ex) {
                throw new IllegalArgumentException(String.format(Locale.ROOT,
                        "Syntax error in expression: '%s' on line %s, position %s",
                        message, line, position));
            }
            @Override
            public void reportAmbiguity(final Parser parser, final DFA dfa, final int i, final int i1,
                                        final boolean b, final BitSet bitSet, final ATNConfigSet atnConfigSet) {
            }
            @Override
            public void reportAttemptingFullContext(final Parser parser, final DFA dfa, final int i, final int i1,
                                                    final BitSet bitSet, final ATNConfigSet atnConfigSet) {
            }
            @Override
            public void reportContextSensitivity(final Parser parser, final DFA dfa, final int i, final int i1,
                                                 final int i2, final ATNConfigSet atnConfigSet) {
            }
        };
    }
private ANTLRErrorListener createErrorListener ( ) { return new ANTLRErrorListener ( ) { public void syntaxError ( final Recognizer < ? , ? > arg0 , final Object obj , final int line , final int position , final String message , final RecognitionException ex ) { throw new IllegalArgumentException ( String . format ( Locale . ROOT , "Syntax error in expression: '%s' on line %s, position %s" , message , line , position ) ) ; } @ Override public void reportAmbiguity ( final Parser parser , final DFA dfa , final int i , final int i1 , final boolean b , final BitSet bitSet , final ATNConfigSet atnConfigSet ) { } @ Override public void reportAttemptingFullContext ( final Parser parser , final DFA dfa , final int i , final int i1 , final BitSet bitSet , final ATNConfigSet atnConfigSet ) { } @ Override public void reportContextSensitivity ( final Parser parser , final DFA dfa , final int i , final int i1 , final int i2 , final ATNConfigSet atnConfigSet ) { } } ; }
Helper method to create an ANTLRErrorListener.
Helper method to create an ANTLRErrorListener .
// not used by lexer code // not used by lexer code // not used by lexer code