openpinescript 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. openpinescript/__init__.py +129 -0
  2. openpinescript/__main__.py +5 -0
  3. openpinescript/_cli.py +24 -0
  4. openpinescript/_engine/LICENSE +674 -0
  5. openpinescript/_engine/VERSION +1 -0
  6. openpinescript/_engine/dist/cli.mjs +108691 -0
  7. openpinescript/_engine/node_modules/antlr4ng/LICENSE.txt +29 -0
  8. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATN.cjs +3159 -0
  9. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATN.js +3159 -0
  10. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATN.mjs +3139 -0
  11. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfig.cjs +911 -0
  12. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfig.js +911 -0
  13. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfig.mjs +891 -0
  14. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfigSet.cjs +3781 -0
  15. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfigSet.js +3781 -0
  16. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfigSet.mjs +3761 -0
  17. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializationOptions.cjs +17 -0
  18. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializationOptions.js +17 -0
  19. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializationOptions.mjs +0 -0
  20. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializer.cjs +4300 -0
  21. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializer.js +4300 -0
  22. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializer.mjs +4280 -0
  23. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSerializer.cjs +4798 -0
  24. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSerializer.js +4798 -0
  25. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSerializer.mjs +4778 -0
  26. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSimulator.cjs +982 -0
  27. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSimulator.js +982 -0
  28. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSimulator.mjs +962 -0
  29. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNState.cjs +85 -0
  30. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNState.js +85 -0
  31. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNState.mjs +67 -0
  32. openpinescript/_engine/node_modules/antlr4ng/dist/atn/AbstractPredicateTransition.cjs +78 -0
  33. openpinescript/_engine/node_modules/antlr4ng/dist/atn/AbstractPredicateTransition.js +78 -0
  34. openpinescript/_engine/node_modules/antlr4ng/dist/atn/AbstractPredicateTransition.mjs +58 -0
  35. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ActionTransition.cjs +96 -0
  36. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ActionTransition.js +96 -0
  37. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ActionTransition.mjs +76 -0
  38. openpinescript/_engine/node_modules/antlr4ng/dist/atn/AmbiguityInfo.cjs +17 -0
  39. openpinescript/_engine/node_modules/antlr4ng/dist/atn/AmbiguityInfo.js +17 -0
  40. openpinescript/_engine/node_modules/antlr4ng/dist/atn/AmbiguityInfo.mjs +0 -0
  41. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ArrayPredictionContext.cjs +243 -0
  42. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ArrayPredictionContext.js +243 -0
  43. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ArrayPredictionContext.mjs +223 -0
  44. openpinescript/_engine/node_modules/antlr4ng/dist/atn/AtomTransition.cjs +904 -0
  45. openpinescript/_engine/node_modules/antlr4ng/dist/atn/AtomTransition.js +904 -0
  46. openpinescript/_engine/node_modules/antlr4ng/dist/atn/AtomTransition.mjs +884 -0
  47. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicBlockStartState.cjs +112 -0
  48. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicBlockStartState.js +112 -0
  49. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicBlockStartState.mjs +92 -0
  50. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicState.cjs +95 -0
  51. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicState.js +95 -0
  52. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicState.mjs +75 -0
  53. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockEndState.cjs +96 -0
  54. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockEndState.js +96 -0
  55. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockEndState.mjs +76 -0
  56. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockStartState.cjs +104 -0
  57. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockStartState.js +104 -0
  58. openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockStartState.mjs +84 -0
  59. openpinescript/_engine/node_modules/antlr4ng/dist/atn/CodePointTransitions.cjs +947 -0
  60. openpinescript/_engine/node_modules/antlr4ng/dist/atn/CodePointTransitions.js +947 -0
  61. openpinescript/_engine/node_modules/antlr4ng/dist/atn/CodePointTransitions.mjs +927 -0
  62. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ContextSensitivityInfo.cjs +17 -0
  63. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ContextSensitivityInfo.js +17 -0
  64. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ContextSensitivityInfo.mjs +0 -0
  65. openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionEventInfo.cjs +17 -0
  66. openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionEventInfo.js +17 -0
  67. openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionEventInfo.mjs +0 -0
  68. openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionInfo.cjs +206 -0
  69. openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionInfo.js +206 -0
  70. openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionInfo.mjs +188 -0
  71. openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionState.cjs +96 -0
  72. openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionState.js +96 -0
  73. openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionState.mjs +76 -0
  74. openpinescript/_engine/node_modules/antlr4ng/dist/atn/EmptyPredictionContext.cjs +237 -0
  75. openpinescript/_engine/node_modules/antlr4ng/dist/atn/EmptyPredictionContext.js +237 -0
  76. openpinescript/_engine/node_modules/antlr4ng/dist/atn/EmptyPredictionContext.mjs +217 -0
  77. openpinescript/_engine/node_modules/antlr4ng/dist/atn/EpsilonTransition.cjs +103 -0
  78. openpinescript/_engine/node_modules/antlr4ng/dist/atn/EpsilonTransition.js +103 -0
  79. openpinescript/_engine/node_modules/antlr4ng/dist/atn/EpsilonTransition.mjs +83 -0
  80. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LL1Analyzer.cjs +3159 -0
  81. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LL1Analyzer.js +3159 -0
  82. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LL1Analyzer.mjs +3139 -0
  83. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNConfig.cjs +961 -0
  84. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNConfig.js +961 -0
  85. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNConfig.mjs +941 -0
  86. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNSimulator.cjs +5604 -0
  87. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNSimulator.js +5604 -0
  88. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNSimulator.mjs +5584 -0
  89. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerAction.cjs +17 -0
  90. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerAction.js +17 -0
  91. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerAction.mjs +0 -0
  92. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionExecutor.cjs +305 -0
  93. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionExecutor.js +305 -0
  94. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionExecutor.mjs +285 -0
  95. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionType.cjs +42 -0
  96. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionType.js +42 -0
  97. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionType.mjs +22 -0
  98. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerChannelAction.cjs +163 -0
  99. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerChannelAction.js +163 -0
  100. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerChannelAction.mjs +143 -0
  101. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerCustomAction.cjs +169 -0
  102. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerCustomAction.js +169 -0
  103. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerCustomAction.mjs +149 -0
  104. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerIndexedCustomAction.cjs +142 -0
  105. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerIndexedCustomAction.js +142 -0
  106. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerIndexedCustomAction.mjs +122 -0
  107. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerModeAction.cjs +163 -0
  108. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerModeAction.js +163 -0
  109. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerModeAction.mjs +143 -0
  110. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerMoreAction.cjs +73 -0
  111. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerMoreAction.js +73 -0
  112. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerMoreAction.mjs +53 -0
  113. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPopModeAction.cjs +73 -0
  114. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPopModeAction.js +73 -0
  115. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPopModeAction.mjs +53 -0
  116. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPushModeAction.cjs +163 -0
  117. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPushModeAction.js +163 -0
  118. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPushModeAction.mjs +143 -0
  119. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerSkipAction.cjs +71 -0
  120. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerSkipAction.js +71 -0
  121. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerSkipAction.mjs +51 -0
  122. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerTypeAction.cjs +159 -0
  123. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerTypeAction.js +159 -0
  124. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerTypeAction.mjs +139 -0
  125. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LookaheadEventInfo.cjs +17 -0
  126. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LookaheadEventInfo.js +17 -0
  127. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LookaheadEventInfo.mjs +0 -0
  128. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LoopEndState.cjs +96 -0
  129. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LoopEndState.js +96 -0
  130. openpinescript/_engine/node_modules/antlr4ng/dist/atn/LoopEndState.mjs +76 -0
  131. openpinescript/_engine/node_modules/antlr4ng/dist/atn/NotSetTransition.cjs +921 -0
  132. openpinescript/_engine/node_modules/antlr4ng/dist/atn/NotSetTransition.js +921 -0
  133. openpinescript/_engine/node_modules/antlr4ng/dist/atn/NotSetTransition.mjs +901 -0
  134. openpinescript/_engine/node_modules/antlr4ng/dist/atn/OrderedATNConfigSet.cjs +3824 -0
  135. openpinescript/_engine/node_modules/antlr4ng/dist/atn/OrderedATNConfigSet.js +3824 -0
  136. openpinescript/_engine/node_modules/antlr4ng/dist/atn/OrderedATNConfigSet.mjs +3804 -0
  137. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParseInfo.cjs +156 -0
  138. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParseInfo.js +156 -0
  139. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParseInfo.mjs +138 -0
  140. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParserATNSimulator.cjs +6082 -0
  141. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParserATNSimulator.js +6082 -0
  142. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParserATNSimulator.mjs +6062 -0
  143. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusBlockStartState.cjs +113 -0
  144. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusBlockStartState.js +113 -0
  145. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusBlockStartState.mjs +93 -0
  146. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusLoopbackState.cjs +104 -0
  147. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusLoopbackState.js +104 -0
  148. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusLoopbackState.mjs +84 -0
  149. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PrecedencePredicateTransition.cjs +887 -0
  150. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PrecedencePredicateTransition.js +887 -0
  151. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PrecedencePredicateTransition.mjs +867 -0
  152. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateEvalInfo.cjs +17 -0
  153. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateEvalInfo.js +17 -0
  154. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateEvalInfo.mjs +0 -0
  155. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateTransition.cjs +892 -0
  156. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateTransition.js +892 -0
  157. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateTransition.mjs +872 -0
  158. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContext.cjs +153 -0
  159. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContext.js +153 -0
  160. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContext.mjs +133 -0
  161. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextCache.cjs +715 -0
  162. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextCache.js +715 -0
  163. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextCache.mjs +695 -0
  164. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextUtils.cjs +3604 -0
  165. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextUtils.js +3604 -0
  166. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextUtils.mjs +3584 -0
  167. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionMode.cjs +4284 -0
  168. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionMode.js +4284 -0
  169. openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionMode.mjs +4264 -0
  170. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ProfilingATNSimulator.cjs +6467 -0
  171. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ProfilingATNSimulator.js +6467 -0
  172. openpinescript/_engine/node_modules/antlr4ng/dist/atn/ProfilingATNSimulator.mjs +6447 -0
  173. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RangeTransition.cjs +905 -0
  174. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RangeTransition.js +905 -0
  175. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RangeTransition.mjs +885 -0
  176. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStartState.cjs +97 -0
  177. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStartState.js +97 -0
  178. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStartState.mjs +77 -0
  179. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStopState.cjs +95 -0
  180. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStopState.js +95 -0
  181. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStopState.mjs +75 -0
  182. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleTransition.cjs +93 -0
  183. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleTransition.js +93 -0
  184. openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleTransition.mjs +73 -0
  185. openpinescript/_engine/node_modules/antlr4ng/dist/atn/SemanticContext.cjs +807 -0
  186. openpinescript/_engine/node_modules/antlr4ng/dist/atn/SemanticContext.js +807 -0
  187. openpinescript/_engine/node_modules/antlr4ng/dist/atn/SemanticContext.mjs +787 -0
  188. openpinescript/_engine/node_modules/antlr4ng/dist/atn/SetTransition.cjs +905 -0
  189. openpinescript/_engine/node_modules/antlr4ng/dist/atn/SetTransition.js +905 -0
  190. openpinescript/_engine/node_modules/antlr4ng/dist/atn/SetTransition.mjs +885 -0
  191. openpinescript/_engine/node_modules/antlr4ng/dist/atn/SingletonPredictionContext.cjs +207 -0
  192. openpinescript/_engine/node_modules/antlr4ng/dist/atn/SingletonPredictionContext.js +207 -0
  193. openpinescript/_engine/node_modules/antlr4ng/dist/atn/SingletonPredictionContext.mjs +187 -0
  194. openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarBlockStartState.cjs +112 -0
  195. openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarBlockStartState.js +112 -0
  196. openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarBlockStartState.mjs +92 -0
  197. openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopEntryState.cjs +117 -0
  198. openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopEntryState.js +117 -0
  199. openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopEntryState.mjs +97 -0
  200. openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopbackState.cjs +95 -0
  201. openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopbackState.js +95 -0
  202. openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopbackState.mjs +75 -0
  203. openpinescript/_engine/node_modules/antlr4ng/dist/atn/TokensStartState.cjs +104 -0
  204. openpinescript/_engine/node_modules/antlr4ng/dist/atn/TokensStartState.js +104 -0
  205. openpinescript/_engine/node_modules/antlr4ng/dist/atn/TokensStartState.mjs +84 -0
  206. openpinescript/_engine/node_modules/antlr4ng/dist/atn/Transition.cjs +66 -0
  207. openpinescript/_engine/node_modules/antlr4ng/dist/atn/Transition.js +66 -0
  208. openpinescript/_engine/node_modules/antlr4ng/dist/atn/Transition.mjs +48 -0
  209. openpinescript/_engine/node_modules/antlr4ng/dist/atn/WildcardTransition.cjs +84 -0
  210. openpinescript/_engine/node_modules/antlr4ng/dist/atn/WildcardTransition.js +84 -0
  211. openpinescript/_engine/node_modules/antlr4ng/dist/atn/WildcardTransition.mjs +64 -0
  212. openpinescript/_engine/node_modules/antlr4ng/dist/atn/helpers.cjs +246 -0
  213. openpinescript/_engine/node_modules/antlr4ng/dist/atn/helpers.js +246 -0
  214. openpinescript/_engine/node_modules/antlr4ng/dist/atn/helpers.mjs +226 -0
  215. openpinescript/_engine/node_modules/antlr4ng/dist/atn/index.cjs +9485 -0
  216. openpinescript/_engine/node_modules/antlr4ng/dist/atn/index.js +9485 -0
  217. openpinescript/_engine/node_modules/antlr4ng/dist/atn/index.mjs +9465 -0
  218. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFA.cjs +559 -0
  219. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFA.js +559 -0
  220. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFA.mjs +539 -0
  221. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFASerializer.cjs +76 -0
  222. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFASerializer.js +76 -0
  223. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFASerializer.mjs +58 -0
  224. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAState.cjs +136 -0
  225. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAState.js +136 -0
  226. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAState.mjs +116 -0
  227. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAStateEqualityComparator.cjs +150 -0
  228. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAStateEqualityComparator.js +150 -0
  229. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAStateEqualityComparator.mjs +130 -0
  230. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/LexerDFASerializer.cjs +237 -0
  231. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/LexerDFASerializer.js +237 -0
  232. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/LexerDFASerializer.mjs +217 -0
  233. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/PredPrediction.cjs +31 -0
  234. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/PredPrediction.js +31 -0
  235. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/PredPrediction.mjs +13 -0
  236. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/index.cjs +571 -0
  237. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/index.js +571 -0
  238. openpinescript/_engine/node_modules/antlr4ng/dist/dfa/index.mjs +551 -0
  239. openpinescript/_engine/node_modules/antlr4ng/dist/index.cjs +17501 -0
  240. openpinescript/_engine/node_modules/antlr4ng/dist/index.mjs +17481 -0
  241. openpinescript/_engine/node_modules/antlr4ng/dist/misc/BitSet.cjs +208 -0
  242. openpinescript/_engine/node_modules/antlr4ng/dist/misc/BitSet.js +208 -0
  243. openpinescript/_engine/node_modules/antlr4ng/dist/misc/BitSet.mjs +190 -0
  244. openpinescript/_engine/node_modules/antlr4ng/dist/misc/DefaultEqualityComparator.cjs +68 -0
  245. openpinescript/_engine/node_modules/antlr4ng/dist/misc/DefaultEqualityComparator.js +68 -0
  246. openpinescript/_engine/node_modules/antlr4ng/dist/misc/DefaultEqualityComparator.mjs +48 -0
  247. openpinescript/_engine/node_modules/antlr4ng/dist/misc/EqualityComparator.cjs +17 -0
  248. openpinescript/_engine/node_modules/antlr4ng/dist/misc/EqualityComparator.js +17 -0
  249. openpinescript/_engine/node_modules/antlr4ng/dist/misc/EqualityComparator.mjs +0 -0
  250. openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashMap.cjs +545 -0
  251. openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashMap.js +545 -0
  252. openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashMap.mjs +525 -0
  253. openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashSet.cjs +438 -0
  254. openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashSet.js +438 -0
  255. openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashSet.mjs +418 -0
  256. openpinescript/_engine/node_modules/antlr4ng/dist/misc/InterpreterDataReader.cjs +4420 -0
  257. openpinescript/_engine/node_modules/antlr4ng/dist/misc/InterpreterDataReader.js +4420 -0
  258. openpinescript/_engine/node_modules/antlr4ng/dist/misc/InterpreterDataReader.mjs +4400 -0
  259. openpinescript/_engine/node_modules/antlr4ng/dist/misc/Interval.cjs +133 -0
  260. openpinescript/_engine/node_modules/antlr4ng/dist/misc/Interval.js +133 -0
  261. openpinescript/_engine/node_modules/antlr4ng/dist/misc/Interval.mjs +115 -0
  262. openpinescript/_engine/node_modules/antlr4ng/dist/misc/IntervalSet.cjs +834 -0
  263. openpinescript/_engine/node_modules/antlr4ng/dist/misc/IntervalSet.js +834 -0
  264. openpinescript/_engine/node_modules/antlr4ng/dist/misc/IntervalSet.mjs +814 -0
  265. openpinescript/_engine/node_modules/antlr4ng/dist/misc/MapKeyEqualityOperator.cjs +40 -0
  266. openpinescript/_engine/node_modules/antlr4ng/dist/misc/MapKeyEqualityOperator.js +40 -0
  267. openpinescript/_engine/node_modules/antlr4ng/dist/misc/MapKeyEqualityOperator.mjs +22 -0
  268. openpinescript/_engine/node_modules/antlr4ng/dist/misc/MultiMap.cjs +55 -0
  269. openpinescript/_engine/node_modules/antlr4ng/dist/misc/MultiMap.js +55 -0
  270. openpinescript/_engine/node_modules/antlr4ng/dist/misc/MultiMap.mjs +37 -0
  271. openpinescript/_engine/node_modules/antlr4ng/dist/misc/ObjectEqualityComparator.cjs +43 -0
  272. openpinescript/_engine/node_modules/antlr4ng/dist/misc/ObjectEqualityComparator.js +43 -0
  273. openpinescript/_engine/node_modules/antlr4ng/dist/misc/ObjectEqualityComparator.mjs +25 -0
  274. openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashMap.cjs +610 -0
  275. openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashMap.js +610 -0
  276. openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashMap.mjs +590 -0
  277. openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashSet.cjs +470 -0
  278. openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashSet.js +470 -0
  279. openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashSet.mjs +450 -0
  280. openpinescript/_engine/node_modules/antlr4ng/dist/misc/ParseCancellationException.cjs +34 -0
  281. openpinescript/_engine/node_modules/antlr4ng/dist/misc/ParseCancellationException.js +34 -0
  282. openpinescript/_engine/node_modules/antlr4ng/dist/misc/ParseCancellationException.mjs +16 -0
  283. openpinescript/_engine/node_modules/antlr4ng/dist/misc/index.cjs +4643 -0
  284. openpinescript/_engine/node_modules/antlr4ng/dist/misc/index.js +4643 -0
  285. openpinescript/_engine/node_modules/antlr4ng/dist/misc/index.mjs +4623 -0
  286. openpinescript/_engine/node_modules/antlr4ng/dist/tree/AbstractParseTreeVisitor.cjs +63 -0
  287. openpinescript/_engine/node_modules/antlr4ng/dist/tree/AbstractParseTreeVisitor.js +63 -0
  288. openpinescript/_engine/node_modules/antlr4ng/dist/tree/AbstractParseTreeVisitor.mjs +45 -0
  289. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ErrorNode.cjs +211 -0
  290. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ErrorNode.js +211 -0
  291. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ErrorNode.mjs +191 -0
  292. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTree.cjs +17 -0
  293. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTree.js +17 -0
  294. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTree.mjs +0 -0
  295. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeListener.cjs +17 -0
  296. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeListener.js +17 -0
  297. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeListener.mjs +0 -0
  298. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeVisitor.cjs +17 -0
  299. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeVisitor.js +17 -0
  300. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeVisitor.mjs +0 -0
  301. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeWalker.cjs +267 -0
  302. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeWalker.js +267 -0
  303. openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeWalker.mjs +247 -0
  304. openpinescript/_engine/node_modules/antlr4ng/dist/tree/TerminalNode.cjs +201 -0
  305. openpinescript/_engine/node_modules/antlr4ng/dist/tree/TerminalNode.js +201 -0
  306. openpinescript/_engine/node_modules/antlr4ng/dist/tree/TerminalNode.mjs +181 -0
  307. openpinescript/_engine/node_modules/antlr4ng/dist/tree/Trees.cjs +3159 -0
  308. openpinescript/_engine/node_modules/antlr4ng/dist/tree/Trees.js +3159 -0
  309. openpinescript/_engine/node_modules/antlr4ng/dist/tree/Trees.mjs +3139 -0
  310. openpinescript/_engine/node_modules/antlr4ng/dist/tree/index.cjs +16018 -0
  311. openpinescript/_engine/node_modules/antlr4ng/dist/tree/index.js +16018 -0
  312. openpinescript/_engine/node_modules/antlr4ng/dist/tree/index.mjs +15998 -0
  313. openpinescript/_engine/node_modules/antlr4ng/dist/utils/DoubleDict.cjs +568 -0
  314. openpinescript/_engine/node_modules/antlr4ng/dist/utils/DoubleDict.js +568 -0
  315. openpinescript/_engine/node_modules/antlr4ng/dist/utils/DoubleDict.mjs +548 -0
  316. openpinescript/_engine/node_modules/antlr4ng/dist/utils/MurmurHash.cjs +98 -0
  317. openpinescript/_engine/node_modules/antlr4ng/dist/utils/MurmurHash.js +98 -0
  318. openpinescript/_engine/node_modules/antlr4ng/dist/utils/MurmurHash.mjs +80 -0
  319. openpinescript/_engine/node_modules/antlr4ng/dist/utils/helpers.cjs +78 -0
  320. openpinescript/_engine/node_modules/antlr4ng/dist/utils/helpers.js +78 -0
  321. openpinescript/_engine/node_modules/antlr4ng/dist/utils/helpers.mjs +60 -0
  322. openpinescript/_engine/node_modules/antlr4ng/dist/utils/index.cjs +625 -0
  323. openpinescript/_engine/node_modules/antlr4ng/dist/utils/index.js +625 -0
  324. openpinescript/_engine/node_modules/antlr4ng/dist/utils/index.mjs +605 -0
  325. openpinescript/_engine/node_modules/antlr4ng/package.json +72 -0
  326. openpinescript/_engine/package.json +94 -0
  327. openpinescript/_runtime.py +29 -0
  328. openpinescript-0.1.1.dist-info/METADATA +140 -0
  329. openpinescript-0.1.1.dist-info/RECORD +332 -0
  330. openpinescript-0.1.1.dist-info/WHEEL +4 -0
  331. openpinescript-0.1.1.dist-info/entry_points.txt +2 -0
  332. openpinescript-0.1.1.dist-info/licenses/LICENSE +674 -0
