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