@@ -102,8 +102,6 @@ namespace antlr4 {
102
102
NProtoAST::IErrorCollector* errors;
103
103
bool * error;
104
104
public:
105
- static ConsoleErrorListener INSTANCE;
106
-
107
105
YqlErrorListener (NProtoAST::IErrorCollector* errors, bool * error);
108
106
109
107
virtual void syntaxError (Recognizer *recognizer, Token * offendingSymbol, size_t line, size_t charPositionInLine,
@@ -137,8 +135,8 @@ namespace NProtoAST {
137
135
return Parser.Parse (Lexer, &errors);
138
136
} catch (const TTooManyErrors&) {
139
137
return nullptr ;
140
- } catch (const yexception& e ) {
141
- errors.Error (0 , 0 , e. what ());
138
+ } catch (... ) {
139
+ errors.Error (0 , 0 , CurrentExceptionMessage ());
142
140
return nullptr ;
143
141
}
144
142
}
@@ -159,7 +157,7 @@ namespace NProtoAST {
159
157
public:
160
158
TProtoASTBuilder (TStringBuf data, const TString& queryName = " query" , google::protobuf::Arena* arena = nullptr )
161
159
: QueryName(queryName)
162
- , InputStream(std::string( data)) // Why the hell antlr needs non-const ptr??
160
+ , InputStream(data)
163
161
, Lexer(&InputStream)
164
162
, TokenStream(&Lexer)
165
163
, Parser(&TokenStream, arena)
@@ -169,6 +167,7 @@ namespace NProtoAST {
169
167
google::protobuf::Message* BuildAST (IErrorCollector& errors) {
170
168
// TODO: find a better way to break on lexer errors
171
169
typename antlr4::YqlErrorListener listener (&errors, &Parser.error );
170
+ Parser.removeErrorListeners ();
172
171
Parser.addErrorListener (&listener);
173
172
try {
174
173
auto result = Parser.Parse (&errors);
@@ -179,8 +178,8 @@ namespace NProtoAST {
179
178
Parser.removeErrorListener (&listener);
180
179
Parser.error = false ;
181
180
return nullptr ;
182
- } catch (const yexception& e ) {
183
- errors.Error (0 , 0 , e. what ());
181
+ } catch (... ) {
182
+ errors.Error (0 , 0 , CurrentExceptionMessage ());
184
183
Parser.removeErrorListener (&listener);
185
184
Parser.error = false ;
186
185
return nullptr ;
@@ -232,8 +231,8 @@ namespace NProtoAST {
232
231
}
233
232
}
234
233
} catch (const TTooManyErrors&) {
235
- } catch (const yexception& e ) {
236
- errors.Error (0 , 0 , e. what ());
234
+ } catch (... ) {
235
+ errors.Error (0 , 0 , CurrentExceptionMessage ());
237
236
}
238
237
}
239
238
@@ -272,8 +271,8 @@ namespace NProtoAST {
272
271
}
273
272
}
274
273
} catch (const TTooManyErrors&) {
275
- } catch (const yexception& e ) {
276
- errors.Error (0 , 0 , e. what ());
274
+ } catch (... ) {
275
+ errors.Error (0 , 0 , CurrentExceptionMessage ());
277
276
}
278
277
}
279
278
0 commit comments