-
Notifications
You must be signed in to change notification settings - Fork 0
/
presto_parser.patch
47 lines (40 loc) · 1.4 KB
/
presto_parser.patch
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
diff --git a/ext/presto_parser/presto_parser.cpp b/ext/presto_parser/presto_parser.cpp
index 1d13004..603127a 100644
--- a/ext/presto_parser/presto_parser.cpp
+++ b/ext/presto_parser/presto_parser.cpp
@@ -6,6 +6,8 @@
#include "antlrgen/PrestoBaseVisitor.h"
#include "antlrgen/PrestoLexer.h"
+#include "PrestoErrorListener.h"
+
#include <rice/rice.hpp>
#include <rice/stl.hpp>
@@ -169,6 +171,7 @@ Class rb_cParser;
Class rb_cParseTree;
Class rb_cTerminalNode;
Class rb_cContextProxy;
+VALUE rb_eSyntaxError;
namespace Rice::detail {
template <>
@@ -12858,7 +12861,6 @@ public:
};
-
class ParserProxy {
public:
static ParserProxy* parse(string code) {
@@ -12910,6 +12912,8 @@ private:
parser -> lexer = new PrestoLexer(parser -> input);
parser -> tokens = new CommonTokenStream(parser -> lexer);
parser -> parser = new PrestoParser(parser -> tokens);
+ parser -> parser -> removeErrorListeners();
+ parser -> parser -> addErrorListener(new PrestoErrorListener(rb_eSyntaxError));
return parser;
}
@@ -13508,6 +13512,8 @@ extern "C"
void Init_presto_parser() {
Module rb_mPrestoParser = define_module("PrestoParser");
+ rb_eSyntaxError = define_class_under(rb_mPrestoParser, "SyntaxError", rb_eStandardError);
+
rb_cToken = define_class_under<Token>(rb_mPrestoParser, "Token")
.define_method("text", &Token::getText)
.define_method("channel", &Token::getChannel)