summarylogtreecommitdiffstats
path: root/0007-ANTLR4-4.10-compatibility.patch
blob: c2790d1763fb7ea5d4b15c7abcf219d2b81ef55f (plain)
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
52
53
54
55
56
From d760aa7784c28cb914e51f7f771652d2bbbd1d32 Mon Sep 17 00:00:00 2001
From: Xiretza <xiretza@xiretza.xyz>
Date: Sat, 4 Jun 2022 10:47:32 +0200
Subject: [PATCH 7/9] ANTLR4 4.10 compatibility

Commit 70b2edcf98[0] removed antlrcpp::Any in favor of std::any.

[0]: https://github.com/antlr/antlr4/commit/70b2edcf98eb612a92d3dbaedb2ce0b69533b0cb
---
 src/ParseFasm.cpp | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/ParseFasm.cpp b/src/ParseFasm.cpp
index 6a1e720..8f3ca67 100644
--- a/src/ParseFasm.cpp
+++ b/src/ParseFasm.cpp
@@ -199,7 +199,7 @@ struct ParseException {
 
 /// Helper macro to convert a rule context into a string
 /// For use inside FasmParserBaseVisitor
-#define GET(x) (context->x() ? visit(context->x()).as<std::string>() : "")
+#define GET(x) (context->x() ? std::any_cast<std::string>(visit(context->x())) : "")
 
 /// FasmParserBaseVisitor is a visitor for the parse tree
 /// generated by the ANTLR parser.
@@ -218,7 +218,7 @@ class FasmParserBaseVisitor : public FasmParserVisitor {
         virtual Any visitFasmFile(
             FasmParser::FasmFileContext* context) override {
                 for (auto& line : context->fasmLine()) {
-                        std::string str = visit(line).as<std::string>();
+                        std::string str = std::any_cast<std::string>(visit(line));
                         if (!str.empty()) {
                                 out << str;
                                 if (hex_mode)
@@ -285,8 +285,7 @@ class FasmParserBaseVisitor : public FasmParserVisitor {
                                     TAG('\'', width),
                                     std::stoi(context->INT()->getText()));
                         }
-                        data << visit(context->verilogDigits())
-                                    .as<std::string>();
+                        data << std::any_cast<std::string>(visit(context->verilogDigits()));
                 }
                 return data.str();
         }
@@ -439,7 +438,7 @@ class FasmParserBaseVisitor : public FasmParserVisitor {
             FasmParser::AnnotationsContext* context) override {
                 std::ostringstream data;
                 for (auto& a : context->annotation()) {
-                        data << visit(a).as<std::string>();
+                        data << std::any_cast<std::string>(visit(a));
                 }
                 return withHeader(TAG('{', annotations), data.str());
         }
-- 
2.36.1