feat(css/parser): Add parse_string_input (#6441)

This commit is contained in:
Donny/강동윤 2022-11-15 17:05:43 +09:00 committed by GitHub
parent 4d6b182dc2
commit 9600308108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,7 +49,22 @@ pub fn parse_file<'a, T>(
where
Parser<Lexer<StringInput<'a>>>: Parse<T>,
{
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<Error>,
) -> PResult<T>
where
Parser<Lexer<StringInput<'a>>>: Parse<T>,
{
let lexer = Lexer::new(input, config);
let mut parser = Parser::new(lexer, config);
let res = parser.parse();