@sheetxl/sdk 0.8.0-beta.1 → 0.8.0-beta.2

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 (353) hide show
  1. package/THIRD-PARTY-NOTICES.md +1 -1
  2. package/browser/cjs/4f5eoQQfV-V7LO2_.cjs +1 -0
  3. package/browser/cjs/BEnEDC1m546-gzWS.cjs +1 -0
  4. package/browser/cjs/CwCUa4IzGNGissLL.cjs +1 -0
  5. package/browser/cjs/{a0Z-SXs_N71CtqYb.cjs → Dg3GaW0QWwnlqetX.cjs} +1 -1
  6. package/browser/cjs/KWQPie2u7AP69web.cjs +93 -0
  7. package/browser/cjs/index.cjs +2 -2
  8. package/browser/esm/{B0HS42a7lga1k1U_.mjs → BJ9hcZAGY8Tj5_9L.mjs} +1 -1
  9. package/browser/esm/C8vpA2ZBtZf6w4nq.mjs +394 -0
  10. package/browser/esm/DDojiE2-oycJ7qGi.mjs +20 -0
  11. package/browser/esm/DEPT7zmpiMdZ-_qC.mjs +70253 -0
  12. package/browser/esm/DOvCi3lf49To36WP.mjs +8 -0
  13. package/browser/esm/{uyWBMSIxMlt8n5Z3.mjs → Dq3sc4B_HQHBrT5N.mjs} +2 -2
  14. package/browser/esm/index.mjs +871 -696
  15. package/browser/esm/{DlPMeIyxT9tG_WDk.mjs → trwZArJQQq7K9kL7.mjs} +2 -2
  16. package/licenses/dependencies.txt +204 -204
  17. package/node/esm/CGWsQOMWdnDeF4dX.mjs +8 -0
  18. package/node/esm/{Cku7XiUvw1xrRasi.mjs → CL9MI-b6D9BmtVXW.mjs} +1 -1
  19. package/node/esm/CressiwiIhxCVp1v.mjs +28 -0
  20. package/node/esm/O2cOO3xIynWUgOWe.mjs +403 -0
  21. package/node/esm/index.mjs +52356 -37345
  22. package/package.json +6 -7
  23. package/resources/locales/de/model.msg.json +45 -9
  24. package/resources/locales/en/model.msg.json +42 -9
  25. package/types/scripting-api.json +7093 -0
  26. package/types/scripting-enums.json +54 -8
  27. package/types/scripting.d.ts +7006 -1202
  28. package/types/src/anchored/AbstractAnchored.d.ts +18 -8
  29. package/types/src/anchored/AnchoredMap.d.ts +2 -0
  30. package/types/src/anchored/IAnchoredMap.d.ts +52 -4
  31. package/types/src/autoFill/AutoFill.d.ts +316 -32
  32. package/types/src/autoFill/IAutoFill.d.ts +232 -15
  33. package/types/src/border/{IBorder.d.ts → IBorders.d.ts} +41 -40
  34. package/types/src/border/index.d.ts +1 -1
  35. package/types/src/calculation/Calculation.d.ts +740 -35
  36. package/types/src/calculation/ExternalBookBindings.d.ts +118 -0
  37. package/types/src/calculation/FormulaText.d.ts +74 -0
  38. package/types/src/calculation/ICalculation.d.ts +318 -81
  39. package/types/src/calculation/INamedFormulasCollection.d.ts +5 -8
  40. package/types/src/calculation/NamedFormulaCollection.d.ts +139 -107
  41. package/types/src/calculation/NamedLambdaFunction.d.ts +28 -0
  42. package/types/src/calculation/TokenType.d.ts +9 -0
  43. package/types/src/calculation/Types.d.ts +83 -2
  44. package/types/src/calculation/_CloneBoundary.d.ts +80 -0
  45. package/types/src/calculation/compiler/ASTTypes.d.ts +58 -0
  46. package/types/src/calculation/compiler/CompilerUtils.d.ts +134 -12
  47. package/types/src/calculation/compiler/FormulaCompiler.d.ts +29 -4
  48. package/types/src/calculation/compiler/FormulaParser.d.ts +1 -2
  49. package/types/src/calculation/compiler/LiteTransform.d.ts +17 -0
  50. package/types/src/calculation/compiler/ParserUtils.d.ts +26 -1
  51. package/types/src/calculation/compiler/SRParser.d.ts +2 -1
  52. package/types/src/calculation/compiler/Types.d.ts +79 -9
  53. package/types/src/calculation/executor/CalcExecutor.d.ts +312 -33
  54. package/types/src/calculation/executor/CalcExecutorUtils.d.ts +43 -2
  55. package/types/src/calculation/executor/CircularReference.d.ts +2 -0
  56. package/types/src/calculation/formula/Formula.d.ts +58 -21
  57. package/types/src/calculation/formula/FormulaBlock.d.ts +124 -21
  58. package/types/src/calculation/formula/FormulaRecordView.d.ts +79 -0
  59. package/types/src/calculation/formula/IFormulaBlock.d.ts +261 -67
  60. package/types/src/calculation/formula/LambdaValue.d.ts +15 -16
  61. package/types/src/calculation/formula/LazyValue.d.ts +96 -0
  62. package/types/src/calculation/formula/TokenUtils.d.ts +25 -1
  63. package/types/src/calculation/formula/index.d.ts +1 -0
  64. package/types/src/calculation/functions/FunctionDeclarations.d.ts +31 -0
  65. package/types/src/calculation/functions/initializeFunctions.d.ts +15 -2
  66. package/types/src/calculation/grid/CalcGrid.d.ts +384 -158
  67. package/types/src/calculation/grid/CalcGridBackend.d.ts +450 -0
  68. package/types/src/calculation/grid/CalcGridProxy.d.ts +133 -0
  69. package/types/src/calculation/grid/CalcGridUtils.d.ts +62 -12
  70. package/types/src/calculation/grid/FormulaEntry.d.ts +129 -0
  71. package/types/src/calculation/grid/FormulaHost.d.ts +236 -0
  72. package/types/src/calculation/grid/ICalcGrid.d.ts +456 -143
  73. package/types/src/calculation/grid/_CalcRequest.d.ts +272 -0
  74. package/types/src/calculation/grid/index.d.ts +4 -0
  75. package/types/src/calculation/index.d.ts +2 -0
  76. package/types/src/calculation/spatial/ContentfulSpatialValue.d.ts +6 -2
  77. package/types/src/calculation/spatial/FormulaSpatialValue.d.ts +339 -11
  78. package/types/src/calculation/spatial/SpillEntry.d.ts +20 -5
  79. package/types/src/calculation/spatial/TouchedWindows.d.ts +86 -0
  80. package/types/src/calculation/spatial/index.d.ts +1 -0
  81. package/types/src/calculation/state/CalcInputs.d.ts +41 -0
  82. package/types/src/calculation/state/CalcNode.d.ts +141 -30
  83. package/types/src/calculation/state/CalcScope.d.ts +37 -0
  84. package/types/src/calculation/state/CalcState.d.ts +22 -1
  85. package/types/src/calculation/state/CalculationContext.d.ts +36 -2
  86. package/types/src/calculation/state/IContextContainer.d.ts +129 -27
  87. package/types/src/calculation/state/_PendingOverlayGrid.d.ts +163 -0
  88. package/types/src/calculation/state/_ReadObservedGrid.d.ts +74 -8
  89. package/types/src/calculation/state/index.d.ts +1 -0
  90. package/types/src/calculation/symbol/ExternalSheetSymbols.d.ts +80 -0
  91. package/types/src/calculation/symbol/ISymbolRegistry.d.ts +23 -0
  92. package/types/src/calculation/symbol/IndirectSymbolProvider.d.ts +16 -2
  93. package/types/src/calculation/symbol/SheetSymbolProvider.d.ts +63 -3
  94. package/types/src/calculation/symbol/SymbolRegistry.d.ts +20 -0
  95. package/types/src/calculation/symbol/index.d.ts +3 -2
  96. package/types/src/cell/ICell.d.ts +78 -23
  97. package/types/src/cell/ICellProtection.d.ts +50 -10
  98. package/types/src/cellRange/ICellRange.d.ts +329 -72
  99. package/types/src/cellRange/ICellRanges.d.ts +9 -7
  100. package/types/src/chart/Chart.d.ts +72 -2
  101. package/types/src/chart/ChartCollection.d.ts +26 -0
  102. package/types/src/chart/IChart.d.ts +162 -9
  103. package/types/src/chart/IChartCollection.d.ts +25 -0
  104. package/types/src/chart/_ChartXml.d.ts +70 -0
  105. package/types/src/chart/index.d.ts +1 -3
  106. package/types/src/collections/ArraysGrid.d.ts +1 -1
  107. package/types/src/collections/IGrid.d.ts +1 -1
  108. package/types/src/collections/ISparseGrid.d.ts +9 -0
  109. package/types/src/collections/ISpatialMap.d.ts +59 -21
  110. package/types/src/collections/ImmutableList.d.ts +28 -0
  111. package/types/src/collections/MixedTypedArrayList.d.ts +168 -108
  112. package/types/src/collections/OverlappingRangeIterator.d.ts +13 -17
  113. package/types/src/collections/RepeatingList.d.ts +7 -0
  114. package/types/src/collections/ScalarGrid.d.ts +50 -0
  115. package/types/src/collections/SparseGrid.d.ts +1 -1
  116. package/types/src/collections/SpatialMap.d.ts +13 -21
  117. package/types/src/collections/Tuple.d.ts +128 -16
  118. package/types/src/collections/_GridUtils.d.ts +19 -6
  119. package/types/src/collections/_RangeSweep.d.ts +97 -0
  120. package/types/src/collections/_SpatialUtils.d.ts +20 -2
  121. package/types/src/collections/index.d.ts +1 -0
  122. package/types/src/comment/Comment.d.ts +159 -0
  123. package/types/src/comment/CommentCollection.d.ts +40 -0
  124. package/types/src/comment/IComment.d.ts +319 -48
  125. package/types/src/comment/ICommentCollection.d.ts +90 -0
  126. package/types/src/comment/_CommentUtils.d.ts +28 -0
  127. package/types/src/comment/index.d.ts +1 -0
  128. package/types/src/condition/AnchoredConditional.d.ts +76 -17
  129. package/types/src/condition/BuiltInOperators/AbstractOperator.d.ts +8 -7
  130. package/types/src/condition/BuiltInOperators/EqualToOperator.d.ts +2 -1
  131. package/types/src/condition/BuiltInOperators/ExpressionOperator.d.ts +3 -6
  132. package/types/src/condition/BuiltInOperators/InSetOperator.d.ts +1 -1
  133. package/types/src/condition/BuiltinSelectors/BaseSelector.d.ts +7 -0
  134. package/types/src/condition/BuiltinSelectors/ListSelector.d.ts +9 -0
  135. package/types/src/condition/Condition.d.ts +16 -0
  136. package/types/src/condition/ICondition.d.ts +86 -33
  137. package/types/src/condition/_ConditionFormula.d.ts +152 -0
  138. package/types/src/condition/_ConditionUtils.d.ts +73 -10
  139. package/types/src/conditionalFormat/ConditionalFormat.d.ts +21 -10
  140. package/types/src/conditionalFormat/ConditionalFormatCollection.d.ts +19 -8
  141. package/types/src/conditionalFormat/IConditionalFormat.d.ts +5 -3
  142. package/types/src/conditionalFormat/IConditionalFormatCollection.d.ts +2 -0
  143. package/types/src/dataValidation/DataValidation.d.ts +50 -3
  144. package/types/src/dataValidation/DataValidationCollection.d.ts +20 -9
  145. package/types/src/dataValidation/IDataValidation.d.ts +119 -30
  146. package/types/src/dataValidation/IDataValidationCollection.d.ts +10 -2
  147. package/types/src/date/DateUtils.d.ts +20 -0
  148. package/types/src/date/_DateUtils.d.ts +91 -7
  149. package/types/src/externalBook/ExternalBookCollection.d.ts +145 -12
  150. package/types/src/externalBook/ExternalBookName.d.ts +96 -0
  151. package/types/src/externalBook/IExternalBook.d.ts +170 -18
  152. package/types/src/externalBook/IExternalBookCollection.d.ts +79 -7
  153. package/types/src/externalBook/index.d.ts +1 -0
  154. package/types/src/fill/IStroke.d.ts +1 -1
  155. package/types/src/filter/IFilter.d.ts +29 -4
  156. package/types/src/font/IFont.d.ts +17 -0
  157. package/types/src/history/IHistory.d.ts +3 -2
  158. package/types/src/i18n/LanguagePack.d.ts +12 -4
  159. package/types/src/index.d.ts +3 -0
  160. package/types/src/io/AbstractBackingStore.d.ts +24 -1
  161. package/types/src/io/ArrayBackingStore.d.ts +1 -1
  162. package/types/src/io/EmbeddedPart.d.ts +20 -0
  163. package/types/src/io/IEmbeddedPart.d.ts +63 -0
  164. package/types/src/io/IWorkbookIO.d.ts +185 -18
  165. package/types/src/io/WorkbookIO.d.ts +9 -0
  166. package/types/src/io/WorkbookOrigin.d.ts +20 -11
  167. package/types/src/io/WorkbookOriginProvider.d.ts +46 -0
  168. package/types/src/io/_XmlFragment.d.ts +49 -0
  169. package/types/src/io/index.d.ts +1 -0
  170. package/types/src/lib/file/file.browser.d.ts +19 -5
  171. package/types/src/lib/file/file.node.d.ts +5 -0
  172. package/types/src/lib/utils/_Utils.d.ts +11 -0
  173. package/types/src/lib/utils/utils.browser.d.ts +9 -3
  174. package/types/src/license/license-key.d.ts +27 -0
  175. package/types/src/listener/IListener.d.ts +12 -7
  176. package/types/src/listener/ListenerEmitter.d.ts +46 -5
  177. package/types/src/model/AbstractModel.d.ts +14 -5
  178. package/types/src/movable/Control.d.ts +57 -0
  179. package/types/src/movable/IControl.d.ts +84 -0
  180. package/types/src/movable/IMovable.d.ts +23 -1
  181. package/types/src/movable/IMovableCollection.d.ts +2 -0
  182. package/types/src/movable/Movable.d.ts +4 -6
  183. package/types/src/movable/MovableCollection.d.ts +7 -7
  184. package/types/src/movable/index.d.ts +4 -0
  185. package/types/src/named/AbstractNamed.d.ts +1 -1
  186. package/types/src/named/INamed.d.ts +4 -1
  187. package/types/src/named/INamedCollection.d.ts +26 -0
  188. package/types/src/named/NamedCollection.d.ts +16 -15
  189. package/types/src/numFmt/BuiltInFormats.d.ts +15 -7
  190. package/types/src/numFmt/IFormatEngine.d.ts +2 -0
  191. package/types/src/numFmt/NumfmtFormatEngine.d.ts +2 -0
  192. package/types/src/person/IPerson.d.ts +99 -0
  193. package/types/src/person/IPersonCollection.d.ts +51 -0
  194. package/types/src/person/Person.d.ts +32 -0
  195. package/types/src/person/PersonCollection.d.ts +49 -0
  196. package/types/src/person/index.d.ts +3 -0
  197. package/types/src/picture/IPicture.d.ts +2 -0
  198. package/types/src/picture/Picture.d.ts +2 -0
  199. package/types/src/pivot/IPivotTable.d.ts +107 -0
  200. package/types/src/pivot/IPivotTableCollection.d.ts +25 -0
  201. package/types/src/pivot/PivotTable.d.ts +57 -0
  202. package/types/src/pivot/PivotTableCollection.d.ts +25 -0
  203. package/types/src/pivot/index.d.ts +6 -0
  204. package/types/src/primitives/CompositeRangeStats.d.ts +2 -0
  205. package/types/src/primitives/Criteria.d.ts +1 -1
  206. package/types/src/primitives/LambdaBrand.d.ts +21 -0
  207. package/types/src/primitives/PrimitiveUtils.d.ts +56 -19
  208. package/types/src/primitives/Range.d.ts +102 -24
  209. package/types/src/primitives/RangeStats.d.ts +24 -1
  210. package/types/src/primitives/ReferenceRange.d.ts +42 -0
  211. package/types/src/primitives/Runtime.d.ts +15 -2
  212. package/types/src/primitives/stats/FrequencyStats.d.ts +9 -0
  213. package/types/src/primitives/stats/LookupIndex.d.ts +46 -0
  214. package/types/src/primitives/stats/SortedNumbers.d.ts +2 -0
  215. package/types/src/primitives/stats/index.d.ts +1 -0
  216. package/types/src/print/IPrint.d.ts +0 -22
  217. package/types/src/protectedRange/IProtectedRange.d.ts +4 -0
  218. package/types/src/protectedRange/IProtectedRangeCollection.d.ts +2 -0
  219. package/types/src/protectedRange/ProtectedRange.d.ts +1 -4
  220. package/types/src/protectedRange/ProtectedRangeCollection.d.ts +19 -8
  221. package/types/src/protection/DefaultProtection.d.ts +12 -1
  222. package/types/src/protection/IProtection.d.ts +36 -2
  223. package/types/src/reference/ReferenceUtils.d.ts +80 -0
  224. package/types/src/reference/index.d.ts +2 -0
  225. package/types/src/resource/IResource.d.ts +21 -1
  226. package/types/src/resource/IResourceCollection.d.ts +9 -1
  227. package/types/src/resource/ResourceCollection.d.ts +6 -6
  228. package/types/src/scripting/FunctionCollection.d.ts +41 -11
  229. package/types/src/scripting/IFunctionCollection.d.ts +41 -0
  230. package/types/src/scripting/IModule.d.ts +25 -0
  231. package/types/src/scripting/IModuleCollection.d.ts +17 -0
  232. package/types/src/scripting/IScript.d.ts +18 -0
  233. package/types/src/scripting/Module.d.ts +34 -6
  234. package/types/src/scripting/ModuleCollection.d.ts +17 -12
  235. package/types/src/scripting/Runtime.d.ts +15 -0
  236. package/types/src/scripting/Scripts.d.ts +2 -0
  237. package/types/src/scripting/TypedFunction.d.ts +151 -18
  238. package/types/src/scripting/_FunctionIndex.d.ts +5 -0
  239. package/types/src/scripting/_ModuleUtils.d.ts +11 -1
  240. package/types/src/scripting/_ScriptUtils.d.ts +3 -0
  241. package/types/src/scripting/declarations.browser.d.ts +10 -0
  242. package/types/src/scripting/declarations.d.ts +49 -0
  243. package/types/src/scripting/declarations.node.d.ts +9 -0
  244. package/types/src/scripting/index.d.ts +3 -0
  245. package/types/src/selection/IRangeSelection.d.ts +9 -4
  246. package/types/src/selection/RangeSelection.d.ts +2 -0
  247. package/types/src/shape/IShape.d.ts +41 -3
  248. package/types/src/shape/Shape.d.ts +10 -0
  249. package/types/src/shape/_ShapeXml.d.ts +28 -0
  250. package/types/src/sheet/CellRegion.d.ts +6 -0
  251. package/types/src/sheet/ICellContainerOptions.d.ts +50 -0
  252. package/types/src/sheet/ISheet.d.ts +224 -41
  253. package/types/src/sheet/ISheetCollection.d.ts +2 -5
  254. package/types/src/sheet/NamedCellRange.d.ts +16 -7
  255. package/types/src/sheet/Sheet.d.ts +749 -114
  256. package/types/src/sheet/SheetCell.d.ts +81 -21
  257. package/types/src/sheet/SheetCollection.d.ts +19 -8
  258. package/types/src/sheet/SheetRange.d.ts +62 -14
  259. package/types/src/sheet/SheetRanges.d.ts +4 -6
  260. package/types/src/sheet/_CellBuffer.d.ts +214 -0
  261. package/types/src/sheet/_InvalidSheetRange.d.ts +5 -5
  262. package/types/src/sheet/_ListenerAnchor.d.ts +104 -0
  263. package/types/src/sheet/_RangeStateSweep.d.ts +16 -0
  264. package/types/src/sheet/_ScalarListFactory.d.ts +61 -0
  265. package/types/src/sheet/_SheetAutoFillUtils.d.ts +74 -0
  266. package/types/src/sheet/_SheetAutoFitUtils.d.ts +2 -2
  267. package/types/src/sheet/_SheetEvents.d.ts +43 -0
  268. package/types/src/sheet/_SheetFilterUtils.d.ts +32 -1
  269. package/types/src/sheet/_SheetIntents.d.ts +250 -0
  270. package/types/src/sheet/_SheetMutations.d.ts +179 -59
  271. package/types/src/sheet/_SheetStateReader.d.ts +16 -10
  272. package/types/src/sheet/_SheetStateTypes.d.ts +57 -73
  273. package/types/src/sheet/_SheetUtils.d.ts +2 -18
  274. package/types/src/sheet/_WatchAnchor.d.ts +93 -0
  275. package/types/src/sheet/spatial/HeldFormulaEntry.d.ts +36 -0
  276. package/types/src/sheet/spatial/index.d.ts +1 -0
  277. package/types/src/sheet/style/SheetCellStyle.d.ts +91 -64
  278. package/types/src/sheet/style/SheetDirectStyle.d.ts +16 -5
  279. package/types/src/sheet/style/_Resolvers.d.ts +5 -3
  280. package/types/src/sheet/style/_StyleUtils.d.ts +37 -7
  281. package/types/src/sheetHeader/ISheetHeader.d.ts +2 -0
  282. package/types/src/sheetHeader/SheetHeader.d.ts +14 -0
  283. package/types/src/sheetProtection/ISheetProtection.d.ts +41 -7
  284. package/types/src/sheetProtection/SheetProtection.d.ts +12 -0
  285. package/types/src/sheetView/ISheetView.d.ts +45 -1
  286. package/types/src/sheetView/SheetView.d.ts +11 -0
  287. package/types/src/slicer/ISlicer.d.ts +2 -0
  288. package/types/src/slicer/Slicer.d.ts +2 -0
  289. package/types/src/sort/ISort.d.ts +2 -0
  290. package/types/src/string/IStringCollection.d.ts +5 -0
  291. package/types/src/string/StringCollection.d.ts +6 -6
  292. package/types/src/style/INamedStyleCollection.d.ts +72 -0
  293. package/types/src/style/IStyle.d.ts +30 -10
  294. package/types/src/style/IStyleCollection.d.ts +63 -42
  295. package/types/src/style/ITableStyleCollection.d.ts +89 -0
  296. package/types/src/style/NamedStyleCollection.d.ts +39 -0
  297. package/types/src/style/StyleCollection.d.ts +41 -5
  298. package/types/src/style/TableStyleCollection.d.ts +49 -0
  299. package/types/src/style/_BuiltInStyleDefs.d.ts +3 -3
  300. package/types/src/style/index.d.ts +4 -0
  301. package/types/src/table/AnchoredTable.d.ts +644 -68
  302. package/types/src/table/AutoTable.d.ts +5 -5
  303. package/types/src/table/ITable.d.ts +228 -30
  304. package/types/src/table/ITableCollection.d.ts +2 -0
  305. package/types/src/table/TableCollection.d.ts +19 -8
  306. package/types/src/table/_FilterField.d.ts +7 -5
  307. package/types/src/table/_NamedTable.d.ts +17 -1
  308. package/types/src/table/_NamedTableSource.d.ts +1 -0
  309. package/types/src/table/_SortField.d.ts +2 -0
  310. package/types/src/table/_TableColumn.d.ts +13 -2
  311. package/types/src/table/_TableMessages.d.ts +1 -0
  312. package/types/src/table/_TableUtils.d.ts +40 -0
  313. package/types/src/text/Bullet.d.ts +4 -0
  314. package/types/src/text/ITextFrame.d.ts +25 -1
  315. package/types/src/text/TextBoxAlignment.d.ts +15 -6
  316. package/types/src/text/TextFrame.d.ts +4 -0
  317. package/types/src/text/TextLine.d.ts +4 -0
  318. package/types/src/text/TextParagraph.d.ts +4 -0
  319. package/types/src/text/TextRun.d.ts +9 -0
  320. package/types/src/text/TextStacked.d.ts +83 -0
  321. package/types/src/text/index.d.ts +1 -0
  322. package/types/src/theme/ITheme.d.ts +2 -0
  323. package/types/src/theme/IThemeCollection.d.ts +2 -0
  324. package/types/src/theme/ThemeCollection.d.ts +8 -7
  325. package/types/src/transaction/ITransaction.d.ts +238 -36
  326. package/types/src/transaction/Transaction.d.ts +99 -11
  327. package/types/src/type/AbstractCollection.d.ts +101 -0
  328. package/types/src/type/ICollection.d.ts +117 -0
  329. package/types/src/type/ITypes.d.ts +9 -7
  330. package/types/src/type/index.d.ts +1 -0
  331. package/types/src/utils/_CSSUtils.d.ts +3 -3
  332. package/types/src/workbook/IWorkbook.d.ts +171 -40
  333. package/types/src/workbook/Workbook.d.ts +103 -7
  334. package/types/src/workbook/_WorkbookIntents.d.ts +36 -0
  335. package/types/src/workbookProtection/IWorkbookProtection.d.ts +7 -0
  336. package/types/src/workbookProtection/WorkbookProtection.d.ts +3 -0
  337. package/types/src/workbookView/IWorkbookView.d.ts +12 -0
  338. package/types/src/workbookView/WorkbookView.d.ts +5 -0
  339. package/browser/cjs/BatsV2UUraVDCRXm.cjs +0 -57
  340. package/browser/cjs/CUz53T65cRGQRgvv.cjs +0 -33
  341. package/browser/cjs/DU0kYUtdFa3jK-im.cjs +0 -1
  342. package/browser/cjs/Dv4yIPLV98M5zLHa.cjs +0 -1
  343. package/browser/esm/6JKSOvc5czaQB2Bj.mjs +0 -109
  344. package/browser/esm/BtuJ9AGzeURtAsGo.mjs +0 -51241
  345. package/browser/esm/DGU6sM25u0EWCKl1.mjs +0 -824
  346. package/browser/esm/f2G3QRgEbvFJcoa2.mjs +0 -4436
  347. package/node/esm/-pxdn3M3tc6PLHs7.mjs +0 -114
  348. package/node/esm/0n5bslM9jhO1JnI2.mjs +0 -843
  349. package/types/src/cellRange/_GraphNode.d.ts +0 -38
  350. package/types/src/dataValidation/_Utils.d.ts +0 -10
  351. package/types/src/sheet/listener/RangesListener.d.ts +0 -32
  352. package/types/src/sheet/listener/RangesListenerEntry.d.ts +0 -19
  353. package/types/src/sheet/listener/index.d.ts +0 -3
