expressir 1.2.4 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (312) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +0 -6
  3. data/.github/workflows/rake.yml +200 -21
  4. data/.gitignore +7 -2
  5. data/.gitmodules +3 -0
  6. data/.rubocop.yml +13 -4
  7. data/README.adoc +8 -0
  8. data/Rakefile +4 -1
  9. data/bin/console +0 -1
  10. data/bin/rspec +3 -3
  11. data/exe/expressir +4 -2
  12. data/exe/format +1 -1
  13. data/exe/format-test +25 -25
  14. data/exe/generate-parser +16 -13
  15. data/expressir.gemspec +12 -10
  16. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
  17. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
  18. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
  19. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
  20. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
  21. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
  22. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
  23. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
  24. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
  25. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
  26. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
  27. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
  28. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
  29. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
  30. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
  31. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
  32. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
  33. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
  34. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
  35. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
  36. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
  37. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
  38. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
  39. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
  40. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
  41. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
  42. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
  43. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
  44. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
  45. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
  46. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
  47. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
  48. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
  49. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
  50. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
  51. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
  52. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
  53. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
  54. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
  55. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
  56. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
  57. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
  58. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
  59. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
  60. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
  61. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
  62. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
  63. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
  64. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
  65. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
  66. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
  67. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
  68. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
  69. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
  70. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
  71. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
  72. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
  73. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
  74. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
  75. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
  76. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
  77. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
  78. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
  79. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
  80. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
  81. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
  82. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
  83. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
  84. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
  85. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
  86. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
  87. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
  88. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
  89. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
  90. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
  91. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
  92. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
  93. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
  94. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
  95. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
  96. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
  97. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
  98. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
  99. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
  100. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
  101. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
  102. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
  103. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
  104. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
  105. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
  106. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
  107. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
  108. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
  109. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
  110. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
  111. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
  112. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
  113. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
  114. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
  115. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
  116. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
  117. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
  118. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
  119. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
  120. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
  121. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
  122. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
  123. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
  124. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
  125. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
  126. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
  127. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
  128. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
  129. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
  130. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
  131. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
  132. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
  133. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
  134. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
  135. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
  136. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
  137. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
  138. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
  139. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
  140. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
  141. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
  142. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
  143. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
  144. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
  145. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
  146. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
  147. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
  148. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
  149. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
  150. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
  151. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
  152. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
  153. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
  154. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
  155. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
  156. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
  157. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
  158. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
  159. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
  160. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
  161. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
  162. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
  163. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
  164. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
  165. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
  166. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
  167. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
  168. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
  169. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
  170. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
  171. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
  172. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
  173. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
  174. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
  175. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
  176. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
  177. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
  178. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
  179. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
  180. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
  181. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
  182. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
  183. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
  184. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
  185. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
  186. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
  187. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
  188. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
  189. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
  190. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
  221. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
  222. data/ext/express-parser/antlrgen/Express.interp +1 -1
  223. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
  224. data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
  225. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
  226. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
  227. data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
  228. data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
  229. data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
  230. data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
  231. data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
  232. data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
  233. data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
  234. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
  235. data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
  236. data/ext/express-parser/express_parser.cpp +294 -86
  237. data/ext/express-parser/extconf.rb +13 -12
  238. data/lib/expressir/config.rb +1 -1
  239. data/lib/expressir/express/parser.rb +3 -4
  240. data/lib/expressir/express/visitor.rb +7 -5
  241. data/lib/expressir/model.rb +78 -78
  242. data/lib/expressir/version.rb +1 -1
  243. data/rakelib/antlr4-native.rake +161 -0
  244. data/rakelib/cross-ruby.rake +213 -162
  245. data/spec/acceptance/version_spec.rb +17 -2
  246. data/spec/expressir/express/cache_spec.rb +23 -5
  247. data/spec/expressir/express/formatter_spec.rb +54 -8
  248. data/spec/expressir/express/parser_spec.rb +47 -11
  249. data/spec/expressir/model/model_element_spec.rb +198 -146
  250. data/spec/spec_helper.rb +7 -0
  251. metadata +81 -93
  252. data/demo.rb +0 -18
  253. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
  254. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
  255. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
  256. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
  257. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
  258. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
  259. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
  260. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
  261. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
  262. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
  263. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
  264. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
  265. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
  266. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
  267. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
  268. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
  274. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
  275. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
  276. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
  277. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
  278. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
  279. data/original/examples/employment/eclipse/.project +0 -17
  280. data/original/examples/employment/eclipse/Export/Employment.png +0 -0
  281. data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
  282. data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
  283. data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
  284. data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
  285. data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
  286. data/original/examples/employment/eclipse/readme.txt +0 -7
  287. data/original/examples/employment/employment_schema.exp +0 -33
  288. data/original/examples/employment/employment_schema.rb +0 -232
  289. data/original/examples/employment/employment_schema.xml +0 -93
  290. data/original/examples/employment/employment_schema___module.rb +0 -46
  291. data/original/examples/employment/employment_schema___p28attr.rb +0 -126
  292. data/original/examples/employment/employment_schema___p28inst.rb +0 -26
  293. data/original/examples/employment/example_employment_data.xml +0 -1
  294. data/original/examples/employment/example_employment_data_copy.xml +0 -1
  295. data/original/examples/employment/example_employment_reader.rb +0 -30
  296. data/original/examples/employment/example_employment_writer.rb +0 -51
  297. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
  298. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
  299. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
  300. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
  301. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
  302. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
  303. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
  304. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
  305. data/original/exp2ruby.rb +0 -525
  306. data/original/expsm.rb +0 -34
  307. data/original/mapping_owl.rb +0 -1018
  308. data/original/mapping_sysml.rb +0 -2281
  309. data/original/mapping_uml2.rb +0 -599
  310. data/original/mapping_uml2_eclipse.rb +0 -433
  311. data/original/reeper.rb +0 -134
  312. data/spec/expressr_spec.rb +0 -5
