Skip to main content

draxl_parser/
lib.rs

1#![forbid(unsafe_code)]
2//! Hand-written lexer and parser for the current Draxl Rust profile.
3//!
4//! The crate is intentionally small and explicit:
5//!
6//! - `syntax` defines the token model shared by the lexer and parser
7//! - `lexer` turns source text into tokens
8//! - `parser` builds a typed Draxl AST from those tokens
9//! - `error` provides parse errors with stable span and line/column reporting
10
11mod error;
12mod lexer;
13mod parser;
14mod syntax;
15
16use draxl_ast::File;
17
18pub use error::ParseError;
19
20/// Parses Draxl source into the bootstrap AST.
21pub fn parse_file(source: &str) -> Result<File, ParseError> {
22    let tokens = lexer::lex(source)?;
23    parser::Parser::new(source, tokens).parse_file()
24}