expressir 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +0 -6
  3. data/.github/workflows/rake.yml +200 -9
  4. data/.gitignore +7 -2
  5. data/.gitmodules +3 -0
  6. data/.rubocop.yml +13 -4
  7. data/Rakefile +4 -1
  8. data/bin/console +0 -1
  9. data/bin/rspec +3 -3
  10. data/exe/expressir +4 -2
  11. data/exe/format +1 -1
  12. data/exe/format-test +25 -25
  13. data/exe/generate-parser +16 -13
  14. data/expressir.gemspec +11 -9
  15. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
  16. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
  17. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
  18. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
  19. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
  20. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
  21. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
  22. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
  23. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
  24. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
  25. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
  26. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
  27. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
  28. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
  29. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
  30. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
  31. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
  32. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
  33. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
  34. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
  35. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
  36. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
  37. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
  38. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
  39. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
  40. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
  41. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
  42. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
  43. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
  44. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
  45. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
  46. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
  47. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
  48. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
  49. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
  50. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
  51. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
  52. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
  53. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
  54. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
  55. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
  56. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
  57. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
  58. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
  59. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
  60. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
  61. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
  62. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
  63. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
  64. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
  65. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
  66. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
  67. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
  68. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
  69. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
  70. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
  71. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
  72. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
  73. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
  74. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
  75. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
  76. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
  77. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
  78. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
  79. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
  80. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
  81. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
  82. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
  83. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
  84. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
  85. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
  86. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
  87. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
  88. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
  89. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
  90. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
  91. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
  92. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
  93. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
  94. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
  95. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
  96. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
  97. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
  98. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
  99. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
  100. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
  101. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
  102. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
  103. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
  104. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
  105. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
  106. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
  107. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
  108. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
  109. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
  110. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
  111. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
  112. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
  113. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
  114. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
  115. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
  116. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
  117. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
  118. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
  119. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
  120. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
  121. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
  122. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
  123. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
  124. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
  125. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
  126. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
  127. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
  128. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
  129. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
  130. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
  131. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
  132. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
  133. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
  134. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
  135. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
  136. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
  137. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
  138. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
  139. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
  140. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
  141. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
  142. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
  143. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
  144. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
  145. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
  146. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
  147. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
  148. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
  149. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
  150. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
  151. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
  152. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
  153. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
  154. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
  155. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
  156. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
  157. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
  158. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
  159. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
  160. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
  161. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
  162. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
  163. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
  164. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
  165. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
  166. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
  167. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
  168. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
  169. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
  170. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
  171. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
  172. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
  173. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
  174. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
  175. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
  176. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
  177. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
  178. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
  179. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
  180. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
  181. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
  182. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
  183. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
  184. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
  185. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
  186. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
  187. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
  188. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
  189. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
  190. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
  221. data/ext/express-parser/antlrgen/Express.interp +1 -1
  222. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
  223. data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
  224. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
  225. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
  226. data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
  227. data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
  228. data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
  229. data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
  230. data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
  231. data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
  232. data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
  233. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
  234. data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
  235. data/ext/express-parser/express_parser.cpp +207 -75
  236. data/ext/express-parser/extconf.rb +10 -9
  237. data/lib/expressir/config.rb +1 -1
  238. data/lib/expressir/express/parser.rb +2 -2
  239. data/lib/expressir/express/visitor.rb +7 -5
  240. data/lib/expressir/model.rb +78 -78
  241. data/lib/expressir/version.rb +1 -1
  242. data/rakelib/antlr4-native.rake +63 -0
  243. data/rakelib/cross-ruby.rake +213 -162
  244. data/spec/acceptance/version_spec.rb +7 -2
  245. data/spec/expressir/express/cache_spec.rb +8 -5
  246. data/spec/expressir/express/formatter_spec.rb +16 -8
  247. data/spec/expressir/express/parser_spec.rb +17 -11
  248. data/spec/expressir/model/model_element_spec.rb +154 -146
  249. metadata +79 -91
  250. data/demo.rb +0 -18
  251. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
  252. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
  253. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
  254. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
  255. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
  256. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
  257. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
  258. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
  259. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
  260. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
  261. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
  262. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
  263. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
  264. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
  265. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
  266. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
  267. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
  268. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
  274. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
  275. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
  276. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
  277. data/original/examples/employment/eclipse/.project +0 -17
  278. data/original/examples/employment/eclipse/Export/Employment.png +0 -0
  279. data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
  280. data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
  281. data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
  282. data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
  283. data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
  284. data/original/examples/employment/eclipse/readme.txt +0 -7
  285. data/original/examples/employment/employment_schema.exp +0 -33
  286. data/original/examples/employment/employment_schema.rb +0 -232
  287. data/original/examples/employment/employment_schema.xml +0 -93
  288. data/original/examples/employment/employment_schema___module.rb +0 -46
  289. data/original/examples/employment/employment_schema___p28attr.rb +0 -126
  290. data/original/examples/employment/employment_schema___p28inst.rb +0 -26
  291. data/original/examples/employment/example_employment_data.xml +0 -1
  292. data/original/examples/employment/example_employment_data_copy.xml +0 -1
  293. data/original/examples/employment/example_employment_reader.rb +0 -30
  294. data/original/examples/employment/example_employment_writer.rb +0 -51
  295. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
  296. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
  297. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
  298. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
  299. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
  300. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
  301. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
  302. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
  303. data/original/exp2ruby.rb +0 -525
  304. data/original/expsm.rb +0 -34
  305. data/original/mapping_owl.rb +0 -1018
  306. data/original/mapping_sysml.rb +0 -2281
  307. data/original/mapping_uml2.rb +0 -599
  308. data/original/mapping_uml2_eclipse.rb +0 -433
  309. data/original/reeper.rb +0 -134
  310. data/spec/expressr_spec.rb +0 -5
