cove_syntax/lib.rs
1//! Lexer, AST, and parser for the Cove surface language.
2
3pub mod ast;
4pub mod format;
5pub mod lexer;
6pub mod number;
7pub mod parser;
8pub mod token;
9
10use cove_diag::{Diagnostic, FileId, SourceMap};
11
12/// Lexes, parses, and numbers one `.cove` file.
13///
14/// Numbering happens here rather than in the parser so that every caller gets
15/// it: a unit this function returns has an [`ast::ExprId`] on every
16/// expression, and none of them is [`ast::ExprId::UNSET`].
17pub fn parse_file(sources: &SourceMap, file: FileId) -> Result<ast::SourceUnit, Vec<Diagnostic>> {
18 let tokens = lexer::lex(sources, file)?;
19 let mut unit = parser::parse(sources, file, tokens)?;
20 number::number_unit(&mut unit);
21 Ok(unit)
22}