XACC
xasm_errorlistener.hpp
1 /*******************************************************************************
2  * Copyright (c) 2019 UT-Battelle, LLC.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * and Eclipse Distribution License v1.0 which accompanies this
6  * distribution. The Eclipse Public License is available at
7  * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
8  *License is available at https://eclipse.org/org/documents/edl-v10.php
9  *
10  * Contributors:
11  * Alexander J. McCaskey - initial API and implementation
12  *******************************************************************************/
13 #ifndef XACC_XASMERRORLISTENER_HPP
14 #define XACC_XASMERRORLISTENER_HPP
15 
16 using namespace antlr4;
17 
18 class XASMErrorListener : public BaseErrorListener {
19 public:
20  void syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line,
21  size_t charPositionInLine, const std::string &msg,
22  std::exception_ptr e) override {
23  std::ostringstream output;
24  output << "Invalid xasm source: [";
25  output << line << ":" << charPositionInLine << "] " << msg;
26  xacc::error(output.str());
27  }
28 };
29 
30 #endif // XACC_LANG_ERRORLISTENER_HPP