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
@@ -11,11 +11,7 @@
11
11
  using namespace antlr4::misc;
12
12
  using namespace antlr4::atn;
13
13
 
14
- AtomTransition::AtomTransition(ATNState *target, size_t label) : Transition(target), _label(label) {
15
- }
16
-
17
- Transition::SerializationType AtomTransition::getSerializationType() const {
18
- return ATOM;
14
+ AtomTransition::AtomTransition(ATNState *target, size_t label) : Transition(TransitionType::ATOM, target), _label(label) {
19
15
  }
20
16
 
21
17
  IntervalSet AtomTransition::label() const {
@@ -13,13 +13,16 @@ namespace atn {
13
13
  /// TODO: make all transitions sets? no, should remove set edges.
14
14
  class ANTLR4CPP_PUBLIC AtomTransition final : public Transition {
15
15
  public:
16
+ static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::ATOM; }
17
+
18
+ static bool is(const Transition *transition) { return transition != nullptr && is(*transition); }
19
+
16
20
  /// The token type or character value; or, signifies special label.
21
+ /// TODO: rename this to label
17
22
  const size_t _label;
18
23
 
19
24
  AtomTransition(ATNState *target, size_t label);
20
25
 
21
- virtual SerializationType getSerializationType() const override;
22
-
23
26
  virtual misc::IntervalSet label() const override;
24
27
  virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override;
25
28
 
@@ -12,10 +12,12 @@ namespace antlr4 {
12
12
  namespace atn {
13
13
 
14
14
  class ANTLR4CPP_PUBLIC BasicBlockStartState final : public BlockStartState {
15
-
16
15
  public:
17
- virtual size_t getStateType() override;
16
+ static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::BLOCK_START; }
17
+
18
+ static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
18
19
 
20
+ BasicBlockStartState() : BlockStartState(ATNStateType::BLOCK_START) {}
19
21
  };
20
22
 
21
23
  } // namespace atn
@@ -11,10 +11,12 @@ namespace antlr4 {
11
11
  namespace atn {
12
12
 
13
13
  class ANTLR4CPP_PUBLIC BasicState final : public ATNState {
14
-
15
14
  public:
16
- virtual size_t getStateType() override;
15
+ static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::BASIC; }
16
+
17
+ static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
17
18
 
19
+ BasicState() : ATNState(ATNStateType::BASIC) {}
18
20
  };
19
21
 
20
22
  } // namespace atn
@@ -13,11 +13,13 @@ namespace atn {
13
13
  /// Terminal node of a simple {@code (a|b|c)} block.
14
14
  class ANTLR4CPP_PUBLIC BlockEndState final : public ATNState {
15
15
  public:
16
- BlockStartState *startState = nullptr;
16
+ static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::BLOCK_END; }
17
+
18
+ static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
17
19
 
18
- BlockEndState();
20
+ BlockStartState *startState = nullptr;
19
21
 
20
- virtual size_t getStateType() override;
22
+ BlockEndState() : ATNState(ATNStateType::BLOCK_END) {}
21
23
  };
22
24
 
23
25
  } // namespace atn
@@ -13,8 +13,17 @@ namespace atn {
13
13
  /// The start of a regular {@code (...)} block.
14
14
  class ANTLR4CPP_PUBLIC BlockStartState : public DecisionState {
15
15
  public:
16
- ~BlockStartState();
16
+ static bool is(const ATNState &atnState) {
17
+ const auto stateType = atnState.getStateType();
18
+ return stateType >= ATNStateType::BLOCK_START && stateType <= ATNStateType::STAR_BLOCK_START;
19
+ }
20
+
21
+ static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
22
+
17
23
  BlockEndState *endState = nullptr;
24
+
25
+ protected:
26
+ using DecisionState::DecisionState;
18
27
  };
19
28
 
20
29
  } // namespace atn
@@ -218,7 +218,7 @@ namespace atn {
218
218
  /// statistics for a particular decision.
219
219
  /// </summary>
220
220
  /// <param name="decision"> The decision number </param>
221
- DecisionInfo(size_t decision);
221
+ explicit DecisionInfo(size_t decision);
222
222
 
223
223
  std::string toString() const;
224
224
  };
@@ -7,11 +7,6 @@
7
7
 
8
8
  using namespace antlr4::atn;
9
9
 
10
- void DecisionState::InitializeInstanceFields() {
11
- decision = -1;
12
- nonGreedy = false;
13
- }
14
-
15
10
  std::string DecisionState::toString() const {
16
11
  return "DECISION " + ATNState::toString();
17
12
  }
@@ -12,18 +12,22 @@ namespace atn {
12
12
 
13
13
  class ANTLR4CPP_PUBLIC DecisionState : public ATNState {
14
14
  public:
15
- int decision;
16
- bool nonGreedy;
15
+ static bool is(const ATNState &atnState) {
16
+ const auto stateType = atnState.getStateType();
17
+ return (stateType >= ATNStateType::BLOCK_START && stateType <= ATNStateType::TOKEN_START) ||
18
+ stateType == ATNStateType::PLUS_LOOP_BACK ||
19
+ stateType == ATNStateType::STAR_LOOP_ENTRY;
20
+ }
17
21
 
18
- private:
19
- void InitializeInstanceFields();
22
+ static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
20
23
 
21
- public:
22
- DecisionState() {
23
- InitializeInstanceFields();
24
- }
24
+ int decision = -1;
25
+ bool nonGreedy = false;
25
26
 
26
27
  virtual std::string toString() const override;
28
+
29
+ protected:
30
+ using ATNState::ATNState;
27
31
  };
28
32
 
29
33
  } // namespace atn
@@ -11,17 +11,13 @@ EpsilonTransition::EpsilonTransition(ATNState *target) : EpsilonTransition(targe
11
11
  }
12
12
 
13
13
  EpsilonTransition::EpsilonTransition(ATNState *target, size_t outermostPrecedenceReturn)
14
- : Transition(target), _outermostPrecedenceReturn(outermostPrecedenceReturn) {
14
+ : Transition(TransitionType::EPSILON, target), _outermostPrecedenceReturn(outermostPrecedenceReturn) {
15
15
  }
16
16
 
17
- size_t EpsilonTransition::outermostPrecedenceReturn() {
17
+ size_t EpsilonTransition::outermostPrecedenceReturn() const {
18
18
  return _outermostPrecedenceReturn;
19
19
  }
20
20
 
21
- Transition::SerializationType EpsilonTransition::getSerializationType() const {
22
- return EPSILON;
23
- }
24
-
25
21
  bool EpsilonTransition::isEpsilon() const {
26
22
  return true;
27
23
  }
@@ -12,7 +12,11 @@ namespace atn {
12
12
 
13
13
  class ANTLR4CPP_PUBLIC EpsilonTransition final : public Transition {
14
14
  public:
15
- EpsilonTransition(ATNState *target);
15
+ static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::EPSILON; }
16
+
17
+ static bool is(const Transition *transition) { return transition != nullptr && is(*transition); }
18
+
19
+ explicit EpsilonTransition(ATNState *target);
16
20
  EpsilonTransition(ATNState *target, size_t outermostPrecedenceReturn);
17
21
 
18
22
  /**
@@ -23,8 +27,7 @@ namespace atn {
23
27
  * @see ParserATNSimulator#applyPrecedenceFilter(ATNConfigSet)
24
28
  * @since 4.4.1
25
29
  */
26
- size_t outermostPrecedenceReturn();
27
- virtual SerializationType getSerializationType() const override;
30
+ size_t outermostPrecedenceReturn() const;
28
31
 
29
32
  virtual bool isEpsilon() const override;
30
33
  virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override;
@@ -7,12 +7,10 @@
7
7
  #include "atn/Transition.h"
8
8
  #include "atn/RuleTransition.h"
9
9
  #include "atn/SingletonPredictionContext.h"
10
- #include "atn/AbstractPredicateTransition.h"
11
10
  #include "atn/WildcardTransition.h"
12
11
  #include "atn/NotSetTransition.h"
13
12
  #include "misc/IntervalSet.h"
14
13
  #include "atn/ATNConfig.h"
15
- #include "atn/EmptyPredictionContext.h"
16
14
 
17
15
  #include "support/CPPUtils.h"
18
16
 
@@ -22,10 +20,140 @@ using namespace antlr4;
22
20
  using namespace antlr4::atn;
23
21
  using namespace antlrcpp;
24
22
 
25
- LL1Analyzer::LL1Analyzer(const ATN &atn) : _atn(atn) {
26
- }
23
+ namespace {
24
+
25
+ struct ATNConfigHasher final {
26
+ size_t operator()(const ATNConfig& atn_config) const {
27
+ return atn_config.hashCode();
28
+ }
29
+ };
30
+
31
+ struct ATNConfigComparer final {
32
+ bool operator()(const ATNConfig& lhs, const ATNConfig& rhs) const {
33
+ return lhs == rhs;
34
+ }
35
+ };
36
+
37
+ class LL1AnalyzerImpl final {
38
+ public:
39
+ LL1AnalyzerImpl(const ATN& atn, misc::IntervalSet& look, bool seeThruPreds, bool addEOF) : _atn(atn), _look(look), _seeThruPreds(seeThruPreds), _addEOF(addEOF) {}
40
+
41
+ /// <summary>
42
+ /// Compute set of tokens that can follow {@code s} in the ATN in the
43
+ /// specified {@code ctx}.
44
+ /// <p/>
45
+ /// If {@code ctx} is {@code null} and {@code stopState} or the end of the
46
+ /// rule containing {@code s} is reached, <seealso cref="Token#EPSILON"/> is added to
47
+ /// the result set. If {@code ctx} is not {@code null} and {@code addEOF} is
48
+ /// {@code true} and {@code stopState} or the end of the outermost rule is
49
+ /// reached, <seealso cref="Token#EOF"/> is added to the result set.
50
+ /// </summary>
51
+ /// <param name="s"> the ATN state. </param>
52
+ /// <param name="stopState"> the ATN state to stop at. This can be a
53
+ /// <seealso cref="BlockEndState"/> to detect epsilon paths through a closure. </param>
54
+ /// <param name="ctx"> The outer context, or {@code null} if the outer context should
55
+ /// not be used. </param>
56
+ /// <param name="look"> The result lookahead set. </param>
57
+ /// <param name="lookBusy"> A set used for preventing epsilon closures in the ATN
58
+ /// from causing a stack overflow. Outside code should pass
59
+ /// {@code new HashSet<ATNConfig>} for this argument. </param>
60
+ /// <param name="calledRuleStack"> A set used for preventing left recursion in the
61
+ /// ATN from causing a stack overflow. Outside code should pass
62
+ /// {@code new BitSet()} for this argument. </param>
63
+ /// <param name="seeThruPreds"> {@code true} to true semantic predicates as
64
+ /// implicitly {@code true} and "see through them", otherwise {@code false}
65
+ /// to treat semantic predicates as opaque and add <seealso cref="#HIT_PRED"/> to the
66
+ /// result if one is encountered. </param>
67
+ /// <param name="addEOF"> Add <seealso cref="Token#EOF"/> to the result if the end of the
68
+ /// outermost context is reached. This parameter has no effect if {@code ctx}
69
+ /// is {@code null}. </param>
70
+ void LOOK(ATNState *s, ATNState *stopState, Ref<const PredictionContext> const& ctx) {
71
+ if (!_lookBusy.insert(ATNConfig(s, 0, ctx)).second) {
72
+ return;
73
+ }
74
+
75
+ // ml: s can never be null, hence no need to check if stopState is != null.
76
+ if (s == stopState) {
77
+ if (ctx == nullptr) {
78
+ _look.add(Token::EPSILON);
79
+ return;
80
+ } else if (ctx->isEmpty() && _addEOF) {
81
+ _look.add(Token::EOF);
82
+ return;
83
+ }
84
+ }
85
+
86
+ if (s->getStateType() == ATNStateType::RULE_STOP) {
87
+ if (ctx == nullptr) {
88
+ _look.add(Token::EPSILON);
89
+ return;
90
+ } else if (ctx->isEmpty() && _addEOF) {
91
+ _look.add(Token::EOF);
92
+ return;
93
+ }
94
+
95
+ if (ctx != PredictionContext::EMPTY) {
96
+ bool removed = _calledRuleStack.test(s->ruleIndex);
97
+ _calledRuleStack[s->ruleIndex] = false;
98
+ // run thru all possible stack tops in ctx
99
+ for (size_t i = 0; i < ctx->size(); i++) {
100
+ ATNState *returnState = _atn.states[ctx->getReturnState(i)];
101
+ LOOK(returnState, stopState, ctx->getParent(i));
102
+ }
103
+ if (removed) {
104
+ _calledRuleStack.set(s->ruleIndex);
105
+ }
106
+ return;
107
+ }
108
+ }
109
+
110
+ size_t n = s->transitions.size();
111
+ for (size_t i = 0; i < n; i++) {
112
+ const Transition *t = s->transitions[i].get();
113
+ const auto tType = t->getTransitionType();
114
+
115
+ if (tType == TransitionType::RULE) {
116
+ if (_calledRuleStack[(static_cast<const RuleTransition*>(t))->target->ruleIndex]) {
117
+ continue;
118
+ }
119
+
120
+ Ref<const PredictionContext> newContext = SingletonPredictionContext::create(ctx, (static_cast<const RuleTransition*>(t))->followState->stateNumber);
121
+
122
+ _calledRuleStack.set((static_cast<const RuleTransition*>(t))->target->ruleIndex);
123
+ LOOK(t->target, stopState, newContext);
124
+ _calledRuleStack[(static_cast<const RuleTransition*>(t))->target->ruleIndex] = false;
125
+
126
+ } else if (tType == TransitionType::PREDICATE || tType == TransitionType::PRECEDENCE) {
127
+ if (_seeThruPreds) {
128
+ LOOK(t->target, stopState, ctx);
129
+ } else {
130
+ _look.add(LL1Analyzer::HIT_PRED);
131
+ }
132
+ } else if (t->isEpsilon()) {
133
+ LOOK(t->target, stopState, ctx);
134
+ } else if (tType == TransitionType::WILDCARD) {
135
+ _look.addAll(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, static_cast<ssize_t>(_atn.maxTokenType)));
136
+ } else {
137
+ misc::IntervalSet set = t->label();
138
+ if (!set.isEmpty()) {
139
+ if (tType == TransitionType::NOT_SET) {
140
+ set = set.complement(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, static_cast<ssize_t>(_atn.maxTokenType)));
141
+ }
142
+ _look.addAll(set);
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ private:
149
+ const ATN& _atn;
150
+ misc::IntervalSet& _look;
151
+ antlrcpp::BitSet _calledRuleStack;
152
+ std::unordered_set<ATNConfig, ATNConfigHasher, ATNConfigComparer> _lookBusy;
153
+ bool _seeThruPreds;
154
+ bool _addEOF;
155
+ };
27
156
 
28
- LL1Analyzer::~LL1Analyzer() {
29
157
  }
30
158
 
31
159
  std::vector<misc::IntervalSet> LL1Analyzer::getDecisionLookahead(ATNState *s) const {
@@ -37,16 +165,11 @@ std::vector<misc::IntervalSet> LL1Analyzer::getDecisionLookahead(ATNState *s) co
37
165
 
38
166
  look.resize(s->transitions.size()); // Fills all interval sets with defaults.
39
167
  for (size_t alt = 0; alt < s->transitions.size(); alt++) {
40
- bool seeThruPreds = false; // fail to get lookahead upon pred
41
-
42
- ATNConfig::Set lookBusy;
43
- antlrcpp::BitSet callRuleStack;
44
- _LOOK(s->transitions[alt]->target, nullptr, PredictionContext::EMPTY,
45
- look[alt], lookBusy, callRuleStack, seeThruPreds, false);
46
-
168
+ LL1AnalyzerImpl impl(_atn, look[alt], false, false);
169
+ impl.LOOK(s->transitions[alt]->target, nullptr, PredictionContext::EMPTY);
47
170
  // Wipe out lookahead for this alternative if we found nothing
48
171
  // or we had a predicate when we !seeThruPreds
49
- if (look[alt].size() == 0 || look[alt].contains(HIT_PRED)) {
172
+ if (look[alt].size() == 0 || look[alt].contains(LL1Analyzer::HIT_PRED)) {
50
173
  look[alt].clear();
51
174
  }
52
175
  }
@@ -58,99 +181,9 @@ misc::IntervalSet LL1Analyzer::LOOK(ATNState *s, RuleContext *ctx) const {
58
181
  }
59
182
 
60
183
  misc::IntervalSet LL1Analyzer::LOOK(ATNState *s, ATNState *stopState, RuleContext *ctx) const {
184
+ Ref<const PredictionContext> lookContext = ctx != nullptr ? PredictionContext::fromRuleContext(_atn, ctx) : nullptr;
61
185
  misc::IntervalSet r;
62
- bool seeThruPreds = true; // ignore preds; get all lookahead
63
- Ref<PredictionContext> lookContext = ctx != nullptr ? PredictionContext::fromRuleContext(_atn, ctx) : nullptr;
64
-
65
- ATNConfig::Set lookBusy;
66
- antlrcpp::BitSet callRuleStack;
67
- _LOOK(s, stopState, lookContext, r, lookBusy, callRuleStack, seeThruPreds, true);
68
-
186
+ LL1AnalyzerImpl impl(_atn, r, true, true);
187
+ impl.LOOK(s, stopState, lookContext);
69
188
  return r;
70
189
  }
71
-
72
- void LL1Analyzer::_LOOK(ATNState *s, ATNState *stopState, Ref<PredictionContext> const& ctx, misc::IntervalSet &look,
73
- ATNConfig::Set &lookBusy, antlrcpp::BitSet &calledRuleStack, bool seeThruPreds, bool addEOF) const {
74
-
75
- Ref<ATNConfig> c = std::make_shared<ATNConfig>(s, 0, ctx);
76
-
77
- if (lookBusy.count(c) > 0) // Keep in mind comparison is based on members of the class, not the actual instance.
78
- return;
79
-
80
- lookBusy.insert(c);
81
-
82
- // ml: s can never be null, hence no need to check if stopState is != null.
83
- if (s == stopState) {
84
- if (ctx == nullptr) {
85
- look.add(Token::EPSILON);
86
- return;
87
- } else if (ctx->isEmpty() && addEOF) {
88
- look.add(Token::EOF);
89
- return;
90
- }
91
- }
92
-
93
- if (s->getStateType() == ATNState::RULE_STOP) {
94
- if (ctx == nullptr) {
95
- look.add(Token::EPSILON);
96
- return;
97
- } else if (ctx->isEmpty() && addEOF) {
98
- look.add(Token::EOF);
99
- return;
100
- }
101
-
102
- if (ctx != PredictionContext::EMPTY) {
103
- bool removed = calledRuleStack.test(s->ruleIndex);
104
- calledRuleStack[s->ruleIndex] = false;
105
- auto onExit = finally([removed, &calledRuleStack, s] {
106
- if (removed) {
107
- calledRuleStack.set(s->ruleIndex);
108
- }
109
- });
110
- // run thru all possible stack tops in ctx
111
- for (size_t i = 0; i < ctx->size(); i++) {
112
- ATNState *returnState = _atn.states[ctx->getReturnState(i)];
113
- _LOOK(returnState, stopState, ctx->getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
114
- }
115
- return;
116
- }
117
- }
118
-
119
- size_t n = s->transitions.size();
120
- for (size_t i = 0; i < n; i++) {
121
- Transition *t = s->transitions[i];
122
-
123
- if (t->getSerializationType() == Transition::RULE) {
124
- if (calledRuleStack[(static_cast<RuleTransition*>(t))->target->ruleIndex]) {
125
- continue;
126
- }
127
-
128
- Ref<PredictionContext> newContext = SingletonPredictionContext::create(ctx, (static_cast<RuleTransition*>(t))->followState->stateNumber);
129
- auto onExit = finally([t, &calledRuleStack] {
130
- calledRuleStack[(static_cast<RuleTransition*>(t))->target->ruleIndex] = false;
131
- });
132
-
133
- calledRuleStack.set((static_cast<RuleTransition*>(t))->target->ruleIndex);
134
- _LOOK(t->target, stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
135
-
136
- } else if (is<AbstractPredicateTransition *>(t)) {
137
- if (seeThruPreds) {
138
- _LOOK(t->target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
139
- } else {
140
- look.add(HIT_PRED);
141
- }
142
- } else if (t->isEpsilon()) {
143
- _LOOK(t->target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
144
- } else if (t->getSerializationType() == Transition::WILDCARD) {
145
- look.addAll(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, static_cast<ssize_t>(_atn.maxTokenType)));
146
- } else {
147
- misc::IntervalSet set = t->label();
148
- if (!set.isEmpty()) {
149
- if (is<NotSetTransition*>(t)) {
150
- set = set.complement(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, static_cast<ssize_t>(_atn.maxTokenType)));
151
- }
152
- look.addAll(set);
153
- }
154
- }
155
- }
156
- }
@@ -6,29 +6,20 @@
6
6
  #pragma once
7
7
 
8
8
  #include "Token.h"
9
- #include "support/BitSet.h"
10
- #include "atn/PredictionContext.h"
11
9
  #include "atn/ATNConfig.h"
10
+ #include "atn/PredictionContext.h"
11
+ #include "support/BitSet.h"
12
12
 
13
13
  namespace antlr4 {
14
14
  namespace atn {
15
15
 
16
- class ANTLR4CPP_PUBLIC LL1Analyzer {
16
+ class ANTLR4CPP_PUBLIC LL1Analyzer final {
17
17
  public:
18
18
  /// Special value added to the lookahead sets to indicate that we hit
19
19
  /// a predicate during analysis if {@code seeThruPreds==false}.
20
- #if __cplusplus >= 201703L
21
20
  static constexpr size_t HIT_PRED = Token::INVALID_TYPE;
22
- #else
23
- enum : size_t {
24
- HIT_PRED = Token::INVALID_TYPE,
25
- };
26
- #endif
27
21
 
28
- const atn::ATN &_atn;
29
-
30
- LL1Analyzer(const atn::ATN &atn);
31
- virtual ~LL1Analyzer();
22
+ explicit LL1Analyzer(const atn::ATN &atn) : _atn(atn) {}
32
23
 
33
24
  /// <summary>
34
25
  /// Calculates the SLL(1) expected lookahead set for each outgoing transition
@@ -39,7 +30,7 @@ namespace atn {
39
30
  /// </summary>
40
31
  /// <param name="s"> the ATN state </param>
41
32
  /// <returns> the expected symbols for each outgoing transition of {@code s}. </returns>
42
- virtual std::vector<misc::IntervalSet> getDecisionLookahead(ATNState *s) const;
33
+ std::vector<misc::IntervalSet> getDecisionLookahead(ATNState *s) const;
43
34
 
44
35
  /// <summary>
45
36
  /// Compute set of tokens that can follow {@code s} in the ATN in the
@@ -56,7 +47,7 @@ namespace atn {
56
47
  /// </param>
57
48
  /// <returns> The set of tokens that can follow {@code s} in the ATN in the
58
49
  /// specified {@code ctx}. </returns>
59
- virtual misc::IntervalSet LOOK(ATNState *s, RuleContext *ctx) const;
50
+ misc::IntervalSet LOOK(ATNState *s, RuleContext *ctx) const;
60
51
 
61
52
  /// <summary>
62
53
  /// Compute set of tokens that can follow {@code s} in the ATN in the
@@ -75,40 +66,10 @@ namespace atn {
75
66
  /// </param>
76
67
  /// <returns> The set of tokens that can follow {@code s} in the ATN in the
77
68
  /// specified {@code ctx}. </returns>
78
- virtual misc::IntervalSet LOOK(ATNState *s, ATNState *stopState, RuleContext *ctx) const;
69
+ misc::IntervalSet LOOK(ATNState *s, ATNState *stopState, RuleContext *ctx) const;
79
70
 
80
- /// <summary>
81
- /// Compute set of tokens that can follow {@code s} in the ATN in the
82
- /// specified {@code ctx}.
83
- /// <p/>
84
- /// If {@code ctx} is {@code null} and {@code stopState} or the end of the
85
- /// rule containing {@code s} is reached, <seealso cref="Token#EPSILON"/> is added to
86
- /// the result set. If {@code ctx} is not {@code null} and {@code addEOF} is
87
- /// {@code true} and {@code stopState} or the end of the outermost rule is
88
- /// reached, <seealso cref="Token#EOF"/> is added to the result set.
89
- /// </summary>
90
- /// <param name="s"> the ATN state. </param>
91
- /// <param name="stopState"> the ATN state to stop at. This can be a
92
- /// <seealso cref="BlockEndState"/> to detect epsilon paths through a closure. </param>
93
- /// <param name="ctx"> The outer context, or {@code null} if the outer context should
94
- /// not be used. </param>
95
- /// <param name="look"> The result lookahead set. </param>
96
- /// <param name="lookBusy"> A set used for preventing epsilon closures in the ATN
97
- /// from causing a stack overflow. Outside code should pass
98
- /// {@code new HashSet<ATNConfig>} for this argument. </param>
99
- /// <param name="calledRuleStack"> A set used for preventing left recursion in the
100
- /// ATN from causing a stack overflow. Outside code should pass
101
- /// {@code new BitSet()} for this argument. </param>
102
- /// <param name="seeThruPreds"> {@code true} to true semantic predicates as
103
- /// implicitly {@code true} and "see through them", otherwise {@code false}
104
- /// to treat semantic predicates as opaque and add <seealso cref="#HIT_PRED"/> to the
105
- /// result if one is encountered. </param>
106
- /// <param name="addEOF"> Add <seealso cref="Token#EOF"/> to the result if the end of the
107
- /// outermost context is reached. This parameter has no effect if {@code ctx}
108
- /// is {@code null}. </param>
109
- protected:
110
- virtual void _LOOK(ATNState *s, ATNState *stopState, Ref<PredictionContext> const& ctx, misc::IntervalSet &look,
111
- ATNConfig::Set &lookBusy, antlrcpp::BitSet &calledRuleStack, bool seeThruPreds, bool addEOF) const;
71
+ private:
72
+ const atn::ATN &_atn;
112
73
  };
113
74
 
114
75
  } // namespace atn
@@ -10,44 +10,27 @@
10
10
  #include "atn/LexerActionExecutor.h"
11
11
 
12
12
  #include "support/CPPUtils.h"
13
+ #include "support/Casts.h"
13
14
 
14
15
  #include "atn/LexerATNConfig.h"
15
16
 
16
17
  using namespace antlr4::atn;
17
18
  using namespace antlrcpp;
18
19
 
19
- LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext> const& context)
20
- : ATNConfig(state, alt, context, SemanticContext::NONE), _passedThroughNonGreedyDecision(false) {
21
- }
20
+ LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<const PredictionContext> context)
21
+ : ATNConfig(state, alt, std::move(context)) {}
22
22
 
23
- LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext> const& context,
24
- Ref<LexerActionExecutor> const& lexerActionExecutor)
25
- : ATNConfig(state, alt, context, SemanticContext::NONE), _lexerActionExecutor(lexerActionExecutor),
26
- _passedThroughNonGreedyDecision(false) {
27
- }
23
+ LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<const PredictionContext> context, Ref<const LexerActionExecutor> lexerActionExecutor)
24
+ : ATNConfig(state, alt, std::move(context)), _lexerActionExecutor(std::move(lexerActionExecutor)) {}
28
25
 
29
- LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> const& c, ATNState *state)
30
- : ATNConfig(c, state, c->context, c->semanticContext), _lexerActionExecutor(c->_lexerActionExecutor),
31
- _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
32
- }
26
+ LexerATNConfig::LexerATNConfig(LexerATNConfig const& other, ATNState *state)
27
+ : ATNConfig(other, state), _lexerActionExecutor(other._lexerActionExecutor), _passedThroughNonGreedyDecision(checkNonGreedyDecision(other, state)) {}
33
28
 
34
- LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> const& c, ATNState *state, Ref<LexerActionExecutor> const& lexerActionExecutor)
35
- : ATNConfig(c, state, c->context, c->semanticContext), _lexerActionExecutor(lexerActionExecutor),
36
- _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
37
- }
29
+ LexerATNConfig::LexerATNConfig(LexerATNConfig const& other, ATNState *state, Ref<const LexerActionExecutor> lexerActionExecutor)
30
+ : ATNConfig(other, state), _lexerActionExecutor(std::move(lexerActionExecutor)), _passedThroughNonGreedyDecision(checkNonGreedyDecision(other, state)) {}
38
31
 
39
- LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> const& c, ATNState *state, Ref<PredictionContext> const& context)
40
- : ATNConfig(c, state, context, c->semanticContext), _lexerActionExecutor(c->_lexerActionExecutor),
41
- _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
42
- }
43
-
44
- Ref<LexerActionExecutor> LexerATNConfig::getLexerActionExecutor() const {
45
- return _lexerActionExecutor;
46
- }
47
-
48
- bool LexerATNConfig::hasPassedThroughNonGreedyDecision() {
49
- return _passedThroughNonGreedyDecision;
50
- }
32
+ LexerATNConfig::LexerATNConfig(LexerATNConfig const& other, ATNState *state, Ref<const PredictionContext> context)
33
+ : ATNConfig(other, state, std::move(context)), _lexerActionExecutor(other._lexerActionExecutor), _passedThroughNonGreedyDecision(checkNonGreedyDecision(other, state)) {}
51
34
 
52
35
  size_t LexerATNConfig::hashCode() const {
53
36
  size_t hashCode = misc::MurmurHash::initialize(7);
@@ -61,7 +44,7 @@ size_t LexerATNConfig::hashCode() const {
61
44
  return hashCode;
62
45
  }
63
46
 
64
- bool LexerATNConfig::operator == (const LexerATNConfig& other) const
47
+ bool LexerATNConfig::operator==(const LexerATNConfig& other) const
65
48
  {
66
49
  if (this == &other)
67
50
  return true;
@@ -75,10 +58,10 @@ bool LexerATNConfig::operator == (const LexerATNConfig& other) const
75
58
  return false;
76
59
  }
77
60
 
78
- return ATNConfig::operator == (other);
61
+ return ATNConfig::operator==(other);
79
62
  }
80
63
 
81
- bool LexerATNConfig::checkNonGreedyDecision(Ref<LexerATNConfig> const& source, ATNState *target) {
82
- return source->_passedThroughNonGreedyDecision ||
83
- (is<DecisionState*>(target) && (static_cast<DecisionState*>(target))->nonGreedy);
64
+ bool LexerATNConfig::checkNonGreedyDecision(LexerATNConfig const& source, ATNState *target) {
65
+ return source._passedThroughNonGreedyDecision ||
66
+ (DecisionState::is(target) && downCast<DecisionState*>(target)->nonGreedy);
84
67
  }