@forgecharts/sdk 1.1.27 → 1.1.28
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.
- package/dist/__tests__/backwardCompatibility.test.d.ts +14 -0
- package/dist/__tests__/backwardCompatibility.test.d.ts.map +1 -0
- package/dist/__tests__/backwardCompatibility.test.js +159 -0
- package/dist/__tests__/backwardCompatibility.test.js.map +1 -0
- package/dist/__tests__/candleInvariant.test.d.ts +20 -0
- package/dist/__tests__/candleInvariant.test.d.ts.map +1 -0
- package/dist/__tests__/candleInvariant.test.js +415 -0
- package/dist/__tests__/candleInvariant.test.js.map +1 -0
- package/dist/__tests__/public-api-surface.d.ts +13 -0
- package/dist/__tests__/public-api-surface.d.ts.map +1 -0
- package/{src/__tests__/public-api-surface.ts → dist/__tests__/public-api-surface.js} +4 -42
- package/dist/__tests__/public-api-surface.js.map +1 -0
- package/dist/__tests__/timeframeBoundary.test.d.ts +17 -0
- package/dist/__tests__/timeframeBoundary.test.d.ts.map +1 -0
- package/dist/__tests__/timeframeBoundary.test.js +452 -0
- package/dist/__tests__/timeframeBoundary.test.js.map +1 -0
- package/dist/api/DrawingManager.d.ts +20 -0
- package/dist/api/DrawingManager.d.ts.map +1 -0
- package/dist/api/DrawingManager.js +190 -0
- package/dist/api/DrawingManager.js.map +1 -0
- package/dist/api/EventBus.d.ts +19 -0
- package/dist/api/EventBus.d.ts.map +1 -0
- package/dist/api/EventBus.js +44 -0
- package/dist/api/EventBus.js.map +1 -0
- package/dist/api/IndicatorDAG.d.ts +85 -0
- package/dist/api/IndicatorDAG.d.ts.map +1 -0
- package/dist/api/IndicatorDAG.js +316 -0
- package/dist/api/IndicatorDAG.js.map +1 -0
- package/dist/api/IndicatorRegistry.d.ts +22 -0
- package/dist/api/IndicatorRegistry.d.ts.map +1 -0
- package/dist/api/IndicatorRegistry.js +39 -0
- package/dist/api/IndicatorRegistry.js.map +1 -0
- package/dist/api/LayoutManager.d.ts +30 -0
- package/dist/api/LayoutManager.d.ts.map +1 -0
- package/dist/api/LayoutManager.js +51 -0
- package/dist/api/LayoutManager.js.map +1 -0
- package/dist/api/PaneManager.d.ts +42 -0
- package/dist/api/PaneManager.d.ts.map +1 -0
- package/dist/api/PaneManager.js +119 -0
- package/dist/api/PaneManager.js.map +1 -0
- package/dist/api/ReferenceAPI.d.ts +78 -0
- package/dist/api/ReferenceAPI.d.ts.map +1 -0
- package/dist/api/ReferenceAPI.js +153 -0
- package/dist/api/ReferenceAPI.js.map +1 -0
- package/dist/api/TChart.d.ts +345 -0
- package/dist/api/TChart.d.ts.map +1 -0
- package/dist/api/TChart.js +765 -0
- package/dist/api/TChart.js.map +1 -0
- package/{src/api/createChart.ts → dist/api/createChart.d.ts} +2 -7
- package/dist/api/createChart.d.ts.map +1 -0
- package/dist/api/createChart.js +42 -0
- package/dist/api/createChart.js.map +1 -0
- package/dist/api/drawing tools/fib gann menu/fibRetracement.d.ts +4 -0
- package/dist/api/drawing tools/fib gann menu/fibRetracement.d.ts.map +1 -0
- package/dist/api/drawing tools/fib gann menu/fibRetracement.js +22 -0
- package/dist/api/drawing tools/fib gann menu/fibRetracement.js.map +1 -0
- package/dist/api/drawing tools/lines menu/crossLine.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/crossLine.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/crossLine.js +16 -0
- package/dist/api/drawing tools/lines menu/crossLine.js.map +1 -0
- package/dist/api/drawing tools/lines menu/disjointChannel.d.ts +17 -0
- package/dist/api/drawing tools/lines menu/disjointChannel.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/disjointChannel.js +59 -0
- package/dist/api/drawing tools/lines menu/disjointChannel.js.map +1 -0
- package/dist/api/drawing tools/lines menu/extendedLine.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/extendedLine.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/extendedLine.js +17 -0
- package/dist/api/drawing tools/lines menu/extendedLine.js.map +1 -0
- package/dist/api/drawing tools/lines menu/flatTopBottom.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/flatTopBottom.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/flatTopBottom.js +41 -0
- package/dist/api/drawing tools/lines menu/flatTopBottom.js.map +1 -0
- package/dist/api/drawing tools/lines menu/horizontal.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/horizontal.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/horizontal.js +19 -0
- package/dist/api/drawing tools/lines menu/horizontal.js.map +1 -0
- package/dist/api/drawing tools/lines menu/horizontalRay.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/horizontalRay.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/horizontalRay.js +20 -0
- package/dist/api/drawing tools/lines menu/horizontalRay.js.map +1 -0
- package/dist/api/drawing tools/lines menu/infoLine.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/infoLine.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/infoLine.js +107 -0
- package/dist/api/drawing tools/lines menu/infoLine.js.map +1 -0
- package/dist/api/drawing tools/lines menu/insidePitchfork.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/insidePitchfork.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/insidePitchfork.js +31 -0
- package/dist/api/drawing tools/lines menu/insidePitchfork.js.map +1 -0
- package/dist/api/drawing tools/lines menu/modifiedSchiffPitchfork.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/modifiedSchiffPitchfork.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/modifiedSchiffPitchfork.js +15 -0
- package/dist/api/drawing tools/lines menu/modifiedSchiffPitchfork.js.map +1 -0
- package/dist/api/drawing tools/lines menu/parallelChannel.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/parallelChannel.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/parallelChannel.js +43 -0
- package/dist/api/drawing tools/lines menu/parallelChannel.js.map +1 -0
- package/dist/api/drawing tools/lines menu/pitchfork.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/pitchfork.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/pitchfork.js +12 -0
- package/dist/api/drawing tools/lines menu/pitchfork.js.map +1 -0
- package/dist/api/drawing tools/lines menu/ray.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/ray.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/ray.js +23 -0
- package/dist/api/drawing tools/lines menu/ray.js.map +1 -0
- package/dist/api/drawing tools/lines menu/regressionTrend.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/regressionTrend.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/regressionTrend.js +127 -0
- package/dist/api/drawing tools/lines menu/regressionTrend.js.map +1 -0
- package/dist/api/drawing tools/lines menu/schiffPitchfork.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/schiffPitchfork.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/schiffPitchfork.js +15 -0
- package/dist/api/drawing tools/lines menu/schiffPitchfork.js.map +1 -0
- package/dist/api/drawing tools/lines menu/trendAngle.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/trendAngle.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/trendAngle.js +51 -0
- package/dist/api/drawing tools/lines menu/trendAngle.js.map +1 -0
- package/dist/api/drawing tools/lines menu/trendline.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/trendline.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/trendline.js +11 -0
- package/dist/api/drawing tools/lines menu/trendline.js.map +1 -0
- package/dist/api/drawing tools/lines menu/vertical.d.ts +4 -0
- package/dist/api/drawing tools/lines menu/vertical.d.ts.map +1 -0
- package/dist/api/drawing tools/lines menu/vertical.js +11 -0
- package/dist/api/drawing tools/lines menu/vertical.js.map +1 -0
- package/dist/api/drawing tools/pointers menu/crosshair.d.ts +16 -0
- package/dist/api/drawing tools/pointers menu/crosshair.d.ts.map +1 -0
- package/{src/api/drawing tools/pointers menu/crosshair.ts → dist/api/drawing tools/pointers menu/crosshair.js } +6 -7
- package/dist/api/drawing tools/pointers menu/crosshair.js.map +1 -0
- package/dist/api/drawing tools/pointers menu/cursor.d.ts +15 -0
- package/dist/api/drawing tools/pointers menu/cursor.d.ts.map +1 -0
- package/{src/api/drawing tools/pointers menu/cursor.ts → dist/api/drawing tools/pointers menu/cursor.js } +7 -8
- package/dist/api/drawing tools/pointers menu/cursor.js.map +1 -0
- package/dist/api/drawing tools/pointers menu/demonstration.d.ts +30 -0
- package/dist/api/drawing tools/pointers menu/demonstration.d.ts.map +1 -0
- package/{src/api/drawing tools/pointers menu/demonstration.ts → dist/api/drawing tools/pointers menu/demonstration.js } +9 -14
- package/dist/api/drawing tools/pointers menu/demonstration.js.map +1 -0
- package/dist/api/drawing tools/pointers menu/dot.d.ts +23 -0
- package/dist/api/drawing tools/pointers menu/dot.d.ts.map +1 -0
- package/{src/api/drawing tools/pointers menu/dot.ts → dist/api/drawing tools/pointers menu/dot.js } +8 -11
- package/dist/api/drawing tools/pointers menu/dot.js.map +1 -0
- package/dist/api/drawing tools/shapes menu/rectangle.d.ts +4 -0
- package/dist/api/drawing tools/shapes menu/rectangle.d.ts.map +1 -0
- package/dist/api/drawing tools/shapes menu/rectangle.js +19 -0
- package/dist/api/drawing tools/shapes menu/rectangle.js.map +1 -0
- package/dist/api/drawing tools/shapes menu/text.d.ts +4 -0
- package/dist/api/drawing tools/shapes menu/text.d.ts.map +1 -0
- package/dist/api/drawing tools/shapes menu/text.js +25 -0
- package/dist/api/drawing tools/shapes menu/text.js.map +1 -0
- package/dist/api/drawingUtils.d.ts +22 -0
- package/dist/api/drawingUtils.d.ts.map +1 -0
- package/dist/api/drawingUtils.js +83 -0
- package/dist/api/drawingUtils.js.map +1 -0
- package/dist/core/CanvasLayer.d.ts +26 -0
- package/dist/core/CanvasLayer.d.ts.map +1 -0
- package/dist/core/CanvasLayer.js +56 -0
- package/dist/core/CanvasLayer.js.map +1 -0
- package/dist/core/Chart.d.ts +164 -0
- package/dist/core/Chart.d.ts.map +1 -0
- package/dist/core/Chart.js +839 -0
- package/dist/core/Chart.js.map +1 -0
- package/dist/core/CoordTransform.d.ts +168 -0
- package/dist/core/CoordTransform.d.ts.map +1 -0
- package/dist/core/CoordTransform.js +224 -0
- package/dist/core/CoordTransform.js.map +1 -0
- package/dist/core/Crosshair.d.ts +30 -0
- package/dist/core/Crosshair.d.ts.map +1 -0
- package/dist/core/Crosshair.js +186 -0
- package/dist/core/Crosshair.js.map +1 -0
- package/dist/core/IndicatorEngine.d.ts +51 -0
- package/dist/core/IndicatorEngine.d.ts.map +1 -0
- package/dist/core/IndicatorEngine.js +181 -0
- package/dist/core/IndicatorEngine.js.map +1 -0
- package/dist/core/InteractionManager.d.ts +197 -0
- package/dist/core/InteractionManager.d.ts.map +1 -0
- package/dist/core/InteractionManager.js +698 -0
- package/dist/core/InteractionManager.js.map +1 -0
- package/dist/core/PriceScale.d.ts +27 -0
- package/dist/core/PriceScale.d.ts.map +1 -0
- package/dist/core/PriceScale.js +113 -0
- package/dist/core/PriceScale.js.map +1 -0
- package/dist/core/Series.d.ts +40 -0
- package/dist/core/Series.d.ts.map +1 -0
- package/dist/core/Series.js +114 -0
- package/dist/core/Series.js.map +1 -0
- package/dist/core/TimeScale.d.ts +43 -0
- package/dist/core/TimeScale.d.ts.map +1 -0
- package/dist/core/TimeScale.js +150 -0
- package/dist/core/TimeScale.js.map +1 -0
- package/dist/datafeed/DatafeedConnector.d.ts +89 -0
- package/dist/datafeed/DatafeedConnector.d.ts.map +1 -0
- package/dist/datafeed/DatafeedConnector.js +268 -0
- package/dist/datafeed/DatafeedConnector.js.map +1 -0
- package/dist/engine/CandleEngine.d.ts +207 -0
- package/dist/engine/CandleEngine.d.ts.map +1 -0
- package/dist/engine/CandleEngine.js +318 -0
- package/dist/engine/CandleEngine.js.map +1 -0
- package/dist/engine/__tests__/CandleEngine.test.d.ts +2 -0
- package/dist/engine/__tests__/CandleEngine.test.d.ts.map +1 -0
- package/dist/engine/__tests__/CandleEngine.test.js +300 -0
- package/dist/engine/__tests__/CandleEngine.test.js.map +1 -0
- package/dist/engine/candleInvariants.d.ts +66 -0
- package/dist/engine/candleInvariants.d.ts.map +1 -0
- package/dist/engine/candleInvariants.js +134 -0
- package/dist/engine/candleInvariants.js.map +1 -0
- package/{src/engine/mergeUtils.ts → dist/engine/mergeUtils.d.ts} +15 -52
- package/dist/engine/mergeUtils.d.ts.map +1 -0
- package/dist/engine/mergeUtils.js +64 -0
- package/dist/engine/mergeUtils.js.map +1 -0
- package/dist/engine/timeframeUtils.d.ts +80 -0
- package/dist/engine/timeframeUtils.d.ts.map +1 -0
- package/{src/engine/timeframeUtils.ts → dist/engine/timeframeUtils.js} +30 -48
- package/dist/engine/timeframeUtils.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +29 -0
- package/dist/internal.d.ts.map +1 -0
- package/{src/internal.ts → dist/internal.js} +1 -10
- package/dist/internal.js.map +1 -0
- package/dist/licensing/ChartRuntimeResolver.d.ts +233 -0
- package/dist/licensing/ChartRuntimeResolver.d.ts.map +1 -0
- package/dist/licensing/ChartRuntimeResolver.js +310 -0
- package/dist/licensing/ChartRuntimeResolver.js.map +1 -0
- package/dist/licensing/LicenseManager.d.ts +55 -0
- package/dist/licensing/LicenseManager.d.ts.map +1 -0
- package/dist/licensing/LicenseManager.js +114 -0
- package/dist/licensing/LicenseManager.js.map +1 -0
- package/dist/licensing/__tests__/ChartRuntimeResolver.test.d.ts +13 -0
- package/dist/licensing/__tests__/ChartRuntimeResolver.test.d.ts.map +1 -0
- package/dist/licensing/__tests__/ChartRuntimeResolver.test.js +177 -0
- package/dist/licensing/__tests__/ChartRuntimeResolver.test.js.map +1 -0
- package/dist/licensing/__tests__/LicenseManager.test.d.ts +12 -0
- package/dist/licensing/__tests__/LicenseManager.test.d.ts.map +1 -0
- package/dist/licensing/__tests__/LicenseManager.test.js +153 -0
- package/dist/licensing/__tests__/LicenseManager.test.js.map +1 -0
- package/dist/licensing/licenseTypes.d.ts +18 -0
- package/dist/licensing/licenseTypes.d.ts.map +1 -0
- package/dist/licensing/licenseTypes.js +2 -0
- package/dist/licensing/licenseTypes.js.map +1 -0
- package/dist/pine/PineCompiler.d.ts +35 -0
- package/dist/pine/PineCompiler.d.ts.map +1 -0
- package/dist/pine/PineCompiler.js +44 -0
- package/dist/pine/PineCompiler.js.map +1 -0
- package/dist/pine/diagnostics.d.ts +20 -0
- package/dist/pine/diagnostics.d.ts.map +1 -0
- package/dist/pine/diagnostics.js +11 -0
- package/dist/pine/diagnostics.js.map +1 -0
- package/{src/pine/index.ts → dist/pine/index.d.ts} +4 -3
- package/dist/pine/index.d.ts.map +1 -0
- package/dist/pine/index.js +5 -0
- package/dist/pine/index.js.map +1 -0
- package/dist/pine/pine-ast.d.ts +142 -0
- package/dist/pine/pine-ast.d.ts.map +1 -0
- package/dist/pine/pine-ast.js +19 -0
- package/dist/pine/pine-ast.js.map +1 -0
- package/dist/pine/pine-lexer.d.ts +41 -0
- package/dist/pine/pine-lexer.d.ts.map +1 -0
- package/dist/pine/pine-lexer.js +249 -0
- package/dist/pine/pine-lexer.js.map +1 -0
- package/dist/pine/pine-parser.d.ts +51 -0
- package/dist/pine/pine-parser.d.ts.map +1 -0
- package/dist/pine/pine-parser.js +416 -0
- package/dist/pine/pine-parser.js.map +1 -0
- package/dist/pine/pine-transpiler.d.ts +33 -0
- package/dist/pine/pine-transpiler.d.ts.map +1 -0
- package/dist/pine/pine-transpiler.js +260 -0
- package/dist/pine/pine-transpiler.js.map +1 -0
- package/dist/pixi/LayerName.d.ts +18 -0
- package/dist/pixi/LayerName.d.ts.map +1 -0
- package/dist/pixi/LayerName.js +35 -0
- package/dist/pixi/LayerName.js.map +1 -0
- package/dist/pixi/PixiCandlestickRenderer.d.ts +23 -0
- package/dist/pixi/PixiCandlestickRenderer.d.ts.map +1 -0
- package/dist/pixi/PixiCandlestickRenderer.js +107 -0
- package/dist/pixi/PixiCandlestickRenderer.js.map +1 -0
- package/dist/pixi/PixiChart.d.ts +72 -0
- package/dist/pixi/PixiChart.d.ts.map +1 -0
- package/dist/pixi/PixiChart.js +367 -0
- package/dist/pixi/PixiChart.js.map +1 -0
- package/dist/pixi/PixiCrosshairRenderer.d.ts +29 -0
- package/dist/pixi/PixiCrosshairRenderer.d.ts.map +1 -0
- package/dist/pixi/PixiCrosshairRenderer.js +110 -0
- package/dist/pixi/PixiCrosshairRenderer.js.map +1 -0
- package/dist/pixi/PixiDrawingRenderer.d.ts +17 -0
- package/dist/pixi/PixiDrawingRenderer.d.ts.map +1 -0
- package/dist/pixi/PixiDrawingRenderer.js +111 -0
- package/dist/pixi/PixiDrawingRenderer.js.map +1 -0
- package/dist/pixi/PixiGridRenderer.d.ts +22 -0
- package/dist/pixi/PixiGridRenderer.d.ts.map +1 -0
- package/dist/pixi/PixiGridRenderer.js +114 -0
- package/dist/pixi/PixiGridRenderer.js.map +1 -0
- package/dist/pixi/PixiLayerManager.d.ts +56 -0
- package/dist/pixi/PixiLayerManager.d.ts.map +1 -0
- package/dist/pixi/PixiLayerManager.js +92 -0
- package/dist/pixi/PixiLayerManager.js.map +1 -0
- package/dist/react/canvas/ChartCanvas.d.ts +85 -0
- package/dist/react/canvas/ChartCanvas.d.ts.map +1 -0
- package/dist/react/canvas/ChartCanvas.js +604 -0
- package/dist/react/canvas/ChartCanvas.js.map +1 -0
- package/dist/react/canvas/ChartContextMenu.d.ts +18 -0
- package/dist/react/canvas/ChartContextMenu.d.ts.map +1 -0
- package/dist/react/canvas/ChartContextMenu.js +5 -0
- package/dist/react/canvas/ChartContextMenu.js.map +1 -0
- package/dist/react/canvas/ChartSettingsDialog.d.ts +25 -0
- package/dist/react/canvas/ChartSettingsDialog.d.ts.map +1 -0
- package/dist/react/canvas/ChartSettingsDialog.js +28 -0
- package/dist/react/canvas/ChartSettingsDialog.js.map +1 -0
- package/dist/react/canvas/IndicatorLabel.d.ts +21 -0
- package/dist/react/canvas/IndicatorLabel.d.ts.map +1 -0
- package/dist/react/canvas/IndicatorLabel.js +196 -0
- package/dist/react/canvas/IndicatorLabel.js.map +1 -0
- package/dist/react/canvas/IndicatorPane.d.ts +32 -0
- package/dist/react/canvas/IndicatorPane.d.ts.map +1 -0
- package/dist/react/canvas/IndicatorPane.js +395 -0
- package/dist/react/canvas/IndicatorPane.js.map +1 -0
- package/dist/react/canvas/PointerOverlay.d.ts +23 -0
- package/dist/react/canvas/PointerOverlay.d.ts.map +1 -0
- package/dist/react/canvas/PointerOverlay.js +61 -0
- package/dist/react/canvas/PointerOverlay.js.map +1 -0
- package/dist/react/canvas/toolbars/LeftToolbar.d.ts +19 -0
- package/dist/react/canvas/toolbars/LeftToolbar.d.ts.map +1 -0
- package/dist/react/canvas/toolbars/LeftToolbar.js +407 -0
- package/dist/react/canvas/toolbars/LeftToolbar.js.map +1 -0
- package/dist/react/hooks/useChartCapabilities.d.ts +21 -0
- package/dist/react/hooks/useChartCapabilities.d.ts.map +1 -0
- package/dist/react/hooks/useChartCapabilities.js +66 -0
- package/dist/react/hooks/useChartCapabilities.js.map +1 -0
- package/dist/react/index.d.ts +30 -0
- package/dist/react/index.d.ts.map +1 -0
- package/{src/react/index.ts → dist/react/index.js} +1 -24
- package/dist/react/index.js.map +1 -0
- package/dist/react/internal.d.ts +38 -0
- package/dist/react/internal.d.ts.map +1 -0
- package/{src/react/internal.ts → dist/react/internal.js} +1 -19
- package/dist/react/internal.js.map +1 -0
- package/dist/react/shell/ManagedAppShell.d.ts +91 -0
- package/dist/react/shell/ManagedAppShell.d.ts.map +1 -0
- package/dist/react/shell/ManagedAppShell.js +440 -0
- package/dist/react/shell/ManagedAppShell.js.map +1 -0
- package/dist/react/trading/TradingBridge.d.ts +86 -0
- package/dist/react/trading/TradingBridge.d.ts.map +1 -0
- package/dist/react/trading/TradingBridge.js +73 -0
- package/dist/react/trading/TradingBridge.js.map +1 -0
- package/dist/react/workspace/ChartWorkspace.d.ts +73 -0
- package/dist/react/workspace/ChartWorkspace.d.ts.map +1 -0
- package/dist/react/workspace/ChartWorkspace.js +42 -0
- package/dist/react/workspace/ChartWorkspace.js.map +1 -0
- package/dist/react/workspace/FloatingPanel.d.ts +18 -0
- package/dist/react/workspace/FloatingPanel.d.ts.map +1 -0
- package/dist/react/workspace/FloatingPanel.js +82 -0
- package/dist/react/workspace/FloatingPanel.js.map +1 -0
- package/dist/react/workspace/IndicatorsDialog.d.ts +8 -0
- package/dist/react/workspace/IndicatorsDialog.d.ts.map +1 -0
- package/dist/react/workspace/IndicatorsDialog.js +121 -0
- package/dist/react/workspace/IndicatorsDialog.js.map +1 -0
- package/dist/react/workspace/LayoutMenu.d.ts +33 -0
- package/dist/react/workspace/LayoutMenu.d.ts.map +1 -0
- package/dist/react/workspace/LayoutMenu.js +113 -0
- package/dist/react/workspace/LayoutMenu.js.map +1 -0
- package/dist/react/workspace/SymbolSearchDialog.d.ts +10 -0
- package/dist/react/workspace/SymbolSearchDialog.d.ts.map +1 -0
- package/dist/react/workspace/SymbolSearchDialog.js +245 -0
- package/dist/react/workspace/SymbolSearchDialog.js.map +1 -0
- package/dist/react/workspace/TabBar.d.ts +17 -0
- package/dist/react/workspace/TabBar.d.ts.map +1 -0
- package/dist/react/workspace/TabBar.js +29 -0
- package/dist/react/workspace/TabBar.js.map +1 -0
- package/dist/react/workspace/toolbars/BottomToolbar.d.ts +19 -0
- package/dist/react/workspace/toolbars/BottomToolbar.d.ts.map +1 -0
- package/dist/react/workspace/toolbars/BottomToolbar.js +236 -0
- package/dist/react/workspace/toolbars/BottomToolbar.js.map +1 -0
- package/dist/react/workspace/toolbars/RightToolbar.d.ts +8 -0
- package/dist/react/workspace/toolbars/RightToolbar.d.ts.map +1 -0
- package/dist/react/workspace/toolbars/RightToolbar.js +18 -0
- package/dist/react/workspace/toolbars/RightToolbar.js.map +1 -0
- package/dist/react/workspace/toolbars/TopToolbar.d.ts +41 -0
- package/dist/react/workspace/toolbars/TopToolbar.d.ts.map +1 -0
- package/dist/react/workspace/toolbars/TopToolbar.js +82 -0
- package/dist/react/workspace/toolbars/TopToolbar.js.map +1 -0
- package/dist/renderers/CandlestickRenderer.d.ts +13 -0
- package/dist/renderers/CandlestickRenderer.d.ts.map +1 -0
- package/dist/renderers/CandlestickRenderer.js +98 -0
- package/dist/renderers/CandlestickRenderer.js.map +1 -0
- package/dist/renderers/HistogramRenderer.d.ts +11 -0
- package/dist/renderers/HistogramRenderer.d.ts.map +1 -0
- package/dist/renderers/HistogramRenderer.js +50 -0
- package/dist/renderers/HistogramRenderer.js.map +1 -0
- package/dist/renderers/LineRenderer.d.ts +12 -0
- package/dist/renderers/LineRenderer.d.ts.map +1 -0
- package/dist/renderers/LineRenderer.js +64 -0
- package/dist/renderers/LineRenderer.js.map +1 -0
- package/dist/theme/colors.d.ts +4 -0
- package/dist/theme/colors.d.ts.map +1 -0
- package/dist/theme/colors.js +19 -0
- package/dist/theme/colors.js.map +1 -0
- package/dist/tools/barDivergenceCheck.d.ts +120 -0
- package/dist/tools/barDivergenceCheck.d.ts.map +1 -0
- package/dist/tools/barDivergenceCheck.js +200 -0
- package/dist/tools/barDivergenceCheck.js.map +1 -0
- package/dist/trading/TradingOverlayStore.d.ts +86 -0
- package/dist/trading/TradingOverlayStore.d.ts.map +1 -0
- package/dist/trading/TradingOverlayStore.js +139 -0
- package/dist/trading/TradingOverlayStore.js.map +1 -0
- package/dist/trading/UnmanagedIngestion.d.ts +91 -0
- package/dist/trading/UnmanagedIngestion.d.ts.map +1 -0
- package/dist/trading/UnmanagedIngestion.js +114 -0
- package/dist/trading/UnmanagedIngestion.js.map +1 -0
- package/dist/trading/__tests__/ManagedTradingController.test.d.ts +18 -0
- package/dist/trading/__tests__/ManagedTradingController.test.d.ts.map +1 -0
- package/dist/trading/__tests__/ManagedTradingController.test.js +271 -0
- package/dist/trading/__tests__/ManagedTradingController.test.js.map +1 -0
- package/dist/trading/__tests__/TradingOverlayStore.test.d.ts +16 -0
- package/dist/trading/__tests__/TradingOverlayStore.test.d.ts.map +1 -0
- package/dist/trading/__tests__/TradingOverlayStore.test.js +267 -0
- package/dist/trading/__tests__/TradingOverlayStore.test.js.map +1 -0
- package/dist/trading/__tests__/UnmanagedIngestion.test.d.ts +16 -0
- package/dist/trading/__tests__/UnmanagedIngestion.test.d.ts.map +1 -0
- package/dist/trading/__tests__/UnmanagedIngestion.test.js +170 -0
- package/dist/trading/__tests__/UnmanagedIngestion.test.js.map +1 -0
- package/dist/trading/managed/ManagedTradingController.d.ts +110 -0
- package/dist/trading/managed/ManagedTradingController.d.ts.map +1 -0
- package/dist/trading/managed/ManagedTradingController.js +247 -0
- package/dist/trading/managed/ManagedTradingController.js.map +1 -0
- package/dist/trading/managed/managedCapabilities.d.ts +45 -0
- package/dist/trading/managed/managedCapabilities.d.ts.map +1 -0
- package/dist/trading/managed/managedCapabilities.js +79 -0
- package/dist/trading/managed/managedCapabilities.js.map +1 -0
- package/dist/trading/managed/managedTypes.d.ts +122 -0
- package/dist/trading/managed/managedTypes.d.ts.map +1 -0
- package/dist/trading/managed/managedTypes.js +13 -0
- package/dist/trading/managed/managedTypes.js.map +1 -0
- package/dist/trading/tradingTypes.d.ts +89 -0
- package/dist/trading/tradingTypes.d.ts.map +1 -0
- package/dist/trading/tradingTypes.js +8 -0
- package/dist/trading/tradingTypes.js.map +1 -0
- package/dist/tscript/TScriptIndicator.d.ts +41 -0
- package/dist/tscript/TScriptIndicator.d.ts.map +1 -0
- package/dist/tscript/TScriptIndicator.js +47 -0
- package/dist/tscript/TScriptIndicator.js.map +1 -0
- package/dist/tscript/ast.d.ts +89 -0
- package/dist/tscript/ast.d.ts.map +1 -0
- package/dist/tscript/ast.js +22 -0
- package/dist/tscript/ast.js.map +1 -0
- package/dist/tscript/lexer.d.ts +36 -0
- package/dist/tscript/lexer.d.ts.map +1 -0
- package/dist/tscript/lexer.js +187 -0
- package/dist/tscript/lexer.js.map +1 -0
- package/dist/tscript/parser.d.ts +50 -0
- package/dist/tscript/parser.d.ts.map +1 -0
- package/dist/tscript/parser.js +318 -0
- package/dist/tscript/parser.js.map +1 -0
- package/dist/tscript/runtime.d.ts +123 -0
- package/dist/tscript/runtime.d.ts.map +1 -0
- package/dist/tscript/runtime.js +475 -0
- package/dist/tscript/runtime.js.map +1 -0
- package/dist/tscript/series.d.ts +49 -0
- package/dist/tscript/series.d.ts.map +1 -0
- package/dist/tscript/series.js +79 -0
- package/dist/tscript/series.js.map +1 -0
- package/dist/types/IChart.d.ts +48 -0
- package/dist/types/IChart.d.ts.map +1 -0
- package/dist/types/IChart.js +2 -0
- package/dist/types/IChart.js.map +1 -0
- package/{src/types/IRenderer.ts → dist/types/IRenderer.d.ts} +2 -8
- package/dist/types/IRenderer.d.ts.map +1 -0
- package/dist/types/IRenderer.js +2 -0
- package/dist/types/IRenderer.js.map +1 -0
- package/dist/types/ISeries.d.ts +26 -0
- package/dist/types/ISeries.d.ts.map +1 -0
- package/dist/types/ISeries.js +2 -0
- package/dist/types/ISeries.js.map +1 -0
- package/package.json +5 -1
- package/src/__tests__/backwardCompatibility.test.ts +0 -191
- package/src/__tests__/candleInvariant.test.ts +0 -500
- package/src/__tests__/timeframeBoundary.test.ts +0 -583
- package/src/api/DrawingManager.ts +0 -188
- package/src/api/EventBus.ts +0 -53
- package/src/api/IndicatorDAG.ts +0 -389
- package/src/api/IndicatorRegistry.ts +0 -47
- package/src/api/LayoutManager.ts +0 -72
- package/src/api/PaneManager.ts +0 -129
- package/src/api/ReferenceAPI.ts +0 -195
- package/src/api/TChart.ts +0 -881
- package/src/api/drawing tools/fib gann menu/fibRetracement.ts +0 -27
- package/src/api/drawing tools/lines menu/crossLine.ts +0 -21
- package/src/api/drawing tools/lines menu/disjointChannel.ts +0 -74
- package/src/api/drawing tools/lines menu/extendedLine.ts +0 -22
- package/src/api/drawing tools/lines menu/flatTopBottom.ts +0 -45
- package/src/api/drawing tools/lines menu/horizontal.ts +0 -24
- package/src/api/drawing tools/lines menu/horizontalRay.ts +0 -25
- package/src/api/drawing tools/lines menu/infoLine.ts +0 -127
- package/src/api/drawing tools/lines menu/insidePitchfork.ts +0 -21
- package/src/api/drawing tools/lines menu/modifiedSchiffPitchfork.ts +0 -18
- package/src/api/drawing tools/lines menu/parallelChannel.ts +0 -47
- package/src/api/drawing tools/lines menu/pitchfork.ts +0 -15
- package/src/api/drawing tools/lines menu/ray.ts +0 -28
- package/src/api/drawing tools/lines menu/regressionTrend.ts +0 -157
- package/src/api/drawing tools/lines menu/schiffPitchfork.ts +0 -18
- package/src/api/drawing tools/lines menu/trendAngle.ts +0 -64
- package/src/api/drawing tools/lines menu/trendline.ts +0 -16
- package/src/api/drawing tools/lines menu/vertical.ts +0 -16
- package/src/api/drawing tools/shapes menu/rectangle.ts +0 -24
- package/src/api/drawing tools/shapes menu/text.ts +0 -30
- package/src/api/drawingUtils.ts +0 -82
- package/src/core/CanvasLayer.ts +0 -77
- package/src/core/Chart.ts +0 -917
- package/src/core/CoordTransform.ts +0 -282
- package/src/core/Crosshair.ts +0 -207
- package/src/core/IndicatorEngine.ts +0 -216
- package/src/core/InteractionManager.ts +0 -899
- package/src/core/PriceScale.ts +0 -133
- package/src/core/Series.ts +0 -132
- package/src/core/TimeScale.ts +0 -175
- package/src/datafeed/DatafeedConnector.ts +0 -300
- package/src/engine/CandleEngine.ts +0 -458
- package/src/engine/__tests__/CandleEngine.test.ts +0 -402
- package/src/engine/candleInvariants.ts +0 -172
- package/src/index.ts +0 -190
- package/src/licensing/ChartRuntimeResolver.ts +0 -380
- package/src/licensing/LicenseManager.ts +0 -131
- package/src/licensing/__tests__/ChartRuntimeResolver.test.ts +0 -207
- package/src/licensing/__tests__/LicenseManager.test.ts +0 -180
- package/src/licensing/licenseTypes.ts +0 -19
- package/src/pine/PineCompiler.ts +0 -68
- package/src/pine/diagnostics.ts +0 -30
- package/src/pine/pine-ast.ts +0 -163
- package/src/pine/pine-lexer.ts +0 -265
- package/src/pine/pine-parser.ts +0 -439
- package/src/pine/pine-transpiler.ts +0 -301
- package/src/pixi/LayerName.ts +0 -35
- package/src/pixi/PixiCandlestickRenderer.ts +0 -125
- package/src/pixi/PixiChart.ts +0 -425
- package/src/pixi/PixiCrosshairRenderer.ts +0 -134
- package/src/pixi/PixiDrawingRenderer.ts +0 -121
- package/src/pixi/PixiGridRenderer.ts +0 -136
- package/src/pixi/PixiLayerManager.ts +0 -102
- package/src/react/canvas/ChartCanvas.tsx +0 -984
- package/src/react/canvas/ChartContextMenu.tsx +0 -60
- package/src/react/canvas/ChartSettingsDialog.tsx +0 -133
- package/src/react/canvas/IndicatorLabel.tsx +0 -347
- package/src/react/canvas/IndicatorPane.tsx +0 -503
- package/src/react/canvas/PointerOverlay.tsx +0 -126
- package/src/react/canvas/toolbars/LeftToolbar.tsx +0 -1096
- package/src/react/hooks/useChartCapabilities.ts +0 -76
- package/src/react/shell/ManagedAppShell.tsx +0 -699
- package/src/react/trading/TradingBridge.ts +0 -156
- package/src/react/workspace/ChartWorkspace.tsx +0 -228
- package/src/react/workspace/FloatingPanel.tsx +0 -131
- package/src/react/workspace/IndicatorsDialog.tsx +0 -246
- package/src/react/workspace/LayoutMenu.tsx +0 -345
- package/src/react/workspace/SymbolSearchDialog.tsx +0 -377
- package/src/react/workspace/TabBar.tsx +0 -87
- package/src/react/workspace/toolbars/BottomToolbar.tsx +0 -372
- package/src/react/workspace/toolbars/RightToolbar.tsx +0 -46
- package/src/react/workspace/toolbars/TopToolbar.tsx +0 -431
- package/src/renderers/CandlestickRenderer.ts +0 -130
- package/src/renderers/HistogramRenderer.ts +0 -63
- package/src/renderers/LineRenderer.ts +0 -77
- package/src/theme/colors.ts +0 -21
- package/src/tools/barDivergenceCheck.ts +0 -305
- package/src/trading/TradingOverlayStore.ts +0 -161
- package/src/trading/UnmanagedIngestion.ts +0 -156
- package/src/trading/__tests__/ManagedTradingController.test.ts +0 -338
- package/src/trading/__tests__/TradingOverlayStore.test.ts +0 -323
- package/src/trading/__tests__/UnmanagedIngestion.test.ts +0 -205
- package/src/trading/managed/ManagedTradingController.ts +0 -292
- package/src/trading/managed/managedCapabilities.ts +0 -98
- package/src/trading/managed/managedTypes.ts +0 -151
- package/src/trading/tradingTypes.ts +0 -135
- package/src/tscript/TScriptIndicator.ts +0 -54
- package/src/tscript/ast.ts +0 -105
- package/src/tscript/lexer.ts +0 -190
- package/src/tscript/parser.ts +0 -334
- package/src/tscript/runtime.ts +0 -525
- package/src/tscript/series.ts +0 -84
- package/src/types/IChart.ts +0 -56
- package/src/types/ISeries.ts +0 -30
- package/tsconfig.json +0 -23
- package/tsup.config.ts +0 -16
- package/vitest.config.ts +0 -25
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TScriptIndicator — compiles and executes a TScript program, exposing its
|
|
3
|
-
* plot() outputs as IndicatorPoint arrays compatible with the DAG DAGResult format.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* const ind = new TScriptIndicator(`
|
|
8
|
-
* indicator("My SMA")
|
|
9
|
-
* length = input(14)
|
|
10
|
-
* value = sma(close, length)
|
|
11
|
-
* plot(value)
|
|
12
|
-
* `);
|
|
13
|
-
*
|
|
14
|
-
* const plots = ind.run(bars);
|
|
15
|
-
* // plots[0] → IndicatorPoint[] for the first plot() call
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import type { OHLCV } from '@forgecharts/types';
|
|
20
|
-
import { TScriptRuntime } from './runtime';
|
|
21
|
-
import type { IndicatorPoint } from '../core/IndicatorEngine';
|
|
22
|
-
|
|
23
|
-
export class TScriptIndicator {
|
|
24
|
-
private readonly _runtime: TScriptRuntime;
|
|
25
|
-
|
|
26
|
-
/** Title from the `indicator("...")` declaration, or `'Script'` if absent. */
|
|
27
|
-
readonly title: string;
|
|
28
|
-
|
|
29
|
-
constructor(src: string) {
|
|
30
|
-
this._runtime = new TScriptRuntime(src);
|
|
31
|
-
this.title = this._runtime.title;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Execute the script over the full bar history.
|
|
36
|
-
*
|
|
37
|
-
* Each call resets internal state and replays every bar from scratch,
|
|
38
|
-
* ensuring the output is deterministic regardless of prior calls.
|
|
39
|
-
*
|
|
40
|
-
* @returns array of plot series — `plots[0]` corresponds to the first
|
|
41
|
-
* `plot()` call in source, `plots[1]` to the second, etc.
|
|
42
|
-
*/
|
|
43
|
-
run(bars: readonly OHLCV[]): IndicatorPoint[][] {
|
|
44
|
-
return this._runtime.run(bars);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Reset all persistent series state (ring buffers) without re-parsing.
|
|
49
|
-
* Call when the chart symbol or timeframe changes.
|
|
50
|
-
*/
|
|
51
|
-
reset(): void {
|
|
52
|
-
this._runtime.reset();
|
|
53
|
-
}
|
|
54
|
-
}
|
package/src/tscript/ast.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TScript Abstract Syntax Tree node types.
|
|
3
|
-
*
|
|
4
|
-
* Grammar (simplified):
|
|
5
|
-
* program → stmt*
|
|
6
|
-
* stmt → indicator_decl | assign | expr_stmt
|
|
7
|
-
* assign → IDENT '=' expr
|
|
8
|
-
* indicator → 'indicator' '(' STRING ')'
|
|
9
|
-
* expr → ternary
|
|
10
|
-
* ternary → or ('?' expr ':' expr)?
|
|
11
|
-
* or → and ('or' and)*
|
|
12
|
-
* and → not ('and' not)*
|
|
13
|
-
* not → 'not' comparison | comparison
|
|
14
|
-
* comparison → addition (('<'|'>'|'<='|'>='|'=='|'!=') addition)*
|
|
15
|
-
* addition → multiplication (('+' | '-') multiplication)*
|
|
16
|
-
* multiplication→ unary (('*' | '/' | '%') unary)*
|
|
17
|
-
* unary → '-' unary | primary
|
|
18
|
-
* primary → NUMBER | STRING | BOOL | IDENT ('[' expr ']')? | call | '(' expr ')'
|
|
19
|
-
* call → IDENT '(' args ')'
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
// ─── Literal / leaf nodes ─────────────────────────────────────────────────────
|
|
23
|
-
|
|
24
|
-
export type NumberLit = { kind: 'NumberLit'; value: number };
|
|
25
|
-
export type StringLit = { kind: 'StringLit'; value: string };
|
|
26
|
-
export type BoolLit = { kind: 'BoolLit'; value: boolean };
|
|
27
|
-
export type Identifier = { kind: 'Identifier'; name: string };
|
|
28
|
-
|
|
29
|
-
// ─── Expression nodes ─────────────────────────────────────────────────────────
|
|
30
|
-
|
|
31
|
-
export type IndexExpr = {
|
|
32
|
-
kind: 'IndexExpr';
|
|
33
|
-
series: Expr; // the base series (usually an Identifier)
|
|
34
|
-
index: Expr; // bar-lookback, e.g. close[1]
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type CallExpr = {
|
|
38
|
-
kind: 'CallExpr';
|
|
39
|
-
callee: string;
|
|
40
|
-
args: Expr[];
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type BinaryExpr = {
|
|
44
|
-
kind: 'BinaryExpr';
|
|
45
|
-
op: '+' | '-' | '*' | '/' | '%' | '<' | '>' | '<=' | '>=' | '==' | '!=';
|
|
46
|
-
left: Expr;
|
|
47
|
-
right: Expr;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export type UnaryExpr = {
|
|
51
|
-
kind: 'UnaryExpr';
|
|
52
|
-
op: '-' | 'not';
|
|
53
|
-
operand: Expr;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export type TernaryExpr = {
|
|
57
|
-
kind: 'TernaryExpr';
|
|
58
|
-
condition: Expr;
|
|
59
|
-
consequent: Expr;
|
|
60
|
-
alternate: Expr;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export type LogicalExpr = {
|
|
64
|
-
kind: 'LogicalExpr';
|
|
65
|
-
op: 'and' | 'or';
|
|
66
|
-
left: Expr;
|
|
67
|
-
right: Expr;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export type Expr =
|
|
71
|
-
| NumberLit
|
|
72
|
-
| StringLit
|
|
73
|
-
| BoolLit
|
|
74
|
-
| Identifier
|
|
75
|
-
| IndexExpr
|
|
76
|
-
| CallExpr
|
|
77
|
-
| BinaryExpr
|
|
78
|
-
| UnaryExpr
|
|
79
|
-
| TernaryExpr
|
|
80
|
-
| LogicalExpr;
|
|
81
|
-
|
|
82
|
-
// ─── Statement nodes ──────────────────────────────────────────────────────────
|
|
83
|
-
|
|
84
|
-
export type IndicatorDecl = {
|
|
85
|
-
kind: 'IndicatorDecl';
|
|
86
|
-
title: string;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type AssignStmt = {
|
|
90
|
-
kind: 'AssignStmt';
|
|
91
|
-
name: string;
|
|
92
|
-
value: Expr;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export type ExprStmt = {
|
|
96
|
-
kind: 'ExprStmt';
|
|
97
|
-
expr: Expr;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export type Stmt = IndicatorDecl | AssignStmt | ExprStmt;
|
|
101
|
-
|
|
102
|
-
export type Program = {
|
|
103
|
-
kind: 'Program';
|
|
104
|
-
stmts: Stmt[];
|
|
105
|
-
};
|
package/src/tscript/lexer.ts
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TScript Lexer — converts source text into a flat token stream.
|
|
3
|
-
*
|
|
4
|
-
* Token types:
|
|
5
|
-
* NUMBER — 42, 3.14, .5
|
|
6
|
-
* STRING — "hello" or 'hello'
|
|
7
|
-
* BOOL — true / false
|
|
8
|
-
* IDENT — identifier or keyword
|
|
9
|
-
* OP — single/double-char operator
|
|
10
|
-
* LPAREN, RPAREN, LBRACKET, RBRACKET, COMMA, EQ, NEWLINE
|
|
11
|
-
* EOF
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export type TokenKind =
|
|
15
|
-
| 'NUMBER' | 'STRING' | 'BOOL' | 'IDENT'
|
|
16
|
-
| 'PLUS' | 'MINUS' | 'STAR' | 'SLASH' | 'PERCENT'
|
|
17
|
-
| 'LT' | 'GT' | 'LTE' | 'GTE' | 'EQEQ' | 'NEQ'
|
|
18
|
-
| 'QMARK' | 'COLON'
|
|
19
|
-
| 'LPAREN' | 'RPAREN' | 'LBRACKET' | 'RBRACKET'
|
|
20
|
-
| 'COMMA' | 'EQ'
|
|
21
|
-
| 'NEWLINE' | 'EOF';
|
|
22
|
-
|
|
23
|
-
export type Token = {
|
|
24
|
-
kind: TokenKind;
|
|
25
|
-
value: string; // raw matched text
|
|
26
|
-
line: number;
|
|
27
|
-
col: number;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// Keywords that are NOT identifiers
|
|
31
|
-
const KEYWORDS = new Set(['true', 'false', 'and', 'or', 'not', 'indicator', 'input', 'plot', 'na']);
|
|
32
|
-
|
|
33
|
-
export class Lexer {
|
|
34
|
-
private _src: string;
|
|
35
|
-
private _pos: number = 0;
|
|
36
|
-
private _line: number = 1;
|
|
37
|
-
private _col: number = 1;
|
|
38
|
-
|
|
39
|
-
constructor(src: string) {
|
|
40
|
-
this._src = src;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
tokenize(): Token[] {
|
|
44
|
-
const tokens: Token[] = [];
|
|
45
|
-
while (this._pos < this._src.length) {
|
|
46
|
-
this._skipWhitespaceAndComments();
|
|
47
|
-
if (this._pos >= this._src.length) break;
|
|
48
|
-
|
|
49
|
-
const ch = this._src[this._pos]!;
|
|
50
|
-
|
|
51
|
-
// Newline as statement separator
|
|
52
|
-
if (ch === '\n') {
|
|
53
|
-
tokens.push(this._make('NEWLINE', '\n'));
|
|
54
|
-
this._pos++;
|
|
55
|
-
this._line++;
|
|
56
|
-
this._col = 1;
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Numbers
|
|
61
|
-
if (ch >= '0' && ch <= '9' || (ch === '.' && this._peek(1) >= '0' && this._peek(1) <= '9')) {
|
|
62
|
-
tokens.push(this._readNumber());
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Strings
|
|
67
|
-
if (ch === '"' || ch === "'") {
|
|
68
|
-
tokens.push(this._readString(ch));
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Identifiers / keywords
|
|
73
|
-
if (this._isAlpha(ch)) {
|
|
74
|
-
tokens.push(this._readIdent());
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Two-char operators first
|
|
79
|
-
const two = this._src.slice(this._pos, this._pos + 2);
|
|
80
|
-
if (two === '<=' ) { tokens.push(this._make('LTE', two)); this._pos += 2; this._col += 2; continue; }
|
|
81
|
-
if (two === '>=' ) { tokens.push(this._make('GTE', two)); this._pos += 2; this._col += 2; continue; }
|
|
82
|
-
if (two === '==' ) { tokens.push(this._make('EQEQ', two)); this._pos += 2; this._col += 2; continue; }
|
|
83
|
-
if (two === '!=' ) { tokens.push(this._make('NEQ', two)); this._pos += 2; this._col += 2; continue; }
|
|
84
|
-
|
|
85
|
-
// Single-char operators
|
|
86
|
-
const ops: Record<string, TokenKind> = {
|
|
87
|
-
'+': 'PLUS', '-': 'MINUS', '*': 'STAR', '/': 'SLASH', '%': 'PERCENT',
|
|
88
|
-
'<': 'LT', '>': 'GT',
|
|
89
|
-
'?': 'QMARK', ':': 'COLON',
|
|
90
|
-
'(': 'LPAREN', ')': 'RPAREN',
|
|
91
|
-
'[': 'LBRACKET', ']': 'RBRACKET',
|
|
92
|
-
',': 'COMMA',
|
|
93
|
-
'=': 'EQ',
|
|
94
|
-
};
|
|
95
|
-
if (ch in ops) {
|
|
96
|
-
tokens.push(this._make(ops[ch]!, ch));
|
|
97
|
-
this._pos++;
|
|
98
|
-
this._col++;
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
throw new SyntaxError(`[TScript] Unexpected character '${ch}' at ${this._line}:${this._col}`);
|
|
103
|
-
}
|
|
104
|
-
tokens.push(this._make('EOF', ''));
|
|
105
|
-
return tokens;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ─── Private helpers ────────────────────────────────────────────────────────
|
|
109
|
-
|
|
110
|
-
private _make(kind: TokenKind, value: string): Token {
|
|
111
|
-
return { kind, value, line: this._line, col: this._col };
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private _peek(offset: number): string {
|
|
115
|
-
return this._src[this._pos + offset] ?? '';
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private _isAlpha(ch: string): boolean {
|
|
119
|
-
return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch === '_';
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private _isAlphaNum(ch: string): boolean {
|
|
123
|
-
return this._isAlpha(ch) || (ch >= '0' && ch <= '9');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private _skipWhitespaceAndComments(): void {
|
|
127
|
-
while (this._pos < this._src.length) {
|
|
128
|
-
const ch = this._src[this._pos]!;
|
|
129
|
-
// Skip spaces/tabs/carriage-returns but NOT newlines (they are tokens)
|
|
130
|
-
if (ch === ' ' || ch === '\t' || ch === '\r') {
|
|
131
|
-
this._pos++; this._col++;
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
// Line comment: // ... to end of line
|
|
135
|
-
if (ch === '/' && this._peek(1) === '/') {
|
|
136
|
-
while (this._pos < this._src.length && this._src[this._pos] !== '\n') {
|
|
137
|
-
this._pos++; this._col++;
|
|
138
|
-
}
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
private _readNumber(): Token {
|
|
146
|
-
const start = this._pos;
|
|
147
|
-
const startCol = this._col;
|
|
148
|
-
while (this._pos < this._src.length) {
|
|
149
|
-
const c = this._src[this._pos]!;
|
|
150
|
-
if ((c >= '0' && c <= '9') || c === '.') { this._pos++; this._col++; }
|
|
151
|
-
else break;
|
|
152
|
-
}
|
|
153
|
-
const raw = this._src.slice(start, this._pos);
|
|
154
|
-
return { kind: 'NUMBER', value: raw, line: this._line, col: startCol };
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
private _readString(quote: string): Token {
|
|
158
|
-
const startCol = this._col;
|
|
159
|
-
this._pos++; this._col++; // skip opening quote
|
|
160
|
-
let result = '';
|
|
161
|
-
while (this._pos < this._src.length && this._src[this._pos] !== quote) {
|
|
162
|
-
if (this._src[this._pos] === '\\') {
|
|
163
|
-
this._pos++; this._col++;
|
|
164
|
-
const esc = this._src[this._pos] ?? '';
|
|
165
|
-
result += esc === 'n' ? '\n' : esc === 't' ? '\t' : esc;
|
|
166
|
-
} else {
|
|
167
|
-
result += this._src[this._pos];
|
|
168
|
-
}
|
|
169
|
-
this._pos++; this._col++;
|
|
170
|
-
}
|
|
171
|
-
this._pos++; this._col++; // skip closing quote
|
|
172
|
-
return { kind: 'STRING', value: result, line: this._line, col: startCol };
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
private _readIdent(): Token {
|
|
176
|
-
const start = this._pos;
|
|
177
|
-
const startCol = this._col;
|
|
178
|
-
while (this._pos < this._src.length && this._isAlphaNum(this._src[this._pos]!)) {
|
|
179
|
-
this._pos++; this._col++;
|
|
180
|
-
}
|
|
181
|
-
const name = this._src.slice(start, this._pos);
|
|
182
|
-
if (name === 'true' || name === 'false') {
|
|
183
|
-
return { kind: 'BOOL', value: name, line: this._line, col: startCol };
|
|
184
|
-
}
|
|
185
|
-
// Keywords like 'and', 'or', 'not', 'indicator' stay as IDENT so parser can
|
|
186
|
-
// recognise them by value rather than needing dedicated token kinds.
|
|
187
|
-
void KEYWORDS; // referenced for documentation only
|
|
188
|
-
return { kind: 'IDENT', value: name, line: this._line, col: startCol };
|
|
189
|
-
}
|
|
190
|
-
}
|
package/src/tscript/parser.ts
DELETED
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TScript Parser — recursive-descent, produces a typed AST.
|
|
3
|
-
*
|
|
4
|
-
* Precedence (low → high):
|
|
5
|
-
* ternary ? :
|
|
6
|
-
* or
|
|
7
|
-
* and
|
|
8
|
-
* not
|
|
9
|
-
* comparison < > <= >= == !=
|
|
10
|
-
* addition + -
|
|
11
|
-
* multiply * / %
|
|
12
|
-
* unary - (prefix)
|
|
13
|
-
* primary literals, identifiers, index [], call()
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import type {
|
|
17
|
-
Program, Stmt, Expr,
|
|
18
|
-
IndicatorDecl, AssignStmt, ExprStmt,
|
|
19
|
-
NumberLit, StringLit, BoolLit, Identifier,
|
|
20
|
-
IndexExpr, CallExpr, BinaryExpr, UnaryExpr,
|
|
21
|
-
TernaryExpr, LogicalExpr,
|
|
22
|
-
} from './ast';
|
|
23
|
-
import { Lexer } from './lexer';
|
|
24
|
-
import type { Token, TokenKind } from './lexer';
|
|
25
|
-
|
|
26
|
-
export class Parser {
|
|
27
|
-
private _tokens: Token[];
|
|
28
|
-
private _pos: number = 0;
|
|
29
|
-
|
|
30
|
-
constructor(src: string) {
|
|
31
|
-
this._tokens = new Lexer(src).tokenize().filter((t) => t.kind !== 'NEWLINE' || this._isStatementBoundary(t));
|
|
32
|
-
// Re-filter: keep NEWLINEs as statement separators but collapse runs
|
|
33
|
-
this._tokens = this._collapseNewlines(new Lexer(src).tokenize());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
parse(): Program {
|
|
37
|
-
const stmts: Stmt[] = [];
|
|
38
|
-
this._skipNewlines();
|
|
39
|
-
while (!this._check('EOF')) {
|
|
40
|
-
stmts.push(this._stmt());
|
|
41
|
-
this._skipNewlines();
|
|
42
|
-
}
|
|
43
|
-
return { kind: 'Program', stmts };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// ─── Statements ─────────────────────────────────────────────────────────────
|
|
47
|
-
|
|
48
|
-
private _stmt(): Stmt {
|
|
49
|
-
// indicator("title")
|
|
50
|
-
if (this._checkIdent('indicator')) {
|
|
51
|
-
return this._indicatorDecl();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// assignment: IDENT = expr (but not IDENT == ...)
|
|
55
|
-
if (this._check('IDENT') && this._peekKind(1) === 'EQ') {
|
|
56
|
-
return this._assign();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return this._exprStmt();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private _indicatorDecl(): IndicatorDecl {
|
|
63
|
-
this._consumeIdent('indicator');
|
|
64
|
-
this._consume('LPAREN', "Expected '(' after 'indicator'");
|
|
65
|
-
const title = this._consume('STRING', "Expected string title in indicator()").value;
|
|
66
|
-
this._consume('RPAREN', "Expected ')' after indicator title");
|
|
67
|
-
this._consumeNewlineOrEOF();
|
|
68
|
-
return { kind: 'IndicatorDecl', title };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private _assign(): AssignStmt {
|
|
72
|
-
const name = this._consume('IDENT', 'Expected identifier').value;
|
|
73
|
-
this._consume('EQ', "Expected '='");
|
|
74
|
-
const value = this._expr();
|
|
75
|
-
this._consumeNewlineOrEOF();
|
|
76
|
-
return { kind: 'AssignStmt', name, value };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private _exprStmt(): ExprStmt {
|
|
80
|
-
const expr = this._expr();
|
|
81
|
-
this._consumeNewlineOrEOF();
|
|
82
|
-
return { kind: 'ExprStmt', expr };
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// ─── Expressions ────────────────────────────────────────────────────────────
|
|
86
|
-
|
|
87
|
-
private _expr(): Expr {
|
|
88
|
-
return this._ternary();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private _ternary(): Expr {
|
|
92
|
-
let left = this._or();
|
|
93
|
-
if (this._match('QMARK')) {
|
|
94
|
-
const consequent = this._expr();
|
|
95
|
-
this._consume('COLON', "Expected ':' in ternary expression");
|
|
96
|
-
const alternate = this._expr();
|
|
97
|
-
const node: TernaryExpr = { kind: 'TernaryExpr', condition: left, consequent, alternate };
|
|
98
|
-
left = node;
|
|
99
|
-
}
|
|
100
|
-
return left;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
private _or(): Expr {
|
|
104
|
-
let left = this._and();
|
|
105
|
-
while (this._checkIdent('or')) {
|
|
106
|
-
this._advance();
|
|
107
|
-
const right = this._and();
|
|
108
|
-
const node: LogicalExpr = { kind: 'LogicalExpr', op: 'or', left, right };
|
|
109
|
-
left = node;
|
|
110
|
-
}
|
|
111
|
-
return left;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private _and(): Expr {
|
|
115
|
-
let left = this._not();
|
|
116
|
-
while (this._checkIdent('and')) {
|
|
117
|
-
this._advance();
|
|
118
|
-
const right = this._not();
|
|
119
|
-
const node: LogicalExpr = { kind: 'LogicalExpr', op: 'and', left, right };
|
|
120
|
-
left = node;
|
|
121
|
-
}
|
|
122
|
-
return left;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private _not(): Expr {
|
|
126
|
-
if (this._checkIdent('not')) {
|
|
127
|
-
this._advance();
|
|
128
|
-
const operand = this._comparison();
|
|
129
|
-
const node: UnaryExpr = { kind: 'UnaryExpr', op: 'not', operand };
|
|
130
|
-
return node;
|
|
131
|
-
}
|
|
132
|
-
return this._comparison();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
private _comparison(): Expr {
|
|
136
|
-
let left = this._addition();
|
|
137
|
-
while (true) {
|
|
138
|
-
if (this._match('LTE')) { left = this._binop('<=', left, this._addition()); continue; }
|
|
139
|
-
if (this._match('GTE')) { left = this._binop('>=', left, this._addition()); continue; }
|
|
140
|
-
if (this._match('EQEQ')) { left = this._binop('==', left, this._addition()); continue; }
|
|
141
|
-
if (this._match('NEQ')) { left = this._binop('!=', left, this._addition()); continue; }
|
|
142
|
-
if (this._match('LT')) { left = this._binop('<', left, this._addition()); continue; }
|
|
143
|
-
if (this._match('GT')) { left = this._binop('>', left, this._addition()); continue; }
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
return left;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
private _addition(): Expr {
|
|
150
|
-
let left = this._multiplication();
|
|
151
|
-
while (true) {
|
|
152
|
-
if (this._match('PLUS')) { left = this._binop('+', left, this._multiplication()); continue; }
|
|
153
|
-
if (this._match('MINUS')) { left = this._binop('-', left, this._multiplication()); continue; }
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
return left;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
private _multiplication(): Expr {
|
|
160
|
-
let left = this._unary();
|
|
161
|
-
while (true) {
|
|
162
|
-
if (this._match('STAR')) { left = this._binop('*', left, this._unary()); continue; }
|
|
163
|
-
if (this._match('SLASH')) { left = this._binop('/', left, this._unary()); continue; }
|
|
164
|
-
if (this._match('PERCENT')) { left = this._binop('%', left, this._unary()); continue; }
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
return left;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private _unary(): Expr {
|
|
171
|
-
if (this._match('MINUS')) {
|
|
172
|
-
const operand = this._unary();
|
|
173
|
-
const node: UnaryExpr = { kind: 'UnaryExpr', op: '-', operand };
|
|
174
|
-
return node;
|
|
175
|
-
}
|
|
176
|
-
return this._primary();
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
private _primary(): Expr {
|
|
180
|
-
const tok = this._current();
|
|
181
|
-
|
|
182
|
-
// Number literal
|
|
183
|
-
if (tok.kind === 'NUMBER') {
|
|
184
|
-
this._advance();
|
|
185
|
-
const node: NumberLit = { kind: 'NumberLit', value: parseFloat(tok.value) };
|
|
186
|
-
return node;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// String literal
|
|
190
|
-
if (tok.kind === 'STRING') {
|
|
191
|
-
this._advance();
|
|
192
|
-
const node: StringLit = { kind: 'StringLit', value: tok.value };
|
|
193
|
-
return node;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Bool literal
|
|
197
|
-
if (tok.kind === 'BOOL') {
|
|
198
|
-
this._advance();
|
|
199
|
-
const node: BoolLit = { kind: 'BoolLit', value: tok.value === 'true' };
|
|
200
|
-
return node;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// na (special NaN constant)
|
|
204
|
-
if (tok.kind === 'IDENT' && tok.value === 'na') {
|
|
205
|
-
this._advance();
|
|
206
|
-
const node: NumberLit = { kind: 'NumberLit', value: NaN };
|
|
207
|
-
return node;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Function call: IDENT '(' args ')'
|
|
211
|
-
if (tok.kind === 'IDENT' && this._peekKind(1) === 'LPAREN') {
|
|
212
|
-
return this._callExpr();
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Identifier (and optional series index)
|
|
216
|
-
if (tok.kind === 'IDENT') {
|
|
217
|
-
this._advance();
|
|
218
|
-
let node: Expr = { kind: 'Identifier', name: tok.value } satisfies Identifier;
|
|
219
|
-
// Series index: ident[expr]
|
|
220
|
-
while (this._check('LBRACKET')) {
|
|
221
|
-
this._advance();
|
|
222
|
-
const index = this._expr();
|
|
223
|
-
this._consume('RBRACKET', "Expected ']'");
|
|
224
|
-
const indexNode: IndexExpr = { kind: 'IndexExpr', series: node, index };
|
|
225
|
-
node = indexNode;
|
|
226
|
-
}
|
|
227
|
-
return node;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Grouped: '(' expr ')'
|
|
231
|
-
if (tok.kind === 'LPAREN') {
|
|
232
|
-
this._advance();
|
|
233
|
-
const inner = this._expr();
|
|
234
|
-
this._consume('RPAREN', "Expected ')'");
|
|
235
|
-
return inner;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
throw new SyntaxError(
|
|
239
|
-
`[TScript] Unexpected token '${tok.value}' (${tok.kind}) at ${tok.line}:${tok.col}`,
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
private _callExpr(): CallExpr {
|
|
244
|
-
const callee = this._consume('IDENT', 'Expected function name').value;
|
|
245
|
-
this._consume('LPAREN', "Expected '('");
|
|
246
|
-
const args: Expr[] = [];
|
|
247
|
-
if (!this._check('RPAREN')) {
|
|
248
|
-
args.push(this._expr());
|
|
249
|
-
while (this._match('COMMA')) {
|
|
250
|
-
args.push(this._expr());
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
this._consume('RPAREN', "Expected ')'");
|
|
254
|
-
return { kind: 'CallExpr', callee, args };
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// ─── Utility helpers ────────────────────────────────────────────────────────
|
|
258
|
-
|
|
259
|
-
private _binop(
|
|
260
|
-
op: BinaryExpr['op'],
|
|
261
|
-
left: Expr,
|
|
262
|
-
right: Expr,
|
|
263
|
-
): BinaryExpr {
|
|
264
|
-
return { kind: 'BinaryExpr', op, left, right };
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
private _current(): Token {
|
|
268
|
-
return this._tokens[this._pos]!;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
private _advance(): Token {
|
|
272
|
-
return this._tokens[this._pos++]!;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
private _check(kind: TokenKind): boolean {
|
|
276
|
-
return this._current().kind === kind;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
private _checkIdent(name: string): boolean {
|
|
280
|
-
const t = this._current();
|
|
281
|
-
return t.kind === 'IDENT' && t.value === name;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
private _peekKind(offset: number): TokenKind {
|
|
285
|
-
return this._tokens[this._pos + offset]?.kind ?? 'EOF';
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
private _match(kind: TokenKind): boolean {
|
|
289
|
-
if (this._check(kind)) { this._advance(); return true; }
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
private _consume(kind: TokenKind, msg: string): Token {
|
|
294
|
-
if (this._check(kind)) return this._advance();
|
|
295
|
-
const t = this._current();
|
|
296
|
-
throw new SyntaxError(`[TScript] ${msg} — got '${t.value}' at ${t.line}:${t.col}`);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
private _consumeIdent(name: string): Token {
|
|
300
|
-
if (this._checkIdent(name)) return this._advance();
|
|
301
|
-
const t = this._current();
|
|
302
|
-
throw new SyntaxError(`[TScript] Expected '${name}' — got '${t.value}' at ${t.line}:${t.col}`);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
private _consumeNewlineOrEOF(): void {
|
|
306
|
-
// Silently accept NEWLINE or EOF; required at end of every statement.
|
|
307
|
-
if (this._check('NEWLINE') || this._check('EOF')) {
|
|
308
|
-
if (this._check('NEWLINE')) this._advance();
|
|
309
|
-
}
|
|
310
|
-
// If neither, we just continue (expression statements don't need semicolons)
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
private _skipNewlines(): void {
|
|
314
|
-
while (this._check('NEWLINE')) this._advance();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
private _collapseNewlines(tokens: Token[]): Token[] {
|
|
318
|
-
const out: Token[] = [];
|
|
319
|
-
let lastWasNL = false;
|
|
320
|
-
for (const t of tokens) {
|
|
321
|
-
if (t.kind === 'NEWLINE') {
|
|
322
|
-
if (!lastWasNL) out.push(t);
|
|
323
|
-
lastWasNL = true;
|
|
324
|
-
} else {
|
|
325
|
-
lastWasNL = false;
|
|
326
|
-
out.push(t);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
return out;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
333
|
-
private _isStatementBoundary(_t: Token): boolean { return true; }
|
|
334
|
-
}
|