DEYIN DOCS
GRAMMAR & SPECIFICATION

DEYIN LANGUAGE REFERENCE

Deyin pipelines are composed using the single pipeline operator |. All whitespace and newline breaks preceding pipe operators are ignored.

1. COMPLETE EBNF SPECIFICATION

pipeline   ::= "stream" CNAME "from" source ("|" step)*
source     ::= CNAME (STRING | CNAME)?
step       ::= window | filter | map | sink | compile

window     ::= "window" DURATION
filter     ::= "filter" EXPR
map        ::= "map" EXPR
sink       ::= "sink" "to" CNAME (STRING | CNAME)?
compile    ::= "compile" "to" CNAME

DURATION   ::= [0-9]+ ("s" | "m" | "h" | "d")
PERCENT    ::= [0-9]+ "%"
EXPR       ::= [^|\n]+

2. STAGE OPERATORS

KEYWORD SYNTAX PATTERN EXAMPLE
stream stream <name> from <source> [arg] stream ticks from kafka "market.BTC"
window window <number><unit> window 5m, window 30s, window 1h
filter filter <boolean_expr> filter price > 20 and rsi(14) < 30
map map <assignment | signal> map buy 10%, map delta = price - 100
sink sink to <dest> [arg] sink to stdout, sink to postgres "trades"
compile compile to <python | wasm> compile to python, compile to wasm

3. BUILT-IN TECHNICAL FUNCTIONS

FUNCTION SIGNATURE DESCRIPTION
rsi rsi(period=14) Calculates Relative Strength Index over the sliding window ring buffer
sma sma(period=10) Computes Simple Moving Average of price over period
ema ema(period=10) Computes Exponential Moving Average of price

4. EXPRESSION EVALUATION RULES

- Numeric Coercion: Fields like price, rsi, volume, and timestamp are automatically coerced to floating-point or integer values.
- Percentage Syntax: 10% evaluates to 0.10.
- Action Shorthands: buy 10% sets row["signal"] = "BUY 0.1"; sell all sets row["signal"] = "SELL".