antlr3defs.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /** \file
  2. * Basic type and constant definitions for ANTLR3 Runtime.
  3. */
  4. #ifndef _ANTLR3DEFS_HPP
  5. #define _ANTLR3DEFS_HPP
  6. // [The "BSD licence"]
  7. // Copyright (c) 2005-2009 Gokulakannan Somasundaram, ElectronDB
  8. //
  9. // All rights reserved.
  10. //
  11. // Redistribution and use in source and binary forms, with or without
  12. // modification, are permitted provided that the following conditions
  13. // are met:
  14. // 1. Redistributions of source code must retain the above copyright
  15. // notice, this list of conditions and the following disclaimer.
  16. // 2. Redistributions in binary form must reproduce the above copyright
  17. // notice, this list of conditions and the following disclaimer in the
  18. // documentation and/or other materials provided with the distribution.
  19. // 3. The name of the author may not be used to endorse or promote products
  20. // derived from this software without specific prior written permission.
  21. //
  22. // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  23. // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  25. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  27. // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31. // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. // not used in C++ target (kept for "historical" reasons, the generated code still uses this)
  33. #define ANTLR_SIZE_HINT 0U
  34. /* Work out what operating system/compiler this is. We just do this once
  35. * here and use an internal symbol after this.
  36. */
  37. #ifdef _WIN64
  38. # define ANTLR_USE_64BIT
  39. #endif
  40. #ifdef _WIN32
  41. #ifndef WIN32_LEAN_AND_MEAN
  42. #define WIN32_LEAN_AND_MEAN
  43. #endif
  44. /* Allow VC 8 (vs2005) and above to use 'secure' versions of various functions such as sprintf
  45. */
  46. #ifndef _CRT_SECURE_NO_DEPRECATE
  47. #define _CRT_SECURE_NO_DEPRECATE
  48. #endif
  49. #ifndef NOMINMAX
  50. #define NOMINMAX
  51. #endif
  52. #include <winsock2.h>
  53. #define ANTLR_INLINE __inline
  54. typedef FILE * ANTLR_FDSC;
  55. typedef struct sockaddr_in ANTLR_SOCKADDRT, * pANTLR_SOCKADDRT; // Type used for socket address declaration
  56. typedef struct sockaddr ANTLR_SOCKADDRC, * pANTLR_SOCKADDRC; // Type used for cast on accept()
  57. #define ANTLR_CLOSESOCKET closesocket
  58. #else // Un*x
  59. #ifdef __LP64__
  60. #define ANTLR_USE_64BIT
  61. #endif
  62. #define ANTLR_INLINE inline
  63. typedef int SOCKET;
  64. typedef FILE * ANTLR_FDSC;
  65. #endif
  66. // Standard integer types (since C++11) (should work with MSVC 2010/2013, gcc, clang)
  67. //
  68. typedef std::int32_t ANTLR_CHAR;
  69. typedef std::uint32_t ANTLR_UCHAR;
  70. typedef std::int8_t ANTLR_INT8;
  71. typedef std::int16_t ANTLR_INT16;
  72. typedef std::int32_t ANTLR_INT32;
  73. typedef std::int64_t ANTLR_INT64;
  74. typedef std::uint8_t ANTLR_UINT8;
  75. typedef std::uint16_t ANTLR_UINT16;
  76. typedef std::uint32_t ANTLR_UINT32;
  77. typedef std::uint64_t ANTLR_UINT64;
  78. typedef std::uint64_t ANTLR_BITWORD;
  79. #ifdef ANTLR_USE_64BIT
  80. #define ANTLR_UINT64_CAST(ptr) (ANTLR_UINT64)(ptr))
  81. #define ANTLR_UINT32_CAST(ptr) (ANTLR_UINT32)((ANTLR_UINT64)(ptr))
  82. typedef ANTLR_INT64 ANTLR_MARKER;
  83. typedef ANTLR_UINT64 ANTLR_INTKEY;
  84. #else
  85. #define ANTLR_UINT64_CAST(ptr) (ANTLR_UINT64)((ANTLR_UINT32)(ptr))
  86. #define ANTLR_UINT32_CAST(ptr) (ANTLR_UINT32)(ptr)
  87. typedef ANTLR_INT32 ANTLR_MARKER;
  88. typedef ANTLR_UINT32 ANTLR_INTKEY;
  89. #endif
  90. #define ANTLR_UINT64_LIT(lit) lit##ULL
  91. #endif /* _ANTLR3DEFS_H */