mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 17:55:06 +00:00
JSSpecCompiler: Try to get section number even if header parsing failed
This commit is contained in:
parent
6b30c4d2f0
commit
ed04aff1de
1 changed files with 9 additions and 5 deletions
|
@ -271,10 +271,16 @@ Optional<FailedTextParseDiagnostic> SpecificationClause::parse_header(XML::Node
|
|||
|
||||
TextParser parser(ctx, tokens, element);
|
||||
auto parse_result = parser.parse_clause_header();
|
||||
if (parse_result.is_error())
|
||||
return parser.get_diagnostic();
|
||||
if (parse_result.is_error()) {
|
||||
// Still try to at least scavenge section number.
|
||||
if (tokens.size() && tokens[0].type == TokenType::SectionNumber)
|
||||
ctx.current_logical_scope().section = MUST(String::from_utf8(tokens[0].data));
|
||||
|
||||
m_header = parse_result.value();
|
||||
return parser.get_diagnostic();
|
||||
}
|
||||
|
||||
m_header = parse_result.release_value();
|
||||
ctx.current_logical_scope().section = MUST(String::from_utf8(m_header.section_number));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -295,8 +301,6 @@ void SpecificationClause::parse(XML::Node const* element)
|
|||
return;
|
||||
}
|
||||
header_parse_error = parse_header(child);
|
||||
if (!header_parse_error.has_value())
|
||||
ctx.current_logical_scope().section = MUST(String::from_utf8(m_header.section_number));
|
||||
} else {
|
||||
if (element.name == tag_h1) {
|
||||
ctx.diag().error(ctx.location_from_xml_offset(child->offset),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue