Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(css/parser): Add parse_string_input #6441

Merged
merged 2 commits into from Nov 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion crates/swc_css_parser/src/lib.rs
Expand Up @@ -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();
Expand Down