Add language specification document

This commit introduces the BNF for the Myc language, along with its core
semantics, data types, and evaluation logic. It also details the macro
system and provides an overview of the standard library. This document
serves as a foundational context for LLMs to understand and generate Myc
code.
This commit is contained in:
Michael Schimmel
2026-03-06 11:35:18 +01:00
parent 9ba4f795d1
commit 32a1f21463
7 changed files with 221 additions and 50 deletions
-19
View File
@@ -1,19 +0,0 @@
;; advanced.myc
;; Hull Moving Average
;; Formula: WMA(2 * WMA(n/2) - WMA(n), sqrt(n))
(def HMA (fn [len]
(do
;; Create inner WMA instances
(def wma_half (WMA (/ len 2)))
(def wma_full (WMA len))
;; Create outer WMA instance
;; Note: sqrt is a native RTL function
(def wma_outer (WMA (sqrt len)))
(fn [val]
(do
(def v_half (wma_half val))
(def v_full (wma_full val))
(def diff (- (* 2 v_half) v_full))
(wma_outer diff))))))
-30
View File
@@ -1,30 +0,0 @@
(do
;; Simple Moving Average O(1)
(def SMA (fn [len]
(do
(def s (Series len))
(def sum 0.0)
(fn [val]
(do
(if (>= (count s) len)
(set sum (- sum (get_item s (- len 1))))
(nop))
(push s val)
(set sum (+ sum val))
(/ sum (count s)))))))
;; Weighted Moving Average
(def WMA (fn [len]
(do
(def s (Series len))
(def weight_sum (/ (* len (+ len 1)) 2))
(fn [val]
(do
(push s val)
(def current_sum 0.0)
(def i 0)
(while (< i (count s))
(do
(set current_sum (+ current_sum (* (get_item s i) (- len i))))
(set i (+ i 1))))
(/ current_sum weight_sum)))))))