@@ -1,4436 +0,0 @@
1
- /**
2
- * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.8.0-beta.1
3
- *
4
- * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
- * License: The license can be found at https://www.sheetxl.com/license.
6
- */
7
- import { nt as e } from "./BtuJ9AGzeURtAsGo.mjs";
8
- import { FormulaError as t } from "@sheetxl/primitives";
9
- function n(e) {
10
- console && console.error && console.error(`Error: ${e}`);
11
- }
12
- function r(e) {
13
- console && console.warn && console.warn(`Warning: ${e}`);
14
- }
15
- function i(e) {
16
- let t = (/* @__PURE__ */ new Date()).getTime(), n = e();
17
- return {
18
- time: (/* @__PURE__ */ new Date()).getTime() - t,
19
- value: n
20
- };
21
- }
22
- function a(e) {
23
- function t() {}
24
- t.prototype = e;
25
- let n = new t();
26
- function r() {
27
- return typeof n.bar;
28
- }
29
- return r(), r(), e;
30
- }
31
- var o = class {
32
- get definition() {
33
- return this._definition;
34
- }
35
- set definition(e) {
36
- this._definition = e;
37
- }
38
- constructor(e) {
39
- this._definition = e;
40
- }
41
- accept(e) {
42
- e.visit(this), this.definition.forEach((t) => {
43
- t.accept(e);
44
- });
45
- }
46
- }, s = class extends o {
47
- constructor(e) {
48
- super([]), this.idx = 1, Object.assign(this, v(e));
49
- }
50
- set definition(e) {}
51
- get definition() {
52
- return this.referencedRule === void 0 ? [] : this.referencedRule.definition;
53
- }
54
- accept(e) {
55
- e.visit(this);
56
- }
57
- }, c = class extends o {
58
- constructor(e) {
59
- super(e.definition), this.orgText = "", Object.assign(this, v(e));
60
- }
61
- }, l = class extends o {
62
- constructor(e) {
63
- super(e.definition), this.ignoreAmbiguities = !1, Object.assign(this, v(e));
64
- }
65
- }, u = class extends o {
66
- constructor(e) {
67
- super(e.definition), this.idx = 1, Object.assign(this, v(e));
68
- }
69
- }, d = class extends o {
70
- constructor(e) {
71
- super(e.definition), this.idx = 1, Object.assign(this, v(e));
72
- }
73
- }, f = class extends o {
74
- constructor(e) {
75
- super(e.definition), this.idx = 1, Object.assign(this, v(e));
76
- }
77
- }, p = class extends o {
78
- constructor(e) {
79
- super(e.definition), this.idx = 1, Object.assign(this, v(e));
80
- }
81
- }, m = class extends o {
82
- constructor(e) {
83
- super(e.definition), this.idx = 1, Object.assign(this, v(e));
84
- }
85
- }, h = class extends o {
86
- get definition() {
87
- return this._definition;
88
- }
89
- set definition(e) {
90
- this._definition = e;
91
- }
92
- constructor(e) {
93
- super(e.definition), this.idx = 1, this.ignoreAmbiguities = !1, this.hasPredicates = !1, Object.assign(this, v(e));
94
- }
95
- }, g = class {
96
- constructor(e) {
97
- this.idx = 1, Object.assign(this, v(e));
98
- }
99
- accept(e) {
100
- e.visit(this);
101
- }
102
- };
103
- function _(e) {
104
- function t(e) {
105
- return e.map(_);
106
- }
107
- if (e instanceof s) {
108
- let t = {
109
- type: "NonTerminal",
110
- name: e.nonTerminalName,
111
- idx: e.idx
112
- };
113
- return typeof e.label == "string" && (t.label = e.label), t;
114
- }
115
- if (e instanceof l) return {
116
- type: "Alternative",
117
- definition: t(e.definition)
118
- };
119
- if (e instanceof u) return {
120
- type: "Option",
121
- idx: e.idx,
122
- definition: t(e.definition)
123
- };
124
- if (e instanceof d) return {
125
- type: "RepetitionMandatory",
126
- idx: e.idx,
127
- definition: t(e.definition)
128
- };
129
- if (e instanceof f) return {
130
- type: "RepetitionMandatoryWithSeparator",
131
- idx: e.idx,
132
- separator: _(new g({ terminalType: e.separator })),
133
- definition: t(e.definition)
134
- };
135
- if (e instanceof m) return {
136
- type: "RepetitionWithSeparator",
137
- idx: e.idx,
138
- separator: _(new g({ terminalType: e.separator })),
139
- definition: t(e.definition)
140
- };
141
- if (e instanceof p) return {
142
- type: "Repetition",
143
- idx: e.idx,
144
- definition: t(e.definition)
145
- };
146
- if (e instanceof h) return {
147
- type: "Alternation",
148
- idx: e.idx,
149
- definition: t(e.definition)
150
- };
151
- if (e instanceof g) {
152
- let t = {
153
- type: "Terminal",
154
- name: e.terminalType.name,
155
- label: (n = e.terminalType, typeof (r = n).LABEL == "string" && r.LABEL !== "" ? n.LABEL : n.name),
156
- idx: e.idx
157
- };
158
- typeof e.label == "string" && (t.terminalLabel = e.label);
159
- let i = e.terminalType.PATTERN;
160
- return e.terminalType.PATTERN && (t.pattern = i instanceof RegExp ? i.source : i), t;
161
- }
162
- if (e instanceof c) return {
163
- type: "Rule",
164
- name: e.name,
165
- orgText: e.orgText,
166
- definition: t(e.definition)
167
- };
168
- throw Error("non exhaustive match");
169
- var n, r;
170
- }
171
- function v(e) {
172
- return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
173
- }
174
- var y = class {
175
- visit(e) {
176
- let t = e;
177
- switch (t.constructor) {
178
- case s: return this.visitNonTerminal(t);
179
- case l: return this.visitAlternative(t);
180
- case u: return this.visitOption(t);
181
- case d: return this.visitRepetitionMandatory(t);
182
- case f: return this.visitRepetitionMandatoryWithSeparator(t);
183
- case m: return this.visitRepetitionWithSeparator(t);
184
- case p: return this.visitRepetition(t);
185
- case h: return this.visitAlternation(t);
186
- case g: return this.visitTerminal(t);
187
- case c: return this.visitRule(t);
188
- default: throw Error("non exhaustive match");
189
- }
190
- }
191
- visitNonTerminal(e) {}
192
- visitAlternative(e) {}
193
- visitOption(e) {}
194
- visitRepetition(e) {}
195
- visitRepetitionMandatory(e) {}
196
- visitRepetitionMandatoryWithSeparator(e) {}
197
- visitRepetitionWithSeparator(e) {}
198
- visitAlternation(e) {}
199
- visitTerminal(e) {}
200
- visitRule(e) {}
201
- };
202
- function b(e, t = []) {
203
- return e instanceof u || e instanceof p || e instanceof m || (e instanceof h ? e.definition.some((e) => b(e, t)) : !(e instanceof s && t.includes(e)) && e instanceof o && (e instanceof s && t.push(e), e.definition.every((e) => b(e, t))));
204
- }
205
- function x(e) {
206
- if (e instanceof s) return "SUBRULE";
207
- if (e instanceof u) return "OPTION";
208
- if (e instanceof h) return "OR";
209
- if (e instanceof d) return "AT_LEAST_ONE";
210
- if (e instanceof f) return "AT_LEAST_ONE_SEP";
211
- if (e instanceof m) return "MANY_SEP";
212
- if (e instanceof p) return "MANY";
213
- if (e instanceof g) return "CONSUME";
214
- throw Error("non exhaustive match");
215
- }
216
- var S = class {
217
- walk(e, t = []) {
218
- e.definition.forEach((n, r) => {
219
- let i = e.definition.slice(r + 1);
220
- if (n instanceof s) this.walkProdRef(n, i, t);
221
- else if (n instanceof g) this.walkTerminal(n, i, t);
222
- else if (n instanceof l) this.walkFlat(n, i, t);
223
- else if (n instanceof u) this.walkOption(n, i, t);
224
- else if (n instanceof d) this.walkAtLeastOne(n, i, t);
225
- else if (n instanceof f) this.walkAtLeastOneSep(n, i, t);
226
- else if (n instanceof m) this.walkManySep(n, i, t);
227
- else if (n instanceof p) this.walkMany(n, i, t);
228
- else {
229
- if (!(n instanceof h)) throw Error("non exhaustive match");
230
- this.walkOr(n, i, t);
231
- }
232
- });
233
- }
234
- walkTerminal(e, t, n) {}
235
- walkProdRef(e, t, n) {}
236
- walkFlat(e, t, n) {
237
- let r = t.concat(n);
238
- this.walk(e, r);
239
- }
240
- walkOption(e, t, n) {
241
- let r = t.concat(n);
242
- this.walk(e, r);
243
- }
244
- walkAtLeastOne(e, t, n) {
245
- let r = [new u({ definition: e.definition })].concat(t, n);
246
- this.walk(e, r);
247
- }
248
- walkAtLeastOneSep(e, t, n) {
249
- let r = C(e, t, n);
250
- this.walk(e, r);
251
- }
252
- walkMany(e, t, n) {
253
- let r = [new u({ definition: e.definition })].concat(t, n);
254
- this.walk(e, r);
255
- }
256
- walkManySep(e, t, n) {
257
- let r = C(e, t, n);
258
- this.walk(e, r);
259
- }
260
- walkOr(e, t, n) {
261
- let r = t.concat(n);
262
- e.definition.forEach((e) => {
263
- let t = new l({ definition: [e] });
264
- this.walk(t, r);
265
- });
266
- }
267
- };
268
- function C(e, t, n) {
269
- return [new u({ definition: [new g({ terminalType: e.separator })].concat(e.definition) })].concat(t, n);
270
- }
271
- function w(e) {
272
- if (e instanceof s) return w(e.referencedRule);
273
- if (e instanceof g) return [e.terminalType];
274
- if (function(e) {
275
- return e instanceof l || e instanceof u || e instanceof p || e instanceof d || e instanceof f || e instanceof m || e instanceof g || e instanceof c;
276
- }(e)) return function(e) {
277
- let t = [], n = e.definition, r, i = 0, a = n.length > i, o = !0;
278
- for (; a && o;) r = n[i], o = b(r), t = t.concat(w(r)), i += 1, a = n.length > i;
279
- return [...new Set(t)];
280
- }(e);
281
- if (function(e) {
282
- return e instanceof h;
283
- }(e)) return function(e) {
284
- let t = e.definition.map((e) => w(e));
285
- return [...new Set(t.flat())];
286
- }(e);
287
- throw Error("non exhaustive match");
288
- }
289
- var T = "_~IN~_", E = class extends S {
290
- constructor(e) {
291
- super(), this.topProd = e, this.follows = {};
292
- }
293
- startWalking() {
294
- return this.walk(this.topProd), this.follows;
295
- }
296
- walkTerminal(e, t, n) {}
297
- walkProdRef(e, t, n) {
298
- let r = (i = e.referencedRule, a = e.idx, i.name + a + T + this.topProd.name);
299
- var i, a;
300
- let o = w(new l({ definition: t.concat(n) }));
301
- this.follows[r] = o;
302
- }
303
- };
304
- function D(e) {
305
- return e.charCodeAt(0);
306
- }
307
- function O(e, t) {
308
- Array.isArray(e) ? e.forEach(function(e) {
309
- t.push(e);
310
- }) : t.push(e);
311
- }
312
- function k(e, t) {
313
- if (!0 === e[t]) throw "duplicate flag " + t;
314
- e[t], e[t] = !0;
315
- }
316
- function A(e) {
317
- if (e === void 0) throw Error("Internal Error - Should never get here!");
318
- return !0;
319
- }
320
- function j() {
321
- throw Error("Internal Error - Should never get here!");
322
- }
323
- function M(e) {
324
- return e.type === "Character";
325
- }
326
- var N = [];
327
- for (let e = D("0"); e <= D("9"); e++) N.push(e);
328
- var P = [D("_")].concat(N);
329
- for (let e = D("a"); e <= D("z"); e++) P.push(e);
330
- for (let e = D("A"); e <= D("Z"); e++) P.push(e);
331
- var ee = [
332
- D(" "),
333
- D("\f"),
334
- D("\n"),
335
- D("\r"),
336
- D(" "),
337
- D("\v"),
338
- D(" "),
339
- D("\xA0"),
340
- D(" "),
341
- D(" "),
342
- D(" "),
343
- D(" "),
344
- D(" "),
345
- D(" "),
346
- D(" "),
347
- D(" "),
348
- D(" "),
349
- D(" "),
350
- D(" "),
351
- D(" "),
352
- D("\u2028"),
353
- D("\u2029"),
354
- D(" "),
355
- D(" "),
356
- D(" "),
357
- D("")
358
- ], te = /[0-9a-fA-F]/, F = /[0-9]/, ne = /[1-9]/, I = class {
359
- visitChildren(e) {
360
- for (let t in e) {
361
- let n = e[t];
362
- e.hasOwnProperty(t) && (n.type === void 0 ? Array.isArray(n) && n.forEach((e) => {
363
- this.visit(e);
364
- }, this) : this.visit(n));
365
- }
366
- }
367
- visit(e) {
368
- switch (e.type) {
369
- case "Pattern":
370
- this.visitPattern(e);
371
- break;
372
- case "Flags":
373
- this.visitFlags(e);
374
- break;
375
- case "Disjunction":
376
- this.visitDisjunction(e);
377
- break;
378
- case "Alternative":
379
- this.visitAlternative(e);
380
- break;
381
- case "StartAnchor":
382
- this.visitStartAnchor(e);
383
- break;
384
- case "EndAnchor":
385
- this.visitEndAnchor(e);
386
- break;
387
- case "WordBoundary":
388
- this.visitWordBoundary(e);
389
- break;
390
- case "NonWordBoundary":
391
- this.visitNonWordBoundary(e);
392
- break;
393
- case "Lookahead":
394
- this.visitLookahead(e);
395
- break;
396
- case "NegativeLookahead":
397
- this.visitNegativeLookahead(e);
398
- break;
399
- case "Lookbehind":
400
- this.visitLookbehind(e);
401
- break;
402
- case "NegativeLookbehind":
403
- this.visitNegativeLookbehind(e);
404
- break;
405
- case "Character":
406
- this.visitCharacter(e);
407
- break;
408
- case "Set":
409
- this.visitSet(e);
410
- break;
411
- case "Group":
412
- this.visitGroup(e);
413
- break;
414
- case "GroupBackReference":
415
- this.visitGroupBackReference(e);
416
- break;
417
- case "Quantifier": this.visitQuantifier(e);
418
- }
419
- this.visitChildren(e);
420
- }
421
- visitPattern(e) {}
422
- visitFlags(e) {}
423
- visitDisjunction(e) {}
424
- visitAlternative(e) {}
425
- visitStartAnchor(e) {}
426
- visitEndAnchor(e) {}
427
- visitWordBoundary(e) {}
428
- visitNonWordBoundary(e) {}
429
- visitLookahead(e) {}
430
- visitNegativeLookahead(e) {}
431
- visitLookbehind(e) {}
432
- visitNegativeLookbehind(e) {}
433
- visitCharacter(e) {}
434
- visitSet(e) {}
435
- visitGroup(e) {}
436
- visitGroupBackReference(e) {}
437
- visitQuantifier(e) {}
438
- }, L = {}, re = new class {
439
- constructor() {
440
- this.idx = 0, this.input = "", this.groupIdx = 0;
441
- }
442
- saveState() {
443
- return {
444
- idx: this.idx,
445
- input: this.input,
446
- groupIdx: this.groupIdx
447
- };
448
- }
449
- restoreState(e) {
450
- this.idx = e.idx, this.input = e.input, this.groupIdx = e.groupIdx;
451
- }
452
- pattern(e) {
453
- this.idx = 0, this.input = e, this.groupIdx = 0, this.consumeChar("/");
454
- let t = this.disjunction();
455
- this.consumeChar("/");
456
- let n = {
457
- type: "Flags",
458
- loc: {
459
- begin: this.idx,
460
- end: e.length
461
- },
462
- global: !1,
463
- ignoreCase: !1,
464
- multiLine: !1,
465
- unicode: !1,
466
- sticky: !1
467
- };
468
- for (; this.isRegExpFlag();) switch (this.popChar()) {
469
- case "g":
470
- k(n, "global");
471
- break;
472
- case "i":
473
- k(n, "ignoreCase");
474
- break;
475
- case "m":
476
- k(n, "multiLine");
477
- break;
478
- case "u":
479
- k(n, "unicode");
480
- break;
481
- case "y": k(n, "sticky");
482
- }
483
- if (this.idx !== this.input.length) throw Error("Redundant input: " + this.input.substring(this.idx));
484
- return {
485
- type: "Pattern",
486
- flags: n,
487
- value: t,
488
- loc: this.loc(0)
489
- };
490
- }
491
- disjunction() {
492
- let e = [], t = this.idx;
493
- for (e.push(this.alternative()); this.peekChar() === "|";) this.consumeChar("|"), e.push(this.alternative());
494
- return {
495
- type: "Disjunction",
496
- value: e,
497
- loc: this.loc(t)
498
- };
499
- }
500
- alternative() {
501
- let e = [], t = this.idx;
502
- for (; this.isTerm();) e.push(this.term());
503
- return {
504
- type: "Alternative",
505
- value: e,
506
- loc: this.loc(t)
507
- };
508
- }
509
- term() {
510
- return this.isAssertion() ? this.assertion() : this.atom();
511
- }
512
- assertion() {
513
- let e = this.idx;
514
- switch (this.popChar()) {
515
- case "^": return {
516
- type: "StartAnchor",
517
- loc: this.loc(e)
518
- };
519
- case "$": return {
520
- type: "EndAnchor",
521
- loc: this.loc(e)
522
- };
523
- case "\\":
524
- switch (this.popChar()) {
525
- case "b": return {
526
- type: "WordBoundary",
527
- loc: this.loc(e)
528
- };
529
- case "B": return {
530
- type: "NonWordBoundary",
531
- loc: this.loc(e)
532
- };
533
- }
534
- throw Error("Invalid Assertion Escape");
535
- case "(":
536
- let t;
537
- switch (this.consumeChar("?"), this.popChar()) {
538
- case "=":
539
- t = "Lookahead";
540
- break;
541
- case "!":
542
- t = "NegativeLookahead";
543
- break;
544
- case "<": switch (this.popChar()) {
545
- case "=":
546
- t = "Lookbehind";
547
- break;
548
- case "!": t = "NegativeLookbehind";
549
- }
550
- }
551
- A(t);
552
- let n = this.disjunction();
553
- return this.consumeChar(")"), {
554
- type: t,
555
- value: n,
556
- loc: this.loc(e)
557
- };
558
- }
559
- return j();
560
- }
561
- quantifier(e = !1) {
562
- let t, n = this.idx;
563
- switch (this.popChar()) {
564
- case "*":
565
- t = {
566
- atLeast: 0,
567
- atMost: Infinity
568
- };
569
- break;
570
- case "+":
571
- t = {
572
- atLeast: 1,
573
- atMost: Infinity
574
- };
575
- break;
576
- case "?":
577
- t = {
578
- atLeast: 0,
579
- atMost: 1
580
- };
581
- break;
582
- case "{":
583
- let n = this.integerIncludingZero();
584
- switch (this.popChar()) {
585
- case "}":
586
- t = {
587
- atLeast: n,
588
- atMost: n
589
- };
590
- break;
591
- case ",":
592
- let e;
593
- this.isDigit() ? (e = this.integerIncludingZero(), t = {
594
- atLeast: n,
595
- atMost: e
596
- }) : t = {
597
- atLeast: n,
598
- atMost: Infinity
599
- }, this.consumeChar("}");
600
- }
601
- if (!0 === e && t === void 0) return;
602
- A(t);
603
- }
604
- if (!0 !== e || t !== void 0) return A(t) ? (this.peekChar(0) === "?" ? (this.consumeChar("?"), t.greedy = !1) : t.greedy = !0, t.type = "Quantifier", t.loc = this.loc(n), t) : void 0;
605
- }
606
- atom() {
607
- let e, t = this.idx;
608
- switch (this.peekChar()) {
609
- case ".":
610
- e = this.dotAll();
611
- break;
612
- case "\\":
613
- e = this.atomEscape();
614
- break;
615
- case "[":
616
- e = this.characterClass();
617
- break;
618
- case "(": e = this.group();
619
- }
620
- return e === void 0 && this.isPatternCharacter() && (e = this.patternCharacter()), A(e) ? (e.loc = this.loc(t), this.isQuantifier() && (e.quantifier = this.quantifier()), e) : j();
621
- }
622
- dotAll() {
623
- return this.consumeChar("."), {
624
- type: "Set",
625
- complement: !0,
626
- value: [
627
- D("\n"),
628
- D("\r"),
629
- D("\u2028"),
630
- D("\u2029")
631
- ]
632
- };
633
- }
634
- atomEscape() {
635
- switch (this.consumeChar("\\"), this.peekChar()) {
636
- case "1":
637
- case "2":
638
- case "3":
639
- case "4":
640
- case "5":
641
- case "6":
642
- case "7":
643
- case "8":
644
- case "9": return this.decimalEscapeAtom();
645
- case "d":
646
- case "D":
647
- case "s":
648
- case "S":
649
- case "w":
650
- case "W": return this.characterClassEscape();
651
- case "f":
652
- case "n":
653
- case "r":
654
- case "t":
655
- case "v": return this.controlEscapeAtom();
656
- case "c": return this.controlLetterEscapeAtom();
657
- case "0": return this.nulCharacterAtom();
658
- case "x": return this.hexEscapeSequenceAtom();
659
- case "u": return this.regExpUnicodeEscapeSequenceAtom();
660
- default: return this.identityEscapeAtom();
661
- }
662
- }
663
- decimalEscapeAtom() {
664
- return {
665
- type: "GroupBackReference",
666
- value: this.positiveInteger()
667
- };
668
- }
669
- characterClassEscape() {
670
- let e, t = !1;
671
- switch (this.popChar()) {
672
- case "d":
673
- e = N;
674
- break;
675
- case "D":
676
- e = N, t = !0;
677
- break;
678
- case "s":
679
- e = ee;
680
- break;
681
- case "S":
682
- e = ee, t = !0;
683
- break;
684
- case "w":
685
- e = P;
686
- break;
687
- case "W": e = P, t = !0;
688
- }
689
- return A(e) ? {
690
- type: "Set",
691
- value: e,
692
- complement: t
693
- } : j();
694
- }
695
- controlEscapeAtom() {
696
- let e;
697
- switch (this.popChar()) {
698
- case "f":
699
- e = D("\f");
700
- break;
701
- case "n":
702
- e = D("\n");
703
- break;
704
- case "r":
705
- e = D("\r");
706
- break;
707
- case "t":
708
- e = D(" ");
709
- break;
710
- case "v": e = D("\v");
711
- }
712
- return A(e) ? {
713
- type: "Character",
714
- value: e
715
- } : j();
716
- }
717
- controlLetterEscapeAtom() {
718
- this.consumeChar("c");
719
- let e = this.popChar();
720
- if (!1 === /[a-zA-Z]/.test(e)) throw Error("Invalid ");
721
- return {
722
- type: "Character",
723
- value: e.toUpperCase().charCodeAt(0) - 64
724
- };
725
- }
726
- nulCharacterAtom() {
727
- return this.consumeChar("0"), {
728
- type: "Character",
729
- value: D("\0")
730
- };
731
- }
732
- hexEscapeSequenceAtom() {
733
- return this.consumeChar("x"), this.parseHexDigits(2);
734
- }
735
- regExpUnicodeEscapeSequenceAtom() {
736
- return this.consumeChar("u"), this.parseHexDigits(4);
737
- }
738
- identityEscapeAtom() {
739
- return {
740
- type: "Character",
741
- value: D(this.popChar())
742
- };
743
- }
744
- classPatternCharacterAtom() {
745
- switch (this.peekChar()) {
746
- case "\n":
747
- case "\r":
748
- case "\u2028":
749
- case "\u2029":
750
- case "\\":
751
- case "]": throw Error("TBD");
752
- default: return {
753
- type: "Character",
754
- value: D(this.popChar())
755
- };
756
- }
757
- }
758
- characterClass() {
759
- let e = [], t = !1;
760
- for (this.consumeChar("["), this.peekChar(0) === "^" && (this.consumeChar("^"), t = !0); this.isClassAtom();) {
761
- let t = this.classAtom();
762
- if (t.type, M(t) && this.isRangeDash()) {
763
- this.consumeChar("-");
764
- let n = this.classAtom();
765
- if (n.type, M(n)) {
766
- if (n.value < t.value) throw Error("Range out of order in character class");
767
- e.push({
768
- from: t.value,
769
- to: n.value
770
- });
771
- } else O(t.value, e), e.push(D("-")), O(n.value, e);
772
- } else O(t.value, e);
773
- }
774
- return this.consumeChar("]"), {
775
- type: "Set",
776
- complement: t,
777
- value: e
778
- };
779
- }
780
- classAtom() {
781
- switch (this.peekChar()) {
782
- case "]":
783
- case "\n":
784
- case "\r":
785
- case "\u2028":
786
- case "\u2029": throw Error("TBD");
787
- case "\\": return this.classEscape();
788
- default: return this.classPatternCharacterAtom();
789
- }
790
- }
791
- classEscape() {
792
- switch (this.consumeChar("\\"), this.peekChar()) {
793
- case "b": return this.consumeChar("b"), {
794
- type: "Character",
795
- value: D("\b")
796
- };
797
- case "d":
798
- case "D":
799
- case "s":
800
- case "S":
801
- case "w":
802
- case "W": return this.characterClassEscape();
803
- case "f":
804
- case "n":
805
- case "r":
806
- case "t":
807
- case "v": return this.controlEscapeAtom();
808
- case "c": return this.controlLetterEscapeAtom();
809
- case "0": return this.nulCharacterAtom();
810
- case "x": return this.hexEscapeSequenceAtom();
811
- case "u": return this.regExpUnicodeEscapeSequenceAtom();
812
- default: return this.identityEscapeAtom();
813
- }
814
- }
815
- group() {
816
- let e = !0;
817
- this.consumeChar("("), this.peekChar(0) === "?" ? (this.consumeChar("?"), this.consumeChar(":"), e = !1) : this.groupIdx++;
818
- let t = this.disjunction();
819
- this.consumeChar(")");
820
- let n = {
821
- type: "Group",
822
- capturing: e,
823
- value: t
824
- };
825
- return e && (n.idx = this.groupIdx), n;
826
- }
827
- positiveInteger() {
828
- let e = this.popChar();
829
- if (!1 === ne.test(e)) throw Error("Expecting a positive integer");
830
- for (; F.test(this.peekChar(0));) e += this.popChar();
831
- return parseInt(e, 10);
832
- }
833
- integerIncludingZero() {
834
- let e = this.popChar();
835
- if (!1 === F.test(e)) throw Error("Expecting an integer");
836
- for (; F.test(this.peekChar(0));) e += this.popChar();
837
- return parseInt(e, 10);
838
- }
839
- patternCharacter() {
840
- let e = this.popChar();
841
- switch (e) {
842
- case "\n":
843
- case "\r":
844
- case "\u2028":
845
- case "\u2029":
846
- case "^":
847
- case "$":
848
- case "\\":
849
- case ".":
850
- case "*":
851
- case "+":
852
- case "?":
853
- case "(":
854
- case ")":
855
- case "[":
856
- case "|": throw Error("TBD");
857
- default: return {
858
- type: "Character",
859
- value: D(e)
860
- };
861
- }
862
- }
863
- isRegExpFlag() {
864
- switch (this.peekChar(0)) {
865
- case "g":
866
- case "i":
867
- case "m":
868
- case "u":
869
- case "y": return !0;
870
- default: return !1;
871
- }
872
- }
873
- isRangeDash() {
874
- return this.peekChar() === "-" && this.isClassAtom(1);
875
- }
876
- isDigit() {
877
- return F.test(this.peekChar(0));
878
- }
879
- isClassAtom(e = 0) {
880
- switch (this.peekChar(e)) {
881
- case "]":
882
- case "\n":
883
- case "\r":
884
- case "\u2028":
885
- case "\u2029": return !1;
886
- default: return !0;
887
- }
888
- }
889
- isTerm() {
890
- return this.isAtom() || this.isAssertion();
891
- }
892
- isAtom() {
893
- if (this.isPatternCharacter()) return !0;
894
- switch (this.peekChar(0)) {
895
- case ".":
896
- case "\\":
897
- case "[":
898
- case "(": return !0;
899
- default: return !1;
900
- }
901
- }
902
- isAssertion() {
903
- switch (this.peekChar(0)) {
904
- case "^":
905
- case "$": return !0;
906
- case "\\": switch (this.peekChar(1)) {
907
- case "b":
908
- case "B": return !0;
909
- default: return !1;
910
- }
911
- case "(": return this.peekChar(1) === "?" && (this.peekChar(2) === "=" || this.peekChar(2) === "!" || this.peekChar(2) === "<" && (this.peekChar(3) === "=" || this.peekChar(3) === "!"));
912
- default: return !1;
913
- }
914
- }
915
- isQuantifier() {
916
- let e = this.saveState();
917
- try {
918
- return this.quantifier(!0) !== void 0;
919
- } catch {
920
- return !1;
921
- } finally {
922
- this.restoreState(e);
923
- }
924
- }
925
- isPatternCharacter() {
926
- switch (this.peekChar()) {
927
- case "^":
928
- case "$":
929
- case "\\":
930
- case ".":
931
- case "*":
932
- case "+":
933
- case "?":
934
- case "(":
935
- case ")":
936
- case "[":
937
- case "|":
938
- case "/":
939
- case "\n":
940
- case "\r":
941
- case "\u2028":
942
- case "\u2029": return !1;
943
- default: return !0;
944
- }
945
- }
946
- parseHexDigits(e) {
947
- let t = "";
948
- for (let n = 0; n < e; n++) {
949
- let e = this.popChar();
950
- if (!1 === te.test(e)) throw Error("Expecting a HexDecimal digits");
951
- t += e;
952
- }
953
- return {
954
- type: "Character",
955
- value: parseInt(t, 16)
956
- };
957
- }
958
- peekChar(e = 0) {
959
- return this.input[this.idx + e];
960
- }
961
- popChar() {
962
- let e = this.peekChar(0);
963
- return this.consumeChar(void 0), e;
964
- }
965
- consumeChar(e) {
966
- if (e !== void 0 && this.input[this.idx] !== e) throw Error("Expected: '" + e + "' but found: '" + this.input[this.idx] + "' at offset: " + this.idx);
967
- if (this.idx >= this.input.length) throw Error("Unexpected end of input");
968
- this.idx++;
969
- }
970
- loc(e) {
971
- return {
972
- begin: e,
973
- end: this.idx
974
- };
975
- }
976
- }();
977
- function ie(e) {
978
- let t = e.toString();
979
- if (L.hasOwnProperty(t)) return L[t];
980
- {
981
- let e = re.pattern(t);
982
- return L[t] = e, e;
983
- }
984
- }
985
- var ae = "Complement Sets are not supported for first char optimization", oe = "Unable to use \"first char\" lexer optimizations:\n";
986
- function se(e, t = !1) {
987
- try {
988
- let t = ie(e);
989
- return ce(t.value, {}, t.flags.ignoreCase);
990
- } catch (i) {
991
- if (i.message === ae) t && r(`${oe}\tUnable to optimize: < ${e.toString()} >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);
992
- else {
993
- let r = "";
994
- t && (r = "\n This will disable the lexer's first char optimizations.\n See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."), n(`${oe}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n\tPlease open an issue at: https://github.com/chevrotain/chevrotain/issues` + r);
995
- }
996
- }
997
- return [];
998
- }
999
- function ce(e, t, n) {
1000
- switch (e.type) {
1001
- case "Disjunction":
1002
- for (let r = 0; r < e.value.length; r++) ce(e.value[r], t, n);
1003
- break;
1004
- case "Alternative":
1005
- let r = e.value;
1006
- for (let e = 0; e < r.length; e++) {
1007
- let i = r[e];
1008
- switch (i.type) {
1009
- case "EndAnchor":
1010
- case "GroupBackReference":
1011
- case "Lookahead":
1012
- case "NegativeLookahead":
1013
- case "Lookbehind":
1014
- case "NegativeLookbehind":
1015
- case "StartAnchor":
1016
- case "WordBoundary":
1017
- case "NonWordBoundary": continue;
1018
- }
1019
- let a = i;
1020
- switch (a.type) {
1021
- case "Character":
1022
- le(a.value, t, n);
1023
- break;
1024
- case "Set":
1025
- if (!0 === a.complement) throw Error(ae);
1026
- a.value.forEach((e) => {
1027
- if (typeof e == "number") le(e, t, n);
1028
- else {
1029
- let r = e;
1030
- if (!0 === n) for (let e = r.from; e <= r.to; e++) le(e, t, n);
1031
- else {
1032
- for (let e = r.from; e <= r.to && e < 256; e++) le(e, t, n);
1033
- if (r.to >= 256) {
1034
- let e = r.from >= 256 ? r.from : 256, n = r.to, i = z(e), a = z(n);
1035
- for (let e = i; e <= a; e++) t[e] = e;
1036
- }
1037
- }
1038
- }
1039
- });
1040
- break;
1041
- case "Group":
1042
- ce(a.value, t, n);
1043
- break;
1044
- default: throw Error("Non Exhaustive Match");
1045
- }
1046
- let o = a.quantifier !== void 0 && a.quantifier.atLeast === 0;
1047
- if (a.type === "Group" && !1 === de(a) || a.type !== "Group" && !1 === o) break;
1048
- }
1049
- break;
1050
- default: throw Error("non exhaustive match!");
1051
- }
1052
- return Object.values(t);
1053
- }
1054
- function le(e, t, n) {
1055
- let r = z(e);
1056
- t[r] = r, !0 === n && function(e, t) {
1057
- let n = String.fromCharCode(e), r = n.toUpperCase();
1058
- if (r !== n) {
1059
- let e = z(r.charCodeAt(0));
1060
- t[e] = e;
1061
- } else {
1062
- let e = n.toLowerCase();
1063
- if (e !== n) {
1064
- let n = z(e.charCodeAt(0));
1065
- t[n] = n;
1066
- }
1067
- }
1068
- }(e, t);
1069
- }
1070
- function ue(e, t) {
1071
- return e.value.find((e) => {
1072
- if (typeof e == "number") return t.includes(e);
1073
- {
1074
- let n = e;
1075
- return t.find((e) => n.from <= e && e <= n.to) !== void 0;
1076
- }
1077
- });
1078
- }
1079
- function de(e) {
1080
- let t = e.quantifier;
1081
- return !(!t || t.atLeast !== 0) || !!e.value && (Array.isArray(e.value) ? e.value.every(de) : de(e.value));
1082
- }
1083
- var fe = class extends I {
1084
- constructor(e) {
1085
- super(), this.targetCharCodes = e, this.found = !1;
1086
- }
1087
- visitChildren(e) {
1088
- if (!0 !== this.found) {
1089
- switch (e.type) {
1090
- case "Lookahead":
1091
- this.visitLookahead(e);
1092
- return;
1093
- case "NegativeLookahead":
1094
- this.visitNegativeLookahead(e);
1095
- return;
1096
- case "Lookbehind":
1097
- this.visitLookbehind(e);
1098
- return;
1099
- case "NegativeLookbehind":
1100
- this.visitNegativeLookbehind(e);
1101
- return;
1102
- }
1103
- super.visitChildren(e);
1104
- }
1105
- }
1106
- visitCharacter(e) {
1107
- this.targetCharCodes.includes(e.value) && (this.found = !0);
1108
- }
1109
- visitSet(e) {
1110
- e.complement ? ue(e, this.targetCharCodes) === void 0 && (this.found = !0) : ue(e, this.targetCharCodes) !== void 0 && (this.found = !0);
1111
- }
1112
- };
1113
- function pe(e, t) {
1114
- if (t instanceof RegExp) {
1115
- let n = ie(t), r = new fe(e);
1116
- return r.visit(n), r.found;
1117
- }
1118
- for (let n of t) {
1119
- let t = n.charCodeAt(0);
1120
- if (e.includes(t)) return !0;
1121
- }
1122
- return !1;
1123
- }
1124
- var R = "PATTERN", me = "defaultMode";
1125
- function he(e, t) {
1126
- let r = (t = Object.assign({
1127
- safeMode: !1,
1128
- positionTracking: "full",
1129
- lineTerminatorCharacters: ["\r", "\n"],
1130
- tracer: (e, t) => t()
1131
- }, t)).tracer, i;
1132
- r("initCharCodeToOptimizedIndexMap", () => {
1133
- (function() {
1134
- if (De.length === 0) {
1135
- De = Array(65536);
1136
- for (let e = 0; e < 65536; e++) De[e] = e > 255 ? 255 + ~~(e / 255) : e;
1137
- }
1138
- })();
1139
- }), r("Reject Lexer.NA", () => {
1140
- i = e.filter((e) => e[R] !== W.NA);
1141
- });
1142
- let a, o, s, c, l, u, d, f, p, m, h, g = !1;
1143
- r("Transform Patterns", () => {
1144
- g = !1, a = i.map((e) => {
1145
- let t = e[R];
1146
- if (t instanceof RegExp) {
1147
- let e = t.source;
1148
- return e.length !== 1 || e === "^" || e === "$" || e === "." || t.ignoreCase ? e.length !== 2 || e[0] !== "\\" || [
1149
- "d",
1150
- "D",
1151
- "s",
1152
- "S",
1153
- "t",
1154
- "r",
1155
- "n",
1156
- "t",
1157
- "0",
1158
- "c",
1159
- "b",
1160
- "B",
1161
- "f",
1162
- "v",
1163
- "w",
1164
- "W"
1165
- ].includes(e[1]) ? ye(t) : e[1] : e;
1166
- }
1167
- if (typeof t == "function") return g = !0, { exec: t };
1168
- if (typeof t == "object") return g = !0, t;
1169
- if (typeof t == "string") {
1170
- if (t.length === 1) return t;
1171
- {
1172
- let e = t.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
1173
- return ye(new RegExp(e));
1174
- }
1175
- }
1176
- throw Error("non exhaustive match");
1177
- });
1178
- }), r("misc mapping", () => {
1179
- o = i.map((e) => e.tokenTypeIdx), s = i.map((e) => {
1180
- let t = e.GROUP;
1181
- if (t !== W.SKIPPED) {
1182
- if (typeof t == "string") return t;
1183
- if (t === void 0) return !1;
1184
- throw Error("non exhaustive match");
1185
- }
1186
- }), c = i.map((e) => {
1187
- let t = e.LONGER_ALT;
1188
- if (t) return Array.isArray(t) ? t.map((e) => i.indexOf(e)) : [i.indexOf(t)];
1189
- }), l = i.map((e) => e.PUSH_MODE), u = i.map((e) => Object.hasOwn(e, "POP_MODE"));
1190
- }), r("Line Terminator Handling", () => {
1191
- let e = Te(t.lineTerminatorCharacters);
1192
- d = i.map((e) => !1), t.positionTracking !== "onlyOffset" && (d = i.map((t) => Object.hasOwn(t, "LINE_BREAKS") ? !!t.LINE_BREAKS : !1 === Ce(t, e) && pe(e, t.PATTERN)));
1193
- }), r("Misc Mapping #2", () => {
1194
- f = i.map(be), p = a.map(xe), m = i.reduce((e, t) => {
1195
- let n = t.GROUP;
1196
- return typeof n == "string" && n !== W.SKIPPED && (e[n] = []), e;
1197
- }, {}), h = a.map((e, t) => ({
1198
- pattern: a[t],
1199
- longerAlt: c[t],
1200
- canLineTerminator: d[t],
1201
- isCustom: f[t],
1202
- short: p[t],
1203
- group: s[t],
1204
- push: l[t],
1205
- pop: u[t],
1206
- tokenTypeIdx: o[t],
1207
- tokenType: i[t]
1208
- }));
1209
- });
1210
- let _ = !0, v = [];
1211
- return t.safeMode || r("First Char Optimization", () => {
1212
- v = i.reduce((e, r, i) => {
1213
- if (typeof r.PATTERN == "string") Ee(e, z(r.PATTERN.charCodeAt(0)), h[i]);
1214
- else if (Array.isArray(r.START_CHARS_HINT)) {
1215
- let t;
1216
- r.START_CHARS_HINT.forEach((n) => {
1217
- let r = z(typeof n == "string" ? n.charCodeAt(0) : n);
1218
- t !== r && (t = r, Ee(e, r, h[i]));
1219
- });
1220
- } else if (r.PATTERN instanceof RegExp) if (r.PATTERN.unicode) _ = !1, t.ensureOptimizations && n(`${oe}\tUnable to analyze < ${r.PATTERN.toString()} > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);
1221
- else {
1222
- let n = se(r.PATTERN, t.ensureOptimizations);
1223
- n.length === 0 && (_ = !1), n.forEach((t) => {
1224
- Ee(e, t, h[i]);
1225
- });
1226
- }
1227
- else t.ensureOptimizations && n(`${oe}\tTokenType: <${r.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`), _ = !1;
1228
- return e;
1229
- }, []);
1230
- }), {
1231
- emptyGroups: m,
1232
- patternIdxToConfig: h,
1233
- charCodeToPatternIdxToConfig: v,
1234
- hasCustom: g,
1235
- canBeOptimized: _
1236
- };
1237
- }
1238
- function ge(e, t) {
1239
- let n = [], r = function(e) {
1240
- let t = e.filter((e) => !Object.hasOwn(e, R));
1241
- return {
1242
- errors: t.map((e) => ({
1243
- message: "Token Type: ->" + e.name + "<- missing static 'PATTERN' property",
1244
- type: H.MISSING_PATTERN,
1245
- tokenTypes: [e]
1246
- })),
1247
- valid: e.filter((e) => !t.includes(e))
1248
- };
1249
- }(e);
1250
- n = n.concat(r.errors);
1251
- let i = function(e) {
1252
- let t = e.filter((e) => {
1253
- let t = e[R];
1254
- return !(t instanceof RegExp || typeof t == "function" || Object.hasOwn(t, "exec") || typeof t == "string");
1255
- });
1256
- return {
1257
- errors: t.map((e) => ({
1258
- message: "Token Type: ->" + e.name + "<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",
1259
- type: H.INVALID_PATTERN,
1260
- tokenTypes: [e]
1261
- })),
1262
- valid: e.filter((e) => !t.includes(e))
1263
- };
1264
- }(r.valid), a = i.valid;
1265
- return n = n.concat(i.errors), n = n.concat(function(e) {
1266
- let t = [], n = e.filter((e) => e[R] instanceof RegExp);
1267
- return t = t.concat(function(e) {
1268
- class t extends I {
1269
- constructor() {
1270
- super(...arguments), this.found = !1;
1271
- }
1272
- visitEndAnchor(e) {
1273
- this.found = !0;
1274
- }
1275
- }
1276
- return e.filter((e) => {
1277
- let n = e.PATTERN;
1278
- try {
1279
- let e = ie(n), r = new t();
1280
- return r.visit(e), r.found;
1281
- } catch {
1282
- return _e.test(n.source);
1283
- }
1284
- }).map((e) => ({
1285
- message: "Unexpected RegExp Anchor Error:\n Token Type: ->" + e.name + "<- static 'PATTERN' cannot contain end of input anchor '$'\n See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.",
1286
- type: H.EOI_ANCHOR_FOUND,
1287
- tokenTypes: [e]
1288
- }));
1289
- }(n)), t = t.concat(function(e) {
1290
- class t extends I {
1291
- constructor() {
1292
- super(...arguments), this.found = !1;
1293
- }
1294
- visitStartAnchor(e) {
1295
- this.found = !0;
1296
- }
1297
- }
1298
- return e.filter((e) => {
1299
- let n = e.PATTERN;
1300
- try {
1301
- let e = ie(n), r = new t();
1302
- return r.visit(e), r.found;
1303
- } catch {
1304
- return ve.test(n.source);
1305
- }
1306
- }).map((e) => ({
1307
- message: "Unexpected RegExp Anchor Error:\n Token Type: ->" + e.name + "<- static 'PATTERN' cannot contain start of input anchor '^'\n See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.",
1308
- type: H.SOI_ANCHOR_FOUND,
1309
- tokenTypes: [e]
1310
- }));
1311
- }(n)), t = t.concat(function(e) {
1312
- return e.filter((e) => {
1313
- let t = e[R];
1314
- return t instanceof RegExp && (t.multiline || t.global);
1315
- }).map((e) => ({
1316
- message: "Token Type: ->" + e.name + "<- static 'PATTERN' may NOT contain global('g') or multiline('m')",
1317
- type: H.UNSUPPORTED_FLAGS_FOUND,
1318
- tokenTypes: [e]
1319
- }));
1320
- }(n)), t = t.concat(function(e) {
1321
- let t = [], n = e.map((n) => e.reduce((e, r) => (n.PATTERN.source !== r.PATTERN.source || t.includes(r) || r.PATTERN === W.NA || (t.push(r), e.push(r)), e), []));
1322
- return n = n.filter(Boolean), n.filter((e) => e.length > 1).map((e) => {
1323
- let t = e.map((e) => e.name);
1324
- return {
1325
- message: `The same RegExp pattern ->${e[0].PATTERN}<-has been used in all of the following Token Types: ${t.join(", ")} <-`,
1326
- type: H.DUPLICATE_PATTERNS_FOUND,
1327
- tokenTypes: e
1328
- };
1329
- });
1330
- }(n)), t = t.concat(function(e) {
1331
- return e.filter((e) => e.PATTERN.test("")).map((e) => ({
1332
- message: "Token Type: ->" + e.name + "<- static 'PATTERN' must not match an empty string",
1333
- type: H.EMPTY_MATCH_PATTERN,
1334
- tokenTypes: [e]
1335
- }));
1336
- }(n)), t;
1337
- }(a)), n = n.concat(function(e) {
1338
- return e.filter((e) => {
1339
- if (!Object.hasOwn(e, "GROUP")) return !1;
1340
- let t = e.GROUP;
1341
- return t !== W.SKIPPED && t !== W.NA && typeof t != "string";
1342
- }).map((e) => ({
1343
- message: "Token Type: ->" + e.name + "<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",
1344
- type: H.INVALID_GROUP_TYPE_FOUND,
1345
- tokenTypes: [e]
1346
- }));
1347
- }(a)), n = n.concat(function(e, t) {
1348
- return e.filter((e) => e.PUSH_MODE !== void 0 && !t.includes(e.PUSH_MODE)).map((e) => ({
1349
- message: `Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,
1350
- type: H.PUSH_MODE_DOES_NOT_EXIST,
1351
- tokenTypes: [e]
1352
- }));
1353
- }(a, t)), n = n.concat(function(e) {
1354
- let t = [], n = e.reduce((e, t, n) => {
1355
- let r = t.PATTERN;
1356
- return r === W.NA || (typeof r == "string" ? e.push({
1357
- str: r,
1358
- idx: n,
1359
- tokenType: t
1360
- }) : r instanceof RegExp && (i = r, [
1361
- ".",
1362
- "\\",
1363
- "[",
1364
- "]",
1365
- "|",
1366
- "^",
1367
- "$",
1368
- "(",
1369
- ")",
1370
- "?",
1371
- "*",
1372
- "+",
1373
- "{"
1374
- ].find((e) => i.source.indexOf(e) !== -1) === void 0) && e.push({
1375
- str: r.source,
1376
- idx: n,
1377
- tokenType: t
1378
- })), e;
1379
- var i;
1380
- }, []);
1381
- return e.forEach((e, r) => {
1382
- n.forEach(({ str: n, idx: i, tokenType: a }) => {
1383
- if (r < i && function(e, t) {
1384
- if (t instanceof RegExp) {
1385
- if (/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(t.source)) return !1;
1386
- let n = t.exec(e);
1387
- return n !== null && n.index === 0;
1388
- }
1389
- if (typeof t == "function") return t(e, 0, [], {});
1390
- if (Object.hasOwn(t, "exec")) return t.exec(e, 0, [], {});
1391
- if (typeof t == "string") return t === e;
1392
- throw Error("non exhaustive match");
1393
- }(n, e.PATTERN)) {
1394
- let n = `Token: ->${a.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;
1395
- t.push({
1396
- message: n,
1397
- type: H.UNREACHABLE_PATTERN,
1398
- tokenTypes: [e, a]
1399
- });
1400
- }
1401
- });
1402
- }), t;
1403
- }(a)), n;
1404
- }
1405
- var _e = /[^\\][$]/, ve = /[^\\[][\^]|^\^/;
1406
- function ye(e) {
1407
- let t = e.ignoreCase ? "iy" : "y";
1408
- return RegExp(`${e.source}`, t);
1409
- }
1410
- function be(e) {
1411
- let t = e.PATTERN;
1412
- if (t instanceof RegExp) return !1;
1413
- if (typeof t == "function" || Object.hasOwn(t, "exec")) return !0;
1414
- if (typeof t == "string") return !1;
1415
- throw Error("non exhaustive match");
1416
- }
1417
- function xe(e) {
1418
- return typeof e == "string" && e.length === 1 && e.charCodeAt(0);
1419
- }
1420
- var Se = {
1421
- test: function(e) {
1422
- let t = e.length;
1423
- for (let n = this.lastIndex; n < t; n++) {
1424
- let t = e.charCodeAt(n);
1425
- if (t === 10) return this.lastIndex = n + 1, !0;
1426
- if (t === 13) return e.charCodeAt(n + 1) === 10 ? this.lastIndex = n + 2 : this.lastIndex = n + 1, !0;
1427
- }
1428
- return !1;
1429
- },
1430
- lastIndex: 0
1431
- };
1432
- function Ce(e, t) {
1433
- if (Object.hasOwn(e, "LINE_BREAKS")) return !1;
1434
- if (e.PATTERN instanceof RegExp) {
1435
- try {
1436
- pe(t, e.PATTERN);
1437
- } catch (e) {
1438
- return {
1439
- issue: H.IDENTIFY_TERMINATOR,
1440
- errMsg: e.message
1441
- };
1442
- }
1443
- return !1;
1444
- }
1445
- if (typeof e.PATTERN == "string") return !1;
1446
- if (be(e)) return { issue: H.CUSTOM_LINE_BREAK };
1447
- throw Error("non exhaustive match");
1448
- }
1449
- function we(e, t) {
1450
- if (t.issue === H.IDENTIFY_TERMINATOR) return `Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;
1451
- if (t.issue === H.CUSTOM_LINE_BREAK) return `Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <${e.name}> Token Type\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;
1452
- throw Error("non exhaustive match");
1453
- }
1454
- function Te(e) {
1455
- return e.map((e) => typeof e == "string" ? e.charCodeAt(0) : e);
1456
- }
1457
- function Ee(e, t, n) {
1458
- e[t] === void 0 ? e[t] = [n] : e[t].push(n);
1459
- }
1460
- var De = [];
1461
- function z(e) {
1462
- return e < 256 ? e : De[e];
1463
- }
1464
- function B(e, t) {
1465
- let n = e.tokenTypeIdx;
1466
- return n === t.tokenTypeIdx || !0 === t.isParent && !0 === t.categoryMatchesMap[n];
1467
- }
1468
- function Oe(e, t) {
1469
- return e.tokenTypeIdx === t.tokenTypeIdx;
1470
- }
1471
- var ke = 1, Ae = {};
1472
- function V(e) {
1473
- let t = function(e) {
1474
- let t = [...e], n = e, r = !0;
1475
- for (; r;) {
1476
- n = n.map((e) => e.CATEGORIES).flat().filter(Boolean);
1477
- let e = n.filter((e) => !t.includes(e));
1478
- t = t.concat(e), e.length === 0 ? r = !1 : n = e;
1479
- }
1480
- return t;
1481
- }(e);
1482
- (function(e) {
1483
- e.forEach((e) => {
1484
- var t;
1485
- Me(e) || (Ae[ke] = e, e.tokenTypeIdx = ke++), Ne(e) && !Array.isArray(e.CATEGORIES) && (e.CATEGORIES = [e.CATEGORIES]), Ne(e) || (e.CATEGORIES = []), t = e, Object.hasOwn(t ?? {}, "categoryMatches") || (e.categoryMatches = []), function(e) {
1486
- return Object.hasOwn(e ?? {}, "categoryMatchesMap");
1487
- }(e) || (e.categoryMatchesMap = {});
1488
- });
1489
- })(t), function(e) {
1490
- e.forEach((e) => {
1491
- je([], e);
1492
- });
1493
- }(t), function(e) {
1494
- e.forEach((e) => {
1495
- e.categoryMatches = [], Object.keys(e.categoryMatchesMap).forEach((t) => {
1496
- e.categoryMatches.push(Ae[t].tokenTypeIdx);
1497
- });
1498
- });
1499
- }(t), t.forEach((e) => {
1500
- e.isParent = e.categoryMatches.length > 0;
1501
- });
1502
- }
1503
- function je(e, t) {
1504
- e.forEach((e) => {
1505
- t.categoryMatchesMap[e.tokenTypeIdx] = !0;
1506
- }), t.CATEGORIES.forEach((n) => {
1507
- let r = e.concat(t);
1508
- r.includes(n) || je(r, n);
1509
- });
1510
- }
1511
- function Me(e) {
1512
- return Object.hasOwn(e ?? {}, "tokenTypeIdx");
1513
- }
1514
- function Ne(e) {
1515
- return Object.hasOwn(e ?? {}, "CATEGORIES");
1516
- }
1517
- function Pe(e) {
1518
- return Object.hasOwn(e ?? {}, "tokenTypeIdx");
1519
- }
1520
- var H, Fe = {
1521
- buildUnableToPopLexerModeMessage: (e) => `Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`,
1522
- buildUnexpectedCharactersMessage: (e, t, n, r, i, a) => `unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`
1523
- };
1524
- (function(e) {
1525
- e[e.MISSING_PATTERN = 0] = "MISSING_PATTERN", e[e.INVALID_PATTERN = 1] = "INVALID_PATTERN", e[e.EOI_ANCHOR_FOUND = 2] = "EOI_ANCHOR_FOUND", e[e.UNSUPPORTED_FLAGS_FOUND = 3] = "UNSUPPORTED_FLAGS_FOUND", e[e.DUPLICATE_PATTERNS_FOUND = 4] = "DUPLICATE_PATTERNS_FOUND", e[e.INVALID_GROUP_TYPE_FOUND = 5] = "INVALID_GROUP_TYPE_FOUND", e[e.PUSH_MODE_DOES_NOT_EXIST = 6] = "PUSH_MODE_DOES_NOT_EXIST", e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE = 7] = "MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE", e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY = 8] = "MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY", e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST = 9] = "MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST", e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED = 10] = "LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED", e[e.SOI_ANCHOR_FOUND = 11] = "SOI_ANCHOR_FOUND", e[e.EMPTY_MATCH_PATTERN = 12] = "EMPTY_MATCH_PATTERN", e[e.NO_LINE_BREAKS_FLAGS = 13] = "NO_LINE_BREAKS_FLAGS", e[e.UNREACHABLE_PATTERN = 14] = "UNREACHABLE_PATTERN", e[e.IDENTIFY_TERMINATOR = 15] = "IDENTIFY_TERMINATOR", e[e.CUSTOM_LINE_BREAK = 16] = "CUSTOM_LINE_BREAK", e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE = 17] = "MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE";
1526
- })(H ||= {});
1527
- var U = {
1528
- deferDefinitionErrorsHandling: !1,
1529
- positionTracking: "full",
1530
- lineTerminatorsPattern: /\n|\r\n?/g,
1531
- lineTerminatorCharacters: ["\n", "\r"],
1532
- ensureOptimizations: !1,
1533
- safeMode: !1,
1534
- errorMessageProvider: Fe,
1535
- traceInitPerf: !1,
1536
- skipValidations: !1,
1537
- recoveryEnabled: !0
1538
- };
1539
- Object.freeze(U);
1540
- var W = class {
1541
- constructor(e, t = U) {
1542
- if (this.lexerDefinition = e, this.lexerDefinitionErrors = [], this.lexerDefinitionWarning = [], this.patternIdxToConfig = {}, this.charCodeToPatternIdxToConfig = {}, this.modes = [], this.emptyGroups = {}, this.cachedGroupKeys = [], this.trackStartLines = !0, this.trackEndLines = !0, this.hasCustom = !1, this.canModeBeOptimized = {}, this.TRACE_INIT = (e, t) => {
1543
- if (!0 === this.traceInitPerf) {
1544
- this.traceInitIndent++;
1545
- let n = Array(this.traceInitIndent + 1).join(" ");
1546
- this.traceInitIndent < this.traceInitMaxIdent && console.log(`${n}--\x3e <${e}>`);
1547
- let { time: r, value: a } = i(t), o = r > 10 ? console.warn : console.log;
1548
- return this.traceInitIndent < this.traceInitMaxIdent && o(`${n}<-- <${e}> time: ${r}ms`), this.traceInitIndent--, a;
1549
- }
1550
- return t();
1551
- }, typeof t == "boolean") throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");
1552
- this.config = Object.assign({}, U, t);
1553
- let n = this.config.traceInitPerf;
1554
- !0 === n ? (this.traceInitMaxIdent = Infinity, this.traceInitPerf = !0) : typeof n == "number" && (this.traceInitMaxIdent = n, this.traceInitPerf = !0), this.traceInitIndent = -1, this.TRACE_INIT("Lexer Constructor", () => {
1555
- let n, i = !0;
1556
- this.TRACE_INIT("Lexer Config handling", () => {
1557
- if (this.config.lineTerminatorsPattern === U.lineTerminatorsPattern) this.config.lineTerminatorsPattern = Se;
1558
- else if (this.config.lineTerminatorCharacters === U.lineTerminatorCharacters) throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");
1559
- if (t.safeMode && t.ensureOptimizations) throw Error("\"safeMode\" and \"ensureOptimizations\" flags are mutually exclusive.");
1560
- this.trackStartLines = /full|onlyStart/i.test(this.config.positionTracking), this.trackEndLines = /full/i.test(this.config.positionTracking), Array.isArray(e) ? n = {
1561
- modes: { defaultMode: [...e] },
1562
- defaultMode: me
1563
- } : (i = !1, n = Object.assign({}, e));
1564
- }), !1 === this.config.skipValidations && (this.TRACE_INIT("performRuntimeChecks", () => {
1565
- this.lexerDefinitionErrors = this.lexerDefinitionErrors.concat(function(e) {
1566
- let t = [];
1567
- return Object.hasOwn(e, "defaultMode") || t.push({
1568
- message: "A MultiMode Lexer cannot be initialized without a <defaultMode> property in its definition\n",
1569
- type: H.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE
1570
- }), Object.hasOwn(e, "modes") || t.push({
1571
- message: "A MultiMode Lexer cannot be initialized without a <modes> property in its definition\n",
1572
- type: H.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY
1573
- }), Object.hasOwn(e, "modes") && Object.hasOwn(e, "defaultMode") && !Object.hasOwn(e.modes, e.defaultMode) && t.push({
1574
- message: `A MultiMode Lexer cannot be initialized with a ${me}: <${e.defaultMode}>which does not exist\n`,
1575
- type: H.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST
1576
- }), Object.hasOwn(e, "modes") && Object.keys(e.modes).forEach((n) => {
1577
- let r = e.modes[n];
1578
- r.forEach((e, i) => {
1579
- e === void 0 ? t.push({
1580
- message: `A Lexer cannot be initialized using an undefined Token Type. Mode:<${n}> at index: <${i}>\n`,
1581
- type: H.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED
1582
- }) : Object.hasOwn(e, "LONGER_ALT") && (Array.isArray(e.LONGER_ALT) ? e.LONGER_ALT : [e.LONGER_ALT]).forEach((i) => {
1583
- i === void 0 || r.includes(i) || t.push({
1584
- message: `A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${e.name}> outside of mode <${n}>\n`,
1585
- type: H.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE
1586
- });
1587
- });
1588
- });
1589
- }), t;
1590
- }(n, this.trackStartLines, this.config.lineTerminatorCharacters));
1591
- }), this.TRACE_INIT("performWarningRuntimeChecks", () => {
1592
- this.lexerDefinitionWarning = this.lexerDefinitionWarning.concat(function(e, t, n) {
1593
- let r = [], i = !1, a = Object.values(e.modes || {}).flat().filter(Boolean).filter((e) => e[R] !== W.NA), o = Te(n);
1594
- return t && a.forEach((e) => {
1595
- let t = Ce(e, o);
1596
- if (!1 !== t) {
1597
- let n = {
1598
- message: we(e, t),
1599
- type: t.issue,
1600
- tokenType: e
1601
- };
1602
- r.push(n);
1603
- } else Object.hasOwn(e, "LINE_BREAKS") ? !0 === e.LINE_BREAKS && (i = !0) : pe(o, e.PATTERN) && (i = !0);
1604
- }), t && !i && r.push({
1605
- message: "Warning: No LINE_BREAKS Found.\n This Lexer has been defined to track line and column information,\n But none of the Token Types can be identified as matching a line terminator.\n See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n for details.",
1606
- type: H.NO_LINE_BREAKS_FLAGS
1607
- }), r;
1608
- }(n, this.trackStartLines, this.config.lineTerminatorCharacters));
1609
- })), n.modes = n.modes ? n.modes : {}, Object.entries(n.modes).forEach(([e, t]) => {
1610
- n.modes[e] = t.filter((e) => e !== void 0);
1611
- });
1612
- let o = Object.keys(n.modes);
1613
- if (Object.entries(n.modes).forEach(([e, n]) => {
1614
- this.TRACE_INIT(`Mode: <${e}> processing`, () => {
1615
- if (this.modes.push(e), !1 === this.config.skipValidations && this.TRACE_INIT("validatePatterns", () => {
1616
- this.lexerDefinitionErrors = this.lexerDefinitionErrors.concat(ge(n, o));
1617
- }), this.lexerDefinitionErrors.length === 0) {
1618
- let r;
1619
- V(n), this.TRACE_INIT("analyzeTokenTypes", () => {
1620
- r = he(n, {
1621
- lineTerminatorCharacters: this.config.lineTerminatorCharacters,
1622
- positionTracking: t.positionTracking,
1623
- ensureOptimizations: t.ensureOptimizations,
1624
- safeMode: t.safeMode,
1625
- tracer: this.TRACE_INIT
1626
- });
1627
- }), this.patternIdxToConfig[e] = r.patternIdxToConfig, this.charCodeToPatternIdxToConfig[e] = r.charCodeToPatternIdxToConfig, this.emptyGroups = Object.assign({}, this.emptyGroups, r.emptyGroups), this.hasCustom = r.hasCustom || this.hasCustom, this.canModeBeOptimized[e] = r.canBeOptimized;
1628
- }
1629
- });
1630
- }), this.defaultMode = n.defaultMode, this.cachedGroupKeys = Object.keys(this.emptyGroups), this.lexerDefinitionErrors.length > 0 && !this.config.deferDefinitionErrorsHandling) {
1631
- let e = this.lexerDefinitionErrors.map((e) => e.message).join("-----------------------\n");
1632
- throw Error("Errors detected in definition of Lexer:\n" + e);
1633
- }
1634
- this.lexerDefinitionWarning.forEach((e) => {
1635
- r(e.message);
1636
- }), this.TRACE_INIT("Choosing sub-methods implementations", () => {
1637
- if (i && (this.handleModes = () => {}), !1 === this.trackStartLines && (this.computeNewColumn = (e) => e), !1 === this.trackEndLines && (this.updateTokenEndLineColumnLocation = () => {}), /full/i.test(this.config.positionTracking)) this.createTokenInstance = this.createFullToken;
1638
- else if (/onlyStart/i.test(this.config.positionTracking)) this.createTokenInstance = this.createStartOnlyToken;
1639
- else {
1640
- if (!/onlyOffset/i.test(this.config.positionTracking)) throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);
1641
- this.createTokenInstance = this.createOffsetOnlyToken;
1642
- }
1643
- this.hasCustom ? (this.addToken = this.addTokenUsingPush, this.handlePayload = this.handlePayloadWithCustom) : (this.addToken = this.addTokenUsingMemberAccess, this.handlePayload = this.handlePayloadNoCustom);
1644
- }), this.TRACE_INIT("Failed Optimization Warnings", () => {
1645
- let e = Object.entries(this.canModeBeOptimized).reduce((e, [t, n]) => (!1 === n && e.push(t), e), []);
1646
- if (t.ensureOptimizations && e.length > 0) throw Error(`Lexer Modes: < ${e.join(", ")} > cannot be optimized.\n\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n\t Or inspect the console log for details on how to resolve these issues.`);
1647
- }), this.TRACE_INIT("clearRegExpParserCache", () => {
1648
- L = {};
1649
- }), this.TRACE_INIT("toFastProperties", () => {
1650
- a(this);
1651
- });
1652
- });
1653
- }
1654
- tokenize(e, t = this.defaultMode) {
1655
- if (this.lexerDefinitionErrors.length > 0) {
1656
- let e = this.lexerDefinitionErrors.map((e) => e.message).join("-----------------------\n");
1657
- throw Error("Unable to Tokenize because Errors detected in definition of Lexer:\n" + e);
1658
- }
1659
- return this.tokenizeInternal(e, t);
1660
- }
1661
- tokenizeInternal(e, t) {
1662
- let n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _ = e, v = _.length, y = 0, b = 0, x = this.hasCustom ? 0 : Math.floor(e.length / 10), S = Array(x), C = [], w = this.trackStartLines ? 1 : void 0, T = this.trackStartLines ? 1 : void 0, E = {};
1663
- for (let e = 0; e < this.cachedGroupKeys.length; e++) E[this.cachedGroupKeys[e]] = [];
1664
- let D = this.trackStartLines, O = this.config.lineTerminatorsPattern, k = 0, A = [], j = [], M = [], N = [];
1665
- Object.freeze(N);
1666
- let P = !1, ee = (e) => {
1667
- if (M.length === 1 && e.tokenType.PUSH_MODE === void 0) {
1668
- let t = this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);
1669
- C.push({
1670
- offset: e.startOffset,
1671
- line: e.startLine,
1672
- column: e.startColumn,
1673
- length: e.image.length,
1674
- message: t
1675
- });
1676
- } else {
1677
- M.pop();
1678
- let e = M.at(-1);
1679
- A = this.patternIdxToConfig[e], j = this.charCodeToPatternIdxToConfig[e], k = A.length;
1680
- let t = this.canModeBeOptimized[e] && !1 === this.config.safeMode;
1681
- P = !(!j || !t);
1682
- }
1683
- };
1684
- function te(e) {
1685
- M.push(e), j = this.charCodeToPatternIdxToConfig[e], A = this.patternIdxToConfig[e], k = A.length;
1686
- let t = this.canModeBeOptimized[e] && !1 === this.config.safeMode;
1687
- P = !(!j || !t);
1688
- }
1689
- let F;
1690
- te.call(this, t);
1691
- let ne = this.config.recoveryEnabled;
1692
- for (; y < v;) {
1693
- s = null, u = -1;
1694
- let t = _.charCodeAt(y), x;
1695
- if (P) {
1696
- let e = z(t), n = j[e];
1697
- x = n === void 0 ? N : n;
1698
- } else x = A;
1699
- let I = x.length;
1700
- for (n = 0; n < I; n++) {
1701
- F = x[n];
1702
- let r = F.pattern;
1703
- c = null;
1704
- let d = F.short;
1705
- if (!1 === d ? !0 === F.isCustom ? (g = r.exec(_, y, S, E), g === null ? s = null : (s = g[0], u = s.length, g.payload !== void 0 && (c = g.payload))) : (r.lastIndex = y, u = this.matchLength(r, e, y)) : t === d && (u = 1, s = r), u !== -1) {
1706
- if (o = F.longerAlt, o !== void 0) {
1707
- s = e.substring(y, y + u);
1708
- let t = o.length;
1709
- for (i = 0; i < t; i++) {
1710
- let t = A[o[i]], n = t.pattern;
1711
- if (l = null, !0 === t.isCustom ? (g = n.exec(_, y, S, E), g === null ? a = null : (a = g[0], g.payload !== void 0 && (l = g.payload))) : (n.lastIndex = y, a = this.match(n, e, y)), a && a.length > s.length) {
1712
- s = a, u = a.length, c = l, F = t;
1713
- break;
1714
- }
1715
- }
1716
- }
1717
- break;
1718
- }
1719
- }
1720
- if (u !== -1) {
1721
- if (d = F.group, d !== void 0 && (s = s === null ? e.substring(y, y + u) : s, f = F.tokenTypeIdx, p = this.createTokenInstance(s, y, f, F.tokenType, w, T, u), this.handlePayload(p, c), !1 === d ? b = this.addToken(S, b, p) : E[d].push(p)), !0 === D && !0 === F.canLineTerminator) {
1722
- let t, n, r = 0;
1723
- O.lastIndex = 0;
1724
- do
1725
- s = s === null ? e.substring(y, y + u) : s, t = O.test(s), !0 === t && (n = O.lastIndex - 1, r++);
1726
- while (!0 === t);
1727
- r === 0 ? T = this.computeNewColumn(T, u) : (w += r, T = u - n, this.updateTokenEndLineColumnLocation(p, d, n, r, w, T, u));
1728
- } else T = this.computeNewColumn(T, u);
1729
- y += u, this.handleModes(F, ee, te, p);
1730
- } else {
1731
- let t = y, n = w, i = T, a = !1 === ne;
1732
- for (; !1 === a && y < v;) for (y++, r = 0; r < k; r++) {
1733
- let t = A[r], n = t.pattern, i = t.short;
1734
- if (!1 === i ? !0 === t.isCustom ? a = n.exec(_, y, S, E) !== null : (n.lastIndex = y, a = n.exec(e) !== null) : _.charCodeAt(y) === i && (a = !0), !0 === a) break;
1735
- }
1736
- if (m = y - t, T = this.computeNewColumn(T, m), h = this.config.errorMessageProvider.buildUnexpectedCharactersMessage(_, t, m, n, i, M.at(-1)), C.push({
1737
- offset: t,
1738
- line: n,
1739
- column: i,
1740
- length: m,
1741
- message: h
1742
- }), !1 === ne) break;
1743
- }
1744
- }
1745
- return this.hasCustom || (S.length = b), {
1746
- tokens: S,
1747
- groups: E,
1748
- errors: C
1749
- };
1750
- }
1751
- handleModes(e, t, n, r) {
1752
- if (!0 === e.pop) {
1753
- let i = e.push;
1754
- t(r), i !== void 0 && n.call(this, i);
1755
- } else e.push !== void 0 && n.call(this, e.push);
1756
- }
1757
- updateTokenEndLineColumnLocation(e, t, n, r, i, a, o) {
1758
- let s, c;
1759
- t !== void 0 && (s = n === o - 1, c = s ? -1 : 0, r === 1 && !0 === s || (e.endLine = i + c, e.endColumn = a - 1 - c));
1760
- }
1761
- computeNewColumn(e, t) {
1762
- return e + t;
1763
- }
1764
- createOffsetOnlyToken(e, t, n, r) {
1765
- return {
1766
- image: e,
1767
- startOffset: t,
1768
- tokenTypeIdx: n,
1769
- tokenType: r
1770
- };
1771
- }
1772
- createStartOnlyToken(e, t, n, r, i, a) {
1773
- return {
1774
- image: e,
1775
- startOffset: t,
1776
- startLine: i,
1777
- startColumn: a,
1778
- tokenTypeIdx: n,
1779
- tokenType: r
1780
- };
1781
- }
1782
- createFullToken(e, t, n, r, i, a, o) {
1783
- return {
1784
- image: e,
1785
- startOffset: t,
1786
- endOffset: t + o - 1,
1787
- startLine: i,
1788
- endLine: i,
1789
- startColumn: a,
1790
- endColumn: a + o - 1,
1791
- tokenTypeIdx: n,
1792
- tokenType: r
1793
- };
1794
- }
1795
- addTokenUsingPush(e, t, n) {
1796
- return e.push(n), t;
1797
- }
1798
- addTokenUsingMemberAccess(e, t, n) {
1799
- return e[t] = n, ++t;
1800
- }
1801
- handlePayloadNoCustom(e, t) {}
1802
- handlePayloadWithCustom(e, t) {
1803
- t !== null && (e.payload = t);
1804
- }
1805
- match(e, t, n) {
1806
- return !0 === e.test(t) ? t.substring(n, e.lastIndex) : null;
1807
- }
1808
- matchLength(e, t, n) {
1809
- return !0 === e.test(t) ? e.lastIndex - n : -1;
1810
- }
1811
- };
1812
- function G(e) {
1813
- return Ie(e) ? e.LABEL : e.name;
1814
- }
1815
- function Ie(e) {
1816
- return typeof e.LABEL == "string" && e.LABEL !== "";
1817
- }
1818
- W.SKIPPED = "This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.", W.NA = /NOT_APPLICABLE/;
1819
- var Le = "parent", Re = "categories", ze = "label", Be = "group", Ve = "push_mode", He = "pop_mode", Ue = "longer_alt", We = "line_breaks", Ge = "start_chars_hint";
1820
- function K(e) {
1821
- return function(e) {
1822
- let t = e.pattern, n = {};
1823
- if (n.name = e.name, t !== void 0 && (n.PATTERN = t), Object.hasOwn(e, Le)) throw "The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";
1824
- return Object.hasOwn(e, Re) && (n.CATEGORIES = e[Re]), V([n]), Object.hasOwn(e, ze) && (n.LABEL = e[ze]), Object.hasOwn(e, Be) && (n.GROUP = e[Be]), Object.hasOwn(e, He) && (n.POP_MODE = e[He]), Object.hasOwn(e, Ve) && (n.PUSH_MODE = e[Ve]), Object.hasOwn(e, Ue) && (n.LONGER_ALT = e[Ue]), Object.hasOwn(e, We) && (n.LINE_BREAKS = e[We]), Object.hasOwn(e, Ge) && (n.START_CHARS_HINT = e[Ge]), n;
1825
- }(e);
1826
- }
1827
- var q = K({
1828
- name: "EOF",
1829
- pattern: W.NA
1830
- });
1831
- function Ke(e, t, n, r, i, a, o, s) {
1832
- return {
1833
- image: t,
1834
- startOffset: n,
1835
- endOffset: r,
1836
- startLine: i,
1837
- endLine: a,
1838
- startColumn: o,
1839
- endColumn: s,
1840
- tokenTypeIdx: e.tokenTypeIdx,
1841
- tokenType: e
1842
- };
1843
- }
1844
- V([q]);
1845
- var qe = {
1846
- buildMismatchTokenMessage: ({ expected: e, actual: t, previous: n, ruleName: r }) => `Expecting ${Ie(e) ? `--\x3e ${G(e)} <--` : `token of type --\x3e ${e.name} <--`} but found --\x3e '${t.image}' <--`,
1847
- buildNotAllInputParsedMessage: ({ firstRedundant: e, ruleName: t }) => "Redundant input, expecting EOF but found: " + e.image,
1848
- buildNoViableAltMessage({ expectedPathsPerAlt: e, actual: t, previous: n, customUserDescription: r, ruleName: i }) {
1849
- let a = "\nbut found: '" + t[0].image + "'";
1850
- return r ? "Expecting: " + r + a : `Expecting: one of these possible Token sequences:\n${e.reduce((e, t) => e.concat(t), []).map((e) => `[${e.map((e) => G(e)).join(", ")}]`).map((e, t) => ` ${t + 1}. ${e}`).join("\n")}` + a;
1851
- },
1852
- buildEarlyExitMessage({ expectedIterationPaths: e, actual: t, customUserDescription: n, ruleName: r }) {
1853
- let i = "\nbut found: '" + t[0].image + "'";
1854
- return n ? "Expecting: " + n + i : `Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <${e.map((e) => `[${e.map((e) => G(e)).join(",")}]`).join(" ,")}>` + i;
1855
- }
1856
- };
1857
- Object.freeze(qe);
1858
- var Je = { buildRuleNotFoundError: (e, t) => "Invalid grammar, reference to a rule which is not defined: ->" + t.nonTerminalName + "<-\ninside top level rule: ->" + e.name + "<-" }, J = {
1859
- buildDuplicateFoundError(e, t) {
1860
- let n = e.name, r = t[0], i = r.idx, a = x(r), o = (c = r) instanceof g ? c.terminalType.name : c instanceof s ? c.nonTerminalName : "";
1861
- var c;
1862
- let l = `->${a}${i > 0 ? i : ""}<- ${o ? `with argument: ->${o}<-` : ""}\n appears more than once (${t.length} times) in the top level rule: ->${n}<-. \n For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES \n `;
1863
- return l = l.replace(/[ \t]+/g, " "), l = l.replace(/\s\s+/g, "\n"), l;
1864
- },
1865
- buildNamespaceConflictError: (e) => `Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`,
1866
- buildAlternationPrefixAmbiguityError(e) {
1867
- let t = e.prefixPath.map((e) => G(e)).join(", "), n = e.alternation.idx === 0 ? "" : e.alternation.idx;
1868
- return `Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`;
1869
- },
1870
- buildAlternationAmbiguityError(e) {
1871
- let t = e.alternation.idx === 0 ? "" : e.alternation.idx, n = e.prefixPath.length === 0, r = `Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${t}> inside <${e.topLevelRule.name}> Rule,\n`;
1872
- return n ? r += "These alternatives are all empty (match no tokens), making them indistinguishable.\nOnly the last alternative may be empty.\n" : r += `<${e.prefixPath.map((e) => G(e)).join(", ")}> may appears as a prefix path in all these alternatives.\n`, r += "See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.", r;
1873
- },
1874
- buildEmptyRepetitionError(e) {
1875
- let t = x(e.repetition);
1876
- return e.repetition.idx !== 0 && (t += e.repetition.idx), `The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`;
1877
- },
1878
- buildTokenNameError: (e) => "deprecated",
1879
- buildEmptyAlternationError: (e) => `Ambiguous empty alternative: <${e.emptyChoiceIdx + 1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`,
1880
- buildTooManyAlternativesError: (e) => `An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length + 1} alternatives.`,
1881
- buildLeftRecursionError(e) {
1882
- let t = e.topLevelRule.name;
1883
- return `Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${t} --\x3e ${e.leftRecursionPath.map((e) => e.name).concat([t]).join(" --> ")}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`;
1884
- },
1885
- buildInvalidRuleNameError: (e) => "deprecated",
1886
- buildDuplicateRuleNameError(e) {
1887
- let t;
1888
- return t = e.topLevelRule instanceof c ? e.topLevelRule.name : e.topLevelRule, `Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`;
1889
- }
1890
- }, Y, Ye = class extends y {
1891
- constructor(e, t) {
1892
- super(), this.nameToTopRule = e, this.errMsgProvider = t, this.errors = [];
1893
- }
1894
- resolveRefs() {
1895
- Object.values(this.nameToTopRule).forEach((e) => {
1896
- this.currTopLevel = e, e.accept(this);
1897
- });
1898
- }
1899
- visitNonTerminal(e) {
1900
- let t = this.nameToTopRule[e.nonTerminalName];
1901
- if (t) e.referencedRule = t;
1902
- else {
1903
- let t = this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel, e);
1904
- this.errors.push({
1905
- message: t,
1906
- type: Q.UNRESOLVED_SUBRULE_REF,
1907
- ruleName: this.currTopLevel.name,
1908
- unresolvedRefName: e.nonTerminalName
1909
- });
1910
- }
1911
- }
1912
- }, Xe = class extends S {
1913
- constructor(e, t) {
1914
- super(), this.topProd = e, this.path = t, this.possibleTokTypes = [], this.nextProductionName = "", this.nextProductionOccurrence = 0, this.found = !1, this.isAtEndOfPath = !1;
1915
- }
1916
- startWalking() {
1917
- if (this.found = !1, this.path.ruleStack[0] !== this.topProd.name) throw Error("The path does not start with the walker's top Rule!");
1918
- return this.ruleStack = [...this.path.ruleStack].reverse(), this.occurrenceStack = [...this.path.occurrenceStack].reverse(), this.ruleStack.pop(), this.occurrenceStack.pop(), this.updateExpectedNext(), this.walk(this.topProd), this.possibleTokTypes;
1919
- }
1920
- walk(e, t = []) {
1921
- this.found || super.walk(e, t);
1922
- }
1923
- walkProdRef(e, t, n) {
1924
- if (e.referencedRule.name === this.nextProductionName && e.idx === this.nextProductionOccurrence) {
1925
- let r = t.concat(n);
1926
- this.updateExpectedNext(), this.walk(e.referencedRule, r);
1927
- }
1928
- }
1929
- updateExpectedNext() {
1930
- this.ruleStack.length === 0 ? (this.nextProductionName = "", this.nextProductionOccurrence = 0, this.isAtEndOfPath = !0) : (this.nextProductionName = this.ruleStack.pop(), this.nextProductionOccurrence = this.occurrenceStack.pop());
1931
- }
1932
- }, Ze = class extends Xe {
1933
- constructor(e, t) {
1934
- super(e, t), this.path = t, this.nextTerminalName = "", this.nextTerminalOccurrence = 0, this.nextTerminalName = this.path.lastTok.name, this.nextTerminalOccurrence = this.path.lastTokOccurrence;
1935
- }
1936
- walkTerminal(e, t, n) {
1937
- if (this.isAtEndOfPath && e.terminalType.name === this.nextTerminalName && e.idx === this.nextTerminalOccurrence && !this.found) {
1938
- let e = new l({ definition: t.concat(n) });
1939
- this.possibleTokTypes = w(e), this.found = !0;
1940
- }
1941
- }
1942
- }, Qe = class extends S {
1943
- constructor(e, t) {
1944
- super(), this.topRule = e, this.occurrence = t, this.result = {
1945
- token: void 0,
1946
- occurrence: void 0,
1947
- isEndOfRule: void 0
1948
- };
1949
- }
1950
- startWalking() {
1951
- return this.walk(this.topRule), this.result;
1952
- }
1953
- }, $e = class extends Qe {
1954
- walkMany(e, t, n) {
1955
- if (e.idx === this.occurrence) {
1956
- let e = t.concat(n)[0];
1957
- this.result.isEndOfRule = e === void 0, e instanceof g && (this.result.token = e.terminalType, this.result.occurrence = e.idx);
1958
- } else super.walkMany(e, t, n);
1959
- }
1960
- }, et = class extends Qe {
1961
- walkManySep(e, t, n) {
1962
- if (e.idx === this.occurrence) {
1963
- let e = t.concat(n)[0];
1964
- this.result.isEndOfRule = e === void 0, e instanceof g && (this.result.token = e.terminalType, this.result.occurrence = e.idx);
1965
- } else super.walkManySep(e, t, n);
1966
- }
1967
- }, tt = class extends Qe {
1968
- walkAtLeastOne(e, t, n) {
1969
- if (e.idx === this.occurrence) {
1970
- let e = t.concat(n)[0];
1971
- this.result.isEndOfRule = e === void 0, e instanceof g && (this.result.token = e.terminalType, this.result.occurrence = e.idx);
1972
- } else super.walkAtLeastOne(e, t, n);
1973
- }
1974
- }, nt = class extends Qe {
1975
- walkAtLeastOneSep(e, t, n) {
1976
- if (e.idx === this.occurrence) {
1977
- let e = t.concat(n)[0];
1978
- this.result.isEndOfRule = e === void 0, e instanceof g && (this.result.token = e.terminalType, this.result.occurrence = e.idx);
1979
- } else super.walkAtLeastOneSep(e, t, n);
1980
- }
1981
- };
1982
- function rt(e, t, n = []) {
1983
- n = [...n];
1984
- let r = [], i = 0;
1985
- function a(a) {
1986
- let o = rt(a.concat(e.slice(i + 1)), t, n);
1987
- return r.concat(o);
1988
- }
1989
- for (; n.length < t && i < e.length;) {
1990
- let t = e[i];
1991
- if (t instanceof l || t instanceof s) return a(t.definition);
1992
- if (t instanceof u) r = a(t.definition);
1993
- else {
1994
- if (t instanceof d) return a(t.definition.concat([new p({ definition: t.definition })]));
1995
- if (t instanceof f) return a([new l({ definition: t.definition }), new p({ definition: [new g({ terminalType: t.separator })].concat(t.definition) })]);
1996
- if (t instanceof m) r = a(t.definition.concat([new p({ definition: [new g({ terminalType: t.separator })].concat(t.definition) })]));
1997
- else if (t instanceof p) r = a(t.definition.concat([new p({ definition: t.definition })]));
1998
- else {
1999
- if (t instanceof h) return t.definition.forEach((e) => {
2000
- e.definition.length !== 0 && (r = a(e.definition));
2001
- }), r;
2002
- if (!(t instanceof g)) throw Error("non exhaustive match");
2003
- n.push(t.terminalType);
2004
- }
2005
- }
2006
- i++;
2007
- }
2008
- return r.push({
2009
- partialPath: n,
2010
- suffixDef: e.slice(i)
2011
- }), r;
2012
- }
2013
- function it(e, t, n, r) {
2014
- let i = [...n];
2015
- i.push(e.name);
2016
- let a = [...r];
2017
- return a.push(1), {
2018
- idx: t,
2019
- def: e.definition,
2020
- ruleStack: i,
2021
- occurrenceStack: a
2022
- };
2023
- }
2024
- function at(e) {
2025
- if (e instanceof u || e === "Option") return Y.OPTION;
2026
- if (e instanceof p || e === "Repetition") return Y.REPETITION;
2027
- if (e instanceof d || e === "RepetitionMandatory") return Y.REPETITION_MANDATORY;
2028
- if (e instanceof f || e === "RepetitionMandatoryWithSeparator") return Y.REPETITION_MANDATORY_WITH_SEPARATOR;
2029
- if (e instanceof m || e === "RepetitionWithSeparator") return Y.REPETITION_WITH_SEPARATOR;
2030
- if (e instanceof h || e === "Alternation") return Y.ALTERNATION;
2031
- throw Error("non exhaustive match");
2032
- }
2033
- function ot(e, t, n, r) {
2034
- let i = e.length, a = e.every((e) => e.every((e) => e.length === 1));
2035
- if (t) return function(t) {
2036
- let r = t.map((e) => e.GATE);
2037
- for (let t = 0; t < i; t++) {
2038
- let i = e[t], a = i.length, o = r[t];
2039
- if (o === void 0 || !1 !== o.call(this)) e: for (let e = 0; e < a; e++) {
2040
- let r = i[e], a = r.length;
2041
- for (let e = 0; e < a; e++) if (!1 === n(this.LA_FAST(e + 1), r[e])) continue e;
2042
- return t;
2043
- }
2044
- }
2045
- };
2046
- if (a && !r) {
2047
- let t = e.map((e) => e.flat()).reduce((e, t, n) => (t.forEach((t) => {
2048
- t.tokenTypeIdx in e || (e[t.tokenTypeIdx] = n), t.categoryMatches.forEach((t) => {
2049
- Object.hasOwn(e, t) || (e[t] = n);
2050
- });
2051
- }), e), {});
2052
- return function() {
2053
- let e = this.LA_FAST(1);
2054
- return t[e.tokenTypeIdx];
2055
- };
2056
- }
2057
- return function() {
2058
- for (let t = 0; t < i; t++) {
2059
- let r = e[t], i = r.length;
2060
- e: for (let e = 0; e < i; e++) {
2061
- let i = r[e], a = i.length;
2062
- for (let e = 0; e < a; e++) if (!1 === n(this.LA_FAST(e + 1), i[e])) continue e;
2063
- return t;
2064
- }
2065
- }
2066
- };
2067
- }
2068
- function st(e, t, n) {
2069
- let r = e.every((e) => e.length === 1), i = e.length;
2070
- if (r && !n) {
2071
- let t = e.flat();
2072
- if (t.length === 1 && t[0].categoryMatches.length === 0) {
2073
- let e = t[0].tokenTypeIdx;
2074
- return function() {
2075
- return this.LA_FAST(1).tokenTypeIdx === e;
2076
- };
2077
- }
2078
- {
2079
- let e = t.reduce((e, t, n) => (e[t.tokenTypeIdx] = !0, t.categoryMatches.forEach((t) => {
2080
- e[t] = !0;
2081
- }), e), []);
2082
- return function() {
2083
- let t = this.LA_FAST(1);
2084
- return !0 === e[t.tokenTypeIdx];
2085
- };
2086
- }
2087
- }
2088
- return function() {
2089
- e: for (let n = 0; n < i; n++) {
2090
- let r = e[n], i = r.length;
2091
- for (let e = 0; e < i; e++) if (!1 === t(this.LA_FAST(e + 1), r[e])) continue e;
2092
- return !0;
2093
- }
2094
- return !1;
2095
- };
2096
- }
2097
- (function(e) {
2098
- e[e.OPTION = 0] = "OPTION", e[e.REPETITION = 1] = "REPETITION", e[e.REPETITION_MANDATORY = 2] = "REPETITION_MANDATORY", e[e.REPETITION_MANDATORY_WITH_SEPARATOR = 3] = "REPETITION_MANDATORY_WITH_SEPARATOR", e[e.REPETITION_WITH_SEPARATOR = 4] = "REPETITION_WITH_SEPARATOR", e[e.ALTERNATION = 5] = "ALTERNATION";
2099
- })(Y ||= {});
2100
- var ct = class extends S {
2101
- constructor(e, t, n) {
2102
- super(), this.topProd = e, this.targetOccurrence = t, this.targetProdType = n;
2103
- }
2104
- startWalking() {
2105
- return this.walk(this.topProd), this.restDef;
2106
- }
2107
- checkIsTarget(e, t, n, r) {
2108
- return e.idx === this.targetOccurrence && this.targetProdType === t && (this.restDef = n.concat(r), !0);
2109
- }
2110
- walkOption(e, t, n) {
2111
- this.checkIsTarget(e, Y.OPTION, t, n) || super.walkOption(e, t, n);
2112
- }
2113
- walkAtLeastOne(e, t, n) {
2114
- this.checkIsTarget(e, Y.REPETITION_MANDATORY, t, n) || super.walkOption(e, t, n);
2115
- }
2116
- walkAtLeastOneSep(e, t, n) {
2117
- this.checkIsTarget(e, Y.REPETITION_MANDATORY_WITH_SEPARATOR, t, n) || super.walkOption(e, t, n);
2118
- }
2119
- walkMany(e, t, n) {
2120
- this.checkIsTarget(e, Y.REPETITION, t, n) || super.walkOption(e, t, n);
2121
- }
2122
- walkManySep(e, t, n) {
2123
- this.checkIsTarget(e, Y.REPETITION_WITH_SEPARATOR, t, n) || super.walkOption(e, t, n);
2124
- }
2125
- }, lt = class extends y {
2126
- constructor(e, t, n) {
2127
- super(), this.targetOccurrence = e, this.targetProdType = t, this.targetRef = n, this.result = [];
2128
- }
2129
- checkIsTarget(e, t) {
2130
- e.idx !== this.targetOccurrence || this.targetProdType !== t || this.targetRef !== void 0 && e !== this.targetRef || (this.result = e.definition);
2131
- }
2132
- visitOption(e) {
2133
- this.checkIsTarget(e, Y.OPTION);
2134
- }
2135
- visitRepetition(e) {
2136
- this.checkIsTarget(e, Y.REPETITION);
2137
- }
2138
- visitRepetitionMandatory(e) {
2139
- this.checkIsTarget(e, Y.REPETITION_MANDATORY);
2140
- }
2141
- visitRepetitionMandatoryWithSeparator(e) {
2142
- this.checkIsTarget(e, Y.REPETITION_MANDATORY_WITH_SEPARATOR);
2143
- }
2144
- visitRepetitionWithSeparator(e) {
2145
- this.checkIsTarget(e, Y.REPETITION_WITH_SEPARATOR);
2146
- }
2147
- visitAlternation(e) {
2148
- this.checkIsTarget(e, Y.ALTERNATION);
2149
- }
2150
- };
2151
- function ut(e) {
2152
- let t = Array(e);
2153
- for (let n = 0; n < e; n++) t[n] = [];
2154
- return t;
2155
- }
2156
- function dt(e) {
2157
- let t = [""];
2158
- for (let n = 0; n < e.length; n++) {
2159
- let r = e[n], i = [];
2160
- for (let e = 0; e < t.length; e++) {
2161
- let n = t[e];
2162
- i.push(n + "_" + r.tokenTypeIdx);
2163
- for (let e = 0; e < r.categoryMatches.length; e++) {
2164
- let t = "_" + r.categoryMatches[e];
2165
- i.push(n + t);
2166
- }
2167
- }
2168
- t = i;
2169
- }
2170
- return t;
2171
- }
2172
- function ft(e, t, n) {
2173
- for (let r = 0; r < e.length; r++) {
2174
- if (r === n) continue;
2175
- let i = e[r];
2176
- for (let e = 0; e < t.length; e++) if (!0 === i[t[e]]) return !1;
2177
- }
2178
- return !0;
2179
- }
2180
- function pt(e, t) {
2181
- let n = e.map((e) => rt([e], 1)), r = ut(n.length), i = n.map((e) => {
2182
- let t = {};
2183
- return e.forEach((e) => {
2184
- dt(e.partialPath).forEach((e) => {
2185
- t[e] = !0;
2186
- });
2187
- }), t;
2188
- }), a = n;
2189
- for (let e = 1; e <= t; e++) {
2190
- let n = a;
2191
- a = ut(n.length);
2192
- for (let o = 0; o < n.length; o++) {
2193
- let s = n[o];
2194
- for (let n = 0; n < s.length; n++) {
2195
- let c = s[n].partialPath, l = s[n].suffixDef, u = dt(c);
2196
- if (ft(i, u, o) || l.length === 0 || c.length === t) {
2197
- let e = r[o];
2198
- if (!1 === gt(e, c)) {
2199
- e.push(c);
2200
- for (let e = 0; e < u.length; e++) {
2201
- let t = u[e];
2202
- i[o][t] = !0;
2203
- }
2204
- }
2205
- } else {
2206
- let t = rt(l, e + 1, c);
2207
- a[o] = a[o].concat(t), t.forEach((e) => {
2208
- dt(e.partialPath).forEach((e) => {
2209
- i[o][e] = !0;
2210
- });
2211
- });
2212
- }
2213
- }
2214
- }
2215
- }
2216
- return r;
2217
- }
2218
- function mt(e, t, n, r) {
2219
- let i = new lt(e, Y.ALTERNATION, r);
2220
- return t.accept(i), pt(i.result, n);
2221
- }
2222
- function ht(e, t, n, r) {
2223
- let i = new lt(e, n);
2224
- t.accept(i);
2225
- let a = i.result, o = new ct(t, e, n).startWalking();
2226
- return pt([new l({ definition: a }), new l({ definition: o })], r);
2227
- }
2228
- function gt(e, t) {
2229
- e: for (let n = 0; n < e.length; n++) {
2230
- let r = e[n];
2231
- if (r.length === t.length) {
2232
- for (let e = 0; e < r.length; e++) {
2233
- let n = t[e], i = r[e];
2234
- if ((n === i || i.categoryMatchesMap[n.tokenTypeIdx] !== void 0) == 0) continue e;
2235
- }
2236
- return !0;
2237
- }
2238
- }
2239
- return !1;
2240
- }
2241
- function _t(e) {
2242
- return e.every((e) => e.every((e) => e.every((e) => e.categoryMatches.length === 0)));
2243
- }
2244
- function vt(e, t, n, r) {
2245
- let i = e.flatMap((e) => function(e, t) {
2246
- let n = new xt();
2247
- e.accept(n);
2248
- let r = n.allProductions, i = Object.groupBy(r, yt), a = Object.fromEntries(Object.entries(i).filter(([e, t]) => t.length > 1));
2249
- return Object.values(a).map((n) => {
2250
- let r = n[0], i = t.buildDuplicateFoundError(e, n), a = x(r), o = {
2251
- message: i,
2252
- type: Q.DUPLICATE_PRODUCTIONS,
2253
- ruleName: e.name,
2254
- dslName: a,
2255
- occurrence: r.idx
2256
- }, s = bt(r);
2257
- return s && (o.parameter = s), o;
2258
- });
2259
- }(e, n)), a = function(e, t, n) {
2260
- let r = [], i = t.map((e) => e.name);
2261
- return e.forEach((e) => {
2262
- let t = e.name;
2263
- if (i.includes(t)) {
2264
- let i = n.buildNamespaceConflictError(e);
2265
- r.push({
2266
- message: i,
2267
- type: Q.CONFLICT_TOKENS_RULES_NAMESPACE,
2268
- ruleName: t
2269
- });
2270
- }
2271
- }), r;
2272
- }(e, t, n), o = e.flatMap((e) => function(e, t) {
2273
- let n = new wt();
2274
- return e.accept(n), n.alternations.flatMap((n) => n.definition.length > 255 ? [{
2275
- message: t.buildTooManyAlternativesError({
2276
- topLevelRule: e,
2277
- alternation: n
2278
- }),
2279
- type: Q.TOO_MANY_ALTS,
2280
- ruleName: e.name,
2281
- occurrence: n.idx
2282
- }] : []);
2283
- }(e, n)), s = e.flatMap((t) => function(e, t, n, r) {
2284
- let i = [];
2285
- if (t.reduce((t, n) => n.name === e.name ? t + 1 : t, 0) > 1) {
2286
- let t = r.buildDuplicateRuleNameError({
2287
- topLevelRule: e,
2288
- grammarName: n
2289
- });
2290
- i.push({
2291
- message: t,
2292
- type: Q.DUPLICATE_RULE_NAME,
2293
- ruleName: e.name
2294
- });
2295
- }
2296
- return i;
2297
- }(t, e, r, n));
2298
- return i.concat(a, o, s);
2299
- }
2300
- function yt(e) {
2301
- return `${x(e)}_#_${e.idx}_#_${bt(e)}`;
2302
- }
2303
- function bt(e) {
2304
- return e instanceof g ? e.terminalType.name : e instanceof s ? e.nonTerminalName : "";
2305
- }
2306
- var xt = class extends y {
2307
- constructor() {
2308
- super(...arguments), this.allProductions = [];
2309
- }
2310
- visitNonTerminal(e) {
2311
- this.allProductions.push(e);
2312
- }
2313
- visitOption(e) {
2314
- this.allProductions.push(e);
2315
- }
2316
- visitRepetitionWithSeparator(e) {
2317
- this.allProductions.push(e);
2318
- }
2319
- visitRepetitionMandatory(e) {
2320
- this.allProductions.push(e);
2321
- }
2322
- visitRepetitionMandatoryWithSeparator(e) {
2323
- this.allProductions.push(e);
2324
- }
2325
- visitRepetition(e) {
2326
- this.allProductions.push(e);
2327
- }
2328
- visitAlternation(e) {
2329
- this.allProductions.push(e);
2330
- }
2331
- visitTerminal(e) {
2332
- this.allProductions.push(e);
2333
- }
2334
- };
2335
- function St(e, t, n, r = []) {
2336
- let i = [], a = Ct(t.definition);
2337
- if (a.length === 0) return [];
2338
- {
2339
- let t = e.name;
2340
- a.includes(e) && i.push({
2341
- message: n.buildLeftRecursionError({
2342
- topLevelRule: e,
2343
- leftRecursionPath: r
2344
- }),
2345
- type: Q.LEFT_RECURSION,
2346
- ruleName: t
2347
- });
2348
- let o = r.concat([e]), s = a.filter((e) => !o.includes(e)).flatMap((t) => {
2349
- let i = [...r];
2350
- return i.push(t), St(e, t, n, i);
2351
- });
2352
- return i.concat(s);
2353
- }
2354
- }
2355
- function Ct(e) {
2356
- let t = [];
2357
- if (e.length === 0) return t;
2358
- let n = e[0];
2359
- if (n instanceof s) t.push(n.referencedRule);
2360
- else if (n instanceof l || n instanceof u || n instanceof d || n instanceof f || n instanceof m || n instanceof p) t = t.concat(Ct(n.definition));
2361
- else if (n instanceof h) t = n.definition.map((e) => Ct(e.definition)).flat();
2362
- else if (!(n instanceof g)) throw Error("non exhaustive match");
2363
- let r = b(n), i = e.length > 1;
2364
- if (r && i) {
2365
- let n = e.slice(1);
2366
- return t.concat(Ct(n));
2367
- }
2368
- return t;
2369
- }
2370
- var wt = class extends y {
2371
- constructor() {
2372
- super(...arguments), this.alternations = [];
2373
- }
2374
- visitAlternation(e) {
2375
- this.alternations.push(e);
2376
- }
2377
- };
2378
- function Tt(e, t) {
2379
- let n = new wt();
2380
- return e.accept(n), n.alternations.flatMap((n) => n.definition.slice(0, -1).flatMap((r, i) => function(e, t, n, r) {
2381
- let i = "EXIT_NONE_TERMINAL", a = [i], o = "EXIT_ALTERNATIVE", _ = !1, v = t.length, y = v - r - 1, b = [], x = [];
2382
- for (x.push({
2383
- idx: -1,
2384
- def: e,
2385
- ruleStack: [],
2386
- occurrenceStack: []
2387
- }); x.length !== 0;) {
2388
- let e = x.pop();
2389
- if (e === o) {
2390
- _ && x.at(-1).idx <= y && x.pop();
2391
- continue;
2392
- }
2393
- let r = e.def, S = e.idx, C = e.ruleStack, w = e.occurrenceStack;
2394
- if (r.length === 0) continue;
2395
- let T = r[0];
2396
- if (T === i) {
2397
- let e = {
2398
- idx: S,
2399
- def: r.slice(1),
2400
- ruleStack: C.slice(0, -1),
2401
- occurrenceStack: w.slice(0, -1)
2402
- };
2403
- x.push(e);
2404
- } else if (T instanceof g) if (S < v - 1) {
2405
- let e = S + 1;
2406
- if (n(t[e], T.terminalType)) {
2407
- let t = {
2408
- idx: e,
2409
- def: r.slice(1),
2410
- ruleStack: C,
2411
- occurrenceStack: w
2412
- };
2413
- x.push(t);
2414
- }
2415
- } else {
2416
- if (S !== v - 1) throw Error("non exhaustive match");
2417
- b.push({
2418
- nextTokenType: T.terminalType,
2419
- nextTokenOccurrence: T.idx,
2420
- ruleStack: C,
2421
- occurrenceStack: w
2422
- }), _ = !0;
2423
- }
2424
- else if (T instanceof s) {
2425
- let e = [...C];
2426
- e.push(T.nonTerminalName);
2427
- let t = [...w];
2428
- t.push(T.idx);
2429
- let n = {
2430
- idx: S,
2431
- def: T.definition.concat(a, r.slice(1)),
2432
- ruleStack: e,
2433
- occurrenceStack: t
2434
- };
2435
- x.push(n);
2436
- } else if (T instanceof u) {
2437
- let e = {
2438
- idx: S,
2439
- def: r.slice(1),
2440
- ruleStack: C,
2441
- occurrenceStack: w
2442
- };
2443
- x.push(e), x.push(o);
2444
- let t = {
2445
- idx: S,
2446
- def: T.definition.concat(r.slice(1)),
2447
- ruleStack: C,
2448
- occurrenceStack: w
2449
- };
2450
- x.push(t);
2451
- } else if (T instanceof d) {
2452
- let e = new p({
2453
- definition: T.definition,
2454
- idx: T.idx
2455
- }), t = {
2456
- idx: S,
2457
- def: T.definition.concat([e], r.slice(1)),
2458
- ruleStack: C,
2459
- occurrenceStack: w
2460
- };
2461
- x.push(t);
2462
- } else if (T instanceof f) {
2463
- let e = new p({
2464
- definition: [new g({ terminalType: T.separator })].concat(T.definition),
2465
- idx: T.idx
2466
- }), t = {
2467
- idx: S,
2468
- def: T.definition.concat([e], r.slice(1)),
2469
- ruleStack: C,
2470
- occurrenceStack: w
2471
- };
2472
- x.push(t);
2473
- } else if (T instanceof m) {
2474
- let e = {
2475
- idx: S,
2476
- def: r.slice(1),
2477
- ruleStack: C,
2478
- occurrenceStack: w
2479
- };
2480
- x.push(e), x.push(o);
2481
- let t = new p({
2482
- definition: [new g({ terminalType: T.separator })].concat(T.definition),
2483
- idx: T.idx
2484
- }), n = {
2485
- idx: S,
2486
- def: T.definition.concat([t], r.slice(1)),
2487
- ruleStack: C,
2488
- occurrenceStack: w
2489
- };
2490
- x.push(n);
2491
- } else if (T instanceof p) {
2492
- let e = {
2493
- idx: S,
2494
- def: r.slice(1),
2495
- ruleStack: C,
2496
- occurrenceStack: w
2497
- };
2498
- x.push(e), x.push(o);
2499
- let t = new p({
2500
- definition: T.definition,
2501
- idx: T.idx
2502
- }), n = {
2503
- idx: S,
2504
- def: T.definition.concat([t], r.slice(1)),
2505
- ruleStack: C,
2506
- occurrenceStack: w
2507
- };
2508
- x.push(n);
2509
- } else if (T instanceof h) for (let e = T.definition.length - 1; e >= 0; e--) {
2510
- let t = {
2511
- idx: S,
2512
- def: T.definition[e].definition.concat(r.slice(1)),
2513
- ruleStack: C,
2514
- occurrenceStack: w
2515
- };
2516
- x.push(t), x.push(o);
2517
- }
2518
- else if (T instanceof l) x.push({
2519
- idx: S,
2520
- def: T.definition.concat(r.slice(1)),
2521
- ruleStack: C,
2522
- occurrenceStack: w
2523
- });
2524
- else {
2525
- if (!(T instanceof c)) throw Error("non exhaustive match");
2526
- x.push(it(T, S, C, w));
2527
- }
2528
- }
2529
- return b;
2530
- }([r], [], B, 1).length === 0 ? [{
2531
- message: t.buildEmptyAlternationError({
2532
- topLevelRule: e,
2533
- alternation: n,
2534
- emptyChoiceIdx: i
2535
- }),
2536
- type: Q.NONE_LAST_EMPTY_ALT,
2537
- ruleName: e.name,
2538
- occurrence: n.idx,
2539
- alternative: i + 1
2540
- }] : []));
2541
- }
2542
- function Et(e, t, n) {
2543
- let r = new wt();
2544
- e.accept(r);
2545
- let i = r.alternations;
2546
- return i = i.filter((e) => !0 !== e.ignoreAmbiguities), i.flatMap((r) => {
2547
- let i = mt(r.idx, e, r.maxLookahead || t, r), a = function(e, t, n, r) {
2548
- let i = [];
2549
- return e.reduce((n, r, a) => (!0 === t.definition[a].ignoreAmbiguities || r.forEach((r) => {
2550
- let o = [a];
2551
- e.forEach((e, n) => {
2552
- a !== n && gt(e, r) && !0 !== t.definition[n].ignoreAmbiguities && o.push(n);
2553
- }), o.length > 1 && !gt(i, r) && (i.push(r), n.push({
2554
- alts: o,
2555
- path: r
2556
- }));
2557
- }), n), []).map((e) => {
2558
- let i = e.alts.map((e) => e + 1);
2559
- return {
2560
- message: r.buildAlternationAmbiguityError({
2561
- topLevelRule: n,
2562
- alternation: t,
2563
- ambiguityIndices: i,
2564
- prefixPath: e.path
2565
- }),
2566
- type: Q.AMBIGUOUS_ALTS,
2567
- ruleName: n.name,
2568
- occurrence: t.idx,
2569
- alternatives: e.alts
2570
- };
2571
- });
2572
- }(i, r, e, n), o = function(e, t, n, r) {
2573
- let i = e.reduce((e, t, n) => {
2574
- let r = t.map((e) => ({
2575
- idx: n,
2576
- path: e
2577
- }));
2578
- return e.concat(r);
2579
- }, []);
2580
- return i.flatMap((e) => {
2581
- if (!0 === t.definition[e.idx].ignoreAmbiguities) return [];
2582
- let a = e.idx, o = e.path;
2583
- return i.filter((e) => {
2584
- return !0 !== t.definition[e.idx].ignoreAmbiguities && e.idx < a && (n = e.path, r = o, n.length < r.length && n.every((e, t) => {
2585
- let n = r[t];
2586
- return e === n || n.categoryMatchesMap[e.tokenTypeIdx];
2587
- }));
2588
- var n, r;
2589
- }).map((e) => {
2590
- let i = [e.idx + 1, a + 1], o = t.idx === 0 ? "" : t.idx;
2591
- return {
2592
- message: r.buildAlternationPrefixAmbiguityError({
2593
- topLevelRule: n,
2594
- alternation: t,
2595
- ambiguityIndices: i,
2596
- prefixPath: e.path
2597
- }),
2598
- type: Q.AMBIGUOUS_PREFIX_ALTS,
2599
- ruleName: n.name,
2600
- occurrence: o,
2601
- alternatives: i
2602
- };
2603
- });
2604
- });
2605
- }(i, r, e, n);
2606
- return a.concat(o);
2607
- });
2608
- }
2609
- var Dt = class extends y {
2610
- constructor() {
2611
- super(...arguments), this.allProductions = [];
2612
- }
2613
- visitRepetitionWithSeparator(e) {
2614
- this.allProductions.push(e);
2615
- }
2616
- visitRepetitionMandatory(e) {
2617
- this.allProductions.push(e);
2618
- }
2619
- visitRepetitionMandatoryWithSeparator(e) {
2620
- this.allProductions.push(e);
2621
- }
2622
- visitRepetition(e) {
2623
- this.allProductions.push(e);
2624
- }
2625
- };
2626
- function Ot(e) {
2627
- let t = Object.assign({ errMsgProvider: Je }, e), n = {};
2628
- return e.rules.forEach((e) => {
2629
- n[e.name] = e;
2630
- }), function(e, t) {
2631
- let n = new Ye(e, t);
2632
- return n.resolveRefs(), n.errors;
2633
- }(n, t.errMsgProvider);
2634
- }
2635
- var kt = "MismatchedTokenException", At = "NoViableAltException", jt = "EarlyExitException", Mt = "NotAllInputParsedException", Nt = [
2636
- kt,
2637
- At,
2638
- jt,
2639
- Mt
2640
- ];
2641
- function Pt(e) {
2642
- return Nt.includes(e.name);
2643
- }
2644
- Object.freeze(Nt);
2645
- var Ft = class extends Error {
2646
- constructor(e, t) {
2647
- super(e), this.token = t, this.resyncedTokens = [], Object.setPrototypeOf(this, new.target.prototype), Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
2648
- }
2649
- }, It = class extends Ft {
2650
- constructor(e, t, n) {
2651
- super(e, t), this.previousToken = n, this.name = kt;
2652
- }
2653
- }, Lt = class extends Ft {
2654
- constructor(e, t, n) {
2655
- super(e, t), this.previousToken = n, this.name = At;
2656
- }
2657
- }, Rt = class extends Ft {
2658
- constructor(e, t) {
2659
- super(e, t), this.name = Mt;
2660
- }
2661
- }, zt = class extends Ft {
2662
- constructor(e, t, n) {
2663
- super(e, t), this.previousToken = n, this.name = jt;
2664
- }
2665
- }, Bt = {}, Vt = class extends Error {
2666
- constructor(e) {
2667
- super(e), this.name = "InRuleRecoveryException";
2668
- }
2669
- };
2670
- function Ht(e, t, n, r, i, a, o) {
2671
- let s = this.getKeyForAutomaticLookahead(r, i), c = this.firstAfterRepMap[s];
2672
- if (c === void 0) {
2673
- let e = this.getCurrRuleFullName();
2674
- c = new a(this.getGAstProductions()[e], i).startWalking(), this.firstAfterRepMap[s] = c;
2675
- }
2676
- let l = c.token, u = c.occurrence, d = c.isEndOfRule;
2677
- this.RULE_STACK_IDX === 0 && d && l === void 0 && (l = q, u = 1), l !== void 0 && u !== void 0 && this.shouldInRepetitionRecoveryBeTried(l, u, o) && this.tryInRepetitionRecovery(e, t, n, l);
2678
- }
2679
- var Ut = 1024, Wt = 1280, Gt = 1536;
2680
- function Kt(e, t, n) {
2681
- return n | t | e;
2682
- }
2683
- var qt = class {
2684
- constructor(e) {
2685
- this.maxLookahead = e?.maxLookahead ?? $.maxLookahead;
2686
- }
2687
- validate(e) {
2688
- let t = this.validateNoLeftRecursion(e.rules);
2689
- if (t.length === 0) {
2690
- let n = this.validateEmptyOrAlternatives(e.rules), r = this.validateAmbiguousAlternationAlternatives(e.rules, this.maxLookahead), i = this.validateSomeNonEmptyLookaheadPath(e.rules, this.maxLookahead);
2691
- return [
2692
- ...t,
2693
- ...n,
2694
- ...r,
2695
- ...i
2696
- ];
2697
- }
2698
- return t;
2699
- }
2700
- validateNoLeftRecursion(e) {
2701
- return e.flatMap((e) => St(e, e, J));
2702
- }
2703
- validateEmptyOrAlternatives(e) {
2704
- return e.flatMap((e) => Tt(e, J));
2705
- }
2706
- validateAmbiguousAlternationAlternatives(e, t) {
2707
- return e.flatMap((e) => Et(e, t, J));
2708
- }
2709
- validateSomeNonEmptyLookaheadPath(e, t) {
2710
- return function(e, t, n) {
2711
- let r = [];
2712
- return e.forEach((e) => {
2713
- let i = new Dt();
2714
- e.accept(i), i.allProductions.forEach((i) => {
2715
- let a = at(i), o = i.maxLookahead || t;
2716
- if (ht(i.idx, e, a, o)[0].flat().length === 0) {
2717
- let t = n.buildEmptyRepetitionError({
2718
- topLevelRule: e,
2719
- repetition: i
2720
- });
2721
- r.push({
2722
- message: t,
2723
- type: Q.NO_NON_EMPTY_LOOKAHEAD,
2724
- ruleName: e.name
2725
- });
2726
- }
2727
- });
2728
- }), r;
2729
- }(e, t, J);
2730
- }
2731
- buildLookaheadForAlternation(e) {
2732
- return function(e, t, n, r, i, a) {
2733
- let o = mt(e, t, n);
2734
- return a(o, r, _t(o) ? Oe : B, i);
2735
- }(e.prodOccurrence, e.rule, e.maxLookahead, e.hasPredicates, e.dynamicTokensEnabled, ot);
2736
- }
2737
- buildLookaheadForOptional(e) {
2738
- return function(e, t, n, r, i, a) {
2739
- let o = ht(e, t, i, n), s = _t(o) ? Oe : B;
2740
- return a(o[0], s, r);
2741
- }(e.prodOccurrence, e.rule, e.maxLookahead, e.dynamicTokensEnabled, at(e.prodType), st);
2742
- }
2743
- }, Jt = new class extends y {
2744
- constructor() {
2745
- super(...arguments), this.dslMethods = {
2746
- option: [],
2747
- alternation: [],
2748
- repetition: [],
2749
- repetitionWithSeparator: [],
2750
- repetitionMandatory: [],
2751
- repetitionMandatoryWithSeparator: []
2752
- };
2753
- }
2754
- reset() {
2755
- this.dslMethods = {
2756
- option: [],
2757
- alternation: [],
2758
- repetition: [],
2759
- repetitionWithSeparator: [],
2760
- repetitionMandatory: [],
2761
- repetitionMandatoryWithSeparator: []
2762
- };
2763
- }
2764
- visitOption(e) {
2765
- this.dslMethods.option.push(e);
2766
- }
2767
- visitRepetitionWithSeparator(e) {
2768
- this.dslMethods.repetitionWithSeparator.push(e);
2769
- }
2770
- visitRepetitionMandatory(e) {
2771
- this.dslMethods.repetitionMandatory.push(e);
2772
- }
2773
- visitRepetitionMandatoryWithSeparator(e) {
2774
- this.dslMethods.repetitionMandatoryWithSeparator.push(e);
2775
- }
2776
- visitRepetition(e) {
2777
- this.dslMethods.repetition.push(e);
2778
- }
2779
- visitAlternation(e) {
2780
- this.dslMethods.alternation.push(e);
2781
- }
2782
- }();
2783
- function Yt(e, t) {
2784
- e.startOffset === -1 ? (e.startOffset = t.startOffset, e.endOffset = t.endOffset) : e.endOffset < t.endOffset == 1 && (e.endOffset = t.endOffset);
2785
- }
2786
- function Xt(e, t) {
2787
- e.startOffset === -1 ? (e.startOffset = t.startOffset, e.startColumn = t.startColumn, e.startLine = t.startLine, e.endOffset = t.endOffset, e.endColumn = t.endColumn, e.endLine = t.endLine) : e.endOffset < t.endOffset == 1 && (e.endOffset = t.endOffset, e.endColumn = t.endColumn, e.endLine = t.endLine);
2788
- }
2789
- var Zt;
2790
- function Qt(e, t) {
2791
- Object.defineProperty(e, "name", {
2792
- enumerable: !1,
2793
- configurable: !0,
2794
- writable: !1,
2795
- value: t
2796
- });
2797
- }
2798
- function $t(e, t) {
2799
- let n = Object.keys(e), r = n.length;
2800
- for (let i = 0; i < r; i++) {
2801
- let r = e[n[i]], a = r.length;
2802
- for (let e = 0; e < a; e++) {
2803
- let n = r[e];
2804
- n.tokenTypeIdx === void 0 && this[n.name](n.children, t);
2805
- }
2806
- }
2807
- }
2808
- function en(e, t) {
2809
- let n = function() {};
2810
- return Qt(n, e + "BaseSemantics"), n.prototype = {
2811
- visit: function(e, t) {
2812
- if (Array.isArray(e) && (e = e[0]), e !== void 0) return this[e.name](e.children, t);
2813
- },
2814
- validateVisitor: function() {
2815
- let e = function(e, t) {
2816
- return function(e, t) {
2817
- return t.filter((t) => typeof e[t] == "function" == 0).map((t) => ({
2818
- msg: `Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,
2819
- type: Zt.MISSING_METHOD,
2820
- methodName: t
2821
- })).filter(Boolean);
2822
- }(e, t);
2823
- }(this, t);
2824
- if (e.length !== 0) {
2825
- let t = e.map((e) => e.msg);
2826
- throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join("\n\n").replace(/\n/g, "\n ")}`);
2827
- }
2828
- }
2829
- }, n.prototype.constructor = n, n._RULE_NAMES = t, n;
2830
- }
2831
- (function(e) {
2832
- e[e.REDUNDANT_METHOD = 0] = "REDUNDANT_METHOD", e[e.MISSING_METHOD = 1] = "MISSING_METHOD";
2833
- })(Zt ||= {});
2834
- var tn = { description: "This Object indicates the Parser is during Recording Phase" };
2835
- Object.freeze(tn);
2836
- var nn = !0, rn = 2 ** 8 - 1, an = K({
2837
- name: "RECORDING_PHASE_TOKEN",
2838
- pattern: W.NA
2839
- });
2840
- V([an]);
2841
- var on = Ke(an, "This IToken indicates the Parser is in Recording Phase\n See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details", -1, -1, -1, -1, -1, -1);
2842
- Object.freeze(on);
2843
- var sn = {
2844
- name: "This CSTNode indicates the Parser is in Recording Phase\n See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",
2845
- children: {}
2846
- };
2847
- function X(e, t, n, r = !1) {
2848
- un(n);
2849
- let i = this.recordingProdStack.at(-1), a = typeof t == "function" ? t : t.DEF, o = new e({
2850
- definition: [],
2851
- idx: n
2852
- });
2853
- return r && (o.separator = t.SEP), Object.hasOwn(t, "MAX_LOOKAHEAD") && (o.maxLookahead = t.MAX_LOOKAHEAD), this.recordingProdStack.push(o), a.call(this), i.definition.push(o), this.recordingProdStack.pop(), tn;
2854
- }
2855
- function cn(e, t) {
2856
- un(t);
2857
- let n = this.recordingProdStack.at(-1), r = !1 === Array.isArray(e), i = !1 === r ? e : e.DEF, a = new h({
2858
- definition: [],
2859
- idx: t,
2860
- ignoreAmbiguities: r && !0 === e.IGNORE_AMBIGUITIES
2861
- });
2862
- return Object.hasOwn(e, "MAX_LOOKAHEAD") && (a.maxLookahead = e.MAX_LOOKAHEAD), a.hasPredicates = i.some((e) => typeof e.GATE == "function"), n.definition.push(a), i.forEach((e) => {
2863
- let t = new l({ definition: [] });
2864
- a.definition.push(t), Object.hasOwn(e, "IGNORE_AMBIGUITIES") ? t.ignoreAmbiguities = e.IGNORE_AMBIGUITIES : Object.hasOwn(e, "GATE") && (t.ignoreAmbiguities = !0), this.recordingProdStack.push(t), e.ALT.call(this), this.recordingProdStack.pop();
2865
- }), tn;
2866
- }
2867
- function ln(e) {
2868
- return e === 0 ? "" : `${e}`;
2869
- }
2870
- function un(e) {
2871
- if (e < 0 || e > rn) {
2872
- let t = /* @__PURE__ */ Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than ${rn + 1}`);
2873
- throw t.KNOWN_RECORDER_ERROR = !0, t;
2874
- }
2875
- }
2876
- var Z = Ke(q, "", -1, -1, -1, -1, -1, -1);
2877
- Object.freeze(Z);
2878
- var Q, $ = Object.freeze({
2879
- recoveryEnabled: !1,
2880
- maxLookahead: 3,
2881
- dynamicTokensEnabled: !1,
2882
- outputCst: !0,
2883
- errorMessageProvider: qe,
2884
- nodeLocationTracking: "none",
2885
- traceInitPerf: !1,
2886
- skipValidations: !1
2887
- }), dn = Object.freeze({
2888
- recoveryValueFunc: () => {},
2889
- resyncEnabled: !0
2890
- });
2891
- (function(e) {
2892
- e[e.INVALID_RULE_NAME = 0] = "INVALID_RULE_NAME", e[e.DUPLICATE_RULE_NAME = 1] = "DUPLICATE_RULE_NAME", e[e.INVALID_RULE_OVERRIDE = 2] = "INVALID_RULE_OVERRIDE", e[e.DUPLICATE_PRODUCTIONS = 3] = "DUPLICATE_PRODUCTIONS", e[e.UNRESOLVED_SUBRULE_REF = 4] = "UNRESOLVED_SUBRULE_REF", e[e.LEFT_RECURSION = 5] = "LEFT_RECURSION", e[e.NONE_LAST_EMPTY_ALT = 6] = "NONE_LAST_EMPTY_ALT", e[e.AMBIGUOUS_ALTS = 7] = "AMBIGUOUS_ALTS", e[e.CONFLICT_TOKENS_RULES_NAMESPACE = 8] = "CONFLICT_TOKENS_RULES_NAMESPACE", e[e.INVALID_TOKEN_NAME = 9] = "INVALID_TOKEN_NAME", e[e.NO_NON_EMPTY_LOOKAHEAD = 10] = "NO_NON_EMPTY_LOOKAHEAD", e[e.AMBIGUOUS_PREFIX_ALTS = 11] = "AMBIGUOUS_PREFIX_ALTS", e[e.TOO_MANY_ALTS = 12] = "TOO_MANY_ALTS", e[e.CUSTOM_LOOKAHEAD_VALIDATION = 13] = "CUSTOM_LOOKAHEAD_VALIDATION";
2893
- })(Q ||= {});
2894
- var fn, pn = class e {
2895
- static performSelfAnalysis(e) {
2896
- throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.");
2897
- }
2898
- performSelfAnalysis() {
2899
- this.TRACE_INIT("performSelfAnalysis", () => {
2900
- let t;
2901
- this.selfAnalysisDone = !0;
2902
- let n = this.className;
2903
- this.TRACE_INIT("toFastProps", () => {
2904
- a(this);
2905
- }), this.TRACE_INIT("Grammar Recording", () => {
2906
- try {
2907
- this.enableRecording(), this.definedRulesNames.forEach((e) => {
2908
- let t = this[e].originalGrammarAction, n;
2909
- this.TRACE_INIT(`${e} Rule`, () => {
2910
- n = this.topLevelRuleRecord(e, t);
2911
- }), this.gastProductionsCache[e] = n;
2912
- });
2913
- } finally {
2914
- this.disableRecording();
2915
- }
2916
- });
2917
- let r = [];
2918
- if (this.TRACE_INIT("Grammar Resolving", () => {
2919
- r = Ot({ rules: Object.values(this.gastProductionsCache) }), this.definitionErrors = this.definitionErrors.concat(r);
2920
- }), this.TRACE_INIT("Grammar Validations", () => {
2921
- if (r.length === 0 && !1 === this.skipValidations) {
2922
- let t = function(e) {
2923
- let t = e.errMsgProvider ?? J;
2924
- return vt(e.rules, e.tokenTypes, t, e.grammarName);
2925
- }({
2926
- rules: Object.values(this.gastProductionsCache),
2927
- tokenTypes: Object.values(this.tokensMap),
2928
- errMsgProvider: J,
2929
- grammarName: n
2930
- }), r = (e = {
2931
- lookaheadStrategy: this.lookaheadStrategy,
2932
- rules: Object.values(this.gastProductionsCache),
2933
- tokenTypes: Object.values(this.tokensMap),
2934
- grammarName: n
2935
- }).lookaheadStrategy.validate({
2936
- rules: e.rules,
2937
- tokenTypes: e.tokenTypes,
2938
- grammarName: e.grammarName
2939
- }).map((e) => Object.assign({ type: Q.CUSTOM_LOOKAHEAD_VALIDATION }, e));
2940
- this.definitionErrors = this.definitionErrors.concat(t, r);
2941
- }
2942
- var e;
2943
- }), this.definitionErrors.length === 0 && (this.recoveryEnabled && this.TRACE_INIT("computeAllProdsFollows", () => {
2944
- let e = function(e) {
2945
- let t = {};
2946
- return e.forEach((e) => {
2947
- let n = new E(e).startWalking();
2948
- Object.assign(t, n);
2949
- }), t;
2950
- }(Object.values(this.gastProductionsCache));
2951
- this.resyncFollows = e;
2952
- }), this.TRACE_INIT("ComputeLookaheadFunctions", () => {
2953
- var e, t;
2954
- (t = (e = this.lookaheadStrategy).initialize) == null || t.call(e, { rules: Object.values(this.gastProductionsCache) }), this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache));
2955
- })), !e.DEFER_DEFINITION_ERRORS_HANDLING && this.definitionErrors.length !== 0) throw t = this.definitionErrors.map((e) => e.message), /* @__PURE__ */ Error(`Parser Definition Errors detected:\n ${t.join("\n-------------------------------\n")}`);
2956
- });
2957
- }
2958
- constructor(e, t) {
2959
- this.definitionErrors = [], this.selfAnalysisDone = !1;
2960
- let n = this;
2961
- if (n.initErrorHandler(t), n.initLexerAdapter(), n.initLooksAhead(t), n.initRecognizerEngine(e, t), n.initRecoverable(t), n.initTreeBuilder(t), n.initGastRecorder(t), n.initPerformanceTracer(t), Object.hasOwn(t, "ignoredIssues")) throw Error("The <ignoredIssues> IParserConfig property has been deprecated.\n Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n For further details.");
2962
- this.skipValidations = Object.hasOwn(t, "skipValidations") ? t.skipValidations : $.skipValidations;
2963
- }
2964
- };
2965
- pn.DEFER_DEFINITION_ERRORS_HANDLING = !1, fn = pn, [
2966
- class {
2967
- initRecoverable(e) {
2968
- this.firstAfterRepMap = {}, this.resyncFollows = {}, this.recoveryEnabled = Object.hasOwn(e, "recoveryEnabled") ? e.recoveryEnabled : $.recoveryEnabled, this.recoveryEnabled && (this.attemptInRepetitionRecovery = Ht);
2969
- }
2970
- getTokenToInsert(e) {
2971
- let t = Ke(e, "", -1, -1, -1, -1, -1, -1);
2972
- return t.isInsertedInRecovery = !0, t;
2973
- }
2974
- canTokenTypeBeInsertedInRecovery(e) {
2975
- return !0;
2976
- }
2977
- canTokenTypeBeDeletedInRecovery(e) {
2978
- return !0;
2979
- }
2980
- tryInRepetitionRecovery(e, t, n, r) {
2981
- let i = this.findReSyncTokenType(), a = this.exportLexerState(), o = [], s = !1, c = this.LA_FAST(1), l = this.LA_FAST(1), u = () => {
2982
- let e = this.LA(0), t = new It(this.errorMessageProvider.buildMismatchTokenMessage({
2983
- expected: r,
2984
- actual: c,
2985
- previous: e,
2986
- ruleName: this.getCurrRuleFullName()
2987
- }), c, this.LA(0));
2988
- t.resyncedTokens = o.slice(0, -1), this.SAVE_ERROR(t);
2989
- };
2990
- for (; !s;) {
2991
- if (this.tokenMatcher(l, r)) return void u();
2992
- if (n.call(this)) return u(), void e.apply(this, t);
2993
- this.tokenMatcher(l, i) ? s = !0 : (l = this.SKIP_TOKEN(), this.addToResyncTokens(l, o));
2994
- }
2995
- this.importLexerState(a);
2996
- }
2997
- shouldInRepetitionRecoveryBeTried(e, t, n) {
2998
- return !1 !== n && !this.tokenMatcher(this.LA_FAST(1), e) && !this.isBackTracking() && !this.canPerformInRuleRecovery(e, this.getFollowsForInRuleRecovery(e, t));
2999
- }
3000
- getNextPossibleTokenTypes(e) {
3001
- let t = e.ruleStack[0], n = this.getGAstProductions()[t];
3002
- return new Ze(n, e).startWalking();
3003
- }
3004
- getFollowsForInRuleRecovery(e, t) {
3005
- let n = this.getCurrentGrammarPath(e, t);
3006
- return this.getNextPossibleTokenTypes(n);
3007
- }
3008
- tryInRuleRecovery(e, t) {
3009
- if (this.canRecoverWithSingleTokenInsertion(e, t)) return this.getTokenToInsert(e);
3010
- if (this.canRecoverWithSingleTokenDeletion(e)) {
3011
- let e = this.SKIP_TOKEN();
3012
- return this.consumeToken(), e;
3013
- }
3014
- throw new Vt("sad sad panda");
3015
- }
3016
- canPerformInRuleRecovery(e, t) {
3017
- return this.canRecoverWithSingleTokenInsertion(e, t) || this.canRecoverWithSingleTokenDeletion(e);
3018
- }
3019
- canRecoverWithSingleTokenInsertion(e, t) {
3020
- if (!this.canTokenTypeBeInsertedInRecovery(e) || t.length === 0) return !1;
3021
- let n = this.LA_FAST(1);
3022
- return t.find((e) => this.tokenMatcher(n, e)) !== void 0;
3023
- }
3024
- canRecoverWithSingleTokenDeletion(e) {
3025
- return !!this.canTokenTypeBeDeletedInRecovery(e) && this.tokenMatcher(this.LA(2), e);
3026
- }
3027
- isInCurrentRuleReSyncSet(e) {
3028
- let t = this.getCurrFollowKey();
3029
- return this.getFollowSetFromFollowKey(t).includes(e);
3030
- }
3031
- findReSyncTokenType() {
3032
- let e = this.flattenFollowSet(), t = this.LA_FAST(1), n = 2;
3033
- for (;;) {
3034
- let r = e.find((e) => B(t, e));
3035
- if (r !== void 0) return r;
3036
- t = this.LA(n), n++;
3037
- }
3038
- }
3039
- getCurrFollowKey() {
3040
- if (this.RULE_STACK_IDX === 0) return Bt;
3041
- let e = this.currRuleShortName, t = this.getLastExplicitRuleOccurrenceIndex(), n = this.getPreviousExplicitRuleShortName();
3042
- return {
3043
- ruleName: this.shortRuleNameToFullName(e),
3044
- idxInCallingRule: t,
3045
- inRule: this.shortRuleNameToFullName(n)
3046
- };
3047
- }
3048
- buildFullFollowKeyStack() {
3049
- let e = this.RULE_STACK, t = this.RULE_OCCURRENCE_STACK, n = this.RULE_STACK_IDX + 1, r = Array(n);
3050
- for (let i = 0; i < n; i++) r[i] = i === 0 ? Bt : {
3051
- ruleName: this.shortRuleNameToFullName(e[i]),
3052
- idxInCallingRule: t[i],
3053
- inRule: this.shortRuleNameToFullName(e[i - 1])
3054
- };
3055
- return r;
3056
- }
3057
- flattenFollowSet() {
3058
- return this.buildFullFollowKeyStack().map((e) => this.getFollowSetFromFollowKey(e)).flat();
3059
- }
3060
- getFollowSetFromFollowKey(e) {
3061
- if (e === Bt) return [q];
3062
- let t = e.ruleName + e.idxInCallingRule + T + e.inRule;
3063
- return this.resyncFollows[t];
3064
- }
3065
- addToResyncTokens(e, t) {
3066
- return this.tokenMatcher(e, q) || t.push(e), t;
3067
- }
3068
- reSyncTo(e) {
3069
- let t = [], n = this.LA_FAST(1);
3070
- for (; !1 === this.tokenMatcher(n, e);) n = this.SKIP_TOKEN(), this.addToResyncTokens(n, t);
3071
- return t.slice(0, -1);
3072
- }
3073
- attemptInRepetitionRecovery(e, t, n, r, i, a, o) {}
3074
- getCurrentGrammarPath(e, t) {
3075
- return {
3076
- ruleStack: this.getHumanReadableRuleStack(),
3077
- occurrenceStack: this.RULE_OCCURRENCE_STACK.slice(0, this.RULE_OCCURRENCE_STACK_IDX + 1),
3078
- lastTok: e,
3079
- lastTokOccurrence: t
3080
- };
3081
- }
3082
- getHumanReadableRuleStack() {
3083
- let e = this.RULE_STACK_IDX + 1, t = Array(e);
3084
- for (let n = 0; n < e; n++) t[n] = this.shortRuleNameToFullName(this.RULE_STACK[n]);
3085
- return t;
3086
- }
3087
- },
3088
- class {
3089
- initLooksAhead(e) {
3090
- this.dynamicTokensEnabled = Object.hasOwn(e, "dynamicTokensEnabled") ? e.dynamicTokensEnabled : $.dynamicTokensEnabled, this.maxLookahead = Object.hasOwn(e, "maxLookahead") ? e.maxLookahead : $.maxLookahead, this.lookaheadStrategy = Object.hasOwn(e, "lookaheadStrategy") ? e.lookaheadStrategy : new qt({ maxLookahead: this.maxLookahead }), this.lookAheadFuncsCache = /* @__PURE__ */ new Map();
3091
- }
3092
- preComputeLookaheadFunctions(e) {
3093
- e.forEach((e) => {
3094
- this.TRACE_INIT(`${e.name} Rule Lookahead`, () => {
3095
- let { alternation: t, repetition: n, option: r, repetitionMandatory: i, repetitionMandatoryWithSeparator: a, repetitionWithSeparator: o } = function(e) {
3096
- Jt.reset(), e.accept(Jt);
3097
- let t = Jt.dslMethods;
3098
- return Jt.reset(), t;
3099
- }(e);
3100
- t.forEach((t) => {
3101
- let n = t.idx === 0 ? "" : t.idx;
3102
- this.TRACE_INIT(`${x(t)}${n}`, () => {
3103
- let n = this.lookaheadStrategy.buildLookaheadForAlternation({
3104
- prodOccurrence: t.idx,
3105
- rule: e,
3106
- maxLookahead: t.maxLookahead || this.maxLookahead,
3107
- hasPredicates: t.hasPredicates,
3108
- dynamicTokensEnabled: this.dynamicTokensEnabled
3109
- }), r = Kt(this.fullRuleNameToShort[e.name], 256, t.idx);
3110
- this.setLaFuncCache(r, n);
3111
- });
3112
- }), n.forEach((t) => {
3113
- this.computeLookaheadFunc(e, t.idx, 768, "Repetition", t.maxLookahead, x(t));
3114
- }), r.forEach((t) => {
3115
- this.computeLookaheadFunc(e, t.idx, 512, "Option", t.maxLookahead, x(t));
3116
- }), i.forEach((t) => {
3117
- this.computeLookaheadFunc(e, t.idx, Ut, "RepetitionMandatory", t.maxLookahead, x(t));
3118
- }), a.forEach((t) => {
3119
- this.computeLookaheadFunc(e, t.idx, Gt, "RepetitionMandatoryWithSeparator", t.maxLookahead, x(t));
3120
- }), o.forEach((t) => {
3121
- this.computeLookaheadFunc(e, t.idx, Wt, "RepetitionWithSeparator", t.maxLookahead, x(t));
3122
- });
3123
- });
3124
- });
3125
- }
3126
- computeLookaheadFunc(e, t, n, r, i, a) {
3127
- this.TRACE_INIT(`${a}${t === 0 ? "" : t}`, () => {
3128
- let a = this.lookaheadStrategy.buildLookaheadForOptional({
3129
- prodOccurrence: t,
3130
- rule: e,
3131
- maxLookahead: i || this.maxLookahead,
3132
- dynamicTokensEnabled: this.dynamicTokensEnabled,
3133
- prodType: r
3134
- }), o = Kt(this.fullRuleNameToShort[e.name], n, t);
3135
- this.setLaFuncCache(o, a);
3136
- });
3137
- }
3138
- getKeyForAutomaticLookahead(e, t) {
3139
- return Kt(this.currRuleShortName, e, t);
3140
- }
3141
- getLaFuncFromCache(e) {
3142
- return this.lookAheadFuncsCache.get(e);
3143
- }
3144
- setLaFuncCache(e, t) {
3145
- this.lookAheadFuncsCache.set(e, t);
3146
- }
3147
- },
3148
- class {
3149
- initTreeBuilder(e) {
3150
- if (this.CST_STACK = [], this.outputCst = e.outputCst, this.nodeLocationTracking = Object.hasOwn(e, "nodeLocationTracking") ? e.nodeLocationTracking : $.nodeLocationTracking, this.outputCst) if (/full/i.test(this.nodeLocationTracking)) this.recoveryEnabled ? (this.setNodeLocationFromToken = Xt, this.setNodeLocationFromNode = Xt, this.cstPostRule = () => {}, this.setInitialNodeLocation = this.setInitialNodeLocationFullRecovery) : (this.setNodeLocationFromToken = () => {}, this.setNodeLocationFromNode = () => {}, this.cstPostRule = this.cstPostRuleFull, this.setInitialNodeLocation = this.setInitialNodeLocationFullRegular);
3151
- else if (/onlyOffset/i.test(this.nodeLocationTracking)) this.recoveryEnabled ? (this.setNodeLocationFromToken = Yt, this.setNodeLocationFromNode = Yt, this.cstPostRule = () => {}, this.setInitialNodeLocation = this.setInitialNodeLocationOnlyOffsetRecovery) : (this.setNodeLocationFromToken = () => {}, this.setNodeLocationFromNode = () => {}, this.cstPostRule = this.cstPostRuleOnlyOffset, this.setInitialNodeLocation = this.setInitialNodeLocationOnlyOffsetRegular);
3152
- else {
3153
- if (!/none/i.test(this.nodeLocationTracking)) throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`);
3154
- this.setNodeLocationFromToken = () => {}, this.setNodeLocationFromNode = () => {}, this.cstPostRule = () => {}, this.setInitialNodeLocation = () => {};
3155
- }
3156
- else this.cstInvocationStateUpdate = () => {}, this.cstFinallyStateUpdate = () => {}, this.cstPostTerminal = () => {}, this.cstPostNonTerminal = () => {}, this.cstPostRule = () => {};
3157
- }
3158
- setInitialNodeLocationOnlyOffsetRecovery(e) {
3159
- e.location = {
3160
- startOffset: -1,
3161
- endOffset: -1
3162
- };
3163
- }
3164
- setInitialNodeLocationOnlyOffsetRegular(e) {
3165
- e.location = {
3166
- startOffset: this.LA_FAST(1).startOffset,
3167
- endOffset: -1
3168
- };
3169
- }
3170
- setInitialNodeLocationFullRecovery(e) {
3171
- e.location = {
3172
- startOffset: -1,
3173
- startLine: -1,
3174
- startColumn: -1,
3175
- endOffset: -1,
3176
- endLine: -1,
3177
- endColumn: -1
3178
- };
3179
- }
3180
- setInitialNodeLocationFullRegular(e) {
3181
- let t = this.LA_FAST(1);
3182
- e.location = {
3183
- startOffset: t.startOffset,
3184
- startLine: t.startLine,
3185
- startColumn: t.startColumn,
3186
- endOffset: -1,
3187
- endLine: -1,
3188
- endColumn: -1
3189
- };
3190
- }
3191
- cstInvocationStateUpdate(e) {
3192
- let t = {
3193
- name: e,
3194
- children: Object.create(null)
3195
- };
3196
- this.setInitialNodeLocation(t), this.CST_STACK.push(t);
3197
- }
3198
- cstFinallyStateUpdate() {
3199
- this.CST_STACK.pop();
3200
- }
3201
- cstPostRuleFull(e) {
3202
- let t = this.LA(0), n = e.location;
3203
- n.startOffset !== -1 && n.startOffset <= t.startOffset == 1 ? (n.endOffset = t.endOffset, n.endLine = t.endLine, n.endColumn = t.endColumn) : (n.startOffset = -1, n.startLine = -1, n.startColumn = -1);
3204
- }
3205
- cstPostRuleOnlyOffset(e) {
3206
- let t = this.LA(0), n = e.location;
3207
- n.startOffset !== -1 && n.startOffset <= t.startOffset == 1 ? n.endOffset = t.endOffset : n.startOffset = -1;
3208
- }
3209
- cstPostTerminal(e, t) {
3210
- let n = this.CST_STACK[this.CST_STACK.length - 1];
3211
- var r, i = t, a = e;
3212
- (r = n).children[a] === void 0 ? r.children[a] = [i] : r.children[a].push(i), this.setNodeLocationFromToken(n.location, t);
3213
- }
3214
- cstPostNonTerminal(e, t) {
3215
- let n = this.CST_STACK[this.CST_STACK.length - 1];
3216
- (function(e, t, n) {
3217
- e.children[t] === void 0 ? e.children[t] = [n] : e.children[t].push(n);
3218
- })(n, t, e), this.setNodeLocationFromNode(n.location, e.location);
3219
- }
3220
- get currCSTNode() {
3221
- return this.CST_STACK[this.CST_STACK.length - 1];
3222
- }
3223
- getBaseCstVisitorConstructor() {
3224
- if (this.baseCstVisitorConstructor === void 0) {
3225
- let e = en(this.className, Object.keys(this.gastProductionsCache));
3226
- return this.baseCstVisitorConstructor = e, e;
3227
- }
3228
- return this.baseCstVisitorConstructor;
3229
- }
3230
- getBaseCstVisitorConstructorWithDefaults() {
3231
- if (this.baseCstVisitorWithDefaultsConstructor === void 0) {
3232
- let e = function(e, t, n) {
3233
- let r = function() {};
3234
- Qt(r, e + "BaseSemanticsWithDefaults");
3235
- let i = Object.create(n.prototype);
3236
- return t.forEach((e) => {
3237
- i[e] = $t;
3238
- }), (r.prototype = i).constructor = r, r;
3239
- }(this.className, Object.keys(this.gastProductionsCache), this.getBaseCstVisitorConstructor());
3240
- return this.baseCstVisitorWithDefaultsConstructor = e, e;
3241
- }
3242
- return this.baseCstVisitorWithDefaultsConstructor;
3243
- }
3244
- getPreviousExplicitRuleShortName() {
3245
- return this.RULE_STACK[this.RULE_STACK_IDX - 1];
3246
- }
3247
- getLastExplicitRuleOccurrenceIndex() {
3248
- return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX];
3249
- }
3250
- },
3251
- class {
3252
- initLexerAdapter() {
3253
- this.tokVector = [], this.tokVectorLength = 0, this.currIdx = -1;
3254
- }
3255
- set input(e) {
3256
- if (!0 !== this.selfAnalysisDone) throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");
3257
- this.reset(), this.tokVector = e, this.tokVectorLength = e.length;
3258
- }
3259
- get input() {
3260
- return this.tokVector;
3261
- }
3262
- SKIP_TOKEN() {
3263
- return this.currIdx <= this.tokVectorLength - 2 ? (this.consumeToken(), this.LA_FAST(1)) : Z;
3264
- }
3265
- LA_FAST(e) {
3266
- let t = this.currIdx + e;
3267
- return this.tokVector[t];
3268
- }
3269
- LA(e) {
3270
- let t = this.currIdx + e;
3271
- return t < 0 || this.tokVectorLength <= t ? Z : this.tokVector[t];
3272
- }
3273
- consumeToken() {
3274
- this.currIdx++;
3275
- }
3276
- exportLexerState() {
3277
- return this.currIdx;
3278
- }
3279
- importLexerState(e) {
3280
- this.currIdx = e;
3281
- }
3282
- resetLexerState() {
3283
- this.currIdx = -1;
3284
- }
3285
- moveToTerminatedState() {
3286
- this.currIdx = this.tokVectorLength - 1;
3287
- }
3288
- getLexerPosition() {
3289
- return this.exportLexerState();
3290
- }
3291
- },
3292
- class {
3293
- initRecognizerEngine(e, t) {
3294
- if (this.className = this.constructor.name, this.shortRuleNameToFull = {}, this.fullRuleNameToShort = {}, this.ruleShortNameIdx = 256, this.tokenMatcher = Oe, this.subruleIdx = 0, this.currRuleShortName = 0, this.definedRulesNames = [], this.tokensMap = {}, this.isBackTrackingStack = [], this.RULE_STACK = [], this.RULE_STACK_IDX = -1, this.RULE_OCCURRENCE_STACK = [], this.RULE_OCCURRENCE_STACK_IDX = -1, this.gastProductionsCache = {}, Object.hasOwn(t, "serializedGrammar")) throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n For Further details.");
3295
- if (Array.isArray(e)) {
3296
- if (e.length === 0) throw Error("A Token Vocabulary cannot be empty.\n Note that the first argument for the parser constructor\n is no longer a Token vector (since v4.0).");
3297
- if (typeof e[0].startOffset == "number") throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n For Further details.");
3298
- }
3299
- if (Array.isArray(e)) this.tokensMap = e.reduce((e, t) => (e[t.name] = t, e), {});
3300
- else if (Object.hasOwn(e, "modes") && Object.values(e.modes).flat().every(Pe)) {
3301
- let t = Object.values(e.modes).flat(), n = [...new Set(t)];
3302
- this.tokensMap = n.reduce((e, t) => (e[t.name] = t, e), {});
3303
- } else {
3304
- if (typeof e != "object" || !e) throw Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");
3305
- this.tokensMap = Object.assign({}, e);
3306
- }
3307
- this.tokensMap.EOF = q;
3308
- let n = (Object.hasOwn(e, "modes") ? Object.values(e.modes).flat() : Object.values(e)).every((e) => e.categoryMatches?.length == 0);
3309
- this.tokenMatcher = n ? Oe : B, V(Object.values(this.tokensMap));
3310
- }
3311
- defineRule(e, t, n) {
3312
- if (this.selfAnalysisDone) throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);
3313
- let r = Object.hasOwn(n, "resyncEnabled") ? n.resyncEnabled : dn.resyncEnabled, i = Object.hasOwn(n, "recoveryValueFunc") ? n.recoveryValueFunc : dn.recoveryValueFunc, a = this.ruleShortNameIdx << 12, o;
3314
- return this.ruleShortNameIdx++, this.shortRuleNameToFull[a] = e, this.fullRuleNameToShort[e] = a, o = !0 === this.outputCst ? function(...n) {
3315
- try {
3316
- this.ruleInvocationStateUpdate(a, e, this.subruleIdx), t.apply(this, n);
3317
- let r = this.CST_STACK[this.CST_STACK.length - 1];
3318
- return this.cstPostRule(r), r;
3319
- } catch (e) {
3320
- return this.invokeRuleCatch(e, r, i);
3321
- } finally {
3322
- this.ruleFinallyStateUpdate();
3323
- }
3324
- } : function(...n) {
3325
- try {
3326
- return this.ruleInvocationStateUpdate(a, e, this.subruleIdx), t.apply(this, n);
3327
- } catch (e) {
3328
- return this.invokeRuleCatch(e, r, i);
3329
- } finally {
3330
- this.ruleFinallyStateUpdate();
3331
- }
3332
- }, Object.assign(function(...t) {
3333
- this.onBeforeParse(e);
3334
- try {
3335
- return o.apply(this, t);
3336
- } finally {
3337
- this.onAfterParse(e);
3338
- }
3339
- }, {
3340
- ruleName: e,
3341
- originalGrammarAction: t,
3342
- coreRule: o
3343
- });
3344
- }
3345
- invokeRuleCatch(e, t, n) {
3346
- let r = this.RULE_STACK_IDX === 0, i = t && !this.isBackTracking() && this.recoveryEnabled;
3347
- if (Pt(e)) {
3348
- let t = e;
3349
- if (i) {
3350
- let r = this.findReSyncTokenType();
3351
- if (this.isInCurrentRuleReSyncSet(r)) {
3352
- if (t.resyncedTokens = this.reSyncTo(r), this.outputCst) {
3353
- let e = this.CST_STACK[this.CST_STACK.length - 1];
3354
- return e.recoveredNode = !0, e;
3355
- }
3356
- return n(e);
3357
- }
3358
- if (this.outputCst) {
3359
- let e = this.CST_STACK[this.CST_STACK.length - 1];
3360
- e.recoveredNode = !0, t.partialCstResult = e;
3361
- }
3362
- throw t;
3363
- }
3364
- if (r) return this.moveToTerminatedState(), n(e);
3365
- throw t;
3366
- }
3367
- throw e;
3368
- }
3369
- optionInternal(e, t) {
3370
- let n = this.getKeyForAutomaticLookahead(512, t);
3371
- return this.optionInternalLogic(e, t, n);
3372
- }
3373
- optionInternalLogic(e, t, n) {
3374
- let r, i = this.getLaFuncFromCache(n);
3375
- if (typeof e != "function") {
3376
- r = e.DEF;
3377
- let t = e.GATE;
3378
- if (t !== void 0) {
3379
- let e = i;
3380
- i = () => t.call(this) && e.call(this);
3381
- }
3382
- } else r = e;
3383
- if (!0 === i.call(this)) return r.call(this);
3384
- }
3385
- atLeastOneInternal(e, t) {
3386
- let n = this.getKeyForAutomaticLookahead(Ut, e);
3387
- return this.atLeastOneInternalLogic(e, t, n);
3388
- }
3389
- atLeastOneInternalLogic(e, t, n) {
3390
- let r, i = this.getLaFuncFromCache(n);
3391
- if (typeof t != "function") {
3392
- r = t.DEF;
3393
- let e = t.GATE;
3394
- if (e !== void 0) {
3395
- let t = i;
3396
- i = () => e.call(this) && t.call(this);
3397
- }
3398
- } else r = t;
3399
- if (!0 !== i.call(this)) throw this.raiseEarlyExitException(e, Y.REPETITION_MANDATORY, t.ERR_MSG);
3400
- {
3401
- let e = this.doSingleRepetition(r);
3402
- for (; !0 === i.call(this) && !0 === e;) e = this.doSingleRepetition(r);
3403
- }
3404
- this.attemptInRepetitionRecovery(this.atLeastOneInternal, [e, t], i, Ut, e, tt);
3405
- }
3406
- atLeastOneSepFirstInternal(e, t) {
3407
- let n = this.getKeyForAutomaticLookahead(Gt, e);
3408
- this.atLeastOneSepFirstInternalLogic(e, t, n);
3409
- }
3410
- atLeastOneSepFirstInternalLogic(e, t, n) {
3411
- let r = t.DEF, i = t.SEP;
3412
- if (!0 !== this.getLaFuncFromCache(n).call(this)) throw this.raiseEarlyExitException(e, Y.REPETITION_MANDATORY_WITH_SEPARATOR, t.ERR_MSG);
3413
- {
3414
- r.call(this);
3415
- let t = () => this.tokenMatcher(this.LA_FAST(1), i);
3416
- for (; !0 === this.tokenMatcher(this.LA_FAST(1), i);) this.CONSUME(i), r.call(this);
3417
- this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal, [
3418
- e,
3419
- i,
3420
- t,
3421
- r,
3422
- nt
3423
- ], t, Gt, e, nt);
3424
- }
3425
- }
3426
- manyInternal(e, t) {
3427
- let n = this.getKeyForAutomaticLookahead(768, e);
3428
- return this.manyInternalLogic(e, t, n);
3429
- }
3430
- manyInternalLogic(e, t, n) {
3431
- let r, i = this.getLaFuncFromCache(n);
3432
- if (typeof t != "function") {
3433
- r = t.DEF;
3434
- let e = t.GATE;
3435
- if (e !== void 0) {
3436
- let t = i;
3437
- i = () => e.call(this) && t.call(this);
3438
- }
3439
- } else r = t;
3440
- let a = !0;
3441
- for (; !0 === i.call(this) && !0 === a;) a = this.doSingleRepetition(r);
3442
- this.attemptInRepetitionRecovery(this.manyInternal, [e, t], i, 768, e, $e, a);
3443
- }
3444
- manySepFirstInternal(e, t) {
3445
- let n = this.getKeyForAutomaticLookahead(Wt, e);
3446
- this.manySepFirstInternalLogic(e, t, n);
3447
- }
3448
- manySepFirstInternalLogic(e, t, n) {
3449
- let r = t.DEF, i = t.SEP;
3450
- if (!0 === this.getLaFuncFromCache(n).call(this)) {
3451
- r.call(this);
3452
- let t = () => this.tokenMatcher(this.LA_FAST(1), i);
3453
- for (; !0 === this.tokenMatcher(this.LA_FAST(1), i);) this.CONSUME(i), r.call(this);
3454
- this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal, [
3455
- e,
3456
- i,
3457
- t,
3458
- r,
3459
- et
3460
- ], t, Wt, e, et);
3461
- }
3462
- }
3463
- repetitionSepSecondInternal(e, t, n, r, i) {
3464
- for (; n();) this.CONSUME(t), r.call(this);
3465
- this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal, [
3466
- e,
3467
- t,
3468
- n,
3469
- r,
3470
- i
3471
- ], n, Gt, e, i);
3472
- }
3473
- doSingleRepetition(e) {
3474
- let t = this.getLexerPosition();
3475
- return e.call(this), this.getLexerPosition() > t;
3476
- }
3477
- orInternal(e, t) {
3478
- let n = this.getKeyForAutomaticLookahead(256, t), r = Array.isArray(e) ? e : e.DEF, i = this.getLaFuncFromCache(n).call(this, r);
3479
- if (i !== void 0) return r[i].ALT.call(this);
3480
- this.raiseNoAltException(t, e.ERR_MSG);
3481
- }
3482
- ruleFinallyStateUpdate() {
3483
- this.RULE_STACK_IDX--, this.RULE_OCCURRENCE_STACK_IDX--, this.RULE_STACK_IDX >= 0 && (this.currRuleShortName = this.RULE_STACK[this.RULE_STACK_IDX]), this.cstFinallyStateUpdate();
3484
- }
3485
- subruleInternal(e, t, n) {
3486
- let r;
3487
- try {
3488
- let i = n === void 0 ? void 0 : n.ARGS;
3489
- return this.subruleIdx = t, r = e.coreRule.apply(this, i), this.cstPostNonTerminal(r, n !== void 0 && n.LABEL !== void 0 ? n.LABEL : e.ruleName), r;
3490
- } catch (t) {
3491
- throw this.subruleInternalError(t, n, e.ruleName);
3492
- }
3493
- }
3494
- subruleInternalError(e, t, n) {
3495
- throw Pt(e) && e.partialCstResult !== void 0 && (this.cstPostNonTerminal(e.partialCstResult, t !== void 0 && t.LABEL !== void 0 ? t.LABEL : n), delete e.partialCstResult), e;
3496
- }
3497
- consumeInternal(e, t, n) {
3498
- let r;
3499
- try {
3500
- let t = this.LA_FAST(1);
3501
- !0 === this.tokenMatcher(t, e) ? (this.consumeToken(), r = t) : this.consumeInternalError(e, t, n);
3502
- } catch (n) {
3503
- r = this.consumeInternalRecovery(e, t, n);
3504
- }
3505
- return this.cstPostTerminal(n !== void 0 && n.LABEL !== void 0 ? n.LABEL : e.name, r), r;
3506
- }
3507
- consumeInternalError(e, t, n) {
3508
- let r, i = this.LA(0);
3509
- throw r = n !== void 0 && n.ERR_MSG ? n.ERR_MSG : this.errorMessageProvider.buildMismatchTokenMessage({
3510
- expected: e,
3511
- actual: t,
3512
- previous: i,
3513
- ruleName: this.getCurrRuleFullName()
3514
- }), this.SAVE_ERROR(new It(r, t, i));
3515
- }
3516
- consumeInternalRecovery(e, t, n) {
3517
- if (!this.recoveryEnabled || n.name !== "MismatchedTokenException" || this.isBackTracking()) throw n;
3518
- {
3519
- let r = this.getFollowsForInRuleRecovery(e, t);
3520
- try {
3521
- return this.tryInRuleRecovery(e, r);
3522
- } catch (e) {
3523
- throw e.name === "InRuleRecoveryException" ? n : e;
3524
- }
3525
- }
3526
- }
3527
- saveRecogState() {
3528
- let e = this.errors, t = this.RULE_STACK.slice(0, this.RULE_STACK_IDX + 1);
3529
- return {
3530
- errors: e,
3531
- lexerState: this.exportLexerState(),
3532
- RULE_STACK: t,
3533
- CST_STACK: this.CST_STACK
3534
- };
3535
- }
3536
- reloadRecogState(e) {
3537
- this.errors = e.errors, this.importLexerState(e.lexerState);
3538
- let t = e.RULE_STACK;
3539
- for (let e = 0; e < t.length; e++) this.RULE_STACK[e] = t[e];
3540
- this.RULE_STACK_IDX = t.length - 1, this.RULE_STACK_IDX >= 0 && (this.currRuleShortName = this.RULE_STACK[this.RULE_STACK_IDX]);
3541
- }
3542
- ruleInvocationStateUpdate(e, t, n) {
3543
- this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX] = n, this.RULE_STACK[++this.RULE_STACK_IDX] = e, this.currRuleShortName = e, this.cstInvocationStateUpdate(t);
3544
- }
3545
- isBackTracking() {
3546
- return this.isBackTrackingStack.length !== 0;
3547
- }
3548
- getCurrRuleFullName() {
3549
- let e = this.currRuleShortName;
3550
- return this.shortRuleNameToFull[e];
3551
- }
3552
- shortRuleNameToFullName(e) {
3553
- return this.shortRuleNameToFull[e];
3554
- }
3555
- isAtEndOfInput() {
3556
- return this.tokenMatcher(this.LA(1), q);
3557
- }
3558
- reset() {
3559
- this.resetLexerState(), this.subruleIdx = 0, this.currRuleShortName = 0, this.isBackTrackingStack = [], this.errors = [], this.RULE_STACK_IDX = -1, this.RULE_OCCURRENCE_STACK_IDX = -1, this.CST_STACK = [];
3560
- }
3561
- onBeforeParse(e) {
3562
- for (let e = 0; e < this.maxLookahead + 1; e++) this.tokVector.push(Z);
3563
- }
3564
- onAfterParse(e) {
3565
- if (!1 === this.isAtEndOfInput()) {
3566
- let e = this.LA(1), t = this.errorMessageProvider.buildNotAllInputParsedMessage({
3567
- firstRedundant: e,
3568
- ruleName: this.getCurrRuleFullName()
3569
- });
3570
- this.SAVE_ERROR(new Rt(t, e));
3571
- }
3572
- for (; this.tokVector.at(-1) === Z;) this.tokVector.pop();
3573
- }
3574
- },
3575
- class {
3576
- ACTION(e) {
3577
- return e.call(this);
3578
- }
3579
- consume(e, t, n) {
3580
- return this.consumeInternal(t, e, n);
3581
- }
3582
- subrule(e, t, n) {
3583
- return this.subruleInternal(t, e, n);
3584
- }
3585
- option(e, t) {
3586
- return this.optionInternal(t, e);
3587
- }
3588
- or(e, t) {
3589
- return this.orInternal(t, e);
3590
- }
3591
- many(e, t) {
3592
- return this.manyInternal(e, t);
3593
- }
3594
- atLeastOne(e, t) {
3595
- return this.atLeastOneInternal(e, t);
3596
- }
3597
- CONSUME(e, t) {
3598
- return this.consumeInternal(e, 0, t);
3599
- }
3600
- CONSUME1(e, t) {
3601
- return this.consumeInternal(e, 1, t);
3602
- }
3603
- CONSUME2(e, t) {
3604
- return this.consumeInternal(e, 2, t);
3605
- }
3606
- CONSUME3(e, t) {
3607
- return this.consumeInternal(e, 3, t);
3608
- }
3609
- CONSUME4(e, t) {
3610
- return this.consumeInternal(e, 4, t);
3611
- }
3612
- CONSUME5(e, t) {
3613
- return this.consumeInternal(e, 5, t);
3614
- }
3615
- CONSUME6(e, t) {
3616
- return this.consumeInternal(e, 6, t);
3617
- }
3618
- CONSUME7(e, t) {
3619
- return this.consumeInternal(e, 7, t);
3620
- }
3621
- CONSUME8(e, t) {
3622
- return this.consumeInternal(e, 8, t);
3623
- }
3624
- CONSUME9(e, t) {
3625
- return this.consumeInternal(e, 9, t);
3626
- }
3627
- SUBRULE(e, t) {
3628
- return this.subruleInternal(e, 0, t);
3629
- }
3630
- SUBRULE1(e, t) {
3631
- return this.subruleInternal(e, 1, t);
3632
- }
3633
- SUBRULE2(e, t) {
3634
- return this.subruleInternal(e, 2, t);
3635
- }
3636
- SUBRULE3(e, t) {
3637
- return this.subruleInternal(e, 3, t);
3638
- }
3639
- SUBRULE4(e, t) {
3640
- return this.subruleInternal(e, 4, t);
3641
- }
3642
- SUBRULE5(e, t) {
3643
- return this.subruleInternal(e, 5, t);
3644
- }
3645
- SUBRULE6(e, t) {
3646
- return this.subruleInternal(e, 6, t);
3647
- }
3648
- SUBRULE7(e, t) {
3649
- return this.subruleInternal(e, 7, t);
3650
- }
3651
- SUBRULE8(e, t) {
3652
- return this.subruleInternal(e, 8, t);
3653
- }
3654
- SUBRULE9(e, t) {
3655
- return this.subruleInternal(e, 9, t);
3656
- }
3657
- OPTION(e) {
3658
- return this.optionInternal(e, 0);
3659
- }
3660
- OPTION1(e) {
3661
- return this.optionInternal(e, 1);
3662
- }
3663
- OPTION2(e) {
3664
- return this.optionInternal(e, 2);
3665
- }
3666
- OPTION3(e) {
3667
- return this.optionInternal(e, 3);
3668
- }
3669
- OPTION4(e) {
3670
- return this.optionInternal(e, 4);
3671
- }
3672
- OPTION5(e) {
3673
- return this.optionInternal(e, 5);
3674
- }
3675
- OPTION6(e) {
3676
- return this.optionInternal(e, 6);
3677
- }
3678
- OPTION7(e) {
3679
- return this.optionInternal(e, 7);
3680
- }
3681
- OPTION8(e) {
3682
- return this.optionInternal(e, 8);
3683
- }
3684
- OPTION9(e) {
3685
- return this.optionInternal(e, 9);
3686
- }
3687
- OR(e) {
3688
- return this.orInternal(e, 0);
3689
- }
3690
- OR1(e) {
3691
- return this.orInternal(e, 1);
3692
- }
3693
- OR2(e) {
3694
- return this.orInternal(e, 2);
3695
- }
3696
- OR3(e) {
3697
- return this.orInternal(e, 3);
3698
- }
3699
- OR4(e) {
3700
- return this.orInternal(e, 4);
3701
- }
3702
- OR5(e) {
3703
- return this.orInternal(e, 5);
3704
- }
3705
- OR6(e) {
3706
- return this.orInternal(e, 6);
3707
- }
3708
- OR7(e) {
3709
- return this.orInternal(e, 7);
3710
- }
3711
- OR8(e) {
3712
- return this.orInternal(e, 8);
3713
- }
3714
- OR9(e) {
3715
- return this.orInternal(e, 9);
3716
- }
3717
- MANY(e) {
3718
- this.manyInternal(0, e);
3719
- }
3720
- MANY1(e) {
3721
- this.manyInternal(1, e);
3722
- }
3723
- MANY2(e) {
3724
- this.manyInternal(2, e);
3725
- }
3726
- MANY3(e) {
3727
- this.manyInternal(3, e);
3728
- }
3729
- MANY4(e) {
3730
- this.manyInternal(4, e);
3731
- }
3732
- MANY5(e) {
3733
- this.manyInternal(5, e);
3734
- }
3735
- MANY6(e) {
3736
- this.manyInternal(6, e);
3737
- }
3738
- MANY7(e) {
3739
- this.manyInternal(7, e);
3740
- }
3741
- MANY8(e) {
3742
- this.manyInternal(8, e);
3743
- }
3744
- MANY9(e) {
3745
- this.manyInternal(9, e);
3746
- }
3747
- MANY_SEP(e) {
3748
- this.manySepFirstInternal(0, e);
3749
- }
3750
- MANY_SEP1(e) {
3751
- this.manySepFirstInternal(1, e);
3752
- }
3753
- MANY_SEP2(e) {
3754
- this.manySepFirstInternal(2, e);
3755
- }
3756
- MANY_SEP3(e) {
3757
- this.manySepFirstInternal(3, e);
3758
- }
3759
- MANY_SEP4(e) {
3760
- this.manySepFirstInternal(4, e);
3761
- }
3762
- MANY_SEP5(e) {
3763
- this.manySepFirstInternal(5, e);
3764
- }
3765
- MANY_SEP6(e) {
3766
- this.manySepFirstInternal(6, e);
3767
- }
3768
- MANY_SEP7(e) {
3769
- this.manySepFirstInternal(7, e);
3770
- }
3771
- MANY_SEP8(e) {
3772
- this.manySepFirstInternal(8, e);
3773
- }
3774
- MANY_SEP9(e) {
3775
- this.manySepFirstInternal(9, e);
3776
- }
3777
- AT_LEAST_ONE(e) {
3778
- this.atLeastOneInternal(0, e);
3779
- }
3780
- AT_LEAST_ONE1(e) {
3781
- return this.atLeastOneInternal(1, e);
3782
- }
3783
- AT_LEAST_ONE2(e) {
3784
- this.atLeastOneInternal(2, e);
3785
- }
3786
- AT_LEAST_ONE3(e) {
3787
- this.atLeastOneInternal(3, e);
3788
- }
3789
- AT_LEAST_ONE4(e) {
3790
- this.atLeastOneInternal(4, e);
3791
- }
3792
- AT_LEAST_ONE5(e) {
3793
- this.atLeastOneInternal(5, e);
3794
- }
3795
- AT_LEAST_ONE6(e) {
3796
- this.atLeastOneInternal(6, e);
3797
- }
3798
- AT_LEAST_ONE7(e) {
3799
- this.atLeastOneInternal(7, e);
3800
- }
3801
- AT_LEAST_ONE8(e) {
3802
- this.atLeastOneInternal(8, e);
3803
- }
3804
- AT_LEAST_ONE9(e) {
3805
- this.atLeastOneInternal(9, e);
3806
- }
3807
- AT_LEAST_ONE_SEP(e) {
3808
- this.atLeastOneSepFirstInternal(0, e);
3809
- }
3810
- AT_LEAST_ONE_SEP1(e) {
3811
- this.atLeastOneSepFirstInternal(1, e);
3812
- }
3813
- AT_LEAST_ONE_SEP2(e) {
3814
- this.atLeastOneSepFirstInternal(2, e);
3815
- }
3816
- AT_LEAST_ONE_SEP3(e) {
3817
- this.atLeastOneSepFirstInternal(3, e);
3818
- }
3819
- AT_LEAST_ONE_SEP4(e) {
3820
- this.atLeastOneSepFirstInternal(4, e);
3821
- }
3822
- AT_LEAST_ONE_SEP5(e) {
3823
- this.atLeastOneSepFirstInternal(5, e);
3824
- }
3825
- AT_LEAST_ONE_SEP6(e) {
3826
- this.atLeastOneSepFirstInternal(6, e);
3827
- }
3828
- AT_LEAST_ONE_SEP7(e) {
3829
- this.atLeastOneSepFirstInternal(7, e);
3830
- }
3831
- AT_LEAST_ONE_SEP8(e) {
3832
- this.atLeastOneSepFirstInternal(8, e);
3833
- }
3834
- AT_LEAST_ONE_SEP9(e) {
3835
- this.atLeastOneSepFirstInternal(9, e);
3836
- }
3837
- RULE(e, t, n = dn) {
3838
- if (this.definedRulesNames.includes(e)) {
3839
- let t = {
3840
- message: J.buildDuplicateRuleNameError({
3841
- topLevelRule: e,
3842
- grammarName: this.className
3843
- }),
3844
- type: Q.DUPLICATE_RULE_NAME,
3845
- ruleName: e
3846
- };
3847
- this.definitionErrors.push(t);
3848
- }
3849
- this.definedRulesNames.push(e);
3850
- let r = this.defineRule(e, t, n);
3851
- return this[e] = r, r;
3852
- }
3853
- OVERRIDE_RULE(e, t, n = dn) {
3854
- let r = function(e, t, n) {
3855
- let r = [], i;
3856
- return t.includes(e) || (i = `Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `, r.push({
3857
- message: i,
3858
- type: Q.INVALID_RULE_OVERRIDE,
3859
- ruleName: e
3860
- })), r;
3861
- }(e, this.definedRulesNames, this.className);
3862
- this.definitionErrors = this.definitionErrors.concat(r);
3863
- let i = this.defineRule(e, t, n);
3864
- return this[e] = i, i;
3865
- }
3866
- BACKTRACK(e, t) {
3867
- let n = e.coreRule ?? e;
3868
- return function() {
3869
- this.isBackTrackingStack.push(1);
3870
- let e = this.saveRecogState();
3871
- try {
3872
- return n.apply(this, t), !0;
3873
- } catch (e) {
3874
- if (Pt(e)) return !1;
3875
- throw e;
3876
- } finally {
3877
- this.reloadRecogState(e), this.isBackTrackingStack.pop();
3878
- }
3879
- };
3880
- }
3881
- getGAstProductions() {
3882
- return this.gastProductionsCache;
3883
- }
3884
- getSerializedGastProductions() {
3885
- return Object.values(this.gastProductionsCache).map(_);
3886
- }
3887
- },
3888
- class {
3889
- initErrorHandler(e) {
3890
- this._errors = [], this.errorMessageProvider = Object.hasOwn(e, "errorMessageProvider") ? e.errorMessageProvider : $.errorMessageProvider;
3891
- }
3892
- SAVE_ERROR(e) {
3893
- if (Pt(e)) return e.context = {
3894
- ruleStack: this.getHumanReadableRuleStack(),
3895
- ruleOccurrenceStack: this.RULE_OCCURRENCE_STACK.slice(0, this.RULE_OCCURRENCE_STACK_IDX + 1)
3896
- }, this._errors.push(e), e;
3897
- throw Error("Trying to save an Error which is not a RecognitionException");
3898
- }
3899
- get errors() {
3900
- return [...this._errors];
3901
- }
3902
- set errors(e) {
3903
- this._errors = e;
3904
- }
3905
- raiseEarlyExitException(e, t, n) {
3906
- let r = this.getCurrRuleFullName(), i = ht(e, this.getGAstProductions()[r], t, this.maxLookahead)[0], a = [];
3907
- for (let e = 1; e <= this.maxLookahead; e++) a.push(this.LA(e));
3908
- let o = this.errorMessageProvider.buildEarlyExitMessage({
3909
- expectedIterationPaths: i,
3910
- actual: a,
3911
- previous: this.LA(0),
3912
- customUserDescription: n,
3913
- ruleName: r
3914
- });
3915
- throw this.SAVE_ERROR(new zt(o, this.LA(1), this.LA(0)));
3916
- }
3917
- raiseNoAltException(e, t) {
3918
- let n = this.getCurrRuleFullName(), r = mt(e, this.getGAstProductions()[n], this.maxLookahead), i = [];
3919
- for (let e = 1; e <= this.maxLookahead; e++) i.push(this.LA(e));
3920
- let a = this.LA(0), o = this.errorMessageProvider.buildNoViableAltMessage({
3921
- expectedPathsPerAlt: r,
3922
- actual: i,
3923
- previous: a,
3924
- customUserDescription: t,
3925
- ruleName: this.getCurrRuleFullName()
3926
- });
3927
- throw this.SAVE_ERROR(new Lt(o, this.LA(1), a));
3928
- }
3929
- },
3930
- class {
3931
- initGastRecorder(e) {
3932
- this.recordingProdStack = [], this.RECORDING_PHASE = !1;
3933
- }
3934
- enableRecording() {
3935
- this.RECORDING_PHASE = !0, this.TRACE_INIT("Enable Recording", () => {
3936
- for (let e = 0; e < 10; e++) {
3937
- let t = e > 0 ? e : "";
3938
- this[`CONSUME${t}`] = function(t, n) {
3939
- return this.consumeInternalRecord(t, e, n);
3940
- }, this[`SUBRULE${t}`] = function(t, n) {
3941
- return this.subruleInternalRecord(t, e, n);
3942
- }, this[`OPTION${t}`] = function(t) {
3943
- return this.optionInternalRecord(t, e);
3944
- }, this[`OR${t}`] = function(t) {
3945
- return this.orInternalRecord(t, e);
3946
- }, this[`MANY${t}`] = function(t) {
3947
- this.manyInternalRecord(e, t);
3948
- }, this[`MANY_SEP${t}`] = function(t) {
3949
- this.manySepFirstInternalRecord(e, t);
3950
- }, this[`AT_LEAST_ONE${t}`] = function(t) {
3951
- this.atLeastOneInternalRecord(e, t);
3952
- }, this[`AT_LEAST_ONE_SEP${t}`] = function(t) {
3953
- this.atLeastOneSepFirstInternalRecord(e, t);
3954
- };
3955
- }
3956
- this.consume = function(e, t, n) {
3957
- return this.consumeInternalRecord(t, e, n);
3958
- }, this.subrule = function(e, t, n) {
3959
- return this.subruleInternalRecord(t, e, n);
3960
- }, this.option = function(e, t) {
3961
- return this.optionInternalRecord(t, e);
3962
- }, this.or = function(e, t) {
3963
- return this.orInternalRecord(t, e);
3964
- }, this.many = function(e, t) {
3965
- this.manyInternalRecord(e, t);
3966
- }, this.atLeastOne = function(e, t) {
3967
- this.atLeastOneInternalRecord(e, t);
3968
- }, this.ACTION = this.ACTION_RECORD, this.BACKTRACK = this.BACKTRACK_RECORD, this.LA = this.LA_RECORD;
3969
- });
3970
- }
3971
- disableRecording() {
3972
- this.RECORDING_PHASE = !1, this.TRACE_INIT("Deleting Recording methods", () => {
3973
- let e = this;
3974
- for (let t = 0; t < 10; t++) {
3975
- let n = t > 0 ? t : "";
3976
- delete e[`CONSUME${n}`], delete e[`SUBRULE${n}`], delete e[`OPTION${n}`], delete e[`OR${n}`], delete e[`MANY${n}`], delete e[`MANY_SEP${n}`], delete e[`AT_LEAST_ONE${n}`], delete e[`AT_LEAST_ONE_SEP${n}`];
3977
- }
3978
- delete e.consume, delete e.subrule, delete e.option, delete e.or, delete e.many, delete e.atLeastOne, delete e.ACTION, delete e.BACKTRACK, delete e.LA;
3979
- });
3980
- }
3981
- ACTION_RECORD(e) {}
3982
- BACKTRACK_RECORD(e, t) {
3983
- return () => !0;
3984
- }
3985
- LA_RECORD(e) {
3986
- return Z;
3987
- }
3988
- topLevelRuleRecord(e, t) {
3989
- try {
3990
- let n = new c({
3991
- definition: [],
3992
- name: e
3993
- });
3994
- return n.name = e, this.recordingProdStack.push(n), t.call(this), this.recordingProdStack.pop(), n;
3995
- } catch (e) {
3996
- if (!0 !== e.KNOWN_RECORDER_ERROR) try {
3997
- e.message += "\n This error was thrown during the \"grammar recording phase\" For more info see:\n https://chevrotain.io/docs/guide/internals.html#grammar-recording";
3998
- } catch {
3999
- throw e;
4000
- }
4001
- throw e;
4002
- }
4003
- }
4004
- optionInternalRecord(e, t) {
4005
- return X.call(this, u, e, t);
4006
- }
4007
- atLeastOneInternalRecord(e, t) {
4008
- X.call(this, d, t, e);
4009
- }
4010
- atLeastOneSepFirstInternalRecord(e, t) {
4011
- X.call(this, f, t, e, nn);
4012
- }
4013
- manyInternalRecord(e, t) {
4014
- X.call(this, p, t, e);
4015
- }
4016
- manySepFirstInternalRecord(e, t) {
4017
- X.call(this, m, t, e, nn);
4018
- }
4019
- orInternalRecord(e, t) {
4020
- return cn.call(this, e, t);
4021
- }
4022
- subruleInternalRecord(e, t, n) {
4023
- if (un(t), !e || !Object.hasOwn(e, "ruleName")) {
4024
- let n = /* @__PURE__ */ Error(`<SUBRULE${ln(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);
4025
- throw n.KNOWN_RECORDER_ERROR = !0, n;
4026
- }
4027
- let r = this.recordingProdStack.at(-1), i = e.ruleName, a = new s({
4028
- idx: t,
4029
- nonTerminalName: i,
4030
- label: n?.LABEL,
4031
- referencedRule: void 0
4032
- });
4033
- return r.definition.push(a), this.outputCst ? sn : tn;
4034
- }
4035
- consumeInternalRecord(e, t, n) {
4036
- if (un(t), !Me(e)) {
4037
- let n = /* @__PURE__ */ Error(`<CONSUME${ln(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);
4038
- throw n.KNOWN_RECORDER_ERROR = !0, n;
4039
- }
4040
- let r = this.recordingProdStack.at(-1), i = new g({
4041
- idx: t,
4042
- terminalType: e,
4043
- label: n?.LABEL
4044
- });
4045
- return r.definition.push(i), on;
4046
- }
4047
- },
4048
- class {
4049
- initPerformanceTracer(e) {
4050
- if (Object.hasOwn(e, "traceInitPerf")) {
4051
- let t = e.traceInitPerf, n = typeof t == "number";
4052
- this.traceInitMaxIdent = n ? t : Infinity, this.traceInitPerf = n ? t > 0 : t;
4053
- } else this.traceInitMaxIdent = 0, this.traceInitPerf = $.traceInitPerf;
4054
- this.traceInitIndent = -1;
4055
- }
4056
- TRACE_INIT(e, t) {
4057
- if (!0 === this.traceInitPerf) {
4058
- this.traceInitIndent++;
4059
- let n = Array(this.traceInitIndent + 1).join(" ");
4060
- this.traceInitIndent < this.traceInitMaxIdent && console.log(`${n}--\x3e <${e}>`);
4061
- let { time: r, value: a } = i(t), o = r > 10 ? console.warn : console.log;
4062
- return this.traceInitIndent < this.traceInitMaxIdent && o(`${n}<-- <${e}> time: ${r}ms`), this.traceInitIndent--, a;
4063
- }
4064
- return t();
4065
- }
4066
- }
4067
- ].forEach((e) => {
4068
- let t = e.prototype;
4069
- Object.getOwnPropertyNames(t).forEach((n) => {
4070
- if (n === "constructor") return;
4071
- let r = Object.getOwnPropertyDescriptor(t, n);
4072
- r && (r.get || r.set) ? Object.defineProperty(fn.prototype, n, r) : fn.prototype[n] = e.prototype[n];
4073
- });
4074
- });
4075
- var mn = class extends pn {
4076
- constructor(e, t = $) {
4077
- let n = Object.assign({}, t);
4078
- n.outputCst = !1, super(e, n);
4079
- }
4080
- }, hn = class n {
4081
- static shared(t) {
4082
- let r = t?.locale ?? e, i = t?.maxColumn ?? yn, a = t?.maxRow ?? bn, o = vn.get(r);
4083
- o || (o = /* @__PURE__ */ new Map(), vn.set(r, o));
4084
- let s = `${i}:${a}`, c = o.get(s);
4085
- return c || (c = new n({
4086
- locale: r,
4087
- maxColumn: i,
4088
- maxRow: a
4089
- }), o.set(s, c)), c;
4090
- }
4091
- constructor(t) {
4092
- let n = t?.maxColumn ?? yn, r = t?.maxRow ?? bn, i = t?.locale ?? e;
4093
- this._locale = i, this._maxColumn = n, this._maxRow = r;
4094
- let { separatorFunction: a, separatorColumn: o, separatorRow: s, separatorDecimal: c } = i.separators;
4095
- if (o === s) throw Error(`FormulaLexer: separatorColumn and separatorRow must differ (both '${o}')`);
4096
- let l = K({
4097
- name: "WhiteSpace",
4098
- pattern: /\s+/,
4099
- group: W.SKIPPED
4100
- }), u = K({
4101
- name: "StringToken",
4102
- pattern: /"(""|[^"])*"/
4103
- }), d = K({
4104
- name: "FunctionToken",
4105
- pattern: /[a-zA-Z_\u007F-\uFFFF]+[a-zA-Z0-9_.\u007F-\uFFFF]*(?=\()/
4106
- }), f = K({
4107
- name: "TableReference",
4108
- pattern: { exec: wn },
4109
- line_breaks: !1,
4110
- start_chars_hint: _n
4111
- }), p = K({
4112
- name: "BracketedString",
4113
- pattern: { exec: En },
4114
- line_breaks: !1,
4115
- start_chars_hint: [91],
4116
- longer_alt: [f, u]
4117
- }), m = (e) => (e ?? []).map((e) => e?.trim()).filter(Boolean).map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).map((e) => e + "|").join(""), h = K({
4118
- name: "LiteralError",
4119
- pattern: RegExp(m(i.errorLiterals) + "#PARSE!|#NULL!|#DIV\\/0!|#VALUE!|#NUM!|#FIELD!|#N\\/A|#GETTING_DATA|#SPILL!|#CONNECT!|#BLOCKED!|#UNKNOWN!|#CALC!|#BUSY!|#PYTHON!|#TIMEOUT!")
4120
- }), g = K({
4121
- name: "RefError",
4122
- pattern: RegExp(m(i.errorRefs) + "#REF!|#NAME\\?")
4123
- }), _ = K({
4124
- name: "SingleQuotedString",
4125
- pattern: /'(''|[^'])*'/
4126
- }), v = K({
4127
- name: "SheetQuoted",
4128
- pattern: /'(?:''|[^'])*?'!/
4129
- }), y = K({
4130
- name: "Sheet",
4131
- pattern: /[A-Za-z_.\d\u007F-\uFFFF]*!/
4132
- }), b = /[a-zA-Z_\\\u007F-\uFFFF][a-zA-Z0-9_.?\\\u007F-\uFFFF]*:?/y, x = K({
4133
- name: "NamedToken",
4134
- pattern: { exec: (e, t) => {
4135
- b.lastIndex = t;
4136
- let n = b.exec(e);
4137
- if (!n) return null;
4138
- let r = n[0], i = r.indexOf(".:");
4139
- return i === -1 ? r.endsWith(":") && (r = r.slice(0, -1)) : r = r.substring(0, i), [r];
4140
- } },
4141
- line_breaks: !1,
4142
- start_chars_hint: _n
4143
- }), S = K({
4144
- name: "Cell",
4145
- pattern: { exec: Cn(n, r) },
4146
- line_breaks: !1,
4147
- start_chars_hint: [36, ...gn],
4148
- longer_alt: x
4149
- }), C = K({
4150
- name: "Column",
4151
- pattern: { exec: Sn(n) },
4152
- line_breaks: !1,
4153
- start_chars_hint: [36, ...gn],
4154
- longer_alt: x
4155
- }), w = K({
4156
- name: "AbsRow",
4157
- pattern: /[$][0-9]+/
4158
- }), T = c === "." ? "\\." : c, E = K({
4159
- name: "NumberToken",
4160
- pattern: RegExp(`[0-9]+${T}(?!:)[0-9]*([eE][+-]?[0-9]+|\\*\\*[+-]?[0-9]+)?|${T}[0-9]+([eE][+-]?[0-9]+|\\*\\*[+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+`)
4161
- }), D = K({
4162
- name: "ScientificDigit",
4163
- pattern: /[0-9]+\*\*[+-]?[0-9]+/
4164
- }), O = K({
4165
- name: "DigitToken",
4166
- pattern: /[0-9]+/
4167
- }), k = ["TRUE", "FALSE"];
4168
- for (let e of [i.booleanTrue, i.booleanFalse]) {
4169
- let t = e?.trim();
4170
- t && !k.some((e) => e.toLowerCase() === t.toLowerCase()) && k.push(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
4171
- }
4172
- let A = K({
4173
- name: "BooleanToken",
4174
- pattern: new RegExp(k.join("|"), "i")
4175
- }), j = K({
4176
- name: "ArgSeparator",
4177
- pattern: Tn(a)
4178
- }), M = K({
4179
- name: "ColSeparator",
4180
- pattern: Tn(o)
4181
- }), N = K({
4182
- name: "RowSeparator",
4183
- pattern: Tn(s)
4184
- }), P = K({
4185
- name: "RangeOp",
4186
- pattern: /:/
4187
- }), ee = K({
4188
- name: "RangeTrimFullOp",
4189
- pattern: /\.:\./
4190
- }), te = K({
4191
- name: "RangeTrimLeadingOp",
4192
- pattern: /\.:/
4193
- }), F = K({
4194
- name: "RangeTrimTrailingOp",
4195
- pattern: /:\./
4196
- }), ne = K({
4197
- name: "OpenParen",
4198
- pattern: /\(/
4199
- }), I = K({
4200
- name: "CloseParen",
4201
- pattern: /\)/
4202
- }), L = K({
4203
- name: "OpenCurlyParen",
4204
- pattern: /{/
4205
- }), re = K({
4206
- name: "CloseCurlyParen",
4207
- pattern: /}/
4208
- }), ie = K({
4209
- name: "QuoteS",
4210
- pattern: /'/
4211
- }), ae = K({
4212
- name: "MulOp",
4213
- pattern: /\*(?!\*)/
4214
- }), oe = K({
4215
- name: "PlusOp",
4216
- pattern: /\+/
4217
- }), se = K({
4218
- name: "DivOp",
4219
- pattern: /\//
4220
- }), ce = K({
4221
- name: "MinOp",
4222
- pattern: /-/
4223
- }), le = K({
4224
- name: "ImplicitIntersectOp",
4225
- pattern: /@/
4226
- }), ue = K({
4227
- name: "ConcatOp",
4228
- pattern: /&/
4229
- }), de = K({
4230
- name: "ExOp",
4231
- pattern: /\^/
4232
- }), fe = K({
4233
- name: "PercentOp",
4234
- pattern: /%/
4235
- }), pe = K({
4236
- name: "ArrayAnchorOp",
4237
- pattern: /#/,
4238
- longer_alt: [h, g]
4239
- }), R = K({
4240
- name: "GtOp",
4241
- pattern: />/
4242
- }), me = K({
4243
- name: "EqOp",
4244
- pattern: /=/
4245
- }), he = K({
4246
- name: "LtOp",
4247
- pattern: /</
4248
- }), ge = [
4249
- l,
4250
- u,
4251
- v,
4252
- _,
4253
- y,
4254
- d,
4255
- f,
4256
- p,
4257
- h,
4258
- g,
4259
- j,
4260
- ...o === a ? [] : [M],
4261
- N,
4262
- ee,
4263
- te,
4264
- F,
4265
- P,
4266
- S,
4267
- A,
4268
- C,
4269
- w,
4270
- E,
4271
- D,
4272
- O,
4273
- pe,
4274
- le,
4275
- x,
4276
- ne,
4277
- I,
4278
- L,
4279
- re,
4280
- ie,
4281
- ae,
4282
- oe,
4283
- se,
4284
- ce,
4285
- ue,
4286
- de,
4287
- fe,
4288
- K({
4289
- name: "NeqOp",
4290
- pattern: /<>/
4291
- }),
4292
- K({
4293
- name: "GteOp",
4294
- pattern: />=/
4295
- }),
4296
- K({
4297
- name: "LteOp",
4298
- pattern: /<=/
4299
- }),
4300
- R,
4301
- me,
4302
- he
4303
- ];
4304
- this._lexer = new W(ge, { ensureOptimizations: !0 });
4305
- let _e = {};
4306
- ge.forEach((e) => {
4307
- _e[e.name] = e;
4308
- }), o === a && (_e.ColSeparator = j), this._vocabulary = _e;
4309
- }
4310
- tokenize(e, n = !0) {
4311
- let r = this._lexer.tokenize(e);
4312
- if (n && r.errors.length > 0) {
4313
- let n = r.errors[0], i = n.line, a = n.column, o = e.substr(n.offset, n.length || 1), s = o ? `Unexpected character '${o}'` : n.message;
4314
- throw new t.Parse(s, {
4315
- line: i,
4316
- column: a,
4317
- offset: n.offset,
4318
- length: n.length
4319
- });
4320
- }
4321
- return r;
4322
- }
4323
- getVocabulary() {
4324
- return this._vocabulary;
4325
- }
4326
- getLocale() {
4327
- return this._locale;
4328
- }
4329
- getMaxColumn() {
4330
- return this._maxColumn;
4331
- }
4332
- getMaxRow() {
4333
- return this._maxRow;
4334
- }
4335
- getSeparators() {
4336
- return this._locale.separators;
4337
- }
4338
- }, gn = (() => {
4339
- let e = [];
4340
- for (let t = 65; t <= 90; t++) e.push(t);
4341
- for (let t = 97; t <= 122; t++) e.push(t);
4342
- for (let t = 48; t <= 57; t++) e.push(t);
4343
- return e;
4344
- })().filter((e) => e < 48 || e > 57), _n = (() => {
4345
- let e = [
4346
- ...gn,
4347
- 95,
4348
- 92
4349
- ];
4350
- for (let t = 127; t <= 65535; t++) e.push(t);
4351
- return e;
4352
- })(), vn = /* @__PURE__ */ new WeakMap(), yn = 16384, bn = 1048576;
4353
- function xn(e, t, n) {
4354
- let r = 0;
4355
- for (let i = t; i < n; i++) {
4356
- let t = e.charCodeAt(i);
4357
- r = 26 * r + (t >= 97 ? t - 96 : t - 64);
4358
- }
4359
- return r;
4360
- }
4361
- function Sn(e) {
4362
- return (t, n) => {
4363
- let r = n;
4364
- t.charCodeAt(r) === 36 && r++;
4365
- let i = r;
4366
- for (; r < t.length && r - i < 3;) {
4367
- let e = t.charCodeAt(r);
4368
- if (!(e >= 65 && e <= 90 || e >= 97 && e <= 122)) break;
4369
- r++;
4370
- }
4371
- if (r - i === 0 || xn(t, i, r) > e) return null;
4372
- if (r < t.length) {
4373
- let e = t.charCodeAt(r);
4374
- if (e >= 48 && e <= 57) return null;
4375
- }
4376
- return [t.substring(n, r)];
4377
- };
4378
- }
4379
- function Cn(e, t) {
4380
- return (n, r) => {
4381
- let i = r;
4382
- n.charCodeAt(i) === 36 && i++;
4383
- let a = i;
4384
- for (; i < n.length && i - a < 3;) {
4385
- let e = n.charCodeAt(i);
4386
- if (!(e >= 65 && e <= 90 || e >= 97 && e <= 122)) break;
4387
- i++;
4388
- }
4389
- if (i - a === 0 || xn(n, a, i) > e) return null;
4390
- i < n.length && n.charCodeAt(i) === 36 && i++;
4391
- let o = i;
4392
- if (i >= n.length) return null;
4393
- let s = n.charCodeAt(i);
4394
- if (s < 49 || s > 57) return null;
4395
- for (i++; i < n.length;) {
4396
- let e = n.charCodeAt(i);
4397
- if (!(e >= 48 && e <= 57)) break;
4398
- i++;
4399
- }
4400
- return parseInt(n.substring(o, i), 10) > t ? null : [n.substring(r, i)];
4401
- };
4402
- }
4403
- function wn(e, t) {
4404
- let n = e.charCodeAt(t);
4405
- if (!(n >= 65 && n <= 90 || n >= 97 && n <= 122 || n === 95 || n >= 127 && n <= 65535)) return null;
4406
- let r = t + 1;
4407
- for (; r < e.length;) {
4408
- let t = e.charCodeAt(r);
4409
- if (!(t >= 65 && t <= 90 || t >= 97 && t <= 122 || t >= 48 && t <= 57 || t === 95 || t === 46 || t >= 127 && t <= 65535)) break;
4410
- r++;
4411
- }
4412
- if (r >= e.length || e.charCodeAt(r) !== 91) return null;
4413
- let i = 0;
4414
- for (; r < e.length;) {
4415
- let n = e.charCodeAt(r);
4416
- if (n === 91) i++;
4417
- else if (n === 93 && (i--, i === 0)) return [e.substring(t, r + 1)];
4418
- r++;
4419
- }
4420
- return null;
4421
- }
4422
- function Tn(e) {
4423
- return new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
4424
- }
4425
- function En(e, t) {
4426
- if (e.charCodeAt(t) !== 91) return null;
4427
- let n = 0, r = t;
4428
- for (; r < e.length;) {
4429
- let i = e.charCodeAt(r);
4430
- if (i === 91) n++;
4431
- else if (i === 93 && (n--, n === 0)) return [e.substring(t, r + 1)];
4432
- r++;
4433
- }
4434
- return null;
4435
- }
4436
- export { K as a, q as i, mn as n, W as o, qe as r, hn as t };