@@ -32,8 +32,13 @@ namespace antlrcpp {
32
32
  return false;
33
33
 
34
34
  for (size_t i = 0; i < a.size(); ++i) {
35
+ if (!a[i] && !b[i])
36
+ continue;
37
+ if (!a[i] || !b[i])
38
+ return false;
35
39
  if (a[i] == b[i])
36
40
  continue;
41
+
37
42
  if (!(*a[i] == *b[i]))
38
43
  return false;
39
44
  }
@@ -61,6 +66,26 @@ namespace antlrcpp {
61
66
  return true;
62
67
  }
63
68
 
69
+ template <typename T>
70
+ static bool equals(const std::vector<std::unique_ptr<T>> &a, const std::vector<std::unique_ptr<T>> &b) {
71
+ if (a.size() != b.size())
72
+ return false;
73
+
74
+ for (size_t i = 0; i < a.size(); ++i) {
75
+ if (!a[i] && !b[i])
76
+ continue;
77
+ if (!a[i] || !b[i])
78
+ return false;
79
+ if (a[i] == b[i])
80
+ continue;
81
+
82
+ if (!(*a[i] == *b[i]))
83
+ return false;
84
+ }
85
+
86
+ return true;
87
+ }
88
+
64
89
  template <typename T>
65
90
  static std::string toString(const std::vector<T> &source) {
66
91
  std::string result = "[";
@@ -89,6 +114,20 @@ namespace antlrcpp {
89
114
  return result + "]";
90
115
  }
91
116
 
117
+ template <typename T>
118
+ static std::string toString(const std::vector<std::unique_ptr<T>> &source) {
119
+ std::string result = "[";
120
+ bool firstEntry = true;
121
+ for (auto &value : source) {
122
+ result += value->toString();
123
+ if (firstEntry) {
124
+ result += ", ";
125
+ firstEntry = false;
126
+ }
127
+ }
128
+ return result + "]";
129
+ }
130
+
92
131
  template <typename T>
93
132
  static std::string toString(const std::vector<T *> &source) {
94
133
  std::string result = "[";
@@ -54,7 +54,7 @@ namespace antlrcpp {
54
54
  return result;
55
55
  }
56
56
 
57
- std::string toString(){
57
+ std::string toString() const {
58
58
  std::stringstream stream;
59
59
  stream << "{";
60
60
  bool valueAdded = false;
@@ -7,10 +7,10 @@
7
7
 
8
8
  namespace antlrcpp {
9
9
 
10
- std::string join(std::vector<std::string> strings, const std::string &separator) {
10
+ std::string join(const std::vector<std::string> &strings, const std::string &separator) {
11
11
  std::string str;
12
12
  bool firstItem = true;
13
- for (std::string s : strings) {
13
+ for (const std::string &s : strings) {
14
14
  if (!firstItem) {
15
15
  str.append(separator);
16
16
  }
@@ -49,15 +49,12 @@ namespace antlrcpp {
49
49
  result += "\u00B7";
50
50
  break;
51
51
  }
52
- // else fall through
53
- #ifndef _MSC_VER
54
- #if __has_cpp_attribute(clang::fallthrough)
55
- [[clang::fallthrough]];
56
- #endif
57
- #endif
52
+ result += c;
53
+ break;
58
54
 
59
55
  default:
60
56
  result += c;
57
+ break;
61
58
  }
62
59
  }
63
60
 
@@ -72,8 +69,13 @@ namespace antlrcpp {
72
69
 
73
70
  std::string arrayToString(const std::vector<std::string> &data) {
74
71
  std::string answer;
75
- for (auto sub: data) {
76
- answer += sub;
72
+ size_t toReserve = 0;
73
+ for (const auto &sub : data) {
74
+ toReserve += sub.size();
75
+ }
76
+ answer.reserve(toReserve);
77
+ for (const auto &sub: data) {
78
+ answer.append(sub);
77
79
  }
78
80
  return answer;
79
81
  }
@@ -202,47 +204,4 @@ namespace antlrcpp {
202
204
  return result;
203
205
  }
204
206
 
205
- //----------------- FinallyAction ------------------------------------------------------------------------------------
206
-
207
- FinalAction finally(std::function<void ()> f) {
208
- return FinalAction(f);
209
- }
210
-
211
- //----------------- SingleWriteMultipleRead --------------------------------------------------------------------------
212
-
213
- void SingleWriteMultipleReadLock::readLock() {
214
- std::unique_lock<std::mutex> lock(_mutex);
215
- while (_waitingWriters != 0)
216
- _readerGate.wait(lock);
217
- ++_activeReaders;
218
- lock.unlock();
219
- }
220
-
221
- void SingleWriteMultipleReadLock::readUnlock() {
222
- std::unique_lock<std::mutex> lock(_mutex);
223
- --_activeReaders;
224
- lock.unlock();
225
- _writerGate.notify_one();
226
- }
227
-
228
- void SingleWriteMultipleReadLock::writeLock() {
229
- std::unique_lock<std::mutex> lock(_mutex);
230
- ++_waitingWriters;
231
- while (_activeReaders != 0 || _activeWriters != 0)
232
- _writerGate.wait(lock);
233
- ++_activeWriters;
234
- lock.unlock();
235
- }
236
-
237
- void SingleWriteMultipleReadLock::writeUnlock() {
238
- std::unique_lock<std::mutex> lock(_mutex);
239
- --_waitingWriters;
240
- --_activeWriters;
241
- if (_waitingWriters > 0)
242
- _writerGate.notify_one();
243
- else
244
- _readerGate.notify_all();
245
- lock.unlock();
246
- }
247
-
248
207
  } // namespace antlrcpp
@@ -9,18 +9,19 @@
9
9
 
10
10
  namespace antlrcpp {
11
11
 
12
- std::string join(std::vector<std::string> strings, const std::string &separator);
13
- std::map<std::string, size_t> toMap(const std::vector<std::string> &keys);
14
- std::string escapeWhitespace(std::string str, bool escapeSpaces);
15
- std::string toHexString(const int t);
16
- std::string arrayToString(const std::vector<std::string> &data);
17
- std::string replaceString(const std::string &s, const std::string &from, const std::string &to);
18
- std::vector<std::string> split(const std::string &s, const std::string &sep, int count);
19
- std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true);
12
+ ANTLR4CPP_PUBLIC std::string join(const std::vector<std::string> &strings, const std::string &separator);
13
+ ANTLR4CPP_PUBLIC std::map<std::string, size_t> toMap(const std::vector<std::string> &keys);
14
+ ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string str, bool escapeSpaces);
15
+ ANTLR4CPP_PUBLIC std::string toHexString(const int t);
16
+ ANTLR4CPP_PUBLIC std::string arrayToString(const std::vector<std::string> &data);
17
+ ANTLR4CPP_PUBLIC std::string replaceString(const std::string &s, const std::string &from, const std::string &to);
18
+ ANTLR4CPP_PUBLIC std::vector<std::string> split(const std::string &s, const std::string &sep, int count);
19
+ ANTLR4CPP_PUBLIC std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true);
20
20
 
21
21
  // Using RAII + a lambda to implement a "finally" replacement.
22
+ template <typename OnEnd>
22
23
  struct FinalAction {
23
- FinalAction(std::function<void ()> f) : _cleanUp { f } {}
24
+ FinalAction(OnEnd f) : _cleanUp { std::move(f) } {}
24
25
  FinalAction(FinalAction &&other) :
25
26
  _cleanUp(std::move(other._cleanUp)), _enabled(other._enabled) {
26
27
  other._enabled = false; // Don't trigger the lambda after ownership has moved.
@@ -29,11 +30,14 @@ namespace antlrcpp {
29
30
 
30
31
  void disable() { _enabled = false; }
31
32
  private:
32
- std::function<void ()> _cleanUp;
33
+ OnEnd _cleanUp;
33
34
  bool _enabled {true};
34
35
  };
35
36
 
36
- ANTLR4CPP_PUBLIC FinalAction finally(std::function<void ()> f);
37
+ template <typename OnEnd>
38
+ FinalAction<OnEnd> finally(OnEnd f) {
39
+ return FinalAction<OnEnd>(std::move(f));
40
+ }
37
41
 
38
42
  // Convenience functions to avoid lengthy dynamic_cast() != nullptr checks in many places.
39
43
  template <typename T1, typename T2>
@@ -56,23 +60,6 @@ namespace antlrcpp {
56
60
  }
57
61
 
58
62
  // Get the error text from an exception pointer or the current exception.
59
- std::string what(std::exception_ptr eptr = std::current_exception());
60
-
61
- class SingleWriteMultipleReadLock {
62
- public:
63
- void readLock();
64
- void readUnlock();
65
- void writeLock();
66
- void writeUnlock();
67
-
68
- private:
69
- std::condition_variable _readerGate;
70
- std::condition_variable _writerGate;
71
-
72
- std::mutex _mutex;
73
- size_t _activeReaders = 0;
74
- size_t _waitingWriters = 0;
75
- size_t _activeWriters = 0;
76
- };
63
+ ANTLR4CPP_PUBLIC std::string what(std::exception_ptr eptr = std::current_exception());
77
64
 
78
65
  } // namespace antlrcpp
@@ -0,0 +1,34 @@
1
+ /* Copyright (c) 2012-2021 The ANTLR Project. All rights reserved.
2
+ * Use of this file is governed by the BSD 3-clause license that
3
+ * can be found in the LICENSE.txt file in the project root.
4
+ */
5
+
6
+ #pragma once
7
+
8
+ #include <cassert>
9
+ #include <memory>
10
+ #include <type_traits>
11
+
12
+ namespace antlrcpp {
13
+
14
+ template <typename To, typename From>
15
+ To downCast(From* from) {
16
+ static_assert(std::is_pointer_v<To>, "Target type not a pointer.");
17
+ static_assert(std::is_base_of_v<From, std::remove_pointer_t<To>>, "Target type not derived from source type.");
18
+ #if !defined(__GNUC__) || defined(__GXX_RTTI)
19
+ assert(from == nullptr || dynamic_cast<To>(from) != nullptr);
20
+ #endif
21
+ return static_cast<To>(from);
22
+ }
23
+
24
+ template <typename To, typename From>
25
+ To downCast(From& from) {
26
+ static_assert(std::is_lvalue_reference_v<To>, "Target type not a lvalue reference.");
27
+ static_assert(std::is_base_of_v<From, std::remove_reference_t<To>>, "Target type not derived from source type.");
28
+ #if !defined(__GNUC__) || defined(__GXX_RTTI)
29
+ assert(dynamic_cast<std::add_pointer_t<std::remove_reference_t<To>>>(std::addressof(from)) != nullptr);
30
+ #endif
31
+ return static_cast<To>(from);
32
+ }
33
+
34
+ }
@@ -69,7 +69,6 @@ namespace antlr4 {
69
69
  class ATNSimulator;
70
70
  class ATNState;
71
71
  enum class ATNType;
72
- class AbstractPredicateTransition;
73
72
  class ActionTransition;
74
73
  class ArrayPredictionContext;
75
74
  class AtomTransition;
@@ -78,7 +77,6 @@ namespace antlr4 {
78
77
  class BlockEndState;
79
78
  class BlockStartState;
80
79
  class DecisionState;
81
- class EmptyPredictionContext;
82
80
  class EpsilonTransition;
83
81
  class LL1Analyzer;
84
82
  class LexerAction;
@@ -7,40 +7,32 @@
7
7
 
8
8
  namespace antlrcpp {
9
9
 
10
- void replaceAll(std::string& str, std::string const& from, std::string const& to)
11
- {
12
- if (from.empty())
13
- return;
14
-
15
- size_t start_pos = 0;
16
- while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
17
- str.replace(start_pos, from.length(), to);
18
- start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'.
10
+ std::string escapeWhitespace(std::string_view in) {
11
+ std::string out;
12
+ escapeWhitespace(out, in);
13
+ out.shrink_to_fit();
14
+ return out;
19
15
  }
20
- }
21
-
22
- std::string ws2s(std::wstring const& wstr) {
23
- #ifndef USE_UTF8_INSTEAD_OF_CODECVT
24
- std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
25
- std::string narrow = converter.to_bytes(wstr);
26
- #else
27
- std::string narrow;
28
- utf8::utf32to8(wstr.begin(), wstr.end(), std::back_inserter(narrow));
29
- #endif
30
-
31
- return narrow;
32
- }
33
16
 
34
- std::wstring s2ws(const std::string &str) {
35
- #ifndef USE_UTF8_INSTEAD_OF_CODECVT
36
- std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
37
- std::wstring wide = converter.from_bytes(str);
38
- #else
39
- std::wstring wide;
40
- utf8::utf8to32(str.begin(), str.end(), std::back_inserter(wide));
41
- #endif
42
-
43
- return wide;
44
- }
17
+ std::string& escapeWhitespace(std::string& out, std::string_view in) {
18
+ out.reserve(in.size()); // Best case, no escaping.
19
+ for (const auto &c : in) {
20
+ switch (c) {
21
+ case '\t':
22
+ out.append("\\t");
23
+ break;
24
+ case '\r':
25
+ out.append("\\r");
26
+ break;
27
+ case '\n':
28
+ out.append("\\n");
29
+ break;
30
+ default:
31
+ out.push_back(c);
32
+ break;
33
+ }
34
+ }
35
+ return out;
36
+ }
45
37
 
46
38
  } // namespace antrlcpp
@@ -7,70 +7,10 @@
7
7
 
8
8
  #include "antlr4-common.h"
9
9
 
10
- #ifdef USE_UTF8_INSTEAD_OF_CODECVT
11
- #include "utf8.h"
12
- #endif
13
-
14
10
  namespace antlrcpp {
15
11
 
16
- // For all conversions utf8 <-> utf32.
17
- // I wouldn't prefer wstring_convert because: according to
18
- // https://en.cppreference.com/w/cpp/locale/wstring_convert,
19
- // wstring_convert is deprecated in C++17.
20
- // utfcpp (https://github.com/nemtrif/utfcpp) is a substitution.
21
- #ifndef USE_UTF8_INSTEAD_OF_CODECVT
22
- // VS 2015 and VS 2017 have different bugs in std::codecvt_utf8<char32_t> (VS 2013 works fine).
23
- #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
24
- typedef std::wstring_convert<std::codecvt_utf8<__int32>, __int32> UTF32Converter;
25
- #else
26
- typedef std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> UTF32Converter;
27
- #endif
28
- #endif
29
-
30
- // The conversion functions fails in VS2017, so we explicitly use a workaround.
31
- template<typename T>
32
- inline std::string utf32_to_utf8(T const& data)
33
- {
34
- #ifndef USE_UTF8_INSTEAD_OF_CODECVT
35
- // Don't make the converter static or we have to serialize access to it.
36
- thread_local UTF32Converter converter;
37
-
38
- #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
39
- const auto p = reinterpret_cast<const int32_t *>(data.data());
40
- return converter.to_bytes(p, p + data.size());
41
- #else
42
- return converter.to_bytes(data);
43
- #endif
44
- #else
45
- std::string narrow;
46
- utf8::utf32to8(data.begin(), data.end(), std::back_inserter(narrow));
47
- return narrow;
48
- #endif
49
- }
50
-
51
- inline UTF32String utf8_to_utf32(const char* first, const char* last)
52
- {
53
- #ifndef USE_UTF8_INSTEAD_OF_CODECVT
54
- thread_local UTF32Converter converter;
55
-
56
- #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
57
- auto r = converter.from_bytes(first, last);
58
- i32string s = reinterpret_cast<const int32_t *>(r.data());
59
- return s;
60
- #else
61
- std::u32string s = converter.from_bytes(first, last);
62
- return s;
63
- #endif
64
- #else
65
- UTF32String wide;
66
- utf8::utf8to32(first, last, std::back_inserter(wide));
67
- return wide;
68
- #endif
69
- }
12
+ ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string_view in);
70
13
 
71
- void replaceAll(std::string &str, std::string const& from, std::string const& to);
14
+ ANTLR4CPP_PUBLIC std::string& escapeWhitespace(std::string& out, std::string_view in);
72
15
 
73
- // string <-> wstring conversion (UTF-16), e.g. for use with Window's wide APIs.
74
- ANTLR4CPP_PUBLIC std::string ws2s(std::wstring const& wstr);
75
- ANTLR4CPP_PUBLIC std::wstring s2ws(std::string const& str);
76
16
  }
@@ -0,0 +1,28 @@
1
+ /* Copyright (c) 2021 The ANTLR Project. All rights reserved.
2
+ * Use of this file is governed by the BSD 3-clause license that
3
+ * can be found in the LICENSE.txt file in the project root.
4
+ */
5
+
6
+ #pragma once
7
+
8
+ #include "antlr4-common.h"
9
+
10
+ namespace antlrcpp {
11
+
12
+ class ANTLR4CPP_PUBLIC Unicode final {
13
+ public:
14
+ static constexpr char32_t REPLACEMENT_CHARACTER = 0xfffd;
15
+
16
+ static constexpr bool isValid(char32_t codePoint) {
17
+ return codePoint < 0xd800 || (codePoint > 0xdfff && codePoint <= 0x10ffff);
18
+ }
19
+
20
+ private:
21
+ Unicode() = delete;
22
+ Unicode(const Unicode&) = delete;
23
+ Unicode(Unicode&&) = delete;
24
+ Unicode& operator=(const Unicode&) = delete;
25
+ Unicode& operator=(Unicode&&) = delete;
26
+ };
27
+
28
+ }