expressir 1.2.3 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (328) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +0 -6
  3. data/.github/workflows/rake.yml +223 -31
  4. data/.gitignore +7 -1
  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 +11 -9
  16. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -9
  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 +19 -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 +51 -35
  26. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +1 -1
  27. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +1 -5
  28. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +1 -5
  29. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +1 -12
  30. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +9 -6
  31. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +43 -18
  32. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +16 -6
  33. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
  34. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +1 -1
  35. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +1 -1
  36. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
  37. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
  38. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
  39. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
  40. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
  41. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +1 -1
  42. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +2 -3
  43. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +9 -9
  44. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
  45. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
  46. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +2 -2
  47. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +2 -2
  48. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +51 -31
  49. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +1 -7
  50. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
  51. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
  52. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +20 -23
  53. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +21 -21
  54. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +4 -4
  55. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
  56. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
  57. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +12 -17
  58. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
  59. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
  60. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
  61. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +7 -7
  62. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +1 -1
  63. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +6 -6
  64. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +4 -2
  65. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
  66. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
  67. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
  68. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -53
  69. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -27
  70. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -58
  71. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
  72. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +6 -57
  73. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +35 -15
  74. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +29 -36
  75. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +36 -27
  76. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
  77. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
  78. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
  79. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
  80. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -464
  81. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -62
  82. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
  83. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
  84. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
  85. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +42 -36
  86. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
  87. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
  88. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
  89. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
  90. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
  91. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
  92. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
  93. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
  94. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
  95. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
  96. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
  97. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
  98. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
  99. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
  100. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
  101. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
  102. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
  103. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -108
  104. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +10 -43
  105. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
  106. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
  107. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
  108. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +17 -28
  109. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
  110. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
  111. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
  112. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
  113. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
  114. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
  115. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
  116. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
  117. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
  118. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
  119. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
  120. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
  121. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
  122. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
  123. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
  124. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
  125. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
  126. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
  127. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
  128. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
  129. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
  130. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
  131. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
  132. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
  133. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
  134. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
  135. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
  136. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
  137. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +169 -152
  138. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
  139. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
  140. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
  141. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
  142. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
  143. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
  144. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
  145. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
  146. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
  147. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
  148. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
  149. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +87 -116
  150. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
  151. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
  152. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
  153. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
  154. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
  155. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
  156. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
  157. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
  158. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
  159. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
  160. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
  161. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
  162. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
  163. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
  164. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
  165. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
  166. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
  167. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
  168. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
  169. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
  170. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
  171. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
  172. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
  173. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
  174. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
  175. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
  176. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
  177. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
  178. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
  179. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
  180. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
  181. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
  182. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
  183. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
  184. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
  185. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +11 -23
  186. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
  187. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +2 -9
  188. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
  189. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
  190. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +15 -28
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +35 -9
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +2 -2
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +13 -54
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -23
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -40
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
  221. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +14 -5
  222. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
  223. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
  224. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
  225. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +30 -6
  226. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
  227. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
  228. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
  229. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +1 -1
  230. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +1 -1
  231. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
  232. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +1 -1
  233. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
  234. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
  235. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +1 -1
  236. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +1 -1
  237. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
  238. data/ext/express-parser/antlrgen/Express.interp +1 -1
  239. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
  240. data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
  241. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
  242. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
  243. data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
  244. data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
  245. data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
  246. data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
  247. data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
  248. data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
  249. data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
  250. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
  251. data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
  252. data/ext/express-parser/express_parser.cpp +165 -101
  253. data/ext/express-parser/extconf.rb +14 -14
  254. data/lib/expressir/config.rb +1 -1
  255. data/lib/expressir/express/parser.rb +17 -15
  256. data/lib/expressir/express/visitor.rb +7 -3
  257. data/lib/expressir/model.rb +78 -78
  258. data/lib/expressir/version.rb +1 -1
  259. data/rakelib/antlr4-native.rake +161 -0
  260. data/rakelib/cross-ruby.rake +213 -162
  261. data/spec/acceptance/version_spec.rb +17 -2
  262. data/spec/expressir/express/cache_spec.rb +23 -5
  263. data/spec/expressir/express/formatter_spec.rb +54 -8
  264. data/spec/expressir/express/parser_spec.rb +47 -11
  265. data/spec/expressir/model/model_element_spec.rb +198 -146
  266. data/spec/spec_helper.rb +7 -0
  267. metadata +79 -91
  268. data/demo.rb +0 -18
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
  274. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
  275. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
  276. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
  277. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
  278. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
  279. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
  280. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
  281. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
  282. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
  283. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
  284. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
  285. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
  286. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
  287. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
  288. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
  289. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
  290. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
  291. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
  292. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
  293. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
  294. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
  295. data/original/examples/employment/eclipse/.project +0 -17
  296. data/original/examples/employment/eclipse/Export/Employment.png +0 -0
  297. data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
  298. data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
  299. data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
  300. data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
  301. data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
  302. data/original/examples/employment/eclipse/readme.txt +0 -7
  303. data/original/examples/employment/employment_schema.exp +0 -33
  304. data/original/examples/employment/employment_schema.rb +0 -232
  305. data/original/examples/employment/employment_schema.xml +0 -93
  306. data/original/examples/employment/employment_schema___module.rb +0 -46
  307. data/original/examples/employment/employment_schema___p28attr.rb +0 -126
  308. data/original/examples/employment/employment_schema___p28inst.rb +0 -26
  309. data/original/examples/employment/example_employment_data.xml +0 -1
  310. data/original/examples/employment/example_employment_data_copy.xml +0 -1
  311. data/original/examples/employment/example_employment_reader.rb +0 -30
  312. data/original/examples/employment/example_employment_writer.rb +0 -51
  313. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
  314. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
  315. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
  316. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
  317. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
  318. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
  319. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
  320. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
  321. data/original/exp2ruby.rb +0 -525
  322. data/original/expsm.rb +0 -34
  323. data/original/mapping_owl.rb +0 -1018
  324. data/original/mapping_sysml.rb +0 -2281
  325. data/original/mapping_uml2.rb +0 -599
  326. data/original/mapping_uml2_eclipse.rb +0 -433
  327. data/original/reeper.rb +0 -134
  328. data/spec/expressr_spec.rb +0 -5
