1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2 * Use of this file is governed by the BSD 3-clause license that
3 * can be found in the LICENSE.txt file in the project root.
28 #include <type_traits>
29 #include <unordered_map>
30 #include <unordered_set>
36 #include <condition_variable>
39 #ifndef USE_UTF8_INSTEAD_OF_CODECVT
43 // Defines for the Guid class and other platform dependent stuff.
46 #pragma warning (disable: 4250) // Class inherits by dominance.
47 #pragma warning (disable: 4512) // assignment operator could not be generated
50 // Before VS 2015 code like "while (true)" will create a (useless) warning in level 4.
51 #pragma warning (disable: 4127) // conditional expression is constant
58 typedef __int64 ssize_t;
60 typedef __int32 ssize_t;
63 #if _MSC_VER >= 1900 && _MSC_VER < 2000
64 // VS 2015 has a known bug when using std::codecvt_utf8<char32_t>
65 // so we have to temporarily use __int32 instead.
66 // https://connect.microsoft.com/VisualStudio/feedback/details/1403302/unresolved-external-when-using-codecvt-utf8
67 typedef std::basic_string<__int32> i32string;
69 typedef i32string UTF32String;
71 typedef std::u32string UTF32String;
74 #ifdef ANTLR4CPP_EXPORTS
75 #define ANTLR4CPP_PUBLIC __declspec(dllexport)
77 #ifdef ANTLR4CPP_STATIC
78 #define ANTLR4CPP_PUBLIC
80 #define ANTLR4CPP_PUBLIC __declspec(dllimport)
84 #if defined(_MSC_VER) && !defined(__clang__)
85 // clang-cl should escape this to prevent [ignored-attributes].
87 class ANTLR4CPP_PUBLIC exception; // Prevents warning C4275 from MSVC.
91 #elif defined(__APPLE__)
92 typedef std::u32string UTF32String;
96 #define ANTLR4CPP_PUBLIC __attribute__ ((visibility ("default")))
98 #define ANTLR4CPP_PUBLIC
101 typedef std::u32string UTF32String;
105 #define ANTLR4CPP_PUBLIC __attribute__ ((visibility ("default")))
107 #define ANTLR4CPP_PUBLIC
111 #include "support/guid.h"
112 #include "support/Declarations.h"
114 #if !defined(HAS_NOEXCEPT)
115 #if defined(__clang__)
116 #if __has_feature(cxx_noexcept)
120 #if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 || \
121 defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026
127 #define NOEXCEPT noexcept
133 // We have to undefine this symbol as ANTLR will use this name for own members and even
134 // generated functions. Because EOF is a global macro we cannot use e.g. a namespace scope to disambiguate.
139 #define INVALID_INDEX std::numeric_limits<size_t>::max()
140 template<class T> using Ref = std::shared_ptr<T>;