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