Files
RustAst/examples/pipeline_script_ticker.myc
T
Brummel ee89d2330d feat: Add comments to AST nodes
This commit introduces support for comments within the AST nodes.
Comments are now parsed by the lexer and stored within the `Token`
struct.
These comments are then propagated through various compiler phases,
including
the `Node` struct, ensuring they are preserved in the Abstract Syntax
Tree.
This change enhances the AST's ability to retain source code
information,
which can be valuable for debugging and analysis.
2026-03-25 18:36:53 +01:00

50 lines
1.1 KiB
Plaintext

;; Benchmark: 2.1us
;; Benchmark-Repeat: 966
;; Output: <StreamNode>
(do
;; Set the random seed to match the existing test output exactly
(def random (make-random 42))
;; Use our new generic create-ticker to pulse 3 times
(def cnt 3)
(def ticker (create-ticker (fn [] (> (assign cnt (- cnt 1)) -1))))
;; The candle generator reacting to the ticker
(def last-close 100.0)
(def src1
(pipe [ticker]
(fn [_]
(do
; Matches Rust: (rng.f64() - 0.5) * 2.0
(def change (* (- (random) 0.5) 2.0))
(def open last-close)
(def high (+ open (abs (* (random) 2.0))))
(def low (- open (abs (* (random) 2.0))))
(assign last-close (+ open change))
{:open open :high high :low low :close last-close}
)
)
)
)
(def combined
(pipe [src1]
(fn [t1]
(.close t1)
)
)
)
(def my_indicator
(pipe [combined]
(fn [close_price]
(+ close_price 10.0)
)
)
)
my_indicator
)