expressir 1.2.4 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (312) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +0 -6
  3. data/.github/workflows/rake.yml +200 -21
  4. data/.gitignore +7 -2
  5. data/.gitmodules +3 -0
  6. data/.rubocop.yml +13 -4
  7. data/README.adoc +8 -0
  8. data/Rakefile +4 -1
  9. data/bin/console +0 -1
  10. data/bin/rspec +3 -3
  11. data/exe/expressir +4 -2
  12. data/exe/format +1 -1
  13. data/exe/format-test +25 -25
  14. data/exe/generate-parser +16 -13
  15. data/expressir.gemspec +12 -10
  16. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
  17. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
  18. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
  19. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
  20. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
  21. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
  22. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
  23. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
  24. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
  25. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
  26. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
  27. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
  28. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
  29. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
  30. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
  31. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
  32. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
  33. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
  34. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
  35. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
  36. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
  37. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
  38. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
  39. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
  40. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
  41. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
  42. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
  43. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
  44. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
  45. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
  46. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
  47. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
  48. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
  49. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
  50. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
  51. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
  52. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
  53. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
  54. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
  55. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
  56. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
  57. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
  58. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
  59. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
  60. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
  61. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
  62. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
  63. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
  64. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
  65. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
  66. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
  67. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
  68. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
  69. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
  70. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
  71. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
  72. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
  73. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
  74. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
  75. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
  76. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
  77. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
  78. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
  79. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
  80. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
  81. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
  82. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
  83. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
  84. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
  85. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
  86. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
  87. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
  88. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
  89. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
  90. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
  91. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
  92. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
  93. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
  94. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
  95. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
  96. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
  97. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
  98. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
  99. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
  100. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
  101. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
  102. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
  103. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
  104. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
  105. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
  106. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
  107. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
  108. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
  109. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
  110. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
  111. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
  112. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
  113. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
  114. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
  115. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
  116. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
  117. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
  118. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
  119. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
  120. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
  121. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
  122. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
  123. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
  124. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
  125. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
  126. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
  127. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
  128. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
  129. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
  130. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
  131. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
  132. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
  133. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
  134. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
  135. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
  136. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
  137. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
  138. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
  139. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
  140. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
  141. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
  142. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
  143. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
  144. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
  145. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
  146. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
  147. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
  148. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
  149. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
  150. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
  151. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
  152. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
  153. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
  154. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
  155. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
  156. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
  157. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
  158. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
  159. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
  160. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
  161. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
  162. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
  163. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
  164. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
  165. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
  166. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
  167. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
  168. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
  169. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
  170. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
  171. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
  172. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
  173. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
  174. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
  175. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
  176. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
  177. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
  178. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
  179. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
  180. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
  181. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
  182. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
  183. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
  184. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
  185. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
  186. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
  187. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
  188. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
  189. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
  190. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
  221. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
  222. data/ext/express-parser/antlrgen/Express.interp +1 -1
  223. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
  224. data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
  225. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
  226. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
  227. data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
  228. data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
  229. data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
  230. data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
  231. data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
  232. data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
  233. data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
  234. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
  235. data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
  236. data/ext/express-parser/express_parser.cpp +294 -86
  237. data/ext/express-parser/extconf.rb +13 -12
  238. data/lib/expressir/config.rb +1 -1
  239. data/lib/expressir/express/parser.rb +3 -4
  240. data/lib/expressir/express/visitor.rb +7 -5
  241. data/lib/expressir/model.rb +78 -78
  242. data/lib/expressir/version.rb +1 -1
  243. data/rakelib/antlr4-native.rake +161 -0
  244. data/rakelib/cross-ruby.rake +213 -162
  245. data/spec/acceptance/version_spec.rb +17 -2
  246. data/spec/expressir/express/cache_spec.rb +23 -5
  247. data/spec/expressir/express/formatter_spec.rb +54 -8
  248. data/spec/expressir/express/parser_spec.rb +47 -11
  249. data/spec/expressir/model/model_element_spec.rb +198 -146
  250. data/spec/spec_helper.rb +7 -0
  251. metadata +81 -93
  252. data/demo.rb +0 -18
  253. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
  254. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
  255. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
  256. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
  257. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
  258. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
  259. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
  260. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
  261. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
  262. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
  263. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
  264. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
  265. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
  266. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
  267. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
  268. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
  274. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
  275. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
  276. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
  277. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
  278. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
  279. data/original/examples/employment/eclipse/.project +0 -17
  280. data/original/examples/employment/eclipse/Export/Employment.png +0 -0
  281. data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
  282. data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
  283. data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
  284. data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
  285. data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
  286. data/original/examples/employment/eclipse/readme.txt +0 -7
  287. data/original/examples/employment/employment_schema.exp +0 -33
  288. data/original/examples/employment/employment_schema.rb +0 -232
  289. data/original/examples/employment/employment_schema.xml +0 -93
  290. data/original/examples/employment/employment_schema___module.rb +0 -46
  291. data/original/examples/employment/employment_schema___p28attr.rb +0 -126
  292. data/original/examples/employment/employment_schema___p28inst.rb +0 -26
  293. data/original/examples/employment/example_employment_data.xml +0 -1
  294. data/original/examples/employment/example_employment_data_copy.xml +0 -1
  295. data/original/examples/employment/example_employment_reader.rb +0 -30
  296. data/original/examples/employment/example_employment_writer.rb +0 -51
  297. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
  298. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
  299. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
  300. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
  301. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
  302. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
  303. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
  304. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
  305. data/original/exp2ruby.rb +0 -525
  306. data/original/expsm.rb +0 -34
  307. data/original/mapping_owl.rb +0 -1018
  308. data/original/mapping_sysml.rb +0 -2281
  309. data/original/mapping_uml2.rb +0 -599
  310. data/original/mapping_uml2_eclipse.rb +0 -433
  311. data/original/reeper.rb +0 -134
  312. data/spec/expressr_spec.rb +0 -5
