1mod diagnostic;
4mod lexer;
5mod parser;
6mod source_map;
7
8pub const MAX_INPUT_SIZE: usize = 64 * 1024 * 1024;
10
11pub use diagnostic::{
12 Diagnostic, DiagnosticCode, ParseError, Parsed, Severity, SourcePosition, SourceSpan,
13};
14
15pub fn parse(input: &[u8]) -> Result<Parsed, ParseError> {
17 if input.len() > MAX_INPUT_SIZE {
18 return Err(ParseError::InputTooLarge);
19 }
20 if let Some(offset) = input.iter().position(|byte| *byte == 0) {
21 return Err(ParseError::NulByte { offset });
22 }
23 let source = std::str::from_utf8(input).map_err(|error| ParseError::InvalidUtf8 {
24 valid_up_to: error.valid_up_to(),
25 error_len: error.error_len(),
26 })?;
27 parser::Parser::new(input, source).parse()
28}