@@ -0,0 +1,3781 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/atn/ATNConfigSet.ts
21
+ var ATNConfigSet_exports = {};
22
+ __export(ATNConfigSet_exports, {
23
+ ATNConfigSet: () => ATNConfigSet
24
+ });
25
+ module.exports = __toCommonJS(ATNConfigSet_exports);
26
+
27
+ // src/IntStream.ts
28
+ var IntStream;
29
+ ((IntStream2) => {
30
+ IntStream2.EOF = -1;
31
+ IntStream2.UNKNOWN_SOURCE_NAME = "<unknown>";
32
+ })(IntStream || (IntStream = {}));
33
+
34
+ // src/Token.ts
35
+ var Token;
36
+ ((Token2) => {
37
+ Token2.INVALID_TYPE = 0;
38
+ Token2.EPSILON = -2;
39
+ Token2.MIN_USER_TOKEN_TYPE = 1;
40
+ Token2.EOF = IntStream.EOF;
41
+ Token2.DEFAULT_CHANNEL = 0;
42
+ Token2.HIDDEN_CHANNEL = 1;
43
+ Token2.MIN_USER_CHANNEL_VALUE = 2;
44
+ })(Token || (Token = {}));
45
+ var isToken = /* @__PURE__ */ __name((candidate) => {
46
+ const token = candidate;
47
+ return token.tokenSource !== void 0 && token.channel !== void 0;
48
+ }, "isToken");
49
+
50
+ // src/misc/BitSet.ts
51
+ var BitSet = class {
52
+ static {
53
+ __name(this, "BitSet");
54
+ }
55
+ data;
56
+ /**
57
+ * Creates a new bit set. All bits are initially `false`.
58
+ *
59
+ * @param data Optional initial data.
60
+ */
61
+ constructor(data) {
62
+ if (data) {
63
+ this.data = new Uint32Array(data.map((value) => {
64
+ return value >>> 0;
65
+ }));
66
+ } else {
67
+ this.data = new Uint32Array(1);
68
+ }
69
+ }
70
+ /**
71
+ * @returns an iterator over all set bits.
72
+ */
73
+ [Symbol.iterator]() {
74
+ const length = this.data.length;
75
+ let currentIndex = 0;
76
+ let currentWord = this.data[currentIndex];
77
+ const words = this.data;
78
+ return {
79
+ [Symbol.iterator]() {
80
+ return this;
81
+ },
82
+ next: /* @__PURE__ */ __name(() => {
83
+ while (currentIndex < length) {
84
+ if (currentWord !== 0) {
85
+ const t = currentWord & -currentWord;
86
+ const value = (currentIndex << 5) + this.bitCount(t - 1);
87
+ currentWord ^= t;
88
+ return { done: false, value };
89
+ } else {
90
+ currentIndex++;
91
+ if (currentIndex < length) {
92
+ currentWord = words[currentIndex];
93
+ }
94
+ }
95
+ }
96
+ return { done: true, value: void 0 };
97
+ }, "next")
98
+ };
99
+ }
100
+ /**
101
+ * Sets a single bit or all of the bits in this `BitSet` to `false`.
102
+ *
103
+ * @param index the index of the bit to be cleared, or undefined to clear all bits.
104
+ */
105
+ clear(index) {
106
+ if (index === void 0) {
107
+ this.data = new Uint32Array();
108
+ } else {
109
+ this.resize(index);
110
+ this.data[index >>> 5] &= ~(1 << index);
111
+ }
112
+ }
113
+ /**
114
+ * Performs a logical **OR** of this bit set with the bit set argument. This bit set is modified so that a bit in it
115
+ * has the value `true` if and only if it either already had the value `true` or the corresponding bit in the bit
116
+ * set argument has the value `true`.
117
+ *
118
+ * @param set the bit set to be ORed with.
119
+ */
120
+ or(set) {
121
+ const minCount = Math.min(this.data.length, set.data.length);
122
+ for (let k = 0; k < minCount; ++k) {
123
+ this.data[k] |= set.data[k];
124
+ }
125
+ if (this.data.length < set.data.length) {
126
+ this.resize((set.data.length << 5) - 1);
127
+ const c = set.data.length;
128
+ for (let k = minCount; k < c; ++k) {
129
+ this.data[k] = set.data[k];
130
+ }
131
+ }
132
+ }
133
+ /**
134
+ * Returns the value of the bit with the specified index. The value is `true` if the bit with the index `bitIndex`
135
+ * is currently set in this `BitSet`; otherwise, the result is `false`.
136
+ *
137
+ * @param index the bit index
138
+ *
139
+ * @returns the value of the bit with the specified index.
140
+ */
141
+ get(index) {
142
+ if (index < 0) {
143
+ throw new RangeError("index cannot be negative");
144
+ }
145
+ const slot = index >>> 5;
146
+ if (slot >= this.data.length) {
147
+ return false;
148
+ }
149
+ return (this.data[slot] & 1 << index % 32) !== 0;
150
+ }
151
+ /**
152
+ * @returns the number of set bits.
153
+ */
154
+ get length() {
155
+ let result = 0;
156
+ const c = this.data.length;
157
+ const w = this.data;
158
+ for (let i = 0; i < c; i++) {
159
+ result += this.bitCount(w[i]);
160
+ }
161
+ return result;
162
+ }
163
+ /**
164
+ * @returns an array with indices of set bits.
165
+ */
166
+ values() {
167
+ const result = new Array(this.length);
168
+ let pos = 0;
169
+ const length = this.data.length;
170
+ for (let k = 0; k < length; ++k) {
171
+ let w = this.data[k];
172
+ while (w !== 0) {
173
+ const t = w & -w;
174
+ result[pos++] = (k << 5) + this.bitCount(t - 1);
175
+ w ^= t;
176
+ }
177
+ }
178
+ return result;
179
+ }
180
+ /**
181
+ * @returns the index of the first bit that is set to `true` that occurs on or after the specified starting index.
182
+ * If no such bit exists then undefined is returned.
183
+ *
184
+ * @param fromIndex the index to start checking from (inclusive)
185
+ */
186
+ nextSetBit(fromIndex) {
187
+ if (fromIndex < 0) {
188
+ throw new RangeError("index cannot be negative");
189
+ }
190
+ for (const index of this) {
191
+ if (index >= fromIndex) {
192
+ return index;
193
+ }
194
+ }
195
+ return void 0;
196
+ }
197
+ /**
198
+ * Sets the bit at the specified index to `true`.
199
+ *
200
+ * @param index a bit index
201
+ */
202
+ set(index) {
203
+ if (index < 0) {
204
+ throw new RangeError("index cannot be negative");
205
+ }
206
+ this.resize(index);
207
+ this.data[index >>> 5] |= 1 << index % 32;
208
+ }
209
+ /**
210
+ * @returns a string representation of this bit set.
211
+ */
212
+ toString() {
213
+ return "{" + this.values().join(", ") + "}";
214
+ }
215
+ resize(index) {
216
+ const count = index + 32 >>> 5;
217
+ if (count <= this.data.length) {
218
+ return;
219
+ }
220
+ const data = new Uint32Array(count);
221
+ data.set(this.data);
222
+ data.fill(0, this.data.length);
223
+ this.data = data;
224
+ }
225
+ bitCount(v) {
226
+ v = v - (v >> 1 & 1431655765);
227
+ v = (v & 858993459) + (v >> 2 & 858993459);
228
+ v = v + (v >> 4) & 252645135;
229
+ v = v + (v >> 8);
230
+ v = v + (v >> 16);
231
+ return v & 63;
232
+ }
233
+ };
234
+
235
+ // src/utils/MurmurHash.ts
236
+ var c1 = 3432918353;
237
+ var c2 = 461845907;
238
+ var r1 = 15;
239
+ var r2 = 13;
240
+ var m = 5;
241
+ var n = 3864292196;
242
+ var MurmurHash = class _MurmurHash {
243
+ static {
244
+ __name(this, "MurmurHash");
245
+ }
246
+ static defaultSeed = 701;
247
+ constructor() {
248
+ }
249
+ /**
250
+ * Initialize the hash using the specified {@code seed}.
251
+ *
252
+ * @param seed the seed
253
+ *
254
+ * @returns the intermediate hash value
255
+ */
256
+ static initialize(seed = _MurmurHash.defaultSeed) {
257
+ return seed;
258
+ }
259
+ static updateFromComparable(hash, value) {
260
+ return this.update(hash, value?.hashCode() ?? 0);
261
+ }
262
+ /**
263
+ * Update the intermediate hash value for the next input {@code value}.
264
+ *
265
+ * @param hash The intermediate hash value.
266
+ * @param value the value to add to the current hash.
267
+ *
268
+ * @returns the updated intermediate hash value
269
+ */
270
+ static update(hash, value) {
271
+ value = Math.imul(value, c1);
272
+ value = value << r1 | value >>> 32 - r1;
273
+ value = Math.imul(value, c2);
274
+ hash = hash ^ value;
275
+ hash = hash << r2 | hash >>> 32 - r2;
276
+ hash = Math.imul(hash, m) + n;
277
+ return hash;
278
+ }
279
+ /**
280
+ * Apply the final computation steps to the intermediate value {@code hash}
281
+ * to form the final result of the MurmurHash 3 hash function.
282
+ *
283
+ * @param hash The intermediate hash value.
284
+ * @param entryCount The number of values added to the hash.
285
+ *
286
+ * @returns the final hash result
287
+ */
288
+ static finish(hash, entryCount) {
289
+ hash ^= entryCount * 4;
290
+ hash ^= hash >>> 16;
291
+ hash = Math.imul(hash, 2246822507);
292
+ hash ^= hash >>> 13;
293
+ hash = Math.imul(hash, 3266489909);
294
+ hash ^= hash >>> 16;
295
+ return hash;
296
+ }
297
+ /**
298
+ * An all-in-one convenience method to compute a hash for a single value.
299
+ *
300
+ * @param value The value to hash.
301
+ * @param seed The seed for the hash value.
302
+ *
303
+ * @returns The computed hash.
304
+ */
305
+ static hashCode(value, seed) {
306
+ return _MurmurHash.finish(_MurmurHash.update(seed ?? _MurmurHash.defaultSeed, value), 1);
307
+ }
308
+ };
309
+
310
+ // src/misc/ObjectEqualityComparator.ts
311
+ var ObjectEqualityComparator = class _ObjectEqualityComparator {
312
+ static {
313
+ __name(this, "ObjectEqualityComparator");
314
+ }
315
+ static instance = new _ObjectEqualityComparator();
316
+ hashCode(obj) {
317
+ if (obj == null) {
318
+ return 0;
319
+ }
320
+ return obj.hashCode();
321
+ }
322
+ equals(a, b) {
323
+ if (a == null) {
324
+ return b == null;
325
+ }
326
+ return a.equals(b);
327
+ }
328
+ };
329
+
330
+ // src/misc/DefaultEqualityComparator.ts
331
+ var DefaultEqualityComparator = class _DefaultEqualityComparator {
332
+ static {
333
+ __name(this, "DefaultEqualityComparator");
334
+ }
335
+ static instance = new _DefaultEqualityComparator();
336
+ hashCode(obj) {
337
+ if (obj == null) {
338
+ return 0;
339
+ }
340
+ return ObjectEqualityComparator.instance.hashCode(obj);
341
+ }
342
+ equals(a, b) {
343
+ if (a == null) {
344
+ return b == null;
345
+ }
346
+ if (typeof a === "string" || typeof a === "number") {
347
+ return a === b;
348
+ }
349
+ return ObjectEqualityComparator.instance.equals(a, b);
350
+ }
351
+ };
352
+
353
+ // src/misc/HashSet.ts
354
+ var HashSet = class _HashSet {
355
+ static {
356
+ __name(this, "HashSet");
357
+ }
358
+ static defaultLoadFactor = 0.75;
359
+ static initialCapacity = 16;
360
+ // must be power of 2
361
+ comparator;
362
+ buckets;
363
+ threshold;
364
+ /** How many elements in set */
365
+ itemCount = 0;
366
+ constructor(comparatorOrSet, initialCapacity = _HashSet.initialCapacity) {
367
+ if (comparatorOrSet instanceof _HashSet) {
368
+ this.comparator = comparatorOrSet.comparator;
369
+ this.buckets = comparatorOrSet.buckets.slice(0);
370
+ for (let i = 0; i < this.buckets.length; i++) {
371
+ const bucket = this.buckets[i];
372
+ if (bucket) {
373
+ this.buckets[i] = bucket.slice(0);
374
+ }
375
+ }
376
+ this.itemCount = comparatorOrSet.itemCount;
377
+ this.threshold = comparatorOrSet.threshold;
378
+ } else {
379
+ this.comparator = comparatorOrSet ?? DefaultEqualityComparator.instance;
380
+ this.buckets = this.createBuckets(initialCapacity);
381
+ this.threshold = Math.floor(_HashSet.initialCapacity * _HashSet.defaultLoadFactor);
382
+ }
383
+ }
384
+ /**
385
+ * Add `o` to set if not there; return existing value if already
386
+ * there. This method performs the same operation as {@link #add} aside from
387
+ * the return value.
388
+ *
389
+ * @param o the object to add to the set.
390
+ *
391
+ * @returns An existing element that equals to `o` if already in set, otherwise `o`.
392
+ */
393
+ getOrAdd(o) {
394
+ if (this.itemCount > this.threshold) {
395
+ this.expand();
396
+ }
397
+ const b = this.getBucket(o);
398
+ let bucket = this.buckets[b];
399
+ if (!bucket) {
400
+ bucket = [o];
401
+ this.buckets[b] = bucket;
402
+ ++this.itemCount;
403
+ return o;
404
+ }
405
+ for (const existing of bucket) {
406
+ if (this.comparator.equals(existing, o)) {
407
+ return existing;
408
+ }
409
+ }
410
+ bucket.push(o);
411
+ ++this.itemCount;
412
+ return o;
413
+ }
414
+ get(o) {
415
+ if (o == null) {
416
+ return o;
417
+ }
418
+ const b = this.getBucket(o);
419
+ const bucket = this.buckets[b];
420
+ if (!bucket) {
421
+ return void 0;
422
+ }
423
+ for (const e of bucket) {
424
+ if (this.comparator.equals(e, o)) {
425
+ return e;
426
+ }
427
+ }
428
+ return void 0;
429
+ }
430
+ /**
431
+ * Removes the specified element from this set if it is present.
432
+ *
433
+ * @param o object to be removed from this set, if present.
434
+ *
435
+ * @returns `true` if the set contained the specified element.
436
+ */
437
+ remove(o) {
438
+ if (o == null) {
439
+ return false;
440
+ }
441
+ const b = this.getBucket(o);
442
+ const bucket = this.buckets[b];
443
+ if (!bucket) {
444
+ return false;
445
+ }
446
+ for (let i = 0; i < bucket.length; i++) {
447
+ const existing = bucket[i];
448
+ if (this.comparator.equals(existing, o)) {
449
+ bucket.splice(i, 1);
450
+ --this.itemCount;
451
+ return true;
452
+ }
453
+ }
454
+ return false;
455
+ }
456
+ hashCode() {
457
+ let hash = MurmurHash.initialize();
458
+ for (const bucket of this.buckets) {
459
+ if (bucket == null) {
460
+ continue;
461
+ }
462
+ for (const o of bucket) {
463
+ if (o == null) {
464
+ break;
465
+ }
466
+ hash = MurmurHash.update(hash, this.comparator.hashCode(o));
467
+ }
468
+ }
469
+ hash = MurmurHash.finish(hash, this.size);
470
+ return hash;
471
+ }
472
+ equals(o) {
473
+ if (o === this) {
474
+ return true;
475
+ }
476
+ if (!(o instanceof _HashSet)) {
477
+ return false;
478
+ }
479
+ if (o.size !== this.size) {
480
+ return false;
481
+ }
482
+ return this.containsAll(o);
483
+ }
484
+ add(t) {
485
+ const existing = this.getOrAdd(t);
486
+ return existing === t;
487
+ }
488
+ contains(o) {
489
+ return this.containsFast(o);
490
+ }
491
+ containsFast(obj) {
492
+ if (obj == null) {
493
+ return false;
494
+ }
495
+ return this.get(obj) !== void 0;
496
+ }
497
+ *[Symbol.iterator]() {
498
+ yield* this.toArray();
499
+ }
500
+ toArray() {
501
+ const a = new Array(this.size);
502
+ let i = 0;
503
+ for (const bucket of this.buckets) {
504
+ if (bucket == null) {
505
+ continue;
506
+ }
507
+ for (const o of bucket) {
508
+ if (o == null) {
509
+ break;
510
+ }
511
+ a[i++] = o;
512
+ }
513
+ }
514
+ return a;
515
+ }
516
+ containsAll(collection) {
517
+ if (collection instanceof _HashSet) {
518
+ for (const bucket of collection.buckets) {
519
+ if (bucket == null) {
520
+ continue;
521
+ }
522
+ for (const o of bucket) {
523
+ if (o == null) {
524
+ break;
525
+ }
526
+ if (!this.containsFast(o)) {
527
+ return false;
528
+ }
529
+ }
530
+ }
531
+ } else {
532
+ for (const o of collection) {
533
+ if (!this.containsFast(o)) {
534
+ return false;
535
+ }
536
+ }
537
+ }
538
+ return true;
539
+ }
540
+ addAll(c) {
541
+ let changed = false;
542
+ for (const o of c) {
543
+ const existing = this.getOrAdd(o);
544
+ if (existing !== o) {
545
+ changed = true;
546
+ }
547
+ }
548
+ return changed;
549
+ }
550
+ clear() {
551
+ this.buckets = this.createBuckets(_HashSet.initialCapacity);
552
+ this.itemCount = 0;
553
+ this.threshold = Math.floor(_HashSet.initialCapacity * _HashSet.defaultLoadFactor);
554
+ }
555
+ toString() {
556
+ if (this.size === 0) {
557
+ return "{}";
558
+ }
559
+ let buf = "{";
560
+ let first = true;
561
+ for (const bucket of this.buckets) {
562
+ if (bucket == null) {
563
+ continue;
564
+ }
565
+ for (const o of bucket) {
566
+ if (o == null) {
567
+ break;
568
+ }
569
+ if (first) {
570
+ first = false;
571
+ } else {
572
+ buf += ", ";
573
+ }
574
+ buf += o.toString();
575
+ }
576
+ }
577
+ buf += "}";
578
+ return buf;
579
+ }
580
+ toTableString() {
581
+ let buf = "";
582
+ for (const bucket of this.buckets) {
583
+ if (bucket == null) {
584
+ buf += "null\n";
585
+ continue;
586
+ }
587
+ buf += "[";
588
+ let first = true;
589
+ for (const o of bucket) {
590
+ if (first) {
591
+ first = false;
592
+ } else {
593
+ buf += " ";
594
+ }
595
+ if (o == null) {
596
+ buf += "_";
597
+ } else {
598
+ buf += o.toString();
599
+ }
600
+ }
601
+ buf += "]\n";
602
+ }
603
+ return buf;
604
+ }
605
+ getBucket(o) {
606
+ const hash = this.comparator.hashCode(o);
607
+ const b = hash & this.buckets.length - 1;
608
+ return b;
609
+ }
610
+ expand() {
611
+ const old = this.buckets;
612
+ const newCapacity = this.buckets.length * 2;
613
+ const newTable = this.createBuckets(newCapacity);
614
+ this.buckets = newTable;
615
+ this.threshold = Math.floor(newCapacity * _HashSet.defaultLoadFactor);
616
+ for (const bucket of old) {
617
+ if (!bucket) {
618
+ continue;
619
+ }
620
+ for (const o of bucket) {
621
+ const b = this.getBucket(o);
622
+ let newBucket = this.buckets[b];
623
+ if (!newBucket) {
624
+ newBucket = [];
625
+ this.buckets[b] = newBucket;
626
+ }
627
+ newBucket.push(o);
628
+ }
629
+ }
630
+ }
631
+ get size() {
632
+ return this.itemCount;
633
+ }
634
+ get isEmpty() {
635
+ return this.itemCount === 0;
636
+ }
637
+ /**
638
+ * Return an array of `T[]` with length `capacity`.
639
+ *
640
+ * @param capacity the length of the array to return
641
+ * @returns the newly constructed array
642
+ */
643
+ createBuckets(capacity) {
644
+ return new Array(capacity);
645
+ }
646
+ };
647
+
648
+ // src/misc/Interval.ts
649
+ var Interval = class _Interval {
650
+ static {
651
+ __name(this, "Interval");
652
+ }
653
+ static INVALID_INTERVAL = new _Interval(-1, -2);
654
+ static INTERVAL_POOL_MAX_VALUE = 1e3;
655
+ static cache = [];
656
+ start;
657
+ stop;
658
+ cachedHashCode;
659
+ constructor(start, stop) {
660
+ this.start = start;
661
+ this.stop = stop;
662
+ this.cachedHashCode = Math.imul(651 + start, 31) + stop;
663
+ }
664
+ /**
665
+ * Creates a new interval from the given values.
666
+ *
667
+ * Interval objects are used readonly so share all with the
668
+ * same single value a==b up to some max size. Use an array as a perfect hash.
669
+ * Return shared object for 0..INTERVAL_POOL_MAX_VALUE or a new
670
+ * Interval object with a..a in it. On Java.g4, 218623 IntervalSets
671
+ * have a..a (set with 1 element).
672
+ *
673
+ * @param a The start of the interval.
674
+ * @param b The end of the interval (inclusive).
675
+ *
676
+ * @returns A cached or new interval.
677
+ */
678
+ static of(a, b) {
679
+ if (a !== b || a < 0 || a > _Interval.INTERVAL_POOL_MAX_VALUE) {
680
+ return new _Interval(a, b);
681
+ }
682
+ if (!_Interval.cache[a]) {
683
+ _Interval.cache[a] = new _Interval(a, a);
684
+ }
685
+ return _Interval.cache[a];
686
+ }
687
+ equals(o) {
688
+ return this.start === o.start && this.stop === o.stop;
689
+ }
690
+ hashCode() {
691
+ return this.cachedHashCode;
692
+ }
693
+ /** Does this start completely before other? Disjoint */
694
+ startsBeforeDisjoint(other) {
695
+ return this.start < other.start && this.stop < other.start;
696
+ }
697
+ /** Does this start at or before other? Nondisjoint */
698
+ startsBeforeNonDisjoint(other) {
699
+ return this.start <= other.start && this.stop >= other.start;
700
+ }
701
+ /** Does this.start start after other.stop? May or may not be disjoint */
702
+ startsAfter(other) {
703
+ return this.start > other.start;
704
+ }
705
+ /** Does this start completely after other? Disjoint */
706
+ startsAfterDisjoint(other) {
707
+ return this.start > other.stop;
708
+ }
709
+ /** Does this start after other? NonDisjoint */
710
+ startsAfterNonDisjoint(other) {
711
+ return this.start > other.start && this.start <= other.stop;
712
+ }
713
+ /** Are both ranges disjoint? I.e., no overlap? */
714
+ disjoint(other) {
715
+ return this.startsBeforeDisjoint(other) || this.startsAfterDisjoint(other);
716
+ }
717
+ /** Are two intervals adjacent such as 0..41 and 42..42? */
718
+ adjacent(other) {
719
+ return this.start === other.stop + 1 || this.stop === other.start - 1;
720
+ }
721
+ properlyContains(other) {
722
+ return other.start >= this.start && other.stop <= this.stop;
723
+ }
724
+ /** Return the interval computed from combining this and other */
725
+ union(other) {
726
+ return _Interval.of(Math.min(this.start, other.start), Math.max(this.stop, other.stop));
727
+ }
728
+ /** Return the interval in common between this and o */
729
+ intersection(other) {
730
+ return _Interval.of(Math.max(this.start, other.start), Math.min(this.stop, other.stop));
731
+ }
732
+ /**
733
+ * Return the interval with elements from this not in other;
734
+ * other must not be totally enclosed (properly contained)
735
+ * within this, which would result in two disjoint intervals
736
+ * instead of the single one returned by this method.
737
+ */
738
+ differenceNotProperlyContained(other) {
739
+ let diff = null;
740
+ if (other.startsBeforeNonDisjoint(this)) {
741
+ diff = _Interval.of(Math.max(this.start, other.stop + 1), this.stop);
742
+ } else if (other.startsAfterNonDisjoint(this)) {
743
+ diff = _Interval.of(this.start, other.start - 1);
744
+ }
745
+ return diff;
746
+ }
747
+ toString() {
748
+ return `${this.start}..${this.stop}`;
749
+ }
750
+ get length() {
751
+ if (this.stop < this.start) {
752
+ return 0;
753
+ }
754
+ return this.stop - this.start + 1;
755
+ }
756
+ };
757
+
758
+ // src/Vocabulary.ts
759
+ var Vocabulary = class _Vocabulary {
760
+ static {
761
+ __name(this, "Vocabulary");
762
+ }
763
+ static EMPTY_NAMES = [];
764
+ /**
765
+ * Gets an empty {@link Vocabulary} instance.
766
+ *
767
+ *
768
+ * No literal or symbol names are assigned to token types, so
769
+ * {@link #getDisplayName(int)} returns the numeric value for all tokens
770
+ * except {@link Token#EOF}.
771
+ */
772
+ static EMPTY_VOCABULARY = new _Vocabulary(_Vocabulary.EMPTY_NAMES, _Vocabulary.EMPTY_NAMES, _Vocabulary.EMPTY_NAMES);
773
+ maxTokenType;
774
+ literalNames;
775
+ symbolicNames;
776
+ displayNames;
777
+ /**
778
+ * Constructs a new instance of {@link Vocabulary} from the specified
779
+ * literal, symbolic, and display token names.
780
+ *
781
+ * @param literalNames The literal names assigned to tokens, or `null`
782
+ * if no literal names are assigned.
783
+ * @param symbolicNames The symbolic names assigned to tokens, or
784
+ * `null` if no symbolic names are assigned.
785
+ * @param displayNames The display names assigned to tokens, or `null`
786
+ * to use the values in `literalNames` and `symbolicNames` as
787
+ * the source of display names, as described in
788
+ * {@link #getDisplayName(int)}.
789
+ */
790
+ constructor(literalNames, symbolicNames, displayNames) {
791
+ this.literalNames = literalNames ?? _Vocabulary.EMPTY_NAMES;
792
+ this.symbolicNames = symbolicNames ?? _Vocabulary.EMPTY_NAMES;
793
+ this.displayNames = displayNames ?? _Vocabulary.EMPTY_NAMES;
794
+ this.maxTokenType = Math.max(this.displayNames.length, Math.max(
795
+ this.literalNames.length,
796
+ this.symbolicNames.length
797
+ )) - 1;
798
+ }
799
+ /**
800
+ * Returns a {@link Vocabulary} instance from the specified set of token
801
+ * names. This method acts as a compatibility layer for the single
802
+ * `tokenNames` array generated by previous releases of ANTLR.
803
+ *
804
+ * The resulting vocabulary instance returns `null` for
805
+ * {@link getLiteralName getLiteralName(int)} and {@link getSymbolicName getSymbolicName(int)}, and the
806
+ * value from `tokenNames` for the display names.
807
+ *
808
+ * @param tokenNames The token names, or `null` if no token names are
809
+ * available.
810
+ * @returns A {@link Vocabulary} instance which uses `tokenNames` for
811
+ * the display names of tokens.
812
+ */
813
+ static fromTokenNames(tokenNames) {
814
+ if (tokenNames == null || tokenNames.length === 0) {
815
+ return _Vocabulary.EMPTY_VOCABULARY;
816
+ }
817
+ const literalNames = [...tokenNames];
818
+ const symbolicNames = [...tokenNames];
819
+ for (let i = 0; i < tokenNames.length; i++) {
820
+ const tokenName = tokenNames[i];
821
+ if (tokenName == null) {
822
+ continue;
823
+ }
824
+ if (tokenName.length > 0) {
825
+ const firstChar = tokenName.codePointAt(0);
826
+ if (firstChar === 39) {
827
+ symbolicNames[i] = null;
828
+ continue;
829
+ } else if (firstChar >= 65 && firstChar <= 90) {
830
+ literalNames[i] = null;
831
+ continue;
832
+ }
833
+ }
834
+ literalNames[i] = null;
835
+ symbolicNames[i] = null;
836
+ }
837
+ return new _Vocabulary(literalNames, symbolicNames, tokenNames);
838
+ }
839
+ getMaxTokenType() {
840
+ return this.maxTokenType;
841
+ }
842
+ getLiteralName(tokenType) {
843
+ if (tokenType >= 0 && tokenType < this.literalNames.length) {
844
+ return this.literalNames[tokenType];
845
+ }
846
+ return null;
847
+ }
848
+ getSymbolicName(tokenType) {
849
+ if (tokenType >= 0 && tokenType < this.symbolicNames.length) {
850
+ return this.symbolicNames[tokenType];
851
+ }
852
+ if (tokenType === Token.EOF) {
853
+ return "EOF";
854
+ }
855
+ return null;
856
+ }
857
+ getDisplayName(tokenType) {
858
+ if (tokenType >= 0 && tokenType < this.displayNames.length) {
859
+ const displayName = this.displayNames[tokenType];
860
+ if (displayName != null) {
861
+ return displayName;
862
+ }
863
+ }
864
+ const literalName = this.getLiteralName(tokenType);
865
+ if (literalName != null) {
866
+ return literalName;
867
+ }
868
+ const symbolicName = this.getSymbolicName(tokenType);
869
+ if (symbolicName != null) {
870
+ return symbolicName;
871
+ }
872
+ return `${tokenType}`;
873
+ }
874
+ getLiteralNames() {
875
+ return this.literalNames;
876
+ }
877
+ getSymbolicNames() {
878
+ return this.symbolicNames;
879
+ }
880
+ getDisplayNames() {
881
+ return this.displayNames;
882
+ }
883
+ };
884
+
885
+ // src/misc/IntervalSet.ts
886
+ var IntervalSet = class _IntervalSet {
887
+ static {
888
+ __name(this, "IntervalSet");
889
+ }
890
+ /** The list of sorted, disjoint intervals. */
891
+ intervals = [];
892
+ cachedHashCode;
893
+ constructor(set) {
894
+ if (set) {
895
+ if (Array.isArray(set)) {
896
+ for (const el of set) {
897
+ this.addOne(el);
898
+ }
899
+ } else {
900
+ this.addSet(set);
901
+ }
902
+ }
903
+ }
904
+ /** Create a set with all ints within range [a..b] (inclusive) */
905
+ static of(a, b) {
906
+ const s = new _IntervalSet();
907
+ s.addRange(a, b);
908
+ return s;
909
+ }
910
+ /** Combine all sets in the array and return the union of them */
911
+ static or(sets) {
912
+ const result = new _IntervalSet();
913
+ for (const set of sets) {
914
+ result.addSet(set);
915
+ }
916
+ return result;
917
+ }
918
+ [Symbol.iterator]() {
919
+ return this.intervals[Symbol.iterator]();
920
+ }
921
+ get(index) {
922
+ return this.intervals[index];
923
+ }
924
+ /**
925
+ * Returns the minimum value contained in the set if not isNil().
926
+ *
927
+ * @returns the minimum value contained in the set.
928
+ */
929
+ get minElement() {
930
+ if (this.intervals.length === 0) {
931
+ return Token.INVALID_TYPE;
932
+ }
933
+ return this.intervals[0].start;
934
+ }
935
+ /**
936
+ * Returns the maximum value contained in the set if not isNil().
937
+ *
938
+ * @returns the maximum value contained in the set.
939
+ */
940
+ get maxElement() {
941
+ if (this.intervals.length === 0) {
942
+ return Token.INVALID_TYPE;
943
+ }
944
+ return this.intervals[this.intervals.length - 1].stop;
945
+ }
946
+ clear() {
947
+ this.cachedHashCode = void 0;
948
+ this.intervals = [];
949
+ }
950
+ /**
951
+ * Add a single element to the set. An isolated element is stored
952
+ * as a range el..el.
953
+ */
954
+ addOne(v) {
955
+ this.addInterval(new Interval(v, v));
956
+ }
957
+ /**
958
+ * Add interval; i.e., add all integers from a to b to set.
959
+ * If b < a, do nothing.
960
+ * Keep list in sorted order (by left range value).
961
+ * If overlap, combine ranges. For example,
962
+ * If this is {1..5, 10..20}, adding 6..7 yields
963
+ * {1..5, 6..7, 10..20}. Adding 4..8 yields {1..8, 10..20}.
964
+ */
965
+ addRange(l, h) {
966
+ this.addInterval(new Interval(l, h));
967
+ }
968
+ addInterval(addition) {
969
+ this.cachedHashCode = void 0;
970
+ if (this.intervals.length === 0) {
971
+ this.intervals.push(addition);
972
+ } else {
973
+ for (let pos = 0; pos < this.intervals.length; pos++) {
974
+ const existing = this.intervals[pos];
975
+ if (addition.equals(existing)) {
976
+ return;
977
+ }
978
+ if (addition.adjacent(existing) || !addition.disjoint(existing)) {
979
+ const bigger = addition.union(existing);
980
+ this.intervals[pos] = bigger;
981
+ for (let sub = pos + 1; sub < this.intervals.length; ) {
982
+ const next = this.intervals[sub];
983
+ if (!bigger.adjacent(next) && bigger.disjoint(next)) {
984
+ break;
985
+ }
986
+ this.intervals.splice(sub, 1);
987
+ this.intervals[pos] = bigger.union(next);
988
+ }
989
+ return;
990
+ }
991
+ if (addition.startsBeforeDisjoint(existing)) {
992
+ this.intervals.splice(pos, 0, addition);
993
+ return;
994
+ }
995
+ }
996
+ this.intervals.push(addition);
997
+ }
998
+ }
999
+ addSet(other) {
1000
+ other.intervals.forEach((toAdd) => {
1001
+ return this.addInterval(toAdd);
1002
+ }, this);
1003
+ return this;
1004
+ }
1005
+ complementWithVocabulary(vocabulary) {
1006
+ const result = new _IntervalSet();
1007
+ if (!vocabulary) {
1008
+ return result;
1009
+ }
1010
+ if (vocabulary.length === 0) {
1011
+ return result;
1012
+ }
1013
+ result.addSet(vocabulary);
1014
+ return result.subtract(this);
1015
+ }
1016
+ complement(minElement, maxElement) {
1017
+ const result = new _IntervalSet();
1018
+ result.addInterval(new Interval(minElement, maxElement));
1019
+ return result.subtract(this);
1020
+ }
1021
+ /** combine all sets in the array returned the or'd value */
1022
+ or(sets) {
1023
+ const result = new _IntervalSet();
1024
+ result.addSet(this);
1025
+ sets.forEach((set) => {
1026
+ return result.addSet(set);
1027
+ });
1028
+ return result;
1029
+ }
1030
+ and(other) {
1031
+ if (other.length === 0) {
1032
+ return new _IntervalSet();
1033
+ }
1034
+ const myIntervals = this.intervals;
1035
+ const theirIntervals = other.intervals;
1036
+ let intersection;
1037
+ const mySize = myIntervals.length;
1038
+ const theirSize = theirIntervals.length;
1039
+ let i = 0;
1040
+ let j = 0;
1041
+ while (i < mySize && j < theirSize) {
1042
+ const mine = myIntervals[i];
1043
+ const theirs = theirIntervals[j];
1044
+ if (mine.startsBeforeDisjoint(theirs)) {
1045
+ i++;
1046
+ } else if (theirs.startsBeforeDisjoint(mine)) {
1047
+ j++;
1048
+ } else if (mine.properlyContains(theirs)) {
1049
+ if (!intersection) {
1050
+ intersection = new _IntervalSet();
1051
+ }
1052
+ intersection.addInterval(mine.intersection(theirs));
1053
+ j++;
1054
+ } else if (theirs.properlyContains(mine)) {
1055
+ if (!intersection) {
1056
+ intersection = new _IntervalSet();
1057
+ }
1058
+ intersection.addInterval(mine.intersection(theirs));
1059
+ i++;
1060
+ } else if (!mine.disjoint(theirs)) {
1061
+ if (!intersection) {
1062
+ intersection = new _IntervalSet();
1063
+ }
1064
+ intersection.addInterval(mine.intersection(theirs));
1065
+ if (mine.startsAfterNonDisjoint(theirs)) {
1066
+ j++;
1067
+ } else if (theirs.startsAfterNonDisjoint(mine)) {
1068
+ i++;
1069
+ }
1070
+ }
1071
+ }
1072
+ if (!intersection) {
1073
+ return new _IntervalSet();
1074
+ }
1075
+ return intersection;
1076
+ }
1077
+ /**
1078
+ * Compute the set difference between two interval sets. The specific
1079
+ * operation is `left - right`. If either of the input sets is
1080
+ * `null`, it is treated as though it was an empty set.
1081
+ */
1082
+ subtract(other) {
1083
+ if (this.length === 0) {
1084
+ return new _IntervalSet();
1085
+ }
1086
+ const result = new _IntervalSet(this);
1087
+ if (other.length === 0) {
1088
+ return result;
1089
+ }
1090
+ let resultI = 0;
1091
+ let rightI = 0;
1092
+ while (resultI < result.intervals.length && rightI < other.intervals.length) {
1093
+ const resultInterval = result.intervals[resultI];
1094
+ const rightInterval = other.intervals[rightI];
1095
+ if (rightInterval.stop < resultInterval.start) {
1096
+ rightI++;
1097
+ continue;
1098
+ }
1099
+ if (rightInterval.start > resultInterval.stop) {
1100
+ resultI++;
1101
+ continue;
1102
+ }
1103
+ let beforeCurrent;
1104
+ let afterCurrent;
1105
+ if (rightInterval.start > resultInterval.start) {
1106
+ beforeCurrent = new Interval(resultInterval.start, rightInterval.start - 1);
1107
+ }
1108
+ if (rightInterval.stop < resultInterval.stop) {
1109
+ afterCurrent = new Interval(rightInterval.stop + 1, resultInterval.stop);
1110
+ }
1111
+ if (beforeCurrent) {
1112
+ if (afterCurrent) {
1113
+ result.intervals[resultI] = beforeCurrent;
1114
+ result.intervals.splice(resultI + 1, 0, afterCurrent);
1115
+ resultI++;
1116
+ rightI++;
1117
+ } else {
1118
+ result.intervals[resultI] = beforeCurrent;
1119
+ resultI++;
1120
+ }
1121
+ } else {
1122
+ if (afterCurrent) {
1123
+ result.intervals[resultI] = afterCurrent;
1124
+ rightI++;
1125
+ } else {
1126
+ result.intervals.splice(resultI, 1);
1127
+ }
1128
+ }
1129
+ }
1130
+ return result;
1131
+ }
1132
+ contains(el) {
1133
+ const n2 = this.intervals.length;
1134
+ let l = 0;
1135
+ let r = n2 - 1;
1136
+ while (l <= r) {
1137
+ const m2 = Math.floor((l + r) / 2);
1138
+ const interval = this.intervals[m2];
1139
+ if (interval.stop < el) {
1140
+ l = m2 + 1;
1141
+ } else if (interval.start > el) {
1142
+ r = m2 - 1;
1143
+ } else {
1144
+ return true;
1145
+ }
1146
+ }
1147
+ return false;
1148
+ }
1149
+ removeRange(toRemove) {
1150
+ this.cachedHashCode = void 0;
1151
+ if (toRemove.start === toRemove.stop) {
1152
+ this.removeOne(toRemove.start);
1153
+ } else if (this.intervals !== null) {
1154
+ let pos = 0;
1155
+ for (const existing of this.intervals) {
1156
+ if (toRemove.stop <= existing.start) {
1157
+ return;
1158
+ } else if (toRemove.start > existing.start && toRemove.stop < existing.stop) {
1159
+ this.intervals[pos] = new Interval(existing.start, toRemove.start);
1160
+ const x = new Interval(toRemove.stop, existing.stop);
1161
+ this.intervals.splice(pos, 0, x);
1162
+ return;
1163
+ } else if (toRemove.start <= existing.start && toRemove.stop >= existing.stop) {
1164
+ this.intervals.splice(pos, 1);
1165
+ pos = pos - 1;
1166
+ } else if (toRemove.start < existing.stop) {
1167
+ this.intervals[pos] = new Interval(existing.start, toRemove.start);
1168
+ } else if (toRemove.stop < existing.stop) {
1169
+ this.intervals[pos] = new Interval(toRemove.stop, existing.stop);
1170
+ }
1171
+ pos += 1;
1172
+ }
1173
+ }
1174
+ }
1175
+ removeOne(value) {
1176
+ this.cachedHashCode = void 0;
1177
+ for (let i = 0; i < this.intervals.length; i++) {
1178
+ const existing = this.intervals[i];
1179
+ if (value < existing.start) {
1180
+ return;
1181
+ } else if (value === existing.start && value === existing.stop) {
1182
+ this.intervals.splice(i, 1);
1183
+ return;
1184
+ } else if (value === existing.start) {
1185
+ this.intervals[i] = new Interval(existing.start + 1, existing.stop);
1186
+ return;
1187
+ } else if (value === existing.stop) {
1188
+ this.intervals[i] = new Interval(existing.start, existing.stop - 1);
1189
+ return;
1190
+ } else if (value < existing.stop) {
1191
+ const replace = new Interval(existing.start, value - 1);
1192
+ this.intervals[i] = new Interval(value + 1, existing.stop);
1193
+ this.intervals.splice(i, 0, replace);
1194
+ return;
1195
+ }
1196
+ }
1197
+ }
1198
+ hashCode() {
1199
+ if (this.cachedHashCode === void 0) {
1200
+ let hash = MurmurHash.initialize();
1201
+ for (const interval of this.intervals) {
1202
+ hash = MurmurHash.update(hash, interval.start);
1203
+ hash = MurmurHash.update(hash, interval.stop);
1204
+ }
1205
+ this.cachedHashCode = MurmurHash.finish(hash, this.intervals.length * 2);
1206
+ }
1207
+ return this.cachedHashCode;
1208
+ }
1209
+ /**
1210
+ * Are two IntervalSets equal? Because all intervals are sorted and disjoint, equals is a simple linear walk over
1211
+ * both lists to make sure they are the same. Interval.equals() is used by the List.equals() method to check
1212
+ * the ranges.
1213
+ */
1214
+ equals(other) {
1215
+ if (this === other) {
1216
+ return true;
1217
+ }
1218
+ if (this.intervals.length !== other.intervals.length) {
1219
+ return false;
1220
+ }
1221
+ for (let i = 0; i < this.intervals.length; i++) {
1222
+ if (!this.intervals[i].equals(other.intervals[i])) {
1223
+ return false;
1224
+ }
1225
+ }
1226
+ return true;
1227
+ }
1228
+ toString(elementsAreChar) {
1229
+ if (this.intervals.length === 0) {
1230
+ return "{}";
1231
+ }
1232
+ let result = "";
1233
+ if (this.length > 1) {
1234
+ result += "{";
1235
+ }
1236
+ for (let i = 0; i < this.intervals.length; ++i) {
1237
+ const interval = this.intervals[i];
1238
+ const start = interval.start;
1239
+ const stop = interval.stop;
1240
+ if (start === stop) {
1241
+ if (start === Token.EOF) {
1242
+ result += "<EOF>";
1243
+ } else if (elementsAreChar) {
1244
+ result += "'" + String.fromCodePoint(start) + "'";
1245
+ } else {
1246
+ result += start;
1247
+ }
1248
+ } else {
1249
+ if (elementsAreChar) {
1250
+ result += "'" + String.fromCodePoint(start) + "'..'" + String.fromCodePoint(stop) + "'";
1251
+ } else {
1252
+ result += start + ".." + stop;
1253
+ }
1254
+ }
1255
+ if (i < this.intervals.length - 1) {
1256
+ result += ", ";
1257
+ }
1258
+ }
1259
+ if (this.length > 1) {
1260
+ result += "}";
1261
+ }
1262
+ return result;
1263
+ }
1264
+ toStringWithVocabulary(vocabulary) {
1265
+ if (this.intervals.length === 0) {
1266
+ return "{}";
1267
+ }
1268
+ let result = "";
1269
+ if (this.length > 1) {
1270
+ result += "{";
1271
+ }
1272
+ for (let i = 0; i < this.intervals.length; ++i) {
1273
+ const interval = this.intervals[i];
1274
+ const start = interval.start;
1275
+ const stop = interval.stop;
1276
+ if (start === stop) {
1277
+ if (start === Token.EOF) {
1278
+ result += "<EOF>";
1279
+ } else {
1280
+ result += this.elementName(vocabulary, start);
1281
+ }
1282
+ } else {
1283
+ for (let i2 = start; i2 <= stop; ++i2) {
1284
+ if (i2 > start) {
1285
+ result += ", ";
1286
+ }
1287
+ result += this.elementName(vocabulary, i2);
1288
+ }
1289
+ }
1290
+ if (i < this.intervals.length - 1) {
1291
+ result += ", ";
1292
+ }
1293
+ }
1294
+ if (this.length > 1) {
1295
+ result += "}";
1296
+ }
1297
+ return result;
1298
+ }
1299
+ toStringWithRuleNames(ruleNames) {
1300
+ if (this.intervals.length === 0) {
1301
+ return "{}";
1302
+ }
1303
+ let result = "";
1304
+ if (this.length > 1) {
1305
+ result += "{";
1306
+ }
1307
+ const vocabulary = Vocabulary.fromTokenNames(ruleNames);
1308
+ for (let i = 0; i < this.intervals.length; ++i) {
1309
+ const interval = this.intervals[i];
1310
+ const start = interval.start;
1311
+ const stop = interval.stop;
1312
+ if (start === stop) {
1313
+ if (start === Token.EOF) {
1314
+ result += "<EOF>";
1315
+ } else {
1316
+ result += this.elementName(vocabulary, start);
1317
+ }
1318
+ } else {
1319
+ for (let i2 = start; i2 <= stop; ++i2) {
1320
+ if (i2 > start) {
1321
+ result += ", ";
1322
+ }
1323
+ result += this.elementName(vocabulary, i2);
1324
+ }
1325
+ }
1326
+ if (i < this.intervals.length - 1) {
1327
+ result += ", ";
1328
+ }
1329
+ }
1330
+ if (this.length > 1) {
1331
+ result += "}";
1332
+ }
1333
+ return result;
1334
+ }
1335
+ toArray() {
1336
+ const data = [];
1337
+ for (const interval of this.intervals) {
1338
+ for (let j = interval.start; j <= interval.stop; j++) {
1339
+ data.push(j);
1340
+ }
1341
+ }
1342
+ return data;
1343
+ }
1344
+ /** @returns the number of elements in this set. */
1345
+ get length() {
1346
+ let result = 0;
1347
+ for (const interval of this.intervals) {
1348
+ result += interval.length;
1349
+ }
1350
+ return result;
1351
+ }
1352
+ elementName(vocabulary, token) {
1353
+ if (token === Token.EOF) {
1354
+ return "<EOF>";
1355
+ }
1356
+ if (token === Token.EPSILON) {
1357
+ return "<EPSILON>";
1358
+ }
1359
+ return vocabulary.getDisplayName(token);
1360
+ }
1361
+ };
1362
+
1363
+ // src/utils/helpers.ts
1364
+ var valueToString = /* @__PURE__ */ __name((v) => {
1365
+ return v === null ? "null" : v;
1366
+ }, "valueToString");
1367
+ var arrayToString = /* @__PURE__ */ __name((value) => {
1368
+ return Array.isArray(value) ? "[" + value.map(valueToString).join(", ") + "]" : "null";
1369
+ }, "arrayToString");
1370
+ var equalArrays = /* @__PURE__ */ __name((a, b) => {
1371
+ if (a === b) {
1372
+ return true;
1373
+ }
1374
+ if (a.length !== b.length) {
1375
+ return false;
1376
+ }
1377
+ for (let i = 0; i < a.length; i++) {
1378
+ const left = a[i];
1379
+ const right = b[i];
1380
+ if (left === right) {
1381
+ continue;
1382
+ }
1383
+ if (!left || !left.equals(right)) {
1384
+ return false;
1385
+ }
1386
+ }
1387
+ return true;
1388
+ }, "equalArrays");
1389
+ var equalNumberArrays = /* @__PURE__ */ __name((a, b) => {
1390
+ if (a === b) {
1391
+ return true;
1392
+ }
1393
+ if (a.length !== b.length) {
1394
+ return false;
1395
+ }
1396
+ for (let i = 0; i < a.length; i++) {
1397
+ if (a[i] !== b[i]) {
1398
+ return false;
1399
+ }
1400
+ }
1401
+ return true;
1402
+ }, "equalNumberArrays");
1403
+ var escapeWhitespace = /* @__PURE__ */ __name((s, escapeSpaces = false) => {
1404
+ s = s.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
1405
+ if (escapeSpaces) {
1406
+ s = s.replace(/ /g, "\xB7");
1407
+ }
1408
+ return s;
1409
+ }, "escapeWhitespace");
1410
+
1411
+ // src/atn/SemanticContext.ts
1412
+ var SemanticContext = class _SemanticContext {
1413
+ static {
1414
+ __name(this, "SemanticContext");
1415
+ }
1416
+ cachedHashCode;
1417
+ static andContext(a, b) {
1418
+ if (a === null || a === _SemanticContext.NONE) {
1419
+ return b;
1420
+ }
1421
+ if (b === null || b === _SemanticContext.NONE) {
1422
+ return a;
1423
+ }
1424
+ const result = new AND(a, b);
1425
+ if (result.operands.length === 1) {
1426
+ return result.operands[0];
1427
+ }
1428
+ return result;
1429
+ }
1430
+ static orContext(a, b) {
1431
+ if (a === null) {
1432
+ return b;
1433
+ }
1434
+ if (b === null) {
1435
+ return a;
1436
+ }
1437
+ if (a === _SemanticContext.NONE || b === _SemanticContext.NONE) {
1438
+ return _SemanticContext.NONE;
1439
+ }
1440
+ const result = new OR(a, b);
1441
+ if (result.operands.length === 1) {
1442
+ return result.operands[0];
1443
+ } else {
1444
+ return result;
1445
+ }
1446
+ }
1447
+ static filterPrecedencePredicates(set) {
1448
+ const result = [];
1449
+ for (const context of set) {
1450
+ if (context instanceof _SemanticContext.PrecedencePredicate) {
1451
+ result.push(context);
1452
+ }
1453
+ }
1454
+ return result;
1455
+ }
1456
+ /**
1457
+ * Evaluate the precedence predicates for the context and reduce the result.
1458
+ *
1459
+ * @param _parser The parser instance.
1460
+ * @param _parserCallStack The current parser context object.
1461
+ * @returns The simplified semantic context after precedence predicates are
1462
+ * evaluated, which will be one of the following values.
1463
+ * - {@link NONE}: if the predicate simplifies to `true` after
1464
+ * precedence predicates are evaluated.
1465
+ * - `null`: if the predicate simplifies to `false` after
1466
+ * precedence predicates are evaluated.
1467
+ * - `this`: if the semantic context is not changed as a result of
1468
+ * precedence predicate evaluation.
1469
+ * - A non-`null` {@link SemanticContext}: the new simplified
1470
+ * semantic context after precedence predicates are evaluated.
1471
+ */
1472
+ evalPrecedence(_parser, _parserCallStack) {
1473
+ return this;
1474
+ }
1475
+ };
1476
+ var AND = class _AND extends SemanticContext {
1477
+ static {
1478
+ __name(this, "AND");
1479
+ }
1480
+ operands;
1481
+ /**
1482
+ * A semantic context which is true whenever none of the contained contexts
1483
+ * is false
1484
+ */
1485
+ constructor(a, b) {
1486
+ super();
1487
+ const operands = new HashSet();
1488
+ if (a instanceof _AND) {
1489
+ a.operands.forEach((o) => {
1490
+ operands.add(o);
1491
+ });
1492
+ } else {
1493
+ operands.add(a);
1494
+ }
1495
+ if (b instanceof _AND) {
1496
+ b.operands.forEach((o) => {
1497
+ operands.add(o);
1498
+ });
1499
+ } else {
1500
+ operands.add(b);
1501
+ }
1502
+ const precedencePredicates = SemanticContext.filterPrecedencePredicates(operands);
1503
+ if (precedencePredicates.length > 0) {
1504
+ let reduced = null;
1505
+ precedencePredicates.forEach((p) => {
1506
+ if (reduced === null || p.precedence < reduced.precedence) {
1507
+ reduced = p;
1508
+ }
1509
+ });
1510
+ if (reduced) {
1511
+ operands.add(reduced);
1512
+ }
1513
+ }
1514
+ this.operands = operands.toArray();
1515
+ }
1516
+ equals(other) {
1517
+ if (this === other) {
1518
+ return true;
1519
+ }
1520
+ if (!(other instanceof _AND)) {
1521
+ return false;
1522
+ }
1523
+ return equalArrays(this.operands, other.operands);
1524
+ }
1525
+ hashCode() {
1526
+ if (this.cachedHashCode === void 0) {
1527
+ let hash = MurmurHash.initialize();
1528
+ for (const operand of this.operands) {
1529
+ hash = MurmurHash.updateFromComparable(hash, operand);
1530
+ }
1531
+ hash = MurmurHash.update(hash, 3813686060);
1532
+ this.cachedHashCode = MurmurHash.finish(hash, this.operands.length + 1);
1533
+ }
1534
+ return this.cachedHashCode;
1535
+ }
1536
+ /**
1537
+ * {@inheritDoc}
1538
+ *
1539
+ *
1540
+ * The evaluation of predicates by this context is short-circuiting, but
1541
+ * unordered.
1542
+ */
1543
+ evaluate(parser, parserCallStack) {
1544
+ for (const operand of this.operands) {
1545
+ if (!operand.evaluate(parser, parserCallStack)) {
1546
+ return false;
1547
+ }
1548
+ }
1549
+ return true;
1550
+ }
1551
+ evalPrecedence(parser, parserCallStack) {
1552
+ let differs = false;
1553
+ const operands = [];
1554
+ for (const context of this.operands) {
1555
+ const evaluated = context.evalPrecedence(parser, parserCallStack);
1556
+ differs ||= evaluated !== context;
1557
+ if (evaluated === null) {
1558
+ return null;
1559
+ } else if (evaluated !== SemanticContext.NONE) {
1560
+ operands.push(evaluated);
1561
+ }
1562
+ }
1563
+ if (!differs) {
1564
+ return this;
1565
+ }
1566
+ if (operands.length === 0) {
1567
+ return SemanticContext.NONE;
1568
+ }
1569
+ let result = null;
1570
+ operands.forEach((o) => {
1571
+ result = result === null ? o : SemanticContext.andContext(result, o);
1572
+ });
1573
+ return result;
1574
+ }
1575
+ toString() {
1576
+ const s = this.operands.map((o) => {
1577
+ return o.toString();
1578
+ });
1579
+ return (s.length > 3 ? s.slice(3) : s).join("&&");
1580
+ }
1581
+ };
1582
+ var OR = class _OR extends SemanticContext {
1583
+ static {
1584
+ __name(this, "OR");
1585
+ }
1586
+ operands;
1587
+ /**
1588
+ * A semantic context which is true whenever at least one of the contained
1589
+ * contexts is true
1590
+ */
1591
+ constructor(a, b) {
1592
+ super();
1593
+ const operands = new HashSet();
1594
+ if (a instanceof _OR) {
1595
+ a.operands.forEach((o) => {
1596
+ operands.add(o);
1597
+ });
1598
+ } else {
1599
+ operands.add(a);
1600
+ }
1601
+ if (b instanceof _OR) {
1602
+ b.operands.forEach((o) => {
1603
+ operands.add(o);
1604
+ });
1605
+ } else {
1606
+ operands.add(b);
1607
+ }
1608
+ const precedencePredicates = SemanticContext.filterPrecedencePredicates(operands);
1609
+ if (precedencePredicates.length > 0) {
1610
+ const s = precedencePredicates.sort((a2, b2) => {
1611
+ return a2.compareTo(b2);
1612
+ });
1613
+ const reduced = s[s.length - 1];
1614
+ operands.add(reduced);
1615
+ }
1616
+ this.operands = operands.toArray();
1617
+ }
1618
+ equals(other) {
1619
+ if (this === other) {
1620
+ return true;
1621
+ } else if (!(other instanceof _OR)) {
1622
+ return false;
1623
+ } else {
1624
+ return equalArrays(this.operands, other.operands);
1625
+ }
1626
+ }
1627
+ hashCode() {
1628
+ if (this.cachedHashCode === void 0) {
1629
+ let hash = MurmurHash.initialize();
1630
+ for (const operand of this.operands) {
1631
+ hash = MurmurHash.updateFromComparable(hash, operand);
1632
+ }
1633
+ hash = MurmurHash.update(hash, 3383313031);
1634
+ this.cachedHashCode = MurmurHash.finish(hash, this.operands.length + 1);
1635
+ }
1636
+ return this.cachedHashCode;
1637
+ }
1638
+ /**
1639
+ * The evaluation of predicates by this context is short-circuiting, but unordered.
1640
+ */
1641
+ evaluate(parser, parserCallStack) {
1642
+ for (const operand of this.operands) {
1643
+ if (operand.evaluate(parser, parserCallStack)) {
1644
+ return true;
1645
+ }
1646
+ }
1647
+ return false;
1648
+ }
1649
+ evalPrecedence(parser, parserCallStack) {
1650
+ let differs = false;
1651
+ const operands = [];
1652
+ for (const context of this.operands) {
1653
+ const evaluated = context.evalPrecedence(parser, parserCallStack);
1654
+ differs ||= evaluated !== context;
1655
+ if (evaluated === SemanticContext.NONE) {
1656
+ return SemanticContext.NONE;
1657
+ } else if (evaluated !== null) {
1658
+ operands.push(evaluated);
1659
+ }
1660
+ }
1661
+ if (!differs) {
1662
+ return this;
1663
+ }
1664
+ if (operands.length === 0) {
1665
+ return null;
1666
+ }
1667
+ let result = null;
1668
+ operands.forEach((o) => {
1669
+ result = result === null ? o : SemanticContext.orContext(result, o);
1670
+ });
1671
+ return result;
1672
+ }
1673
+ toString() {
1674
+ const s = this.operands.map((o) => {
1675
+ return o.toString();
1676
+ });
1677
+ return (s.length > 3 ? s.slice(3) : s).join("||");
1678
+ }
1679
+ };
1680
+ ((SemanticContext2) => {
1681
+ class Predicate extends SemanticContext2 {
1682
+ static {
1683
+ __name(this, "Predicate");
1684
+ }
1685
+ ruleIndex;
1686
+ predIndex;
1687
+ isCtxDependent;
1688
+ // e.g., $i ref in pred
1689
+ constructor(ruleIndex, predIndex, isCtxDependent) {
1690
+ super();
1691
+ this.ruleIndex = ruleIndex ?? -1;
1692
+ this.predIndex = predIndex ?? -1;
1693
+ this.isCtxDependent = isCtxDependent ?? false;
1694
+ }
1695
+ evaluate(parser, outerContext) {
1696
+ const localctx = this.isCtxDependent ? outerContext : null;
1697
+ return parser.sempred(localctx, this.ruleIndex, this.predIndex);
1698
+ }
1699
+ hashCode() {
1700
+ if (this.cachedHashCode === void 0) {
1701
+ let hashCode = MurmurHash.initialize();
1702
+ hashCode = MurmurHash.update(hashCode, this.ruleIndex);
1703
+ hashCode = MurmurHash.update(hashCode, this.predIndex);
1704
+ hashCode = MurmurHash.update(hashCode, this.isCtxDependent ? 1 : 0);
1705
+ hashCode = MurmurHash.finish(hashCode, 3);
1706
+ this.cachedHashCode = hashCode;
1707
+ }
1708
+ return this.cachedHashCode;
1709
+ }
1710
+ equals(other) {
1711
+ if (this === other) {
1712
+ return true;
1713
+ }
1714
+ return this.ruleIndex === other.ruleIndex && this.predIndex === other.predIndex && this.isCtxDependent === other.isCtxDependent;
1715
+ }
1716
+ toString() {
1717
+ return "{" + this.ruleIndex + ":" + this.predIndex + "}?";
1718
+ }
1719
+ }
1720
+ SemanticContext2.Predicate = Predicate;
1721
+ class PrecedencePredicate extends SemanticContext2 {
1722
+ static {
1723
+ __name(this, "PrecedencePredicate");
1724
+ }
1725
+ precedence;
1726
+ constructor(precedence) {
1727
+ super();
1728
+ this.precedence = precedence ?? 0;
1729
+ }
1730
+ evaluate(parser, outerContext) {
1731
+ return parser.precpred(outerContext, this.precedence);
1732
+ }
1733
+ evalPrecedence(parser, outerContext) {
1734
+ if (parser.precpred(outerContext ?? null, this.precedence)) {
1735
+ return SemanticContext2.NONE;
1736
+ }
1737
+ return null;
1738
+ }
1739
+ compareTo(other) {
1740
+ return this.precedence - other.precedence;
1741
+ }
1742
+ hashCode() {
1743
+ return 31 + this.precedence;
1744
+ }
1745
+ equals(other) {
1746
+ if (this === other) {
1747
+ return true;
1748
+ }
1749
+ return this.precedence === other.precedence;
1750
+ }
1751
+ toString() {
1752
+ return "{" + this.precedence + ">=prec}?";
1753
+ }
1754
+ }
1755
+ SemanticContext2.PrecedencePredicate = PrecedencePredicate;
1756
+ SemanticContext2.NONE = new Predicate();
1757
+ })(SemanticContext || (SemanticContext = {}));
1758
+
1759
+ // src/atn/ATNConfig.ts
1760
+ var ATNConfig = class _ATNConfig {
1761
+ static {
1762
+ __name(this, "ATNConfig");
1763
+ }
1764
+ /** The ATN state associated with this configuration */
1765
+ state;
1766
+ /** What alt (or lexer rule) is predicted by this configuration */
1767
+ alt;
1768
+ /**
1769
+ * We cannot execute predicates dependent upon local context unless
1770
+ * we know for sure we are in the correct context. Because there is
1771
+ * no way to do this efficiently, we simply cannot evaluate
1772
+ * dependent predicates unless we are in the rule that initially
1773
+ * invokes the ATN simulator.
1774
+ *
1775
+ * closure() tracks the depth of how far we dip into the outer context:
1776
+ * depth > 0.
1777
+ */
1778
+ reachesIntoOuterContext = false;
1779
+ // Not used in hash code.
1780
+ precedenceFilterSuppressed = false;
1781
+ // Not used in hash code.
1782
+ get semanticContext() {
1783
+ return this.#semanticContext;
1784
+ }
1785
+ cachedHashCode;
1786
+ // Shared with LexerATNConfig.
1787
+ /**
1788
+ * The syntactic context is a graph-structured stack node whose
1789
+ * path(s) to the root is the rule invocation(s)
1790
+ * chain used to arrive at the state. The semantic context is
1791
+ * the tree of semantic predicates encountered before reaching
1792
+ * an ATN state
1793
+ */
1794
+ #context = null;
1795
+ #semanticContext;
1796
+ /** Never create config classes directly. Use the factory methods below. */
1797
+ constructor(c, state, context, semanticContext) {
1798
+ this.state = state;
1799
+ this.alt = c.alt;
1800
+ this.context = context;
1801
+ this.#semanticContext = semanticContext ?? SemanticContext.NONE;
1802
+ this.reachesIntoOuterContext = c.reachesIntoOuterContext;
1803
+ if (c.precedenceFilterSuppressed !== void 0) {
1804
+ this.precedenceFilterSuppressed = c.precedenceFilterSuppressed;
1805
+ }
1806
+ }
1807
+ static duplicate(old, semanticContext) {
1808
+ return new _ATNConfig(old, old.state, old.context, semanticContext ?? old.semanticContext);
1809
+ }
1810
+ static createWithContext(state, alt, context, semanticContext) {
1811
+ return new _ATNConfig({ alt }, state, context, semanticContext);
1812
+ }
1813
+ static createWithConfig(state, config, context) {
1814
+ return new _ATNConfig(config, state, context ?? config.context, config.semanticContext);
1815
+ }
1816
+ static createWithSemanticContext(state, c, semanticContext) {
1817
+ return new _ATNConfig(c, state ?? c.state, c.context, semanticContext);
1818
+ }
1819
+ hashCode() {
1820
+ if (this.cachedHashCode === void 0) {
1821
+ let hashCode = MurmurHash.initialize(7);
1822
+ hashCode = MurmurHash.update(hashCode, this.state.stateNumber);
1823
+ hashCode = MurmurHash.update(hashCode, this.alt);
1824
+ hashCode = MurmurHash.updateFromComparable(hashCode, this.#context);
1825
+ hashCode = MurmurHash.updateFromComparable(hashCode, this.semanticContext);
1826
+ hashCode = MurmurHash.finish(hashCode, 4);
1827
+ this.cachedHashCode = hashCode;
1828
+ }
1829
+ return this.cachedHashCode;
1830
+ }
1831
+ /**
1832
+ * The stack of invoking states leading to the rule/states associated
1833
+ * with this config. We track only those contexts pushed during
1834
+ * execution of the ATN simulator.
1835
+ */
1836
+ get context() {
1837
+ return this.#context;
1838
+ }
1839
+ set context(context) {
1840
+ this.#context = context;
1841
+ this.cachedHashCode = void 0;
1842
+ }
1843
+ /**
1844
+ * An ATN configuration is equal to another if both have
1845
+ * the same state, they predict the same alternative, and
1846
+ * syntactic/semantic contexts are the same.
1847
+ */
1848
+ equals(other) {
1849
+ if (this === other) {
1850
+ return true;
1851
+ }
1852
+ return this.state.stateNumber === other.state.stateNumber && this.alt === other.alt && (this.context === null ? other.context === null : this.context.equals(other.context)) && this.semanticContext.equals(other.semanticContext) && this.precedenceFilterSuppressed === other.precedenceFilterSuppressed;
1853
+ }
1854
+ toString(_recog, showAlt = true) {
1855
+ let alt = "";
1856
+ if (showAlt) {
1857
+ alt = "," + this.alt;
1858
+ }
1859
+ return "(" + this.state + alt + (this.context !== null ? ",[" + this.context.toString() + "]" : "") + (this.semanticContext !== SemanticContext.NONE ? "," + this.semanticContext.toString() : "") + (this.reachesIntoOuterContext ? ",up=" + this.reachesIntoOuterContext : "") + ")";
1860
+ }
1861
+ };
1862
+
1863
+ // src/atn/ATNState.ts
1864
+ var ATNState = class _ATNState {
1865
+ static {
1866
+ __name(this, "ATNState");
1867
+ }
1868
+ static INVALID_STATE_NUMBER = -1;
1869
+ static INVALID_TYPE = 0;
1870
+ static BASIC = 1;
1871
+ static RULE_START = 2;
1872
+ static BLOCK_START = 3;
1873
+ static PLUS_BLOCK_START = 4;
1874
+ static STAR_BLOCK_START = 5;
1875
+ static TOKEN_START = 6;
1876
+ static RULE_STOP = 7;
1877
+ static BLOCK_END = 8;
1878
+ static STAR_LOOP_BACK = 9;
1879
+ static STAR_LOOP_ENTRY = 10;
1880
+ static PLUS_LOOP_BACK = 11;
1881
+ static LOOP_END = 12;
1882
+ static stateType = _ATNState.INVALID_STATE_NUMBER;
1883
+ stateNumber = 0;
1884
+ ruleIndex = 0;
1885
+ // at runtime, we don't have Rule objects
1886
+ epsilonOnlyTransitions = false;
1887
+ /** Used to cache lookahead during parsing, not used during construction */
1888
+ nextTokenWithinRule;
1889
+ /** Track the transitions emanating from this ATN state. */
1890
+ transitions = [];
1891
+ hashCode() {
1892
+ return this.stateNumber;
1893
+ }
1894
+ equals(other) {
1895
+ return this.stateNumber === other.stateNumber;
1896
+ }
1897
+ toString() {
1898
+ return `${this.stateNumber}`;
1899
+ }
1900
+ addTransitionAtIndex(index, transition) {
1901
+ if (this.transitions.length === 0) {
1902
+ this.epsilonOnlyTransitions = transition.isEpsilon;
1903
+ } else if (this.epsilonOnlyTransitions !== transition.isEpsilon) {
1904
+ this.epsilonOnlyTransitions = false;
1905
+ }
1906
+ this.transitions.splice(index, 1, transition);
1907
+ }
1908
+ addTransition(transition) {
1909
+ if (this.transitions.length === 0) {
1910
+ this.epsilonOnlyTransitions = transition.isEpsilon;
1911
+ } else if (this.epsilonOnlyTransitions !== transition.isEpsilon) {
1912
+ this.epsilonOnlyTransitions = false;
1913
+ }
1914
+ this.transitions.push(transition);
1915
+ }
1916
+ setTransition(i, e) {
1917
+ this.transitions.splice(i, 1, e);
1918
+ }
1919
+ removeTransition(index) {
1920
+ const t = this.transitions.splice(index, 1);
1921
+ return t[0];
1922
+ }
1923
+ };
1924
+
1925
+ // src/atn/PredictionContext.ts
1926
+ var PredictionContext = class _PredictionContext {
1927
+ static {
1928
+ __name(this, "PredictionContext");
1929
+ }
1930
+ /**
1931
+ * Represents `$` in an array in full context mode, when `$`
1932
+ * doesn't mean wildcard: `$ + x = [$,x]`. Here,
1933
+ * `$` = {@link EMPTY_RETURN_STATE}.
1934
+ */
1935
+ static EMPTY_RETURN_STATE = 2147483647;
1936
+ static traceATNSimulator = false;
1937
+ cachedHashCode;
1938
+ constructor(cachedHashCode) {
1939
+ this.cachedHashCode = cachedHashCode;
1940
+ }
1941
+ static calculateEmptyHashCode() {
1942
+ let hash = MurmurHash.initialize(31);
1943
+ hash = MurmurHash.finish(hash, 0);
1944
+ return hash;
1945
+ }
1946
+ static calculateHashCodeSingle(parent, returnState) {
1947
+ let hash = MurmurHash.initialize(31);
1948
+ hash = MurmurHash.updateFromComparable(hash, parent);
1949
+ hash = MurmurHash.update(hash, returnState);
1950
+ hash = MurmurHash.finish(hash, 2);
1951
+ return hash;
1952
+ }
1953
+ static calculateHashCodeList(parents, returnStates) {
1954
+ let hash = MurmurHash.initialize(31);
1955
+ for (const parent of parents) {
1956
+ hash = MurmurHash.updateFromComparable(hash, parent);
1957
+ }
1958
+ for (const returnState of returnStates) {
1959
+ hash = MurmurHash.update(hash, returnState);
1960
+ }
1961
+ hash = MurmurHash.finish(hash, 2 * parents.length);
1962
+ return hash;
1963
+ }
1964
+ isEmpty() {
1965
+ return false;
1966
+ }
1967
+ hasEmptyPath() {
1968
+ return this.getReturnState(this.length - 1) === _PredictionContext.EMPTY_RETURN_STATE;
1969
+ }
1970
+ hashCode() {
1971
+ return this.cachedHashCode;
1972
+ }
1973
+ toString(_recog) {
1974
+ return "";
1975
+ }
1976
+ };
1977
+
1978
+ // src/atn/SingletonPredictionContext.ts
1979
+ var SingletonPredictionContext = class _SingletonPredictionContext extends PredictionContext {
1980
+ static {
1981
+ __name(this, "SingletonPredictionContext");
1982
+ }
1983
+ parent;
1984
+ returnState;
1985
+ constructor(parent, returnState) {
1986
+ super(
1987
+ parent ? PredictionContext.calculateHashCodeSingle(parent, returnState) : PredictionContext.calculateEmptyHashCode()
1988
+ );
1989
+ this.parent = parent ?? null;
1990
+ this.returnState = returnState;
1991
+ }
1992
+ getParent(_index) {
1993
+ return this.parent;
1994
+ }
1995
+ getReturnState(_index) {
1996
+ return this.returnState;
1997
+ }
1998
+ equals(other) {
1999
+ if (this === other) {
2000
+ return true;
2001
+ }
2002
+ if (!(other instanceof _SingletonPredictionContext)) {
2003
+ return false;
2004
+ }
2005
+ if (this.hashCode() !== other.hashCode()) {
2006
+ return false;
2007
+ }
2008
+ if (this.returnState !== other.returnState) {
2009
+ return false;
2010
+ }
2011
+ if (this.parent == null) {
2012
+ return other.parent == null;
2013
+ }
2014
+ return this.parent.equals(other.parent);
2015
+ }
2016
+ toString() {
2017
+ const up = this.parent === null ? "" : this.parent.toString();
2018
+ if (up.length === 0) {
2019
+ if (this.returnState === PredictionContext.EMPTY_RETURN_STATE) {
2020
+ return "$";
2021
+ }
2022
+ return "" + this.returnState;
2023
+ } else {
2024
+ return "" + this.returnState + " " + up;
2025
+ }
2026
+ }
2027
+ get length() {
2028
+ return 1;
2029
+ }
2030
+ };
2031
+
2032
+ // src/atn/EmptyPredictionContext.ts
2033
+ var EmptyPredictionContext = class _EmptyPredictionContext extends SingletonPredictionContext {
2034
+ static {
2035
+ __name(this, "EmptyPredictionContext");
2036
+ }
2037
+ /**
2038
+ * Represents `$` in local context prediction, which means wildcard.
2039
+ * `*+x = *`.
2040
+ */
2041
+ static instance = new _EmptyPredictionContext();
2042
+ constructor() {
2043
+ super(void 0, PredictionContext.EMPTY_RETURN_STATE);
2044
+ }
2045
+ isEmpty() {
2046
+ return true;
2047
+ }
2048
+ getParent() {
2049
+ return null;
2050
+ }
2051
+ getReturnState() {
2052
+ return this.returnState;
2053
+ }
2054
+ equals(other) {
2055
+ return this === other;
2056
+ }
2057
+ toString() {
2058
+ return "$";
2059
+ }
2060
+ };
2061
+
2062
+ // src/atn/Transition.ts
2063
+ var Transition = class {
2064
+ static {
2065
+ __name(this, "Transition");
2066
+ }
2067
+ static INVALID = 0;
2068
+ static EPSILON = 1;
2069
+ static RANGE = 2;
2070
+ static RULE = 3;
2071
+ static PREDICATE = 4;
2072
+ // e.g., {isType(input.LT(1))}
2073
+ static ATOM = 5;
2074
+ static ACTION = 6;
2075
+ static SET = 7;
2076
+ // ~(A|B) or ~atom, wildcard, which convert to next
2077
+ static NOT_SET = 8;
2078
+ static WILDCARD = 9;
2079
+ static PRECEDENCE = 10;
2080
+ /** The target of this transition. */
2081
+ target;
2082
+ constructor(target) {
2083
+ this.target = target;
2084
+ }
2085
+ /**
2086
+ * Determines if the transition is an "epsilon" transition.
2087
+ *
2088
+ * The default implementation returns `false`.
2089
+ *
2090
+ * @returns `true` if traversing this transition in the ATN does not
2091
+ * consume an input symbol; otherwise, `false` if traversing this
2092
+ * transition consumes (matches) an input symbol.
2093
+ */
2094
+ get isEpsilon() {
2095
+ return false;
2096
+ }
2097
+ get label() {
2098
+ return null;
2099
+ }
2100
+ toString() {
2101
+ return "";
2102
+ }
2103
+ };
2104
+
2105
+ // src/atn/SetTransition.ts
2106
+ var SetTransition = class extends Transition {
2107
+ static {
2108
+ __name(this, "SetTransition");
2109
+ }
2110
+ set;
2111
+ constructor(target, set) {
2112
+ super(target);
2113
+ if (set) {
2114
+ this.set = set;
2115
+ } else {
2116
+ this.set = IntervalSet.of(Token.INVALID_TYPE, Token.INVALID_TYPE);
2117
+ }
2118
+ }
2119
+ get transitionType() {
2120
+ return Transition.SET;
2121
+ }
2122
+ get label() {
2123
+ return this.set;
2124
+ }
2125
+ matches(symbol, _minVocabSymbol, _maxVocabSymbol) {
2126
+ return this.set.contains(symbol);
2127
+ }
2128
+ toString() {
2129
+ return this.set.toString();
2130
+ }
2131
+ };
2132
+
2133
+ // src/atn/NotSetTransition.ts
2134
+ var NotSetTransition = class extends SetTransition {
2135
+ static {
2136
+ __name(this, "NotSetTransition");
2137
+ }
2138
+ get transitionType() {
2139
+ return Transition.NOT_SET;
2140
+ }
2141
+ matches(symbol, minVocabSymbol, maxVocabSymbol) {
2142
+ return symbol >= minVocabSymbol && symbol <= maxVocabSymbol && !super.matches(symbol, minVocabSymbol, maxVocabSymbol);
2143
+ }
2144
+ toString() {
2145
+ return "~" + super.toString();
2146
+ }
2147
+ };
2148
+
2149
+ // src/misc/MapKeyEqualityOperator.ts
2150
+ var MapKeyEqualityComparator = class {
2151
+ static {
2152
+ __name(this, "MapKeyEqualityComparator");
2153
+ }
2154
+ keyComparator;
2155
+ constructor(keyComparator) {
2156
+ this.keyComparator = keyComparator;
2157
+ }
2158
+ hashCode(obj) {
2159
+ return this.keyComparator.hashCode(obj.key);
2160
+ }
2161
+ equals(a, b) {
2162
+ return this.keyComparator.equals(a.key, b.key);
2163
+ }
2164
+ };
2165
+
2166
+ // src/misc/HashMap.ts
2167
+ var HashMap = class _HashMap {
2168
+ static {
2169
+ __name(this, "HashMap");
2170
+ }
2171
+ backingStore;
2172
+ constructor(keyComparer) {
2173
+ if (keyComparer instanceof _HashMap) {
2174
+ this.backingStore = new HashSet(keyComparer.backingStore);
2175
+ } else {
2176
+ keyComparer = keyComparer ?? DefaultEqualityComparator.instance;
2177
+ this.backingStore = new HashSet(new MapKeyEqualityComparator(keyComparer));
2178
+ }
2179
+ }
2180
+ clear() {
2181
+ this.backingStore.clear();
2182
+ }
2183
+ containsKey(key) {
2184
+ return this.backingStore.contains({ key });
2185
+ }
2186
+ get(key) {
2187
+ const bucket = this.backingStore.get({ key });
2188
+ if (!bucket) {
2189
+ return void 0;
2190
+ }
2191
+ return bucket.value;
2192
+ }
2193
+ get isEmpty() {
2194
+ return this.backingStore.isEmpty;
2195
+ }
2196
+ /**
2197
+ * Sets the value for a key in the map. If the key is not present in the map, it is added.
2198
+ * If the key is present, the value is updated and the old value is returned.
2199
+ *
2200
+ * @param key The key to set.
2201
+ * @param value The value to set.
2202
+ *
2203
+ * @returns The old value for the key, if present.
2204
+ */
2205
+ set(key, value) {
2206
+ const element = this.backingStore.get({ key, value });
2207
+ let result;
2208
+ if (!element) {
2209
+ this.backingStore.add({ key, value });
2210
+ } else {
2211
+ result = element.value;
2212
+ element.value = value;
2213
+ }
2214
+ return result;
2215
+ }
2216
+ /**
2217
+ * Sets the value for a key in the map if the key is not already present. Otherwise the value is not changed and
2218
+ * the old value is returned.
2219
+ *
2220
+ * @param key The key to set.
2221
+ * @param value The value to set.
2222
+ *
2223
+ * @returns The current value for the key, if present.
2224
+ */
2225
+ setIfAbsent(key, value) {
2226
+ const element = this.backingStore.get({ key, value });
2227
+ let result;
2228
+ if (!element) {
2229
+ this.backingStore.add({ key, value });
2230
+ } else {
2231
+ result = element.value;
2232
+ }
2233
+ return result;
2234
+ }
2235
+ keys() {
2236
+ return this.backingStore.toArray().map((bucket) => {
2237
+ return bucket.key;
2238
+ });
2239
+ }
2240
+ values() {
2241
+ return this.backingStore.toArray().map((bucket) => {
2242
+ return bucket.value;
2243
+ });
2244
+ }
2245
+ get size() {
2246
+ return this.backingStore.size;
2247
+ }
2248
+ hashCode() {
2249
+ return this.backingStore.hashCode();
2250
+ }
2251
+ equals(o) {
2252
+ return this.backingStore.equals(o.backingStore);
2253
+ }
2254
+ };
2255
+
2256
+ // src/tree/TerminalNode.ts
2257
+ var TerminalNode = class {
2258
+ static {
2259
+ __name(this, "TerminalNode");
2260
+ }
2261
+ parent = null;
2262
+ symbol;
2263
+ constructor(symbol) {
2264
+ this.symbol = symbol;
2265
+ }
2266
+ getChild(_i) {
2267
+ return null;
2268
+ }
2269
+ getSymbol() {
2270
+ return this.symbol;
2271
+ }
2272
+ getPayload() {
2273
+ return this.symbol;
2274
+ }
2275
+ getSourceInterval() {
2276
+ if (this.symbol === null) {
2277
+ return Interval.INVALID_INTERVAL;
2278
+ }
2279
+ const tokenIndex = this.symbol.tokenIndex;
2280
+ return new Interval(tokenIndex, tokenIndex);
2281
+ }
2282
+ getChildCount() {
2283
+ return 0;
2284
+ }
2285
+ accept(visitor) {
2286
+ return visitor.visitTerminal(this);
2287
+ }
2288
+ getText() {
2289
+ return this.symbol?.text ?? "";
2290
+ }
2291
+ toString() {
2292
+ if (this.symbol?.type === Token.EOF) {
2293
+ return "<EOF>";
2294
+ } else {
2295
+ return this.symbol?.text ?? "";
2296
+ }
2297
+ }
2298
+ toStringTree() {
2299
+ return this.toString();
2300
+ }
2301
+ };
2302
+
2303
+ // src/tree/ErrorNode.ts
2304
+ var ErrorNode = class extends TerminalNode {
2305
+ static {
2306
+ __name(this, "ErrorNode");
2307
+ }
2308
+ accept(visitor) {
2309
+ return visitor.visitErrorNode(this);
2310
+ }
2311
+ };
2312
+
2313
+ // src/CommonToken.ts
2314
+ var CommonToken = class _CommonToken {
2315
+ static {
2316
+ __name(this, "CommonToken");
2317
+ }
2318
+ /**
2319
+ * An empty tuple which is used as the default value of
2320
+ * {@link source} for tokens that do not have a source.
2321
+ */
2322
+ // eslint-disable-next-line @typescript-eslint/naming-convention
2323
+ static EMPTY_SOURCE = [null, null];
2324
+ /**
2325
+ * These properties share a field to reduce the memory footprint of
2326
+ * {@link CommonToken}. Tokens created by a {@link CommonTokenFactory} from
2327
+ * the same source and input stream share a reference to the same
2328
+ * {@link Pair} containing these values.
2329
+ */
2330
+ source;
2331
+ tokenIndex;
2332
+ start;
2333
+ stop;
2334
+ /**
2335
+ * This is the backing field for {@link #getType} and {@link #setType}.
2336
+ */
2337
+ type;
2338
+ /**
2339
+ * The (one-based) line number on which the 1st character of this token was.
2340
+ */
2341
+ line;
2342
+ /**
2343
+ * The zero-based index of the first character position in its line.
2344
+ */
2345
+ column;
2346
+ /**
2347
+ * The token's channel.
2348
+ */
2349
+ channel;
2350
+ /**
2351
+ * This is the backing field for {@link getText} when the token text is
2352
+ * explicitly set in the constructor or via {@link setText}.
2353
+ */
2354
+ #text;
2355
+ constructor(details) {
2356
+ this.type = details.type;
2357
+ this.source = details.source;
2358
+ this.tokenIndex = details.tokenIndex ?? -1;
2359
+ this.line = details.line ?? 0;
2360
+ this.column = details.column ?? -1;
2361
+ this.channel = details.channel ?? Token.DEFAULT_CHANNEL;
2362
+ this.start = details.start ?? 0;
2363
+ this.stop = details.stop ?? 0;
2364
+ this.#text = details.text;
2365
+ if (details.line === void 0 && details.source[0] !== null) {
2366
+ this.line = details.source[0].line;
2367
+ }
2368
+ if (details.column === void 0 && details.source[0] !== null) {
2369
+ this.column = details.source[0].column;
2370
+ }
2371
+ }
2372
+ /**
2373
+ * Constructs a new {@link CommonToken} as a copy of another {@link Token}.
2374
+ *
2375
+ * If `token` is also a {@link CommonToken} instance, the newly
2376
+ * constructed token will share a reference to the {@link #text} field and
2377
+ * the {@link Pair} stored in {@link source}. Otherwise, {@link text} will
2378
+ * be assigned the result of calling {@link getText}, and {@link source}
2379
+ * will be constructed from the result of {@link Token.getTokenSource} and
2380
+ * {@link Token#getInputStream}.
2381
+ *
2382
+ * @param token The token to copy.
2383
+ */
2384
+ static fromToken(token) {
2385
+ const source = [token.tokenSource, token.inputStream];
2386
+ return new _CommonToken({
2387
+ type: token.type,
2388
+ line: token.line,
2389
+ tokenIndex: token.tokenIndex,
2390
+ column: token.column,
2391
+ channel: token.channel,
2392
+ start: token.start,
2393
+ stop: token.stop,
2394
+ text: token.text,
2395
+ source
2396
+ });
2397
+ }
2398
+ /**
2399
+ * Constructs a new {@link CommonToken} with the specified token type and text.
2400
+ *
2401
+ * @param type The token type.
2402
+ * @param text The text of the token.
2403
+ */
2404
+ static fromType(type, text) {
2405
+ return new _CommonToken({ type, text, source: _CommonToken.EMPTY_SOURCE });
2406
+ }
2407
+ static fromSource(source, type, channel, start, stop) {
2408
+ return new _CommonToken({ type, channel, start, stop, source });
2409
+ }
2410
+ get tokenSource() {
2411
+ return this.source[0];
2412
+ }
2413
+ get inputStream() {
2414
+ return this.source[1];
2415
+ }
2416
+ set inputStream(input) {
2417
+ this.source[1] = input;
2418
+ }
2419
+ /**
2420
+ * Constructs a new {@link CommonToken} as a copy of another {@link Token}.
2421
+ *
2422
+ * If `oldToken` is also a {@link CommonToken} instance, the newly
2423
+ * constructed token will share a reference to the {@link text} field and
2424
+ * the {@link Pair} stored in {@link source}. Otherwise, {@link text} will
2425
+ * be assigned the result of calling {@link getText}, and {@link source}
2426
+ * will be constructed from the result of {@link Token.getTokenSource} and
2427
+ * {@link Token.getInputStream}.
2428
+ */
2429
+ clone() {
2430
+ const t = new _CommonToken({
2431
+ source: this.source,
2432
+ type: this.type,
2433
+ channel: this.channel,
2434
+ start: this.start,
2435
+ stop: this.stop,
2436
+ tokenIndex: this.tokenIndex,
2437
+ line: this.line,
2438
+ column: this.column,
2439
+ text: this.#text
2440
+ });
2441
+ return t;
2442
+ }
2443
+ toString(recognizer) {
2444
+ let channelStr = "";
2445
+ if (this.channel > 0) {
2446
+ channelStr = ",channel=" + this.channel;
2447
+ }
2448
+ let text = this.text;
2449
+ if (text) {
2450
+ text = text.replace(/\n/g, "\\n");
2451
+ text = text.replace(/\r/g, "\\r");
2452
+ text = text.replace(/\t/g, "\\t");
2453
+ } else {
2454
+ text = "<no text>";
2455
+ }
2456
+ let typeString = String(this.type);
2457
+ if (recognizer) {
2458
+ typeString = recognizer.vocabulary.getDisplayName(this.type) ?? "<unknown>";
2459
+ }
2460
+ return "[@" + this.tokenIndex + "," + this.start + ":" + this.stop + "='" + text + "',<" + typeString + ">" + channelStr + "," + this.line + ":" + this.column + "]";
2461
+ }
2462
+ get text() {
2463
+ if (this.#text !== void 0) {
2464
+ return this.#text;
2465
+ }
2466
+ const input = this.inputStream;
2467
+ if (!input) {
2468
+ return void 0;
2469
+ }
2470
+ const n2 = input.size;
2471
+ if (this.start < n2 && this.stop < n2) {
2472
+ return input.getTextFromRange(this.start, this.stop);
2473
+ }
2474
+ return "<EOF>";
2475
+ }
2476
+ set text(text) {
2477
+ this.#text = text;
2478
+ }
2479
+ // WritableToken implementation
2480
+ setText(text) {
2481
+ this.#text = text;
2482
+ }
2483
+ setType(ttype) {
2484
+ this.type = ttype;
2485
+ }
2486
+ setLine(line) {
2487
+ this.line = line;
2488
+ }
2489
+ setCharPositionInLine(pos) {
2490
+ this.column = pos;
2491
+ }
2492
+ setChannel(channel) {
2493
+ this.channel = channel;
2494
+ }
2495
+ setTokenIndex(index) {
2496
+ this.tokenIndex = index;
2497
+ }
2498
+ };
2499
+
2500
+ // src/tree/Trees.ts
2501
+ var Trees = class _Trees {
2502
+ static {
2503
+ __name(this, "Trees");
2504
+ }
2505
+ /**
2506
+ * Print out a whole tree in LISP form. {@link getNodeText} is used on the
2507
+ * node payloads to get the text for the nodes. Detect
2508
+ * parse trees and extract data appropriately.
2509
+ */
2510
+ static toStringTree(tree, ruleNames, recog) {
2511
+ ruleNames = ruleNames ?? null;
2512
+ if (recog) {
2513
+ ruleNames = recog.ruleNames;
2514
+ }
2515
+ let s = _Trees.getNodeText(tree, ruleNames);
2516
+ s = escapeWhitespace(s, false);
2517
+ const c = tree.getChildCount();
2518
+ if (c === 0) {
2519
+ return s;
2520
+ }
2521
+ let res = "(" + s + " ";
2522
+ if (c > 0) {
2523
+ s = _Trees.toStringTree(tree.getChild(0), ruleNames);
2524
+ res = res.concat(s);
2525
+ }
2526
+ for (let i = 1; i < c; i++) {
2527
+ s = _Trees.toStringTree(tree.getChild(i), ruleNames);
2528
+ res = res.concat(" " + s);
2529
+ }
2530
+ res = res.concat(")");
2531
+ return res;
2532
+ }
2533
+ static getNodeText(t, ruleNames, recog) {
2534
+ ruleNames = ruleNames ?? null;
2535
+ if (recog) {
2536
+ ruleNames = recog.ruleNames;
2537
+ }
2538
+ if (ruleNames !== null) {
2539
+ if (t instanceof ParserRuleContext) {
2540
+ const context = t.ruleContext;
2541
+ const altNumber = context.getAltNumber();
2542
+ if (altNumber !== 0) {
2543
+ return ruleNames[t.ruleIndex] + ":" + altNumber;
2544
+ }
2545
+ return ruleNames[t.ruleIndex];
2546
+ } else if (t instanceof ErrorNode) {
2547
+ return t.toString();
2548
+ } else if (t instanceof TerminalNode) {
2549
+ return t.symbol.text;
2550
+ }
2551
+ }
2552
+ const payload = t.getPayload();
2553
+ if (isToken(payload)) {
2554
+ return payload.text;
2555
+ }
2556
+ return String(t.getPayload());
2557
+ }
2558
+ /**
2559
+ * Return ordered list of all children of this node
2560
+ */
2561
+ static getChildren(t) {
2562
+ const list = [];
2563
+ for (let i = 0; i < t.getChildCount(); i++) {
2564
+ list.push(t.getChild(i));
2565
+ }
2566
+ return list;
2567
+ }
2568
+ /**
2569
+ * Return a list of all ancestors of this node. The first node of
2570
+ * list is the root and the last is the parent of this node.
2571
+ */
2572
+ static getAncestors(t) {
2573
+ if (t.parent === null) {
2574
+ return [];
2575
+ }
2576
+ let ancestors = [];
2577
+ let p = t.parent;
2578
+ while (p !== null) {
2579
+ ancestors = [p].concat(ancestors);
2580
+ p = p.parent;
2581
+ }
2582
+ return ancestors;
2583
+ }
2584
+ /**
2585
+ * Return true if t is u's parent or a node on path to root from u.
2586
+ */
2587
+ static isAncestorOf(t, u) {
2588
+ if (t === null || u === null || t.parent === null) {
2589
+ return false;
2590
+ }
2591
+ let p = u.parent;
2592
+ while (p !== null) {
2593
+ if (t === p) {
2594
+ return true;
2595
+ }
2596
+ p = p.parent;
2597
+ }
2598
+ return false;
2599
+ }
2600
+ static findAllTokenNodes(t, ttype) {
2601
+ return _Trees.findAllNodes(t, ttype, true);
2602
+ }
2603
+ static findAllRuleNodes(t, ruleIndex) {
2604
+ return _Trees.findAllNodes(t, ruleIndex, false);
2605
+ }
2606
+ static findAllNodes(t, index, findTokens) {
2607
+ const nodes = [];
2608
+ _Trees.doFindAllNodes(t, index, findTokens, nodes);
2609
+ return nodes;
2610
+ }
2611
+ static descendants(t) {
2612
+ let nodes = [t];
2613
+ for (let i = 0; i < t.getChildCount(); i++) {
2614
+ nodes = nodes.concat(_Trees.descendants(t.getChild(i)));
2615
+ }
2616
+ return nodes;
2617
+ }
2618
+ /**
2619
+ * Find smallest subtree of t enclosing range startTokenIndex..stopTokenIndex
2620
+ * inclusively using post order traversal. Recursive depth-first-search.
2621
+ */
2622
+ static getRootOfSubtreeEnclosingRegion(t, startTokenIndex, stopTokenIndex) {
2623
+ const n2 = t.getChildCount();
2624
+ for (let i = 0; i < n2; i++) {
2625
+ const child = t.getChild(i);
2626
+ const r = this.getRootOfSubtreeEnclosingRegion(child, startTokenIndex, stopTokenIndex);
2627
+ if (r !== null) {
2628
+ return r;
2629
+ }
2630
+ }
2631
+ if (t instanceof ParserRuleContext) {
2632
+ if (startTokenIndex >= t.start.tokenIndex && // is range fully contained in t?
2633
+ (t.stop === null || stopTokenIndex <= t.stop.tokenIndex)) {
2634
+ return t;
2635
+ }
2636
+ }
2637
+ return null;
2638
+ }
2639
+ /**
2640
+ * Replace any subtree siblings of root that are completely to left
2641
+ * or right of lookahead range with a CommonToken(Token.INVALID_TYPE,"...")
2642
+ * node. The source interval for t is not altered to suit smaller range!
2643
+ *
2644
+ * WARNING: destructive to t.
2645
+ */
2646
+ static stripChildrenOutOfRange(t, root, startIndex, stopIndex) {
2647
+ if (t === null) {
2648
+ return;
2649
+ }
2650
+ for (let i = 0; i < t.getChildCount(); i++) {
2651
+ const child = t.getChild(i);
2652
+ const range = child.getSourceInterval();
2653
+ if (t instanceof ParserRuleContext && (range.stop < startIndex || range.start > stopIndex)) {
2654
+ if (this.isAncestorOf(child, root)) {
2655
+ const abbrev = CommonToken.fromType(Token.INVALID_TYPE, "...");
2656
+ t.children[i] = new TerminalNode(abbrev);
2657
+ }
2658
+ }
2659
+ }
2660
+ }
2661
+ static doFindAllNodes(t, index, findTokens, nodes) {
2662
+ if (findTokens && t instanceof TerminalNode) {
2663
+ if (t.symbol?.type === index) {
2664
+ nodes.push(t);
2665
+ }
2666
+ } else if (!findTokens && t instanceof ParserRuleContext) {
2667
+ if (t.ruleIndex === index) {
2668
+ nodes.push(t);
2669
+ }
2670
+ }
2671
+ for (let i = 0; i < t.getChildCount(); i++) {
2672
+ _Trees.doFindAllNodes(t.getChild(i), index, findTokens, nodes);
2673
+ }
2674
+ }
2675
+ };
2676
+
2677
+ // src/ParserRuleContext.ts
2678
+ var ParserRuleContext = class _ParserRuleContext {
2679
+ static {
2680
+ __name(this, "ParserRuleContext");
2681
+ }
2682
+ static empty = new _ParserRuleContext(null);
2683
+ start = null;
2684
+ stop = null;
2685
+ children = [];
2686
+ /**
2687
+ * What state invoked the rule associated with this context?
2688
+ * The "return address" is the followState of invokingState
2689
+ * If parent is null, this should be -1 this context object represents
2690
+ * the start rule.
2691
+ */
2692
+ invokingState;
2693
+ parent;
2694
+ /**
2695
+ * A rule context is a record of a single rule invocation. It knows
2696
+ * which context invoked it, if any. If there is no parent context, then
2697
+ * naturally the invoking state is not valid. The parent link
2698
+ * provides a chain upwards from the current rule invocation to the root
2699
+ * of the invocation tree, forming a stack. We actually carry no
2700
+ * information about the rule associated with this context (except
2701
+ * when parsing). We keep only the state number of the invoking state from
2702
+ * the ATN submachine that invoked this. Contrast this with the s
2703
+ * pointer inside ParserRuleContext that tracks the current state
2704
+ * being "executed" for the current rule.
2705
+ *
2706
+ * The parent contexts are useful for computing lookahead sets and
2707
+ * getting error information.
2708
+ *
2709
+ * These objects are used during parsing and prediction.
2710
+ * For the special case of parsers, we use the subclass
2711
+ * ParserRuleContext.
2712
+ */
2713
+ constructor(parent, invokingStateNumber = -1) {
2714
+ this.parent = parent;
2715
+ this.invokingState = invokingStateNumber;
2716
+ }
2717
+ /** Copy a context */
2718
+ copyFrom(ctx) {
2719
+ this.parent = ctx.parent;
2720
+ this.invokingState = ctx.invokingState;
2721
+ this.children.slice(0, this.children.length);
2722
+ this.start = ctx.start;
2723
+ this.stop = ctx.stop;
2724
+ if (ctx.children) {
2725
+ ctx.children.forEach((child) => {
2726
+ if (child instanceof ErrorNode) {
2727
+ this.children.push(child);
2728
+ child.parent = this;
2729
+ }
2730
+ });
2731
+ }
2732
+ }
2733
+ // Double dispatch methods for listeners
2734
+ enterRule(_listener) {
2735
+ }
2736
+ exitRule(_listener) {
2737
+ }
2738
+ addChild(child) {
2739
+ this.children.push(child);
2740
+ return child;
2741
+ }
2742
+ /**
2743
+ * Used by enterOuterAlt to toss out a RuleContext previously added as
2744
+ * we entered a rule. If we have label, we will need to remove
2745
+ * generic ruleContext object.
2746
+ */
2747
+ removeLastChild() {
2748
+ this.children.pop();
2749
+ }
2750
+ addTokenNode(token) {
2751
+ const node = new TerminalNode(token);
2752
+ this.children.push(node);
2753
+ node.parent = this;
2754
+ return node;
2755
+ }
2756
+ addErrorNode(errorNode) {
2757
+ errorNode.parent = this;
2758
+ this.children.push(errorNode);
2759
+ return errorNode;
2760
+ }
2761
+ getChild(i, type) {
2762
+ if (i < 0 || i >= this.children.length) {
2763
+ return null;
2764
+ }
2765
+ if (!type) {
2766
+ return this.children[i];
2767
+ }
2768
+ for (const child of this.children) {
2769
+ if (child instanceof type) {
2770
+ if (i === 0) {
2771
+ return child;
2772
+ } else {
2773
+ i -= 1;
2774
+ }
2775
+ }
2776
+ }
2777
+ return null;
2778
+ }
2779
+ getToken(ttype, i) {
2780
+ if (i < 0 || i >= this.children.length) {
2781
+ return null;
2782
+ }
2783
+ for (const child of this.children) {
2784
+ if ("symbol" in child) {
2785
+ if (child.symbol?.type === ttype) {
2786
+ if (i === 0) {
2787
+ return child;
2788
+ } else {
2789
+ i -= 1;
2790
+ }
2791
+ }
2792
+ }
2793
+ }
2794
+ return null;
2795
+ }
2796
+ getTokens(ttype) {
2797
+ const tokens = [];
2798
+ for (const child of this.children) {
2799
+ if ("symbol" in child) {
2800
+ if (child.symbol?.type === ttype) {
2801
+ tokens.push(child);
2802
+ }
2803
+ }
2804
+ }
2805
+ return tokens;
2806
+ }
2807
+ // XXX: base the child type selection on the rule index, not the class.
2808
+ getRuleContext(index, ctxType) {
2809
+ return this.getChild(index, ctxType);
2810
+ }
2811
+ // XXX: base the child type selection on the rule index, not the class.
2812
+ getRuleContexts(ctxType) {
2813
+ const contexts = [];
2814
+ for (const child of this.children) {
2815
+ if (child instanceof ctxType) {
2816
+ contexts.push(child);
2817
+ }
2818
+ }
2819
+ return contexts;
2820
+ }
2821
+ getChildCount() {
2822
+ return this.children.length;
2823
+ }
2824
+ getSourceInterval() {
2825
+ if (this.start === null) {
2826
+ return Interval.INVALID_INTERVAL;
2827
+ }
2828
+ if (this.stop === null || this.stop.tokenIndex < this.start.tokenIndex) {
2829
+ return new Interval(this.start.tokenIndex, this.start.tokenIndex - 1);
2830
+ }
2831
+ return new Interval(this.start.tokenIndex, this.stop.tokenIndex);
2832
+ }
2833
+ depth() {
2834
+ let n2 = 0;
2835
+ let p = this;
2836
+ while (p !== null) {
2837
+ p = p.parent;
2838
+ n2 += 1;
2839
+ }
2840
+ return n2;
2841
+ }
2842
+ /**
2843
+ * A context is empty if there is no invoking state; meaning nobody call
2844
+ * current context.
2845
+ */
2846
+ isEmpty() {
2847
+ return this.invokingState === -1;
2848
+ }
2849
+ get ruleContext() {
2850
+ return this;
2851
+ }
2852
+ get ruleIndex() {
2853
+ return -1;
2854
+ }
2855
+ getPayload() {
2856
+ return this;
2857
+ }
2858
+ getText() {
2859
+ if (this.children.length === 0) {
2860
+ return "";
2861
+ }
2862
+ return this.children.map((child) => {
2863
+ return child.getText();
2864
+ }).join("");
2865
+ }
2866
+ /**
2867
+ * For rule associated with this parse tree internal node, return
2868
+ * the outer alternative number used to match the input. Default
2869
+ * implementation does not compute nor store this alt num. Create
2870
+ * a subclass of ParserRuleContext with backing field and set
2871
+ * option contextSuperClass.
2872
+ * to set it.
2873
+ */
2874
+ getAltNumber() {
2875
+ return ATN.INVALID_ALT_NUMBER;
2876
+ }
2877
+ /**
2878
+ * Set the outer alternative number for this context node. Default
2879
+ * implementation does nothing to avoid backing field overhead for
2880
+ * trees that don't need it. Create
2881
+ * a subclass of ParserRuleContext with backing field and set
2882
+ * option contextSuperClass.
2883
+ */
2884
+ setAltNumber(_altNumber) {
2885
+ }
2886
+ accept(visitor) {
2887
+ return visitor.visitChildren(this);
2888
+ }
2889
+ toStringTree(...args) {
2890
+ if (args.length < 2) {
2891
+ return Trees.toStringTree(this, null, args[0]);
2892
+ }
2893
+ return Trees.toStringTree(this, args[0], args[1]);
2894
+ }
2895
+ toString(ruleNames, stop) {
2896
+ ruleNames = ruleNames ?? null;
2897
+ stop = stop ?? null;
2898
+ let p = this;
2899
+ let s = "[";
2900
+ while (p !== null && p !== stop) {
2901
+ if (ruleNames === null) {
2902
+ if (!p.isEmpty()) {
2903
+ s += p.invokingState;
2904
+ }
2905
+ } else {
2906
+ const ri = p.ruleIndex;
2907
+ const ruleName = ri >= 0 && ri < ruleNames.length ? ruleNames[ri] : "" + ri;
2908
+ s += ruleName;
2909
+ }
2910
+ if (p.parent !== null && (ruleNames !== null || !p.parent.isEmpty())) {
2911
+ s += " ";
2912
+ }
2913
+ p = p.parent;
2914
+ }
2915
+ s += "]";
2916
+ return s;
2917
+ }
2918
+ };
2919
+
2920
+ // src/atn/ArrayPredictionContext.ts
2921
+ var ArrayPredictionContext = class _ArrayPredictionContext extends PredictionContext {
2922
+ static {
2923
+ __name(this, "ArrayPredictionContext");
2924
+ }
2925
+ parents = [];
2926
+ returnStates = [];
2927
+ constructor(parents, returnStates) {
2928
+ super(PredictionContext.calculateHashCodeList(parents, returnStates));
2929
+ this.parents = parents;
2930
+ this.returnStates = returnStates;
2931
+ return this;
2932
+ }
2933
+ isEmpty() {
2934
+ return this.returnStates[0] === PredictionContext.EMPTY_RETURN_STATE;
2935
+ }
2936
+ get length() {
2937
+ return this.returnStates.length;
2938
+ }
2939
+ getParent(index) {
2940
+ return this.parents[index];
2941
+ }
2942
+ getReturnState(index) {
2943
+ return this.returnStates[index];
2944
+ }
2945
+ equals(other) {
2946
+ if (this === other) {
2947
+ return true;
2948
+ }
2949
+ if (!(other instanceof _ArrayPredictionContext) || this.hashCode() !== other.hashCode()) {
2950
+ return false;
2951
+ }
2952
+ return equalNumberArrays(this.returnStates, other.returnStates) && equalArrays(this.parents, other.parents);
2953
+ }
2954
+ toString() {
2955
+ if (this.isEmpty()) {
2956
+ return "[]";
2957
+ }
2958
+ const entries = [];
2959
+ for (let i = 0; i < this.returnStates.length; i++) {
2960
+ if (this.returnStates[i] === PredictionContext.EMPTY_RETURN_STATE) {
2961
+ entries.push("$");
2962
+ continue;
2963
+ }
2964
+ entries.push(this.returnStates[i].toString());
2965
+ if (this.parents[i]) {
2966
+ entries.push(this.parents[i].toString());
2967
+ } else {
2968
+ entries.push("null");
2969
+ }
2970
+ }
2971
+ return `[${entries.join(", ")}]`;
2972
+ }
2973
+ };
2974
+
2975
+ // src/atn/helpers.ts
2976
+ var createSingletonPredictionContext = /* @__PURE__ */ __name((parent, returnState) => {
2977
+ if (returnState === PredictionContext.EMPTY_RETURN_STATE && parent === null) {
2978
+ return EmptyPredictionContext.instance;
2979
+ } else {
2980
+ return new SingletonPredictionContext(parent, returnState);
2981
+ }
2982
+ }, "createSingletonPredictionContext");
2983
+
2984
+ // src/atn/PredictionContextUtils.ts
2985
+ var predictionContextFromRuleContext = /* @__PURE__ */ __name((atn, outerContext) => {
2986
+ if (!outerContext) {
2987
+ outerContext = ParserRuleContext.empty;
2988
+ }
2989
+ if (!outerContext.parent || outerContext === ParserRuleContext.empty) {
2990
+ return EmptyPredictionContext.instance;
2991
+ }
2992
+ const parent = predictionContextFromRuleContext(atn, outerContext.parent);
2993
+ const state = atn.states[outerContext.invokingState];
2994
+ const transition = state.transitions[0];
2995
+ return createSingletonPredictionContext(parent, transition.followState.stateNumber);
2996
+ }, "predictionContextFromRuleContext");
2997
+ var merge = /* @__PURE__ */ __name((a, b, rootIsWildcard, mergeCache) => {
2998
+ if (a === b || a.equals(b)) {
2999
+ return a;
3000
+ }
3001
+ if (a instanceof SingletonPredictionContext && b instanceof SingletonPredictionContext) {
3002
+ return mergeSingletons(a, b, rootIsWildcard, mergeCache);
3003
+ }
3004
+ if (rootIsWildcard) {
3005
+ if (a instanceof EmptyPredictionContext) {
3006
+ return a;
3007
+ }
3008
+ if (b instanceof EmptyPredictionContext) {
3009
+ return b;
3010
+ }
3011
+ }
3012
+ if (a instanceof SingletonPredictionContext) {
3013
+ a = new ArrayPredictionContext([a.parent], [a.returnState]);
3014
+ }
3015
+ if (b instanceof SingletonPredictionContext) {
3016
+ b = new ArrayPredictionContext([b.parent], [b.returnState]);
3017
+ }
3018
+ return mergeArrays(a, b, rootIsWildcard, mergeCache);
3019
+ }, "merge");
3020
+ var mergeArrays = /* @__PURE__ */ __name((a, b, rootIsWildcard, mergeCache) => {
3021
+ if (mergeCache) {
3022
+ let previous = mergeCache.get(a, b);
3023
+ if (previous) {
3024
+ return previous;
3025
+ }
3026
+ previous = mergeCache.get(b, a);
3027
+ if (previous) {
3028
+ return previous;
3029
+ }
3030
+ }
3031
+ let i = 0;
3032
+ let j = 0;
3033
+ let k = 0;
3034
+ let mergedReturnStates = new Array(a.returnStates.length + b.returnStates.length).fill(0);
3035
+ let mergedParents = new Array(a.returnStates.length + b.returnStates.length).fill(null);
3036
+ while (i < a.returnStates.length && j < b.returnStates.length) {
3037
+ const aParent = a.parents[i];
3038
+ const bParent = b.parents[j];
3039
+ if (a.returnStates[i] === b.returnStates[j]) {
3040
+ const payload = a.returnStates[i];
3041
+ const bothDollars = payload === PredictionContext.EMPTY_RETURN_STATE && aParent === null && bParent === null;
3042
+ const axAx = aParent !== null && bParent !== null && aParent === bParent;
3043
+ if (bothDollars || axAx) {
3044
+ mergedParents[k] = aParent;
3045
+ mergedReturnStates[k] = payload;
3046
+ } else {
3047
+ mergedParents[k] = merge(aParent, bParent, rootIsWildcard, mergeCache);
3048
+ mergedReturnStates[k] = payload;
3049
+ }
3050
+ i += 1;
3051
+ j += 1;
3052
+ } else if (a.returnStates[i] < b.returnStates[j]) {
3053
+ mergedParents[k] = aParent;
3054
+ mergedReturnStates[k] = a.returnStates[i];
3055
+ i += 1;
3056
+ } else {
3057
+ mergedParents[k] = bParent;
3058
+ mergedReturnStates[k] = b.returnStates[j];
3059
+ j += 1;
3060
+ }
3061
+ k += 1;
3062
+ }
3063
+ if (i < a.returnStates.length) {
3064
+ for (let p = i; p < a.returnStates.length; p++) {
3065
+ mergedParents[k] = a.parents[p];
3066
+ mergedReturnStates[k] = a.returnStates[p];
3067
+ k += 1;
3068
+ }
3069
+ } else {
3070
+ for (let p = j; p < b.returnStates.length; p++) {
3071
+ mergedParents[k] = b.parents[p];
3072
+ mergedReturnStates[k] = b.returnStates[p];
3073
+ k += 1;
3074
+ }
3075
+ }
3076
+ if (k < mergedParents.length) {
3077
+ if (k === 1) {
3078
+ const aNew = createSingletonPredictionContext(mergedParents[0] ?? void 0, mergedReturnStates[0]);
3079
+ if (mergeCache !== null) {
3080
+ mergeCache.set(a, b, aNew);
3081
+ }
3082
+ return aNew;
3083
+ }
3084
+ mergedParents = mergedParents.slice(0, k);
3085
+ mergedReturnStates = mergedReturnStates.slice(0, k);
3086
+ }
3087
+ const merged = new ArrayPredictionContext(mergedParents, mergedReturnStates);
3088
+ if (merged.equals(a)) {
3089
+ if (mergeCache !== null) {
3090
+ mergeCache.set(a, b, a);
3091
+ }
3092
+ if (PredictionContext.traceATNSimulator) {
3093
+ console.log("mergeArrays a=" + a + ",b=" + b + " -> a");
3094
+ }
3095
+ return a;
3096
+ }
3097
+ if (merged.equals(b)) {
3098
+ if (mergeCache !== null) {
3099
+ mergeCache.set(a, b, b);
3100
+ }
3101
+ return b;
3102
+ }
3103
+ combineCommonParents(mergedParents);
3104
+ if (mergeCache !== null) {
3105
+ mergeCache.set(a, b, merged);
3106
+ }
3107
+ if (PredictionContext.traceATNSimulator) {
3108
+ console.log("mergeArrays a=" + a + ",b=" + b + " -> " + merged);
3109
+ }
3110
+ return merged;
3111
+ }, "mergeArrays");
3112
+ var combineCommonParents = /* @__PURE__ */ __name((parents) => {
3113
+ const uniqueParents = new HashMap(ObjectEqualityComparator.instance);
3114
+ for (const parent of parents) {
3115
+ if (parent) {
3116
+ if (!uniqueParents.containsKey(parent)) {
3117
+ uniqueParents.set(parent, parent);
3118
+ }
3119
+ }
3120
+ }
3121
+ for (let q = 0; q < parents.length; q++) {
3122
+ if (parents[q]) {
3123
+ parents[q] = uniqueParents.get(parents[q]) ?? null;
3124
+ }
3125
+ }
3126
+ }, "combineCommonParents");
3127
+ var mergeSingletons = /* @__PURE__ */ __name((a, b, rootIsWildcard, mergeCache) => {
3128
+ if (mergeCache !== null) {
3129
+ let previous = mergeCache.get(a, b);
3130
+ if (previous !== null) {
3131
+ return previous;
3132
+ }
3133
+ previous = mergeCache.get(b, a);
3134
+ if (previous !== null) {
3135
+ return previous;
3136
+ }
3137
+ }
3138
+ const rootMerge = mergeRoot(a, b, rootIsWildcard);
3139
+ if (rootMerge !== null) {
3140
+ if (mergeCache !== null) {
3141
+ mergeCache.set(a, b, rootMerge);
3142
+ }
3143
+ return rootMerge;
3144
+ }
3145
+ if (a.returnState === b.returnState) {
3146
+ const parent = merge(a.parent, b.parent, rootIsWildcard, mergeCache);
3147
+ if (parent === a.parent) {
3148
+ return a;
3149
+ }
3150
+ if (parent === b.parent) {
3151
+ return b;
3152
+ }
3153
+ const spc = createSingletonPredictionContext(parent, a.returnState);
3154
+ if (mergeCache !== null) {
3155
+ mergeCache.set(a, b, spc);
3156
+ }
3157
+ return spc;
3158
+ } else {
3159
+ let singleParent = null;
3160
+ if (a === b || a.parent !== null && a.parent.equals(b.parent)) {
3161
+ singleParent = a.parent;
3162
+ }
3163
+ if (singleParent !== null) {
3164
+ const payloads2 = [a.returnState, b.returnState];
3165
+ if (a.returnState > b.returnState) {
3166
+ payloads2[0] = b.returnState;
3167
+ payloads2[1] = a.returnState;
3168
+ }
3169
+ const parents2 = [singleParent, singleParent];
3170
+ const apc = new ArrayPredictionContext(parents2, payloads2);
3171
+ if (mergeCache !== null) {
3172
+ mergeCache.set(a, b, apc);
3173
+ }
3174
+ return apc;
3175
+ }
3176
+ const payloads = [a.returnState, b.returnState];
3177
+ let parents = [a.parent, b.parent];
3178
+ if (a.returnState > b.returnState) {
3179
+ payloads[0] = b.returnState;
3180
+ payloads[1] = a.returnState;
3181
+ parents = [b.parent, a.parent];
3182
+ }
3183
+ const aNew = new ArrayPredictionContext(parents, payloads);
3184
+ if (mergeCache !== null) {
3185
+ mergeCache.set(a, b, aNew);
3186
+ }
3187
+ return aNew;
3188
+ }
3189
+ }, "mergeSingletons");
3190
+ var mergeRoot = /* @__PURE__ */ __name((a, b, rootIsWildcard) => {
3191
+ if (rootIsWildcard) {
3192
+ if (a === EmptyPredictionContext.instance || b === EmptyPredictionContext.instance) {
3193
+ return EmptyPredictionContext.instance;
3194
+ }
3195
+ } else {
3196
+ if (a === EmptyPredictionContext.instance && b === EmptyPredictionContext.instance) {
3197
+ return EmptyPredictionContext.instance;
3198
+ }
3199
+ if (a === EmptyPredictionContext.instance) {
3200
+ const payloads = [
3201
+ b.returnState,
3202
+ PredictionContext.EMPTY_RETURN_STATE
3203
+ ];
3204
+ const parents = [b.parent, null];
3205
+ return new ArrayPredictionContext(parents, payloads);
3206
+ }
3207
+ if (b === EmptyPredictionContext.instance) {
3208
+ const payloads = [a.returnState, PredictionContext.EMPTY_RETURN_STATE];
3209
+ const parents = [a.parent, null];
3210
+ return new ArrayPredictionContext(parents, payloads);
3211
+ }
3212
+ }
3213
+ return null;
3214
+ }, "mergeRoot");
3215
+
3216
+ // src/atn/LL1Analyzer.ts
3217
+ var LL1Analyzer = class _LL1Analyzer {
3218
+ constructor(atn) {
3219
+ this.atn = atn;
3220
+ }
3221
+ static {
3222
+ __name(this, "LL1Analyzer");
3223
+ }
3224
+ /**
3225
+ * Special value added to the lookahead sets to indicate that we hit
3226
+ * a predicate during analysis if `seeThruPreds==false`.
3227
+ */
3228
+ static hitPredicate = Token.INVALID_TYPE;
3229
+ /**
3230
+ * Calculates the SLL(1) expected lookahead set for each outgoing transition
3231
+ * of an {@link ATNState}. The returned array has one element for each
3232
+ * outgoing transition in `s`. If the closure from transition
3233
+ * _i_ leads to a semantic predicate before matching a symbol, the
3234
+ * element at index *i* of the result will be `undefined`.
3235
+ *
3236
+ * @param s the ATN state
3237
+ * @returns the expected symbols for each outgoing transition of `s`.
3238
+ */
3239
+ getDecisionLookahead(s) {
3240
+ const count = s.transitions.length;
3241
+ const look = new Array(count);
3242
+ for (let alt = 0; alt < count; alt++) {
3243
+ const set = new IntervalSet();
3244
+ const lookBusy = new HashSet();
3245
+ this.doLook(
3246
+ s.transitions[alt].target,
3247
+ void 0,
3248
+ EmptyPredictionContext.instance,
3249
+ set,
3250
+ lookBusy,
3251
+ new BitSet(),
3252
+ false,
3253
+ false
3254
+ );
3255
+ if (set.length > 0 && !set.contains(_LL1Analyzer.hitPredicate)) {
3256
+ look[alt] = set;
3257
+ }
3258
+ }
3259
+ return look;
3260
+ }
3261
+ /**
3262
+ * Compute set of tokens that can follow `s` in the ATN in the
3263
+ * specified `ctx`.
3264
+ *
3265
+ * If `ctx` is `null` and the end of the rule containing
3266
+ * `s` is reached, {@link Token//EPSILON} is added to the result set.
3267
+ * If `ctx` is not `null` and the end of the outermost rule is
3268
+ * reached, {@link Token//EOF} is added to the result set.
3269
+ *
3270
+ * @param s the ATN state
3271
+ * @param stopState the ATN state to stop at. This can be a
3272
+ * {@link BlockEndState} to detect epsilon paths through a closure.
3273
+ * @param ctx the complete parser context, or `null` if the context
3274
+ * should be ignored
3275
+ *
3276
+ * @returns The set of tokens that can follow `s` in the ATN in the
3277
+ * specified `ctx`.
3278
+ */
3279
+ look(s, stopState, ctx) {
3280
+ const r = new IntervalSet();
3281
+ const lookContext = ctx ? predictionContextFromRuleContext(this.atn, ctx) : null;
3282
+ this.doLook(s, stopState, lookContext, r, new HashSet(), new BitSet(), true, true);
3283
+ return r;
3284
+ }
3285
+ /**
3286
+ * Compute set of tokens that can follow `s` in the ATN in the
3287
+ * specified `ctx`.
3288
+ *
3289
+ * If `ctx` is `null` and `stopState` or the end of the
3290
+ * rule containing `s` is reached, {@link Token//EPSILON} is added to
3291
+ * the result set. If `ctx` is not `null` and `addEOF` is
3292
+ * `true` and `stopState` or the end of the outermost rule is
3293
+ * reached, {@link Token//EOF} is added to the result set.
3294
+ *
3295
+ * @param s the ATN state.
3296
+ * @param stopState the ATN state to stop at. This can be a
3297
+ * {@link BlockEndState} to detect epsilon paths through a closure.
3298
+ * @param ctx The outer context, or `null` if the outer context should
3299
+ * not be used.
3300
+ * @param look The result lookahead set.
3301
+ * @param lookBusy A set used for preventing epsilon closures in the ATN
3302
+ * from causing a stack overflow. Outside code should pass
3303
+ * `new CustomizedSet<ATNConfig>` for this argument.
3304
+ * @param calledRuleStack A set used for preventing left recursion in the
3305
+ * ATN from causing a stack overflow. Outside code should pass
3306
+ * `new BitSet()` for this argument.
3307
+ * @param seeThruPreds `true` to true semantic predicates as
3308
+ * implicitly `true` and "see through them", otherwise `false`
3309
+ * to treat semantic predicates as opaque and add {@link hitPredicate} to the
3310
+ * result if one is encountered.
3311
+ * @param addEOF Add {@link Token//EOF} to the result if the end of the
3312
+ * outermost context is reached. This parameter has no effect if `ctx`
3313
+ * is `null`.
3314
+ */
3315
+ doLook(s, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) {
3316
+ const c = ATNConfig.createWithContext(s, 0, ctx);
3317
+ if (lookBusy.get(c)) {
3318
+ return;
3319
+ }
3320
+ lookBusy.add(c);
3321
+ if (s === stopState) {
3322
+ if (!ctx) {
3323
+ look.addOne(Token.EPSILON);
3324
+ return;
3325
+ } else if (ctx.isEmpty() && addEOF) {
3326
+ look.addOne(Token.EOF);
3327
+ return;
3328
+ }
3329
+ }
3330
+ if (s.constructor.stateType === ATNState.RULE_STOP) {
3331
+ if (!ctx) {
3332
+ look.addOne(Token.EPSILON);
3333
+ return;
3334
+ } else if (ctx.isEmpty() && addEOF) {
3335
+ look.addOne(Token.EOF);
3336
+ return;
3337
+ }
3338
+ if (ctx !== EmptyPredictionContext.instance) {
3339
+ const removed = calledRuleStack.get(s.ruleIndex);
3340
+ try {
3341
+ calledRuleStack.clear(s.ruleIndex);
3342
+ for (let i = 0; i < ctx.length; i++) {
3343
+ const returnState = this.atn.states[ctx.getReturnState(i)];
3344
+ this.doLook(
3345
+ returnState,
3346
+ stopState,
3347
+ ctx.getParent(i),
3348
+ look,
3349
+ lookBusy,
3350
+ calledRuleStack,
3351
+ seeThruPreds,
3352
+ addEOF
3353
+ );
3354
+ }
3355
+ } finally {
3356
+ if (removed) {
3357
+ calledRuleStack.set(s.ruleIndex);
3358
+ }
3359
+ }
3360
+ return;
3361
+ }
3362
+ }
3363
+ for (const t of s.transitions) {
3364
+ switch (t.transitionType) {
3365
+ case Transition.RULE: {
3366
+ if (calledRuleStack.get(t.target.ruleIndex)) {
3367
+ continue;
3368
+ }
3369
+ const newContext = createSingletonPredictionContext(
3370
+ ctx ?? void 0,
3371
+ t.followState.stateNumber
3372
+ );
3373
+ try {
3374
+ calledRuleStack.set(t.target.ruleIndex);
3375
+ this.doLook(
3376
+ t.target,
3377
+ stopState,
3378
+ newContext,
3379
+ look,
3380
+ lookBusy,
3381
+ calledRuleStack,
3382
+ seeThruPreds,
3383
+ addEOF
3384
+ );
3385
+ } finally {
3386
+ calledRuleStack.clear(t.target.ruleIndex);
3387
+ }
3388
+ break;
3389
+ }
3390
+ case Transition.PREDICATE:
3391
+ case Transition.PRECEDENCE: {
3392
+ if (seeThruPreds) {
3393
+ this.doLook(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
3394
+ } else {
3395
+ look.addOne(_LL1Analyzer.hitPredicate);
3396
+ }
3397
+ break;
3398
+ }
3399
+ case Transition.WILDCARD: {
3400
+ look.addRange(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType);
3401
+ break;
3402
+ }
3403
+ default: {
3404
+ if (t.isEpsilon) {
3405
+ this.doLook(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
3406
+ } else {
3407
+ let set = t.label;
3408
+ if (set) {
3409
+ if (t instanceof NotSetTransition) {
3410
+ set = set.complement(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType);
3411
+ }
3412
+ look.addSet(set);
3413
+ }
3414
+ }
3415
+ break;
3416
+ }
3417
+ }
3418
+ }
3419
+ }
3420
+ };
3421
+
3422
+ // src/atn/ATN.ts
3423
+ var ATN = class {
3424
+ static {
3425
+ __name(this, "ATN");
3426
+ }
3427
+ static INVALID_ALT_NUMBER = 0;
3428
+ /** Represents the type of recognizer an ATN applies to */
3429
+ static LEXER = 0;
3430
+ static PARSER = 1;
3431
+ /**
3432
+ * Used for runtime deserialization of ATNs from strings
3433
+ * The type of the ATN.
3434
+ */
3435
+ grammarType;
3436
+ /** The maximum value for any symbol recognized by a transition in the ATN. */
3437
+ maxTokenType;
3438
+ states = [];
3439
+ /**
3440
+ * Each subrule/rule is a decision point and we must track them so we
3441
+ * can go back later and build DFA predictors for them. This includes
3442
+ * all the rules, subrules, optional blocks, ()+, ()* etc...
3443
+ */
3444
+ decisionToState = [];
3445
+ /** Maps from rule index to starting state number. */
3446
+ ruleToStartState = [];
3447
+ // Initialized by the ATN deserializer.
3448
+ /** Maps from rule index to stop state number. */
3449
+ ruleToStopState = [];
3450
+ // Initialized by the ATN deserializer.
3451
+ modeNameToStartState = /* @__PURE__ */ new Map();
3452
+ /**
3453
+ * For lexer ATNs, this maps the rule index to the resulting token type.
3454
+ * For parser ATNs, this maps the rule index to the generated bypass token
3455
+ * type if the {@link ATNDeserializationOptions//isGenerateRuleBypassTransitions}
3456
+ * deserialization option was specified; otherwise, this is `null`
3457
+ */
3458
+ ruleToTokenType = [];
3459
+ // Initialized by the ATN deserializer.
3460
+ /**
3461
+ * For lexer ATNs, this is an array of {@link LexerAction} objects which may
3462
+ * be referenced by action transitions in the ATN
3463
+ */
3464
+ lexerActions = [];
3465
+ modeToStartState = [];
3466
+ analyzer;
3467
+ constructor(grammarType, maxTokenType) {
3468
+ this.grammarType = grammarType;
3469
+ this.maxTokenType = maxTokenType;
3470
+ this.analyzer = new LL1Analyzer(this);
3471
+ }
3472
+ /**
3473
+ * Compute the set of valid tokens that can occur starting in state `s`.
3474
+ * If `ctx` is null, the set of tokens will not include what can follow
3475
+ * the rule surrounding `s`. In other words, the set will be
3476
+ * restricted to tokens reachable staying within `s`'s rule.
3477
+ */
3478
+ nextTokens(atnState, ctx) {
3479
+ if (!ctx && atnState.nextTokenWithinRule) {
3480
+ return atnState.nextTokenWithinRule;
3481
+ }
3482
+ const next = this.analyzer.look(atnState, void 0, ctx);
3483
+ if (!ctx) {
3484
+ atnState.nextTokenWithinRule = next;
3485
+ }
3486
+ return next;
3487
+ }
3488
+ addState(state) {
3489
+ if (state) {
3490
+ state.stateNumber = this.states.length;
3491
+ }
3492
+ this.states.push(state);
3493
+ }
3494
+ removeState(state) {
3495
+ this.states[state.stateNumber] = null;
3496
+ }
3497
+ defineDecisionState(s) {
3498
+ this.decisionToState.push(s);
3499
+ s.decision = this.decisionToState.length - 1;
3500
+ return s.decision;
3501
+ }
3502
+ getDecisionState(decision) {
3503
+ if (this.decisionToState.length === 0) {
3504
+ return null;
3505
+ } else {
3506
+ return this.decisionToState[decision];
3507
+ }
3508
+ }
3509
+ getNumberOfDecisions() {
3510
+ return this.decisionToState.length;
3511
+ }
3512
+ /**
3513
+ * Computes the set of input symbols which could follow ATN state number
3514
+ * `stateNumber` in the specified full `context`. This method
3515
+ * considers the complete parser context, but does not evaluate semantic
3516
+ * predicates (i.e. all predicates encountered during the calculation are
3517
+ * assumed true). If a path in the ATN exists from the starting state to the
3518
+ * {@link RuleStopState} of the outermost context without matching any
3519
+ * symbols, {@link Token//EOF} is added to the returned set.
3520
+ *
3521
+ * If `context` is `null`, it is treated as
3522
+ * {@link ParserRuleContext//EMPTY}.
3523
+ *
3524
+ * @param stateNumber the ATN state number
3525
+ * @param context the full parse context
3526
+ *
3527
+ * @returns {IntervalSet} The set of potentially valid input symbols which could follow the
3528
+ * specified state in the specified context.
3529
+ *
3530
+ * @throws IllegalArgumentException if the ATN does not contain a state with
3531
+ * number `stateNumber`
3532
+ */
3533
+ getExpectedTokens(stateNumber, context) {
3534
+ if (stateNumber < 0 || stateNumber >= this.states.length) {
3535
+ throw new Error("Invalid state number.");
3536
+ }
3537
+ const s = this.states[stateNumber];
3538
+ let following = this.nextTokens(s);
3539
+ if (!following.contains(Token.EPSILON)) {
3540
+ return following;
3541
+ }
3542
+ let ctx = context;
3543
+ const expected = new IntervalSet();
3544
+ expected.addSet(following);
3545
+ expected.removeOne(Token.EPSILON);
3546
+ while (ctx !== null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) {
3547
+ const invokingState = this.states[ctx.invokingState];
3548
+ const rt = invokingState.transitions[0];
3549
+ following = this.nextTokens(rt.followState);
3550
+ expected.addSet(following);
3551
+ expected.removeOne(Token.EPSILON);
3552
+ ctx = ctx.parent;
3553
+ }
3554
+ if (following.contains(Token.EPSILON)) {
3555
+ expected.addOne(Token.EOF);
3556
+ }
3557
+ return expected;
3558
+ }
3559
+ };
3560
+
3561
+ // src/atn/ATNConfigSet.ts
3562
+ var KeyTypeEqualityComparer = class _KeyTypeEqualityComparer {
3563
+ static {
3564
+ __name(this, "KeyTypeEqualityComparer");
3565
+ }
3566
+ static instance = new _KeyTypeEqualityComparer();
3567
+ hashCode(config) {
3568
+ let hashCode = 7;
3569
+ hashCode = 31 * hashCode + config.state.stateNumber;
3570
+ hashCode = 31 * hashCode + config.alt;
3571
+ hashCode = 31 * hashCode + config.semanticContext.hashCode();
3572
+ return hashCode;
3573
+ }
3574
+ equals(a, b) {
3575
+ if (a === b) {
3576
+ return true;
3577
+ }
3578
+ return a.state.stateNumber === b.state.stateNumber && a.alt === b.alt && a.semanticContext.equals(b.semanticContext);
3579
+ }
3580
+ };
3581
+ var ATNConfigSet = class {
3582
+ static {
3583
+ __name(this, "ATNConfigSet");
3584
+ }
3585
+ /**
3586
+ * The reason that we need this is because we don't want the hash map to use
3587
+ * the standard hash code and equals. We need all configurations with the
3588
+ * same
3589
+ * `(s,i,_,semctx)` to be equal. Unfortunately, this key effectively
3590
+ * doubles
3591
+ * the number of objects associated with ATNConfigs. The other solution is
3592
+ * to
3593
+ * use a hash table that lets us specify the equals/hashCode operation.
3594
+ * All configs but hashed by (s, i, _, pi) not including context. Wiped out
3595
+ * when we go readonly as this set becomes a DFA state
3596
+ */
3597
+ configLookup = new HashSet(KeyTypeEqualityComparer.instance);
3598
+ // Track the elements as they are added to the set; supports get(i).
3599
+ configs = [];
3600
+ uniqueAlt = 0;
3601
+ /**
3602
+ * Used in parser and lexer. In lexer, it indicates we hit a pred
3603
+ * while computing a closure operation. Don't make a DFA state from this
3604
+ */
3605
+ hasSemanticContext = false;
3606
+ dipsIntoOuterContext = false;
3607
+ /**
3608
+ * Indicates that this configuration set is part of a full context
3609
+ * LL prediction. It will be used to determine how to merge $. With SLL
3610
+ * it's a wildcard whereas it is not for LL context merge
3611
+ */
3612
+ fullCtx = false;
3613
+ /**
3614
+ * Indicates that the set of configurations is read-only. Do not
3615
+ * allow any code to manipulate the set; DFA states will point at
3616
+ * the sets and they must not change. This does not protect the other
3617
+ * fields; in particular, conflictingAlts is set after
3618
+ * we've made this readonly
3619
+ */
3620
+ readOnly = false;
3621
+ conflictingAlts = null;
3622
+ /**
3623
+ * Tracks the first config that has a rule stop state. Avoids frequent linear search for that, when adding
3624
+ * a DFA state in the lexer ATN simulator.
3625
+ */
3626
+ firstStopState;
3627
+ #cachedHashCode = -1;
3628
+ constructor(fullCtxOrOldSet) {
3629
+ if (fullCtxOrOldSet !== void 0) {
3630
+ if (typeof fullCtxOrOldSet === "boolean") {
3631
+ this.fullCtx = fullCtxOrOldSet ?? true;
3632
+ } else {
3633
+ const old = fullCtxOrOldSet;
3634
+ this.addAll(old.configs);
3635
+ this.uniqueAlt = old.uniqueAlt;
3636
+ this.conflictingAlts = old.conflictingAlts;
3637
+ this.hasSemanticContext = old.hasSemanticContext;
3638
+ this.dipsIntoOuterContext = old.dipsIntoOuterContext;
3639
+ }
3640
+ }
3641
+ }
3642
+ [Symbol.iterator]() {
3643
+ return this.configs[Symbol.iterator]();
3644
+ }
3645
+ /**
3646
+ * Adding a new config means merging contexts with existing configs for
3647
+ * `(s, i, pi, _)`, where `s` is the {@link ATNConfig.state}, `i` is the {@link ATNConfig.alt}, and
3648
+ * `pi` is the {@link ATNConfig.semanticContext}. We use `(s,i,pi)` as key.
3649
+ *
3650
+ * This method updates {@link dipsIntoOuterContext} and
3651
+ * {@link hasSemanticContext} when necessary.
3652
+ */
3653
+ add(config, mergeCache = null) {
3654
+ if (this.readOnly) {
3655
+ throw new Error("This set is readonly");
3656
+ }
3657
+ if (!this.firstStopState && config.state.constructor.stateType === ATNState.RULE_STOP) {
3658
+ this.firstStopState = config;
3659
+ }
3660
+ this.hasSemanticContext ||= config.semanticContext !== SemanticContext.NONE;
3661
+ this.dipsIntoOuterContext ||= config.reachesIntoOuterContext;
3662
+ const existing = this.configLookup.getOrAdd(config);
3663
+ if (existing === config) {
3664
+ this.#cachedHashCode = -1;
3665
+ this.configs.push(config);
3666
+ return;
3667
+ }
3668
+ const rootIsWildcard = !this.fullCtx;
3669
+ const merged = merge(existing.context, config.context, rootIsWildcard, mergeCache);
3670
+ existing.reachesIntoOuterContext ||= config.reachesIntoOuterContext;
3671
+ existing.precedenceFilterSuppressed ||= config.precedenceFilterSuppressed;
3672
+ existing.context = merged;
3673
+ }
3674
+ /** Return a List holding list of configs */
3675
+ get elements() {
3676
+ return this.configs;
3677
+ }
3678
+ /**
3679
+ * Gets the complete set of represented alternatives for the configuration set.
3680
+ *
3681
+ * @returns the set of represented alternatives in this configuration set
3682
+ */
3683
+ getAlts() {
3684
+ const alts = new BitSet();
3685
+ for (const config of this.configs) {
3686
+ alts.set(config.alt);
3687
+ }
3688
+ return alts;
3689
+ }
3690
+ getPredicates() {
3691
+ const preds = [];
3692
+ for (const config of this.configs) {
3693
+ if (config.semanticContext !== SemanticContext.NONE) {
3694
+ preds.push(config.semanticContext);
3695
+ }
3696
+ }
3697
+ return preds;
3698
+ }
3699
+ getStates() {
3700
+ const states = new HashSet();
3701
+ for (const config of this.configs) {
3702
+ states.add(config.state);
3703
+ }
3704
+ return states;
3705
+ }
3706
+ optimizeConfigs(interpreter) {
3707
+ if (this.readOnly) {
3708
+ throw new Error("This set is readonly");
3709
+ }
3710
+ if (this.configLookup.size === 0) {
3711
+ return;
3712
+ }
3713
+ for (const config of this.configs) {
3714
+ config.context = interpreter.getCachedContext(config.context);
3715
+ }
3716
+ }
3717
+ addAll(coll) {
3718
+ for (const config of coll) {
3719
+ this.add(config);
3720
+ }
3721
+ return false;
3722
+ }
3723
+ equals(other) {
3724
+ if (this === other) {
3725
+ return true;
3726
+ }
3727
+ if (this.fullCtx === other.fullCtx && this.uniqueAlt === other.uniqueAlt && this.conflictingAlts === other.conflictingAlts && this.hasSemanticContext === other.hasSemanticContext && this.dipsIntoOuterContext === other.dipsIntoOuterContext && equalArrays(this.configs, other.configs)) {
3728
+ return true;
3729
+ }
3730
+ return false;
3731
+ }
3732
+ hashCode() {
3733
+ if (this.#cachedHashCode === -1) {
3734
+ this.#cachedHashCode = this.computeHashCode();
3735
+ }
3736
+ return this.#cachedHashCode;
3737
+ }
3738
+ get length() {
3739
+ return this.configs.length;
3740
+ }
3741
+ isEmpty() {
3742
+ return this.configs.length === 0;
3743
+ }
3744
+ contains(item) {
3745
+ if (this.configLookup === null) {
3746
+ throw new Error("This method is not implemented for readonly sets.");
3747
+ }
3748
+ return this.configLookup.contains(item);
3749
+ }
3750
+ containsFast(item) {
3751
+ if (this.configLookup === null) {
3752
+ throw new Error("This method is not implemented for readonly sets.");
3753
+ }
3754
+ return this.configLookup.contains(item);
3755
+ }
3756
+ clear() {
3757
+ if (this.readOnly) {
3758
+ throw new Error("This set is readonly");
3759
+ }
3760
+ this.configs = [];
3761
+ this.#cachedHashCode = -1;
3762
+ this.configLookup = new HashSet(KeyTypeEqualityComparer.instance);
3763
+ }
3764
+ setReadonly(readOnly) {
3765
+ this.readOnly = readOnly;
3766
+ if (readOnly) {
3767
+ this.configLookup = null;
3768
+ }
3769
+ }
3770
+ toString() {
3771
+ return arrayToString(this.configs) + (this.hasSemanticContext ? ",hasSemanticContext=" + this.hasSemanticContext : "") + (this.uniqueAlt !== ATN.INVALID_ALT_NUMBER ? ",uniqueAlt=" + this.uniqueAlt : "") + (this.conflictingAlts !== null ? ",conflictingAlts=" + this.conflictingAlts : "") + (this.dipsIntoOuterContext ? ",dipsIntoOuterContext" : "");
3772
+ }
3773
+ computeHashCode() {
3774
+ let hash = MurmurHash.initialize();
3775
+ this.configs.forEach((config) => {
3776
+ hash = MurmurHash.update(hash, config.hashCode());
3777
+ });
3778
+ hash = MurmurHash.finish(hash, this.configs.length);
3779
+ return hash;
3780
+ }
3781
+ };