@@ -7,6 +7,7 @@
7
7
 
8
8
  #include "Recognizer.h"
9
9
  #include "support/CPPUtils.h"
10
+ #include "atn/SemanticContextType.h"
10
11
 
11
12
  namespace antlr4 {
12
13
  namespace atn {
@@ -19,36 +20,15 @@ namespace atn {
19
20
  /// SemanticContext within the scope of this outer class.
20
21
  class ANTLR4CPP_PUBLIC SemanticContext : public std::enable_shared_from_this<SemanticContext> {
21
22
  public:
22
- struct Hasher
23
- {
24
- size_t operator()(Ref<SemanticContext> const& k) const {
25
- return k->hashCode();
26
- }
27
- };
28
-
29
- struct Comparer {
30
- bool operator()(Ref<SemanticContext> const& lhs, Ref<SemanticContext> const& rhs) const {
31
- if (lhs == rhs)
32
- return true;
33
- return (lhs->hashCode() == rhs->hashCode()) && (*lhs == *rhs);
34
- }
35
- };
36
-
37
-
38
- using Set = std::unordered_set<Ref<SemanticContext>, Hasher, Comparer>;
39
-
40
23
  /**
41
24
  * The default {@link SemanticContext}, which is semantically equivalent to
42
25
  * a predicate of the form {@code {true}?}.
43
26
  */
44
- static const Ref<SemanticContext> NONE;
27
+ static const Ref<const SemanticContext> NONE;
45
28
 
46
- virtual ~SemanticContext();
29
+ virtual ~SemanticContext() = default;
47
30
 
48
- virtual size_t hashCode() const = 0;
49
- virtual std::string toString() const = 0;
50
- virtual bool operator == (const SemanticContext &other) const = 0;
51
- virtual bool operator != (const SemanticContext &other) const;
31
+ SemanticContextType getContextType() const { return _contextType; }
52
32
 
53
33
  /// <summary>
54
34
  /// For context independent predicates, we evaluate them without a local
@@ -63,7 +43,7 @@ namespace atn {
63
43
  /// prediction, so we passed in the outer context here in case of context
64
44
  /// dependent predicate evaluation.
65
45
  /// </summary>
66
- virtual bool eval(Recognizer *parser, RuleContext *parserCallStack) = 0;
46
+ virtual bool eval(Recognizer *parser, RuleContext *parserCallStack) const = 0;
67
47
 
68
48
  /**
69
49
  * Evaluate the precedence predicates for the context and reduce the result.
@@ -83,12 +63,18 @@ namespace atn {
83
63
  * semantic context after precedence predicates are evaluated.</li>
84
64
  * </ul>
85
65
  */
86
- virtual Ref<SemanticContext> evalPrecedence(Recognizer *parser, RuleContext *parserCallStack);
66
+ virtual Ref<const SemanticContext> evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) const;
67
+
68
+ virtual size_t hashCode() const = 0;
69
+
70
+ virtual bool equals(const SemanticContext &other) const = 0;
87
71
 
88
- static Ref<SemanticContext> And(Ref<SemanticContext> const& a, Ref<SemanticContext> const& b);
72
+ virtual std::string toString() const = 0;
73
+
74
+ static Ref<const SemanticContext> And(Ref<const SemanticContext> a, Ref<const SemanticContext> b);
89
75
 
90
76
  /// See also: ParserATNSimulator::getPredsForAmbigAlts.
91
- static Ref<SemanticContext> Or(Ref<SemanticContext> const& a, Ref<SemanticContext> const& b);
77
+ static Ref<const SemanticContext> Or(Ref<const SemanticContext> a, Ref<const SemanticContext> b);
92
78
 
93
79
  class Predicate;
94
80
  class PrecedencePredicate;
@@ -96,44 +82,54 @@ namespace atn {
96
82
  class AND;
97
83
  class OR;
98
84
 
85
+ protected:
86
+ explicit SemanticContext(SemanticContextType contextType) : _contextType(contextType) {}
87
+
99
88
  private:
100
- static std::vector<Ref<PrecedencePredicate>> filterPrecedencePredicates(const Set &collection);
89
+ const SemanticContextType _contextType;
101
90
  };
102
91
 
103
- class ANTLR4CPP_PUBLIC SemanticContext::Predicate : public SemanticContext {
92
+ inline bool operator==(const SemanticContext &lhs, const SemanticContext &rhs) {
93
+ return lhs.equals(rhs);
94
+ }
95
+
96
+ inline bool operator!=(const SemanticContext &lhs, const SemanticContext &rhs) {
97
+ return !operator==(lhs, rhs);
98
+ }
99
+
100
+ class ANTLR4CPP_PUBLIC SemanticContext::Predicate final : public SemanticContext {
104
101
  public:
102
+ static bool is(const SemanticContext &semanticContext) { return semanticContext.getContextType() == SemanticContextType::PREDICATE; }
103
+
104
+ static bool is(const SemanticContext *semanticContext) { return semanticContext != nullptr && is(*semanticContext); }
105
+
105
106
  const size_t ruleIndex;
106
107
  const size_t predIndex;
107
108
  const bool isCtxDependent; // e.g., $i ref in pred
108
109
 
109
- protected:
110
- Predicate();
111
-
112
- public:
113
110
  Predicate(size_t ruleIndex, size_t predIndex, bool isCtxDependent);
114
111
 
115
- virtual bool eval(Recognizer *parser, RuleContext *parserCallStack) override;
116
- virtual size_t hashCode() const override;
117
- virtual bool operator == (const SemanticContext &other) const override;
118
- virtual std::string toString() const override;
112
+ bool eval(Recognizer *parser, RuleContext *parserCallStack) const override;
113
+ size_t hashCode() const override;
114
+ bool equals(const SemanticContext &other) const override;
115
+ std::string toString() const override;
119
116
  };
120
117
 
121
- class ANTLR4CPP_PUBLIC SemanticContext::PrecedencePredicate : public SemanticContext {
118
+ class ANTLR4CPP_PUBLIC SemanticContext::PrecedencePredicate final : public SemanticContext {
122
119
  public:
120
+ static bool is(const SemanticContext &semanticContext) { return semanticContext.getContextType() == SemanticContextType::PRECEDENCE; }
121
+
122
+ static bool is(const SemanticContext *semanticContext) { return semanticContext != nullptr && is(*semanticContext); }
123
+
123
124
  const int precedence;
124
125
 
125
- protected:
126
- PrecedencePredicate();
126
+ explicit PrecedencePredicate(int precedence);
127
127
 
128
- public:
129
- PrecedencePredicate(int precedence);
130
-
131
- virtual bool eval(Recognizer *parser, RuleContext *parserCallStack) override;
132
- virtual Ref<SemanticContext> evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) override;
133
- virtual int compareTo(PrecedencePredicate *o);
134
- virtual size_t hashCode() const override;
135
- virtual bool operator == (const SemanticContext &other) const override;
136
- virtual std::string toString() const override;
128
+ bool eval(Recognizer *parser, RuleContext *parserCallStack) const override;
129
+ Ref<const SemanticContext> evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) const override;
130
+ size_t hashCode() const override;
131
+ bool equals(const SemanticContext &other) const override;
132
+ std::string toString() const override;
137
133
  };
138
134
 
139
135
  /**
@@ -144,7 +140,12 @@ namespace atn {
144
140
  */
145
141
  class ANTLR4CPP_PUBLIC SemanticContext::Operator : public SemanticContext {
146
142
  public:
147
- virtual ~Operator() override;
143
+ static bool is(const SemanticContext &semanticContext) {
144
+ const auto contextType = semanticContext.getContextType();
145
+ return contextType == SemanticContextType::AND || contextType == SemanticContextType::OR;
146
+ }
147
+
148
+ static bool is(const SemanticContext *semanticContext) { return semanticContext != nullptr && is(*semanticContext); }
148
149
 
149
150
  /**
150
151
  * Gets the operands for the semantic context operator.
@@ -155,68 +156,78 @@ namespace atn {
155
156
  * @since 4.3
156
157
  */
157
158
 
158
- virtual std::vector<Ref<SemanticContext>> getOperands() const = 0;
159
+ virtual const std::vector<Ref<const SemanticContext>>& getOperands() const = 0;
160
+
161
+ protected:
162
+ using SemanticContext::SemanticContext;
159
163
  };
160
164
 
161
165
  /**
162
166
  * A semantic context which is true whenever none of the contained contexts
163
167
  * is false.
164
168
  */
165
- class ANTLR4CPP_PUBLIC SemanticContext::AND : public SemanticContext::Operator {
169
+ class ANTLR4CPP_PUBLIC SemanticContext::AND final : public SemanticContext::Operator {
166
170
  public:
167
- std::vector<Ref<SemanticContext>> opnds;
171
+ static bool is(const SemanticContext &semanticContext) { return semanticContext.getContextType() == SemanticContextType::AND; }
172
+
173
+ static bool is(const SemanticContext *semanticContext) { return semanticContext != nullptr && is(*semanticContext); }
168
174
 
169
- AND(Ref<SemanticContext> const& a, Ref<SemanticContext> const& b) ;
175
+ AND(Ref<const SemanticContext> a, Ref<const SemanticContext> b) ;
170
176
 
171
- virtual std::vector<Ref<SemanticContext>> getOperands() const override;
172
- virtual bool operator == (const SemanticContext &other) const override;
173
- virtual size_t hashCode() const override;
177
+ const std::vector<Ref<const SemanticContext>>& getOperands() const override;
174
178
 
175
179
  /**
176
180
  * The evaluation of predicates by this context is short-circuiting, but
177
181
  * unordered.</p>
178
182
  */
179
- virtual bool eval(Recognizer *parser, RuleContext *parserCallStack) override;
180
- virtual Ref<SemanticContext> evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) override;
181
- virtual std::string toString() const override;
183
+ bool eval(Recognizer *parser, RuleContext *parserCallStack) const override;
184
+ Ref<const SemanticContext> evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) const override;
185
+ size_t hashCode() const override;
186
+ bool equals(const SemanticContext &other) const override;
187
+ std::string toString() const override;
188
+
189
+ private:
190
+ std::vector<Ref<const SemanticContext>> _opnds;
182
191
  };
183
192
 
184
193
  /**
185
194
  * A semantic context which is true whenever at least one of the contained
186
195
  * contexts is true.
187
196
  */
188
- class ANTLR4CPP_PUBLIC SemanticContext::OR : public SemanticContext::Operator {
197
+ class ANTLR4CPP_PUBLIC SemanticContext::OR final : public SemanticContext::Operator {
189
198
  public:
190
- std::vector<Ref<SemanticContext>> opnds;
199
+ static bool is(const SemanticContext &semanticContext) { return semanticContext.getContextType() == SemanticContextType::OR; }
200
+
201
+ static bool is(const SemanticContext *semanticContext) { return semanticContext != nullptr && is(*semanticContext); }
191
202
 
192
- OR(Ref<SemanticContext> const& a, Ref<SemanticContext> const& b);
203
+ OR(Ref<const SemanticContext> a, Ref<const SemanticContext> b);
193
204
 
194
- virtual std::vector<Ref<SemanticContext>> getOperands() const override;
195
- virtual bool operator == (const SemanticContext &other) const override;
196
- virtual size_t hashCode() const override;
205
+ const std::vector<Ref<const SemanticContext>>& getOperands() const override;
197
206
 
198
207
  /**
199
208
  * The evaluation of predicates by this context is short-circuiting, but
200
209
  * unordered.
201
210
  */
202
- virtual bool eval(Recognizer *parser, RuleContext *parserCallStack) override;
203
- virtual Ref<SemanticContext> evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) override;
204
- virtual std::string toString() const override;
205
- };
211
+ bool eval(Recognizer *parser, RuleContext *parserCallStack) const override;
212
+ Ref<const SemanticContext> evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) const override;
213
+ size_t hashCode() const override;
214
+ bool equals(const SemanticContext &other) const override;
215
+ std::string toString() const override;
206
216
 
207
- } // namespace atn
208
- } // namespace antlr4
217
+ private:
218
+ std::vector<Ref<const SemanticContext>> _opnds;
219
+ };
209
220
 
