antlr3recognizersharedstate.inl 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. namespace antlr3 {
  2. template<class ImplTraits, class StreamType>
  3. RecognizerSharedState<ImplTraits, StreamType>::RecognizerSharedState()
  4. {
  5. m_exception = NULL;
  6. m_sizeHint = 0;
  7. m_error = false;
  8. m_errorRecovery = false;
  9. m_failed = false;
  10. m_token_present = false;
  11. m_lastErrorIndex = 0;
  12. m_errorCount = 0;
  13. m_backtracking = false;
  14. m_ruleMemo = NULL;
  15. m_tokenNames = NULL;
  16. m_tokSource = NULL;
  17. m_channel = 0;
  18. m_type = 0;
  19. m_tokenStartLine = 0;
  20. m_tokenStartCharPositionInLine = 0;
  21. m_tokenStartCharIndex = 0;
  22. m_treeAdaptor = NULL;
  23. }
  24. template<class ImplTraits, class StreamType>
  25. ANTLR_INLINE typename RecognizerSharedState<ImplTraits, StreamType>::FollowingType& RecognizerSharedState<ImplTraits, StreamType>::get_following()
  26. {
  27. return m_following;
  28. }
  29. template<class ImplTraits, class StreamType>
  30. ANTLR_INLINE ANTLR_UINT32 RecognizerSharedState<ImplTraits, StreamType>::get_sizeHint() const
  31. {
  32. return m_sizeHint;
  33. }
  34. template<class ImplTraits, class StreamType>
  35. ANTLR_INLINE bool RecognizerSharedState<ImplTraits, StreamType>::get_error() const
  36. {
  37. return m_error;
  38. }
  39. template<class ImplTraits, class StreamType>
  40. ANTLR_INLINE typename RecognizerSharedState<ImplTraits, StreamType>::ExceptionBaseType*
  41. RecognizerSharedState<ImplTraits, StreamType>::get_exception() const
  42. {
  43. return m_exception;
  44. }
  45. template<class ImplTraits, class StreamType>
  46. ANTLR_INLINE bool RecognizerSharedState<ImplTraits, StreamType>::get_errorRecovery() const
  47. {
  48. return m_errorRecovery;
  49. }
  50. template<class ImplTraits, class StreamType>
  51. ANTLR_INLINE bool RecognizerSharedState<ImplTraits, StreamType>::get_failed() const
  52. {
  53. return m_failed;
  54. }
  55. template<class ImplTraits, class StreamType>
  56. ANTLR_INLINE bool RecognizerSharedState<ImplTraits, StreamType>::get_token_present() const
  57. {
  58. return m_token_present;
  59. }
  60. template<class ImplTraits, class StreamType>
  61. ANTLR_INLINE ANTLR_MARKER RecognizerSharedState<ImplTraits, StreamType>::get_lastErrorIndex() const
  62. {
  63. return m_lastErrorIndex;
  64. }
  65. template<class ImplTraits, class StreamType>
  66. ANTLR_INLINE ANTLR_UINT32 RecognizerSharedState<ImplTraits, StreamType>::get_errorCount() const
  67. {
  68. return m_errorCount;
  69. }
  70. template<class ImplTraits, class StreamType>
  71. ANTLR_INLINE ANTLR_INT32 RecognizerSharedState<ImplTraits, StreamType>::get_backtracking() const
  72. {
  73. return m_backtracking;
  74. }
  75. template<class ImplTraits, class StreamType>
  76. ANTLR_INLINE typename RecognizerSharedState<ImplTraits, StreamType>::RuleMemoType* RecognizerSharedState<ImplTraits, StreamType>::get_ruleMemo() const
  77. {
  78. return m_ruleMemo;
  79. }
  80. template<class ImplTraits, class StreamType>
  81. ANTLR_INLINE ANTLR_UINT8** RecognizerSharedState<ImplTraits, StreamType>::get_tokenNames() const
  82. {
  83. return m_tokenNames;
  84. }
  85. template<class ImplTraits, class StreamType>
  86. ANTLR_INLINE ANTLR_UINT8* RecognizerSharedState<ImplTraits, StreamType>::get_tokenName( ANTLR_UINT32 i ) const
  87. {
  88. return m_tokenNames[i];
  89. }
  90. template<class ImplTraits, class StreamType>
  91. ANTLR_INLINE typename RecognizerSharedState<ImplTraits, StreamType>::CommonTokenType* RecognizerSharedState<ImplTraits, StreamType>::get_token()
  92. {
  93. return &m_token;
  94. }
  95. template<class ImplTraits, class StreamType>
  96. ANTLR_INLINE typename RecognizerSharedState<ImplTraits, StreamType>::TokenSourceType* RecognizerSharedState<ImplTraits, StreamType>::get_tokSource() const
  97. {
  98. return m_tokSource;
  99. }
  100. template<class ImplTraits, class StreamType>
  101. ANTLR_INLINE ANTLR_UINT32& RecognizerSharedState<ImplTraits, StreamType>::get_channel()
  102. {
  103. return m_channel;
  104. }
  105. template<class ImplTraits, class StreamType>
  106. ANTLR_INLINE ANTLR_UINT32 RecognizerSharedState<ImplTraits, StreamType>::get_type() const
  107. {
  108. return m_type;
  109. }
  110. template<class ImplTraits, class StreamType>
  111. ANTLR_INLINE ANTLR_INT32 RecognizerSharedState<ImplTraits, StreamType>::get_tokenStartLine() const
  112. {
  113. return m_tokenStartLine;
  114. }
  115. template<class ImplTraits, class StreamType>
  116. ANTLR_INLINE ANTLR_INT32 RecognizerSharedState<ImplTraits, StreamType>::get_tokenStartCharPositionInLine() const
  117. {
  118. return m_tokenStartCharPositionInLine;
  119. }
  120. template<class ImplTraits, class StreamType>
  121. ANTLR_INLINE ANTLR_MARKER RecognizerSharedState<ImplTraits, StreamType>::get_tokenStartCharIndex() const
  122. {
  123. return m_tokenStartCharIndex;
  124. }
  125. template<class ImplTraits, class StreamType>
  126. ANTLR_INLINE typename RecognizerSharedState<ImplTraits, StreamType>::StringType& RecognizerSharedState<ImplTraits, StreamType>::get_text()
  127. {
  128. return m_text;
  129. }
  130. template<class ImplTraits, class StreamType>
  131. ANTLR_INLINE typename RecognizerSharedState<ImplTraits, StreamType>::StreamsType& RecognizerSharedState<ImplTraits, StreamType>::get_streams()
  132. {
  133. return m_streams;
  134. }
  135. template<class ImplTraits, class StreamType>
  136. ANTLR_INLINE typename RecognizerSharedState<ImplTraits, StreamType>::TreeAdaptorType* RecognizerSharedState<ImplTraits, StreamType>::get_treeAdaptor() const
  137. {
  138. return m_treeAdaptor;
  139. }
  140. template<class ImplTraits, class StreamType>
  141. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_exception( ExceptionBaseType* exception )
  142. {
  143. m_exception = exception;
  144. }
  145. template<class ImplTraits, class StreamType>
  146. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_following( const FollowingType& following )
  147. {
  148. m_following = following;
  149. }
  150. template<class ImplTraits, class StreamType>
  151. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_sizeHint( ANTLR_UINT32 sizeHint )
  152. {
  153. m_sizeHint = sizeHint;
  154. }
  155. template<class ImplTraits, class StreamType>
  156. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_error( bool error )
  157. {
  158. m_error = error;
  159. }
  160. template<class ImplTraits, class StreamType>
  161. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_errorRecovery( bool errorRecovery )
  162. {
  163. m_errorRecovery = errorRecovery;
  164. }
  165. template<class ImplTraits, class StreamType>
  166. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_failed( bool failed )
  167. {
  168. m_failed = failed;
  169. }
  170. template<class ImplTraits, class StreamType>
  171. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_token_present(bool token_present)
  172. {
  173. m_token_present = token_present;
  174. }
  175. template<class ImplTraits, class StreamType>
  176. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_lastErrorIndex( ANTLR_MARKER lastErrorIndex )
  177. {
  178. m_lastErrorIndex = lastErrorIndex;
  179. }
  180. template<class ImplTraits, class StreamType>
  181. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_errorCount( ANTLR_UINT32 errorCount )
  182. {
  183. m_errorCount = errorCount;
  184. }
  185. template<class ImplTraits, class StreamType>
  186. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_backtracking( ANTLR_INT32 backtracking )
  187. {
  188. m_backtracking = backtracking;
  189. }
  190. template<class ImplTraits, class StreamType>
  191. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_ruleMemo( RuleMemoType* ruleMemo )
  192. {
  193. m_ruleMemo = ruleMemo;
  194. }
  195. template<class ImplTraits, class StreamType>
  196. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_tokenNames( ANTLR_UINT8** tokenNames )
  197. {
  198. m_tokenNames = tokenNames;
  199. }
  200. template<class ImplTraits, class StreamType>
  201. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_tokSource( TokenSourceType* tokSource )
  202. {
  203. m_tokSource = tokSource;
  204. }
  205. template<class ImplTraits, class StreamType>
  206. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_channel( ANTLR_UINT32 channel )
  207. {
  208. m_channel = channel;
  209. }
  210. template<class ImplTraits, class StreamType>
  211. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_token(const CommonTokenType* tok)
  212. {
  213. this->set_token_present( tok != NULL );
  214. if( tok != NULL )
  215. m_token = *tok;
  216. }
  217. template<class ImplTraits, class StreamType>
  218. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_type( ANTLR_UINT32 type )
  219. {
  220. m_type = type;
  221. }
  222. template<class ImplTraits, class StreamType>
  223. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_tokenStartLine( ANTLR_INT32 tokenStartLine )
  224. {
  225. m_tokenStartLine = tokenStartLine;
  226. }
  227. template<class ImplTraits, class StreamType>
  228. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_tokenStartCharPositionInLine( ANTLR_INT32 tokenStartCharPositionInLine )
  229. {
  230. m_tokenStartCharPositionInLine = tokenStartCharPositionInLine;
  231. }
  232. template<class ImplTraits, class StreamType>
  233. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_tokenStartCharIndex( ANTLR_MARKER tokenStartCharIndex )
  234. {
  235. m_tokenStartCharIndex = tokenStartCharIndex;
  236. }
  237. template<class ImplTraits, class StreamType>
  238. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_text( const StringType& text )
  239. {
  240. m_text = text;
  241. }
  242. template<class ImplTraits, class StreamType>
  243. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_streams( const InputStreamsType& streams )
  244. {
  245. m_streams = streams;
  246. }
  247. template<class ImplTraits, class StreamType>
  248. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::set_treeAdaptor( TreeAdaptorType* adaptor )
  249. {
  250. m_treeAdaptor = adaptor;
  251. }
  252. template<class ImplTraits, class StreamType>
  253. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::inc_errorCount()
  254. {
  255. ++m_errorCount;
  256. }
  257. template<class ImplTraits, class StreamType>
  258. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::inc_backtracking()
  259. {
  260. ++m_backtracking;
  261. }
  262. template<class ImplTraits, class StreamType>
  263. ANTLR_INLINE void RecognizerSharedState<ImplTraits, StreamType>::dec_backtracking()
  264. {
  265. --m_backtracking;
  266. }
  267. }