Skip to main content

fatou_parser/
parser.rs

1//! The parse pipeline: `lex → parse_expr (Pratt) + structural (recursive
2//! descent) → events → build_tree → rowan CST`.
3//!
4//! Losslessness is the core invariant: `reconstruct(text) == text` for all
5//! inputs. The grammar is a walking skeleton over a Julia subset and grows
6//! incrementally (see `TODO.md`). Incremental reparse splicing lives in
7//! [`reparse`] (a single edit) and [`reparse_edits`] (a chain of them); both
8//! return `None` when no strategy applies, and the host's salsa layer
9//! (`fatou::incremental`) then does a full parse.
10
11mod context;
12mod core;
13mod cursor;
14mod diagnostics;
15mod edit;
16mod events;
17mod expr;
18mod lexer;
19mod recovery;
20mod reparse;
21mod sexpr;
22mod structural;
23mod tree_builder;
24mod unescape;
25mod unicode_ident;
26mod unicode_ops;
27
28pub use core::{ParseDiagnostic, ParseOutput, parse, reconstruct};
29// Semver-loose: exposed for the fatou CLI's completion and semantic layers,
30// not a stable part of this crate's API.
31pub use lexer::{KEYWORDS, is_ident_continue, is_ident_start};
32pub use reparse::{
33    Edit, ReparseTier, Reparsed, apply_edits, diff_edit, reparse, reparse_edits, try_apply_edits,
34};
35// Test support, not API: the in-crate Tenet-4 assert and the
36// `tests/incremental_reparse.rs` oracle harness share this one definition so
37// they can never diverge, which is the only reason it is `pub` at all.
38#[doc(hidden)]
39pub use reparse::fingerprint;
40pub use sexpr::{normalize_sexpr, to_juliasyntax_sexpr};
41// The `lex` bench's entry point. Gated on `bench` so tokenizing on its own —
42// which no consumer has a reason to do — never becomes part of the API.
43#[cfg(feature = "bench")]
44pub fn token_count(input: &str) -> usize {
45    lexer::lex(input).len()
46}
47// A lossless CST hands out a literal's *source*; a consumer reading it as data
48// (the `include` path resolver) needs the value it denotes.
49pub use unescape::{StringDecodeError, string_value};