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