parse_all_files

Function parse_all_files 

Source
pub fn parse_all_files(
    sources: &[SourceFile<'_>],
) -> MultiErrorResult<ParsedProgram>
Expand description

Parse multiple source files with a shared interner.

Each file is lexed and parsed sequentially with a single shared interner. This ensures Spur values are consistent across all files, enabling cross-file symbol resolution during semantic analysis.

Note: This uses sequential parsing rather than parallel to share the interner. A future optimization could add parallel parsing with interner merging and AST Spur remapping.

§Arguments

  • sources - Slice of source files to parse

§Returns

A ParsedProgram containing all parsed files and the shared interner, or errors from any file that failed to parse.

§Example

use gruel_compiler::{SourceFile, parse_all_files};
use gruel_span::FileId;

let sources = vec![
    SourceFile::new("main.gruel", "fn main() -> i32 { 0 }", FileId::new(1)),
    SourceFile::new("utils.gruel", "fn helper() -> i32 { 42 }", FileId::new(2)),
];
let program = parse_all_files(&sources)?;