f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/main/java/io/protobase/f7/spreadsheet/ParseErrorListener.java
-rw-r--r--
846
 1package io.protobase.f7.spreadsheet;
 2
 3import org.antlr.v4.runtime.BaseErrorListener;
 4import org.antlr.v4.runtime.RecognitionException;
 5import org.antlr.v4.runtime.Recognizer;
 6import org.antlr.v4.runtime.misc.ParseCancellationException;
 7
 8/**
 9 * Listens for syntax errors when parsing, throwing a parse cancellation exception.
10 */
11public class ParseErrorListener extends BaseErrorListener {
12
13  /**
14   * If we encounter a syntax error, we can't do anything with it, so we stop parsing by throwing parse cancelation
15   * exception.
16   */
17  @Override
18  public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
19      String msg, RecognitionException e)
20      throws ParseCancellationException {
21    throw new ParseCancellationException("line " + line + ":" + charPositionInLine + " " + msg);
22  }
23}