bynk_syntax/lib.rs
1//! Bynk's syntax foundation — the lowest leaf of the compiler crate set.
2//!
3//! This crate holds the modules every other layer depends *on* and none depend
4//! *up* from: the lexer, the parser and its AST, source [`span`]s, the
5//! [`keywords`] table, the structured [`CompileError`]
6//! type, and the [`diagnostics`] code registry (the single source of truth for
7//! `bynk.*` codes). Diagnostics, positions, and codes therefore cross every
8//! crate without an upward edge.
9//!
10//! Extracted from the old `bynkc` crate as slice 1 of the crate-decomposition
11//! track (ADRs 0099 layering, 0102 foundation boundary). Behaviour is unchanged
12//! from when these modules lived there.
13
14pub mod ast;
15pub mod decimal;
16pub mod diagnostics;
17pub mod error;
18pub mod fix;
19pub mod keywords;
20pub mod lexer;
21pub mod parser;
22pub mod print;
23pub mod semantic_tokens;
24pub mod span;
25
26pub use error::{CompileError, Severity, partition_by_severity};
27
28/// Maximum nesting depth the recursive-descent parser and the interpolation
29/// lexer accept before reporting a bounded-depth diagnostic instead of
30/// recursing another frame (#713). A compiler/LSP must never abort on
31/// malformed source, but every nesting level costs a stack frame, so an
32/// unbounded parser overflows and the process aborts (`SIGABRT`) on
33/// pathologically nested input — reachable on the 8 MB main thread (~880
34/// parenthesised levels) and, at ~8× smaller frames-to-stack ratio, in the
35/// low hundreds on the ~1 MB stacks the LSP and the in-browser playground
36/// run with.
37///
38/// The value sits well below the ~110 levels a 1 MB stack holds, leaving
39/// comfortable headroom, and far above any realistic hand-written or
40/// generated source (expression, type, and interpolation nesting past a
41/// handful is already exceptional). Source that exceeds it is rejected with
42/// a diagnostic rather than crashing the process.
43pub(crate) const MAX_NESTING_DEPTH: usize = 64;