antlr3interfaces.hpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /** \file
  2. * Declarations for all the antlr3 C runtime interfaces/classes. This
  3. * allows the structures that define the interfaces to contain pointers to
  4. * each other without trying to sort out the cyclic interdependencies that
  5. * would otherwise result.
  6. */
  7. #ifndef _ANTLR3_INTERFACES_HPP
  8. #define _ANTLR3_INTERFACES_HPP
  9. // [The "BSD licence"]
  10. // Copyright (c) 2005-2009 Gokulakannan Somasundaram, ElectronDB
  11. //
  12. // All rights reserved.
  13. //
  14. // Redistribution and use in source and binary forms, with or without
  15. // modification, are permitted provided that the following conditions
  16. // are met:
  17. // 1. Redistributions of source code must retain the above copyright
  18. // notice, this list of conditions and the following disclaimer.
  19. // 2. Redistributions in binary form must reproduce the above copyright
  20. // notice, this list of conditions and the following disclaimer in the
  21. // documentation and/or other materials provided with the distribution.
  22. // 3. The name of the author may not be used to endorse or promote products
  23. // derived from this software without specific prior written permission.
  24. //
  25. // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  26. // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  27. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  28. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  29. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  30. // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  34. // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. namespace antlr3 {
  36. // Definitions that indicate the encoding scheme character streams and strings etc
  37. enum Encoding
  38. {
  39. ENC_8BIT = 4 /// General latin-1 or other 8 bit encoding scheme such as straight ASCII
  40. , ENC_UTF8 = 8 /// UTF-8 encoding scheme
  41. , ENC_UTF16 = 16 /// UTF-16 encoding scheme (which also covers UCS2 as that does not have surrogates)
  42. , ENC_UTF16BE
  43. , ENC_UTF16LE
  44. , ENC_UTF32 = 32 /// UTF-32 encoding scheme (basically straight 32 bit)
  45. , ENC_UTF32BE
  46. , ENC_UTF32LE
  47. , ENC_EBCDIC = 64 /// Input is 8 bit EBCDIC (which we convert to 8 bit ASCII on the fly
  48. };
  49. enum ChannelType
  50. {
  51. TOKEN_DEFAULT_CHANNEL = 0 /// Default channel for a token
  52. , HIDDEN = 99 /// Reserved channel number for a HIDDEN token - a token that is hidden from the parser
  53. };
  54. /// Pointer to an instantiation of 'class' #ANTLR3_EXCEPTION
  55. /// \ingroup ANTLR3_EXCEPTION
  56. ///
  57. enum ExceptionType
  58. {
  59. /** Indicates that the recognizer received a token
  60. * in the input that was not predicted.
  61. */
  62. RECOGNITION_EXCEPTION = 0
  63. /** Indicates that the recognizer was expecting one token and found a
  64. * a different one.
  65. */
  66. , MISMATCHED_TOKEN_EXCEPTION
  67. /** Recognizer could not find a valid alternative from the input
  68. */
  69. , NO_VIABLE_ALT_EXCEPTION
  70. /* Character in a set was not found
  71. */
  72. , MISMATCHED_SET_EXCEPTION
  73. /* A rule predicting at least n elements found less than that,
  74. * such as: WS: " "+;
  75. */
  76. , EARLY_EXIT_EXCEPTION
  77. , FAILED_PREDICATE_EXCEPTION
  78. , MISMATCHED_TREE_NODE_EXCEPTION
  79. , REWRITE_EARLY_EXCEPTION
  80. , UNWANTED_TOKEN_EXCEPTION
  81. , MISSING_TOKEN_EXCEPTION
  82. };
  83. template<class ImplTraits, class SuperType>
  84. class IntStream;
  85. /// Pointer to an instantiation of 'class' #ANTLR3_RECOGNIZER_SHARED_STATE
  86. /// \ingroup ANTLR3_RECOGNIZER_SHARED_STATE
  87. ///
  88. template<class ImplTraits, class SuperType>
  89. class RecognizerSharedState;
  90. /// Pointer to an instantiation of 'class' #ANTLR3_BITSET_LIST
  91. /// \ingroup ANTLR3_BITSET_LIST
  92. ///
  93. template<class AllocatorType>
  94. class BitsetList;
  95. /// Pointer to an instantiation of 'class' #ANTLR3_BITSET
  96. /// \ingroup ANTLR3_BITSET
  97. ///
  98. template<class AllocatorType>
  99. class Bitset;
  100. /// Pointer to an instantiation of 'class' #ANTLR3_COMMON_TOKEN
  101. /// \ingroup ANTLR3_COMMON_TOKEN
  102. ///
  103. template<class ImplTraits>
  104. class CommonToken;
  105. template<class ImplTraits, ExceptionType Ex, class StreamType>
  106. class ANTLR_Exception;
  107. /// Pointer to an instantiation of 'class' #ANTLR3_TOPO
  108. /// \ingroup ANTLR3_TOPO
  109. ///
  110. template<class AllocPolicyType>
  111. class Topo;
  112. /// Pointer to an instantiation of 'class' #ANTLR3_INPUT_STREAM
  113. /// \ingroup ANTLR3_INPUT_STREAM
  114. ///
  115. template<class ImplTraits>
  116. class InputStream;
  117. /// Pointer to an instantiation of 'class' #ANTLR3_LEX_STATE
  118. /// \ingroup ANTLR3_LEX_STATE
  119. ///
  120. template<class ImplTraits>
  121. class LexState;
  122. /// Pointer to an instantiation of 'class' #ANTLR3_TOKEN_SOURCE
  123. /// \ingroup ANTLR3_TOKEN_SOURCE
  124. ///
  125. template<class ImplTraits>
  126. class TokenSource;
  127. /// Pointer to an instantiation of 'class' #ANTLR3_TOKEN_STREAM
  128. /// \ingroup ANTLR3_TOKEN_STREAM
  129. ///
  130. template<class ImplTraits>
  131. class TokenStream;
  132. /// Pointer to an instantiation of 'class' #ANTLR3_COMMON_TOKEN_STREAM
  133. /// \ingroup ANTLR3_COMMON_TOKEN_STREAM
  134. ///
  135. template<class ImplTraits>
  136. class CommonTokenStream;
  137. /// Pointer to an instantiation of 'class' #ANTLR3_CYCLIC_DFA
  138. /// \ingroup ANTLR3_CYCLIC_DFA
  139. ///
  140. template<class ImplTraits, class ComponentType>
  141. class CyclicDFA;
  142. /// Pointer to an instantiation of 'class' #ANTLR3_LEXER
  143. /// \ingroup ANTLR3_LEXER
  144. ///
  145. template<class ImplTraits>
  146. class Lexer;
  147. /// Pointer to an instantiation of 'class' #ANTLR3_PARSER
  148. /// \ingroup ANTLR3_PARSER
  149. ///
  150. template<class ImplTraits>
  151. class Parser;
  152. /// Pointer to an instantiation of 'class' #ANTLR3_BASE_TREE
  153. /// \ingroup ANTLR3_BASE_TREE
  154. ///
  155. template<class ImplTraits>
  156. class BaseTree;
  157. /// Pointer to an instantiation of 'class' #ANTLR3_COMMON_TREE
  158. /// \ingroup ANTLR3_COMMON_TREE
  159. ///
  160. template<class ImplTraits>
  161. class CommonTree;
  162. /// Pointer to an instantiation of 'class' #ANTLR3_PARSE_TREE
  163. /// \ingroup ANTLR3_PARSE_TREE
  164. ///
  165. template<class ImplTraits>
  166. class ParseTree;
  167. /// Pointer to an instantiation of 'class' #ANTLR3_TREE_NODE_STREAM
  168. /// \ingroup ANTLR3_TREE_NODE_STREAM
  169. ///
  170. template<class ImplTraits>
  171. class TreeNodeStream;
  172. /// Pointer to an instantiation of 'class' #ANTLR3_COMMON_TREE_NODE_STREAM
  173. /// \ingroup ANTLR3_COMMON_TREE_NODE_STREAM
  174. ///
  175. template<class ImplTraits>
  176. class CommonTreeNodeStream;
  177. /// Pointer to an instantiation of 'class' #ANTLR3_TREE_WALK_STATE
  178. /// \ingroup ANTLR3_TREE_WALK_STATE
  179. ///
  180. template<class ImplTraits>
  181. class TreeWalkState;
  182. /// Pointer to an instantiation of 'class' #ANTLR3_COMMON_TREE_ADAPTOR
  183. /// \ingroup ANTLR3_COMMON_TREE_ADAPTOR
  184. ///
  185. template<class ImplTraits>
  186. class CommonTreeAdaptor;
  187. /// Pointer to an instantiation of 'class' #ANTLR3_TREE_PARSER
  188. /// \ingroup ANTLR3_TREE_PARSER
  189. ///
  190. template<class ImplTraits>
  191. class TreeParser;
  192. /// Pointer to an instantiation of 'class' #ANTLR3_INT_TRIE
  193. /// \ingroup ANTLR3_INT_TRIE
  194. ///
  195. template< class DataType, class AllocPolicyType >
  196. class IntTrie;
  197. /// Pointer to an instantiation of 'class' #ANTLR3_REWRITE_RULE_ELEMENT_STREAM
  198. /// \ingroup ANTLR3_REWRITE_RULE_ELEMENT_STREAM
  199. ///
  200. template<class ImplTraits, class SuperType>
  201. class RewriteRuleElementStream;
  202. template<class ImplTraits>
  203. class RewriteRuleTokenStream;
  204. template<class ImplTraits>
  205. class RewriteRuleSubtreeStream;
  206. template<class ImplTraits>
  207. class RewriteRuleNodeStream;
  208. /// Pointer to an instantiation of 'class' #ANTLR3_DEBUG_EVENT_LISTENER
  209. /// \ingroup ANTLR3_DEBUG_EVENT_LISTENER
  210. ///
  211. template<class ImplTraits>
  212. class DebugEventListener;
  213. //A Class just used for forwarding other classes for simplifying class forwarding
  214. //Logic: constructor is made simple
  215. template<class A>
  216. class ClassForwarder {};
  217. template<bool b>
  218. class BoolForwarder {};
  219. class Empty {};
  220. template<class ImplTraits, class StreamType>
  221. class ComponentTypeFinder
  222. {
  223. };
  224. template<class ImplTraits>
  225. class ComponentTypeFinder< ImplTraits, typename ImplTraits::InputStreamType>
  226. {
  227. public:
  228. typedef typename ImplTraits::LexerType ComponentType;
  229. };
  230. template<class ImplTraits>
  231. class ComponentTypeFinder< ImplTraits, typename ImplTraits::TokenStreamType>
  232. {
  233. public:
  234. typedef typename ImplTraits::ParserType ComponentType;
  235. };
  236. template<class ImplTraits>
  237. class ComponentTypeFinder< ImplTraits, typename ImplTraits::TreeNodeStreamType>
  238. {
  239. public:
  240. typedef typename ImplTraits::TreeParserType ComponentType;
  241. };
  242. }
  243. #endif