1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![deny(unused_must_use)]
3#![deny(clippy::all)]
4#![allow(clippy::needless_return)]
5#![allow(clippy::nonminimal_bool)]
6#![allow(clippy::wrong_self_convention)]
7
8use swc_common::{input::StringInput, SourceFile};
9use swc_xml_ast::Document;
10
11use crate::{
12 error::Error,
13 lexer::Lexer,
14 parser::{PResult, Parser, ParserConfig},
15};
16
17pub mod error;
18pub mod lexer;
19pub mod parser;
20
21pub fn parse_file_as_document(
26 fm: &SourceFile,
27 config: ParserConfig,
28 errors: &mut Vec<Error>,
29) -> PResult<Document> {
30 let lexer = Lexer::new(StringInput::from(fm));
31 let mut parser = Parser::new(lexer, config);
32 let result = parser.parse_document();
33
34 errors.extend(parser.take_errors());
35
36 result
37}