@@ -26,6 +26,7 @@
26
26
  #include "tree/ErrorNode.h"
27
27
 
28
28
  #include "support/CPPUtils.h"
29
+ #include "support/Casts.h"
29
30
 
30
31
  #include "ParserInterpreter.h"
31
32
 
@@ -35,19 +36,10 @@ using namespace antlr4::misc;
35
36
 
36
37
  using namespace antlrcpp;
37
38
 
38
- ParserInterpreter::ParserInterpreter(const std::string &grammarFileName, const std::vector<std::string>& tokenNames,
39
- const std::vector<std::string>& ruleNames, const atn::ATN &atn, TokenStream *input)
40
- : ParserInterpreter(grammarFileName, dfa::Vocabulary::fromTokenNames(tokenNames), ruleNames, atn, input) {
41
- }
42
-
43
39
  ParserInterpreter::ParserInterpreter(const std::string &grammarFileName, const dfa::Vocabulary &vocabulary,
44
40
  const std::vector<std::string> &ruleNames, const atn::ATN &atn, TokenStream *input)
45
41
  : Parser(input), _grammarFileName(grammarFileName), _atn(atn), _ruleNames(ruleNames), _vocabulary(vocabulary) {
46
42
 
47
- for (size_t i = 0; i < atn.maxTokenType; ++i) {
48
- _tokenNames.push_back(vocabulary.getDisplayName(i));
49
- }
50
-
51
43
  // init decision DFA
52
44
  for (size_t i = 0; i < atn.getNumberOfDecisions(); ++i) {
53
45
  atn::DecisionState *decisionState = atn.getDecisionState(i);
@@ -72,10 +64,6 @@ const atn::ATN& ParserInterpreter::getATN() const {
72
64
  return _atn;
73
65
  }
74
66
 
75
- const std::vector<std::string>& ParserInterpreter::getTokenNames() const {
76
- return _tokenNames;
77
- }
78
-
79
67
  const dfa::Vocabulary& ParserInterpreter::getVocabulary() const {
80
68
  return _vocabulary;
81
69
  }
@@ -102,7 +90,7 @@ ParserRuleContext* ParserInterpreter::parse(size_t startRuleIndex) {
102
90
  while (true) {
103
91
  atn::ATNState *p = getATNState();
104
92
  switch (p->getStateType()) {
105
- case atn::ATNState::RULE_STOP :
93
+ case atn::ATNStateType::RULE_STOP :
106
94
  // pop; return from rule
107
95
  if (_ctx->isEmpty()) {
108
96
  if (startRuleStartState->isLeftRecursiveRule) {
@@ -161,16 +149,16 @@ atn::ATNState* ParserInterpreter::getATNState() {
161
149
 
162
150
  void ParserInterpreter::visitState(atn::ATNState *p) {
163
151
  size_t predictedAlt = 1;
164
- if (is<DecisionState *>(p)) {
165
- predictedAlt = visitDecisionState(dynamic_cast<DecisionState *>(p));
152
+ if (DecisionState::is(p)) {
153
+ predictedAlt = visitDecisionState(downCast<DecisionState*>(p));
166
154
  }
167
155
 
168
- atn::Transition *transition = p->transitions[predictedAlt - 1];
169
- switch (transition->getSerializationType()) {
170
- case atn::Transition::EPSILON:
171
- if (p->getStateType() == ATNState::STAR_LOOP_ENTRY &&
172
- (dynamic_cast<StarLoopEntryState *>(p))->isPrecedenceDecision &&
173
- !is<LoopEndState *>(transition->target)) {
156
+ const atn::Transition *transition = p->transitions[predictedAlt - 1].get();
157
+ switch (transition->getTransitionType()) {
158
+ case atn::TransitionType::EPSILON:
159
+ if (p->getStateType() == ATNStateType::STAR_LOOP_ENTRY &&
160
+ (downCast<StarLoopEntryState *>(p))->isPrecedenceDecision &&
161
+ !LoopEndState::is(transition->target)) {
174
162
  // We are at the start of a left recursive rule's (...)* loop
175
163
  // and we're not taking the exit branch of loop.
176
164
  InterpreterRuleContext *localctx = createInterpreterRuleContext(_parentContextStack.top().first,
@@ -179,56 +167,56 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
179
167
  }
180
168
  break;
181
169
 
182
- case atn::Transition::ATOM:
183
- match(static_cast<int>(static_cast<atn::AtomTransition*>(transition)->_label));
170
+ case atn::TransitionType::ATOM:
171
+ match(static_cast<int>(static_cast<const atn::AtomTransition*>(transition)->_label));
184
172
  break;
185
173
 
186
- case atn::Transition::RANGE:
187
- case atn::Transition::SET:
188
- case atn::Transition::NOT_SET:
174
+ case atn::TransitionType::RANGE:
175
+ case atn::TransitionType::SET:
176
+ case atn::TransitionType::NOT_SET:
189
177
  if (!transition->matches(static_cast<int>(_input->LA(1)), Token::MIN_USER_TOKEN_TYPE, Lexer::MAX_CHAR_VALUE)) {
190
178
  recoverInline();
191
179
  }
192
180
  matchWildcard();
193
181
  break;
194
182
 
195
- case atn::Transition::WILDCARD:
183
+ case atn::TransitionType::WILDCARD:
196
184
  matchWildcard();
197
185
  break;
198
186
 
199
- case atn::Transition::RULE:
187
+ case atn::TransitionType::RULE:
200
188
  {
201
189
  atn::RuleStartState *ruleStartState = static_cast<atn::RuleStartState*>(transition->target);
202
190
  size_t ruleIndex = ruleStartState->ruleIndex;
203
191
  InterpreterRuleContext *newctx = createInterpreterRuleContext(_ctx, p->stateNumber, ruleIndex);
204
192
  if (ruleStartState->isLeftRecursiveRule) {
205
- enterRecursionRule(newctx, ruleStartState->stateNumber, ruleIndex, static_cast<atn::RuleTransition*>(transition)->precedence);
193
+ enterRecursionRule(newctx, ruleStartState->stateNumber, ruleIndex, static_cast<const atn::RuleTransition*>(transition)->precedence);
206
194
  } else {
207
195
  enterRule(newctx, transition->target->stateNumber, ruleIndex);
208
196
  }
209
197
  }
210
198
  break;
211
199
 
212
- case atn::Transition::PREDICATE:
200
+ case atn::TransitionType::PREDICATE:
213
201
  {
214
- atn::PredicateTransition *predicateTransition = static_cast<atn::PredicateTransition*>(transition);
215
- if (!sempred(_ctx, predicateTransition->ruleIndex, predicateTransition->predIndex)) {
202
+ const atn::PredicateTransition *predicateTransition = static_cast<const atn::PredicateTransition*>(transition);
203
+ if (!sempred(_ctx, predicateTransition->getRuleIndex(), predicateTransition->getPredIndex())) {
216
204
  throw FailedPredicateException(this);
217
205
  }
218
206
  }
219
207
  break;
220
208
 
221
- case atn::Transition::ACTION:
209
+ case atn::TransitionType::ACTION:
222
210
  {
223
- atn::ActionTransition *actionTransition = static_cast<atn::ActionTransition*>(transition);
211
+ const atn::ActionTransition *actionTransition = static_cast<const atn::ActionTransition*>(transition);
224
212
  action(_ctx, actionTransition->ruleIndex, actionTransition->actionIndex);
225
213
  }
226
214
  break;
227
215
 
228
- case atn::Transition::PRECEDENCE:
216
+ case atn::TransitionType::PRECEDENCE:
229
217
  {
230
- if (!precpred(_ctx, static_cast<atn::PrecedencePredicateTransition*>(transition)->precedence)) {
231
- throw FailedPredicateException(this, "precpred(_ctx, " + std::to_string(static_cast<atn::PrecedencePredicateTransition*>(transition)->precedence) + ")");
218
+ if (!precpred(_ctx, static_cast<const atn::PrecedencePredicateTransition*>(transition)->getPrecedence())) {
219
+ throw FailedPredicateException(this, "precpred(_ctx, " + std::to_string(static_cast<const atn::PrecedencePredicateTransition*>(transition)->getPrecedence()) + ")");
232
220
  }
233
221
  }
234
222
  break;
@@ -272,7 +260,7 @@ void ParserInterpreter::visitRuleStopState(atn::ATNState *p) {
272
260
  exitRule();
273
261
  }
274
262
 
275
- atn::RuleTransition *ruleTransition = static_cast<atn::RuleTransition*>(_atn.states[getState()]->transitions[0]);
263
+ const atn::RuleTransition *ruleTransition = static_cast<const atn::RuleTransition*>(_atn.states[getState()]->transitions[0].get());
276
264
  setState(ruleTransition->followState->stateNumber);
277
265
  }
278
266
 
@@ -9,6 +9,7 @@
9
9
  #include "atn/ATN.h"
10
10
  #include "support/BitSet.h"
11
11
  #include "atn/PredictionContext.h"
12
+ #include "atn/PredictionContextCache.h"
12
13
  #include "Vocabulary.h"
13
14
 
14
15
  namespace antlr4 {
@@ -29,9 +30,6 @@ namespace antlr4 {
29
30
  /// </summary>
30
31
  class ANTLR4CPP_PUBLIC ParserInterpreter : public Parser {
31
32
  public:
32
- // @deprecated
33
- ParserInterpreter(const std::string &grammarFileName, const std::vector<std::string>& tokenNames,
34
- const std::vector<std::string>& ruleNames, const atn::ATN &atn, TokenStream *input);
35
33
  ParserInterpreter(const std::string &grammarFileName, const dfa::Vocabulary &vocabulary,
36
34
  const std::vector<std::string> &ruleNames, const atn::ATN &atn, TokenStream *input);
37
35
  ~ParserInterpreter();
@@ -40,9 +38,6 @@ namespace antlr4 {
40
38
 
41
39
  virtual const atn::ATN& getATN() const override;
42
40
 
43
- // @deprecated
44
- virtual const std::vector<std::string>& getTokenNames() const override;
45
-
46
41
  virtual const dfa::Vocabulary& getVocabulary() const override;
47
42
 
48
43
  virtual const std::vector<std::string>& getRuleNames() const override;
@@ -110,7 +105,6 @@ namespace antlr4 {
110
105
 
111
106
  protected:
112
107
  const std::string _grammarFileName;
113
- std::vector<std::string> _tokenNames;
114
108
  const atn::ATN &_atn;
115
109
 
116
110
  std::vector<std::string> _ruleNames;
@@ -9,6 +9,7 @@
9
9
  #include "Parser.h"
10
10
  #include "Token.h"
11
11
 
12
+ #include "support/Casts.h"
12
13
  #include "support/CPPUtils.h"
13
14
 
14
15
  #include "ParserRuleContext.h"
@@ -38,11 +39,10 @@ void ParserRuleContext::copyFrom(ParserRuleContext *ctx) {
38
39
 
39
40
  // copy any error nodes to alt label node
40
41
  if (!ctx->children.empty()) {
41
- for (auto child : ctx->children) {
42
- auto errorNode = dynamic_cast<ErrorNode *>(child);
43
- if (errorNode != nullptr) {
44
- errorNode->setParent(this);
45
- children.push_back(errorNode);
42
+ for (auto *child : ctx->children) {
43
+ if (ErrorNode::is(child)) {
44
+ downCast<ErrorNode*>(child)->setParent(this);
45
+ children.push_back(child);
46
46
  }
47
47
  }
48
48
 
@@ -76,39 +76,36 @@ void ParserRuleContext::removeLastChild() {
76
76
  }
77
77
  }
78
78
 
79
- tree::TerminalNode* ParserRuleContext::getToken(size_t ttype, size_t i) {
79
+ tree::TerminalNode* ParserRuleContext::getToken(size_t ttype, size_t i) const {
80
80
  if (i >= children.size()) {
81
81
  return nullptr;
82
82
  }
83
-
84
83
  size_t j = 0; // what token with ttype have we found?
85
- for (auto o : children) {
86
- if (is<tree::TerminalNode *>(o)) {
87
- tree::TerminalNode *tnode = dynamic_cast<tree::TerminalNode *>(o);
88
- Token *symbol = tnode->getSymbol();
84
+ for (auto *child : children) {
85
+ if (TerminalNode::is(child)) {
86
+ tree::TerminalNode *typedChild = downCast<tree::TerminalNode*>(child);
87
+ Token *symbol = typedChild->getSymbol();
89
88
  if (symbol->getType() == ttype) {
90
89
  if (j++ == i) {
91
- return tnode;
90
+ return typedChild;
92
91
  }
93
92
  }
94
93
  }
95
94
  }
96
-
97
95
  return nullptr;
98
96
  }
99
97
 
100
- std::vector<tree::TerminalNode *> ParserRuleContext::getTokens(size_t ttype) {
101
- std::vector<tree::TerminalNode *> tokens;
102
- for (auto &o : children) {
103
- if (is<tree::TerminalNode *>(o)) {
104
- tree::TerminalNode *tnode = dynamic_cast<tree::TerminalNode *>(o);
105
- Token *symbol = tnode->getSymbol();
98
+ std::vector<tree::TerminalNode *> ParserRuleContext::getTokens(size_t ttype) const {
99
+ std::vector<tree::TerminalNode*> tokens;
100
+ for (auto *child : children) {
101
+ if (TerminalNode::is(child)) {
102
+ tree::TerminalNode *typedChild = downCast<tree::TerminalNode*>(child);
103
+ Token *symbol = typedChild->getSymbol();
106
104
  if (symbol->getType() == ttype) {
107
- tokens.push_back(tnode);
105
+ tokens.push_back(typedChild);
108
106
  }
109
107
  }
110
108
  }
111
-
112
109
  return tokens;
113
110
  }
114
111
 
@@ -123,11 +120,11 @@ misc::Interval ParserRuleContext::getSourceInterval() {
123
120
  return misc::Interval(start->getTokenIndex(), stop->getTokenIndex());
124
121
  }
125
122
 
126
- Token* ParserRuleContext::getStart() {
123
+ Token* ParserRuleContext::getStart() const {
127
124
  return start;
128
125
  }
129
126
 
130
- Token* ParserRuleContext::getStop() {
127
+ Token* ParserRuleContext::getStop() const {
131
128
  return stop;
132
129
  }
133
130
 
@@ -67,7 +67,6 @@ namespace antlr4 {
67
67
 
68
68
  ParserRuleContext();
69
69
  ParserRuleContext(ParserRuleContext *parent, size_t invokingStateNumber);
70
- virtual ~ParserRuleContext() {}
71
70
 
72
71
  /** COPY a ctx (I'm deliberately not using copy constructor) to avoid
73
72
  * confusion with creating node with parent. Does not copy children
@@ -88,23 +87,22 @@ namespace antlr4 {
88
87
  /// Used by enterOuterAlt to toss out a RuleContext previously added as
89
88
  /// we entered a rule. If we have # label, we will need to remove
90
89
  /// generic ruleContext object.
91
- virtual void removeLastChild();
90
+ void removeLastChild();
92
91
 
93
- virtual tree::TerminalNode* getToken(size_t ttype, std::size_t i);
92
+ tree::TerminalNode* getToken(size_t ttype, std::size_t i) const;
94
93
 
95
- virtual std::vector<tree::TerminalNode *> getTokens(size_t ttype);
94
+ std::vector<tree::TerminalNode*> getTokens(size_t ttype) const;
96
95
 
97
96
  template<typename T>
98
- T* getRuleContext(size_t i) {
99
- if (children.empty()) {
100
- return nullptr;
101
- }
102
-
97
+ T* getRuleContext(size_t i) const {
98
+ static_assert(std::is_base_of_v<RuleContext, T>, "T must be derived from RuleContext");
103
99
  size_t j = 0; // what element have we found with ctxType?
104
- for (auto &child : children) {
105
- if (antlrcpp::is<T *>(child)) {
106
- if (j++ == i) {
107
- return dynamic_cast<T *>(child);
100
+ for (auto *child : children) {
101
+ if (RuleContext::is(child)) {
102
+ if (auto *typedChild = dynamic_cast<T*>(child); typedChild != nullptr) {
103
+ if (j++ == i) {
104
+ return typedChild;
105
+ }
108
106
  }
109
107
  }
110
108
  }
@@ -112,14 +110,16 @@ namespace antlr4 {
112
110
  }
113
111
 
114
112
  template<typename T>
115
- std::vector<T *> getRuleContexts() {
116
- std::vector<T *> contexts;
117
- for (auto child : children) {
118
- if (antlrcpp::is<T *>(child)) {
119
- contexts.push_back(dynamic_cast<T *>(child));
113
+ std::vector<T*> getRuleContexts() const {
114
+ static_assert(std::is_base_of_v<RuleContext, T>, "T must be derived from RuleContext");
115
+ std::vector<T*> contexts;
116
+ for (auto *child : children) {
117
+ if (RuleContext::is(child)) {
118
+ if (auto *typedChild = dynamic_cast<T*>(child); typedChild != nullptr) {
119
+ contexts.push_back(typedChild);
120
+ }
120
121
  }
121
122
  }
122
-
123
123
  return contexts;
124
124
  }
125
125
 
@@ -130,14 +130,14 @@ namespace antlr4 {
130
130
  * Note that the range from start to stop is inclusive, so for rules that do not consume anything
131
131
  * (for example, zero length or error productions) this token may exceed stop.
132
132
  */
133
- virtual Token *getStart();
133
+ Token* getStart() const;
134
134
 
135
135
  /**
136
136
  * Get the final token in this context.
137
137
  * Note that the range from start to stop is inclusive, so for rules that do not consume anything
138
138
  * (for example, zero length or error productions) this token may precede start.
139
139
  */
140
- virtual Token *getStop();
140
+ Token* getStop() const;
141
141
 
142
142
  /// <summary>
143
143
  /// Used for rule context info debugging during parse-time, not so much for ATN debugging </summary>
@@ -26,28 +26,28 @@ void ProxyErrorListener::removeErrorListeners() {
26
26
  void ProxyErrorListener::syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line,
27
27
  size_t charPositionInLine, const std::string &msg, std::exception_ptr e) {
28
28
 
29
- for (auto listener : _delegates) {
29
+ for (auto *listener : _delegates) {
30
30
  listener->syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
31
31
  }
32
32
  }
33
33
 
34
34
  void ProxyErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
35
35
  bool exact, const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) {
36
- for (auto listener : _delegates) {
36
+ for (auto *listener : _delegates) {
37
37
  listener->reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
38
38
  }
39
39
  }
40
40
 
41
41
  void ProxyErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
42
42
  size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) {
43
- for (auto listener : _delegates) {
43
+ for (auto *listener : _delegates) {
44
44
  listener->reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
45
45
  }
46
46
  }
47
47
 
48
48
  void ProxyErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
49
49
  size_t prediction, atn::ATNConfigSet *configs) {
50
- for (auto listener : _delegates) {
50
+ for (auto *listener : _delegates) {
51
51
  listener->reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
52
52
  }
53
53
  }
@@ -5,7 +5,6 @@
5
5
 
6
6
  #include "atn/ATN.h"
7
7
  #include "Recognizer.h"
8
- #include "support/StringUtils.h"
9
8
  #include "ParserRuleContext.h"
10
9
  #include "misc/IntervalSet.h"
11
10
 
@@ -6,11 +6,11 @@
6
6
  #include "ConsoleErrorListener.h"
7
7
  #include "RecognitionException.h"
8
8
  #include "support/CPPUtils.h"
9
- #include "support/StringUtils.h"
10
9
  #include "Token.h"
11
10
  #include "atn/ATN.h"
12
11
  #include "atn/ATNSimulator.h"
13
12
  #include "support/CPPUtils.h"
13
+ #include "support/StringUtils.h"
14
14
 
15
15
  #include "Vocabulary.h"
16
16
 
@@ -19,7 +19,7 @@
19
19
  using namespace antlr4;
20
20
  using namespace antlr4::atn;
21
21
 
22
- std::map<const dfa::Vocabulary*, std::map<std::string, size_t>> Recognizer::_tokenTypeMapCache;
22
+ std::map<const dfa::Vocabulary*, std::map<std::string_view, size_t>> Recognizer::_tokenTypeMapCache;
23
23
  std::map<std::vector<std::string>, std::map<std::string, size_t>> Recognizer::_ruleIndexMapCache;
24
24
 
25
25
  Recognizer::Recognizer() {
@@ -30,31 +30,26 @@ Recognizer::Recognizer() {
30
30
  Recognizer::~Recognizer() {
31
31
  }
32
32
 
33
- dfa::Vocabulary const& Recognizer::getVocabulary() const {
34
- static dfa::Vocabulary vocabulary = dfa::Vocabulary::fromTokenNames(getTokenNames());
35
- return vocabulary;
36
- }
37
-
38
- std::map<std::string, size_t> Recognizer::getTokenTypeMap() {
33
+ std::map<std::string_view, size_t> Recognizer::getTokenTypeMap() {
39
34
  const dfa::Vocabulary& vocabulary = getVocabulary();
40
35
 
41
36
  std::lock_guard<std::mutex> lck(_mutex);
42
- std::map<std::string, size_t> result;
37
+ std::map<std::string_view, size_t> result;
43
38
  auto iterator = _tokenTypeMapCache.find(&vocabulary);
44
39
  if (iterator != _tokenTypeMapCache.end()) {
45
40
  result = iterator->second;
46
41
  } else {
47
42
  for (size_t i = 0; i <= getATN().maxTokenType; ++i) {
48
- std::string literalName = vocabulary.getLiteralName(i);
43
+ std::string_view literalName = vocabulary.getLiteralName(i);
49
44
  if (!literalName.empty()) {
50
45
  result[literalName] = i;
51
46
  }
52
47
 
53
- std::string symbolicName = vocabulary.getSymbolicName(i);
48
+ std::string_view symbolicName = vocabulary.getSymbolicName(i);
54
49
  if (!symbolicName.empty()) {
55
50
  result[symbolicName] = i;
56
51
  }
57
- }
52
+ }
58
53
  result["EOF"] = EOF;
59
54
  _tokenTypeMapCache[&vocabulary] = result;
60
55
  }
@@ -80,8 +75,8 @@ std::map<std::string, size_t> Recognizer::getRuleIndexMap() {
80
75
  return result;
81
76
  }
82
77
 
83
- size_t Recognizer::getTokenType(const std::string &tokenName) {
84
- const std::map<std::string, size_t> &map = getTokenTypeMap();
78
+ size_t Recognizer::getTokenType(std::string_view tokenName) {
79
+ const std::map<std::string_view, size_t> &map = getTokenTypeMap();
85
80
  auto iterator = map.find(tokenName);
86
81
  if (iterator == map.end())
87
82
  return Token::INVALID_TYPE;
@@ -118,11 +113,13 @@ std::string Recognizer::getTokenErrorDisplay(Token *t) {
118
113
  }
119
114
  }
120
115
 
121
- antlrcpp::replaceAll(s, "\n", "\\n");
122
- antlrcpp::replaceAll(s, "\r","\\r");
123
- antlrcpp::replaceAll(s, "\t", "\\t");
124
-
125
- return "'" + s + "'";
116
+ std::string result;
117
+ result.reserve(s.size() + 2);
118
+ result.push_back('\'');
119
+ antlrcpp::escapeWhitespace(result, s);
120
+ result.push_back('\'');
121
+ result.shrink_to_fit();
122
+ return result;
126
123
  }
127
124
 
128
125
  void Recognizer::addErrorListener(ANTLRErrorListener *listener) {
@@ -152,14 +149,6 @@ bool Recognizer::precpred(RuleContext * /*localctx*/, int /*precedence*/) {
152
149
  void Recognizer::action(RuleContext * /*localctx*/, size_t /*ruleIndex*/, size_t /*actionIndex*/) {
153
150
  }
154
151
 
155
- size_t Recognizer::getState() const {
156
- return _stateNumber;
157
- }
158
-
159
- void Recognizer::setState(size_t atnState) {
160
- _stateNumber = atnState;
161
- }
162
-
163
152
  void Recognizer::InitializeInstanceFields() {
164
153
  _stateNumber = ATNState::INVALID_STATE_NUMBER;
165
154
  _interpreter = nullptr;
@@ -6,12 +6,14 @@
6
6
  #pragma once
7
7
 
8
8
  #include "ProxyErrorListener.h"
9
+ #include "support/Casts.h"
10
+ #include "atn/SerializedATNView.h"
9
11
 
10
12
  namespace antlr4 {
11
13
 
12
14
  class ANTLR4CPP_PUBLIC Recognizer {
13
15
  public:
14
- static const size_t EOF = static_cast<size_t>(-1); // std::numeric_limits<size_t>::max(); doesn't work in VS 2013.
16
+ static constexpr size_t EOF = std::numeric_limits<size_t>::max();
15
17
 
16
18
  Recognizer();
17
19
  Recognizer(Recognizer const&) = delete;
@@ -19,13 +21,6 @@ namespace antlr4 {
19
21
 
20
22
  Recognizer& operator=(Recognizer const&) = delete;
21
23
 
22
- /** Used to print out token names like ID during debugging and
23
- * error reporting. The generated parsers implement a method
24
- * that overrides this to point to their String[] tokenNames.
25
- *
26
- * @deprecated Use {@link #getVocabulary()} instead.
27
- */
28
- virtual std::vector<std::string> const& getTokenNames() const = 0;
29
24
  virtual std::vector<std::string> const& getRuleNames() const = 0;
30
25
 
31
26
  /**
@@ -34,14 +29,14 @@ namespace antlr4 {
34
29
  * @return A {@link Vocabulary} instance providing information about the
35
30
  * vocabulary used by the grammar.
36
31
  */
37
- virtual dfa::Vocabulary const& getVocabulary() const;
32
+ virtual dfa::Vocabulary const& getVocabulary() const = 0;
38
33
 
39
34
  /// <summary>
40
35
  /// Get a map from token names to token types.
41
36
  /// <p/>
42
37
  /// Used for XPath and tree pattern compilation.
43
38
  /// </summary>
44
- virtual std::map<std::string, size_t> getTokenTypeMap();
39
+ virtual std::map<std::string_view, size_t> getTokenTypeMap();
45
40
 
46
41
  /// <summary>
47
42
  /// Get a map from rule names to rule indexes.
@@ -50,7 +45,7 @@ namespace antlr4 {
50
45
  /// </summary>
51
46
  virtual std::map<std::string, size_t> getRuleIndexMap();
52
47
 
53
- virtual size_t getTokenType(const std::string &tokenName);
48
+ virtual size_t getTokenType(std::string_view tokenName);
54
49
 
55
50
  /// <summary>
56
51
  /// If this recognizer was generated, it will have a serialized ATN
@@ -59,7 +54,7 @@ namespace antlr4 {
59
54
  /// For interpreters, we don't know their serialized ATN despite having
60
55
  /// created the interpreter from it.
61
56
  /// </summary>
62
- virtual const std::vector<uint16_t> getSerializedATN() const {
57
+ virtual atn::SerializedATNView getSerializedATN() const {
63
58
  throw "there is no serialized ATN";
64
59
  }
65
60
 
@@ -73,7 +68,7 @@ namespace antlr4 {
73
68
  /// @returns The ATN interpreter used by the recognizer for prediction.
74
69
  template <class T>
75
70
  T* getInterpreter() const {
76
- return dynamic_cast<T *>(_interpreter);
71
+ return antlrcpp::downCast<T *>(_interpreter);
77
72
  }
78
73
 
79
74
  /**
@@ -119,7 +114,7 @@ namespace antlr4 {
119
114
 
120
115
  virtual void action(RuleContext *localctx, size_t ruleIndex, size_t actionIndex);
121
116
 
122
- virtual size_t getState() const ;
117
+ size_t getState() const { return _stateNumber; }
123
118
 
124
119
  // Get the ATN used by the recognizer for prediction.
125
120
  virtual const atn::ATN& getATN() const = 0;
@@ -132,13 +127,13 @@ namespace antlr4 {
132
127
  /// invoking rules. Combine this and we have complete ATN
133
128
  /// configuration information.
134
129
  /// </summary>
135
- void setState(size_t atnState);
130
+ void setState(size_t atnState) { _stateNumber = atnState; }
136
131
 
137
132
  virtual IntStream* getInputStream() = 0;
138
133
 
139
134
  virtual void setInputStream(IntStream *input) = 0;
140
135
 
141
- virtual Ref<TokenFactory<CommonToken>> getTokenFactory() = 0;
136
+ virtual TokenFactory<CommonToken>* getTokenFactory() = 0;
142
137
 
143
138
  template<typename T1>
144
139
  void setTokenFactory(TokenFactory<T1> *input);
@@ -150,7 +145,7 @@ namespace antlr4 {
150
145
  std::mutex _mutex;
151
146
 
152
147
  private:
153
- static std::map<const dfa::Vocabulary*, std::map<std::string, size_t>> _tokenTypeMapCache;
148
+ static std::map<const dfa::Vocabulary*, std::map<std::string_view, size_t>> _tokenTypeMapCache;
154
149
  static std::map<std::vector<std::string>, std::map<std::string, size_t>> _ruleIndexMapCache;
155
150
 
156
151
  ProxyErrorListener _proxListener; // Manages a collection of listeners.
@@ -14,12 +14,13 @@
14
14
 
15
15
  using namespace antlr4;
16
16
  using namespace antlr4::atn;
17
+ using namespace antlr4::tree;
17
18
 
18
- RuleContext::RuleContext() {
19
+ RuleContext::RuleContext() : ParseTree(ParseTreeType::RULE) {
19
20
  InitializeInstanceFields();
20
21
  }
21
22
 
22
- RuleContext::RuleContext(RuleContext *parent_, size_t invokingState_) {
23
+ RuleContext::RuleContext(RuleContext *parent_, size_t invokingState_) : ParseTree(ParseTreeType::RULE) {
23
24
  InitializeInstanceFields();
24
25
  this->parent = parent_;
25
26
  this->invokingState = invokingState_;
@@ -71,7 +72,7 @@ size_t RuleContext::getAltNumber() const {
71
72
  void RuleContext::setAltNumber(size_t /*altNumber*/) {
72
73
  }
73
74
 
74
- antlrcpp::Any RuleContext::accept(tree::ParseTreeVisitor *visitor) {
75
+ std::any RuleContext::accept(tree::ParseTreeVisitor *visitor) {
75
76
  return visitor->visitChildren(this);
76
77
  }
77
78
 
@@ -61,6 +61,10 @@ namespace antlr4 {
61
61
  */
62
62
  class ANTLR4CPP_PUBLIC RuleContext : public tree::ParseTree {
63
63
  public:
64
+ static bool is(const tree::ParseTree &parseTree) { return parseTree.getTreeType() == tree::ParseTreeType::RULE; }
65
+
66
+ static bool is(const tree::ParseTree *parseTree) { return parseTree != nullptr && is(*parseTree); }
67
+
64
68
  /// What state invoked the rule associated with this context?
65
69
  /// The "return address" is the followState of invokingState
66
70
  /// If parent is null, this should be -1 and this context object represents the start rule.
@@ -103,7 +107,7 @@ namespace antlr4 {
103
107
  */
104
108
  virtual void setAltNumber(size_t altNumber);
105
109
 
106
- virtual antlrcpp::Any accept(tree::ParseTreeVisitor *visitor) override;
110
+ virtual std::any accept(tree::ParseTreeVisitor *visitor) override;
107
111
 
108
112
  /// <summary>
109
113
  /// Print out a whole tree, not just a node, in LISP format