This repository was archived by the owner on Sep 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcstructerrorlistener.h
More file actions
51 lines (37 loc) · 1.36 KB
/
cstructerrorlistener.h
File metadata and controls
51 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef CSTRUCTERRORLISTENER_H
#define CSTRUCTERRORLISTENER_H
#include <antlr4-runtime.h>
#include <functional>
#include <QCoreApplication>
#include <QString>
#include "define.h"
class CStructErrorListener : public antlr4::BaseErrorListener {
Q_DECLARE_TR_FUNCTIONS(CStructErrorListener)
public:
using ErrorHandler = std::function<void(const MsgInfo &)>;
public:
explicit CStructErrorListener(const ErrorHandler &handler);
// ANTLRErrorListener interface
public:
virtual void syntaxError(antlr4::Recognizer *recognizer,
antlr4::Token *offendingSymbol, size_t line,
size_t charPositionInLine, const std::string &msg,
std::exception_ptr e) override;
public:
void reportError(size_t line, size_t charPositionInLine,
const QString &info);
void reportWarn(size_t line, size_t charPositionInLine,
const QString &info);
size_t lineOffset() const;
size_t charPosOffset() const;
void setPositionOffset(size_t line, size_t charPosOff);
void resetPositionOffset();
private:
void reportMsg(MsgType type, size_t line, size_t charPositionInLine,
const QString &info);
private:
ErrorHandler _handler;
size_t _line = 0;
size_t _charPosOffset = 0;
};
#endif // CSTRUCTERRORLISTENER_H