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
//! Parser for the Nova programming language.
//!
//! Converts a `Vec<Spanned<Token>>` (from `nova-lexer`) into an `ast::File`.
//! A hand-written recursive-descent parser: after an error it skips to the next
//! item or statement boundary and keeps going.
//!
//! # Usage
//!
//! ```
//! use nova_diagnostics::FileDb;
//! use nova_lexer::lex;
//! use nova_parser::parse;
//!
//! let mut db = FileDb::new();
//! let file_id = db.add("main.nova", "fn main() {}");
//! let source = db.get_source(file_id).unwrap();
//! let (tokens, _lex_errs) = lex(source, file_id);
//! let (ast, _parse_errs) = parse(&tokens, file_id);
//! ```
pub use ParseError;
use File;
use ;
use Token;
/// Parse a token stream into a `File` AST.
///
/// Returns `Some(File)` even when errors are present: the parser skips to the
/// next item or statement boundary after an error and keeps going. It
/// currently never returns `None`.
/// What [`parse_recovering`] returns.
/// [`parse`], also naming the items it dropped (spec
/// `docs/superpowers/specs/2026-10-08-phase-3-2-lsp-core-design.md` ยง3.2).
/// The language server's analysis calls this; every other caller uses
/// [`parse`], whose result is the same file and errors.