expressir 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +0 -6
  3. data/.github/workflows/rake.yml +200 -9
  4. data/.gitignore +7 -2
  5. data/.gitmodules +3 -0
  6. data/.rubocop.yml +13 -4
  7. data/Rakefile +4 -1
  8. data/bin/console +0 -1
  9. data/bin/rspec +3 -3
  10. data/exe/expressir +4 -2
  11. data/exe/format +1 -1
  12. data/exe/format-test +25 -25
  13. data/exe/generate-parser +16 -13
  14. data/expressir.gemspec +11 -9
  15. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
  16. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
  17. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
  18. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
  19. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
  20. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
  21. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
  22. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
  23. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
  24. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
  25. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
  26. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
  27. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
  28. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
  29. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
  30. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
  31. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
  32. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
  33. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
  34. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
  35. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
  36. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
  37. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
  38. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
  39. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
  40. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
  41. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
  42. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
  43. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
  44. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
  45. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
  46. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
  47. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
  48. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
  49. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
  50. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
  51. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
  52. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
  53. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
  54. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
  55. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
  56. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
  57. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
  58. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
  59. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
  60. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
  61. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
  62. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
  63. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
  64. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
  65. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
  66. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
  67. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
  68. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
  69. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
  70. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
  71. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
  72. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
  73. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
  74. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
  75. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
  76. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
  77. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
  78. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
  79. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
  80. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
  81. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
  82. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
  83. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
  84. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
  85. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
  86. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
  87. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
  88. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
  89. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
  90. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
  91. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
  92. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
  93. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
  94. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
  95. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
  96. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
  97. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
  98. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
  99. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
  100. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
  101. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
  102. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
  103. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
  104. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
  105. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
  106. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
  107. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
  108. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
  109. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
  110. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
  111. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
  112. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
  113. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
  114. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
  115. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
  116. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
  117. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
  118. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
  119. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
  120. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
  121. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
  122. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
  123. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
  124. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
  125. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
  126. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
  127. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
  128. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
  129. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
  130. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
  131. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
  132. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
  133. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
  134. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
  135. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
  136. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
  137. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
  138. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
  139. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
  140. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
  141. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
  142. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
  143. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
  144. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
  145. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
  146. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
  147. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
  148. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
  149. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
  150. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
  151. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
  152. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
  153. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
  154. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
  155. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
  156. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
  157. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
  158. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
  159. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
  160. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
  161. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
  162. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
  163. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
  164. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
  165. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
  166. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
  167. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
  168. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
  169. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
  170. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
  171. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
  172. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
  173. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
  174. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
  175. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
  176. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
  177. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
  178. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
  179. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
  180. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
  181. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
  182. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
  183. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
  184. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
  185. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
  186. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
  187. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
  188. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
  189. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
  190. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
  221. data/ext/express-parser/antlrgen/Express.interp +1 -1
  222. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
  223. data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
  224. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
  225. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
  226. data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
  227. data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
  228. data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
  229. data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
  230. data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
  231. data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
  232. data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
  233. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
  234. data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
  235. data/ext/express-parser/express_parser.cpp +207 -75
  236. data/ext/express-parser/extconf.rb +10 -9
  237. data/lib/expressir/config.rb +1 -1
  238. data/lib/expressir/express/parser.rb +2 -2
  239. data/lib/expressir/express/visitor.rb +7 -5
  240. data/lib/expressir/model.rb +78 -78
  241. data/lib/expressir/version.rb +1 -1
  242. data/rakelib/antlr4-native.rake +63 -0
  243. data/rakelib/cross-ruby.rake +213 -162
  244. data/spec/acceptance/version_spec.rb +7 -2
  245. data/spec/expressir/express/cache_spec.rb +8 -5
  246. data/spec/expressir/express/formatter_spec.rb +16 -8
  247. data/spec/expressir/express/parser_spec.rb +17 -11
  248. data/spec/expressir/model/model_element_spec.rb +154 -146
  249. metadata +79 -91
  250. data/demo.rb +0 -18
  251. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
  252. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
  253. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
  254. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
  255. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
  256. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
  257. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
  258. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
  259. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
  260. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
  261. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
  262. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
  263. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
  264. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
  265. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
  266. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
  267. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
  268. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
  274. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
  275. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
  276. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
  277. data/original/examples/employment/eclipse/.project +0 -17
  278. data/original/examples/employment/eclipse/Export/Employment.png +0 -0
  279. data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
  280. data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
  281. data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
  282. data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
  283. data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
  284. data/original/examples/employment/eclipse/readme.txt +0 -7
  285. data/original/examples/employment/employment_schema.exp +0 -33
  286. data/original/examples/employment/employment_schema.rb +0 -232
  287. data/original/examples/employment/employment_schema.xml +0 -93
  288. data/original/examples/employment/employment_schema___module.rb +0 -46
  289. data/original/examples/employment/employment_schema___p28attr.rb +0 -126
  290. data/original/examples/employment/employment_schema___p28inst.rb +0 -26
  291. data/original/examples/employment/example_employment_data.xml +0 -1
  292. data/original/examples/employment/example_employment_data_copy.xml +0 -1
  293. data/original/examples/employment/example_employment_reader.rb +0 -30
  294. data/original/examples/employment/example_employment_writer.rb +0 -51
  295. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
  296. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
  297. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
  298. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
  299. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
  300. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
  301. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
  302. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
  303. data/original/exp2ruby.rb +0 -525
  304. data/original/expsm.rb +0 -34
  305. data/original/mapping_owl.rb +0 -1018
  306. data/original/mapping_sysml.rb +0 -2281
  307. data/original/mapping_uml2.rb +0 -599
  308. data/original/mapping_uml2_eclipse.rb +0 -433
  309. data/original/reeper.rb +0 -134
  310. data/spec/expressr_spec.rb +0 -5
