Skip to main content

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 `bynkc` as slice 1 of the crate-decomposition track (ADRs
11//! 0099 layering, 0102 foundation boundary). Behaviour is unchanged from when
12//! these modules lived in `bynkc`; `bynkc` now re-exports them so its public
13//! API is preserved.
14
15pub mod ast;
16pub mod diagnostics;
17pub mod error;
18pub mod keywords;
19pub mod lexer;
20pub mod parser;
21pub mod span;
22
23pub use error::{CompileError, Severity, partition_by_severity};
24
25/// Maximum nesting depth the recursive-descent parser and the interpolation
26/// lexer accept before reporting a bounded-depth diagnostic instead of
27/// recursing another frame (#713). A compiler/LSP must never abort on
28/// malformed source, but every nesting level costs a stack frame, so an
29/// unbounded parser overflows and the process aborts (`SIGABRT`) on
30/// pathologically nested input — reachable on the 8 MB main thread (~880
31/// parenthesised levels) and, at ~8× smaller frames-to-stack ratio, in the
32/// low hundreds on the ~1 MB stacks the LSP and the in-browser playground
33/// run with.
34///
35/// The value sits well below the ~110 levels a 1 MB stack holds, leaving
36/// comfortable headroom, and far above any realistic hand-written or
37/// generated source (expression, type, and interpolation nesting past a
38/// handful is already exceptional). Source that exceeds it is rejected with
39/// a diagnostic rather than crashing the process.
40pub(crate) const MAX_NESTING_DEPTH: usize = 64;