1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Lemon — the strategy DSL for the citrus backtesting engine.
//!
//! Lemon is a small text language for writing trading strategies. A strategy
//! such as `close > sma(close, 2)` is *lowered* into a JSON `Expr` tree — the
//! serializable strategy AST ([`spec::Expr`]) — which the **yuzu** engine walks
//! against price/fundamental data to produce a position matrix. The same JSON
//! runs identically in-browser (WASM) and in the native batch runner.
//!
//! This crate does no math itself: it is a **surface syntax over the `Expr`
//! AST**. [`parse`] turns text into the JSON tree; [`format()`] renders a tree
//! back into canonical, re-indented text (a "gofmt for lemon"). All numeric
//! semantics live in the engine crate.
//!
//! # Layout
//!
//! - [`spec`] — the serializable [`Expr`] AST (JSON, tagged by `"op"`).
//! - [`services`] — editor language services (diagnostics, hover, completions),
//! pure functions of `(source, position)` that back both the WASM boundary and
//! the `lemon-lsp` language server.
//! - `dsl` (private) — the text syntax: `lex` (tokenizer), `parse` (text →
//! JSON), `ops` (surface-name ⇄ op-tag vocabulary), `print` (JSON → text).
//!
//! # Example
//!
//! ```
//! let tree = lemon::parse("close > sma(close, 2)").unwrap();
//! assert_eq!(tree["op"], "Gt");
//! // `format` renders a tree back to canonical DSL text.
//! let text = lemon::format(&tree);
//! assert_eq!(text, "(close > sma(close, 2))");
//! ```
//!
//! A [`ParseError`] carries a 1-based `line`/`col` and prints as
//! `line:col: message`.
//!
//! # Syntax reference
//!
//! The author-facing language reference (lexical rules, operators and
//! precedence, the `let`/call grammar, and the complete op table) lives in
//! `docs/lemon.md` in the repository.
pub use ;
pub use ;
pub use Expr;
/// Machine-readable op vocabulary: the catalog of callable ops (canonical names,
/// aliases, tags, ordered field specs, defaults, descriptions) plus the binary
/// operators. This is the single source of truth the schema generator
/// (`cargo run -p lemon-lang --example gen-schema`) reads to emit
/// `schema/op-catalog.json` and `schema/lemon-spec.schema.json`.