diff options
author | Victor Smirnov <[email protected]> | 2025-03-19 13:03:56 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-03-19 13:18:48 +0300 |
commit | 28b29535ce7b21a3dde60b485c98f66f8c08f882 (patch) | |
tree | b831ec57225a22c3241a443eccc20af1053fc561 /yql/essentials/parser/common/error.cpp | |
parent | 6c4b9a2b45127baabf73cdcb6323f3e3e09e5440 (diff) |
YQL-19616 Implement ILexer via antlr_ast
- [x] Added `antlr_ast/antlr4` module and moved `TLexerTokensCollector4` there from `proto_ast/antlr4`.
- [x] Moved stuff around back and forth.
Ready for a review.
---
Co-authored-by: vityaman [[email protected]]
Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1128
commit_hash:e08785c3408ef813505bdc7511560e9536f4ab79
Diffstat (limited to 'yql/essentials/parser/common/error.cpp')
-rw-r--r-- | yql/essentials/parser/common/error.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/yql/essentials/parser/common/error.cpp b/yql/essentials/parser/common/error.cpp new file mode 100644 index 00000000000..9954a037cb4 --- /dev/null +++ b/yql/essentials/parser/common/error.cpp @@ -0,0 +1,47 @@ +#include "error.h" + +namespace NAST { + + IErrorCollector::IErrorCollector(size_t maxErrors) + : MaxErrors(maxErrors) + , NumErrors(0) + { + } + + IErrorCollector::~IErrorCollector() + { + } + + void IErrorCollector::Error(ui32 line, ui32 col, const TString& message) { + if (NumErrors + 1 == MaxErrors) { + AddError(0, 0, "Too many errors"); + ++NumErrors; + } + + if (NumErrors >= MaxErrors) { + ythrow TTooManyErrors() << "Too many errors"; + } + + AddError(line, col, message); + ++NumErrors; + } + + TErrorOutput::TErrorOutput(IOutputStream& err, const TString& name, size_t maxErrors) + : IErrorCollector(maxErrors) + , Err(err) + , Name(name) + { + } + + TErrorOutput::~TErrorOutput() + { + } + + void TErrorOutput::AddError(ui32 line, ui32 col, const TString& message) { + if (!Name.empty()) { + Err << "Query " << Name << ": "; + } + Err << "Line " << line << " column " << col << " error: " << message; + } + +} // namespace NAST |