Language Model
Tea Script is a script language. A file begins with a declaration header, then contains statements that the compiler lowers into TSGraph semantic IR.
Program Shape
Section titled “Program Shape”Program ::= Declaration Statement*Declaration ::= IndicatorDeclaration | StrategyDeclarationIndicatorDeclaration ::= "indicator" "(" StringLiteral ")"StrategyDeclaration ::= "strategy" "(" StringLiteral ")"Library headers are reserved language-level forms and remain syntax errors until the grammar and semantic rules own them.
Statements And Expressions
Section titled “Statements And Expressions”Tea Script v0 supports:
- assignment statements:
period = input.int(20); - tuple assignment for tuple-returning builtins:
[macd, signal, hist] = ta.macd(close, 12, 26, 9); - expression statements for accepted effect calls;
ifstatements over accepted expressions and effect forms;- object expressions for supported option objects;
- arithmetic, comparison, boolean, ternary, call, member, and lookback expressions.
Runtime Contracts
Section titled “Runtime Contracts”- Source series resolve through the bound main input.
- Lookback expressions are no-lookahead reads over prior aligned rows.
- Stateful TA functions own prefix state and warmup through TSGraph lowering.
input.*declarations produce parameter descriptors and compile-time override points.output(...)defines persisted output fields.plot(...),draw.*,log.*,alert.*, and strategy calls are effects in semantic IR.- Strategy order effects are valid only inside
strategy(...)scripts.
Compatibility Boundary
Section titled “Compatibility Boundary”Tea Script is Pine-inspired, but Pine compatibility is not the durable contract. Compatibility is useful when it helps users and agents migrate scripts. The actual contract is the grammar, semantic rules, diagnostics, capability manifest, and TSGraph lowering behavior owned by the compiler.