210
- // Hash function for SemanticContext, used in the MurmurHash::update function
221
+ } // namespace atn
222
+ } // namespace antlr4
211
223
 
212
224
  namespace std {
213
- using antlr4::atn::SemanticContext;
214
225
 
215
- template <> struct hash<SemanticContext>
216
- {
217
- size_t operator () (SemanticContext &x) const
218
- {
219
- return x.hashCode();
226
+ template <>
227
+ struct hash<::antlr4::atn::SemanticContext> {
228
+ size_t operator()(const ::antlr4::atn::SemanticContext &semanticContext) const {
229
+ return semanticContext.hashCode();
220
230
  }
221
231
  };
222
- }
232
+
233
+ } // namespace std
@@ -0,0 +1,23 @@
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.
4
+ */
5
+
6
+ #pragma once
7
+
8
+ #include <cstddef>
9
+
10
+ #include "antlr4-common.h"
11
+
12
+ namespace antlr4 {
13
+ namespace atn {
14
+
15
+ enum class SemanticContextType : size_t {
16
+ PREDICATE = 1,
17
+ PRECEDENCE = 2,
18
+ AND = 3,
19
+ OR = 4,
20
+ };
21
+
22
+ } // namespace atn
23
+ } // namespace antlr4
@@ -0,0 +1,101 @@
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.
4
+ */
5
+
6
+ #pragma once
7
+
8
+ #include <cstddef>
9
+ #include <cstdint>
10
+ #include <cstring>
11
+ #include <iterator>
12
+ #include <vector>
13
+
14
+ #include "antlr4-common.h"
15
+ #include "misc/MurmurHash.h"
16
+
17
+ namespace antlr4 {
18
+ namespace atn {
19
+
20
+ class ANTLR4CPP_PUBLIC SerializedATNView final {
21
+ public:
22
+ using value_type = int32_t;
23
+ using size_type = size_t;
24
+ using difference_type = ptrdiff_t;
25
+ using reference = int32_t&;
26
+ using const_reference = const int32_t&;
27
+ using pointer = int32_t*;
28
+ using const_pointer = const int32_t*;
29
+ using iterator = const_pointer;
30
+ using const_iterator = const_pointer;
31
+ using reverse_iterator = std::reverse_iterator<iterator>;
32
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
33
+
34
+ SerializedATNView() = default;
35
+
36
+ SerializedATNView(const_pointer data, size_type size) : _data(data), _size(size) {}
37
+
38
+ SerializedATNView(const std::vector<int32_t> &serializedATN) : _data(serializedATN.data()), _size(serializedATN.size()) {}
39
+
40
+ SerializedATNView(const SerializedATNView&) = default;
41
+
42
+ SerializedATNView& operator=(const SerializedATNView&) = default;
43
+
44
+ const_iterator begin() const { return data(); }
45
+
46
+ const_iterator cbegin() const { return data(); }
47
+
48
+ const_iterator end() const { return data() + size(); }
49
+
50
+ const_iterator cend() const { return data() + size(); }
51
+
52
+ const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
53
+
54
+ const_reverse_iterator crbegin() const { return const_reverse_iterator(cend()); }
55
+
56
+ const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
57
+
58
+ const_reverse_iterator crend() const { return const_reverse_iterator(cbegin()); }
59
+
60
+ bool empty() const { return size() == 0; }
61
+
62
+ const_pointer data() const { return _data; }
63
+
64
+ size_type size() const { return _size; }
65
+
66
+ size_type size_bytes() const { return size() * sizeof(value_type); }
67
+
68
+ const_reference operator[](size_type index) const { return _data[index]; }
69
+
70
+ private:
71
+ const_pointer _data = nullptr;
72
+ size_type _size = 0;
73
+ };
74
+
75
+ inline bool operator==(const SerializedATNView &lhs, const SerializedATNView &rhs) {
76
+ return (lhs.data() == rhs.data() && lhs.size() == rhs.size()) ||
77
+ (lhs.size() == rhs.size() && std::memcmp(lhs.data(), rhs.data(), lhs.size_bytes()) == 0);
78
+ }
79
+
80
+ inline bool operator!=(const SerializedATNView &lhs, const SerializedATNView &rhs) {
81
+ return !operator==(lhs, rhs);
82
+ }
83
+
84
+ inline bool operator<(const SerializedATNView &lhs, const SerializedATNView &rhs) {
85
+ int diff = std::memcmp(lhs.data(), rhs.data(), std::min(lhs.size_bytes(), rhs.size_bytes()));
86
+ return diff < 0 || (diff == 0 && lhs.size() < rhs.size());
87
+ }
88
+
89
+ } // namespace atn
90
+ } // namespace antlr4
91
+
92
+ namespace std {
93
+
94
+ template <>
95
+ struct hash<::antlr4::atn::SerializedATNView> {
96
+ size_t operator()(const ::antlr4::atn::SerializedATNView &serializedATNView) const {
97
+ return ::antlr4::misc::MurmurHash::hashCode(serializedATNView.data(), serializedATNView.size());
98
+ }
99
+ };
100
+
101
+ } // namespace std
@@ -11,12 +11,8 @@
11
11
  using namespace antlr4;
12
12
  using namespace antlr4::atn;
13
13
 
14
- SetTransition::SetTransition(ATNState *target, const misc::IntervalSet &aSet)
15
- : Transition(target), set(aSet.isEmpty() ? misc::IntervalSet::of(Token::INVALID_TYPE) : aSet) {
16
- }
17
-
18
- Transition::SerializationType SetTransition::getSerializationType() const {
19
- return SET;
14
+ SetTransition::SetTransition(TransitionType transitionType, ATNState *target, misc::IntervalSet aSet)
15
+ : Transition(transitionType, target), set(aSet.isEmpty() ? misc::IntervalSet::of(Token::INVALID_TYPE) : std::move(aSet)) {
20
16
  }
21
17
 
22
18
  misc::IntervalSet SetTransition::label() const {
@@ -14,16 +14,24 @@ namespace atn {
14
14
  /// A transition containing a set of values. </summary>
15
15
  class ANTLR4CPP_PUBLIC SetTransition : public Transition {
16
16
  public:
17
- const misc::IntervalSet set;
17
+ static bool is(const Transition &transition) {
18
+ const auto transitionType = transition.getTransitionType();
19
+ return transitionType == TransitionType::SET || transitionType == TransitionType::NOT_SET;
20
+ }
21
+
22
+ static bool is(const Transition *transition) { return transition != nullptr && is(*transition); }
18
23
 
19
- SetTransition(ATNState *target, const misc::IntervalSet &set);
24
+ const misc::IntervalSet set;
20
25
 
21
- virtual SerializationType getSerializationType() const override;
26
+ SetTransition(ATNState *target, misc::IntervalSet set) : SetTransition(TransitionType::SET, target, std::move(set)) {}
22
27
 
23
28
  virtual misc::IntervalSet label() const override;
24
29
  virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override;
25
30
 
26
31
  virtual std::string toString() const override;
32
+
33
+ protected:
34
+ SetTransition(TransitionType transitionType, ATNState *target, misc::IntervalSet set);
27
35
  };
28
36
 
29
37
  } // namespace atn
@@ -3,69 +3,74 @@
3
3
  * can be found in the LICENSE.txt file in the project root.
4
4
  */
5
5
 
6
- #include "atn/EmptyPredictionContext.h"
7
-
8
6
  #include "atn/SingletonPredictionContext.h"
9
7
 
8
+ #include "support/Casts.h"
9
+ #include "misc/MurmurHash.h"
10
+
10
11
  using namespace antlr4::atn;
12
+ using namespace antlrcpp;
11
13
 
12
- SingletonPredictionContext::SingletonPredictionContext(Ref<PredictionContext> const& parent, size_t returnState)
13
- : PredictionContext(parent ? calculateHashCode(parent, returnState) : calculateEmptyHashCode()),
14
- parent(parent), returnState(returnState) {
15
- assert(returnState != ATNState::INVALID_STATE_NUMBER);
16
- }
14
+ namespace {
15
+
16
+ bool cachedHashCodeEqual(size_t lhs, size_t rhs) {
17
+ return lhs == rhs || lhs == 0 || rhs == 0;
18
+ }
17
19
 
18
- SingletonPredictionContext::~SingletonPredictionContext() {
19
20
  }
20
21
 
21
- Ref<SingletonPredictionContext> SingletonPredictionContext::create(Ref<PredictionContext> const& parent, size_t returnState) {
22
+ SingletonPredictionContext::SingletonPredictionContext(Ref<const PredictionContext> parent, size_t returnState)
23
+ : PredictionContext(PredictionContextType::SINGLETON), parent(std::move(parent)), returnState(returnState) {
24
+ assert(returnState != ATNState::INVALID_STATE_NUMBER);
25
+ }
22
26
 
23
- if (returnState == EMPTY_RETURN_STATE && parent) {
27
+ Ref<const SingletonPredictionContext> SingletonPredictionContext::create(Ref<const PredictionContext> parent, size_t returnState) {
28
+ if (returnState == EMPTY_RETURN_STATE && parent == nullptr) {
24
29
  // someone can pass in the bits of an array ctx that mean $
25
- return std::dynamic_pointer_cast<SingletonPredictionContext>(EMPTY);
30
+ return std::dynamic_pointer_cast<const SingletonPredictionContext>(EMPTY);
26
31
  }
27
- return std::make_shared<SingletonPredictionContext>(parent, returnState);
32
+ return std::make_shared<SingletonPredictionContext>(std::move(parent), returnState);
33
+ }
34
+
35
+ bool SingletonPredictionContext::isEmpty() const {
36
+ return parent == nullptr && returnState == EMPTY_RETURN_STATE;
28
37
  }
29
38
 
30
39
  size_t SingletonPredictionContext::size() const {
31
40
  return 1;
32
41
  }
33
42
 
34
- Ref<PredictionContext> SingletonPredictionContext::getParent(size_t index) const {
43
+ const Ref<const PredictionContext>& SingletonPredictionContext::getParent(size_t index) const {
35
44
  assert(index == 0);
36
- ((void)(index)); // Make Release build happy.
45
+ static_cast<void>(index);
37
46
  return parent;
38
47
  }
39
48
 
40
49
  size_t SingletonPredictionContext::getReturnState(size_t index) const {
41
50
  assert(index == 0);
42
- ((void)(index)); // Make Release build happy.
51
+ static_cast<void>(index);
43
52
  return returnState;
44
53
  }
45
54
 
46
- bool SingletonPredictionContext::operator == (const PredictionContext &o) const {
47
- if (this == &o) {
55
+ size_t SingletonPredictionContext::hashCodeImpl() const {
56
+ size_t hash = misc::MurmurHash::initialize();
57
+ hash = misc::MurmurHash::update(hash, static_cast<size_t>(getContextType()));
58
+ hash = misc::MurmurHash::update(hash, parent);
59
+ hash = misc::MurmurHash::update(hash, returnState);
60
+ return misc::MurmurHash::finish(hash, 3);
61
+ }
62
+
63
+ bool SingletonPredictionContext::equals(const PredictionContext &other) const {
64
+ if (this == std::addressof(other)) {
48
65
  return true;
49
66
  }
50
-
51
- const SingletonPredictionContext *other = dynamic_cast<const SingletonPredictionContext*>(&o);
52
- if (other == nullptr) {
67
+ if (getContextType() != other.getContextType()) {
53
68
  return false;
54
69
  }
55
-
56
- if (this->hashCode() != other->hashCode()) {
57
- return false; // can't be same if hash is different
58
- }
59
-
60
- if (returnState != other->returnState)
61
- return false;
62
-
63
- if (!parent && !other->parent)
64
- return true;
65
- if (!parent || !other->parent)
66
- return false;
67
-
68
- return *parent == *other->parent;
70
+ const auto &singleton = downCast<const SingletonPredictionContext&>(other);
71
+ return returnState == singleton.returnState &&
72
+ cachedHashCodeEqual(cachedHashCode(), singleton.cachedHashCode()) &&
73
+ (parent == singleton.parent || (parent != nullptr && singleton.parent != nullptr && *parent == *singleton.parent));
69
74
  }
70
75
 
71
76
  std::string SingletonPredictionContext::toString() const {
@@ -10,26 +10,33 @@
10
10
  namespace antlr4 {
11
11
  namespace atn {
12
12
 
13
- class ANTLR4CPP_PUBLIC SingletonPredictionContext : public PredictionContext {
13
+ class ANTLR4CPP_PUBLIC SingletonPredictionContext final : public PredictionContext {
14
14
  public:
15
+ static bool is(const PredictionContext &predictionContext) { return predictionContext.getContextType() == PredictionContextType::SINGLETON; }
16
+
17
+ static bool is(const PredictionContext *predictionContext) { return predictionContext != nullptr && is(*predictionContext); }
18
+
19
+ static Ref<const SingletonPredictionContext> create(Ref<const PredictionContext> parent, size_t returnState);
20
+
15
21
  // Usually a parent is linked via a weak ptr. Not so here as we have kinda reverse reference chain.
16
22
  // There are no child contexts stored here and often the parent context is left dangling when it's
17
23
  // owning ATNState is released. In order to avoid having this context released as well (leaving all other contexts
18
24
  // which got this one as parent with a null reference) we use a shared_ptr here instead, to keep those left alone
19
25
  // parent contexts alive.
20
- const Ref<PredictionContext> parent;
26
+ const Ref<const PredictionContext> parent;
21
27
  const size_t returnState;
22
28
 
23
- SingletonPredictionContext(Ref<PredictionContext> const& parent, size_t returnState);
24
- virtual ~SingletonPredictionContext();
29
+ SingletonPredictionContext(Ref<const PredictionContext> parent, size_t returnState);
25
30
 
26
- static Ref<SingletonPredictionContext> create(Ref<PredictionContext> const& parent, size_t returnState);
31
+ bool isEmpty() const override;
32
+ size_t size() const override;
33
+ const Ref<const PredictionContext>& getParent(size_t index) const override;
34
+ size_t getReturnState(size_t index) const override;
35
+ bool equals(const PredictionContext &other) const override;
36
+ std::string toString() const override;
27
37
 
28
- virtual size_t size() const override;
29
- virtual Ref<PredictionContext> getParent(size_t index) const override;
30
- virtual size_t getReturnState(size_t index) const override;
31
- virtual bool operator == (const PredictionContext &o) const override;
32
- virtual std::string toString() const override;
38
+ protected:
39
+ size_t hashCodeImpl() const override;
33
40
  };
34
41
 
35
42
  } // namespace atn
@@ -12,9 +12,12 @@ namespace atn {
12
12
 
13
13
  /// The block that begins a closure loop.
14
14
  class ANTLR4CPP_PUBLIC StarBlockStartState final : public BlockStartState {
15
-
16
15
  public:
17
- virtual size_t getStateType() override;
16
+ static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::STAR_BLOCK_START; }
17
+
18
+ static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
19
+
20
+ StarBlockStartState() : BlockStartState(ATNStateType::STAR_BLOCK_START) {}
18
21
  };
19
22
 
20
23
  } // namespace atn
@@ -12,7 +12,9 @@ namespace atn {
12
12
 
13
13
  class ANTLR4CPP_PUBLIC StarLoopEntryState final : public DecisionState {
14
14
  public:
15
- StarLoopEntryState();
15
+ static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::STAR_LOOP_ENTRY; }
16
+
17
+ static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
16
18
 
17
19
  /**
18
20
  * Indicates whether this state can benefit from a precedence DFA during SLL
@@ -28,7 +30,7 @@ namespace atn {
28
30
 
29
31
  StarLoopbackState *loopBackState = nullptr;
30
32
 
31
- virtual size_t getStateType() override;
33
+ StarLoopEntryState() : DecisionState(ATNStateType::STAR_LOOP_ENTRY) {}
32
34
  };
33
35
 
34
36
  } // namespace atn
@@ -5,15 +5,15 @@
5
5
 
6
6
  #include "atn/StarLoopEntryState.h"
7
7
  #include "atn/Transition.h"
8
+ #include "support/Casts.h"
8
9
 
9
10
  #include "atn/StarLoopbackState.h"
10
11
 
11
12
  using namespace antlr4::atn;
12
13
 
13
- StarLoopEntryState *StarLoopbackState::getLoopEntryState() {
14
- return dynamic_cast<StarLoopEntryState *>(transitions[0]->target);
15
- }
16
-
17
- size_t StarLoopbackState::getStateType() {
18
- return STAR_LOOP_BACK;
14
+ StarLoopEntryState *StarLoopbackState::getLoopEntryState() const {
15
+ if (transitions[0]->target != nullptr && transitions[0]->target->getStateType() == ATNStateType::STAR_LOOP_ENTRY) {
16
+ return antlrcpp::downCast<StarLoopEntryState*>(transitions[0]->target);
17
+ }
18
+ return nullptr;
19
19
  }