@@ -6,18 +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
- #if __cplusplus >= 201703L
15
16
  static constexpr size_t EOF = std::numeric_limits<size_t>::max();
16
- #else
17
- enum : size_t {
18
- EOF = static_cast<size_t>(-1), // std::numeric_limits<size_t>::max(); doesn't work in VS 2013.
19
- };
20
- #endif
21
17
 
22
18
  Recognizer();
23
19
  Recognizer(Recognizer const&) = delete;
@@ -25,13 +21,6 @@ namespace antlr4 {
25
21
 
26
22
  Recognizer& operator=(Recognizer const&) = delete;
27
23
 
28
- /** Used to print out token names like ID during debugging and
29
- * error reporting. The generated parsers implement a method
30
- * that overrides this to point to their String[] tokenNames.
31
- *
32
- * @deprecated Use {@link #getVocabulary()} instead.
33
- */
34
- virtual std::vector<std::string> const& getTokenNames() const = 0;
35
24
  virtual std::vector<std::string> const& getRuleNames() const = 0;
36
25
 
37
26
  /**
@@ -40,14 +29,14 @@ namespace antlr4 {
40
29
  * @return A {@link Vocabulary} instance providing information about the
41
30
  * vocabulary used by the grammar.
42
31
  */
43
- virtual dfa::Vocabulary const& getVocabulary() const;
32
+ virtual dfa::Vocabulary const& getVocabulary() const = 0;
44
33
 
45
34
  /// <summary>
46
35
  /// Get a map from token names to token types.
47
36
  /// <p/>
48
37
  /// Used for XPath and tree pattern compilation.
49
38
  /// </summary>
50
- virtual std::map<std::string, size_t> getTokenTypeMap();
39
+ virtual std::map<std::string_view, size_t> getTokenTypeMap();
51
40
 
52
41
  /// <summary>
53
42
  /// Get a map from rule names to rule indexes.
@@ -56,7 +45,7 @@ namespace antlr4 {
56
45
  /// </summary>
57
46
  virtual std::map<std::string, size_t> getRuleIndexMap();
58
47
 
59
- virtual size_t getTokenType(const std::string &tokenName);
48
+ virtual size_t getTokenType(std::string_view tokenName);
60
49
 
61
50
  /// <summary>
62
51
  /// If this recognizer was generated, it will have a serialized ATN
@@ -65,7 +54,7 @@ namespace antlr4 {
65
54
  /// For interpreters, we don't know their serialized ATN despite having
66
55
  /// created the interpreter from it.
67
56
  /// </summary>
68
- virtual const std::vector<uint16_t> getSerializedATN() const {
57
+ virtual atn::SerializedATNView getSerializedATN() const {
69
58
  throw "there is no serialized ATN";
70
59
  }
71
60
 
@@ -79,7 +68,7 @@ namespace antlr4 {
79
68
  /// @returns The ATN interpreter used by the recognizer for prediction.
80
69
  template <class T>
81
70
  T* getInterpreter() const {
82
- return dynamic_cast<T *>(_interpreter);
71
+ return antlrcpp::downCast<T *>(_interpreter);
83
72
  }
84
73
 
85
74
  /**
@@ -125,7 +114,7 @@ namespace antlr4 {
125
114
 
126
115
  virtual void action(RuleContext *localctx, size_t ruleIndex, size_t actionIndex);
127
116
 
128
- virtual size_t getState() const ;
117
+ size_t getState() const { return _stateNumber; }
129
118
 
130
119
  // Get the ATN used by the recognizer for prediction.
131
120
  virtual const atn::ATN& getATN() const = 0;
@@ -138,7 +127,7 @@ namespace antlr4 {
138
127
  /// invoking rules. Combine this and we have complete ATN
139
128
  /// configuration information.
140
129
  /// </summary>
141
- void setState(size_t atnState);
130
+ void setState(size_t atnState) { _stateNumber = atnState; }
142
131
 
143
132
  virtual IntStream* getInputStream() = 0;
144
133
 
@@ -156,7 +145,7 @@ namespace antlr4 {
156
145
  std::mutex _mutex;
157
146
 
158
147
  private:
159
- 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;
160
149
  static std::map<std::vector<std::string>, std::map<std::string, size_t>> _ruleIndexMapCache;
161
150
 
162
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
@@ -4,10 +4,11 @@
4
4
  */
5
5
 
6
6
  #include "RuntimeMetaData.h"
7
+ #include "Version.h"
7
8
 
8
9
  using namespace antlr4;
9
10
 
10
- const std::string RuntimeMetaData::VERSION = "4.9.2";
11
+ const std::string RuntimeMetaData::VERSION = ANTLRCPP_VERSION_STRING;
11
12
 
12
13
  std::string RuntimeMetaData::getRuntimeVersion() {
13
14
  return VERSION;
@@ -14,50 +14,24 @@ namespace antlr4 {
14
14
  /// we obtained this token.
15
15
  class ANTLR4CPP_PUBLIC Token {
16
16
  public:
17
- #if __cplusplus >= 201703L
18
17
  static constexpr size_t INVALID_TYPE = 0;
19
- #else
20
- enum : size_t {
21
- INVALID_TYPE = 0,
22
- };
23
- #endif
24
18
 
25
19
  /// During lookahead operations, this "token" signifies we hit rule end ATN state
26
20
  /// and did not follow it despite needing to.
27
- #if __cplusplus >= 201703L
28
21
  static constexpr size_t EPSILON = std::numeric_limits<size_t>::max() - 1;
29
22
  static constexpr size_t MIN_USER_TOKEN_TYPE = 1;
30
23
  static constexpr size_t EOF = IntStream::EOF;
31
- #else
32
- enum : size_t {
33
- EPSILON = static_cast<size_t>(-2), // std::numeric_limits<size_t>::max() - 1; doesn't work in VS 2013
34
- MIN_USER_TOKEN_TYPE = 1,
35
- EOF = IntStream::EOF,
36
- };
37
- #endif
38
24
 
39
25
  virtual ~Token();
40
26
 
41
27
  /// All tokens go to the parser (unless skip() is called in that rule)
42
28
  /// on a particular "channel". The parser tunes to a particular channel
43
29
  /// so that whitespace etc... can go to the parser on a "hidden" channel.
44
- #if __cplusplus >= 201703L
45
30
  static constexpr size_t DEFAULT_CHANNEL = 0;
46
- #else
47
- enum : size_t {
48
- DEFAULT_CHANNEL = 0,
49
- };
50
- #endif
51
31
 
52
32
  /// Anything on different channel than DEFAULT_CHANNEL is not parsed
53
33
  /// by parser.
54
- #if __cplusplus >= 201703L
55
34
  static constexpr size_t HIDDEN_CHANNEL = 1;
56
- #else
57
- enum : size_t {
58
- HIDDEN_CHANNEL = 1,
59
- };
60
- #endif
61
35
 
62
36
  /**
63
37
  * This is the minimum constant value which can be assigned to a
@@ -70,13 +44,7 @@ namespace antlr4 {
70
44
  *
71
45
  * @see Token#getChannel()
72
46
  */
73
- #if __cplusplus >= 201703L
74
47
  static constexpr size_t MIN_USER_CHANNEL_VALUE = 2;
75
- #else
76
- enum : size_t {
77
- MIN_USER_CHANNEL_VALUE = 2,
78
- };
79
- #endif
80
48
 
81
49
  /// Get the text of the token.
82
50
  virtual std::string getText() const = 0;
@@ -93,7 +93,7 @@ TokenStreamRewriter::TokenStreamRewriter(TokenStream *tokens_) : tokens(tokens_)
93
93
  }
94
94
 
95
95
  TokenStreamRewriter::~TokenStreamRewriter() {
96
- for (auto program : _programs) {
96
+ for (const auto &program : _programs) {
97
97
  for (auto *operation : program.second) {
98
98
  delete operation;
99
99
  }
@@ -5,6 +5,8 @@
5
5
 
6
6
  #pragma once
7
7
 
8
+ #include "antlr4-common.h"
9
+
8
10
  namespace antlr4 {
9
11
 
10
12
  /**
@@ -86,15 +88,8 @@ namespace antlr4 {
86
88
  class ANTLR4CPP_PUBLIC TokenStreamRewriter {
87
89
  public:
88
90
  static const std::string DEFAULT_PROGRAM_NAME;
89
- #if __cplusplus >= 201703L
90
91
  static constexpr size_t PROGRAM_INIT_SIZE = 100;
91
92
  static constexpr size_t MIN_TOKEN_INDEX = 0;
92
- #else
93
- enum : size_t {
94
- PROGRAM_INIT_SIZE = 100,
95
- MIN_TOKEN_INDEX = 0,
96
- };
97
- #endif
98
93
 
99
94
  TokenStreamRewriter(TokenStream *tokens);
100
95
  virtual ~TokenStreamRewriter();
@@ -5,7 +5,7 @@
5
5
 
6
6
  #include "misc/Interval.h"
7
7
  #include "Exceptions.h"
8
- #include "support/StringUtils.h"
8
+ #include "support/Utf8.h"
9
9
 
10
10
  #include "UnbufferedCharStream.h"
11
11
 
@@ -13,9 +13,8 @@ using namespace antlrcpp;
13
13
  using namespace antlr4;
14
14
  using namespace antlr4::misc;
15
15
 
16
- UnbufferedCharStream::UnbufferedCharStream(std::wistream &input) : _input(input) {
17
- InitializeInstanceFields();
18
-
16
+ UnbufferedCharStream::UnbufferedCharStream(std::wistream &input)
17
+ : _p(0), _numMarkers(0), _lastChar(0), _lastCharBufferStart(0), _currentCharIndex(0), _input(input) {
19
18
  // The vector's size is what used to be n in Java code.
20
19
  fill(1); // prime
21
20
  }
@@ -74,9 +73,7 @@ size_t UnbufferedCharStream::fill(size_t n) {
74
73
  }
75
74
 
76
75
  char32_t UnbufferedCharStream::nextChar() {
77
- wchar_t result = 0;
78
- _input >> result;
79
- return result;
76
+ return _input.get();
80
77
  }
81
78
 
82
79
  void UnbufferedCharStream::add(char32_t c) {
@@ -101,7 +98,7 @@ size_t UnbufferedCharStream::LA(ssize_t i) {
101
98
  return EOF;
102
99
  }
103
100
 
104
- if (_data[static_cast<size_t>(index)] == 0xFFFF) {
101
+ if (_data[static_cast<size_t>(index)] == std::char_traits<wchar_t>::eof()) {
105
102
  return EOF;
106
103
  }
107
104
 
@@ -178,7 +175,7 @@ std::string UnbufferedCharStream::getSourceName() const {
178
175
  }
179
176
 
180
177
  std::string UnbufferedCharStream::getText(const misc::Interval &interval) {
181
- if (interval.a < 0 || interval.b >= interval.a - 1) {
178
+ if (interval.a < 0 || interval.b < interval.a - 1) {
182
179
  throw IllegalArgumentException("invalid interval");
183
180
  }
184
181
 
@@ -195,17 +192,17 @@ std::string UnbufferedCharStream::getText(const misc::Interval &interval) {
195
192
  }
196
193
  // convert from absolute to local index
197
194
  size_t i = interval.a - bufferStartIndex;
198
- return utf32_to_utf8(_data.substr(i, interval.length()));
195
+ auto maybeUtf8 = Utf8::strictEncode(std::u32string_view(_data).substr(i, interval.length()));
196
+ if (!maybeUtf8.has_value()) {
197
+ throw IllegalArgumentException("Unbuffered stream contains invalid Unicode code points");
198
+ }
199
+ return std::move(maybeUtf8).value();
199
200
  }
200
201
 
201
- size_t UnbufferedCharStream::getBufferStartIndex() const {
202
- return _currentCharIndex - _p;
202
+ std::string UnbufferedCharStream::toString() const {
203
+ throw UnsupportedOperationException("Unbuffered stream cannot be materialized to a string");
203
204
  }
204
205
 
205
- void UnbufferedCharStream::InitializeInstanceFields() {
206
- _p = 0;
207
- _numMarkers = 0;
208
- _lastChar = 0;
209
- _lastCharBufferStart = 0;
210
- _currentCharIndex = 0;
206
+ size_t UnbufferedCharStream::getBufferStartIndex() const {
207
+ return _currentCharIndex - _p;
211
208
  }
@@ -18,10 +18,10 @@ namespace antlr4 {
18
18
  /// The name or source of this char stream.
19
19
  std::string name;
20
20
 
21
- UnbufferedCharStream(std::wistream &input);
21
+ explicit UnbufferedCharStream(std::wistream &input);
22
22
 
23
- virtual void consume() override;
24
- virtual size_t LA(ssize_t i) override;
23
+ void consume() override;
24
+ size_t LA(ssize_t i) override;
25
25
 
26
26
  /// <summary>
27
27
  /// Return a marker that we can release later.
@@ -30,35 +30,32 @@ namespace antlr4 {
30
30
  /// protection against misuse where {@code seek()} is called on a mark or
31
31
  /// {@code release()} is called in the wrong order.
32
32
  /// </summary>
33
- virtual ssize_t mark() override;
33
+ ssize_t mark() override;
34
34
 
35
35
  /// <summary>
36
36
  /// Decrement number of markers, resetting buffer if we hit 0. </summary>
37
37
  /// <param name="marker"> </param>
38
- virtual void release(ssize_t marker) override;
39
- virtual size_t index() override;
38
+ void release(ssize_t marker) override;
39
+ size_t index() override;
40
40
 
41
41
  /// <summary>
42
42
  /// Seek to absolute character index, which might not be in the current
43
43
  /// sliding window. Move {@code p} to {@code index-bufferStartIndex}.
44
44
  /// </summary>
45
- virtual void seek(size_t index) override;
46
- virtual size_t size() override;
47
- virtual std::string getSourceName() const override;
48
- virtual std::string getText(const misc::Interval &interval) override;
45
+ void seek(size_t index) override;
46
+ size_t size() override;
47
+ std::string getSourceName() const override;
48
+ std::string getText(const misc::Interval &interval) override;
49
+
50
+ std::string toString() const override;
49
51
 
50
52
  protected:
51
53
  /// A moving window buffer of the data being scanned. While there's a marker,
52
54
  /// we keep adding to buffer. Otherwise, <seealso cref="#consume consume()"/> resets so
53
55
  /// we start filling at index 0 again.
54
56
  // UTF-32 encoded.
55
- #if defined(_MSC_VER) && _MSC_VER == 1900
56
- i32string _data; // Custom type for VS 2015.
57
- typedef __int32 storage_type;
58
- #else
59
57
  std::u32string _data;
60
58
  typedef char32_t storage_type;
61
- #endif
62
59
 
63
60
  /// <summary>
64
61
  /// 0..n-1 index into <seealso cref="#data data"/> of next character.
@@ -115,9 +112,6 @@ namespace antlr4 {
115
112
  virtual char32_t nextChar();
116
113
  virtual void add(char32_t c);
117
114
  size_t getBufferStartIndex() const;
118
-
119
- private:
120
- void InitializeInstanceFields();
121
115
  };
122
116
 
123
117
  } // namespace antlr4
@@ -0,0 +1,42 @@
1
+ // Copyright 2012-2022 The ANTLR Project
2
+ //
3
+ // Redistribution and use in source and binary forms, with or without modification, are permitted
4
+ // provided that the following conditions are met:
5
+ //
6
+ // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7
+ // and the following disclaimer.
8
+ //
9
+ // 2. Redistributions in binary form must reproduce the above copyright notice, this list of
10
+ // conditions and the following disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ //
13
+ // 3. Neither the name of the copyright holder nor the names of its contributors may be used to
14
+ // endorse or promote products derived from this software without specific prior written
15
+ // permission.
16
+ //
17
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18
+ // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19
+ // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20
+ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23
+ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24
+ // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ #pragma once
27
+
28
+ #include "antlr4-common.h"
29
+
30
+ #define ANTLRCPP_VERSION_MAJOR 4
31
+ #define ANTLRCPP_VERSION_MINOR 10
32
+ #define ANTLRCPP_VERSION_PATCH 1
33
+
34
+ #define ANTLRCPP_MAKE_VERSION(major, minor, patch) ((major) * 100000 + (minor) * 1000 + (patch))
35
+
36
+ #define ANTLRCPP_VERSION \
37
+ ANTLRCPP_MAKE_VERSION(ANTLR4CPP_VERSION_MAJOR, ANTLR4CPP_VERSION_MINOR, ANTLR4CPP_VERSION_PATCH)
38
+
39
+ #define ANTLRCPP_VERSION_STRING \
40
+ ANTLR4CPP_STRINGIFY(ANTLR4CPP_VERSION_MAJOR) "." \
41
+ ANTLR4CPP_STRINGIFY(ANTLR4CPP_VERSION_MINOR) "." \
42
+ ANTLR4CPP_STRINGIFY(ANTLR4CPP_VERSION_PATCH)
@@ -11,50 +11,18 @@ using namespace antlr4::dfa;
11
11
 
12
12
  const Vocabulary Vocabulary::EMPTY_VOCABULARY;
13
13
 
14
- Vocabulary::Vocabulary(const std::vector<std::string> &literalNames, const std::vector<std::string> &symbolicNames)
15
- : Vocabulary(literalNames, symbolicNames, {}) {
14
+ Vocabulary::Vocabulary(std::vector<std::string> literalNames, std::vector<std::string> symbolicNames)
15
+ : Vocabulary(std::move(literalNames), std::move(symbolicNames), {}) {
16
16
  }
17
17
 
18
- Vocabulary::Vocabulary(const std::vector<std::string> &literalNames,
19
- const std::vector<std::string> &symbolicNames, const std::vector<std::string> &displayNames)
20
- : _literalNames(literalNames), _symbolicNames(symbolicNames), _displayNames(displayNames),
18
+ Vocabulary::Vocabulary(std::vector<std::string> literalNames,
19
+ std::vector<std::string> symbolicNames, std::vector<std::string> displayNames)
20
+ : _literalNames(std::move(literalNames)), _symbolicNames(std::move(symbolicNames)), _displayNames(std::move(displayNames)),
21
21
  _maxTokenType(std::max(_displayNames.size(), std::max(_literalNames.size(), _symbolicNames.size())) - 1) {
22
22
  // See note here on -1 part: https://github.com/antlr/antlr4/pull/1146
23
23
  }
24
24
 
25
- Vocabulary::~Vocabulary() = default;
26
-
27
- Vocabulary Vocabulary::fromTokenNames(const std::vector<std::string> &tokenNames) {
28
- if (tokenNames.empty()) {
29
- return EMPTY_VOCABULARY;
30
- }
31
-
32
- std::vector<std::string> literalNames = tokenNames;
33
- std::vector<std::string> symbolicNames = tokenNames;
34
- std::locale locale;
35
- for (size_t i = 0; i < tokenNames.size(); i++) {
36
- const std::string& tokenName = tokenNames[i];
37
- if (tokenName.empty()) {
38
- continue;
39
- } else if (tokenName.front() == '\'') {
40
- symbolicNames[i].clear();
41
- } else if (std::isupper(tokenName.front(), locale)) {
42
- literalNames[i].clear();
43
- } else {
44
- // wasn't a literal or symbolic name
45
- literalNames[i].clear();
46
- symbolicNames[i].clear();
47
- }
48
- }
49
-
50
- return Vocabulary(literalNames, symbolicNames, tokenNames);
51
- }
52
-
53
- size_t Vocabulary::getMaxTokenType() const {
54
- return _maxTokenType;
55
- }
56
-
57
- std::string Vocabulary::getLiteralName(size_t tokenType) const {
25
+ std::string_view Vocabulary::getLiteralName(size_t tokenType) const {
58
26
  if (tokenType < _literalNames.size()) {
59
27
  return _literalNames[tokenType];
60
28
  }
@@ -62,7 +30,7 @@ std::string Vocabulary::getLiteralName(size_t tokenType) const {
62
30
  return "";
63
31
  }
64
32
 
65
- std::string Vocabulary::getSymbolicName(size_t tokenType) const {
33
+ std::string_view Vocabulary::getSymbolicName(size_t tokenType) const {
66
34
  if (tokenType == Token::EOF) {
67
35
  return "EOF";
68
36
  }
@@ -76,20 +44,20 @@ std::string Vocabulary::getSymbolicName(size_t tokenType) const {
76
44
 
77
45
  std::string Vocabulary::getDisplayName(size_t tokenType) const {
78
46
  if (tokenType < _displayNames.size()) {
79
- std::string displayName = _displayNames[tokenType];
47
+ std::string_view displayName = _displayNames[tokenType];
80
48
  if (!displayName.empty()) {
81
- return displayName;
49
+ return std::string(displayName);
82
50
  }
83
51
  }
84
52
 
85
- std::string literalName = getLiteralName(tokenType);
53
+ std::string_view literalName = getLiteralName(tokenType);
86
54
  if (!literalName.empty()) {
87
- return literalName;
55
+ return std::string(literalName);
88
56
  }
89
57
 
90
- std::string symbolicName = getSymbolicName(tokenType);
58
+ std::string_view symbolicName = getSymbolicName(tokenType);
91
59
  if (!symbolicName.empty()) {
92
- return symbolicName;
60
+ return std::string(symbolicName);
93
61
  }
94
62
 
95
63
  return std::to_string(tokenType);
@@ -12,7 +12,7 @@ namespace dfa {
12
12
 
13
13
  /// This class provides a default implementation of the <seealso cref="Vocabulary"/>
14
14
  /// interface.
15
- class ANTLR4CPP_PUBLIC Vocabulary {
15
+ class ANTLR4CPP_PUBLIC Vocabulary final {
16
16
  public:
17
17
  /// Gets an empty <seealso cref="Vocabulary"/> instance.
18
18
  ///
@@ -20,11 +20,11 @@ namespace dfa {
20
20
  /// No literal or symbol names are assigned to token types, so
21
21
  /// <seealso cref="#getDisplayName(int)"/> returns the numeric value for all tokens
22
22
  /// except <seealso cref="Token#EOF"/>.</para>
23
- static const Vocabulary EMPTY_VOCABULARY;
23
+ [[deprecated("Use the default constructor of Vocabulary instead.")]] static const Vocabulary EMPTY_VOCABULARY;
24
24
 
25
25
  Vocabulary() {}
26
- Vocabulary(Vocabulary const&) = default;
27
- virtual ~Vocabulary();
26
+
27
+ Vocabulary(const Vocabulary&) = default;
28
28
 
29
29
  /// <summary>
30
30
  /// Constructs a new instance of <seealso cref="Vocabulary"/> from the specified
@@ -37,7 +37,7 @@ namespace dfa {
37
37
  /// </param>
38
38
  /// <seealso cref= #getLiteralName(int) </seealso>
39
39
  /// <seealso cref= #getSymbolicName(int) </seealso>
40
- Vocabulary(const std::vector<std::string> &literalNames, const std::vector<std::string> &symbolicNames);
40
+ Vocabulary(std::vector<std::string> literalNames, std::vector<std::string> symbolicNames);
41
41
 
42
42
  /// <summary>
43
43
  /// Constructs a new instance of <seealso cref="Vocabulary"/> from the specified
@@ -55,29 +55,14 @@ namespace dfa {
55
55
  /// <seealso cref= #getLiteralName(int) </seealso>
56
56
  /// <seealso cref= #getSymbolicName(int) </seealso>
57
57
  /// <seealso cref= #getDisplayName(int) </seealso>
58
- Vocabulary(const std::vector<std::string> &literalNames, const std::vector<std::string> &symbolicNames,
59
- const std::vector<std::string> &displayNames);
60
-
61
- /// <summary>
62
- /// Returns a <seealso cref="Vocabulary"/> instance from the specified set of token
63
- /// names. This method acts as a compatibility layer for the single
64
- /// {@code tokenNames} array generated by previous releases of ANTLR.
65
- ///
66
- /// <para>The resulting vocabulary instance returns {@code null} for
67
- /// <seealso cref="#getLiteralName(int)"/> and <seealso cref="#getSymbolicName(int)"/>, and the
68
- /// value from {@code tokenNames} for the display names.</para>
69
- /// </summary>
70
- /// <param name="tokenNames"> The token names, or {@code null} if no token names are
71
- /// available. </param>
72
- /// <returns> A <seealso cref="Vocabulary"/> instance which uses {@code tokenNames} for
73
- /// the display names of tokens. </returns>
74
- static Vocabulary fromTokenNames(const std::vector<std::string> &tokenNames);
58
+ Vocabulary(std::vector<std::string> literalNames, std::vector<std::string> symbolicNames,
59
+ std::vector<std::string> displayNames);
75
60
 
76
61
  /// <summary>
77
62
  /// Returns the highest token type value. It can be used to iterate from
78
63
  /// zero to that number, inclusively, thus querying all stored entries. </summary>
79
64
  /// <returns> the highest token type value </returns>
80
- virtual size_t getMaxTokenType() const;
65
+ constexpr size_t getMaxTokenType() const { return _maxTokenType; }
81
66
 
82
67
  /// <summary>
83
68
  /// Gets the string literal associated with a token type. The string returned
@@ -114,7 +99,7 @@ namespace dfa {
114
99
  /// </param>
115
100
  /// <returns> The string literal associated with the specified token type, or
116
101
  /// {@code null} if no string literal is associated with the type. </returns>
117
- virtual std::string getLiteralName(size_t tokenType) const;
102
+ std::string_view getLiteralName(size_t tokenType) const;
118
103
 
119
104
  /// <summary>
120
105
  /// Gets the symbolic name associated with a token type. The string returned
@@ -158,7 +143,7 @@ namespace dfa {
158
143
  /// </param>
159
144
  /// <returns> The symbolic name associated with the specified token type, or
160
145
  /// {@code null} if no symbolic name is associated with the type. </returns>
161
- virtual std::string getSymbolicName(size_t tokenType) const;
146
+ std::string_view getSymbolicName(size_t tokenType) const;
162
147
 
163
148
  /// <summary>
164
149
  /// Gets the display name of a token type.
@@ -179,7 +164,7 @@ namespace dfa {
179
164
  /// </param>
180
165
  /// <returns> The display name of the token type, for use in error reporting or
181
166
  /// other user-visible messages which reference specific token types. </returns>
182
- virtual std::string getDisplayName(size_t tokenType) const;
167
+ std::string getDisplayName(size_t tokenType) const;
183
168
 
184
169
  private:
185
170
  std::vector<std::string> const _literalNames;