@@ -7,6 +7,7 @@
7
7
  #include "atn/LexerIndexedCustomAction.h"
8
8
  #include "support/CPPUtils.h"
9
9
  #include "support/Arrays.h"
10
+ #include "support/Casts.h"
10
11
 
11
12
  #include "atn/LexerActionExecutor.h"
12
13
 
@@ -15,48 +16,54 @@ using namespace antlr4::atn;
15
16
  using namespace antlr4::misc;
16
17
  using namespace antlrcpp;
17
18
 
18
- LexerActionExecutor::LexerActionExecutor(const std::vector<Ref<LexerAction>> &lexerActions)
19
- : _lexerActions(lexerActions), _hashCode(generateHashCode()) {
20
- }
19
+ namespace {
20
+
21
+ bool cachedHashCodeEqual(size_t lhs, size_t rhs) {
22
+ return lhs == rhs || lhs == 0 || rhs == 0;
23
+ }
24
+
25
+ bool lexerActionEqual(const Ref<const LexerAction> &lhs, const Ref<const LexerAction> &rhs) {
26
+ return *lhs == *rhs;
27
+ }
21
28
 
22
- LexerActionExecutor::~LexerActionExecutor() {
23
29
  }
24
30
 
25
- Ref<LexerActionExecutor> LexerActionExecutor::append(Ref<LexerActionExecutor> const& lexerActionExecutor,
26
- Ref<LexerAction> const& lexerAction) {
31
+ LexerActionExecutor::LexerActionExecutor(std::vector<Ref<const LexerAction>> lexerActions)
32
+ : _lexerActions(std::move(lexerActions)), _hashCode(0) {}
33
+
34
+ Ref<const LexerActionExecutor> LexerActionExecutor::append(const Ref<const LexerActionExecutor> &lexerActionExecutor,
35
+ Ref<const LexerAction> lexerAction) {
27
36
  if (lexerActionExecutor == nullptr) {
28
- return std::make_shared<LexerActionExecutor>(std::vector<Ref<LexerAction>> { lexerAction });
37
+ return std::make_shared<LexerActionExecutor>(std::vector<Ref<const LexerAction>>{ std::move(lexerAction) });
29
38
  }
30
-
31
- std::vector<Ref<LexerAction>> lexerActions = lexerActionExecutor->_lexerActions; // Make a copy.
32
- lexerActions.push_back(lexerAction);
33
- return std::make_shared<LexerActionExecutor>(lexerActions);
39
+ std::vector<Ref<const LexerAction>> lexerActions;
40
+ lexerActions.reserve(lexerActionExecutor->_lexerActions.size() + 1);
41
+ lexerActions.insert(lexerActions.begin(), lexerActionExecutor->_lexerActions.begin(), lexerActionExecutor->_lexerActions.end());
42
+ lexerActions.push_back(std::move(lexerAction));
43
+ return std::make_shared<LexerActionExecutor>(std::move(lexerActions));
34
44
  }
35
45
 
36
- Ref<LexerActionExecutor> LexerActionExecutor::fixOffsetBeforeMatch(int offset) {
37
- std::vector<Ref<LexerAction>> updatedLexerActions;
46
+ Ref<const LexerActionExecutor> LexerActionExecutor::fixOffsetBeforeMatch(int offset) const {
47
+ std::vector<Ref<const LexerAction>> updatedLexerActions;
38
48
  for (size_t i = 0; i < _lexerActions.size(); i++) {
39
- if (_lexerActions[i]->isPositionDependent() && !is<LexerIndexedCustomAction>(_lexerActions[i])) {
49
+ if (_lexerActions[i]->isPositionDependent() && !LexerIndexedCustomAction::is(*_lexerActions[i])) {
40
50
  if (updatedLexerActions.empty()) {
41
51
  updatedLexerActions = _lexerActions; // Make a copy.
42
52
  }
43
-
44
53
  updatedLexerActions[i] = std::make_shared<LexerIndexedCustomAction>(offset, _lexerActions[i]);
45
54
  }
46
55
  }
47
-
48
56
  if (updatedLexerActions.empty()) {
49
57
  return shared_from_this();
50
58
  }
51
-
52
- return std::make_shared<LexerActionExecutor>(updatedLexerActions);
59
+ return std::make_shared<LexerActionExecutor>(std::move(updatedLexerActions));
53
60
  }
54
61
 
55
- std::vector<Ref<LexerAction>> LexerActionExecutor::getLexerActions() const {
62
+ const std::vector<Ref<const LexerAction>>& LexerActionExecutor::getLexerActions() const {
56
63
  return _lexerActions;
57
64
  }
58
65
 
59
- void LexerActionExecutor::execute(Lexer *lexer, CharStream *input, size_t startIndex) {
66
+ void LexerActionExecutor::execute(Lexer *lexer, CharStream *input, size_t startIndex) const {
60
67
  bool requiresSeek = false;
61
68
  size_t stopIndex = input->index();
62
69
 
@@ -65,43 +72,40 @@ void LexerActionExecutor::execute(Lexer *lexer, CharStream *input, size_t startI
65
72
  input->seek(stopIndex);
66
73
  }
67
74
  });
68
- for (auto lexerAction : _lexerActions) {
69
- if (is<LexerIndexedCustomAction>(lexerAction)) {
70
- int offset = (std::static_pointer_cast<LexerIndexedCustomAction>(lexerAction))->getOffset();
75
+ for (const auto &lexerAction : _lexerActions) {
76
+ if (LexerIndexedCustomAction::is(*lexerAction)) {
77
+ int offset = downCast<const LexerIndexedCustomAction&>(*lexerAction).getOffset();
71
78
  input->seek(startIndex + offset);
72
- lexerAction = std::static_pointer_cast<LexerIndexedCustomAction>(lexerAction)->getAction();
73
79
  requiresSeek = (startIndex + offset) != stopIndex;
74
80
  } else if (lexerAction->isPositionDependent()) {
75
81
  input->seek(stopIndex);
76
82
  requiresSeek = false;
77
83
  }
78
-
79
84
  lexerAction->execute(lexer);
80
85
  }
81
86
  }
82
87
 
83
88
  size_t LexerActionExecutor::hashCode() const {
84
- return _hashCode;
85
- }
86
-
87
- bool LexerActionExecutor::operator == (const LexerActionExecutor &obj) const {
88
- if (&obj == this) {
89
- return true;
89
+ auto hash = _hashCode.load(std::memory_order_relaxed);
90
+ if (hash == 0) {
91
+ hash = MurmurHash::initialize();
92
+ for (const auto &lexerAction : _lexerActions) {
93
+ hash = MurmurHash::update(hash, lexerAction);
94
+ }
95
+ hash = MurmurHash::finish(hash, _lexerActions.size());
96
+ if (hash == 0) {
97
+ hash = std::numeric_limits<size_t>::max();
98
+ }
99
+ _hashCode.store(hash, std::memory_order_relaxed);
90
100
  }
91
-
92
- return _hashCode == obj._hashCode && Arrays::equals(_lexerActions, obj._lexerActions);
93
- }
94
-
95
- bool LexerActionExecutor::operator != (const LexerActionExecutor &obj) const {
96
- return !operator==(obj);
101
+ return hash;
97
102
  }
98
103
 
99
- size_t LexerActionExecutor::generateHashCode() const {
100
- size_t hash = MurmurHash::initialize();
101
- for (auto lexerAction : _lexerActions) {
102
- hash = MurmurHash::update(hash, lexerAction);
104
+ bool LexerActionExecutor::equals(const LexerActionExecutor &other) const {
105
+ if (this == std::addressof(other)) {
106
+ return true;
103
107
  }
104
- hash = MurmurHash::finish(hash, _lexerActions.size());
105
-
106
- return hash;
108
+ return cachedHashCodeEqual(_hashCode.load(std::memory_order_relaxed), other._hashCode.load(std::memory_order_relaxed)) &&
109
+ _lexerActions.size() == other._lexerActions.size() &&
110
+ std::equal(_lexerActions.begin(), _lexerActions.end(), other._lexerActions.begin(), lexerActionEqual);
107
111
  }
@@ -17,13 +17,12 @@ namespace atn {
17
17
  /// <para>The executor tracks position information for position-dependent lexer actions
18
18
  /// efficiently, ensuring that actions appearing only at the end of the rule do
19
19
  /// not cause bloating of the <seealso cref="DFA"/> created for the lexer.</para>
20
- class ANTLR4CPP_PUBLIC LexerActionExecutor : public std::enable_shared_from_this<LexerActionExecutor> {
20
+ class ANTLR4CPP_PUBLIC LexerActionExecutor final : public std::enable_shared_from_this<LexerActionExecutor> {
21
21
  public:
22
22
  /// <summary>
23
23
  /// Constructs an executor for a sequence of <seealso cref="LexerAction"/> actions. </summary>
24
24
  /// <param name="lexerActions"> The lexer actions to execute. </param>
25
- LexerActionExecutor(const std::vector<Ref<LexerAction>> &lexerActions);
26
- virtual ~LexerActionExecutor();
25
+ explicit LexerActionExecutor(std::vector<Ref<const LexerAction>> lexerActions);
27
26
 
28
27
  /// <summary>
29
28
  /// Creates a <seealso cref="LexerActionExecutor"/> which executes the actions for
@@ -39,8 +38,8 @@ namespace atn {
39
38
  /// </param>
40
39
  /// <returns> A <seealso cref="LexerActionExecutor"/> for executing the combine actions
41
40
  /// of {@code lexerActionExecutor} and {@code lexerAction}. </returns>
42
- static Ref<LexerActionExecutor> append(Ref<LexerActionExecutor> const& lexerActionExecutor,
43
- Ref<LexerAction> const& lexerAction);
41
+ static Ref<const LexerActionExecutor> append(const Ref<const LexerActionExecutor> &lexerActionExecutor,
42
+ Ref<const LexerAction> lexerAction);
44
43
 
45
44
  /// <summary>
46
45
  /// Creates a <seealso cref="LexerActionExecutor"/> which encodes the current offset
@@ -70,12 +69,12 @@ namespace atn {
70
69
  /// </param>
71
70
  /// <returns> A <seealso cref="LexerActionExecutor"/> which stores input stream offsets
72
71
  /// for all position-dependent lexer actions. </returns>
73
- virtual Ref<LexerActionExecutor> fixOffsetBeforeMatch(int offset);
72
+ Ref<const LexerActionExecutor> fixOffsetBeforeMatch(int offset) const;
74
73
 
75
74
  /// <summary>
76
75
  /// Gets the lexer actions to be executed by this executor. </summary>
77
76
  /// <returns> The lexer actions to be executed by this executor. </returns>
78
- virtual std::vector<Ref<LexerAction>> getLexerActions() const;
77
+ const std::vector<Ref<const LexerAction>>& getLexerActions() const;
79
78
 
80
79
  /// <summary>
81
80
  /// Execute the actions encapsulated by this executor within the context of a
@@ -95,21 +94,35 @@ namespace atn {
95
94
  /// <param name="startIndex"> The token start index. This value may be passed to
96
95
  /// <seealso cref="IntStream#seek"/> to set the {@code input} position to the beginning
97
96
  /// of the token. </param>
98
- virtual void execute(Lexer *lexer, CharStream *input, size_t startIndex);
97
+ void execute(Lexer *lexer, CharStream *input, size_t startIndex) const;
99
98
 
100
- virtual size_t hashCode() const;
101
- virtual bool operator == (const LexerActionExecutor &obj) const;
102
- virtual bool operator != (const LexerActionExecutor &obj) const;
99
+ size_t hashCode() const;
100
+
101
+ bool equals(const LexerActionExecutor &other) const;
103
102
 
104
103
  private:
105
- const std::vector<Ref<LexerAction>> _lexerActions;
104
+ const std::vector<Ref<const LexerAction>> _lexerActions;
105
+ mutable std::atomic<size_t> _hashCode;
106
+ };
107
+
108
+ inline bool operator==(const LexerActionExecutor &lhs, const LexerActionExecutor &rhs) {
109
+ return lhs.equals(rhs);
110
+ }
111
+
112
+ inline bool operator!=(const LexerActionExecutor &lhs, const LexerActionExecutor &rhs) {
113
+ return !operator==(lhs, rhs);
114
+ }
115
+
116
+ } // namespace atn
117
+ } // namespace antlr4
106
118
 
107
- /// Caches the result of <seealso cref="#hashCode"/> since the hash code is an element
108
- /// of the performance-critical <seealso cref="LexerATNConfig#hashCode"/> operation.
109
- const size_t _hashCode;
119
+ namespace std {
110
120
 
111
- size_t generateHashCode() const;
121
+ template <>
122
+ struct hash<::antlr4::atn::LexerActionExecutor> {
123
+ size_t operator()(const ::antlr4::atn::LexerActionExecutor &lexerActionExecutor) const {
124
+ return lexerActionExecutor.hashCode();
125
+ }
112
126
  };
113
127
 
114
- } // namespace atn
115
- } // namespace antlr4
128
+ } // namespace std
@@ -20,7 +20,7 @@ namespace atn {
20
20
  /// <summary>
21
21
  /// The type of a <seealso cref="LexerChannelAction"/> action.
22
22
  /// </summary>
23
- CHANNEL,
23
+ CHANNEL = 0,
24
24
  /// <summary>
25
25
  /// The type of a <seealso cref="LexerCustomAction"/> action.
26
26
  /// </summary>
@@ -49,6 +49,8 @@ namespace atn {
49
49
  /// The type of a <seealso cref="LexerTypeAction"/> action.
50
50
  /// </summary>
51
51
  TYPE,
52
+
53
+ INDEXED_CUSTOM,
52
54
  };
53
55
 
54
56
  } // namespace atn
@@ -5,51 +5,39 @@
5
5
 
6
6
  #include "misc/MurmurHash.h"
7
7
  #include "Lexer.h"
8
+ #include "support/Casts.h"
8
9
 
9
10
  #include "atn/LexerChannelAction.h"
10
11
 
11
12
  using namespace antlr4::atn;
12
13
  using namespace antlr4::misc;
14
+ using namespace antlrcpp;
13
15
 
14
- LexerChannelAction::LexerChannelAction(int channel) : _channel(channel) {
15
- }
16
-
17
- int LexerChannelAction::getChannel() const {
18
- return _channel;
19
- }
20
-
21
- LexerActionType LexerChannelAction::getActionType() const {
22
- return LexerActionType::CHANNEL;
23
- }
16
+ LexerChannelAction::LexerChannelAction(int channel)
17
+ : LexerAction(LexerActionType::CHANNEL, false), _channel(channel) {}
24
18
 
25
- bool LexerChannelAction::isPositionDependent() const {
26
- return false;
19
+ void LexerChannelAction::execute(Lexer *lexer) const {
20
+ lexer->setChannel(getChannel());
27
21
  }
28
22
 
29
- void LexerChannelAction::execute(Lexer *lexer) {
30
- lexer->setChannel(_channel);
31
- }
32
-
33
- size_t LexerChannelAction::hashCode() const {
23
+ size_t LexerChannelAction::hashCodeImpl() const {
34
24
  size_t hash = MurmurHash::initialize();
35
25
  hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
36
- hash = MurmurHash::update(hash, _channel);
26
+ hash = MurmurHash::update(hash, getChannel());
37
27
  return MurmurHash::finish(hash, 2);
38
28
  }
39
29
 
40
- bool LexerChannelAction::operator == (const LexerAction &obj) const {
41
- if (&obj == this) {
30
+ bool LexerChannelAction::equals(const LexerAction &other) const {
31
+ if (this == std::addressof(other)) {
42
32
  return true;
43
33
  }
44
-
45
- const LexerChannelAction *action = dynamic_cast<const LexerChannelAction *>(&obj);
46
- if (action == nullptr) {
34
+ if (getActionType() != other.getActionType()) {
47
35
  return false;
48
36
  }
49
-
50
- return _channel == action->_channel;
37
+ const auto &lexerAction = downCast<const LexerChannelAction&>(other);
38
+ return getChannel() == lexerAction.getChannel();
51
39
  }
52
40
 
53
41
  std::string LexerChannelAction::toString() const {
54
- return "channel(" + std::to_string(_channel) + ")";
42
+ return "channel(" + std::to_string(getChannel()) + ")";
55
43
  }
@@ -22,26 +22,20 @@ namespace atn {
22
22
  /// </summary>
23
23
  class ANTLR4CPP_PUBLIC LexerChannelAction final : public LexerAction {
24
24
  public:
25
+ static bool is(const LexerAction &lexerAction) { return lexerAction.getActionType() == LexerActionType::CHANNEL; }
26
+
27
+ static bool is(const LexerAction *lexerAction) { return lexerAction != nullptr && is(*lexerAction); }
28
+
25
29
  /// <summary>
26
30
  /// Constructs a new {@code channel} action with the specified channel value. </summary>
27
31
  /// <param name="channel"> The channel value to pass to <seealso cref="Lexer#setChannel"/>. </param>
28
- LexerChannelAction(int channel);
32
+ explicit LexerChannelAction(int channel);
29
33
 
30
34
  /// <summary>
31
35
  /// Gets the channel to use for the <seealso cref="Token"/> created by the lexer.
32
36
  /// </summary>
33
37
  /// <returns> The channel to use for the <seealso cref="Token"/> created by the lexer. </returns>
34
- int getChannel() const;
35
-
36
- /// <summary>
37
- /// {@inheritDoc} </summary>
38
- /// <returns> This method returns <seealso cref="LexerActionType#CHANNEL"/>. </returns>
39
- virtual LexerActionType getActionType() const override;
40
-
41
- /// <summary>
42
- /// {@inheritDoc} </summary>
43
- /// <returns> This method returns {@code false}. </returns>
44
- virtual bool isPositionDependent() const override;
38
+ int getChannel() const { return _channel; }
45
39
 
46
40
  /// <summary>
47
41
  /// {@inheritDoc}
@@ -49,11 +43,13 @@ namespace atn {
49
43
  /// <para>This action is implemented by calling <seealso cref="Lexer#setChannel"/> with the
50
44
  /// value provided by <seealso cref="#getChannel"/>.</para>
51
45
  /// </summary>
52
- virtual void execute(Lexer *lexer) override;
46
+ void execute(Lexer *lexer) const override;
47
+
48
+ bool equals(const LexerAction &other) const override;
49
+ std::string toString() const override;
53
50
 
54
- virtual size_t hashCode() const override;
55
- virtual bool operator == (const LexerAction &obj) const override;
56
- virtual std::string toString() const override;
51
+ protected:
52
+ size_t hashCodeImpl() const override;
57
53
 
58
54
  private:
59
55
  const int _channel;
@@ -4,59 +4,42 @@
4
4
  */
5
5
 
6
6
  #include "misc/MurmurHash.h"
7
- #include "support/CPPUtils.h"
8
7
  #include "Lexer.h"
8
+ #include "support/Casts.h"
9
9
 
10
10
  #include "atn/LexerCustomAction.h"
11
11
 
12
12
  using namespace antlr4;
13
13
  using namespace antlr4::atn;
14
14
  using namespace antlr4::misc;
15
+ using namespace antlrcpp;
15
16
 
16
- LexerCustomAction::LexerCustomAction(size_t ruleIndex, size_t actionIndex) : _ruleIndex(ruleIndex), _actionIndex(actionIndex) {
17
- }
18
-
19
- size_t LexerCustomAction::getRuleIndex() const {
20
- return _ruleIndex;
21
- }
17
+ LexerCustomAction::LexerCustomAction(size_t ruleIndex, size_t actionIndex)
18
+ : LexerAction(LexerActionType::CUSTOM, true), _ruleIndex(ruleIndex), _actionIndex(actionIndex) {}
22
19
 
23
- size_t LexerCustomAction::getActionIndex() const {
24
- return _actionIndex;
20
+ void LexerCustomAction::execute(Lexer *lexer) const {
21
+ lexer->action(nullptr, getRuleIndex(), getActionIndex());
25
22
  }
26
23
 
27
- LexerActionType LexerCustomAction::getActionType() const {
28
- return LexerActionType::CUSTOM;
29
- }
30
-
31
- bool LexerCustomAction::isPositionDependent() const {
32
- return true;
33
- }
34
-
35
- void LexerCustomAction::execute(Lexer *lexer) {
36
- lexer->action(nullptr, _ruleIndex, _actionIndex);
37
- }
38
-
39
- size_t LexerCustomAction::hashCode() const {
24
+ size_t LexerCustomAction::hashCodeImpl() const {
40
25
  size_t hash = MurmurHash::initialize();
41
26
  hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
42
- hash = MurmurHash::update(hash, _ruleIndex);
43
- hash = MurmurHash::update(hash, _actionIndex);
27
+ hash = MurmurHash::update(hash, getRuleIndex());
28
+ hash = MurmurHash::update(hash, getActionIndex());
44
29
  return MurmurHash::finish(hash, 3);
45
30
  }
46
31
 
47
- bool LexerCustomAction::operator == (const LexerAction &obj) const {
48
- if (&obj == this) {
32
+ bool LexerCustomAction::equals(const LexerAction &other) const {
33
+ if (this == std::addressof(other)) {
49
34
  return true;
50
35
  }
51
-
52
- const LexerCustomAction *action = dynamic_cast<const LexerCustomAction *>(&obj);
53
- if (action == nullptr) {
36
+ if (getActionType() != other.getActionType()) {
54
37
  return false;
55
38
  }
56
-
57
- return _ruleIndex == action->_ruleIndex && _actionIndex == action->_actionIndex;
39
+ const auto &lexerAction = downCast<const LexerCustomAction&>(other);
40
+ return getRuleIndex() == lexerAction.getRuleIndex() && getActionIndex() == lexerAction.getActionIndex();
58
41
  }
59
42
 
60
43
  std::string LexerCustomAction::toString() const {
61
- return antlrcpp::toString(this);
44
+ return "custom(" + std::to_string(getRuleIndex()) + ", " + std::to_string(getActionIndex()) + ")";
62
45
  }
@@ -26,6 +26,10 @@ namespace atn {
26
26
  /// </summary>
27
27
  class ANTLR4CPP_PUBLIC LexerCustomAction final : public LexerAction {
28
28
  public:
29
+ static bool is(const LexerAction &lexerAction) { return lexerAction.getActionType() == LexerActionType::CUSTOM; }
30
+
31
+ static bool is(const LexerAction *lexerAction) { return lexerAction != nullptr && is(*lexerAction); }
32
+
29
33
  /// <summary>
30
34
  /// Constructs a custom lexer action with the specified rule and action
31
35
  /// indexes.
@@ -40,31 +44,13 @@ namespace atn {
40
44
  /// Gets the rule index to use for calls to <seealso cref="Recognizer#action"/>.
41
45
  /// </summary>
42
46
  /// <returns> The rule index for the custom action. </returns>
43
- size_t getRuleIndex() const;
47
+ size_t getRuleIndex() const { return _ruleIndex; }
44
48
 
45
49
  /// <summary>
46
50
  /// Gets the action index to use for calls to <seealso cref="Recognizer#action"/>.
47
51
  /// </summary>
48
52
  /// <returns> The action index for the custom action. </returns>
49
- size_t getActionIndex() const;
50
-
51
- /// <summary>
52
- /// {@inheritDoc}
53
- /// </summary>
54
- /// <returns> This method returns <seealso cref="LexerActionType#CUSTOM"/>. </returns>
55
- virtual LexerActionType getActionType() const override;
56
-
57
- /// <summary>
58
- /// Gets whether the lexer action is position-dependent. Position-dependent
59
- /// actions may have different semantics depending on the <seealso cref="CharStream"/>
60
- /// index at the time the action is executed.
61
- ///
62
- /// <para>Custom actions are position-dependent since they may represent a
63
- /// user-defined embedded action which makes calls to methods like
64
- /// <seealso cref="Lexer#getText"/>.</para>
65
- /// </summary>
66
- /// <returns> This method returns {@code true}. </returns>
67
- virtual bool isPositionDependent() const override;
53
+ size_t getActionIndex() const { return _actionIndex; }
68
54
 
69
55
  /// <summary>
70
56
  /// {@inheritDoc}
@@ -72,11 +58,13 @@ namespace atn {
72
58
  /// <para>Custom actions are implemented by calling <seealso cref="Lexer#action"/> with the
73
59
  /// appropriate rule and action indexes.</para>
74
60
  /// </summary>
75
- virtual void execute(Lexer *lexer) override;
61
+ void execute(Lexer *lexer) const override;
62
+
63
+ bool equals(const LexerAction &other) const override;
64
+ std::string toString() const override;
76
65
 
77
- virtual size_t hashCode() const override;
78
- virtual bool operator == (const LexerAction &obj) const override;
79
- virtual std::string toString() const override;
66
+ protected:
67
+ size_t hashCodeImpl() const override;
80
68
 
81
69
  private:
82
70
  const size_t _ruleIndex;
@@ -6,58 +6,52 @@
6
6
  #include "misc/MurmurHash.h"
7
7
  #include "Lexer.h"
8
8
  #include "support/CPPUtils.h"
9
+ #include "support/Casts.h"
9
10
 
10
11
  #include "atn/LexerIndexedCustomAction.h"
11
12
 
12
13
  using namespace antlr4;
13
14
  using namespace antlr4::atn;
14
15
  using namespace antlr4::misc;
16
+ using namespace antlrcpp;
15
17
 
16
- LexerIndexedCustomAction::LexerIndexedCustomAction(int offset, Ref<LexerAction> const& action)
17
- : _offset(offset), _action(action) {
18
- }
19
-
20
- int LexerIndexedCustomAction::getOffset() const {
21
- return _offset;
22
- }
18
+ namespace {
23
19
 
24
- Ref<LexerAction> LexerIndexedCustomAction::getAction() const {
25
- return _action;
26
- }
20
+ bool cachedHashCodeEqual(size_t lhs, size_t rhs) {
21
+ return lhs == rhs || lhs == 0 || rhs == 0;
22
+ }
27
23
 
28
- LexerActionType LexerIndexedCustomAction::getActionType() const {
29
- return _action->getActionType();
30
24
  }
31
25
 
32
- bool LexerIndexedCustomAction::isPositionDependent() const {
33
- return true;
34
- }
26
+ LexerIndexedCustomAction::LexerIndexedCustomAction(int offset, Ref<const LexerAction> action)
27
+ : LexerAction(LexerActionType::INDEXED_CUSTOM, true), _action(std::move(action)), _offset(offset) {}
35
28
 
36
- void LexerIndexedCustomAction::execute(Lexer *lexer) {
29
+ void LexerIndexedCustomAction::execute(Lexer *lexer) const {
37
30
  // assume the input stream position was properly set by the calling code
38
- _action->execute(lexer);
31
+ getAction()->execute(lexer);
39
32
  }
40
33
 
41
- size_t LexerIndexedCustomAction::hashCode() const {
34
+ size_t LexerIndexedCustomAction::hashCodeImpl() const {
42
35
  size_t hash = MurmurHash::initialize();
43
- hash = MurmurHash::update(hash, _offset);
44
- hash = MurmurHash::update(hash, _action);
45
- return MurmurHash::finish(hash, 2);
36
+ hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
37
+ hash = MurmurHash::update(hash, getOffset());
38
+ hash = MurmurHash::update(hash, getAction());
39
+ return MurmurHash::finish(hash, 3);
46
40
  }
47
41
 
48
- bool LexerIndexedCustomAction::operator == (const LexerAction &obj) const {
49
- if (&obj == this) {
42
+ bool LexerIndexedCustomAction::equals(const LexerAction &other) const {
43
+ if (this == std::addressof(other)) {
50
44
  return true;
51
45
  }
52
-
53
- const LexerIndexedCustomAction *action = dynamic_cast<const LexerIndexedCustomAction *>(&obj);
54
- if (action == nullptr) {
46
+ if (getActionType() != other.getActionType()) {
55
47
  return false;
56
48
  }
57
-
58
- return _offset == action->_offset && *_action == *action->_action;
49
+ const auto &lexerAction = downCast<const LexerIndexedCustomAction&>(other);
50
+ return getOffset() == lexerAction.getOffset() &&
51
+ cachedHashCodeEqual(cachedHashCode(), lexerAction.cachedHashCode()) &&
52
+ *getAction() == *lexerAction.getAction();
59
53
  }
60
54
 
61
55
  std::string LexerIndexedCustomAction::toString() const {
62
- return antlrcpp::toString(this);
56
+ return "indexedCustom(" + std::to_string(getOffset()) + ", " + getAction()->toString() + ")";
63
57
  }
@@ -26,6 +26,10 @@ namespace atn {
26
26
  /// </summary>
27
27
  class ANTLR4CPP_PUBLIC LexerIndexedCustomAction final : public LexerAction {
28
28
  public:
29
+ static bool is(const LexerAction &lexerAction) { return lexerAction.getActionType() == LexerActionType::INDEXED_CUSTOM; }
30
+
31
+ static bool is(const LexerAction *lexerAction) { return lexerAction != nullptr && is(*lexerAction); }
32
+
29
33
  /// <summary>
30
34
  /// Constructs a new indexed custom action by associating a character offset
31
35
  /// with a <seealso cref="LexerAction"/>.
@@ -38,7 +42,7 @@ namespace atn {
38
42
  /// executed. </param>
39
43
  /// <param name="action"> The lexer action to execute at a particular offset in the
40
44
  /// input <seealso cref="CharStream"/>. </param>
41
- LexerIndexedCustomAction(int offset, Ref<LexerAction> const& action);
45
+ LexerIndexedCustomAction(int offset, Ref<const LexerAction> action);
42
46
 
43
47
  /// <summary>
44
48
  /// Gets the location in the input <seealso cref="CharStream"/> at which the lexer
@@ -47,34 +51,24 @@ namespace atn {
47
51
  /// </summary>
48
52
  /// <returns> The location in the input <seealso cref="CharStream"/> at which the lexer
49
53
  /// action should be executed. </returns>
50
- int getOffset() const;
54
+ int getOffset() const { return _offset; }
51
55
 
52
56
  /// <summary>
53
57
  /// Gets the lexer action to execute.
54
58
  /// </summary>
55
59
  /// <returns> A <seealso cref="LexerAction"/> object which executes the lexer action. </returns>
56
- Ref<LexerAction> getAction() const;
57
-
58
- /// <summary>
59
- /// {@inheritDoc}
60
- /// </summary>
61
- /// <returns> This method returns the result of calling <seealso cref="#getActionType"/>
62
- /// on the <seealso cref="LexerAction"/> returned by <seealso cref="#getAction"/>. </returns>
63
- virtual LexerActionType getActionType() const override;
60
+ const Ref<const LexerAction>& getAction() const { return _action; }
64
61
 
65
- /// <summary>
66
- /// {@inheritDoc} </summary>
67
- /// <returns> This method returns {@code true}. </returns>
68
- virtual bool isPositionDependent() const override;
62
+ void execute(Lexer *lexer) const override;
63
+ bool equals(const LexerAction &other) const override;
64
+ std::string toString() const override;
69
65
 
70
- virtual void execute(Lexer *lexer) override;
71
- virtual size_t hashCode() const override;
72
- virtual bool operator == (const LexerAction &obj) const override;
73
- virtual std::string toString() const override;
66
+ protected:
67
+ size_t hashCodeImpl() const override;
74
68
 
75
69
  private:
70
+ const Ref<const LexerAction> _action;
76
71
  const int _offset;
77
- const Ref<LexerAction> _action;
78
72
  };
79
73
 
80
74
  } // namespace atn