diff --git a/crates/swc_css_parser/src/lib.rs b/crates/swc_css_parser/src/lib.rs index e6ac6451e75..c026f2302b7 100644 --- a/crates/swc_css_parser/src/lib.rs +++ b/crates/swc_css_parser/src/lib.rs @@ -49,7 +49,22 @@ pub fn parse_file<'a, T>( where Parser>>: Parse, { - let lexer = Lexer::new(StringInput::from(fm), config); + parse_string_input(StringInput::from(fm), config, errors) +} + +/// Parse a given [StringInput] as `T`. +/// +/// If there are syntax errors but if it was recoverable, it will be appended +/// to `errors`. +pub fn parse_string_input<'a, T>( + input: StringInput<'a>, + config: ParserConfig, + errors: &mut Vec, +) -> PResult +where + Parser>>: Parse, +{ + let lexer = Lexer::new(input, config); let mut parser = Parser::new(lexer, config); let res = parser.parse();