fix(frontend): 规范一下前端实现
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
|
||||
namespace {
|
||||
|
||||
bool HasParsePrefix(const std::string& msg) {
|
||||
return msg.rfind("[parse]", 0) == 0;
|
||||
}
|
||||
|
||||
class ParseErrorListener : public antlr4::BaseErrorListener {
|
||||
public:
|
||||
void syntaxError(antlr4::Recognizer* /*recognizer*/, antlr4::Token* /*offendingSymbol*/,
|
||||
@@ -49,6 +53,9 @@ AntlrResult ParseFileWithAntlr(const std::string& path) {
|
||||
} catch (const std::exception& ex) {
|
||||
const std::string msg = ex.what();
|
||||
if (!msg.empty()) {
|
||||
if (HasParsePrefix(msg)) {
|
||||
throw;
|
||||
}
|
||||
throw std::runtime_error("[parse] 暂不支持的语法/词法 - " + msg);
|
||||
}
|
||||
if (auto* tok = parser->getCurrentToken()) {
|
||||
|
||||
Reference in New Issue
Block a user